From 7efd60642f69a650396fe42d37ac9740a339bd59 Mon Sep 17 00:00:00 2001 From: Fanli2 <374861669@qq.com> Date: Tue, 10 Nov 2020 11:21:53 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B9=BF=E5=91=8A=E7=AE=A1=E7=90=86=EF=BC=8C?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=A4=87=E4=BB=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Common/Helper.php | 38 ++ app/Common/Utils/Database.php | 209 ++++++++ app/Common/Utils/HttpDownload.php | 260 +++++++++ app/Common/Utils/Utils.php | 48 ++ app/Common/Utils/Zip.php | 502 ++++++++++++++++++ app/Common/function.php | 29 + app/Http/Controllers/Admin/AdController.php | 113 ++++ .../Controllers/Admin/DatabaseController.php | 388 ++++++++++++++ app/Http/Controllers/Home/AdController.php | 43 ++ app/Http/Controllers/Home/PageController.php | 6 +- app/Http/Logic/AdLogic.php | 149 ++++++ app/Http/Model/Ad.php | 164 ++++++ app/Http/Requests/AdRequest.php | 102 ++++ database_backup/.gitignore | 2 + lqycms.sql | 43 +- public/index.php | 3 + resources/views/admin/ad/add.blade.php | 74 +++ resources/views/admin/ad/edit.blade.php | 74 +++ resources/views/admin/ad/index.blade.php | 26 + .../views/admin/database/index.blade.php | 86 +++ resources/views/admin/database/index.html | 86 +++ resources/views/admin/menu/add.blade.php | 6 +- resources/views/admin/menu/edit.blade.php | 6 +- routes/web.php | 15 +- 24 files changed, 2456 insertions(+), 16 deletions(-) create mode 100644 app/Common/Utils/Database.php create mode 100644 app/Common/Utils/HttpDownload.php create mode 100644 app/Common/Utils/Utils.php create mode 100644 app/Common/Utils/Zip.php create mode 100644 app/Http/Controllers/Admin/AdController.php create mode 100644 app/Http/Controllers/Admin/DatabaseController.php create mode 100644 app/Http/Controllers/Home/AdController.php create mode 100644 app/Http/Logic/AdLogic.php create mode 100644 app/Http/Model/Ad.php create mode 100644 app/Http/Requests/AdRequest.php create mode 100644 database_backup/.gitignore create mode 100644 resources/views/admin/ad/add.blade.php create mode 100644 resources/views/admin/ad/edit.blade.php create mode 100644 resources/views/admin/ad/index.blade.php create mode 100644 resources/views/admin/database/index.blade.php create mode 100644 resources/views/admin/database/index.html diff --git a/app/Common/Helper.php b/app/Common/Helper.php index faaca08..d337090 100644 --- a/app/Common/Helper.php +++ b/app/Common/Helper.php @@ -429,4 +429,42 @@ class Helper return $str; } + + //判断是移动端访问 + public static function is_mobile_access() + { + // 如果有HTTP_X_WAP_PROFILE则一定是移动设备 + if (isset ($_SERVER['HTTP_X_WAP_PROFILE'])) { + return true; + } + //此条摘自TPM智能切换模板引擎,适合TPM开发 + if (isset ($_SERVER['HTTP_CLIENT']) && 'PhoneClient' == $_SERVER['HTTP_CLIENT']) { + return true; + } + //如果via信息含有wap则一定是移动设备,部分服务商会屏蔽该信息 + if (isset ($_SERVER['HTTP_VIA'])) { + //找不到为flase,否则为true + return stristr($_SERVER['HTTP_VIA'], 'wap') ? true : false; + } + //判断手机发送的客户端标志,兼容性有待提高 + if (isset ($_SERVER['HTTP_USER_AGENT'])) { + $clientkeywords = array( + 'nokia', 'sony', 'ericsson', 'mot', 'samsung', 'htc', 'sgh', 'lg', 'sharp', 'sie-', 'philips', 'panasonic', 'alcatel', 'lenovo', 'iphone', 'ipod', 'blackberry', 'meizu', 'android', 'netfront', 'symbian', 'ucweb', 'windowsce', 'palm', 'operamini', 'operamobi', 'openwave', 'nexusone', 'cldc', 'midp', 'wap', 'mobile' + ); + //从HTTP_USER_AGENT中查找手机浏览器的关键字 + if (preg_match("/(" . implode('|', $clientkeywords) . ")/i", strtolower($_SERVER['HTTP_USER_AGENT']))) { + return true; + } + } + //协议法,因为有可能不准确,放到最后判断 + if (isset ($_SERVER['HTTP_ACCEPT'])) { + // 如果只支持wml并且不支持html那一定是移动设备 + // 如果支持wml和html但是wml在html之前则是移动设备 + if ((strpos($_SERVER['HTTP_ACCEPT'], 'vnd.wap.wml') !== false) && (strpos($_SERVER['HTTP_ACCEPT'], 'text/html') === false || (strpos($_SERVER['HTTP_ACCEPT'], 'vnd.wap.wml') < strpos($_SERVER['HTTP_ACCEPT'], 'text/html')))) { + return true; + } + } + + return false; + } } \ No newline at end of file diff --git a/app/Common/Utils/Database.php b/app/Common/Utils/Database.php new file mode 100644 index 0000000..55f62b6 --- /dev/null +++ b/app/Common/Utils/Database.php @@ -0,0 +1,209 @@ +file = $file; + $this->config = $config; + } + + /** + * 打开一个卷,用于写入数据 + * @param integer $size 写入数据的大小 + */ + private function open($size) + { + if ($this->fp) { + $this->size += $size; + if ($this->size > $this->config['part']) { + $this->config['compress'] ? @gzclose($this->fp) : @fclose($this->fp); + $this->fp = null; + $this->file['part']++; + session('backup_file', $this->file); + $this->create(); + } + } else { + $backuppath = $this->config['path']; + $filename = "{$backuppath}{$this->file['name']}-{$this->file['part']}.sql"; + if ($this->config['compress']) { + $filename = "{$filename}.gz"; + $this->fp = @gzopen($filename, "a{$this->config['level']}"); + } else { + $this->fp = @fopen($filename, 'a'); + } + $this->size = filesize($filename) + $size; + } + } + + /** + * 写入初始数据 + * @return boolean true - 写入成功,false - 写入失败 + */ + public function create() + { + $sql = "-- -----------------------------\n"; + $sql .= "-- Think MySQL Data Transfer \n"; + $sql .= "-- \n"; + $sql .= "-- Host : " . config('database.hostname') . "\n"; + $sql .= "-- Port : " . config('database.hostport') . "\n"; + $sql .= "-- Database : " . config('database.database') . "\n"; + $sql .= "-- \n"; + $sql .= "-- Part : #{$this->file['part']}\n"; + $sql .= "-- Date : " . date("Y-m-d H:i:s") . "\n"; + $sql .= "-- -----------------------------\n\n"; + $sql .= "SET FOREIGN_KEY_CHECKS = 0;\n\n"; + return $this->write($sql); + } + + /** + * 写入SQL语句 + * @param string $sql 要写入的SQL语句 + * @return boolean true - 写入成功,false - 写入失败 + */ + private function write($sql) + { + $size = strlen($sql); + + //由于压缩原因,无法计算出压缩后的长度,这里假设压缩率为50%, + //一般情况压缩率都会高于50%; + $size = $this->config['compress'] ? $size / 2 : $size; + + $this->open($size); + return $this->config['compress'] ? @gzwrite($this->fp, $sql) : @fwrite($this->fp, $sql); + } + + /** + * 备份表结构 + * @param string $table 表名 + * @param integer $start 起始行数 + * @return boolean false - 备份失败 + */ + public function backup($table, $start) + { + //备份表结构 + if (0 == $start) { + $result = Db::query("SHOW CREATE TABLE `{$table}`"); + $sql = "\n"; + $sql .= "-- -----------------------------\n"; + $sql .= "-- Table structure for `{$table}`\n"; + $sql .= "-- -----------------------------\n"; + $sql .= "DROP TABLE IF EXISTS `{$table}`;\n"; + //$sql .= trim($result[0]['Create Table']) . ";\n\n"; + $sql .= trim($result[0]['create table']) . ";\n\n"; + if (false === $this->write($sql)) { + return false; + } + } + + //数据总数 + $result = Db::query("SELECT COUNT(*) AS count FROM `{$table}`"); + $count = $result['0']['count']; + + //备份表数据 + if ($count) { + //写入数据注释 + if (0 == $start) { + $sql = "-- -----------------------------\n"; + $sql .= "-- Records of `{$table}`\n"; + $sql .= "-- -----------------------------\n"; + $this->write($sql); + } + + //备份数据记录 + $result = Db::query("SELECT * FROM `{$table}` LIMIT {$start}, 1000"); + foreach ($result as $row) { + //$row = array_map('mysql_real_escape_string', $row); + $row = array_map('mysql_escape_string', $row); + $sql = "INSERT INTO `{$table}` VALUES ('" . implode("', '", $row) . "');\n"; + if (false === $this->write($sql)) { + return false; + } + } + + //还有更多数据 + if ($count > $start + 1000) { + return array($start + 1000, $count); + } + } + + //备份下一表 + return 0; + } + + public function import($start) + { + if ($this->config['compress']) { + $gz = gzopen($this->file[1], 'r'); + $size = 0; + } else { + $size = filesize($this->file[1]); + $gz = fopen($this->file[1], 'r'); + } + + $sql = ''; + if ($start) { + $this->config['compress'] ? gzseek($gz, $start) : fseek($gz, $start); + } + + for ($i = 0; $i < 1000; $i++) { + $sql .= $this->config['compress'] ? gzgets($gz) : fgets($gz); + if (preg_match('/.*;$/', trim($sql))) { + //if(false !== $db->query($sql)){ + if (false !== Db::execute($sql)) { + $start += strlen($sql); + } else { + return false; + } + $sql = ''; + } elseif ($this->config['compress'] ? gzeof($gz) : feof($gz)) { + return 0; + } + } + + return array($start, $size); + } + + /** + * 析构方法,用于关闭文件资源 + */ + public function __destruct() + { + $this->config['compress'] ? @gzclose($this->fp) : @fclose($this->fp); + } +} \ No newline at end of file diff --git a/app/Common/Utils/HttpDownload.php b/app/Common/Utils/HttpDownload.php new file mode 100644 index 0000000..6b7cd4f --- /dev/null +++ b/app/Common/Utils/HttpDownload.php @@ -0,0 +1,260 @@ +m_url = $url; + if (is_array($urls)) { + $this->m_host = $urls["host"]; + if (!empty($urls["scheme"])) $this->m_scheme = $urls["scheme"]; + if (!empty($urls["user"])) $this->m_user = $urls["user"]; + if (!empty($urls["pass"])) $this->m_pass = $urls["pass"]; + if (!empty($urls["port"])) $this->m_port = $urls["port"]; + if (!empty($urls["path"])) $this->m_path = $urls["path"]; + $this->m_urlpath = $this->m_path; + if (!empty($urls["query"])) { + $this->m_query = $urls["query"]; + $this->m_urlpath .= "?" . $this->m_query; + } + } + } + + /** + * 打开指定网址 + */ + function OpenUrl($url) + { + #重设各参数 + $this->m_url = ""; + $this->m_urlpath = ""; + $this->m_scheme = "http"; + $this->m_host = ""; + $this->m_port = "80"; + $this->m_user = ""; + $this->m_pass = ""; + $this->m_path = "/"; + $this->m_query = ""; + $this->m_error = ""; + $this->m_httphead = ""; + $this->m_html = ""; + $this->Close(); + #初始化系统 + $this->PrivateInit($url); + $this->PrivateStartSession(); + } + + /** + * 获得某操作错误的原因 + */ + public function printError() + { + echo "错误信息:" . $this->m_error; + echo "具体返回头:
"; + foreach ($this->m_httphead as $k => $v) { + echo "$k => $v
\r\n"; + } + } + + /** + * 判别用Get方法发送的头的应答结果是否正确 + */ + public function IsGetOK() + { + if (ereg("^2", $this->GetHead("http-state"))) { + return true; + } else { + $this->m_error .= $this->GetHead("http-state") . " - " . $this->GetHead("http-describe") . "
"; + return false; + } + } + + /** + * 看看返回的网页是否是text类型 + */ + public function IsText() + { + if (ereg("^2", $this->GetHead("http-state")) && eregi("^text", $this->GetHead("content-type"))) { + return true; + } else { + $this->m_error .= "内容为非文本类型
"; + return false; + } + } + + /** + * 判断返回的网页是否是特定的类型 + */ + public function IsContentType($ctype) + { + if (ereg("^2", $this->GetHead("http-state")) && $this->GetHead("content-type") == strtolower($ctype)) { + return true; + } else { + $this->m_error .= "类型不对 " . $this->GetHead("content-type") . "
"; + return false; + } + } + + /** + * 用 HTTP 协议下载文件 + */ + public function SaveToBin($savefilename) + { + if (!$this->IsGetOK()) return false; + if (@feof($this->m_fp)) { + $this->m_error = "连接已经关闭!"; + return false; + } + $fp = fopen($savefilename, "w") or die("写入文件 $savefilename 失败!"); + while (!feof($this->m_fp)) { + @fwrite($fp, fgets($this->m_fp, 256)); + } + @fclose($this->m_fp); + return true; + } + + /** + * 保存网页内容为 Text 文件 + */ + public function SaveToText($savefilename) + { + if ($this->IsText()) { + $this->SaveBinFile($savefilename); + } else { + return ""; + } + } + + /** + * 用 HTTP 协议获得一个网页的内容 + */ + public function GetHtml() + { + if (!$this->IsText()) return ""; + if ($this->m_html != "") return $this->m_html; + if (!$this->m_fp || @feof($this->m_fp)) return ""; + while (!feof($this->m_fp)) { + $this->m_html .= fgets($this->m_fp, 256); + } + @fclose($this->m_fp); + return $this->m_html; + } + + /** + * 开始 HTTP 会话 + */ + public function PrivateStartSession() + { + if (!$this->PrivateOpenHost()) { + $this->m_error .= "打开远程主机出错!"; + return false; + } + if ($this->GetHead("http-edition") == "HTTP/1.1") { + $httpv = "HTTP/1.1"; + } else { + $httpv = "HTTP/1.0"; + } + fputs($this->m_fp, "GET " . $this->m_urlpath . " $httpv\r\n"); + fputs($this->m_fp, "Host: " . $this->m_host . "\r\n"); + fputs($this->m_fp, "Accept: */*\r\n"); + fputs($this->m_fp, "User-Agent: Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.2)\r\n"); + #HTTP1.1协议必须指定文档结束后关闭链接,否则读取文档时无法使用feof判断结束 + if ($httpv == "HTTP/1.1") { + fputs($this->m_fp, "Connection: Close\r\n\r\n"); + } else { + fputs($this->m_fp, "\r\n"); + } + $httpstas = fgets($this->m_fp, 256); + $httpstas = split(" ", $httpstas); + $this->m_httphead["http-edition"] = trim($httpstas[0]); + $this->m_httphead["http-state"] = trim($httpstas[1]); + $this->m_httphead["http-describe"] = ""; + for ($i = 2; $i < count($httpstas); $i++) { + $this->m_httphead["http-describe"] .= " " . trim($httpstas[$i]); + } + while (!feof($this->m_fp)) { + $line = str_replace("\"", "", trim(fgets($this->m_fp, 256))); + if ($line == "") break; + if (ereg(":", $line)) { + $lines = split(":", $line); + $this->m_httphead[strtolower(trim($lines[0]))] = trim($lines[1]); + } + } + } + + /** + * 获得一个Http头的值 + */ + public function GetHead($headname) + { + $headname = strtolower($headname); + if (isset($this->m_httphead[$headname])) { + return $this->m_httphead[$headname]; + } else { + return ""; + } + } + + /** + * 打开连接 + */ + public function PrivateOpenHost() + { + if ($this->m_host == "") return false; + $this->m_fp = @fsockopen($this->m_host, $this->m_port, $errno, $errstr, 10); + if (!$this->m_fp) { + $this->m_error = $errstr; + return false; + } else { + return true; + } + } + + /** + * 关闭连接 + */ + public function Close() + { + @fclose($this->m_fp); + } +} +/* +#两种使用方法,分别如下: + +#打开网页 +$httpdown = new HttpDownload(); +$httpdown->OpenUrl("http://www.google.com.hk"); +echo $httpdown->GetHtml(); +$httpdown->Close(); + + +#下载文件 +$file = new HttpDownload(); # 实例化类 +$file->OpenUrl("http://www.ti.com.cn/cn/lit/an/rust020/rust020.pdf"); # 远程文件地址 +$file->SaveToBin("rust020.pdf"); # 保存路径及文件名 +$file->Close(); +*/ \ No newline at end of file diff --git a/app/Common/Utils/Utils.php b/app/Common/Utils/Utils.php new file mode 100644 index 0000000..28c42bc --- /dev/null +++ b/app/Common/Utils/Utils.php @@ -0,0 +1,48 @@ +debug($url, $fileContent, $header, $result); + return $status; + } +} \ No newline at end of file diff --git a/app/Common/Utils/Zip.php b/app/Common/Utils/Zip.php new file mode 100644 index 0000000..f55a730 --- /dev/null +++ b/app/Common/Utils/Zip.php @@ -0,0 +1,502 @@ +visitFile(文件夹路径); + // print "当前文件夹的文件:

\r\n"; + // foreach($filelist as $file) + // printf("%s
\r\n", $file); + // ------------------------------------------------------ // + var $fileList = array(); + + public function visitFile($path) + { + global $fileList; + $path = str_replace("\\", "/", $path); + $fdir = dir($path); + while (($file = $fdir->read()) !== false) { + if ($file == '.' || $file == '..') { + continue; + } + $pathSub = preg_replace("*/{2,}*", "/", $path . "/" . $file); // 替换多个反斜杠 + $fileList[] = is_dir($pathSub) ? $pathSub . "/" : $pathSub; + if (is_dir($pathSub)) { + $this->visitFile($pathSub); + } + } + $fdir->close(); + return $fileList; + } + + private function unix2DosTime($unixtime = 0) + { + $timearray = ($unixtime == 0) ? getdate() : getdate($unixtime); + if ($timearray['year'] < 1980) { + $timearray['year'] = 1980; + $timearray['mon'] = 1; + $timearray['mday'] = 1; + $timearray['hours'] = 0; + $timearray['minutes'] = 0; + $timearray['seconds'] = 0; + } + return (($timearray['year'] - 1980) << 25) + | ($timearray['mon'] << 21) + | ($timearray['mday'] << 16) + | ($timearray['hours'] << 11) + | ($timearray['minutes'] << 5) + | ($timearray['seconds'] >> 1); + } + + var $old_offset = 0; + + private function addFile($data, $filename, $time = 0) + { + $filename = str_replace('\\', '/', $filename); + $dtime = dechex($this->unix2DosTime($time)); + $hexdtime = '\x' . $dtime[6] . $dtime[7] + . '\x' . $dtime[4] . $dtime[5] + . '\x' . $dtime[2] . $dtime[3] + . '\x' . $dtime[0] . $dtime[1]; + eval('$hexdtime = "' . $hexdtime . '";'); + $fr = "\x50\x4b\x03\x04"; + $fr .= "\x14\x00"; + $fr .= "\x00\x00"; + $fr .= "\x08\x00"; + $fr .= $hexdtime; + $unc_len = strlen($data); + $crc = crc32($data); + $zdata = gzcompress($data); + $c_len = strlen($zdata); + $zdata = substr(substr($zdata, 0, strlen($zdata) - 4), 2); + $fr .= pack('V', $crc); + $fr .= pack('V', $c_len); + $fr .= pack('V', $unc_len); + $fr .= pack('v', strlen($filename)); + $fr .= pack('v', 0); + $fr .= $filename; + $fr .= $zdata; + $fr .= pack('V', $crc); + $fr .= pack('V', $c_len); + $fr .= pack('V', $unc_len); + $this->datasec[] = $fr; + $new_offset = strlen(implode('', $this->datasec)); + $cdrec = "\x50\x4b\x01\x02"; + $cdrec .= "\x00\x00"; + $cdrec .= "\x14\x00"; + $cdrec .= "\x00\x00"; + $cdrec .= "\x08\x00"; + $cdrec .= $hexdtime; + $cdrec .= pack('V', $crc); + $cdrec .= pack('V', $c_len); + $cdrec .= pack('V', $unc_len); + $cdrec .= pack('v', strlen($filename)); + $cdrec .= pack('v', 0); + $cdrec .= pack('v', 0); + $cdrec .= pack('v', 0); + $cdrec .= pack('v', 0); + $cdrec .= pack('V', 32); + $cdrec .= pack('V', $this->old_offset); + $this->old_offset = $new_offset; + $cdrec .= $filename; + $this->ctrl_dir[] = $cdrec; + } + + var $eof_ctrl_dir = "\x50\x4b\x05\x06\x00\x00\x00\x00"; + + private function file() + { + $data = implode('', $this->datasec); + $ctrldir = implode('', $this->ctrl_dir); + return $data + . $ctrldir + . $this->eof_ctrl_dir + . pack('v', sizeof($this->ctrl_dir)) + . pack('v', sizeof($this->ctrl_dir)) + . pack('V', strlen($ctrldir)) + . pack('V', strlen($data)) + . "\x00\x00"; + } + // ------------------------------------------------------ // + // #压缩到服务器 + // + // $archive = new PHPZip(); + // $archive->Zip("需压缩的文件所在目录", "ZIP压缩文件名"); + // ------------------------------------------------------ // + public function zip($dir, $saveName) + { + if (@!function_exists('gzcompress')) { + return; + } + ob_end_clean(); + $filelist = $this->visitFile($dir); + if (count($filelist) == 0) { + return; + } + foreach ($filelist as $file) { + if (!file_exists($file) || !is_file($file)) { + continue; + } + $fd = fopen($file, "rb"); + $content = @fread($fd, filesize($file)); + fclose($fd); + // 1.删除$dir的字符(./folder/file.txt删除./folder/) + // 2.如果存在/就删除(/file.txt删除/) + $file = substr($file, strlen($dir)); + if (substr($file, 0, 1) == "\\" || substr($file, 0, 1) == "/") { + $file = substr($file, 1); + } + $this->addFile($content, $file); + } + $out = $this->file(); + $fp = fopen($saveName, "wb"); + fwrite($fp, $out, strlen($out)); + fclose($fp); + } + // ------------------------------------------------------ // + // #压缩并直接下载 + // + // $archive = new PHPZip(); + // $archive->ZipAndDownload("需压缩的文件所在目录"); + // ------------------------------------------------------ // + public function ZipAndDownload($dir) + { + if (@!function_exists('gzcompress')) { + return; + } + ob_end_clean(); + $filelist = $this->visitFile($dir); + if (count($filelist) == 0) { + return; + } + foreach ($filelist as $file) { + if (!file_exists($file) || !is_file($file)) { + continue; + } + $fd = fopen($file, "rb"); + $content = @fread($fd, filesize($file)); + fclose($fd); + // 1.删除$dir的字符(./folder/file.txt删除./folder/) + // 2.如果存在/就删除(/file.txt删除/) + $file = substr($file, strlen($dir)); + if (substr($file, 0, 1) == "\\" || substr($file, 0, 1) == "/") { + $file = substr($file, 1); + } + $this->addFile($content, $file); + } + $out = $this->file(); + @header('Content-Encoding: none'); + @header('Content-Type: application/zip'); + @header('Content-Disposition: attachment ; filename=Farticle' . date("YmdHis", time()) . '.zip'); + @header('Pragma: no-cache'); + @header('Expires: 0'); + print($out); + } + /********************************************************** + * 解压部分 + **********************************************************/ + // ------------------------------------------------------ // + // ReadCentralDir($zip, $zipfile) + // $zip是经过@fopen($zipfile, 'rb')打开的 + // $zipfile是zip文件的路径 + // ------------------------------------------------------ // + private function ReadCentralDir($zip, $zipfile) + { + $size = filesize($zipfile); + $max_size = ($size < 277) ? $size : 277; + @fseek($zip, $size - $max_size); + $pos = ftell($zip); + $bytes = 0x00000000; + while ($pos < $size) { + $byte = @fread($zip, 1); + $bytes = ($bytes << 8) | Ord($byte); + $pos++; + // 如果不是windows服务器,则要以504b0506作为对比 + if (strrpos(strtolower(PHP_OS), "win") === FALSE && substr(dechex($bytes), -8, 8) == '504b0506') { + break; + } // 如果是windows服务器,则要以0x504b0506作为对比 + elseif ($bytes == 0x504b0506) { + break; + } + } + $data = unpack('vdisk/vdisk_start/vdisk_entries/ventries/Vsize/Voffset/vcomment_size', fread($zip, 18)); + $centd['comment'] = ($data['comment_size'] != 0) ? fread($zip, $data['comment_size']) : ''; // 注释 + $centd['entries'] = $data['entries']; + $centd['disk_entries'] = $data['disk_entries']; + $centd['offset'] = $data['offset']; + $centd['disk_start'] = $data['disk_start']; + $centd['size'] = $data['size']; + $centd['disk'] = $data['disk']; + return $centd; + } + + private function ReadCentralFileHeaders($zip) + { + $binary_data = fread($zip, 46); + $header = unpack('vchkid/vid/vversion/vversion_extracted/vflag/vcompression/vmtime/vmdate/Vcrc/Vcompressed_size/Vsize/vfilename_len/vextra_len/vcomment_len/vdisk/vinternal/Vexternal/Voffset', $binary_data); + $header['filename'] = ($header['filename_len'] != 0) ? fread($zip, $header['filename_len']) : ''; + $header['extra'] = ($header['extra_len'] != 0) ? fread($zip, $header['extra_len']) : ''; + $header['comment'] = ($header['comment_len'] != 0) ? fread($zip, $header['comment_len']) : ''; + if ($header['mdate'] && $header['mtime']) { + $hour = ($header['mtime'] & 0xF800) >> 11; + $minute = ($header['mtime'] & 0x07E0) >> 5; + $seconde = ($header['mtime'] & 0x001F) * 2; + $year = (($header['mdate'] & 0xFE00) >> 9) + 1980; + $month = ($header['mdate'] & 0x01E0) >> 5; + $day = $header['mdate'] & 0x001F; + $header['mtime'] = mktime($hour, $minute, $seconde, $month, $day, $year); + } else { + $header['mtime'] = time(); + } + $header['stored_filename'] = $header['filename']; + $header['status'] = 'ok'; + if (substr($header['filename'], -1) == '/') { + $header['external'] = 0x41FF0010; + } // 判断是否文件夹 + return $header; + } + + private function ReadFileHeader($zip) + { + $binary_data = fread($zip, 30); + $data = unpack('vchk/vid/vversion/vflag/vcompression/vmtime/vmdate/Vcrc/Vcompressed_size/Vsize/vfilename_len/vextra_len', $binary_data); + $header['filename'] = fread($zip, $data['filename_len']); + $header['extra'] = ($data['extra_len'] != 0) ? fread($zip, $data['extra_len']) : ''; + $header['compression'] = $data['compression']; + $header['size'] = $data['size']; + $header['compressed_size'] = $data['compressed_size']; + $header['crc'] = $data['crc']; + $header['flag'] = $data['flag']; + $header['mdate'] = $data['mdate']; + $header['mtime'] = $data['mtime']; + if ($header['mdate'] && $header['mtime']) { + $hour = ($header['mtime'] & 0xF800) >> 11; + $minute = ($header['mtime'] & 0x07E0) >> 5; + $seconde = ($header['mtime'] & 0x001F) * 2; + $year = (($header['mdate'] & 0xFE00) >> 9) + 1980; + $month = ($header['mdate'] & 0x01E0) >> 5; + $day = $header['mdate'] & 0x001F; + $header['mtime'] = mktime($hour, $minute, $seconde, $month, $day, $year); + } else { + $header['mtime'] = time(); + } + $header['stored_filename'] = $header['filename']; + $header['status'] = "ok"; + return $header; + } + + private function ExtractFile($header, $to, $zip) + { + $header = $this->readfileheader($zip); + if (substr($to, -1) != "/") { + $to .= "/"; + } + if (!@is_dir($to)) { + @mkdir($to, 0777); + } + $pth = explode("/", dirname($header['filename'])); + $pthss = ''; + for ($i = 0; isset($pth[$i]); $i++) { + if (!$pth[$i]) { + continue; + } + $pthss .= $pth[$i] . "/"; + if (!is_dir($to . $pthss)) { + @mkdir($to . $pthss, 0777); + } + } + if (!isset($header['external']) || ($header['external'] != 0x41FF0010 && $header['external'] != 16)) { + if ($header['compression'] == 0) { + $fp = @fopen($to . $header['filename'], 'wb'); + if (!$fp) { + return (-1); + } + $size = $header['compressed_size']; + while ($size != 0) { + $read_size = ($size < 2048 ? $size : 2048); + $buffer = fread($zip, $read_size); + $binary_data = pack('a' . $read_size, $buffer); + @fwrite($fp, $binary_data, $read_size); + $size -= $read_size; + } + fclose($fp); + touch($to . $header['filename'], $header['mtime']); + } else { + $fp = @fopen($to . $header['filename'] . '.gz', 'wb'); + if (!$fp) { + return (-1); + } + $binary_data = pack('va1a1Va1a1', 0x8b1f, Chr($header['compression']), Chr(0x00), time(), Chr(0x00), Chr(3)); + fwrite($fp, $binary_data, 10); + $size = $header['compressed_size']; + while ($size != 0) { + $read_size = ($size < 1024 ? $size : 1024); + $buffer = fread($zip, $read_size); + $binary_data = pack('a' . $read_size, $buffer); + @fwrite($fp, $binary_data, $read_size); + $size -= $read_size; + } + $binary_data = pack('VV', $header['crc'], $header['size']); + fwrite($fp, $binary_data, 8); + fclose($fp); + $gzp = @gzopen($to . $header['filename'] . '.gz', 'rb') or die("Cette archive est compress!"); + if (!$gzp) { + return (-2); + } + $fp = @fopen($to . $header['filename'], 'wb'); + if (!$fp) { + return (-1); + } + $size = $header['size']; + while ($size != 0) { + $read_size = ($size < 2048 ? $size : 2048); + $buffer = gzread($gzp, $read_size); + $binary_data = pack('a' . $read_size, $buffer); + @fwrite($fp, $binary_data, $read_size); + $size -= $read_size; + } + fclose($fp); + gzclose($gzp); + touch($to . $header['filename'], $header['mtime']); + @unlink($to . $header['filename'] . '.gz'); + } + } + return true; + } + // ------------------------------------------------------ // + // #解压文件 + // + // $archive = new PHPZip(); + // $zipfile = "ZIP压缩文件名"; + // $savepath = "解压缩目录名"; + // $zipfile = $unzipfile; + // $savepath = $unziptarget; + // $array = $archive->GetZipInnerFilesInfo($zipfile); + // $filecount = 0; + // $dircount = 0; + // $failfiles = array(); + // set_time_limit(0); // 修改为不限制超时时间(默认为30秒) + // + // for($i=0; $iunZip($zipfile, $savepath, $i) > 0){ + // $filecount++; + // }else{ + // $failfiles[] = $array[$i][filename]; + // } + // }else{ + // $dircount++; + // } + // } + // set_time_limit(30); + //printf("文件夹:%d    解压文件:%d    失败:%d
\r\n", $dircount, $filecount, count($failfiles)); + //if(count($failfiles) > 0){ + // foreach($failfiles as $file){ + // printf("·%s
\r\n", $file); + // } + //} + // ------------------------------------------------------ // + public function unzip($zipfile, $to, $index = Array(-1)) + { + $ok = 0; + $zip = @fopen($zipfile, 'rb'); + if (!$zip) { + return (-1); + } + $cdir = $this->ReadCentralDir($zip, $zipfile); + $pos_entry = $cdir['offset']; + if (!is_array($index)) { + $index = array($index); + } + for ($i = 0; isset($index[$i]) && $index[$i]; $i++) { + if (intval($index[$i]) != $index[$i] || $index[$i] > $cdir['entries']) { + return (-1); + } + } + for ($i = 0; $i < $cdir['entries']; $i++) { + @fseek($zip, $pos_entry); + $header = $this->ReadCentralFileHeaders($zip); + $header['index'] = $i; + $pos_entry = ftell($zip); + @rewind($zip); + fseek($zip, $header['offset']); + if (in_array("-1", $index) || in_array($i, $index)) { + $stat[$header['filename']] = $this->ExtractFile($header, $to, $zip); + } + } + fclose($zip); + return $stat; + } + /********************************************************** + * 其它部分 + **********************************************************/ + // ------------------------------------------------------ // + // #获取被压缩文件的信息 + // + // $archive = new PHPZip(); + // $array = $archive->GetZipInnerFilesInfo(ZIP压缩文件名); + // for($i=0; $i·%s
\r\n", $array[$i][filename]); + // foreach($array[$i] as $key => $value) + // printf("%s => %s
\r\n", $key, $value); + // print "\r\n

------------------------------------

\r\n\r\n"; + // } + // ------------------------------------------------------ // + public function GetZipInnerFilesInfo($zipfile) + { + $zip = @fopen($zipfile, 'rb'); + if (!$zip) { + return (0); + } + $centd = $this->ReadCentralDir($zip, $zipfile); + @rewind($zip); + @fseek($zip, $centd['offset']); + $ret = array(); + for ($i = 0; $i < $centd['entries']; $i++) { + $header = $this->ReadCentralFileHeaders($zip); + $header['index'] = $i; + $info = array( + 'filename' => $header['filename'], // 文件名 + 'stored_filename' => $header['stored_filename'], // 压缩后文件名 + 'size' => $header['size'], // 大小 + 'compressed_size' => $header['compressed_size'], // 压缩后大小 + 'crc' => strtoupper(dechex($header['crc'])), // CRC32 + 'mtime' => date("Y-m-d H:i:s", $header['mtime']), // 文件修改时间 + 'comment' => $header['comment'], // 注释 + 'folder' => ($header['external'] == 0x41FF0010 || $header['external'] == 16) ? 1 : 0, // 是否为文件夹 + 'index' => $header['index'], // 文件索引 + 'status' => $header['status'] // 状态 + ); + $ret[] = $info; + unset($header); + } + fclose($zip); + return $ret; + } + // ------------------------------------------------------ // + // #获取压缩文件的注释 + // + // $archive = new PHPZip(); + // echo $archive->GetZipComment(ZIP压缩文件名); + // ------------------------------------------------------ // + public function GetZipComment($zipfile) + { + $zip = @fopen($zipfile, 'rb'); + if (!$zip) { + return (0); + } + $centd = $this->ReadCentralDir($zip, $zipfile); + fclose($zip); + return $centd[comment]; + } +} \ No newline at end of file diff --git a/app/Common/function.php b/app/Common/function.php index 653540d..511b897 100644 --- a/app/Common/function.php +++ b/app/Common/function.php @@ -1296,3 +1296,32 @@ function isCarLicense($license) return false; } + +/** + * 格式化文件大小显示 + * + * @param int $size + * @return string + */ +function format_bytes($size) +{ + $prec = 3; + $size = round(abs($size)); + $units = array( + 0 => " B ", + 1 => " KB", + 2 => " MB", + 3 => " GB", + 4 => " TB" + ); + if ($size == 0) + { + return str_repeat(" ", $prec) . "0$units[0]"; + } + $unit = min(4, floor(log($size) / log(2) / 10)); + $size = $size * pow(2, -10 * $unit); + $digi = $prec - 1 - floor(log($size) / log(10)); + $size = round($size * pow(10, $digi)) * pow(10, -$digi); + + return $size . $units[$unit]; +} diff --git a/app/Http/Controllers/Admin/AdController.php b/app/Http/Controllers/Admin/AdController.php new file mode 100644 index 0000000..dbf4aa3 --- /dev/null +++ b/app/Http/Controllers/Admin/AdController.php @@ -0,0 +1,113 @@ +where('name', 'like', '%'.$_REQUEST['keyword'].'%'); + } + }; + + $list = $this->getLogic()->getPaginate($where, array('id', 'desc')); + $data['list'] = $list; + return view('admin.ad.index', $data); + } + + public function add(Request $request) + { + if(Helper::isPostRequest()) + { + if ($_POST['start_time'] && $_POST['end_time']) { + $_POST['start_time'] = strtotime($_POST['start_time']); + $_POST['end_time'] = strtotime($_POST['end_time']); + } + + $res = $this->getLogic()->add($_POST); + if($res['code'] == ReturnData::SUCCESS) + { + success_jump($res['msg'], route('admin_ad')); + } + + error_jump($res['msg']); + } + + return view('admin.ad.add'); + } + + public function edit(Request $request) + { + if(!checkIsNumber($request->input('id',null))){error_jump('参数错误');} + $id = $request->input('id'); + + if(Helper::isPostRequest()) + { + if ($_POST['start_time'] && $_POST['end_time']) { + $_POST['start_time'] = strtotime($_POST['start_time']); + $_POST['end_time'] = strtotime($_POST['end_time']); + } + + $where['id'] = $id; + $res = $this->getLogic()->edit($_POST, $where); + if($res['code'] == ReturnData::SUCCESS) + { + success_jump($res['msg'], route('admin_ad')); + } + + error_jump($res['msg']); + } + + $data['id'] = $where['id'] = $id; + $post = $this->getLogic()->getOne($where); + + //时间戳转日期格式 + if ($post->start_time > 0) { + $post->start_time = date('Y-m-d H:i:s', $post->start_time); + } else { + $post['start_time'] = ''; + } + if ($post->end_time > 0) { + $post->end_time = date('Y-m-d H:i:s', $post->end_time); + } else { + $post->end_time = ''; + } + + $data['post'] = $post; + return view('admin.ad.edit', $data); + } + + public function del(Request $request) + { + if(!checkIsNumber($request->input('id',null))){error_jump('参数错误');} + $id = $request->input('id'); + + $where['id'] = $id; + $res = $this->getLogic()->del($where); + if($res['code'] != ReturnData::SUCCESS) + { + error_jump($res['msg']); + } + + success_jump($res['msg']); + } +} \ No newline at end of file diff --git a/app/Http/Controllers/Admin/DatabaseController.php b/app/Http/Controllers/Admin/DatabaseController.php new file mode 100644 index 0000000..09e90cb --- /dev/null +++ b/app/Http/Controllers/Admin/DatabaseController.php @@ -0,0 +1,388 @@ +get_all_table(); + return view('admin.database.index', $data); + } + + public function get_all_table() + { + $list = DB::select('SHOW TABLE STATUS'); + $list = object_to_array($list); + $list = array_map('array_change_key_case', $list); + return $list; + } + + public function recovery() + { + $path = base_path() . DIRECTORY_SEPARATOR . 'database_backup'; + //判断目录是否存在 + is_writeable($path) || mkdir('./' . C("DB_PATH_NAME") . '', 0777, true); + //列出备份文件列表 + $flag = \FilesystemIterator::KEY_AS_FILENAME; + $glob = new \FilesystemIterator($path, $flag); + + $list = array(); + foreach ($glob as $name => $file) { + if (preg_match('/^\d{8,8}-\d{6,6}-\d+\.sql(?:\.gz)?$/', $name)) { + $name = sscanf($name, '%4s%2s%2s-%2s%2s%2s-%d'); + + $date = "{$name[0]}-{$name[1]}-{$name[2]}"; + $time = "{$name[3]}:{$name[4]}:{$name[5]}"; + $part = $name[6]; + + if (isset($list["{$date} {$time}"])) { + $info = $list["{$date} {$time}"]; + $info['part'] = max($info['part'], $part); + $info['size'] = $info['size'] + $file->getSize(); + } else { + $info['part'] = $part; + $info['size'] = $file->getSize(); + } + $extension = strtoupper(pathinfo($file->getFilename(), PATHINFO_EXTENSION)); + $info['compress'] = ($extension === 'SQL') ? '-' : $extension; + $info['time'] = strtotime("{$date} {$time}"); + + $list["{$date} {$time}"] = $info; + } + } + $this->assign('list', $list); + $this->display(); + } + + /** + * 优化表 + * @param String $tables 表名 + */ + public function optimize($tables = null) + { + if (!$tables) { + $tables = request('tables'); + } + if (!$tables) { + error_jump("请指定要优化的表"); + } + if (is_array($tables)) { + if (count($tables) > 5) { + $all_table = $this->get_all_table(); + foreach ($all_table as $k => $v) { + DB::statement("OPTIMIZE TABLE `" . $v['name'] . "`"); + } + success_jump("数据库优化完成"); + } + $tables = implode('`,`', $tables); + $list = DB::statement("OPTIMIZE TABLE `{$tables}`"); + if (!$list) { + error_jump("数据表优化出错请重试"); + } + success_jump("数据表优化完成"); + } + if (substr_count($tables, ',') > 5) { + $all_table = $this->get_all_table(); + foreach ($all_table as $k => $v) { + DB::statement("OPTIMIZE TABLE `" . $v['name'] . "`"); + } + success_jump("数据库优化完成"); + } + $list = DB::statement("OPTIMIZE TABLE `{$tables}`"); + if (!$list) { + error_jump("数据表'{$tables}'优化出错请重试"); + } + success_jump("数据表'{$tables}'优化完成"); + } + + /** + * 修复表 + * @param String $tables 表名 + */ + public function repair($tables = null) + { + if (!$tables) { + $tables = request('tables'); + } + if (!$tables) { + error_jump("请指定要修复的表"); + } + if (is_array($tables)) { + if (count($tables) > 5) { + $all_table = $this->get_all_table(); + foreach ($all_table as $k => $v) { + DB::statement("REPAIR TABLE `" . $v['name'] . "`"); + } + success_jump("数据库修复完成"); + } + $tables = implode('`,`', $tables); + $list = DB::statement("REPAIR TABLE `{$tables}`"); + if (!$list) { + error_jump("数据表修复出错请重试"); + } + success_jump("数据表修复完成"); + } + if (substr_count($tables, ',') > 5) { + $all_table = $this->get_all_table(); + foreach ($all_table as $k => $v) { + DB::statement("REPAIR TABLE `" . $v['name'] . "`"); + } + success_jump("数据库修复完成"); + } + $list = DB::statement("REPAIR TABLE `{$tables}`"); + if (!$list) { + error_jump("数据表'{$tables}'修复出错请重试"); + } + success_jump("数据表'{$tables}'修复完成"); + } + + /** + * 删除备份文件 + * @param Integer $time 备份时间 + */ + public function del($time = 0) + { + if (!$time) { + error_jump('参数错误'); + } + $name = date('Ymd-His', $time) . '-*.sql*'; + $path = base_path() . DIRECTORY_SEPARATOR . 'database_backup' . DIRECTORY_SEPARATOR . $name; + array_map("unlink", glob($path)); + if (count(glob($path))) { + error_jump('备份文件删除失败,请检查权限'); + } + success_jump('备份文件删除成功'); + } + + /** + * 备份数据库 + * @param String $tables 表名 + * @param Integer $id 表ID + * @param Integer $start 起始行数 + */ + public function tables_backup() + { + $tables = request('tables'); + if (!$tables) { + error_jump('参数错误'); + } + $tables = explode(',', $tables); + //初始化 + if (!(!empty($tables) && is_array($tables))) { + error_jump('参数错误'); + } + if (count($tables) > 5) { + $all_table = $this->get_all_table(); + $tables = array_column($all_table, 'name'); + } + + $backup_path = base_path() . DIRECTORY_SEPARATOR . 'database_backup' . DIRECTORY_SEPARATOR; + foreach ($tables as $table) { + $filename = "{$backup_path}{$table}.sql"; + //判断文件是否已经存在 + if (file_exists($filename)) { + unlink($filename); + } + $fp = @fopen($filename, 'a'); + //将每个表的表结构导出到文件 + $table_structure = DB::select("SHOW CREATE TABLE `{$table}`"); + $table_structure = object_to_array($table_structure); + $sql = "\n"; + $sql .= "-- -----------------------------\n"; + $sql .= "-- Table structure for `{$table}`\n"; + $sql .= "-- -----------------------------\n"; + $sql .= "\n"; + $sql .= "DROP TABLE IF EXISTS `{$table}`;\n"; + $sql .= "\n"; + //$sql .= trim($table_structure[0]['create table']) . ";\n"; + $sql .= trim($table_structure[0]['Create Table']) . ";\n"; + $sql .= "\n"; + + //将每个表的数据导出到文件 + $table_data = DB::select("select * from " . $table); + if ($table_data) { + $table_data = object_to_array($table_data); + //数据量5万条以下导出 + if (count($table_data) < 50000) { + $sqlStr = "INSERT INTO `" . $table . "` VALUES ("; + foreach ($table_data as $k => $v) { + $keys = array_keys($v); + foreach ($keys as $row) { + $sqlStr .= "'" . $v[$row] . "', "; + } + //去掉最后一个逗号和空格 + $sqlStr = substr($sqlStr, 0, strlen($sqlStr) - 2); + $sqlStr = $sqlStr . '), ('; + } + //去掉最后一个逗号和空格 + $sqlStr = substr($sqlStr, 0, strlen($sqlStr) - 3); + $sqlStr .= ";\n"; + $sql .= $sqlStr; + } + } + + if (false === @fwrite($fp, $sql)) { + error_jump($table . '备份失败'); + } + } + success_jump('备份完成'); + } + + /** + * 备份数据库 + * @param String $tables 表名 + * @param Integer $id 表ID + * @param Integer $start 起始行数 + */ + public function backup() + { + if (Helper::isPostRequest()) { + $tables = request('tables'); + if (!$tables) { + error_jump('参数错误'); + } + $tables = explode(',', $tables); + //初始化 + if (!(!empty($tables) && is_array($tables))) { + error_jump('参数错误'); + } + //读取备份配置 + $config = array( + 'path' => base_path() . DIRECTORY_SEPARATOR . 'database_backup' . DIRECTORY_SEPARATOR, //路径 + 'part' => 20971520, // 该值用于限制压缩后的分卷最大长度。单位:B;建议设置20M + 'compress' => 1, // 压缩备份文件需要PHP环境支持gzopen,gzwrite函数 0:不压缩 1:启用压缩 + 'level' => 9, // 压缩级别, 1:普通 4:一般 9:最高 + ); + //检查是否有正在执行的任务 + $lock = "{$config['path']}backup_database.lock"; + if (is_file($lock)) { + error_jump('检测到有一个备份任务正在执行,请稍后再试'); + } + //创建锁文件 + file_put_contents($lock, time()); + + //检查备份目录是否可写 创建备份目录 + is_writeable($config['path']) || mkdir($config['path'], 0777, true); + session('backup_config', $config); + + //生成备份文件信息 + $file = array( + 'name' => date('Ymd-His'), + 'part' => 1, + ); + session('backup_file', $file); + + //缓存要备份的表 + session('backup_tables', $tables); + + //创建备份文件 + $database = new DatabaseUtil($file, $config); + if (false !== $database->create()) { + $tab = array('id' => 0, 'start' => 0); + success_jump('初始化成功', '', array('tables' => $tables, 'tab' => $tab)); + } + error_jump('初始化失败,备份文件创建失败'); + } + $id = request('id'); + $start = request('start'); + //备份数据 + if (is_numeric($id) && is_numeric($start)) { + error_jump('参数错误'); + } + $tables = session('backup_tables'); + //备份指定表 + $database = new DatabaseUtil(session('backup_file'), session('backup_config')); + $start = $database->backup($tables[$id], $start); + if (false === $start) { //出错 + error_jump('备份出错'); + } elseif (0 === $start) { //下一表 + if (isset($tables[++$id])) { + $tab = array('id' => $id, 'start' => 0); + success_jump('备份完成', '', array('tab' => $tab)); + } else { //备份完成,清空缓存 + unlink(session('backup_config.path') . 'backup_database.lock'); + session('backup_tables', null); + session('backup_file', null); + session('backup_config', null); + success_jump('备份完成'); + } + } else { + $tab = array('id' => $id, 'start' => $start[0]); + $rate = floor(100 * ($start[0] / $start[1])); + success_jump("正在备份...({$rate}%)", '', array('tab' => $tab)); + } + } + + /** + * 还原数据库 + */ + public function import($time = 0, $part = null, $start = null) + { + if (is_numeric($time) && is_null($part) && is_null($start)) { //初始化 + //获取备份文件信息 + $name = date('Ymd-His', $time) . '-*.sql*'; + $path = realpath(C('DB_PATH')) . DIRECTORY_SEPARATOR . $name; + $files = glob($path); + $list = array(); + foreach ($files as $name) { + $basename = basename($name); + $match = sscanf($basename, '%4s%2s%2s-%2s%2s%2s-%d'); + $gz = preg_match('/^\d{8,8}-\d{6,6}-\d+\.sql.gz$/', $basename); + $list[$match[6]] = array($match[6], $name, $gz); + } + ksort($list); + + //检测文件正确性 + $last = end($list); + if (count($list) === $last[0]) { + session('backup_list', $list); //缓存备份列表 + success_jump('初始化完成', '', array('part' => 1, 'start' => 0)); + } else { + error_jump('备份文件可能已经损坏,请检查'); + } + } elseif (is_numeric($part) && is_numeric($start)) { + $list = session('backup_list'); + $db = new DatabaseUtil($list[$part], array( + 'path' => realpath(C('DB_PATH')) . DIRECTORY_SEPARATOR, + 'compress' => $list[$part][2] + )); + + $start = $db->import($start); + + if (false === $start) { + error_jump('还原数据出错'); + } elseif (0 === $start) { //下一卷 + if (isset($list[++$part])) { + $data = array('part' => $part, 'start' => 0); + success_jump("正在还原...#{$part}", '', $data); + } else { + session('backup_list', null); + success_jump('还原完成'); + } + } else { + $data = array('part' => $part, 'start' => $start[0]); + if ($start[1]) { + $rate = floor(100 * ($start[0] / $start[1])); + success_jump("正在还原...#{$part} ({$rate}%)", '', $data); + } else { + $data['gz'] = 1; + success_jump("正在还原...#{$part}", '', $data); + } + } + } else { + error_jump('参数错误'); + } + } +} \ No newline at end of file diff --git a/app/Http/Controllers/Home/AdController.php b/app/Http/Controllers/Home/AdController.php new file mode 100644 index 0000000..5cc59a5 --- /dev/null +++ b/app/Http/Controllers/Home/AdController.php @@ -0,0 +1,43 @@ +where('id', '=', $id)->orWhere('flag', '=', $id); + }; + $post = cache("index_ad_detail_$id"); + if (!$post) { + $time = time(); + $post = DB::table('ad')->where($where)->first(); + if (!$post) { + exit('not found'); + } + if ($post->is_expire == 1 && $post->end_time < $time) { + exit('expired'); + } + cache("index_ad_detail_$id", $post, 2592000); + } + + if (Helper::is_mobile_access()) { + if ($post->content_wap) { + exit($post->content_wap); + } + } + exit($post->content); + } + +} \ No newline at end of file diff --git a/app/Http/Controllers/Home/PageController.php b/app/Http/Controllers/Home/PageController.php index 7dcefd2..9caff5d 100644 --- a/app/Http/Controllers/Home/PageController.php +++ b/app/Http/Controllers/Home/PageController.php @@ -19,10 +19,12 @@ class PageController extends BaseController $data = []; if (!empty($id) && preg_match('/[a-z0-9]+/', $id)) { - $map['filename'] = $id; + $where = function ($query) use ($id) { + $query->where('id', '=', $id)->orWhere('filename', '=', $id); + }; $post = cache("pageid$id"); if (!$post) { - $post = object_to_array(DB::table('page')->where($map)->first(), 1); + $post = object_to_array(DB::table('page')->where($where)->first(), 1); //cache("pageid$id", $post, 2592000); cache(["pageid$id" => $post], \Carbon\Carbon::now()->addMinutes(2592000)); } diff --git a/app/Http/Logic/AdLogic.php b/app/Http/Logic/AdLogic.php new file mode 100644 index 0000000..b45d716 --- /dev/null +++ b/app/Http/Logic/AdLogic.php @@ -0,0 +1,149 @@ +getSceneRules($scene_name), $validate->getSceneRulesMessages()); + } + + //列表 + public function getList($where = array(), $order = '', $field = '*', $offset = '', $limit = '') + { + $res = $this->getModel()->getList($where, $order, $field, $offset, $limit); + + if($res['count'] > 0) + { + foreach($res['list'] as $k=>$v) + { + $res['list'][$k] = $this->getDataView($v); + } + } + + return $res; + } + + //分页html + public function getPaginate($where = array(), $order = '', $field = '*', $limit = '') + { + $res = $this->getModel()->getPaginate($where, $order, $field, $limit); + + if($res->count() > 0) + { + foreach($res as $k=>$v) + { + $res[$k] = $this->getDataView($v); + } + } + + return $res; + } + + //全部列表 + public function getAll($where = array(), $order = '', $field = '*', $limit = '') + { + $res = $this->getModel()->getAll($where, $order, $field, $limit); + + if($res) + { + foreach($res as $k=>$v) + { + $res[$k] = $this->getDataView($v); + } + } + + return $res; + } + + //详情 + public function getOne($where = array(), $field = '*') + { + $res = $this->getModel()->getOne($where, $field); + if(!$res){return false;} + + $res = $this->getDataView($res); + + return $res; + } + + //添加 + public function add($data = array(), $type=0) + { + if(empty($data)){return ReturnData::create(ReturnData::PARAMS_ERROR);} + + //添加时间 + $time = time(); + if (!(isset($data['add_time']) && !empty($data['add_time']))) { + $data['add_time'] = $time; + } + + $validator = $this->getValidate($data, 'add'); + if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());} + + $res = $this->getModel()->add($data,$type); + if($res){return ReturnData::create(ReturnData::SUCCESS,$res);} + + return ReturnData::create(ReturnData::FAIL); + } + + //修改 + public function edit($data, $where = array()) + { + if(empty($data)){return ReturnData::create(ReturnData::SUCCESS);} + + //更新时间 + $time = time(); + if (!(isset($data['add_time']) && !empty($data['add_time']))) { + $data['add_time'] = $time; + } + + $validator = $this->getValidate($data, 'edit'); + if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());} + + $res = $this->getModel()->edit($data,$where); + if($res){return ReturnData::create(ReturnData::SUCCESS,$res);} + + return ReturnData::create(ReturnData::FAIL); + } + + //删除 + public function del($where) + { + if(empty($where)){return ReturnData::create(ReturnData::PARAMS_ERROR);} + + $validator = $this->getValidate($where,'del'); + if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());} + + $res = $this->getModel()->del($where); + if($res){return ReturnData::create(ReturnData::SUCCESS,$res);} + + return ReturnData::create(ReturnData::FAIL); + } + + /** + * 数据获取器 + * @param array $data 要转化的数据 + * @return array + */ + private function getDataView($data = array()) + { + return getDataAttr($this->getModel(),$data); + } +} \ No newline at end of file diff --git a/app/Http/Model/Ad.php b/app/Http/Model/Ad.php new file mode 100644 index 0000000..670ef3f --- /dev/null +++ b/app/Http/Model/Ad.php @@ -0,0 +1,164 @@ +table); + } + + /** + * 列表 + * @param array $where 查询条件 + * @param string $order 排序 + * @param string $field 字段 + * @param int $offset 偏移量 + * @param int $limit 取多少条 + * @return array + */ + public function getList($where = array(), $order = '', $field = '*', $offset = 0, $limit = 15) + { + $model = $this->getDb(); + if($where){$model = $model->where($where);} + + $res['count'] = $model->count(); + $res['list'] = array(); + + if($res['count'] > 0) + { + if($field){if(is_array($field)){$model = $model->select($field);}else{$model = $model->select(\DB::raw($field));}} + if($order){$model = parent::getOrderByData($model, $order);} + if($offset){}else{$offset = 0;} + if($limit){}else{$limit = 15;} + + $res['list'] = $model->skip($offset)->take($limit)->get(); + } + + return $res; + } + + /** + * 分页,用于前端html输出 + * @param array $where 查询条件 + * @param string $order 排序 + * @param string $field 字段 + * @param int $limit 每页几条 + * @param int $page 当前第几页 + * @return array + */ + public function getPaginate($where = array(), $order = '', $field = '*', $limit = 15) + { + $res = $this->getDb(); + + if($where){$res = $res->where($where);} + if($field){if(is_array($field)){$res = $res->select($field);}else{$res = $res->select(\DB::raw($field));}} + if($order){$res = parent::getOrderByData($res, $order);} + if($limit){}else{$limit = 15;} + + return $res->paginate($limit); + } + + /** + * 查询全部 + * @param array $where 查询条件 + * @param string $order 排序 + * @param string $field 字段 + * @param int $limit 取多少条 + * @return array + */ + public function getAll($where = array(), $order = '', $field = '*', $limit = '', $offset = '') + { + $res = $this->getDb(); + + if($where){$res = $res->where($where);} + if($field){if(is_array($field)){$res = $res->select($field);}else{$res = $res->select(\DB::raw($field));}} + if($order){$res = parent::getOrderByData($res, $order);} + if($offset){$res = $res->skip($offset);} + if($limit){$res = $res->take($limit);} + + $res = $res->get(); + + return $res; + } + + /** + * 获取一条 + * @param array $where 条件 + * @param string $field 字段 + * @return array + */ + public function getOne($where, $field = '*') + { + $res = $this->getDb(); + + if($where){$res = $res->where($where);} + if($field){if(is_array($field)){$res = $res->select($field);}else{$res = $res->select(\DB::raw($field));}} + + $res = $res->first(); + + return $res; + } + + /** + * 添加 + * @param array $data 数据 + * @return int + */ + public function add(array $data,$type = 0) + { + if($type==0) + { + // 新增单条数据并返回主键值 + return self::insertGetId(parent::filterTableColumn($data,$this->table)); + } + elseif($type==1) + { + /** + * 添加单条数据 + * $data = ['foo' => 'bar', 'bar' => 'foo']; + * 添加多条数据 + * $data = [ + * ['foo' => 'bar', 'bar' => 'foo'], + * ['foo' => 'bar1', 'bar' => 'foo1'], + * ['foo' => 'bar2', 'bar' => 'foo2'] + * ]; + */ + return self::insert($data); + } + } + + /** + * 修改 + * @param array $data 数据 + * @param array $where 条件 + * @return int + */ + public function edit($data, $where = array()) + { + $res = $this->getDb(); + return $res->where($where)->update(parent::filterTableColumn($data, $this->table)); + } + + /** + * 删除 + * @param array $where 条件 + * @return bool + */ + public function del($where) + { + $res = $this->getDb(); + $res = $res->where($where)->delete(); + + return $res; + } +} \ No newline at end of file diff --git a/app/Http/Requests/AdRequest.php b/app/Http/Requests/AdRequest.php new file mode 100644 index 0000000..4766e29 --- /dev/null +++ b/app/Http/Requests/AdRequest.php @@ -0,0 +1,102 @@ + 'required|integer', + 'name' => 'required|max:60', + 'description' => 'max:255', + 'flag' => 'max:30', + 'is_expire' => 'between:0,3', + 'start_time' => 'integer', + 'end_time' => 'integer|min:start_time', + 'add_time' => 'required|integer', + ]; + + //总的自定义错误信息 + protected $messages = [ + 'id.required' => 'ID不能为空', + 'id.integer' => 'ID必须是数字', + 'id.gt' => 'ID格式不正确', + 'name.required' => '名称不能为空', + 'name.max' => '名称不能超过60个字符', + 'description.max' => '描述不能超过255个字符', + 'flag.max' => '标识不能超过30个字符', + 'is_expire.between' => '0永不过期', + 'start_time.integer' => '投放开始时间格式不正确', + 'end_time.integer' => '投放结束时间格式不正确', + 'end_time.min' => '投放结束时间格式不正确', + 'add_time.required' => '添加时间不能为空', + 'add_time.integer' => '添加时间格式不正确', + 'add_time.gt' => '添加时间格式不正确', + ]; + + //场景验证规则 + protected $scene = [ + 'add' => ['name', 'description', 'flag', 'is_expire', 'start_time', 'end_time', 'add_time'], + 'edit' => ['name', 'description', 'flag', 'is_expire', 'start_time', 'end_time', 'add_time'], + 'del' => ['id'], + ]; + + /** + * Determine if the user is authorized to make this request. + * + * @return bool + */ + public function authorize() + { + return true; //修改为true + } + + /** + * Get the validation rules that apply to the request. + * + * @return array + */ + public function rules() + { + return $this->rules; + } + + /** + * 获取被定义验证规则的错误消息. + * + * @return array + */ + public function messages() + { + return $this->messages; + } + + //获取场景验证规则 + public function getSceneRules($name, $fields = null) + { + $res = array(); + + if(!isset($this->scene[$name])) + { + return false; + } + + $scene = $this->scene[$name]; + if($fields != null && is_array($fields)) + { + $scene = $fields; + } + + foreach($scene as $k=>$v) + { + if(isset($this->rules[$v])){$res[$v] = $this->rules[$v];} + } + + return $res; + } + + //获取场景验证规则自定义错误信息 + public function getSceneRulesMessages() + { + return $this->messages; + } +} \ No newline at end of file diff --git a/database_backup/.gitignore b/database_backup/.gitignore new file mode 100644 index 0000000..c96a04f --- /dev/null +++ b/database_backup/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore \ No newline at end of file diff --git a/lqycms.sql b/lqycms.sql index b2692d9..6108e80 100644 --- a/lqycms.sql +++ b/lqycms.sql @@ -82,11 +82,34 @@ CREATE TABLE `fl_access` ( `role_id` int(11) unsigned NOT NULL DEFAULT '0', `menu_id` int(11) unsigned NOT NULL DEFAULT '0', PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=560 DEFAULT CHARSET=utf8 CHECKSUM=1 DELAY_KEY_WRITE=1 ROW_FORMAT=DYNAMIC; +) ENGINE=InnoDB AUTO_INCREMENT=565 DEFAULT CHARSET=utf8 CHECKSUM=1 DELAY_KEY_WRITE=1 ROW_FORMAT=DYNAMIC; /*Data for the table `fl_access` */ -insert into `fl_access`(`id`,`role_id`,`menu_id`) values (1,3,1),(2,3,11),(3,3,12),(4,3,13),(5,3,14),(6,3,15),(7,3,16),(8,3,17),(9,3,18),(10,3,19),(11,3,20),(12,3,21),(13,3,22),(14,3,23),(15,3,24),(16,3,25),(17,3,32),(18,3,33),(19,3,34),(20,3,35),(21,3,36),(22,3,37),(23,3,6),(24,3,78),(25,3,83),(26,1,1),(27,1,2),(28,1,3),(29,1,4),(30,1,5),(31,1,6),(32,1,7),(33,1,8),(34,1,9),(35,1,10),(36,1,11),(37,1,12),(38,1,13),(39,1,14),(40,1,15),(41,1,16),(42,1,17),(43,1,18),(44,1,19),(45,1,20),(46,1,21),(47,1,22),(48,1,23),(49,1,24),(50,1,25),(51,1,26),(52,1,27),(53,1,28),(54,1,29),(55,1,30),(56,1,31),(57,1,32),(58,1,33),(59,1,34),(60,1,35),(61,1,36),(62,1,37),(63,1,38),(64,1,39),(65,1,40),(66,1,41),(67,1,42),(68,1,43),(69,1,44),(70,1,45),(71,1,46),(72,1,47),(73,1,48),(74,1,49),(75,1,50),(76,1,51),(77,1,52),(78,1,53),(79,1,54),(80,1,55),(81,1,56),(82,1,57),(83,1,58),(84,1,59),(85,1,60),(86,1,61),(87,1,62),(88,1,63),(89,1,64),(90,1,65),(91,1,66),(92,1,67),(93,1,68),(94,1,69),(95,1,70),(96,1,71),(97,1,72),(98,1,73),(99,1,74),(100,1,75),(101,1,76),(102,1,77),(103,1,78),(104,1,79),(105,1,80),(106,1,81),(107,1,82),(108,1,83),(109,1,84),(110,1,85),(111,1,86),(112,1,87),(113,1,88),(114,1,89),(115,1,90),(116,1,91),(117,1,92),(118,1,93),(119,1,94),(120,1,95),(121,1,96),(122,1,97),(123,1,98),(124,1,99),(125,1,100),(126,1,101),(127,1,102),(128,1,103),(129,1,104),(130,1,105),(131,1,106),(132,1,107),(133,1,108),(134,1,109),(135,1,110),(136,1,111),(137,1,112),(138,1,113),(139,1,114),(140,1,115),(141,1,116),(142,1,117),(170,1,118),(171,1,119),(172,1,120),(173,1,121),(174,1,122),(175,1,123),(176,1,124),(177,1,125),(178,1,126),(179,1,127),(180,1,128),(181,1,129),(486,1,130),(487,2,1),(488,2,11),(489,2,12),(490,2,13),(491,2,14),(492,2,15),(493,2,16),(494,2,17),(495,2,18),(496,2,19),(497,2,20),(498,2,21),(499,2,22),(500,2,23),(501,2,24),(502,2,25),(503,2,32),(504,2,33),(505,2,34),(506,2,35),(507,2,36),(508,2,37),(509,2,2),(510,2,38),(511,2,39),(512,2,40),(513,2,41),(514,2,42),(515,2,50),(516,2,43),(517,2,44),(518,2,45),(519,2,46),(520,2,47),(521,2,48),(522,2,49),(523,2,51),(524,2,107),(525,2,108),(526,2,109),(527,2,110),(528,2,111),(529,2,112),(530,2,3),(531,2,96),(532,2,97),(533,2,98),(534,2,99),(535,2,100),(536,2,101),(537,2,4),(538,2,84),(539,2,85),(540,2,86),(541,2,87),(542,2,88),(543,2,89),(544,2,90),(545,2,91),(546,2,92),(547,2,93),(548,2,94),(549,2,95),(550,2,102),(551,2,103),(552,2,118),(553,2,119),(554,2,5),(555,2,7),(556,2,8),(557,2,9),(558,2,10),(559,2,104); +insert into `fl_access`(`id`,`role_id`,`menu_id`) values (1,3,1),(2,3,11),(3,3,12),(4,3,13),(5,3,14),(6,3,15),(7,3,16),(8,3,17),(9,3,18),(10,3,19),(11,3,20),(12,3,21),(13,3,22),(14,3,23),(15,3,24),(16,3,25),(17,3,32),(18,3,33),(19,3,34),(20,3,35),(21,3,36),(22,3,37),(23,3,6),(24,3,78),(25,3,83),(26,1,1),(27,1,2),(28,1,3),(29,1,4),(30,1,5),(31,1,6),(32,1,7),(33,1,8),(34,1,9),(35,1,10),(36,1,11),(37,1,12),(38,1,13),(39,1,14),(40,1,15),(41,1,16),(42,1,17),(43,1,18),(44,1,19),(45,1,20),(46,1,21),(47,1,22),(48,1,23),(49,1,24),(50,1,25),(51,1,26),(52,1,27),(53,1,28),(54,1,29),(55,1,30),(56,1,31),(57,1,32),(58,1,33),(59,1,34),(60,1,35),(61,1,36),(62,1,37),(63,1,38),(64,1,39),(65,1,40),(66,1,41),(67,1,42),(68,1,43),(69,1,44),(70,1,45),(71,1,46),(72,1,47),(73,1,48),(74,1,49),(75,1,50),(76,1,51),(77,1,52),(78,1,53),(79,1,54),(80,1,55),(81,1,56),(82,1,57),(83,1,58),(84,1,59),(85,1,60),(86,1,61),(87,1,62),(88,1,63),(89,1,64),(90,1,65),(91,1,66),(92,1,67),(93,1,68),(94,1,69),(95,1,70),(96,1,71),(97,1,72),(98,1,73),(99,1,74),(100,1,75),(101,1,76),(102,1,77),(103,1,78),(104,1,79),(105,1,80),(106,1,81),(107,1,82),(108,1,83),(109,1,84),(110,1,85),(111,1,86),(112,1,87),(113,1,88),(114,1,89),(115,1,90),(116,1,91),(117,1,92),(118,1,93),(119,1,94),(120,1,95),(121,1,96),(122,1,97),(123,1,98),(124,1,99),(125,1,100),(126,1,101),(127,1,102),(128,1,103),(129,1,104),(130,1,105),(131,1,106),(132,1,107),(133,1,108),(134,1,109),(135,1,110),(136,1,111),(137,1,112),(138,1,113),(139,1,114),(140,1,115),(141,1,116),(142,1,117),(170,1,118),(171,1,119),(172,1,120),(173,1,121),(174,1,122),(175,1,123),(176,1,124),(177,1,125),(178,1,126),(179,1,127),(180,1,128),(181,1,129),(486,1,130),(487,2,1),(488,2,11),(489,2,12),(490,2,13),(491,2,14),(492,2,15),(493,2,16),(494,2,17),(495,2,18),(496,2,19),(497,2,20),(498,2,21),(499,2,22),(500,2,23),(501,2,24),(502,2,25),(503,2,32),(504,2,33),(505,2,34),(506,2,35),(507,2,36),(508,2,37),(509,2,2),(510,2,38),(511,2,39),(512,2,40),(513,2,41),(514,2,42),(515,2,50),(516,2,43),(517,2,44),(518,2,45),(519,2,46),(520,2,47),(521,2,48),(522,2,49),(523,2,51),(524,2,107),(525,2,108),(526,2,109),(527,2,110),(528,2,111),(529,2,112),(530,2,3),(531,2,96),(532,2,97),(533,2,98),(534,2,99),(535,2,100),(536,2,101),(537,2,4),(538,2,84),(539,2,85),(540,2,86),(541,2,87),(542,2,88),(543,2,89),(544,2,90),(545,2,91),(546,2,92),(547,2,93),(548,2,94),(549,2,95),(550,2,102),(551,2,103),(552,2,118),(553,2,119),(554,2,5),(555,2,7),(556,2,8),(557,2,9),(558,2,10),(559,2,104),(560,1,131),(561,1,132),(562,1,133),(563,1,134),(564,1,135); + +/*Table structure for table `fl_ad` */ + +DROP TABLE IF EXISTS `fl_ad`; + +CREATE TABLE `fl_ad` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `name` varchar(60) NOT NULL DEFAULT '' COMMENT '名称', + `description` varchar(255) NOT NULL DEFAULT '' COMMENT '描述', + `content` mediumtext COMMENT '内容', + `content_wap` mediumtext COMMENT '内容-移动端', + `flag` varchar(30) NOT NULL DEFAULT '' COMMENT '标识', + `is_expire` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '0永不过期', + `start_time` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '投放开始时间', + `end_time` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '投放结束时间', + `add_time` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '添加时间', + PRIMARY KEY (`id`), + KEY `tagname` (`is_expire`,`end_time`,`start_time`) +) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8 CHECKSUM=1 DELAY_KEY_WRITE=1 ROW_FORMAT=DYNAMIC COMMENT='广告位'; + +/*Data for the table `fl_ad` */ + +insert into `fl_ad`(`id`,`name`,`description`,`content`,`content_wap`,`flag`,`is_expire`,`start_time`,`end_time`,`add_time`) values (1,'广告位名称','','',NULL,'',0,1600418553,1603010553,0); /*Table structure for table `fl_admin` */ @@ -108,7 +131,7 @@ CREATE TABLE `fl_admin` ( /*Data for the table `fl_admin` */ -insert into `fl_admin`(`id`,`name`,`email`,`login_time`,`pwd`,`role_id`,`status`,`mobile`,`avatar`,`add_time`) values (1,'admin888','admin@qq.com',1600061998,'e10adc3949ba59abbe56e057f20f883e',1,0,'','',4294967295),(2,'abc','abc@qq.com',1497285296,'e10adc3949ba59abbe56e057f20f883e',2,0,'','',4294967295),(3,'xyz','xyz@qq.com',0,'e10adc3949ba59abbe56e057f20f883e',1,0,'','',4294967295); +insert into `fl_admin`(`id`,`name`,`email`,`login_time`,`pwd`,`role_id`,`status`,`mobile`,`avatar`,`add_time`) values (1,'admin888','admin@qq.com',1604974045,'e10adc3949ba59abbe56e057f20f883e',1,0,'','',4294967295),(2,'abc','abc@qq.com',1497285296,'e10adc3949ba59abbe56e057f20f883e',2,0,'','',4294967295),(3,'xyz','xyz@qq.com',0,'e10adc3949ba59abbe56e057f20f883e',1,0,'','',4294967295); /*Table structure for table `fl_admin_role` */ @@ -329,7 +352,7 @@ CREATE TABLE `fl_failed_jobs` ( `exception` longtext COLLATE utf8mb4_unicode_ci NOT NULL, `failed_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci CHECKSUM=1 DELAY_KEY_WRITE=1 ROW_FORMAT=DYNAMIC COMMENT='任务执行失败表'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci CHECKSUM=1 DELAY_KEY_WRITE=1 ROW_FORMAT=DYNAMIC COMMENT='任务执行失败表'; /*Data for the table `fl_failed_jobs` */ @@ -412,7 +435,7 @@ CREATE TABLE `fl_goods` ( /*Data for the table `fl_goods` */ -insert into `fl_goods`(`id`,`typeid`,`tuijian`,`click`,`title`,`body`,`sn`,`price`,`litpic`,`pubdate`,`add_time`,`keywords`,`seotitle`,`description`,`status`,`shipping_fee`,`market_price`,`goods_number`,`user_id`,`sale`,`cost_price`,`goods_weight`,`point`,`comments`,`promote_start_date`,`promote_price`,`promote_end_date`,`goods_img`,`warn_number`,`spec`,`listorder`,`brand_id`) values (1,2,1,5726,'示例产品一','

是的发生

','sn123456','45000.00','/uploads/2018/04/1.jpg',1512273964,1496577749,'示例,产品,一','','是的发生',0,'0.00','50000.00',99,1,123,'0.00','0.00',0,0,0,'0.00',0,'/uploads/2017/06/201706041951031181.jpg',0,'',50,0),(2,1,1,59,'示例产品二','说的是','sn987','1.00','/uploads/2018/04/2.jpg',1496578330,1496578313,'产品,示例,二','','',0,'3.00','2.00',105,1,67,'0.00','0.00',0,0,0,'0.00',0,'/uploads/2017/06/201706042011354141.jpg',0,'',50,0),(3,1,0,51,'示例产品三','是的发生','sn232143','5.10','/uploads/2018/04/3.jpg',1496578380,1496578380,'示例,产品,三','','',0,'3.00','4.00',103,1,99,'0.00','0.00',0,0,0,'0.00',0,'/uploads/2017/06/201706042012428057.jpg',0,'',50,1),(4,1,0,141,'示例产品四','

电热熔

','sn9809702','5.00','/uploads/2018/04/4.jpg',1519736409,1496578429,'示例,产品,四','','电热熔',0,'3.00','6.00',89,1,345,'0.00','0.00',0,0,1518435963,'2.00',1519905139,'/uploads/2017/06/201706042013331349.jpg',0,'',50,0),(5,1,0,77,'示例产品五','

就回家好看

','kjkhk3','989.00','/uploads/2018/04/5.jpg',1527237789,1522849066,'示例,产品,五','','就回家好看',0,'898.00','98.00',8987,1,1234,'0.00','0.00',0,0,1523281235,'909.00',1524750039,'/uploads/2018/04/5.jpg',1,'',50,0); +insert into `fl_goods`(`id`,`typeid`,`tuijian`,`click`,`title`,`body`,`sn`,`price`,`litpic`,`pubdate`,`add_time`,`keywords`,`seotitle`,`description`,`status`,`shipping_fee`,`market_price`,`goods_number`,`user_id`,`sale`,`cost_price`,`goods_weight`,`point`,`comments`,`promote_start_date`,`promote_price`,`promote_end_date`,`goods_img`,`warn_number`,`spec`,`listorder`,`brand_id`) values (1,2,1,5727,'示例产品一','

是的发生

','sn123456','45000.00','/uploads/2018/04/1.jpg',1512273964,1496577749,'示例,产品,一','','是的发生',0,'0.00','50000.00',99,1,123,'0.00','0.00',0,0,0,'0.00',0,'/uploads/2017/06/201706041951031181.jpg',0,'',50,0),(2,1,1,59,'示例产品二','说的是','sn987','1.00','/uploads/2018/04/2.jpg',1496578330,1496578313,'产品,示例,二','','',0,'3.00','2.00',105,1,67,'0.00','0.00',0,0,0,'0.00',0,'/uploads/2017/06/201706042011354141.jpg',0,'',50,0),(3,1,0,51,'示例产品三','是的发生','sn232143','5.10','/uploads/2018/04/3.jpg',1496578380,1496578380,'示例,产品,三','','',0,'3.00','4.00',103,1,99,'0.00','0.00',0,0,0,'0.00',0,'/uploads/2017/06/201706042012428057.jpg',0,'',50,1),(4,1,0,141,'示例产品四','

电热熔

','sn9809702','5.00','/uploads/2018/04/4.jpg',1519736409,1496578429,'示例,产品,四','','电热熔',0,'3.00','6.00',89,1,345,'0.00','0.00',0,0,1518435963,'2.00',1519905139,'/uploads/2017/06/201706042013331349.jpg',0,'',50,0),(5,1,0,77,'示例产品五','

就回家好看

','kjkhk3','989.00','/uploads/2018/04/5.jpg',1527237789,1522849066,'示例,产品,五','','就回家好看',0,'898.00','98.00',8987,1,1234,'0.00','0.00',0,0,1523281235,'909.00',1524750039,'/uploads/2018/04/5.jpg',1,'',50,0); /*Table structure for table `fl_goods_brand` */ @@ -540,7 +563,7 @@ CREATE TABLE `fl_jobs` ( `created_at` int(10) unsigned NOT NULL, PRIMARY KEY (`id`), KEY `jobs_queue_index` (`queue`(250)) -) ENGINE=MyISAM AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci CHECKSUM=1 DELAY_KEY_WRITE=1 ROW_FORMAT=DYNAMIC COMMENT='队列任务表'; +) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci CHECKSUM=1 DELAY_KEY_WRITE=1 ROW_FORMAT=DYNAMIC COMMENT='队列任务表'; /*Data for the table `fl_jobs` */ @@ -588,7 +611,7 @@ DROP TABLE IF EXISTS `fl_log`; CREATE TABLE `fl_log` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `type` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '类型:默认0未知,1fladmin,2index,3api,4wap,5weixin', + `type` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '类型:默认0未知,1fladmin,2index,3api,4wap,5weixin,6shop,7mobile', `ip` varchar(15) NOT NULL DEFAULT '0' COMMENT 'IP', `domain_name` varchar(60) NOT NULL DEFAULT '' COMMENT '域名', `url` varchar(255) NOT NULL DEFAULT '' COMMENT 'URL', @@ -621,11 +644,11 @@ CREATE TABLE `fl_menu` ( PRIMARY KEY (`id`), KEY `status` (`status`), KEY `parentid` (`pid`) -) ENGINE=InnoDB AUTO_INCREMENT=131 DEFAULT CHARSET=utf8 COMMENT='后台菜单表'; +) ENGINE=InnoDB AUTO_INCREMENT=136 DEFAULT CHARSET=utf8 COMMENT='后台菜单表'; /*Data for the table `fl_menu` */ -insert into `fl_menu`(`id`,`name`,`pid`,`action`,`data`,`type`,`icon`,`des`,`status`,`listorder`) values (1,'文章管理',0,'article_default','',0,'glyphicon glyphicon-pencil','',1,0),(2,'商品管理',0,'goods_default','',0,'glyphicon glyphicon-shopping-cart','',1,10),(3,'菜单管理',0,'menu_default','',0,'glyphicon glyphicon-th-list','',1,20),(4,'用户管理',0,'user_default','',0,'glyphicon glyphicon-user','',1,30),(5,'批量维护',0,'extension_default','',0,'glyphicon glyphicon-cloud','',1,40),(6,'设置',0,'sysconfig_default','',0,'glyphicon glyphicon-wrench','',1,1000),(7,'页面跳转',5,'admin_jump','',1,'','',0,1),(8,'后台首页',5,'admin','',1,'','',0,2),(9,'更新系统参数配置',5,'admin_index_upconfig','',1,'','',0,3),(10,'更新缓存',5,'admin_index_upcache','',1,'','',0,4),(11,'文章列表',1,'admin_article','',1,'','',1,50),(12,'发布文章',1,'admin_article_add','',1,'','',1,50),(13,'发布文章提交',12,'admin_article_doadd','',1,'','',0,50),(14,'文章修改',1,'admin_article_edit','',1,'','',0,50),(15,'文章修改提交',14,'admin_article_doedit','',1,'','',0,50),(16,'文章删除',1,'admin_article_del','',1,'','',0,50),(17,'重复文档检测',1,'admin_article_repetarc','',1,'','',1,50),(18,'文章推荐',1,'admin_article_recommendarc','',1,'','',0,50),(19,'文章是否存在',1,'admin_article_articleexists','',1,'','',0,50),(20,'文章栏目',1,'admin_category','',1,'','',1,50),(21,'文章栏目添加',20,'admin_category_add','',1,'','',0,50),(22,'文章栏目添加提交',21,'admin_category_doadd','',1,'','',0,50),(23,'文章栏目修改',20,'admin_category_edit','',1,'','',0,50),(24,'文章栏目修改提交',23,'admin_category_doedit','',1,'','',0,50),(25,'文章栏目删除',20,'admin_category_del','',1,'','',0,50),(26,'Tag标签管理',5,'admin_tag','',1,'','',1,50),(27,'Tag标签添加',26,'admin_tag_add','',1,'','',0,50),(28,'Tag标签添加提交',27,'admin_tag_doadd','',1,'','',0,50),(29,'Tag标签修改',26,'admin_tag_edit','',1,'','',0,50),(30,'Tag标签修改提交',29,'admin_tag_doedit','',1,'','',0,50),(31,'Tag标签删除',26,'admin_tag_del','',1,'','',0,50),(32,'单页管理',1,'admin_page','',1,'','',1,50),(33,'单页添加',32,'admin_page_add','',1,'','',0,50),(34,'单页添加提交',33,'admin_page_doadd','',1,'','',0,50),(35,'单页修改',32,'admin_page_edit','',1,'','',0,50),(36,'单页修改提交',35,'admin_page_doedit','',1,'','',0,50),(37,'单页删除',32,'admin_page_del','',1,'','',0,50),(38,'商品列表',2,'admin_goods','',1,'','',1,50),(39,'商品添加',2,'admin_goods_add','',1,'','',1,50),(40,'商品添加提交',39,'admin_goods_doadd','',1,'','',0,50),(41,'商品修改',2,'admin_goods_edit','',1,'','',0,50),(42,'商品修改提交',41,'admin_goods_doedit','',1,'','',0,50),(43,'商品删除',2,'admin_goods_del','',1,'','',0,50),(44,'重复商品',2,'admin_goods_recommendarc','',1,'','',0,50),(45,'商品是否存在',2,'admin_goods_goodsexists','',1,'','',0,50),(46,'商品分类',2,'admin_goodstype','',1,'','',1,50),(47,'商品分类添加',46,'admin_goodstype_add','',1,'','',1,50),(48,'商品分类添加提交',47,'admin_goodstype_doadd','',1,'','',0,50),(49,'商品分类修改',46,'admin_producttype_edit','',1,'','',0,50),(50,'商品分类修改提交',42,'admin_producttype_doedit','',1,'','',0,50),(51,'商品分类删除',46,'admin_goodstype_del','',1,'','',0,50),(52,'友情链接',5,'admin_friendlink','',1,'','',1,50),(53,'友情链接添加',52,'admin_friendlink_add','',1,'','',0,50),(54,'友情链接添加提交',53,'admin_friendlink_doadd','',1,'','',0,50),(55,'友情链接修改',52,'admin_friendlink_edit','',1,'','',0,50),(56,'友情链接修改提交',55,'admin_friendlink_doedit','',1,'','',0,50),(57,'友情链接删除',52,'admin_friendlink_del','',1,'','',0,50),(58,'关键词管理',5,'admin_keyword','',1,'','',1,50),(59,'关键词添加',58,'admin_keyword_add','',1,'','',0,50),(60,'关键词添加提交',59,'admin_keyword_doadd','',1,'','',0,50),(61,'关键词修改',58,'admin_keyword_edit','',1,'','',0,50),(62,'关键词修改提交',61,'admin_keyword_doedit','',1,'','',0,50),(63,'关键词删除',58,'admin_keyword_del','',1,'','',0,50),(64,'搜索关键词',5,'admin_searchword','',1,'','',1,50),(65,'搜索关键词添加',64,'admin_searchword_add','',1,'','',0,50),(66,'搜索关键词添加提交',65,'admin_searchword_doadd','',1,'','',0,50),(67,'搜索关键词修改',64,'admin_searchword_edit','',1,'','',0,50),(68,'搜索关键词修改提交',67,'admin_searchword_doedit','',1,'','',0,50),(69,'搜索关键词删除',64,'admin_searchword_del','',1,'','',0,50),(70,'轮播图',5,'admin_slide','',1,'','',1,50),(71,'轮播图添加',70,'admin_slide_add','',1,'','',0,50),(72,'轮播图添加提交',71,'admin_slide_doadd','',1,'','',0,50),(73,'轮播图修改',70,'admin_slide_edit','',1,'','',0,50),(74,'轮播图修改提交',73,'admin_slide_doedit','',1,'','',0,50),(75,'轮播图删除',70,'admin_slide_del','',1,'','',0,50),(76,'在线留言',5,'admin_guestbook','',1,'','',1,50),(77,'在线留言删除',76,'admin_guestbook_del','',1,'','',0,50),(78,'系统基本参数',6,'admin_sysconfig','',1,'','',1,50),(79,'系统参数添加',78,'admin_sysconfig_add','',1,'','',0,50),(80,'系统参数添加提交',79,'admin_sysconfig_doadd','',1,'','',0,50),(81,'系统参数修改',78,'admin_sysconfig_edit','',1,'','',0,50),(82,'系统参数修改提交',81,'admin_sysconfig_doedit','',1,'','',0,50),(83,'系统参数删除',78,'admin_sysconfig_del','',1,'','',0,50),(84,'管理员',4,'admin_admin','',1,'','',1,50),(85,'管理员添加',84,'admin_admin_add','',1,'','',0,50),(86,'管理员添加提交',85,'admin_admin_doadd','',1,'','',0,50),(87,'管理员修改',84,'admin_admin_edit','',1,'','',0,50),(88,'管理员修改提交',87,'admin_admin_doedit','',1,'','',0,50),(89,'管理员删除',84,'admin_admin_del','',1,'','',0,50),(90,'角色管理',4,'admin_adminrole','',1,'','',1,50),(91,'角色添加',90,'admin_adminrole_add','',1,'','',0,50),(92,'角色添加修改',91,'admin_adminrole_doadd','',1,'','',0,50),(93,'角色修改',90,'admin_adminrole_edit','',1,'','',0,50),(94,'角色修改提交',93,'admin_adminrole_doedit','',1,'','',0,50),(95,'角色删除',90,'admin_adminrole_del','',1,'','',0,50),(96,'后台菜单',3,'admin_menu','',1,'','',1,50),(97,'菜单添加',96,'admin_menu_add','',1,'','',0,50),(98,'菜单添加提交',97,'admin_menu_doadd','',1,'','',0,50),(99,'菜单修改',96,'admin_menu_edit','',1,'','',0,50),(100,'菜单修改提交',99,'admin_menu_doedit','',1,'','',0,50),(101,'菜单删除',96,'admin_menu_del','',1,'','',0,50),(102,'权限设置',90,'admin_adminrole_permissions','',1,'','',0,50),(103,'权限设置提交',102,'admin_adminrole_dopermissions','',1,'','',0,50),(104,'欢迎页面',5,'admin_welcome','',1,'','',0,5),(105,'微信开发管理',0,'weixin_default','',0,'glyphicon glyphicon-th-large','',1,50),(106,'微信自定义菜单',105,'admin_weixinmenu','',1,'','',1,50),(107,'商品品牌',2,'admin_goodsbrand','',1,'','',1,50),(108,'品牌添加',107,'admin_goodsbrand_add','',1,'','',0,50),(109,'品牌添加提交',108,'admin_goodsbrand_doadd','',1,'','',0,50),(110,'品牌修改',107,'admin_goodsbrand_edit','',1,'','',0,50),(111,'品牌修改提交',110,'admin_goodsbrand_doedit','',1,'','',0,50),(112,'品牌删除',107,'admin_goodsbrand_del','',1,'','',0,50),(113,'订单管理',0,'order_default','',0,'glyphicon glyphicon-credit-card','',1,50),(114,'订单列表',113,'admin_order','',1,'','',1,50),(115,'订单详情',113,'admin_order_detail','',1,'','',0,50),(116,'订单修改',113,'admin_order_edit','',1,'','',0,50),(117,'订单修改提交',116,'admin_order_doedit','',1,'','',0,50),(118,'会员管理',4,'admin_user','',1,'','',1,50),(119,'提现申请',4,'admin_userwithdraw','',1,'','',1,50),(120,'意见反馈',5,'admin_feedback','',1,'','',1,50),(121,'意见反馈删除',120,'admin_feedback_del','',1,'','',0,50),(122,'快递管理',113,'admin_kuaidi','',1,'','',1,50),(123,'快递添加',122,'admin_kuaidi_add','',1,'','',0,50),(124,'快递修改',122,'admin_kuaidi_edit','',1,'','',0,50),(125,'快递删除',122,'admin_kuaidi_del','',1,'','',0,50),(126,'优惠券管理',2,'admin_bonus','',1,'','',1,50),(127,'优惠券添加',126,'admin_bonus_add','',1,'','',0,50),(128,'优惠券啊修改',126,'admin_bonus_edit','',1,'','',0,50),(129,'优惠券删除',126,'admin_bonus_del','',1,'','',0,50),(130,'操作记录',5,'admin_log','',1,'','',1,50); +insert into `fl_menu`(`id`,`name`,`pid`,`action`,`data`,`type`,`icon`,`des`,`status`,`listorder`) values (1,'文章管理',0,'article_default','',0,'glyphicon glyphicon-pencil','',1,0),(2,'商品管理',0,'goods_default','',0,'glyphicon glyphicon-shopping-cart','',1,10),(3,'菜单管理',0,'menu_default','',0,'glyphicon glyphicon-th-list','',1,20),(4,'用户管理',0,'user_default','',0,'glyphicon glyphicon-user','',1,30),(5,'批量维护',0,'extension_default','',0,'glyphicon glyphicon-cloud','',1,40),(6,'设置',0,'sysconfig_default','',0,'glyphicon glyphicon-wrench','',1,1000),(7,'页面跳转',5,'admin_jump','',1,'','',0,1),(8,'后台首页',5,'admin','',1,'','',0,2),(9,'更新系统参数配置',5,'admin_index_upconfig','',1,'','',0,3),(10,'更新缓存',5,'admin_index_upcache','',1,'','',0,4),(11,'文章列表',1,'admin_article','',1,'','',1,50),(12,'发布文章',1,'admin_article_add','',1,'','',1,50),(13,'发布文章提交',12,'admin_article_doadd','',1,'','',0,50),(14,'文章修改',1,'admin_article_edit','',1,'','',0,50),(15,'文章修改提交',14,'admin_article_doedit','',1,'','',0,50),(16,'文章删除',1,'admin_article_del','',1,'','',0,50),(17,'重复文档检测',1,'admin_article_repetarc','',1,'','',1,50),(18,'文章推荐',1,'admin_article_recommendarc','',1,'','',0,50),(19,'文章是否存在',1,'admin_article_articleexists','',1,'','',0,50),(20,'文章栏目',1,'admin_category','',1,'','',1,50),(21,'文章栏目添加',20,'admin_category_add','',1,'','',0,50),(22,'文章栏目添加提交',21,'admin_category_doadd','',1,'','',0,50),(23,'文章栏目修改',20,'admin_category_edit','',1,'','',0,50),(24,'文章栏目修改提交',23,'admin_category_doedit','',1,'','',0,50),(25,'文章栏目删除',20,'admin_category_del','',1,'','',0,50),(26,'Tag标签管理',5,'admin_tag','',1,'','',1,50),(27,'Tag标签添加',26,'admin_tag_add','',1,'','',0,50),(28,'Tag标签添加提交',27,'admin_tag_doadd','',1,'','',0,50),(29,'Tag标签修改',26,'admin_tag_edit','',1,'','',0,50),(30,'Tag标签修改提交',29,'admin_tag_doedit','',1,'','',0,50),(31,'Tag标签删除',26,'admin_tag_del','',1,'','',0,50),(32,'单页管理',1,'admin_page','',1,'','',1,50),(33,'单页添加',32,'admin_page_add','',1,'','',0,50),(34,'单页添加提交',33,'admin_page_doadd','',1,'','',0,50),(35,'单页修改',32,'admin_page_edit','',1,'','',0,50),(36,'单页修改提交',35,'admin_page_doedit','',1,'','',0,50),(37,'单页删除',32,'admin_page_del','',1,'','',0,50),(38,'商品列表',2,'admin_goods','',1,'','',1,50),(39,'商品添加',2,'admin_goods_add','',1,'','',1,50),(40,'商品添加提交',39,'admin_goods_doadd','',1,'','',0,50),(41,'商品修改',2,'admin_goods_edit','',1,'','',0,50),(42,'商品修改提交',41,'admin_goods_doedit','',1,'','',0,50),(43,'商品删除',2,'admin_goods_del','',1,'','',0,50),(44,'重复商品',2,'admin_goods_recommendarc','',1,'','',0,50),(45,'商品是否存在',2,'admin_goods_goodsexists','',1,'','',0,50),(46,'商品分类',2,'admin_goodstype','',1,'','',1,50),(47,'商品分类添加',46,'admin_goodstype_add','',1,'','',1,50),(48,'商品分类添加提交',47,'admin_goodstype_doadd','',1,'','',0,50),(49,'商品分类修改',46,'admin_producttype_edit','',1,'','',0,50),(50,'商品分类修改提交',42,'admin_producttype_doedit','',1,'','',0,50),(51,'商品分类删除',46,'admin_goodstype_del','',1,'','',0,50),(52,'友情链接',5,'admin_friendlink','',1,'','',1,50),(53,'友情链接添加',52,'admin_friendlink_add','',1,'','',0,50),(54,'友情链接添加提交',53,'admin_friendlink_doadd','',1,'','',0,50),(55,'友情链接修改',52,'admin_friendlink_edit','',1,'','',0,50),(56,'友情链接修改提交',55,'admin_friendlink_doedit','',1,'','',0,50),(57,'友情链接删除',52,'admin_friendlink_del','',1,'','',0,50),(58,'关键词管理',5,'admin_keyword','',1,'','',1,50),(59,'关键词添加',58,'admin_keyword_add','',1,'','',0,50),(60,'关键词添加提交',59,'admin_keyword_doadd','',1,'','',0,50),(61,'关键词修改',58,'admin_keyword_edit','',1,'','',0,50),(62,'关键词修改提交',61,'admin_keyword_doedit','',1,'','',0,50),(63,'关键词删除',58,'admin_keyword_del','',1,'','',0,50),(64,'搜索关键词',5,'admin_searchword','',1,'','',1,50),(65,'搜索关键词添加',64,'admin_searchword_add','',1,'','',0,50),(66,'搜索关键词添加提交',65,'admin_searchword_doadd','',1,'','',0,50),(67,'搜索关键词修改',64,'admin_searchword_edit','',1,'','',0,50),(68,'搜索关键词修改提交',67,'admin_searchword_doedit','',1,'','',0,50),(69,'搜索关键词删除',64,'admin_searchword_del','',1,'','',0,50),(70,'轮播图',5,'admin_slide','',1,'','',1,50),(71,'轮播图添加',70,'admin_slide_add','',1,'','',0,50),(72,'轮播图添加提交',71,'admin_slide_doadd','',1,'','',0,50),(73,'轮播图修改',70,'admin_slide_edit','',1,'','',0,50),(74,'轮播图修改提交',73,'admin_slide_doedit','',1,'','',0,50),(75,'轮播图删除',70,'admin_slide_del','',1,'','',0,50),(76,'在线留言',5,'admin_guestbook','',1,'','',1,50),(77,'在线留言删除',76,'admin_guestbook_del','',1,'','',0,50),(78,'系统基本参数',6,'admin_sysconfig','',1,'','',1,50),(79,'系统参数添加',78,'admin_sysconfig_add','',1,'','',0,50),(80,'系统参数添加提交',79,'admin_sysconfig_doadd','',1,'','',0,50),(81,'系统参数修改',78,'admin_sysconfig_edit','',1,'','',0,50),(82,'系统参数修改提交',81,'admin_sysconfig_doedit','',1,'','',0,50),(83,'系统参数删除',78,'admin_sysconfig_del','',1,'','',0,50),(84,'管理员',4,'admin_admin','',1,'','',1,50),(85,'管理员添加',84,'admin_admin_add','',1,'','',0,50),(86,'管理员添加提交',85,'admin_admin_doadd','',1,'','',0,50),(87,'管理员修改',84,'admin_admin_edit','',1,'','',0,50),(88,'管理员修改提交',87,'admin_admin_doedit','',1,'','',0,50),(89,'管理员删除',84,'admin_admin_del','',1,'','',0,50),(90,'角色管理',4,'admin_adminrole','',1,'','',1,50),(91,'角色添加',90,'admin_adminrole_add','',1,'','',0,50),(92,'角色添加修改',91,'admin_adminrole_doadd','',1,'','',0,50),(93,'角色修改',90,'admin_adminrole_edit','',1,'','',0,50),(94,'角色修改提交',93,'admin_adminrole_doedit','',1,'','',0,50),(95,'角色删除',90,'admin_adminrole_del','',1,'','',0,50),(96,'后台菜单',3,'admin_menu','',1,'','',1,50),(97,'菜单添加',96,'admin_menu_add','',1,'','',0,50),(98,'菜单添加提交',97,'admin_menu_doadd','',1,'','',0,50),(99,'菜单修改',96,'admin_menu_edit','',1,'','',0,50),(100,'菜单修改提交',99,'admin_menu_doedit','',1,'','',0,50),(101,'菜单删除',96,'admin_menu_del','',1,'','',0,50),(102,'权限设置',90,'admin_adminrole_permissions','',1,'','',0,50),(103,'权限设置提交',102,'admin_adminrole_dopermissions','',1,'','',0,50),(104,'欢迎页面',5,'admin_welcome','',1,'','',0,5),(105,'微信开发管理',0,'weixin_default','',0,'glyphicon glyphicon-th-large','',1,50),(106,'微信自定义菜单',105,'admin_weixinmenu','',1,'','',1,50),(107,'商品品牌',2,'admin_goodsbrand','',1,'','',1,50),(108,'品牌添加',107,'admin_goodsbrand_add','',1,'','',0,50),(109,'品牌添加提交',108,'admin_goodsbrand_doadd','',1,'','',0,50),(110,'品牌修改',107,'admin_goodsbrand_edit','',1,'','',0,50),(111,'品牌修改提交',110,'admin_goodsbrand_doedit','',1,'','',0,50),(112,'品牌删除',107,'admin_goodsbrand_del','',1,'','',0,50),(113,'订单管理',0,'order_default','',0,'glyphicon glyphicon-credit-card','',1,50),(114,'订单列表',113,'admin_order','',1,'','',1,50),(115,'订单详情',113,'admin_order_detail','',1,'','',0,50),(116,'订单修改',113,'admin_order_edit','',1,'','',0,50),(117,'订单修改提交',116,'admin_order_doedit','',1,'','',0,50),(118,'会员管理',4,'admin_user','',1,'','',1,50),(119,'提现申请',4,'admin_userwithdraw','',1,'','',1,50),(120,'意见反馈',5,'admin_feedback','',1,'','',1,50),(121,'意见反馈删除',120,'admin_feedback_del','',1,'','',0,50),(122,'快递管理',113,'admin_kuaidi','',1,'','',1,50),(123,'快递添加',122,'admin_kuaidi_add','',1,'','',0,50),(124,'快递修改',122,'admin_kuaidi_edit','',1,'','',0,50),(125,'快递删除',122,'admin_kuaidi_del','',1,'','',0,50),(126,'优惠券管理',2,'admin_bonus','',1,'','',1,50),(127,'优惠券添加',126,'admin_bonus_add','',1,'','',0,50),(128,'优惠券啊修改',126,'admin_bonus_edit','',1,'','',0,50),(129,'优惠券删除',126,'admin_bonus_del','',1,'','',0,50),(130,'操作记录',5,'admin_log','',1,'','',1,50),(131,'广告管理',5,'admin_ad','',1,'','',1,50),(132,'广告添加',131,'admin_ad_add','',1,'','',0,50),(133,'广告修改',131,'admin_ad_edit','',1,'','',0,50),(134,'广告删除',131,'admin_ad_del','',1,'','',0,50),(135,'数据库备份',5,'admin_database','',1,'','',1,50); /*Table structure for table `fl_order` */ @@ -840,7 +863,7 @@ CREATE TABLE `fl_searchword` ( `filename` varchar(60) NOT NULL DEFAULT '' COMMENT '别名', PRIMARY KEY (`id`), UNIQUE KEY `name` (`name`) -) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8; +) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8; /*Data for the table `fl_searchword` */ diff --git a/public/index.php b/public/index.php index 607b53a..a7cf6d3 100644 --- a/public/index.php +++ b/public/index.php @@ -19,6 +19,9 @@ | */ +// 禁止代理IP访问 +empty($_SERVER['HTTP_VIA']) or exit('Access Denied'); + session_start(); //开启session require __DIR__.'/../bootstrap/autoload.php'; diff --git a/resources/views/admin/ad/add.blade.php b/resources/views/admin/ad/add.blade.php new file mode 100644 index 0000000..601e480 --- /dev/null +++ b/resources/views/admin/ad/add.blade.php @@ -0,0 +1,74 @@ +@extends('admin.layouts.app') +@section('title', '广告添加') + +@section('content') + +
广告列表 > 添加广告
+ +
{{ csrf_field() }} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
*名称:
描述:
广告位标识:
时间限制: +  永不过期   +  在设内时间内有效 +
投放开始时间:   投放结束时间:
*广告内容:
广告内容-移动端:
  
+ +@endsection \ No newline at end of file diff --git a/resources/views/admin/ad/edit.blade.php b/resources/views/admin/ad/edit.blade.php new file mode 100644 index 0000000..4c5a1bc --- /dev/null +++ b/resources/views/admin/ad/edit.blade.php @@ -0,0 +1,74 @@ +@extends('admin.layouts.app') +@section('title', '广告修改') + +@section('content') + +
广告列表 > 广告修改
+ +
{{ csrf_field() }} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
*名称:
描述:
广告位标识:
时间限制: + is_expire == 0) { echo 'checked'; } ?> /> 永不过期   + is_expire == 1) { echo 'checked'; } ?> /> 在设内时间内有效 +
投放开始时间:   投放结束时间:
*广告内容:
广告内容-移动端:
  
+ +@endsection \ No newline at end of file diff --git a/resources/views/admin/ad/index.blade.php b/resources/views/admin/ad/index.blade.php new file mode 100644 index 0000000..3229e0e --- /dev/null +++ b/resources/views/admin/ad/index.blade.php @@ -0,0 +1,26 @@ +@extends('admin.layouts.app') +@section('title', '广告列表') + +@section('content') +

广告管理

[ 添加广告 ]

+ +
+ + + + + + + + + + + + + + + +
ID名称是否限时结束时间管理
id; ?>name; ?>is_expire == 0) { echo '不限时间'; } else { echo '限时标记'; } ?>end_time > 0) { echo date('Y-m-d', $row->end_time); } ?>修改 | 删除
+ + +@endsection \ No newline at end of file diff --git a/resources/views/admin/database/index.blade.php b/resources/views/admin/database/index.blade.php new file mode 100644 index 0000000..359b84f --- /dev/null +++ b/resources/views/admin/database/index.blade.php @@ -0,0 +1,86 @@ +@extends('admin.layouts.app') +@section('title', '数据库备份') + +@section('content') +

数据库备份

+ +
+ + + + + + + + + + +$v) { ?> + + + + + + + + + + + +
选择表名数据量数据大小创建时间备份状态操作
" class="np">已备份'; } else { echo '未备份'; } ?>">优化表 ">修复表 ">备份
+ 反选  + 立即备份  + 优化表  + 修复表  + +
+ + +@endsection \ No newline at end of file diff --git a/resources/views/admin/database/index.html b/resources/views/admin/database/index.html new file mode 100644 index 0000000..229efcd --- /dev/null +++ b/resources/views/admin/database/index.html @@ -0,0 +1,86 @@ +{extend name="public/base" /} +{block name="title"}数据库备份{/block} + +{block name="content"} +

数据库备份

+ +
+ + + + + + + + + + +$v) { ?> + + + + + + + + + + + +
选择表名数据量数据大小创建时间备份状态操作
" class="np">{$v.data_length|format_bytes}已备份'; } else { echo '未备份'; } ?>">优化表 ">修复表 ">备份
+ 反选  + 立即备份  + 优化表  + 修复表  + +
+ + +{/block} \ No newline at end of file diff --git a/resources/views/admin/menu/add.blade.php b/resources/views/admin/menu/add.blade.php index 7aab469..5afa627 100644 --- a/resources/views/admin/menu/add.blade.php +++ b/resources/views/admin/menu/add.blade.php @@ -41,6 +41,10 @@ 备注: + + 排序: + + 状态: @@ -49,7 +53,7 @@ - 状态: + 类型:  权限认证+菜单    只作为菜单
注意:“权限认证+菜单”表示加入后台权限管理,纯碎是菜单项请不要选择此项。 diff --git a/resources/views/admin/menu/edit.blade.php b/resources/views/admin/menu/edit.blade.php index 71efd2f..27dc319 100644 --- a/resources/views/admin/menu/edit.blade.php +++ b/resources/views/admin/menu/edit.blade.php @@ -41,6 +41,10 @@ 备注: " style="width:50%"> + + 排序: + " style="width:30%"> + 状态: @@ -49,7 +53,7 @@ - 状态: + 类型: /> 权限认证+菜单   /> 只作为菜单 diff --git a/routes/web.php b/routes/web.php index b3647c0..eb26366 100644 --- a/routes/web.php +++ b/routes/web.php @@ -43,7 +43,8 @@ Route::group(['namespace' => 'Home'], function () { Route::get('/goods/{id}', 'GoodsController@detail')->name('home_goods'); //商品详情页 Route::get('/goodslist', 'GoodsController@index')->name('home_goodslist'); //产品分类页 Route::get('/brandlist', 'GoodsController@brand_list')->name('home_brandlist'); //品牌列表 - Route::get('/sitemap.xml', 'IndexController@sitemap')->name('home_sitemap'); //sitemap + Route::get('/sitemap.xml', 'IndexController@sitemap')->name('home_sitemap');//sitemap + Route::get('/ad/{id}', 'AdController@detail')->name('home_ad_detail'); //广告详情 Route::get('/wx_checksignature', 'IndexController@checksignature')->name('home_wx_checksignature'); Route::get('/test', 'IndexController@test')->name('home_test'); //测试 @@ -442,7 +443,17 @@ Route::group(['prefix' => 'fladmin', 'namespace' => 'Admin', 'middleware' => ['w Route::get('/logout', 'LoginController@logout')->name('admin_logout'); Route::get('/recoverpwd', 'LoginController@recoverpwd')->name('admin_recoverpwd'); //操作日志 - Route::get('/log', 'LogController@index')->name('admin_log'); + Route::any('/log', 'LogController@index')->name('admin_log'); + //数据库备份 + Route::any('/database', 'DatabaseController@index')->name('admin_database'); + Route::any('/database/optimize', 'DatabaseController@optimize')->name('admin_database_optimize'); //优化表 + Route::any('/database/repair', 'DatabaseController@repair')->name('admin_database_repair'); //修复表 + Route::any('/database/tables_backup', 'DatabaseController@tables_backup')->name('admin_database_tables_backup'); //备份数据库 + //广告管理 + Route::any('/ad', 'AdController@index')->name('admin_ad'); + Route::any('/ad/add', 'AdController@add')->name('admin_ad_add'); + Route::any('/ad/edit', 'AdController@edit')->name('admin_ad_edit'); + Route::any('/ad/del', 'AdController@del')->name('admin_ad_del'); //页面跳转 Route::get('/jump', 'LoginController@jump')->name('admin_jump'); //测试