This commit is contained in:
2024-10-29 14:04:59 +08:00
commit 48bf3e6f33
2839 changed files with 762707 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
<?php
namespace app\common\behavior;
use think\Config;
use think\Cache;
use think\Loader;
use think\Hook;
/**
* Description of SystemConfig
* 系统配置初始化
*/
class SystemConfig {
//记录行为
public function run() {
}
}

35
app/common/behavior/CheckIp.php Executable file
View File

@@ -0,0 +1,35 @@
<?php
namespace app\common\behavior;
use think\Request;
use think\Config;
load_trait('controller/Jump');
/**
* Description of CheckIp
* 检测用户访问的ip
*/
class CheckIp {
use \traits\controller\Jump;
/**
* 检测用户IP
*/
public function run() {
$deny_ip = Config::get('admin_deny_ip');
$allow_ip = Config::get('admin_allow_ip');
$ip = Request::instance()->ip();
//$this->error('禁止访问');
if (!is_administrator() && $deny_ip) {
in_array($ip, explode(',', $deny_ip)) && $this->error('禁止访问'); // 检查IP地址访问
}
if (!is_administrator() && $allow_ip) {
!in_array($ip, explode(',', $allow_ip)) && $this->error('禁止访问'); // 检查IP地址访问
}
\think\Log::record("[ 访问者IP ]" . $ip);
}
}

View File

@@ -0,0 +1,53 @@
<?php
namespace app\common\behavior;
use think\Config;
use think\Request;
use think\Hook;
use think\App;
use think\Log;
class ModuleCacheBehavior {
protected static $moduleName = '';
protected static $cachemoduleName;
/**
* 系统配置读取并缓存
*/
public function appBegin(&$param) {
switch ($param['type']) {
case 'redirect': // 重定向跳转
break;
case 'module': // 模块/控制器/操作
self::$moduleName = $param['module'][0];
break;
case 'controller': // 执行控制器操作
break;
case 'method': // 回调方法
break;
case 'function': // 闭包
break;
case 'response': // Response 实例
break;
default:
throw new \InvalidArgumentException('dispatch type not support');
}
self::$cachemoduleName = Config::get('html_cache_module', array());
if (!empty(self::$cachemoduleName) && in_array(self::$moduleName, self::$cachemoduleName)) {
// 监听 app_dispatch
Hook::listen('app_cache_begin', $param);
}
App::$debug && Log::record("[ 模块缓存 ]内容命中缓存处理HOOK");
}
public function viewFilter(&$param) {
if (!empty(self::$cachemoduleName) && in_array(self::$moduleName, self::$cachemoduleName)) {
// 监听 app_cache_end
Hook::listen('app_cache_end', $param);
}
App::$debug && Log::record("[ 模块缓存 ]视图内容缓存处理HOOK");
}
}

View File

@@ -0,0 +1,171 @@
<?php
namespace app\common\behavior;
use think\Config;
use think\Request;
use think\App;
use think\Log;
/**
* 系统行为扩展:静态缓存读取
*/
class ReadHtmlCacheBehavior {
protected static $actionName;
protected static $controllerName;
protected static $moduleName;
protected $storage;
// 行为扩展的执行入口必须是run
public function run(&$param) {
self::$actionName = $param['module'][0];
self::$controllerName = empty($param['module'][1]) ? '' : $param['module'][1];
self::$moduleName = empty($param['module'][2]) ? '' : $param['module'][2];
// 开启静态缓存
if (Request::instance()->isGet() && Config::get('html_cache_on', false)) {
$cacheTime = $this->requireHtmlCache();
if (false !== $cacheTime && $this->checkHTMLCache(HTML_FILE_NAME, $cacheTime)) { //静态页面有效
// 读取静态页面输出
include HTML_FILE_NAME;
exit();
}
}
}
// 判断是否需要静态缓存
static private function requireHtmlCache() {
// 分析当前的静态规则
$htmls = Config::get('html_cache_rules', ''); // 读取静态规则
if (!empty($htmls)) {
$htmls = array_change_key_case($htmls);
// 静态规则文件定义格式 actionName=>array('静态规则','缓存时间','附加规则')
// 'read'=>array('{id},{name}',60,'md5') 必须保证静态规则的唯一性 和 可判断性
// 检测静态规则
$moduleName = strtolower(self::$moduleName);
$controllerName = strtolower(self::$controllerName);
$actionName = strtolower(self::$actionName);
$rules = [
$moduleName . ':' . $controllerName . ':' . $actionName,
$moduleName . ':' . $controllerName,
$moduleName . ':',
$controllerName . ':' . $actionName,
$controllerName . ':',
$actionName,
'*',
];
foreach ($rules as $v) {
if (!empty($htmls[$v])) {
$html = $htmls[$v]; //规则
break;
}
}
if (!empty($html)) {
// thinkphp5
$method = Request::instance()->method();
switch ($method) {
case 'GET':
$_GET = Request::instance()->param();
break;
case 'POST':
$_POST = Request::instance()->param();
break;
case 'REQUEST':
$_REQUEST = Request::instance()->request();
break;
case 'SERVER':
$_SERVER = Request::instance()->server();
break;
case 'SESSION':
$_SESSION = Request::instance()->session();
break;
case 'COOKIE':
$_COOKIE = Request::instance()->cookie();
break;
default:
break;
}
// 解读静态规则
$rule = is_array($html) ? $html[0] : $html;
// 以$_开头的系统变量
$callback = function($match) {
switch ($match[1]) {
case '_GET': $var = $_GET[$match[2]];
break;
case '_POST': $var = $_POST[$match[2]];
break;
case '_REQUEST': $var = $_REQUEST[$match[2]];
break;
case '_SERVER': $var = $_SERVER[$match[2]];
break;
case '_SESSION': $var = $_SESSION[$match[2]];
break;
case '_COOKIE': $var = $_COOKIE[$match[2]];
break;
}
return (count($match) == 4) ? $match[3]($var) : $var;
};
$rule = preg_replace_callback('/{\$(_\w+)\.(\w+)(?:\|(\w+))?}/', $callback, $rule);
// {ID|FUN} GET变量的简写
$rule = preg_replace_callback('/{(\w+)\|(\w+)}/', function($match) {
return $match[2]($_GET[$match[1]]);
}, $rule);
$rule = preg_replace_callback('/{(\w+)}/', function($match) {
return $_GET[$match[1]];
}, $rule);
// 特殊系统变量
$rule = str_ireplace(
array('{:controller}', '{:action}', '{:module}'), array(self::$controllerName, self::$actionName, self::$moduleName), $rule);
// {|FUN} 单独使用函数
$rule = preg_replace_callback('/{|(\w+)}/', function($match) {
return $match[1]();
}, $rule);
// $cacheTime = config('html_cache_time') ?? '.html';//php7
$cacheTime = Config::get('html_cache_time', 60);
$cacheTime = empty($cacheTime) ? 60 : $cacheTime;
if (is_array($html)) {
if (!empty($html[2]))
$rule = $html[2]($rule); // 应用附加函数
$cacheTime = isset($html[1]) ? $html[1] : $cacheTime; // 缓存有效期
}else {
$cacheTime = $cacheTime;
}
// 当前缓存文件
// $html_file_suffix = config('html_file_suffix') ?? '.html';//php7
$html_file_suffix = Config::get('html_file_suffix');
$html_file_suffix = empty($html_file_suffix) ? '.html' : $html_file_suffix;
define('HTML_FILE_NAME', RUNTIME_PATH . $rule . $html_file_suffix);
return $cacheTime;
}
}
// 无需缓存
return false;
}
/**
* 检查静态HTML文件是否有效
* 如果无效需要重新更新
* @access public
* @param string $cacheFile 静态文件名
* @param integer $cacheTime 缓存有效期
* @return boolean
*/
static public function checkHTMLCache($cacheFile = '', $cacheTime = '') {
if (true == Config::get('app_debug')) {
return false;
} elseif (!is_file($cacheFile)) {
return false;
// }elseif (filemtime(\think\view()->parseTemplate()) > $this->storage()->read($cacheFile,'mtime')) {
// // 模板文件如果更新静态文件需要更新
// return false;
} elseif (!is_numeric($cacheTime) && function_exists($cacheTime)) {
return $cacheTime($cacheFile);
} elseif ($cacheTime != 0 && time() > filemtime($cacheFile) + $cacheTime) {
// 文件是否在有效期
return false;
}
//静态文件有效
return true;
}
}

View File

@@ -0,0 +1,36 @@
<?php
namespace app\common\behavior;
use think\Config;
use think\Cache;
use think\Loader;
use think\App;
use think\Log;
/**
* Description of SystemConfig
* 系统配置初始化
*/
class SystemConfig {
/**
* 系统配置读取并缓存
*/
public function run() {
$config = Cache::get('common_config_data');
$configuk = Cache::get('common_config_data_uk');
if (empty($config)) {
$config = Loader::model('Sysconfig')->configLists(['group' => ['in', [1, 2, 3, 4, 6]]]);
Cache::tag('sysconfig')->set('common_config_data', $config);
App::$debug && Log::record("[ 系统配置 ]:初始化成功");
}
if (empty($configuk)) {
$config = Loader::model('SysconfigEn')->configLists(['group' => ['in', [1, 2, 3, 4, 6]]]);
Cache::tag('sysconfiguk')->set('common_config_data_uk', $configuk);
App::$debug && Log::record("[ 系统配置 ]:初始化成功");
}
Config::set($configuk);
}
}

View File

@@ -0,0 +1,30 @@
<?php
namespace app\common\behavior;
use think\Config;
use think\Cache;
use think\Loader;
use think\App;
use think\Log;
/**
* Description of SystemConfig
* 系统配置初始化
*/
class SystemConfig {
/**
* 系统配置读取并缓存
*/
public function run() {
$config = Cache::get('common_config_data');
if (empty($config)) {
$config = Loader::model('Sysconfig')->configLists(['group' => ['in', [1, 2, 3, 4, 6]]]);
Cache::tag('sysconfig')->set('common_config_data', $config);
App::$debug && Log::record("[ 系统配置 ]:初始化成功");
}
Config::set($config);
}
}

View File

@@ -0,0 +1,37 @@
<?php
namespace app\common\behavior;
use think\Config;
use think\Request;
use think\App;
use think\Log;
/**
* 系统行为扩展:静态缓存写入
*/
class WriteHtmlCacheBehavior {
// protected $storage;
// public function action_begin(){
public function run(&$content) {
//2014-11-28 修改 如果有HTTP 4xx 3xx 5xx 头部,禁止存储
//2014-12-1 修改 对注入的网址 防止生成,例如 /game/lst/SortType/hot/-e8-90-8c-e5-85-94-e7-88-b1-e6-b6-88-e9-99-a4/-e8-bf-9b-e5-87-bb-e7-9a-84-e9-83-a8-e8-90-bd/-e9-a3-8e-e4-ba-91-e5-a4-a9-e4-b8-8b/index.shtml
if (Config::get('html_cache_on') && defined('HTML_FILE_NAME') && !preg_match('/Status.*[345]{1}\d{2}/i', implode(' ', headers_list())) && !preg_match('/(-[a-z0-9]{2}){3,}/i', HTML_FILE_NAME)) {
$view_replace_str = Config::get('view_replace_str');
$arraySearch = array_keys($view_replace_str);
$content = str_replace($arraySearch, $view_replace_str, $content);
//静态文件写入
$this->initStorage()->write(HTML_FILE_NAME, $content);
}
}
// 初始化模板编译存储器
private function initStorage() {
$type = Config::get('html_cache_compile_type');
$type = $type ? $type : 'File';
$class = false !== strpos($type, '\\') ? $type : '\\think\\template\\driver\\' . ucwords($type);
return new $class();
}
}

View File

@@ -0,0 +1,304 @@
<?php
namespace app\common\controller;
use think\Controller;
use think\Lang;
use think\Db;
use think\Cache;
use think\Config;
class BaseController extends Controller {
//当前网站ID
protected $siteid = 32267;
//当前用户
protected $member_id;
protected $lang;
public function __construct() {
parent::__construct();
}
/**
* 初始化操作
* @access protected
*/
protected function _initialize() {
//parent::_initialize();
//$this->siteid = Config::get('siteid', 0);
$this->module = $this->request->module();
$this->controller = $this->request->controller();
$this->action = $this->request->action();
$this->view->assign('siteid', $this->siteid);
$this->view->assign('module', $this->module);
$this->view->assign('controller', $this->controller);
$this->view->assign('action', $this->action);
$this->view->assign('request', $this->request);
$this->langid = 1;
$this->lang = 'zh-cn';
$this->view->assign('lang', $this->lang);
$this->view->assign('langid', $this->langid);
$uuid = createGuid();
$this->view->assign('uuid', $uuid);
// 该服务停用了,导致访问慢,暂时注释
// setMomitorFeed($this->request->controller(), $uuid);
$this->check_url();
}
public function check_url()
{
// echo $this->module, '<hr>';
// echo $this->controller, '<hr>';
// echo $this->action, '<hr>';
// echo $this->request->scheme(), '<hr>';
// echo $this->request->domain(), '<hr>';
// echo $this->request->baseUrl(), '<hr>';
// echo $this->request->url(true), '<hr>';
// die;
$module = strtolower($this->module);
$controller = strtolower($this->controller);
$action = strtolower($this->action);
$scheme = $this->request->scheme();
$domain = $this->request->domain();
$base_url = $this->request->baseUrl();
$url = $this->request->url(true);
if ($url == 'https://www.orico.com.cn/index.php')
return $this->redirect('https://www.orico.com.cn');
if ($this->request->isMobile() && strpos($base_url, 'mobile') === false)
{
$ctrl = \think\helper\Str::snake($this->controller);
if ($ctrl == 'tops_nas') {
return $this->redirect(url("@mobile/$ctrl/$action"));
}
if (strpos($domain, 'orico.cc'))
{
// 英文
if ($base_url == '/')
return $this->redirect($scheme . '://www.orico.cc/usmobile.html'); // 首页
else if ($controller == 'product')
{
// 产品
$id = $this->request->param('id');
if ($action == 'catelists')
return $this->redirect($scheme . '://www.orico.cc/usmobile/product/catelists/id/' . $id . '.html');
else if ($action == 'subcatelists')
return $this->redirect($scheme . '://www.orico.cc/usmobile/product/subcatelists/id/' . $id . '.html');
else if ($action == 'detail')
return $this->redirect($scheme . '://www.orico.cc/usmobile/product/detail/id/' . $id . '.html');
else if ($action == 'new_arrival')
return $this->redirect($scheme . '://www.orico.cc/usmobile/product/new_arrival.html');
}
else if ($controller == 'article')
{
// 新闻
$id = $this->request->param('id');
if ($action == 'catelists')
{
$page = $this->request->param('page');
$page = isset($page) ? $page : 1;
}
else if ($action == 'detail')
return $this->redirect($scheme . '://www.orico.cc/usmobile/article/detail/id/' . $id . '.html');
}
else if ($controller == 'group')
return $this->redirect($scheme . '://www.orico.cc/usmobile/' . $controller . '/' . $action . '.html');
}
else
{
// 中文
if ($base_url == '/')
return $this->redirect($scheme . '://www.orico.com.cn/mobile.html'); // 首页
else if ($controller == 'product')
{
// 产品
$id = $this->request->param('id');
if ($action == 'catelists')
return $this->redirect($scheme . '://www.orico.com.cn/mobile/product/catelists/id/' . $id . '.html');
else if ($action == 'subcatelists')
return $this->redirect($scheme . '://www.orico.com.cn/mobile/product/subcatelists/id/' . $id . '.html');
else if ($action == 'detail')
return $this->redirect($scheme . '://www.orico.com.cn/mobile/product/detail/id/' . $id . '.html');
}
else if ($controller == 'article')
{
// 新闻
$id = $this->request->param('id');
if ($action == 'catelists')
{
$page = $this->request->param('page');
$page = isset($page) ? $page : 1;
}
else if ($action == 'detail')
return $this->redirect($scheme . '://www.orico.com.cn/mobile/article/detail/id/' . $id . '.html');
}
else if ($controller == 'group'){
/*if($action == 'oricoindex'){
return $this->redirect($scheme . '://www.orico.com.cn/mobile');
}*/
return $this->redirect($scheme . '://www.orico.com.cn/mobile/' . $controller . '/' . $action . '.html');
}
}
}
}
//空操作
public function _empty() {
if ($_SERVER['HTTP_HOST']=="www.orico.com.cn" && $_SERVER['HTTP_HOST']=="orico.com.cn") {
return $this->redirect("http://orico.com.cn");
} elseif ($_SERVER['HTTP_HOST']=="www.orico.cc" || $_SERVER['HTTP_HOST']=="orico.cc") {
return $this->redirect("http://orico.cc");
}
return exception(_lang_('This operation not valid'));
}
/**
* 检测验证码
* @param $code 验证码ID
* @param integer $id id
* @return bool 检测结果
*/
protected function verify_check($code, $id = '') {
$verify = new \verify\Verify();
return $verify->check($code, $id);
}
protected function verify_build($id = '', $cfg = []) {
//$verify = new \verify\Verify((array) Config::get('captcha'));
$config = [
'expire' => 900, // 验证码过期时间s
'codeSet' => '0123456789', // 验证码字符集合
'length' => 4, // 验证码位数
'fontSize' => 18, // 验证码字体大小(px)
'useCurve' => true, // 是否画混淆曲线
'useNoise' => true, // 是否添加杂点
'imageH' => 35, // 验证码图片高度
'imageW' => 120, // 验证码图片宽度
];
$config = array_merge($config, $cfg);
$verify = new \verify\Verify($config);
return $verify->entry($id);
}
/**
* 判断缓存是否存在
* @access public
* @param string $name 缓存变量名
* @return bool
*/
public function cacheHas($name) {
return Cache::has($name);
}
/**
* 写入缓存
* @access public
* @param string $name 缓存标识
* @param mixed $value 存储数据
* @param int|null $expire 有效时间 0为永久
* @return boolean
*/
public function cacheSet($name, $value, $expire = null) {
return Cache::set($name, $value, $expire);
}
/**
* 读取缓存
* @access public
* @param string $name 缓存标识
* @param mixed $default 默认值
* @return mixed
*/
public function cacheGet($name, $default = false) {
return Cache::get($name, $default);
}
/**
* 删除缓存
* @access public
* @param string $name 缓存标识
* @return boolean
*/
public function cacheDelete($name) {
return Cache::rm($name);
}
/**
* 清除缓存
* @access public
* @param string $tag 标签名
* @return boolean
*/
public function cacheClear($tag = null) {
return Cache::clear($tag);
}
/**
* 读取缓存并删除
* @access public
* @param string $name 缓存变量名
* @return mixed
*/
public function cachePull($name) {
return Cache::pull($name);
}
/**
* 如果不存在则写入缓存
* @access public
* @param string $name 缓存变量名
* @param mixed $value 存储数据
* @param int $expire 有效时间 0为永久
* @return mixed
*/
public function cacheRemember($name, $value, $expire = null) {
return Cache::remember($name, $value, $expire);
}
/**
* 缓存标签
* @access public
* @param string $name 标签名
* @param string|array $keys 缓存标识
* @param bool $overlay 是否覆盖
* @return Driver
*/
public function cacheTag($name, $keys = null, $overlay = false) {
return Cache::tag($name, $keys, $overlay);
}
/**
* json格式返回数据
* @access public
* @param int $code 返回码
* @param string $msg 返回信息
* @param array $data 返回数据
* @return json
*/
public function json($code, $msg, $data=null) {
$result = [
'code' => $code,
'msg' => $msg,
];
if (!empty($data)) {
$result['data'] = $data;
}
echo json_encode($result);
exit;
}
}

11
app/common/controller/Index.php Executable file
View File

@@ -0,0 +1,11 @@
<?php
namespace app\common\controller;
class Index {
public function index() {
return 'Hello World';
}
}

12
app/common/model/Ad.php Executable file
View File

@@ -0,0 +1,12 @@
<?php
namespace app\common\model;
use think\Model;
use think\Request;
use think\Config;
class Ad extends Model {
use \app\common\traits\IndexModel;
}

60
app/common/model/Agents.php Executable file
View File

@@ -0,0 +1,60 @@
<?php
namespace app\common\model;
use think\Model;
use think\Request;
use think\Config;
class Agents extends Model {
use \app\common\traits\IndexModel;
public function getAgentList($where = null, $order = null, $field = null, $limit = null) {
if (is_array($where)) {
$where = array_merge(['a.stat' => ['eq', '0']], $where);
}
if ($where) {
$this->where($where);
}
if ($order) {
$this->order($order);
}
if ($field) {
$this->field($field);
}
if ($limit) {
$this->limit($limit);
}
$data = $this->select();
return $data;
}
public function getAgentLists($where = null, $order = null, $field = null, $limit = null) {
if (is_array($where)) {
$where = array_merge(['a.stat' => ['eq', '0']], $where);
}
if ($where) {
$this->where($where);
}
if ($order) {
$this->order($order);
}
if ($field) {
$this->field($field);
}
if (empty($limit)) {
$limit = Config::get('list_rows') > 0 ? Config::get('list_rows') : 12;
}
$object = $this->paginate($limit);
// header("content-type:text/html;charset=utf8;");
// print_r($object);
// exit;
return $object;
}
}

60
app/common/model/Article.php Executable file
View File

@@ -0,0 +1,60 @@
<?php
namespace app\common\model;
use think\Model;
use think\Request;
use think\Config;
class Article extends Model {
use \app\common\traits\IndexModel;
public function getCateArticleList($where = null, $order = null, $field = null, $limit = null) {
$this->alias('a')->join('article_category c', 'a.cid=c.id', 'LEFT');
if (is_array($where)) {
$where = array_merge(['a.stat' => ['eq', '0']], $where);
}
if ($where) {
$this->where($where);
}
if ($order) {
$this->order($order);
}
if ($field) {
$this->field($field);
}
if ($limit) {
$this->limit($limit);
}
$data = $this->select();
return $data;
}
public function getCateArticleLists($where = null, $order = null, $field = null, $limit = null) {
$this->alias('a')->join('article_category c', 'a.cid=c.id', 'LEFT');
if (is_array($where)) {
$where = array_merge(['a.stat' => ['eq', '0']], $where);
}
if ($where) {
$this->where($where);
}
if ($order) {
$this->order($order);
}
if ($field) {
$this->field($field);
}
if (empty($limit)) {
$limit = Config::get('list_rows') > 0 ? Config::get('list_rows') : 12;
}
$object = $this->paginate($limit);
// header("content-type:text/html;charset=utf8;");
// print_r($object);
// exit;
return $object;
}
}

View File

@@ -0,0 +1,196 @@
<?php
namespace app\common\model;
use think\Model;
use think\Request;
use think\Config;
class ArticleCategory extends Model {
use \app\common\traits\IndexModel;
public function getCategoryLists($where = null, $order = null, $field = null, $limit = 20, $level = 0, array &$alldata = array()) {
if ($level > 5) {
return;
}
if (is_array($where)) {
$where = array_merge(['stat' => 0], $where);
}
if ($where) {
$this->where($where);
}
if ($order) {
$this->order($order);
}
if ($field) {
$this->field($field);
}
if (empty($limit)) {
$limit = Config::get('list_rows');
$limit = $limit? : 12;
}
if ($limit) {
$this->limit($limit);
}
$list = $this->select();
if ($list) {
foreach ($list as $k => $row) {
$row['level'] = $level;
$alldata[] = $row;
$where['pid'] = $row['id'];
//self::getCategoryLists($where, $order, $field, $limit, $level + 1, $alldata);
!$row['haschild'] ? '' : self::getCategoryLists($where, $order, $field, $limit, $level + 1, $alldata);
}
}
return $alldata;
}
public function getChildIDArray($id) {
$list = $this->where(['pid' => $id, 'stat' => 0])->field(['id', 'haschild'])->select();
$childIDArray = array((int) $id);
if ($list) {
foreach ($list as $val) {
$childArray = $val['haschild'] ? self::getChildIDArray($val['id']) : array((int) $val['id']);
$childIDArray = array_merge($childIDArray, $childArray);
}
}
return $childIDArray;
}
public function getTopParentID($id, $where = null) {
$data = $this::get(function($query)use($id, $where) {
$query->where(['id' => $id]);
if ($where) {
$query->where($where);
}
$query->field(['id', 'pid']);
});
if (isset($data['pid']) && $data['pid']) {
$topid = self::getTopParentID($data['pid'], $where);
} else {
$topid = $id;
}
return $topid;
}
public function getBreadCrumb($id, $where = null, array &$catarr = array()) {
if (!$id) {
return array();
}
if (is_array($where)) {
$where = array_merge(['stat' => ['eq', '0']], $where);
}
if ($where) {
$this->where($where);
}
$data = $this->field(['id', 'name', 'pid'])->get($id);
$catarr[] = $data;
if (isset($data['pid']) && $data['pid']) {
self::getBreadCrumb($data['pid'], $where, $catarr);
} else {
return array_reverse($catarr);
}
return $catarr;
}
public function getCategoryOption($id = 0, $where = null, $order = null, $field = null, $limit = null) {
$options = '';
if (is_array($where)) {
$where = array_merge(['stat' => ['eq', '0']], $where);
}
if ($where) {
$this->where($where);
}
if ($order) {
$this->order($order);
}
if ($field) {
$this->field($field);
}
if ($limit) {
$this->limit($limit);
}
$list = $this->select();
if ($list) {
foreach ($list as $k => $row) {
if ($row['id'] == $id) {
$options.='<option value="' . $row['id'] . '" selected>' . $row['name'] . '</option>' . "\n";
} else {
$options.='<option value="' . $row['id'] . '">' . $row['name'] . '</option>' . "\n";
}
}
}
return $options;
}
public function getCategoryOptions($id = 0, $where = null, $order = null, $field = null, $limit = null, $level = 0) {
$options = '';
if (is_array($where)) {
$where = array_merge(['stat' => ['eq', '0']], $where);
}
if ($where) {
$this->where($where);
}
if ($order) {
$this->order($order);
}
if ($field) {
$this->field($field);
}
if (empty($limit)) {
$limit = Config::get('list_rows');
}
if ($limit) {
$this->limit($limit);
}
$list = $this->select();
if ($list) {
foreach ($list as $k => $row) {
if ($row['id'] == $id) {
$options.='<option value="' . $row['id'] . '" selected>' . ($level ? str_repeat('&#160;&#160;&#160;&#160;', $level) . '&#8970;' : '') . $row['name'] . '</option>' . "\n";
} else {
$options.='<option value="' . $row['id'] . '">' . ($level ? str_repeat('&#160;&#160;&#160;&#160;', $level) . '&#8970;' : '') . $row['name'] . '</option>' . "\n";
}
$where['pid'] = $row['id'];
//$options.=self::getCategoryOptions($id, $where, $order, $field, $limit, $level + 1);
$options.=!$row['haschild'] ? '' : self::getCategoryOptions($id, $where, $order, $field, $limit, $level + 1);
}
}
return $options;
}
public function getCategoryTree($where = null, $order = null, $field = null, $limit = 50, $level = 0) {
if (is_array($where)) {
$where = array_merge(['stat' => ['eq', '0']], $where);
}
$result = array();
if ($level > 5) {
return $result;
}
if ($where) {
$this->where($where);
}
if ($order) {
$this->order($order);
}
if ($field) {
$this->field($field);
}
if ($limit) {
$this->limit($limit);
}
$list = $this->select(); // 获取
if ($list) {
foreach ($list as $row) {
$row['level'] = $level;
$where['pid'] = $row['id'];
//$row['child'] = self::getCategoryTree($where, $order, $field, $limit, $level + 1);
$row['child'] = !$row['haschild'] ? array() : self::getCategoryTree($where, $order, $field, $limit, $level + 1);
$result[] = $row;
}
}
return $result;
}
}

View File

@@ -0,0 +1,110 @@
<?php
namespace app\common\model;
use think\Model;
use think\Request;
use think\Config;
class ArticleComment extends Model {
use \app\common\traits\IndexModel;
public function getPageList($where = null, $order = null, $field = null, $limit = null, $selfpaginate = true) {
$this->alias('a')->join('article as c', 'a.article_id=c.id', 'LEFT');
if (is_array($where)) {
$where = array_merge(['c.stat' => ['in', '0,1']], $where);
}
if ($where) {
$this->where($where);
}
if ($order) {
$this->order($order);
}
if ($field) {
$this->field($field);
}
if (empty($limit)) {
$limit = Config::get('list_rows');
}
$object = $this->paginate($limit);
return $object;
}
public function getList($where = null, $order = null, $field = null, $limit = null) {
$this->alias('a')->join('article as c', 'a.article_id=c.id', 'LEFT');
if (is_array($where)) {
$where = array_merge(['c.stat' => ['eq', '0']], $where);
}
if ($where) {
$this->where($where);
}
if ($field) {
$this->field($field);
}
if ($order) {
$this->order($order);
}
if ($limit) {
$this->limit($limit);
}
//$this->fetchsql(true);
$data = $this->select();
return $data;
}
public function getOneRow($where, $field = null, $order = null, $stat = true) {
$object = $this::get(function($query)use($where, $field, $order, $stat) {
if ($stat) {
$query->where(['stat' => ['eq', '1']]);
}
$query->where('id', $where);
if ($field) {
$query->field($field);
}
if ($order) {
$query->order($order);
}
//$query->fetchsql(true);
});
return $object;
}
public function getRow($where = null, $field = null, $order = null, $fetchsql = false) {
$object = $this::get(function($query)use($where, $field, $order, $fetchsql) {
if (is_numeric($where)) {
$query->where(['stat' => ['eq', '1']])->where('id', $where);
}
if (is_array($where)) {
$where = array_merge(['stat' => ['eq', '1']], $where);
$query->where($where);
}
if ($field) {
$query->field($field);
}
if ($order) {
$query->order($order);
}
//$fetchsql ? $query->fetchsql(true) : '';
});
return $object;
}
public function updateRow($data = [], $where = [], $field = null) {
$object = $this::update($data, $where, $field);
return $object;
}
public function updateRows($data = [], $where = []) {
if (!empty($where)) {
$result = $this->save($data, function($query)use($where) {
$query->where($where);
});
}
return isset($result) ? $result : false;
}
}

60
app/common/model/Ask.php Executable file
View File

@@ -0,0 +1,60 @@
<?php
namespace app\common\model;
use think\Model;
use think\Request;
use think\Config;
class Ask extends Model {
use \app\common\traits\IndexModel;
public function getAskList($where = null, $order = null, $field = null, $limit = null) {
if (is_array($where)) {
$where = array_merge(['a.stat' => ['eq', '0']], $where);
}
if ($where) {
$this->where($where);
}
if ($order) {
$this->order($order);
}
if ($field) {
$this->field($field);
}
if ($limit) {
$this->limit($limit);
}
$data = $this->select();
return $data;
}
public function getInquiryLists($where = null, $order = null, $field = null, $limit = null) {
if (is_array($where)) {
$where = array_merge(['a.stat' => ['eq', '0']], $where);
}
if ($where) {
$this->where($where);
}
if ($order) {
$this->order($order);
}
if ($field) {
$this->field($field);
}
if (empty($limit)) {
$limit = Config::get('list_rows') > 0 ? Config::get('list_rows') : 12;
}
$object = $this->paginate($limit);
// header("content-type:text/html;charset=utf8;");
// print_r($object);
// exit;
return $object;
}
}

125
app/common/model/Banner.php Executable file
View File

@@ -0,0 +1,125 @@
<?php
namespace app\common\model;
use think\Model;
use think\Config;
class Banner extends Model {
use \app\common\traits\IndexModel;
public function getBannerList($where = null, $order = null, $field = null, $limit = null) {
$this->alias('b')->join('banner_type bt', 'b.typeid=bt.id', 'LEFT');
if (is_array($where)) {
$where = array_merge(['b.stat' => 0], $where);
}
if ($where) {
$this->where($where);
}
if ($order) {
$this->order($order);
}
if ($field) {
$this->field($field);
}
if ($limit) {
$this->limit($limit);
}
$data = $this->select();
return $data;
}
public function getBannerLists($where = null, $order = null, $field = null, $limit = null) {
$this->alias('b')->join('banner_type bt', 'b.typeid=bt.id', 'LEFT');
if (is_array($where)) {
$where = array_merge(['b.stat' => 0], $where);
}
if ($where) {
$this->where($where);
}
if ($order) {
$this->order($order);
}
if ($field) {
$this->field($field);
}
if (empty($limit)) {
$limit = Config::get('list_rows') > 0 ? Config::get('list_rows') : 12;
}
//$this->fetchsql(true);
$object = $this->paginate($limit);
// header("content-type:text/html;charset=utf8;");
// print_r($object);
// exit;
return $object;
}
public function getList($where = null, $order = null, $field = null, $limit = null) {
if ($where) {
$this->where($where);
}
if ($order) {
$this->order($order);
}
if ($field) {
$this->field($field);
}
if ($limit) {
$this->limit($limit);
}
$data = $this->select();
return $data;
}
public function getLists($where = null, $order = null, $field = null, $limit = null) {
if ($where) {
$this->where($where);
}
if ($order) {
$this->order($order);
}
if ($field) {
$this->field($field);
}
if (empty($limit)) {
$limit = Config::get('list_rows') > 0 ? Config::get('list_rows') : 12;
}
$object = $this->paginate($limit);
return $object;
}
public function getOneBanner($id, $field = null) {
$object = $this::get(function($query)use($id, $field) {
$query->where(['id' => $id, 'stat' => 0]);
if ($field) {
$query->field($field);
}
});
return $object;
}
public function getBanner($where = null, $field = null, $order = null) {
if (is_array($where)) {
$where = array_merge(['stat' => 0], $where);
}
$object = $this::get(function($query)use($where, $field, $order) {
if ($where) {
$query->where($where);
}
if ($field) {
$query->field($field);
}
if ($order) {
$query->order($order);
}
});
return $object;
}
public function updateBanner($data = [], $where = [], $field = null) {
$object = $this::update($data, $where, $field);
return $object;
}
}

112
app/common/model/Blog.php Executable file
View File

@@ -0,0 +1,112 @@
<?php
namespace app\common\model;
use think\Model;
use think\Request;
use think\Config;
class Blog extends Model {
use \app\common\traits\IndexModel;
public function getBlogLists($where = null, $order = null, $field = null, $limit = null) {
//echo "<pre>++"; print_r($where); die;
//$this->alias('a')->join('blog_remark', 'a.b_id=blog_remark.id', 'LEFT');
if (is_array($where)) {
$where = array_merge(['stat' => ['eq', '1']], $where);
}
if ($where) {
$this->where($where);
}
if ($order) {
$this->order($order);
}
if ($field) {
$this->field($field);
}
if (empty($limit)) {
$limit = Config::get('list_rows') > 0 ? Config::get('list_rows') : 12;
}
$object = $this->paginate($limit);
//header("content-type:text/html;charset=utf8;");
//print_r($object);
//exit;
return $object;
}
public function getRemarkList($where = null, $order = null, $field = null, $limit = null) {
$this->alias('a')->join('blog_remark', 'a.id=blog_remark.b_id', 'LEFT');
if (is_array($where)) {
$where = array_merge(['blog_remark.stat' => ['eq', '1']], $where);
}
if ($where) {
$this->where($where);
}
if ($order) {
$this->order($order);
}
if ($field) {
$this->field($field);
}
if (empty($limit)) {
$limit = Config::get('list_rows') > 0 ? Config::get('list_rows') : 12;
}
$object = $this->paginate($limit);
return $object;
}
public function getBlogDetail($id){
}
public function getOneRow($where, $field = null, $order = null, $stat = true) {
$object = $this::get(function($query)use($where, $field, $order, $stat) {
if ($stat) {
$query->where(['stat' => ['eq', '1']]);
}
$query->where('id', $where);
if ($field) {
$query->field($field);
}
if ($order) {
$query->order($order);
}
//$query->fetchsql(true);
});
return $object;
}
public function getRow($where = null, $field = null, $order = null, $fetchsql = false) {
$object = $this::get(function($query)use($where, $field, $order, $fetchsql) {
if (is_numeric($where)) {
$query->where(['stat' => ['eq', '1']])->where('id', $where);
}
if (is_array($where)) {
$where = array_merge(['stat' => ['eq', '1']], $where);
$query->where($where);
}
if ($field) {
$query->field($field);
}
if ($order) {
$query->order($order);
}
//$fetchsql ? $query->fetchsql(true) : '';
});
return $object;
}
/*public function updateRow($data = [], $where = [], $field = null) {
$object = $this::update($data, $where, $field);
return $object;
}*/
}

110
app/common/model/BlogRemark.php Executable file
View File

@@ -0,0 +1,110 @@
<?php
namespace app\common\model;
use think\Model;
use think\Request;
use think\Config;
class BlogRemark extends Model {
use \app\common\traits\IndexModel;
public function getPageList($where = null, $order = null, $field = null, $limit = null, $selfpaginate = true) {
$this->alias('a')->join('blog_remark', 'a.b_id=blog_remark.id', 'LEFT');
if (is_array($where)) {
$where = array_merge(['blog_remark.stat' => ['in', '0,1']], $where);
}
if ($where) {
$this->where($where);
}
if ($order) {
$this->order($order);
}
if ($field) {
$this->field($field);
}
if (empty($limit)) {
$limit = Config::get('list_rows');
}
$object = $this->paginate($limit);
return $object;
}
public function getList($where = null, $order = null, $field = null, $limit = null) {
$this->alias('a')->join('blog_remark', 'a.b_id=blog_remark.id', 'LEFT');
if (is_array($where)) {
$where = array_merge(['stat' => ['eq', '0']], $where);
}
if ($where) {
$this->where($where);
}
if ($field) {
$this->field($field);
}
if ($order) {
$this->order($order);
}
if ($limit) {
$this->limit($limit);
}
//$this->fetchsql(true);
$data = $this->select();
return $data;
}
public function getOneRow($where, $field = null, $order = null, $stat = true) {
$object = $this::get(function($query)use($where, $field, $order, $stat) {
if ($stat) {
$query->where(['stat' => ['eq', '1']]);
}
$query->where('id', $where);
if ($field) {
$query->field($field);
}
if ($order) {
$query->order($order);
}
//$query->fetchsql(true);
});
return $object;
}
public function getRow($where = null, $field = null, $order = null, $fetchsql = false) {
$object = $this::get(function($query)use($where, $field, $order, $fetchsql) {
if (is_numeric($where)) {
$query->where(['stat' => ['eq', '1']])->where('id', $where);
}
if (is_array($where)) {
$where = array_merge(['stat' => ['eq', '1']], $where);
$query->where($where);
}
if ($field) {
$query->field($field);
}
if ($order) {
$query->order($order);
}
//$fetchsql ? $query->fetchsql(true) : '';
});
return $object;
}
public function updateRow($data = [], $where = [], $field = null) {
$object = $this::update($data, $where, $field);
return $object;
}
public function updateRows($data = [], $where = []) {
if (!empty($where)) {
$result = $this->save($data, function($query)use($where) {
$query->where($where);
});
}
return isset($result) ? $result : false;
}
}

60
app/common/model/Bulk.php Executable file
View File

@@ -0,0 +1,60 @@
<?php
namespace app\common\model;
use think\Model;
use think\Request;
use think\Config;
class Bulk extends Model {
use \app\common\traits\IndexModel;
public function getBulkList($where = null, $order = null, $field = null, $limit = null) {
if (is_array($where)) {
$where = array_merge(['a.stat' => ['eq', '0']], $where);
}
if ($where) {
$this->where($where);
}
if ($order) {
$this->order($order);
}
if ($field) {
$this->field($field);
}
if ($limit) {
$this->limit($limit);
}
$data = $this->select();
return $data;
}
public function getInquiryLists($where = null, $order = null, $field = null, $limit = null) {
if (is_array($where)) {
$where = array_merge(['a.stat' => ['eq', '0']], $where);
}
if ($where) {
$this->where($where);
}
if ($order) {
$this->order($order);
}
if ($field) {
$this->field($field);
}
if (empty($limit)) {
$limit = Config::get('list_rows') > 0 ? Config::get('list_rows') : 12;
}
$object = $this->paginate($limit);
// header("content-type:text/html;charset=utf8;");
// print_r($object);
// exit;
return $object;
}
}

View File

@@ -0,0 +1,60 @@
<?php
namespace app\common\model;
use think\Model;
use think\Request;
use think\Config;
class BulkInquiry extends Model {
use \app\common\traits\IndexModel;
public function getBulkInquiryList($where = null, $order = null, $field = null, $limit = null) {
if (is_array($where)) {
$where = array_merge(['a.stat' => ['eq', '0']], $where);
}
if ($where) {
$this->where($where);
}
if ($order) {
$this->order($order);
}
if ($field) {
$this->field($field);
}
if ($limit) {
$this->limit($limit);
}
$data = $this->select();
return $data;
}
public function getBulkInquiryLists($where = null, $order = null, $field = null, $limit = null) {
if (is_array($where)) {
$where = array_merge(['a.stat' => ['eq', '0']], $where);
}
if ($where) {
$this->where($where);
}
if ($order) {
$this->order($order);
}
if ($field) {
$this->field($field);
}
if (empty($limit)) {
$limit = Config::get('list_rows') > 0 ? Config::get('list_rows') : 12;
}
$object = $this->paginate($limit);
// header("content-type:text/html;charset=utf8;");
// print_r($object);
// exit;
return $object;
}
}

33
app/common/model/ClickSum.php Executable file
View File

@@ -0,0 +1,33 @@
<?php
namespace app\common\model;
use think\Model;
use think\Request;
use think\Config;
class ClickSum extends Model {
use \app\common\traits\IndexModel;
public function getList($where = null, $order = null, $field = null, $limit = null) {
if (is_array($where)) {
$where = array_merge(['stat' => ['eq', '0']], $where);
}
if ($where) {
$this->where($where);
}
if ($order) {
$this->order($order);
}
if ($field) {
$this->field($field);
}
if ($limit) {
$this->limit($limit);
}
$result = $this->select();
return $result;
}
}

32
app/common/model/Collection.php Executable file
View File

@@ -0,0 +1,32 @@
<?php
namespace app\common\model;
use think\Model;
use think\Request;
use think\Config;
class Collection extends Model {
use \app\common\traits\IndexModel;
public function getList($where = null, $order = null, $field = null, $limit = null) {
$this->alias('a')->join('product b', 'a.coll_id=b.id', 'LEFT');
if ($where) {
$this->where($where);
}
if ($order) {
$this->order($order);
}
if ($field) {
$this->field($field);
}
if ($limit) {
$this->limit($limit);
}
$result = $this->paginate($limit);
return $result;
}
}

17
app/common/model/Country.php Executable file
View File

@@ -0,0 +1,17 @@
<?php
/**
* Created by PhpStorm.
* User: ORICO
* Date: 2018-12-25
* Time: 17:13
*/
namespace app\common\model;
use think\Model;
use think\Request;
use think\Config;
class Country extends Model
{
}

107
app/common/model/Customer.php Executable file
View File

@@ -0,0 +1,107 @@
<?php
namespace app\common\model;
use think\Model;
use think\Request;
use think\Config;
use think\Session;
class Customer extends Model {
use \app\common\traits\IndexModel;
/**
* 更新用户密码
*/
public function updatePassword($data) {
//$salt = getstr_random();
$row = array(
'id' => $data['id'],
'password' => md5($data['password']),
'salt' => $data['password'],
);
$object = $this::update($row);
return $object;
}
/**
* 用户登录认证
* @param string $condition 验证条件如用户名邮箱手机号ID
* @param string $password 用户密码
* @param integer $type 用户名类型 1-用户名2-邮箱3-手机4-UID
* @return integer 登录成功-用户ID登录失败-错误编号
*/
public function login($condition, $password, $type = 1) {
$where = [];
switch ($type) {
case 1:$where['firstname'] = $condition;
break;
case 2:$where['email'] = $condition;
break;
case 3:$where['mobile'] = $condition;
break;
case 4:$where['id'] = $condition;
break;
default:
return ['status' => false, 'msg' => '参数错误', 'id' => 0]; //参数错误
}
/* 获取用户数据 */
$row = $this->where($where)->field('id,firstname,lastname,password,salt,login,picture,telephone,email,safe,stat')->find();
if (empty($row) || (int) $row->stat !== 0) {
return ['status' => false, 'msg' => '用户不存在或被禁用', 'id' => 0];
}
if (!$row->safe) {
return ['status' => false, 'msg' => '请联系管理员激活您的账户', 'id' => 0];
}
/* 验证用户密码 */
if (md5($password) !== $row->password) {
return ['status' => false, 'msg' => '密码错误', 'id' => 0];
}
unset($row->password);
unset($row->salt);
/* 登录用户 */
$this->autoLogin($row->toArray());
return ['status' => true, 'msg' => '登录成功', 'id' => $row->id]; //登录成功返回用户ID
}
public function getBasicInfo($id) {
return $this->where(['stat' => 0])->field('id, firstname, picture, sex, email, telephone, qq, birthday, password')->find($id);
}
public function getBasicInfoByTelephone($telephone) {
return $this->where(['telephone' => $telephone, 'stat' => 0])->field('id, firstname, picture, sex, email, telephone, qq, birthday, password')->find();
}
public function getBasicInfoByEmail($email) {
return $this->where(['email' => $email, 'stat' => 0])->field('id, firstname, picture, email, sex, telephone, qq, birthday, password')->find();
}
private function autoLogin($row) {
/* 更新登录信息 */
$data = [
'id' => $row['id'],
'login' => \think\Db::raw('`login`+1'),
//'last_login_time' => Request::instance()->time(),
'ip' => Request::instance()->ip()
];
$this::update($data);
/* 记录登录SESSION和COOKIES */
Session::set('customer_auth', $row);
Session::set('customer_auth_sign', data_auth_sign($row));
unset($row);
}
public function insertRow($data) {
$object = $this::create($data);
return $object;
}
protected function setIpAttr($value) {
if (empty($value)) {
return Request::instance()->ip();
}
return $value;
}
}

60
app/common/model/Download.php Executable file
View File

@@ -0,0 +1,60 @@
<?php
namespace app\common\model;
use think\Model;
use think\Request;
use think\Config;
class Download extends Model {
use \app\common\traits\IndexModel;
public function getCateDownloadList($where = null, $order = null, $field = null, $limit = null) {
$this->alias('a')->join('download_category c', 'a.cid=c.id', 'LEFT');
if (is_array($where)) {
$where = array_merge(['a.stat' => ['eq', '0']], $where);
}
if ($where) {
$this->where($where);
}
if ($order) {
$this->order($order);
}
if ($field) {
$this->field($field);
}
if ($limit) {
$this->limit($limit);
}
$data = $this->select();
return $data;
}
public function getCateDownloadLists($where = null, $order = null, $field = null, $limit = null) {
$this->alias('a')->join('download_category c', 'a.cid=c.id', 'LEFT');
if (is_array($where)) {
$where = array_merge(['a.stat' => ['eq', '0']], $where);
}
if ($where) {
$this->where($where);
}
if ($order) {
$this->order($order);
}
if ($field) {
$this->field($field);
}
if (empty($limit)) {
$limit = Config::get('list_rows') > 0 ? Config::get('list_rows') : 12;
}
//$this->fetchsql(true);
$object = $this->paginate($limit);
// header("content-type:text/html;charset=utf8;");
// print_r($object);
// exit;
return $object;
}
}

View File

@@ -0,0 +1,196 @@
<?php
namespace app\common\model;
use think\Model;
use think\Request;
use think\Config;
class DownloadCategory extends Model {
use \app\common\traits\IndexModel;
public function getCategoryLists($where = null, $order = null, $field = null, $limit = 20, $level = 0, array &$alldata = array()) {
if ($level > 5) {
return;
}
if (is_array($where)) {
$where = array_merge(['stat' => 0], $where);
}
if ($where) {
$this->where($where);
}
if ($order) {
$this->order($order);
}
if ($field) {
$this->field($field);
}
if (empty($limit)) {
$limit = Config::get('list_rows');
$limit = $limit? : 12;
}
if ($limit) {
$this->limit($limit);
}
$list = $this->select();
if ($list) {
foreach ($list as $k => $row) {
$row['level'] = $level;
$alldata[] = $row;
$where['pid'] = $row['id'];
//self::getCategoryLists($where, $order, $field, $limit, $level + 1, $alldata);
!$row['haschild'] ? '' : self::getCategoryLists($where, $order, $field, $limit, $level + 1, $alldata);
}
}
return $alldata;
}
public function getChildIDArray($id) {
$list = $this->where(['pid' => $id, 'stat' => 0])->field(['id', 'haschild'])->select();
$childIDArray = array((int) $id);
if ($list) {
foreach ($list as $val) {
$childArray = $val['haschild'] ? self::getChildIDArray($val['id']) : array((int) $val['id']);
$childIDArray = array_merge($childIDArray, $childArray);
}
}
return $childIDArray;
}
public function getTopParentID($id, $where = null) {
$data = $this::get(function($query)use($id, $where) {
$query->where(['id' => $id]);
if ($where) {
$query->where($where);
}
$query->field(['id', 'pid']);
});
if (isset($data['pid']) && $data['pid']) {
$topid = self::getTopParentID($data['pid'], $where);
} else {
$topid = $id;
}
return $topid;
}
public function getBreadCrumb($id, $where = null, array &$catarr = array()) {
if (!$id) {
return array();
}
if (is_array($where)) {
$where = array_merge(['stat' => ['eq', '0']], $where);
}
if ($where) {
$this->where($where);
}
$data = $this->field(['id', 'name', 'pid'])->get($id);
$catarr[] = $data;
if (isset($data['pid']) && $data['pid']) {
self::getBreadCrumb($data['pid'], $where, $catarr);
} else {
return array_reverse($catarr);
}
return $catarr;
}
public function getCategoryOption($id = 0, $where = null, $order = null, $field = null, $limit = null) {
$options = '';
if (is_array($where)) {
$where = array_merge(['stat' => ['eq', '0']], $where);
}
if ($where) {
$this->where($where);
}
if ($order) {
$this->order($order);
}
if ($field) {
$this->field($field);
}
if ($limit) {
$this->limit($limit);
}
$list = $this->select();
if ($list) {
foreach ($list as $k => $row) {
if ($row['id'] == $id) {
$options.='<option value="' . $row['id'] . '" selected>' . $row['name'] . '</option>' . "\n";
} else {
$options.='<option value="' . $row['id'] . '">' . $row['name'] . '</option>' . "\n";
}
}
}
return $options;
}
public function getCategoryOptions($id = 0, $where = null, $order = null, $field = null, $limit = null, $level = 0) {
$options = '';
if (is_array($where)) {
$where = array_merge(['stat' => ['eq', '0']], $where);
}
if ($where) {
$this->where($where);
}
if ($order) {
$this->order($order);
}
if ($field) {
$this->field($field);
}
if (empty($limit)) {
$limit = Config::get('list_rows');
}
if ($limit) {
$this->limit($limit);
}
$list = $this->select();
if ($list) {
foreach ($list as $k => $row) {
if ($row['id'] == $id) {
$options.='<option value="' . $row['id'] . '" selected>' . ($level ? str_repeat('&#160;&#160;&#160;&#160;', $level) . '&#8970;' : '') . $row['name'] . '</option>' . "\n";
} else {
$options.='<option value="' . $row['id'] . '">' . ($level ? str_repeat('&#160;&#160;&#160;&#160;', $level) . '&#8970;' : '') . $row['name'] . '</option>' . "\n";
}
$where['pid'] = $row['id'];
//$options.=self::getCategoryOptions($id, $where, $order, $field, $limit, $level + 1);
$options.=!$row['haschild'] ? '' : self::getCategoryOptions($id, $where, $order, $field, $limit, $level + 1);
}
}
return $options;
}
public function getCategoryTree($where = null, $order = null, $field = null, $limit = 50, $level = 0) {
if (is_array($where)) {
$where = array_merge(['stat' => ['eq', '0']], $where);
}
$result = array();
if ($level > 5) {
return $result;
}
if ($where) {
$this->where($where);
}
if ($order) {
$this->order($order);
}
if ($field) {
$this->field($field);
}
if ($limit) {
$this->limit($limit);
}
$list = $this->select(); // 获取
if ($list) {
foreach ($list as $row) {
$row['level'] = $level;
$where['pid'] = $row['id'];
//$row['child'] = self::getCategoryTree($where, $order, $field, $limit, $level + 1);
$row['child'] = !$row['haschild'] ? array() : self::getCategoryTree($where, $order, $field, $limit, $level + 1);
$result[] = $row;
}
}
return $result;
}
}

53
app/common/model/Email.php Executable file
View File

@@ -0,0 +1,53 @@
<?php
/**
* Created by PhpStorm.
* User: kingliang
* Date: 2020-10-21
* Time: 15:09
*/
namespace app\common\model;
use app\common\traits\IndexModel;
use think\Model;
use think\Request;
use think\Config;
class Email extends Model
{
use \app\common\traits\IndexModel;
protected $insert = ['state' => 0, 'ip', 'createtime'];
public function insertRow($data) {
$object = $this::create($data);
return $object;
}
public function chickEmail($email) {
$list = $this->where(['email' => $email, 'state' => 0])->select();
if (!$list) {
return true;
}else{
return false;
}
}
// 属性修改器 创建时间
protected function setCreatetimeAttr($value, $data) {
if (empty($value)) {
return time();
} else {
return strtotime($value);
}
}
protected function setContentAttr($value) {
return htmlspecialchars($value);
}
protected function setIpAttr() {
return Request::instance()->ip();
}
}

59
app/common/model/Flink.php Executable file
View File

@@ -0,0 +1,59 @@
<?php
namespace app\common\model;
use think\Model;
use think\Request;
use think\Config;
class Flink extends Model {
use \app\common\traits\IndexModel;
public function getFlinkList($where = null, $order = null, $field = null, $limit = null) {
$this->alias('f')->join('flink_type ft', 'f.typeid=ft.id', 'LEFT');
if (is_array($where)) {
$where = array_merge(['f.stat' => 0], $where);
}
if ($where) {
$this->where($where);
}
if ($order) {
$this->order($order);
}
if ($field) {
$this->field($field);
}
if ($limit) {
$this->limit($limit);
}
$data = $this->select();
return $data;
}
public function getFlinkLists($where = null, $order = null, $field = null, $limit = null) {
$this->alias('f')->join('flink_type ft', 'f.typeid=ft.id', 'LEFT');
if (is_array($where)) {
$where = array_merge(['f.stat' => 0], $where);
}
if ($where) {
$this->where($where);
}
if ($order) {
$this->order($order);
}
if ($field) {
$this->field($field);
}
if (empty($limit)) {
$limit = Config::get('list_rows') > 0 ? Config::get('list_rows') : 12;
}
//$this->fetchsql(true);
$object = $this->paginate($limit);
// header("content-type:text/html;charset=utf8;");
// print_r($object);
// exit;
return $object;
}
}

53
app/common/model/Fq.php Executable file
View File

@@ -0,0 +1,53 @@
<?php
namespace app\common\model;
use think\Model;
use think\Request;
use think\Config;
class Fq extends Model {
use \app\common\traits\IndexModel;
public function getList($where = null, $order = null, $field = null, $limit = null) {
if ($where) {
$this->where($where);
}
if ($order) {
$this->order($order);
}
if ($field) {
$this->field($field);
}
if ($limit) {
$this->limit($limit);
}
$data = $this->select();
return $data;
}
public function getLists($where = null, $order = null, $field = null, $limit = null) {
if ($where) {
$this->where($where);
}
if ($order) {
$this->order($order);
}
if ($field) {
$this->field($field);
}
if (empty($limit)) {
$limit = Config::get('list_rows') > 0 ? Config::get('list_rows') : 10;
}
$object = $this->paginate($limit);
// header("content-type:text/html;charset=utf8;");
// print_r($object);
// exit;
return $object;
}
}

60
app/common/model/Inquiry.php Executable file
View File

@@ -0,0 +1,60 @@
<?php
namespace app\common\model;
use think\Model;
use think\Request;
use think\Config;
class Inquiry extends Model {
use \app\common\traits\IndexModel;
public function getInquiryList($where = null, $order = null, $field = null, $limit = null) {
if (is_array($where)) {
$where = array_merge(['a.stat' => ['eq', '0']], $where);
}
if ($where) {
$this->where($where);
}
if ($order) {
$this->order($order);
}
if ($field) {
$this->field($field);
}
if ($limit) {
$this->limit($limit);
}
$data = $this->select();
return $data;
}
public function getInquiryLists($where = null, $order = null, $field = null, $limit = null) {
if (is_array($where)) {
$where = array_merge(['a.stat' => ['eq', '0']], $where);
}
if ($where) {
$this->where($where);
}
if ($order) {
$this->order($order);
}
if ($field) {
$this->field($field);
}
if (empty($limit)) {
$limit = Config::get('list_rows') > 0 ? Config::get('list_rows') : 12;
}
$object = $this->paginate($limit);
// header("content-type:text/html;charset=utf8;");
// print_r($object);
// exit;
return $object;
}
}

36
app/common/model/Job.php Executable file
View File

@@ -0,0 +1,36 @@
<?php
namespace app\index\model;
use think\Model;
use think\Request;
use think\Config;
class Job extends Model {
use \app\common\traits\AdminModel;
public function getJobLists($where = null, $order = null, $field = null, $limit = null) {
if ($where) {
$this->where($where);
}
if ($order) {
$this->order($order);
}
if ($field) {
$this->field($field);
}
if (empty($limit)) {
$limit = Config::get('list_rows');
}
//$this->fetchsql(true);
$object = $this->paginate($limit);
// header("content-type:text/html;charset=utf8;");
// print_r($object);
// exit;
return $object;
}
}

38
app/common/model/Msgform.php Executable file
View File

@@ -0,0 +1,38 @@
<?php
namespace app\common\model;
use think\Model;
use think\Request;
use think\Config;
class Msgform extends Model {
use \app\common\traits\IndexModel;
protected $auto = ['content'];
protected $insert = ['stat' => 0, 'display' => 0, 'ip', 'createtime'];
public function insertRow($data) {
$object = $this::create($data);
return $object;
}
// 属性修改器 创建时间
protected function setCreatetimeAttr($value, $data) {
if (empty($value)) {
return time();
} else {
return strtotime($value);
}
}
protected function setContentAttr($value) {
return htmlspecialchars($value);
}
protected function setIpAttr() {
return Request::instance()->ip();
}
}

73
app/common/model/Navigation.php Executable file
View File

@@ -0,0 +1,73 @@
<?php
namespace app\common\model;
use think\Model;
use think\Request;
use think\Config;
class Navigation extends Model {
use \app\common\traits\AdminModel;
protected $insert = ['createtime'];
protected $update = ['updatetime'];
public function getNavigationList($where = null, $order = null, $field = null, $limit = null) {
if (is_array($where)) {
$where = array_merge(['stat' => ['in', '0,1']], $where);
}
if ($where) {
$this->where($where);
}
if ($order) {
$this->order($order);
}
if ($field) {
$this->field($field);
}
if ($limit) {
$this->limit($limit);
}
$data = $this->select();
return $data;
}
public function getNavigationLists($where = null, $order = null, $field = null, $limit = null) {
if (is_array($where)) {
$where = array_merge(['stat' => ['in', '0,1']], $where);
}
if ($where) {
$this->where($where);
}
if ($order) {
$this->order($order);
}
if ($field) {
$this->field($field);
}
if (empty($limit)) {
$limit = Config::get('list_rows');
}
//$this->fetchsql(true);
$object = $this->paginate($limit);
// header("content-type:text/html;charset=utf8;");
// print_r($object);
// exit;
return $object;
}
// 属性修改器 创建时间
protected function setCreatetimeAttr($value, $data) {
if (empty($value)) {
return time();
} else {
return strtotime($value);
}
}
}

49
app/common/model/Pinglun.php Executable file
View File

@@ -0,0 +1,49 @@
<?php
namespace app\common\model;
use think\Model;
use think\Request;
use think\Config;
class Pinglun extends Model {
use \app\common\traits\IndexModel;
protected $auto = ['content'];
protected $insert = ['stat' => 0, 'display' => 0, 'ip'];
public function insertRow($data) {
$object = $this::create($data);
return $object;
}
protected function setContentAttr($value) {
return htmlspecialchars($value);
}
protected function setIpAttr() {
return Request::instance()->ip();
}
public function getCommentList($where = null, $order = null, $field = null, $limit = null) {
if (is_array($where)) {
$where = array_merge(['stat' => ['eq', '0']], $where);
}
if ($where) {
$this->where($where);
}
if ($order) {
$this->order($order);
}
if ($field) {
$this->field($field);
}
if (empty($limit)) {
$limit = Config::get('list_rows') > 0 ? Config::get('list_rows') : 12;
}
$object = $this->paginate($limit);
return $object;
}
}

155
app/common/model/Product.php Executable file
View File

@@ -0,0 +1,155 @@
<?php
namespace app\common\model;
use think\Model;
use think\Request;
use think\Config;
use think\Db;
class Product extends Model {
use \app\common\traits\IndexModel;
public function getCateProductList($where = null, $order = null, $field = null, $limit = null) {
$this->alias('p')->join('product_category c', 'p.cid=c.id', 'LEFT');
if (is_array($where)) {
$where = array_merge(['p.stat' => ['eq', '0'],'p.is_show' =>'0'], $where);
}
if ($where) {
$this->where($where);
}
if ($order) {
$this->order($order);
}
if ($field) {
$this->field($field);
}
if ($limit) {
$this->limit($limit);
}
$data = $this->select();
return $data;
}
public function getCateProductLists($where = null, $order = null, $field = null, $limit = null) {
$this->alias('p')->join('product_category c', 'p.cid=c.id', 'LEFT');
if (is_array($where)) {
$where = array_merge(['p.stat' => ['eq', '0']], $where);
}
if ($where) {
$this->where($where);
}
if ($order) {
$this->order($order);
}
if ($field) {
$this->field($field);
}
if (empty($limit)) {
$limit = Config::get('list_rows') > 0 ? Config::get('list_rows') : 12;
}
$object = $this->paginate($limit);
return $object;
}
public function getRelatedProductList($where = null, $order = null, $field = null, $limit = null) {
$this->alias('p')->join('product_related pr', 'p.id=pr.related_product_id', 'LEFT');
if (is_array($where)) {
$where = array_merge(['p.stat' => ['eq', '0'], 'pr.stat' => ['eq', '0'], 'pr.product_id' => '0'], $where);
}
if ($where) {
$this->where($where);
}
if ($order) {
$this->order($order);
}
if ($field) {
$this->field($field);
}
if ($limit) {
$this->limit($limit);
}
$data = $this->select();
return $data;
}
public function productImg()
{
return $this->hasMany('ProductBkImg', 'product_id', 'id');
}
public function productTwoImg(){
return $this->hasMany('ProductTwoImg','product_id','id');
}
public function productCategory()
{
return $this->belongsTo('ProductCategory', "id", 'cid');
}
/******获取新品数据******/
public function getNewProductLists($where = null, $order = null, $field = null, $limit = null) {
$this->alias('p')->join('product_category c', 'p.cid=c.id', 'INNER')->join('product_category t', 'c.pid=t.id', 'INNER');
if (is_array($where)) {
$where = array_merge(['p.stat' => ['eq', '0'],'p.isnew' => ['eq', '1'],'p.is_show' => ['eq', '0'],'t.isshow' => ['eq', '1'],'p.country_code' => ['eq', 'US']], $where);
}
if ($where) {
$this->where($where);
}
if ($order) {
$this->order($order);
}
if ($field) {
$this->field($field);
}
if (empty($limit)) {
$this->limit($limit);
}
$data = $this->select();
return $data;
}
/******获取新品数据******/
public function getCnNewProductLists($where = null, $order = null, $field = null, $limit = null) {
$this->alias('p')->join('product_category c', 'p.cid=c.id', 'INNER')->join('product_category t', 'c.pid=t.id', 'INNER');
if (is_array($where)) {
$where = array_merge(['p.stat' => ['eq', '0'],'p.isnew' => ['eq', '1'],'p.is_show' => ['eq', '0'],'t.isshow' => ['eq', '1'],'p.country_code' => ['eq', 'ZH']], $where);
}
if ($where) {
$this->where($where);
}
if ($order) {
$this->order($order);
}
if ($field) {
$this->field($field);
}
if (empty($limit)) {
$this->limit($limit);
}
$data = $this->select();
return $data;
}
public function getNewItemLists($where = null, $order = null, $field = null, $limit = null) {
$this->alias('p')->join('product_category c', 'p.cid=c.id', 'INNER')->join('product_category t', 'c.pid=t.id', 'INNER');
if (is_array($where)) {
$where = array_merge(['p.stat' => ['eq', '0'],'p.isnew' => ['eq', '1'],'p.is_show' => ['eq', '0'],'t.isshow' => ['eq', '1'],'p.country_code' => ['eq', 'ZH']], $where);
}
if ($where) {
$this->where($where);
}
if ($order) {
$this->order($order);
}
if ($field) {
$this->field($field);
}
if (empty($limit)) {
$this->limit($limit);
}
$data = $this->select();
return $data;
}
}

View File

@@ -0,0 +1,20 @@
<?php
/**
* Created by PhpStorm.
* User: ORICO
* Date: 2018-10-22
* Time: 11:42
*/
namespace app\common\model;
use think\Model;
use think\Request;
use think\Config;
class ProductBkImg extends Model {
use \app\common\traits\AdminModel;
}

View File

@@ -0,0 +1,196 @@
<?php
namespace app\common\model;
use think\Model;
use think\Request;
use think\Config;
class ProductCategory extends Model {
use \app\common\traits\IndexModel;
public function getCategoryLists($where = null, $order = null, $field = null, $limit = 20, $level = 0, array &$alldata = array()) {
if ($level > 5) {
return;
}
if (is_array($where)) {
$where = array_merge(['stat' => 0], $where);
}
if ($where) {
$this->where($where);
}
if ($order) {
$this->order($order);
}
if ($field) {
$this->field($field);
}
if (empty($limit)) {
$limit = Config::get('list_rows');
$limit = $limit? : 12;
}
if ($limit) {
$this->limit($limit);
}
$list = $this->select();
if ($list) {
foreach ($list as $k => $row) {
$row['level'] = $level;
$alldata[] = $row;
$where['pid'] = $row['id'];
//self::getCategoryLists($where, $order, $field, $limit, $level + 1, $alldata);
!$row['haschild'] ? '' : self::getCategoryLists($where, $order, $field, $limit, $level + 1, $alldata);
}
}
return $alldata;
}
public function getChildIDArray($id) {
$list = $this->where(['pid' => $id, 'stat' => 0])->field(['id', 'haschild'])->select();
$childIDArray = array((int) $id);
if ($list) {
foreach ($list as $val) {
$childArray = $val['haschild'] ? self::getChildIDArray($val['id']) : array((int) $val['id']);
$childIDArray = array_merge($childIDArray, $childArray);
}
}
return $childIDArray;
}
public function getTopParentID($id, $where = null) {
$data = $this::get(function($query)use($id, $where) {
$query->where(['id' => $id]);
if ($where) {
$query->where($where);
}
$query->field(['id', 'pid']);
});
if (isset($data['pid']) && $data['pid']) {
$topid = self::getTopParentID($data['pid'], $where);
} else {
$topid = $id;
}
return $topid;
}
public function getBreadCrumb($id, $where = null, array &$catarr = array()) {
if (!$id) {
return array();
}
if (is_array($where)) {
$where = array_merge(['stat' => ['eq', '0']], $where);
}
if ($where) {
$this->where($where);
}
$data = $this->field(['id', 'name', 'pid'])->get($id);
$catarr[] = $data;
if (isset($data['pid']) && $data['pid']) {
self::getBreadCrumb($data['pid'], $where, $catarr);
} else {
return array_reverse($catarr);
}
return $catarr;
}
public function getCategoryOption($id = 0, $where = null, $order = null, $field = null, $limit = null) {
$options = '';
if (is_array($where)) {
$where = array_merge(['stat' => ['eq', '0']], $where);
}
if ($where) {
$this->where($where);
}
if ($order) {
$this->order($order);
}
if ($field) {
$this->field($field);
}
if ($limit) {
$this->limit($limit);
}
$list = $this->select();
if ($list) {
foreach ($list as $k => $row) {
if ($row['id'] == $id) {
$options.='<option value="' . $row['id'] . '" selected>' . $row['name'] . '</option>' . "\n";
} else {
$options.='<option value="' . $row['id'] . '">' . $row['name'] . '</option>' . "\n";
}
}
}
return $options;
}
public function getCategoryOptions($id = 0, $where = null, $order = null, $field = null, $limit = null, $level = 0) {
$options = '';
if (is_array($where)) {
$where = array_merge(['stat' => ['eq', '0']], $where);
}
if ($where) {
$this->where($where);
}
if ($order) {
$this->order($order);
}
if ($field) {
$this->field($field);
}
if (empty($limit)) {
$limit = Config::get('list_rows');
}
if ($limit) {
$this->limit($limit);
}
$list = $this->select();
if ($list) {
foreach ($list as $k => $row) {
if ($row['id'] == $id) {
$options.='<option value="' . $row['id'] . '" selected>' . ($level ? str_repeat('&#160;&#160;&#160;&#160;', $level) . '&#8970;' : '') . $row['name'] . '</option>' . "\n";
} else {
$options.='<option value="' . $row['id'] . '">' . ($level ? str_repeat('&#160;&#160;&#160;&#160;', $level) . '&#8970;' : '') . $row['name'] . '</option>' . "\n";
}
$where['pid'] = $row['id'];
//$options.=self::getCategoryOptions($id, $where, $order, $field, $limit, $level + 1);
$options.=!$row['haschild'] ? '' : self::getCategoryOptions($id, $where, $order, $field, $limit, $level + 1);
}
}
return $options;
}
public function getCategoryTree($where = null, $order = null, $field = null, $limit = 50, $level = 0) {
if (is_array($where)) {
$where = array_merge(['stat' => ['eq', '0']], $where);
}
$result = array();
if ($level > 5) {
return $result;
}
if ($where) {
$this->where($where);
}
if ($order) {
$this->order($order);
}
if ($field) {
$this->field($field);
}
if ($limit) {
$this->limit($limit);
}
$list = $this->select(); // 获取
if ($list) {
foreach ($list as $row) {
$row['level'] = $level;
$where['pid'] = $row['id'];
//$row['child'] = self::getCategoryTree($where, $order, $field, $limit, $level + 1);
$row['child'] = !$row['haschild'] ? array() : self::getCategoryTree($where, $order, $field, $limit, $level + 1);
$result[] = $row;
}
}
return $result;
}
}

12
app/common/model/ProductDl.php Executable file
View File

@@ -0,0 +1,12 @@
<?php
namespace app\common\model;
use think\Model;
use think\Request;
use think\Config;
class ProductDl extends Model {
use \app\common\traits\IndexModel;
}

View File

@@ -0,0 +1,12 @@
<?php
namespace app\common\model;
use think\Model;
use think\Request;
use think\Config;
class ProductImage extends Model {
use \app\common\traits\IndexModel;
}

View File

@@ -0,0 +1,8 @@
<?php
namespace app\common\model;
use think\Model;
class ProductSeries extends Model
{
}

17
app/common/model/ProductSku.php Executable file
View File

@@ -0,0 +1,17 @@
<?php
/**
* Created by PhpStorm.
* User: ORICO
* Date: 2019-07-26
* Time: 14:24
*/
namespace app\common\model;
use think\Model;
use think\Request;
use think\Config;
class ProductSku extends Model
{
use \app\common\traits\IndexModel;
}

View File

@@ -0,0 +1,17 @@
<?php
/**
* Created by PhpStorm.
* User: ORICO
* Date: 2018-12-25
* Time: 17:13
*/
namespace app\common\model;
use think\Model;
use think\Request;
use think\Config;
class ProductSpecial extends Model
{
}

View File

@@ -0,0 +1,18 @@
<?php
/**
* Created by PhpStorm.
* User: ORICO
* Date: 2018-10-22
* Time: 10:37
*/
namespace app\common\model;
use think\Model;
use think\Request;
use think\Config;
class ProductTwoImg extends Model {
use \app\common\traits\AdminModel;
}

12
app/common/model/Question.php Executable file
View File

@@ -0,0 +1,12 @@
<?php
namespace app\common\model;
use think\Model;
use think\Request;
use think\Config;
class Question extends Model {
use \app\common\traits\IndexModel;
}

View File

@@ -0,0 +1,29 @@
<?php
namespace app\common\model;
use think\Model;
use think\Request;
use think\Config;
class QuestionCategory extends Model {
use \app\common\traits\IndexModel;
public function getList($where = null, $order = null, $field = null, $limit = null) {
if ($where) {
$this->where($where);
}
if ($order) {
$this->order($order);
}
if ($field) {
$this->field($field);
}
if ($limit) {
$this->limit($limit);
}
$data = $this->select();
return $data;
}
}

29
app/common/model/Report.php Executable file
View File

@@ -0,0 +1,29 @@
<?php
namespace app\common\model;
use think\Model;
use think\Request;
use think\Config;
class Report extends Model {
use \app\common\traits\IndexModel;
public function getList($where = null, $order = null, $field = null, $limit = null) {
if ($where) {
$this->where($where);
}
if ($order) {
$this->order($order);
}
if ($field) {
$this->field($field);
}
if ($limit) {
$this->limit($limit);
}
$data = $this->paginate($limit);
return $data;
}
}

155
app/common/model/Singlepage.php Executable file
View File

@@ -0,0 +1,155 @@
<?php
namespace app\common\model;
use think\Model;
use think\Request;
use think\Config;
class Singlepage extends Model {
use \app\common\traits\IndexModel;
public function getSinglepageLists($where = null, $order = null, $field = null, $limit = 20, $level = 0, array &$alldata = array()) {
if ($level > 3) {
return;
}
if (is_array($where)) {
$where = array_merge(['stat' => 0], $where);
}
if ($where) {
$this->where($where);
}
if ($order) {
$this->order($order);
}
if ($field) {
$this->field($field);
}
if (empty($limit)) {
$limit = Config::get('list_rows');
$limit = $limit? : 12;
}
if ($limit) {
$this->limit($limit);
}
$list = $this->select();
if ($list) {
foreach ($list as $k => $row) {
$row['level'] = $level;
$alldata[] = $row;
$where['pid'] = $row['id'];
self::getSinglepageLists($where, $order, $field, $limit, $level + 1, $alldata);
}
}
return $alldata;
}
public function getChildIDArray($id) {
$list = $this->where(['pid' => $id])->field('id')->select();
$childIDArray = array((int) $id);
if ($list) {
foreach ($list as $val) {
$childArray = self::getChildIDArray($val['id']);
$childIDArray = array_merge($childIDArray, $childArray);
}
}
return $childIDArray;
}
public function getTopParentID($id, $where = null) {
$data = $this::get(function($query)use($id, $where) {
$query->where(['id' => $id]);
if ($where) {
$query->where($where);
}
$query->field(['id', 'pid']);
});
if (isset($data['pid']) && $data['pid']) {
$topid = self::getTopParentID($data['pid'], $where);
} else {
$topid = $id;
}
return $topid;
}
public function getBreadCrumb($id, $where = null, array &$catarr = array()) {
if (!$id) {
return array();
}
if (is_array($where)) {
$where = array_merge(['stat' => ['eq', '0']], $where);
}
if ($where) {
$this->where($where);
}
$data = $this->field(['id', 'name', 'pid'])->get($id);
$catarr[] = $data;
if (isset($data['pid']) && $data['pid']) {
self::getBreadCrumb($data['pid'], $where, $catarr);
} else {
return array_reverse($catarr);
}
return $catarr;
}
public function getOption($id = 0, $where = null, $order = null, $field = null, $limit = 20) {
$options = '';
if ($where) {
$this->where($where);
}
if ($order) {
$this->order($order);
}
if ($field) {
$this->field($field);
}
if ($limit) {
$this->limit($limit);
}
$list = $this->select();
if ($list) {
foreach ($list as $k => $row) {
if ($row['id'] == $id) {
$options.='<option value="' . $row['id'] . '" selected>' . $row['name'] . '</option>' . "\n";
} else {
$options.='<option value="' . $row['id'] . '">' . $row['name'] . '</option>' . "\n";
}
}
}
return $options;
}
public function getOptions($id = 0, $where = null, $order = null, $field = null, $limit = null, $level = 0) {
$options = '';
if ($where) {
$this->where($where);
}
if ($order) {
$this->order($order);
}
if ($field) {
$this->field($field);
}
if (empty($limit)) {
$limit = Config::get('list_rows');
}
if ($limit) {
$this->limit($limit);
}
$list = $this->select();
if ($list) {
foreach ($list as $k => $row) {
if ($row['id'] == $id) {
$options.='<option value="' . $row['id'] . '" selected>' . ($level ? str_repeat('&#160;&#160;&#160;&#160;', $level) . '&#8970;' : '') . $row['name'] . '</option>' . "\n";
} else {
$options.='<option value="' . $row['id'] . '">' . ($level ? str_repeat('&#160;&#160;&#160;&#160;', $level) . '&#8970;' : '') . $row['name'] . '</option>' . "\n";
}
$where['pid'] = $row['id'];
$options.=self::getOptions($id, $where, $order, $field, $limit, $level + 1);
}
}
return $options;
}
}

17
app/common/model/Ssd.php Executable file
View File

@@ -0,0 +1,17 @@
<?php
/**
* Created by PhpStorm.
* User: ORICO
* Date: 2019-07-24
* Time: 16:28
*/
namespace app\common\model;
use think\Model;
use think\Request;
use think\Config;
class Ssd extends Model {
use \app\common\traits\IndexModel;
}

85
app/common/model/Sysconfig.php Executable file
View File

@@ -0,0 +1,85 @@
<?php
namespace app\common\model;
use think\Model;
use think\Request;
use think\Config;
class Sysconfig extends Model {
use \app\common\traits\IndexModel;
/**
* 获取数据库中的配置列表
* @return array 配置数组
*/
public function configLists($where = null) {
$data = $this::all(function($query)use($where) {
$query->where(['stat' => 0])->field('type,name,value,extra');
if ($where) {
$query->where($where);
}
$query->order(['sort' => 'asc', 'id' => 'asc']);
});
$config = [];
if ($data && is_array($data)) {
foreach ($data as $value) {
$config[$value->data['name']] = self::parse($value->data['type'], $value->data['value'], $value->data['extra']);
}
}
return $config;
}
/**
* 根据配置类型解析配置
* @param integer $type 配置类型
* @param string $value 配置值
* @param string $extra 配置项
*/
private function parse($type, $value, $extra = '') {
switch ($type) {
// case 'number':
// $value = intval($value);
// break;
case 'json':
$value = json_decode($value, true);
break;
case 'array': //解析数组
$array = preg_split('/[,;\r\n]+/', trim($value, ",;\r\n"));
if (strpos($value, ':')) {
$value = array();
foreach ($array as $val) {
list($k, $v) = explode(':', $val);
$value[$k] = $v;
}
} else {
$value = $array;
}
break;
// case 'enum': //解析数组
// $array = preg_split('/[,;\r\n]+/', trim($extra, ",;\r\n"));
// if (strpos($value, ':')) {
// $valarr = array();
// foreach ($array as $val) {
// list($k, $v) = explode(':', $val);
// $valarr[$k] = $v;
// }
// } else {
// $valarr = $array;
// }
// $value = isset($valarr[$value]) ? $valarr[$value] : $value;
// break;
case 'dump':
dump($value);
// die;
break;
default:
//dump($value);
// die;
break;
}
return $value;
}
}

18
app/common/model/Tbpl.php Executable file
View File

@@ -0,0 +1,18 @@
<?php
/**
* Created by PhpStorm.
* User: ORICO
* Date: 2019-01-09
* Time: 10:20
*/
namespace app\common\model;
use think\Model;
use think\Request;
use think\Config;
class Tbpl extends Model
{
use \app\common\traits\IndexModel;
}

59
app/common/model/Video.php Executable file
View File

@@ -0,0 +1,59 @@
<?php
namespace app\common\model;
use think\Model;
use think\Request;
use think\Config;
class Video extends Model {
use \app\common\traits\IndexModel;
public function getCateVideoList($where = null, $order = null, $field = null, $limit = null) {
$this->alias('a')->join('video_category c', 'a.cid=c.id', 'LEFT');
if (is_array($where)) {
$where = array_merge(['a.stat' => ['eq', '0']], $where);
}
if ($where) {
$this->where($where);
}
if ($order) {
$this->order($order);
}
if ($field) {
$this->field($field);
}
if ($limit) {
$this->limit($limit);
}
$data = $this->select();
return $data;
}
public function getCateVideoLists($where = null, $order = null, $field = null, $limit = null) {
$this->alias('a')->join('video_category c', 'a.cid=c.id', 'LEFT');
if (is_array($where)) {
$where = array_merge(['a.stat' => ['eq', '0']], $where);
}
if ($where) {
$this->where($where);
}
if ($order) {
$this->order($order);
}
if ($field) {
$this->field($field);
}
if (empty($limit)) {
$limit = Config::get('list_rows') > 0 ? Config::get('list_rows') : 12;
}
//$this->fetchsql(true);
$object = $this->paginate($limit);
// header("content-type:text/html;charset=utf8;");
// print_r($object);
// exit;
return $object;
}
}

View File

@@ -0,0 +1,196 @@
<?php
namespace app\common\model;
use think\Model;
use think\Request;
use think\Config;
class VideoCategory extends Model {
use \app\common\traits\IndexModel;
public function getCategoryLists($where = null, $order = null, $field = null, $limit = 20, $level = 0, array &$alldata = array()) {
if ($level > 5) {
return;
}
if (is_array($where)) {
$where = array_merge(['stat' => 0], $where);
}
if ($where) {
$this->where($where);
}
if ($order) {
$this->order($order);
}
if ($field) {
$this->field($field);
}
if (empty($limit)) {
$limit = Config::get('list_rows');
$limit = $limit? : 12;
}
if ($limit) {
$this->limit($limit);
}
$list = $this->select();
if ($list) {
foreach ($list as $k => $row) {
$row['level'] = $level;
$alldata[] = $row;
$where['pid'] = $row['id'];
//self::getCategoryLists($where, $order, $field, $limit, $level + 1, $alldata);
!$row['haschild'] ? '' : self::getCategoryLists($where, $order, $field, $limit, $level + 1, $alldata);
}
}
return $alldata;
}
public function getChildIDArray($id) {
$list = $this->where(['pid' => $id, 'stat' => 0])->field(['id', 'haschild'])->select();
$childIDArray = array((int) $id);
if ($list) {
foreach ($list as $val) {
$childArray = $val['haschild'] ? self::getChildIDArray($val['id']) : array((int) $val['id']);
$childIDArray = array_merge($childIDArray, $childArray);
}
}
return $childIDArray;
}
public function getTopParentID($id, $where = null) {
$data = $this::get(function($query)use($id, $where) {
$query->where(['id' => $id]);
if ($where) {
$query->where($where);
}
$query->field(['id', 'pid']);
});
if (isset($data['pid']) && $data['pid']) {
$topid = self::getTopParentID($data['pid'], $where);
} else {
$topid = $id;
}
return $topid;
}
public function getBreadCrumb($id, $where = null, array &$catarr = array()) {
if (!$id) {
return array();
}
if (is_array($where)) {
$where = array_merge(['stat' => ['eq', '0']], $where);
}
if ($where) {
$this->where($where);
}
$data = $this->field(['id', 'name', 'pid'])->get($id);
$catarr[] = $data;
if (isset($data['pid']) && $data['pid']) {
self::getBreadCrumb($data['pid'], $where, $catarr);
} else {
return array_reverse($catarr);
}
return $catarr;
}
public function getCategoryOption($id = 0, $where = null, $order = null, $field = null, $limit = null) {
$options = '';
if (is_array($where)) {
$where = array_merge(['stat' => ['eq', '0']], $where);
}
if ($where) {
$this->where($where);
}
if ($order) {
$this->order($order);
}
if ($field) {
$this->field($field);
}
if ($limit) {
$this->limit($limit);
}
$list = $this->select();
if ($list) {
foreach ($list as $k => $row) {
if ($row['id'] == $id) {
$options.='<option value="' . $row['id'] . '" selected>' . $row['name'] . '</option>' . "\n";
} else {
$options.='<option value="' . $row['id'] . '">' . $row['name'] . '</option>' . "\n";
}
}
}
return $options;
}
public function getCategoryOptions($id = 0, $where = null, $order = null, $field = null, $limit = null, $level = 0) {
$options = '';
if (is_array($where)) {
$where = array_merge(['stat' => ['eq', '0']], $where);
}
if ($where) {
$this->where($where);
}
if ($order) {
$this->order($order);
}
if ($field) {
$this->field($field);
}
if (empty($limit)) {
$limit = Config::get('list_rows');
}
if ($limit) {
$this->limit($limit);
}
$list = $this->select();
if ($list) {
foreach ($list as $k => $row) {
if ($row['id'] == $id) {
$options.='<option value="' . $row['id'] . '" selected>' . ($level ? str_repeat('&#160;&#160;&#160;&#160;', $level) . '&#8970;' : '') . $row['name'] . '</option>' . "\n";
} else {
$options.='<option value="' . $row['id'] . '">' . ($level ? str_repeat('&#160;&#160;&#160;&#160;', $level) . '&#8970;' : '') . $row['name'] . '</option>' . "\n";
}
$where['pid'] = $row['id'];
//$options.=self::getCategoryOptions($id, $where, $order, $field, $limit, $level + 1);
$options.=!$row['haschild'] ? '' : self::getCategoryOptions($id, $where, $order, $field, $limit, $level + 1);
}
}
return $options;
}
public function getCategoryTree($where = null, $order = null, $field = null, $limit = 50, $level = 0) {
if (is_array($where)) {
$where = array_merge(['stat' => ['eq', '0']], $where);
}
$result = array();
if ($level > 5) {
return $result;
}
if ($where) {
$this->where($where);
}
if ($order) {
$this->order($order);
}
if ($field) {
$this->field($field);
}
if ($limit) {
$this->limit($limit);
}
$list = $this->select(); // 获取
if ($list) {
foreach ($list as $row) {
$row['level'] = $level;
$where['pid'] = $row['id'];
//$row['child'] = self::getCategoryTree($where, $order, $field, $limit, $level + 1);
$row['child'] = !$row['haschild'] ? array() : self::getCategoryTree($where, $order, $field, $limit, $level + 1);
$result[] = $row;
}
}
return $result;
}
}

208
app/common/traits/AdminModel.php Executable file
View File

@@ -0,0 +1,208 @@
<?php
namespace app\common\traits;
use think\Model as BaseModel;
use think\Config;
trait AdminModel {
// // 设置完整的数据表(包含前缀)
// protected $table = '';
// /*
// * 数据自动完成指在不需要手动赋值的情况下对字段的值进行处理后写入数据库
// * 系统支持 auto 、 insert 和 update 三个属性可以分别在写入、添加和更新的时候进行字段的自动完成机制auto属性自动完成包含添加和更新操作
// */
// protected $insert = [];
// protected $update = [];
//自定义初始化
// protected function initialize() {
// //需要调用`Model`的`initialize`方法
// parent::initialize();
// }
//
// //自定义初始化
// protected static function init() {
// //TODO:自定义的初始化
// }
public function getPageList($where = null, $order = null, $field = null, $limit = null, $selfpaginate = true) {
//$this->alias('this')->join('table that', 'this.id=that.id', 'LEFT')->join('othertable other', 'other.id=this.id', 'LEFT');
if (is_array($where)) {
$where = array_merge(['stat' => ['eq', '0']], $where);
}
if ($where) {
$this->where($where);
}
if ($order) {
$this->order($order);
}
if ($field) {
$this->field($field);
}
if (empty($limit)) {
$limit = Config::get('list_rows');
}
if ($selfpaginate) {
$object = $this->paginate($limit);
} else {
$object = $this->paginate($limit, false, [ 'type' => 'bootstrap', 'var_page' => 'page',]);
}
//$object = $this->paginate($limit);
return $object;
}
public function getList($where = null, $order = null, $field = null, $limit = null) {
if (is_array($where)) {
$where = array_merge(['stat' => ['eq', '0']], $where);
}
if ($where) {
$this->where($where);
}
if ($field) {
$this->field($field);
}
if ($order) {
$this->order($order);
}
if ($limit) {
$this->limit($limit);
}
$data = $this->select();
return $data;
}
public function getOneRow($where, $field = null, $order = null, $stat = true) {
$object = $this::get(function($query)use($where, $field, $order, $stat) {
if ($stat) {
$query->where(['stat' => ['eq', '0']]);
}
$query->where('id', $where);
if ($field) {
$query->field($field);
}
if ($order) {
$query->order($order);
}
//$query->fetchsql(true);
});
return $object;
}
public function getRow($where = null, $field = null, $order = null, $fetchsql = false) {
$object = $this::get(function($query)use($where, $field, $order, $fetchsql) {
if (is_numeric($where)) {
$query->where(['stat' => ['eq', '0']])->where('id', $where);
}
if (is_array($where)) {
$where = array_merge(['stat' => ['eq', '0']], $where);
$query->where($where);
}
if ($field) {
$query->field($field);
}
if ($order) {
$query->order($order);
}
//$fetchsql ? $query->fetchsql(true) : '';
});
return $object;
}
public function insertRow($data) {
$object = $this::create($data);
return $object;
}
public function saveRows($data) {
$object = $this->saveAll($data);
return $object;
}
public function updateRow($data = [], $where = [], $field = null) {
$object = $this::update($data, $where, $field);
return $object;
}
public function updateRows($data = [], $where = []) {
if (!empty($where)) {
$result = $this->save($data, function($query)use($where) {
$query->where($where);
});
}
return isset($result) ? $result : false;
}
public function deleteRow($where, $stat = -1) {
//$result = $this::destroy($id);
if (is_array($where)) {
$wheres = $where;
$data['stat'] = $stat;
} else {
$wheres = ['id' => $where];
$data = ['stat' => $stat];
}
$object = $this::update($data, $wheres);
return $object;
}
public function deleteRows($ids, $stat = -1) {
if (isset($ids) && !empty($ids)) {
$result = $this->where(function($query)use($ids) {
$query->where('id', 'in', $ids);
})->update(['stat' => $stat]);
}
return isset($result) ? $result : false;
}
public function destroyRow($id) {
$result = $this::destroy($id);
return $result;
}
public function destroyRows($ids) {
if (isset($ids) && !empty($ids)) {
//$result = $this::destroy($ids);
$result = $this::destroy(function($query)use($ids) {
$query->where('id', 'in', $ids);
});
}
return isset($result) ? $result : false;
}
public function getOtherList($where = null, $order = null, $field = null, $limit = null) {
if ($where) {
$this->where($where);
}
if ($field) {
$this->field($field);
}
if ($order) {
$this->order($order);
}
if ($limit) {
$this->limit($limit);
}
$data = $this->select();
return $data;
}
public function getOtherLists($where = null, $order = null, $field = null, $limit = null) {
//$this->alias('this')->join('table that', 'this.id=that.id', 'LEFT')->join('othertable other', 'other.id=this.id', 'LEFT');
if ($where) {
$this->where($where);
}
if ($order) {
$this->order($order);
}
if ($field) {
$this->field($field);
}
if (empty($limit)) {
$limit = Config::get('list_rows');
}
$object = $this->paginate($limit);
return $object;
}
}

108
app/common/traits/IndexModel.php Executable file
View File

@@ -0,0 +1,108 @@
<?php
namespace app\common\traits;
use think\Model as BaseModel;
use think\Config;
trait IndexModel {
public function getPageList($where = null, $order = null, $field = null, $limit = null, $selfpaginate = true) {
//$this->alias('this')->join('table that', 'this.id=that.id', 'LEFT')->join('othertable other', 'other.id=this.id', 'LEFT');
if (is_array($where)) {
$where = array_merge(['stat' => ['eq', '0']], $where);
}
if ($where) {
$this->where($where);
}
if ($order) {
$this->order($order);
}
if ($field) {
$this->field($field);
}
if (empty($limit)) {
$limit = Config::get('list_rows');
}
if ($selfpaginate) {
$object = $this->paginate($limit);
} else {
$object = $this->paginate($limit, false, [ 'type' => 'bootstrap', 'var_page' => 'page',]);
}
//$object = $this->paginate($limit);
return $object;
}
public function getList($where = null, $order = null, $field = null, $limit = null) {
if (is_array($where)) {
$where = array_merge(['stat' => ['eq', '0']], $where);
}
if ($where) {
$this->where($where);
}
if ($field) {
$this->field($field);
}
if ($order) {
$this->order($order);
}
if ($limit) {
$this->limit($limit);
}
//$this->fetchsql(true);
$data = $this->select();
return $data;
}
public function getOneRow($where, $field = null, $order = null, $stat = true) {
$object = $this::get(function($query)use($where, $field, $order, $stat) {
if ($stat) {
$query->where(['stat' => ['eq', '0']]);
}
$query->where('id', $where);
if ($field) {
$query->field($field);
}
if ($order) {
$query->order($order);
}
//$query->fetchsql(true);
});
return $object;
}
public function getRow($where = null, $field = null, $order = null, $fetchsql = false) {
$object = $this::get(function($query)use($where, $field, $order, $fetchsql) {
if (is_numeric($where)) {
$query->where(['stat' => ['eq', '0']])->where('id', $where);
}
if (is_array($where)) {
$where = array_merge(['stat' => ['eq', '0']], $where);
$query->where($where);
}
if ($field) {
$query->field($field);
}
if ($order) {
$query->order($order);
}
//$fetchsql ? $query->fetchsql(true) : '';
});
return $object;
}
public function updateRow($data = [], $where = [], $field = null) {
$object = $this::update($data, $where, $field);
return $object;
}
public function updateRows($data = [], $where = []) {
if (!empty($where)) {
$result = $this->save($data, function($query)use($where) {
$query->where($where);
});
}
return isset($result) ? $result : false;
}
}

62
app/common/view/tpl/404.html Executable file
View File

@@ -0,0 +1,62 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<title>404</title>
<style type="text/css">
body{line-height: 1.6;background-color: #ecf0f5;}
.page-404{padding-top: 60px;padding-bottom: 95px;color: #919191}
.text-center{text-align: center;}
.ml-20{margin-left: 20px;}
.va-middle{vertical-align: middle !important;color: #f39c12 !important;}
.page-404 .error-title{font-size: 80px;}
.page-404 .error-description{font-size: 24px;}
.page-404 .error-info{font-size: 14px;}
.color-primary{color:#5a98de;}
.color-primary:hover{color:#5a98de;text-decoration: underline;}
.page-404 p{margin-bottom: 10px;}
.page-404 .jump{ padding-top: 10px; }
.page-404 .jump a,.copyright p a{outline: none;text-decoration: none;}
.copyright p{width:100%;color:#919191;text-align:center;font-size:10px}
@media (max-width:768px){.page-404{padding-top: 30px;}.ml-20{margin-left: 15px;}}
@media (max-width:480px){.page-404{padding-top: 20px;}.page-404 .error-description{font-size:16px;}}
</style>
</head>
<body>
<div class="page-404 text-center">
<p class="error-title">
<span class="va-middle"> 404 </span>
</p>
<p class="error-description">不好意思,您访问的页面不存在~</p>
<p class="error-info">
<a href="javascript:void(0);" onclick="history.go(-1)" class="color-primary">&lt; 返回上一页</a>
<span class="ml-20">|</span>
<a href="/" class="color-primary ml-20">去首页 &gt;</a>
<span class="ml-20">|</span>
<a href="/index.html" target="_blank" class="color-primary ml-20">寻求帮助 &gt;</a>
</p>
<p class="jump">
页面自动 <a id="href" href="/" class="color-primary">跳转首页</a> 等待时间: <b id="wait">30</b>
</p>
</div>
<div class="copyright">
<p>Copyright © 2018-2018 <a href="/" class="color-primary">COD</a>. All rights reserved. </p>
<p>Powered by <a href="/" class="color-primary">COD</a></p>
</div>
<script type="text/javascript">
(function() {
var wait = document.getElementById('wait'),
href = document.getElementById('href').href;
var interval = setInterval(function() {
var time = --wait.innerHTML;
if (time <= 0) {
location.href = href;
clearInterval(interval);
}
}, 1000);
})();
</script>
</body>
</html>

View File

@@ -0,0 +1,10 @@
<?php
namespace {$app}\{$module}{layer};
class Index{$suffix}
{
public function index()
{
return '<style type="text/css">*{ padding: 0; margin: 0; } div{ padding: 4px 48px;} a{color:#2E5CD5;cursor: pointer;text-decoration: none} a:hover{text-decoration:underline; } body{ background: #fff; font-family: "Century Gothic","Microsoft yahei"; color: #333;font-size:18px;} h1{ font-size: 100px; font-weight: normal; margin-bottom: 12px; } p{ line-height: 1.6em; font-size: 42px }</style><div style="padding: 24px 48px;"> <h1>:)</h1><p> ThinkPHP V5<br/><span style="font-size:30px">十年磨一剑 - 为API开发设计的高性能框架</span></p><span style="font-size:22px;">[ V5.0 版本由 <a href="http://www.qiniu.com" target="qiniu">七牛云</a> 独家赞助发布 ]</span></div><script type="text/javascript" src="http://tajs.qq.com/stats?sId=9347272" charset="UTF-8"></script><script type="text/javascript" src="http://ad.topthink.com/Public/static/client.js"></script><thinkad id="ad_bd568ce7058a1091"></thinkad>';
}
}

View File

@@ -0,0 +1,50 @@
{__NOLAYOUT__}<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
<title>跳转提示</title>
<style type="text/css">
*{ padding: 0; margin: 0; }
body{ background: #fff; font-family: "Microsoft Yahei","Helvetica Neue",Helvetica,Arial,sans-serif; color: #333; font-size: 16px; }
.system-message{ padding: 24px 48px; text-align: center;}
.system-message h1{ font-size: 100px; font-weight: normal; line-height: 120px; margin-bottom: 12px; }
.system-message .jump{ padding-top: 10px; }
.system-message .jump a{ color: #333; }
.system-message .success,.system-message .error{ line-height: 1.8em; font-size: 36px; }
.system-message .detail{ font-size: 12px; line-height: 20px; margin-top: 12px; display: none; }
</style>
</head>
<body>
<div class="system-message">
<?php switch ($code) {?>
<?php case 1:?>
<h1>:)</h1>
<p class="success"><?php echo(strip_tags($msg));?></p>
<?php break;?>
<?php case 0:?>
<h1>:(</h1>
<p class="error"><?php echo(strip_tags($msg));?></p>
<?php break;?>
<?php } ?>
<p class="detail"></p>
<p class="jump">
页面自动 <a id="href" href="<?php echo($url);?>">跳转</a> 等待时间: <b id="wait"><?php echo($wait);?></b>
</p>
</div>
<script type="text/javascript">
(function() {
var wait = document.getElementById('wait'),
href = document.getElementById('href').href;
var interval = setInterval(function() {
var time = --wait.innerHTML;
if (time <= 0) {
location.href = href;
clearInterval(interval);
}
;
}, 1000);
})();
</script>
</body>
</html>

57
app/common/view/tpl/jump.html Executable file
View File

@@ -0,0 +1,57 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<title>404</title>
<style type="text/css">
body{line-height: 1.6;background-color: #ecf0f5;}
.page-404{padding-top: 60px;padding-bottom: 95px;color: #919191}
.text-center{text-align: center;}
.page-404 .success,.page-404 .error{ line-height: 1.8em; font-size: 36px; }
.color-primary{color:#5a98de;}
.color-primary:hover{color:#5a98de;text-decoration: underline;}
.page-404 p{margin-bottom: 10px;}
.page-404 .jump{ padding-top: 10px; }
.page-404 .jump a,.copyright p a{outline: none;text-decoration: none;}
.copyright p{width:100%;color:#919191;text-align:center;font-size:10px}
@media (max-width:768px){.page-404{padding-top: 30px;}.ml-20{margin-left: 15px;}}
@media (max-width:480px){.page-404{padding-top: 20px;}.page-404 .error-description{font-size:16px;}}
</style>
</head>
<body>
<div class="page-404 text-center">
<?php switch ($code) {?>
<?php case 1:?>
<h1>:)</h1>
<p class="success"><?php echo(strip_tags($msg));?></p>
<?php break;?>
<?php case 0:?>
<h1>:(</h1>
<p class="error"><?php echo(strip_tags($msg));?></p>
<?php break;?>
<?php } ?>
<p class="jump">
页面自动 <a id="href" href="<?php echo($url);?>" class="color-primary">跳转</a> 等待时间: <b id="wait"><?php echo($wait);?></b>
</p>
</div>
<div class="copyright">
<p>Copyright © 2018-2018 <a class="color-primary">COD</a>. All rights reserved. </p>
<p>Powered by <a class="color-primary">COD</a></p>
</div>
<script type="text/javascript">
(function() {
var wait = document.getElementById('wait'),
href = document.getElementById('href').href;
var interval = setInterval(function() {
var time = --wait.innerHTML;
if (time <= 0) {
location.href = href;
clearInterval(interval);
}
}, 1000);
})();
</script>
</body>
</html>

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,537 @@
<?php
if(!function_exists('parse_padding')){
function parse_padding($source)
{
$length = strlen(strval(count($source['source']) + $source['first']));
return 40 + ($length - 1) * 8;
}
}
if(!function_exists('parse_class')){
function parse_class($name)
{
$names = explode('\\', $name);
return '<abbr title="'.$name.'">'.end($names).'</abbr>';
}
}
if(!function_exists('parse_file')){
function parse_file($file, $line)
{
return '<a class="toggle" title="'."{$file} line {$line}".'">'.basename($file)." line {$line}".'</a>';
}
}
if(!function_exists('parse_args')){
function parse_args($args)
{
$result = [];
foreach ($args as $key => $item) {
switch (true) {
case is_object($item):
$value = sprintf('<em>object</em>(%s)', parse_class(get_class($item)));
break;
case is_array($item):
if(count($item) > 3){
$value = sprintf('[%s, ...]', parse_args(array_slice($item, 0, 3)));
} else {
$value = sprintf('[%s]', parse_args($item));
}
break;
case is_string($item):
if(strlen($item) > 20){
$value = sprintf(
'\'<a class="toggle" title="%s">%s...</a>\'',
htmlentities($item),
htmlentities(substr($item, 0, 20))
);
} else {
$value = sprintf("'%s'", htmlentities($item));
}
break;
case is_int($item):
case is_float($item):
$value = $item;
break;
case is_null($item):
$value = '<em>null</em>';
break;
case is_bool($item):
$value = '<em>' . ($item ? 'true' : 'false') . '</em>';
break;
case is_resource($item):
$value = '<em>resource</em>';
break;
default:
$value = htmlentities(str_replace("\n", '', var_export(strval($item), true)));
break;
}
$result[] = is_int($key) ? $value : "'{$key}' => {$value}";
}
return implode(', ', $result);
}
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title><?php echo \think\Lang::get('System Error'); ?></title>
<meta name="robots" content="noindex,nofollow" />
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<style>
/* Base */
body {
color: #333;
font: 14px Verdana, "Helvetica Neue", helvetica, Arial, 'Microsoft YaHei', sans-serif;
margin: 0;
padding: 0 20px 20px;
word-break: break-word;
}
h1{
margin: 10px 0 0;
font-size: 28px;
font-weight: 500;
line-height: 32px;
}
h2{
color: #4288ce;
font-weight: 400;
padding: 6px 0;
margin: 6px 0 0;
font-size: 18px;
border-bottom: 1px solid #eee;
}
h3.subheading {
color: #4288ce;
margin: 6px 0 0;
font-weight: 400;
}
h3{
margin: 12px;
font-size: 16px;
font-weight: bold;
}
abbr{
cursor: help;
text-decoration: underline;
text-decoration-style: dotted;
}
a{
color: #868686;
cursor: pointer;
}
a:hover{
text-decoration: underline;
}
.line-error{
background: #f8cbcb;
}
.echo table {
width: 100%;
}
.echo pre {
padding: 16px;
overflow: auto;
font-size: 85%;
line-height: 1.45;
background-color: #f7f7f7;
border: 0;
border-radius: 3px;
font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace;
}
.echo pre > pre {
padding: 0;
margin: 0;
}
/* Layout */
.col-md-3 {
width: 25%;
}
.col-md-9 {
width: 75%;
}
[class^="col-md-"] {
float: left;
}
.clearfix {
clear:both;
}
@media only screen
and (min-device-width : 375px)
and (max-device-width : 667px) {
.col-md-3,
.col-md-9 {
width: 100%;
}
}
/* Exception Info */
.exception {
margin-top: 20px;
}
.exception .message{
padding: 12px;
border: 1px solid #ddd;
border-bottom: 0 none;
line-height: 18px;
font-size:16px;
border-top-left-radius: 4px;
border-top-right-radius: 4px;
font-family: Consolas,"Liberation Mono",Courier,Verdana,"微软雅黑";
}
.exception .code{
float: left;
text-align: center;
color: #fff;
margin-right: 12px;
padding: 16px;
border-radius: 4px;
background: #999;
}
.exception .source-code{
padding: 6px;
border: 1px solid #ddd;
background: #f9f9f9;
overflow-x: auto;
}
.exception .source-code pre{
margin: 0;
}
.exception .source-code pre ol{
margin: 0;
color: #4288ce;
display: inline-block;
min-width: 100%;
box-sizing: border-box;
font-size:14px;
font-family: "Century Gothic",Consolas,"Liberation Mono",Courier,Verdana;
padding-left: <?php echo (isset($source) && !empty($source)) ? parse_padding($source) : 40; ?>px;
}
.exception .source-code pre li{
border-left: 1px solid #ddd;
height: 18px;
line-height: 18px;
}
.exception .source-code pre code{
color: #333;
height: 100%;
display: inline-block;
border-left: 1px solid #fff;
font-size:14px;
font-family: Consolas,"Liberation Mono",Courier,Verdana,"微软雅黑";
}
.exception .trace{
padding: 6px;
border: 1px solid #ddd;
border-top: 0 none;
line-height: 16px;
font-size:14px;
font-family: Consolas,"Liberation Mono",Courier,Verdana,"微软雅黑";
}
.exception .trace ol{
margin: 12px;
}
.exception .trace ol li{
padding: 2px 4px;
}
.exception div:last-child{
border-bottom-left-radius: 4px;
border-bottom-right-radius: 4px;
}
/* Exception Variables */
.exception-var table{
width: 100%;
margin: 12px 0;
box-sizing: border-box;
table-layout:fixed;
word-wrap:break-word;
}
.exception-var table caption{
text-align: left;
font-size: 16px;
font-weight: bold;
padding: 6px 0;
}
.exception-var table caption small{
font-weight: 300;
display: inline-block;
margin-left: 10px;
color: #ccc;
}
.exception-var table tbody{
font-size: 13px;
font-family: Consolas,"Liberation Mono",Courier,"微软雅黑";
}
.exception-var table td{
padding: 0 6px;
vertical-align: top;
word-break: break-all;
}
.exception-var table td:first-child{
width: 28%;
font-weight: bold;
white-space: nowrap;
}
.exception-var table td pre{
margin: 0;
}
/* Copyright Info */
.copyright{
margin-top: 24px;
padding: 12px 0;
border-top: 1px solid #eee;
}
/* SPAN elements with the classes below are added by prettyprint. */
pre.prettyprint .pln { color: #000 } /* plain text */
pre.prettyprint .str { color: #080 } /* string content */
pre.prettyprint .kwd { color: #008 } /* a keyword */
pre.prettyprint .com { color: #800 } /* a comment */
pre.prettyprint .typ { color: #606 } /* a type name */
pre.prettyprint .lit { color: #066 } /* a literal value */
/* punctuation, lisp open bracket, lisp close bracket */
pre.prettyprint .pun, pre.prettyprint .opn, pre.prettyprint .clo { color: #660 }
pre.prettyprint .tag { color: #008 } /* a markup tag name */
pre.prettyprint .atn { color: #606 } /* a markup attribute name */
pre.prettyprint .atv { color: #080 } /* a markup attribute value */
pre.prettyprint .dec, pre.prettyprint .var { color: #606 } /* a declaration; a variable name */
pre.prettyprint .fun { color: red } /* a function name */
</style>
</head>
<body>
<div class="echo">
<?php echo $echo;?>
</div>
<?php if(\think\App::$debug) { ?>
<div class="exception">
<div class="message">
<div class="info">
<div>
<h2>[<?php echo $code; ?>]&nbsp;<?php echo sprintf('%s in %s', parse_class($name), parse_file($file, $line)); ?></h2>
</div>
<div><h1><?php echo nl2br(htmlentities($message)); ?></h1></div>
</div>
</div>
<?php if(!empty($source)){?>
<div class="source-code">
<pre class="prettyprint lang-php"><ol start="<?php echo $source['first']; ?>"><?php foreach ((array) $source['source'] as $key => $value) { ?><li class="line-<?php echo $key + $source['first']; ?>"><code><?php echo htmlentities($value); ?></code></li><?php } ?></ol></pre>
</div>
<?php }?>
<div class="trace">
<h2>Call Stack</h2>
<ol>
<li><?php echo sprintf('in %s', parse_file($file, $line)); ?></li>
<?php foreach ((array) $trace as $value) { ?>
<li>
<?php
// Show Function
if($value['function']){
echo sprintf(
'at %s%s%s(%s)',
isset($value['class']) ? parse_class($value['class']) : '',
isset($value['type']) ? $value['type'] : '',
$value['function'],
isset($value['args'])?parse_args($value['args']):''
);
}
// Show line
if (isset($value['file']) && isset($value['line'])) {
echo sprintf(' in %s', parse_file($value['file'], $value['line']));
}
?>
</li>
<?php } ?>
</ol>
</div>
</div>
<?php } else { ?>
<div class="exception">
<div class="info"><h1><?php echo htmlentities($message); ?></h1></div>
</div>
<?php } ?>
<?php if(!empty($datas)){ ?>
<div class="exception-var">
<h2>Exception Datas</h2>
<?php foreach ((array) $datas as $label => $value) { ?>
<table>
<?php if(empty($value)){ ?>
<caption><?php echo $label; ?><small>empty</small></caption>
<?php } else { ?>
<caption><?php echo $label; ?></caption>
<tbody>
<?php foreach ((array) $value as $key => $val) { ?>
<tr>
<td><?php echo htmlentities($key); ?></td>
<td>
<?php
if(is_array($val) || is_object($val)){
echo htmlentities(json_encode($val, JSON_PRETTY_PRINT));
} else if(is_bool($val)) {
echo $val ? 'true' : 'false';
} else if(is_scalar($val)) {
echo htmlentities($val);
} else {
echo 'Resource';
}
?>
</td>
</tr>
<?php } ?>
</tbody>
<?php } ?>
</table>
<?php } ?>
</div>
<?php } ?>
<?php if(!empty($tables)){ ?>
<div class="exception-var">
<h2>Environment Variables</h2>
<?php foreach ((array) $tables as $label => $value) { ?>
<div>
<?php if(empty($value)){ ?>
<div class="clearfix">
<div class="col-md-3"><strong><?php echo $label; ?></strong></div>
<div class="col-md-9"><small>empty</small></div>
</div>
<?php } else { ?>
<h3 class="subheading"><?php echo $label; ?></h3>
<div>
<?php foreach ((array) $value as $key => $val) { ?>
<div class="clearfix">
<div class="col-md-3"><strong><?php echo htmlentities($key); ?></strong></div>
<div class="col-md-9"><small>
<?php
if(is_array($val) || is_object($val)){
echo htmlentities(json_encode($val, JSON_PRETTY_PRINT));
} else if(is_bool($val)) {
echo $val ? 'true' : 'false';
} else if(is_scalar($val)) {
echo htmlentities($val);
} else {
echo 'Resource';
}
?>
</small></div>
</div>
<?php } ?>
</div>
<?php } ?>
</div>
<?php } ?>
</div>
<?php } ?>
<div class="copyright">
<a title="官方网站" href="http://www.thinkphp.cn">ThinkPHP</a>
<span>V<?php echo THINK_VERSION; ?></span>
<span>{ -API开发设计的高性能框架 }</span>
</div>
<?php if(\think\App::$debug) { ?>
<script>
var LINE = <?php echo $line; ?>;
function $(selector, node){
var elements;
node = node || document;
if(document.querySelectorAll){
elements = node.querySelectorAll(selector);
} else {
switch(selector.substr(0, 1)){
case '#':
elements = [node.getElementById(selector.substr(1))];
break;
case '.':
if(document.getElementsByClassName){
elements = node.getElementsByClassName(selector.substr(1));
} else {
elements = get_elements_by_class(selector.substr(1), node);
}
break;
default:
elements = node.getElementsByTagName();
}
}
return elements;
function get_elements_by_class(search_class, node, tag) {
var elements = [], eles,
pattern = new RegExp('(^|\\s)' + search_class + '(\\s|$)');
node = node || document;
tag = tag || '*';
eles = node.getElementsByTagName(tag);
for(var i = 0; i < eles.length; i++) {
if(pattern.test(eles[i].className)) {
elements.push(eles[i])
}
}
return elements;
}
}
$.getScript = function(src, func){
var script = document.createElement('script');
script.async = 'async';
script.src = src;
script.onload = func || function(){};
$('head')[0].appendChild(script);
}
;(function(){
var files = $('.toggle');
var ol = $('ol', $('.prettyprint')[0]);
var li = $('li', ol[0]);
//
for(var i = 0; i < files.length; i++){
files[i].ondblclick = function(){
var title = this.title;
this.title = this.innerHTML;
this.innerHTML = title;
}
}
//
var err_line = $('.line-' + LINE, ol[0])[0];
err_line.className = err_line.className + ' line-error';
$.getScript('//cdn.bootcss.com/prettify/r298/prettify.min.js', function(){
prettyPrint();
// Firefox浏览器一个很诡异的问题
// ol的行号莫名其妙的错位
// li里面的html重新渲染就没有问题了
if(window.navigator.userAgent.indexOf('Firefox') >= 0){
ol[0].innerHTML = ol[0].innerHTML;
}
});
})();
</script>
<?php } ?>
</body>
</html>