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\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,'广告位名称','',' 是的发生 电热熔 就回家好看 是的发生 电热熔 就回家好看
\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; $i
\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
\r\n", $array[$i][filename]);
+ // foreach($array[$i] as $key => $value)
+ // printf("%s => %s
\r\n", $key, $value);
+ // print "\r\n',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,'示例产品一','
广告列表 > 添加广告
+
+
+
+@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')
+
+广告列表 > 广告修改
+
+
+
+@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')
+广告管理
[ 添加广告 ]
+
+
+
+
+@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')
+数据库备份 条
+
+
+
+
+@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"}
+数据库备份 条
+
+
+
+
+{/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');
//测试