diff --git a/Application/Admin/Common/function.php b/Application/Admin/Common/function.php deleted file mode 100644 index bb7f217..0000000 --- a/Application/Admin/Common/function.php +++ /dev/null @@ -1,102 +0,0 @@ - $data) { - $refer[$data[$pk]] = &$list[$key]; - } - foreach ($list as $key => $data) { - $parentId = $data[$pid]; - if ($root == $parentId) { - $tree[] = &$list[$key]; - }else{ - if (isset($refer[$parentId])) { - $parent = &$refer[$parentId]; - $parent[$child][] = &$list[$key]; - } - } - } - } - return $tree; -} - -function formatTree($list, $lv = 0, $title = 'name'){ - $formatTree = array(); - foreach($list as $key => $val){ - $title_prefix = ''; - for( $i=0;$i<$lv;$i++ ){ - $title_prefix .= "|---"; - } - $val['lv'] = $lv; - $val['namePrefix'] = $lv == 0 ? '' : $title_prefix; - $val['showName'] = $lv == 0 ? $val[$title] : $title_prefix.$val[$title]; - if(!array_key_exists('_child', $val)){ - array_push($formatTree, $val); - }else{ - $child = $val['_child']; - unset($val['_child']); - array_push($formatTree, $val); - $middle = formatTree($child, $lv+1, $title); //进行下一层递归 - $formatTree = array_merge($formatTree, $middle); - } - } - return $formatTree; -} - -if (!function_exists('array_column')) { - function array_column($array, $val, $key = null){ - $newArr = array(); - if( is_null($key) ){ - foreach ($array as $index => $item) { - $newArr[] = $item[$val]; - } - }else{ - foreach ($array as $index => $item) { - $newArr[$item[$key]] = $item[$val]; - } - } - return $newArr; - } -} diff --git a/Application/Admin/Common/index.html b/Application/Admin/Common/index.html deleted file mode 100644 index 0519ecb..0000000 --- a/Application/Admin/Common/index.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/Application/Admin/Conf/config.php b/Application/Admin/Conf/config.php deleted file mode 100644 index 1951f7f..0000000 --- a/Application/Admin/Conf/config.php +++ /dev/null @@ -1,8 +0,0 @@ - APP_PATH.'Admin/Tpl/jump.tpl', // 默认错误跳转对应的模板文件 - 'TMPL_ACTION_SUCCESS' => APP_PATH.'Admin/Tpl/jump.tpl', // 默认成功跳转对应的模板文件 - 'TMPL_EXCEPTION_FILE' => APP_PATH.'Admin/Tpl/exception.tpl',// 异常页面的模板文件 -); \ No newline at end of file diff --git a/Application/Admin/Conf/index.html b/Application/Admin/Conf/index.html deleted file mode 100644 index 0519ecb..0000000 --- a/Application/Admin/Conf/index.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/Application/Admin/Controller/ApiKeyController.class.php b/Application/Admin/Controller/ApiKeyController.class.php deleted file mode 100644 index 9ea4312..0000000 --- a/Application/Admin/Controller/ApiKeyController.class.php +++ /dev/null @@ -1,103 +0,0 @@ - - */ - -namespace Admin\Controller; - - -class ApiKeyController extends BaseController { - - public function index() { - $this->display(); - } - - public function ajaxGetIndex() { - $postData = I('post.'); - $start = $postData['start'] ? $postData['start'] : 0; - $limit = $postData['length'] ? $postData['length'] : 20; - $draw = $postData['draw']; - $total = D('ApiStoreAuth')->count(); - $info = D('ApiStoreAuth')->limit($start, $limit)->select(); - $data = array( - 'draw' => $draw, - 'recordsTotal' => $total, - 'recordsFiltered' => $total, - 'data' => $info - ); - $this->ajaxReturn($data, 'json'); - } - - public function edit(){ - if( IS_GET ){ - $id = I('get.id'); - if( $id ){ - $detail = D('ApiStoreAuth')->where(array('id' => $id))->find(); - $this->assign('detail', $detail); - $this->display('add'); - }else{ - $this->redirect('add'); - } - }elseif( IS_POST ){ - $data = I('post.'); - $res = D('ApiStoreAuth')->where(array('id' => $data['id']))->save($data); - if( $res === false ){ - $this->ajaxError('操作失败'); - }else{ - $this->ajaxSuccess('操作成功'); - } - } - } - - public function add(){ - if( IS_POST ){ - $data = I('post.'); - $res = D('ApiStoreAuth')->add($data); - if( $res === false ){ - $this->ajaxError('操作失败'); - }else{ - $this->ajaxSuccess('添加成功'); - } - }else{ - $this->display(); - } - } - - public function open(){ - if( IS_POST ){ - $id = I('post.id'); - if( $id ){ - D('ApiStoreAuth')->open(array('id' => $id)); - $this->ajaxSuccess('操作成功'); - }else{ - $this->ajaxError('缺少参数'); - } - } - } - - public function close(){ - if( IS_POST ){ - $id = I('post.id'); - if( $id ){ - D('ApiStoreAuth')->close(array('id' => $id)); - $this->ajaxSuccess('操作成功'); - }else{ - $this->ajaxError('缺少参数'); - } - } - } - - public function del(){ - if( IS_POST ){ - $id = I('post.id'); - if( $id ){ - D('ApiStoreAuth')->where(array('id' => $id))->delete(); - $this->ajaxSuccess('操作成功'); - }else{ - $this->ajaxError('缺少参数'); - } - } - } - -} \ No newline at end of file diff --git a/Application/Admin/Controller/ApiManageController.class.php b/Application/Admin/Controller/ApiManageController.class.php deleted file mode 100644 index 47f0861..0000000 --- a/Application/Admin/Controller/ApiManageController.class.php +++ /dev/null @@ -1,101 +0,0 @@ - - */ - -namespace Admin\Controller; - - -class ApiManageController extends BaseController { - public function index() { - //添加排序 //add by wkj 2017-03-18 - $list = D('ApiList')->order('id asc')->select(); - $this->assign('list', $list); - $this->display(); - } - - public function edit() { - if( IS_GET ) { - $id = I('get.id'); - if( $id ){ - $detail = D('ApiList')->where(array('id' => $id))->find(); - $this->assign('detail', $detail); - $this->display('add'); - }else{ - $this->redirect('add'); - } - }elseif( IS_POST ) { - $data = I('post.'); - $res = D('ApiList')->where(array('id' => $data['id']))->save($data); - if( $res === false ) { - $this->ajaxError('操作失败'); - } else { - S('ApiInfo_' . $data['hash'], null); - $this->ajaxSuccess('添加成功'); - } - } - } - - public function add() { - if( IS_POST ) { - $data = I('post.'); - $res = D('ApiList')->add($data); - if( $res === false ) { - $this->ajaxError('操作失败'); - } else { - $this->ajaxSuccess('添加成功'); - } - } else { - $data['hash'] = uniqid(); - $this->assign('detail', $data); - $this->display(); - } - } - - public function open() { - if( IS_POST ) { - $id = I('post.id'); - if( $id ) { - $hash = D('ApiList')->where(array('id' => $id))->getField('hash'); - S('ApiInfo_' . $hash, null); - D('ApiList')->open(array('id' => $id)); - $this->ajaxSuccess('操作成功'); - } else { - $this->ajaxError('缺少参数'); - } - } - } - - public function close() { - if( IS_POST ) { - $id = I('post.id'); - if( $id ) { - $hash = D('ApiList')->where(array('id' => $id))->getField('hash'); - S('ApiInfo_' . $hash, null); - D('ApiList')->close(array('id' => $id)); - $this->ajaxSuccess('操作成功'); - } else { - $this->ajaxError('缺少参数'); - } - } - } - - public function del() { - if( IS_POST ) { - $id = I('post.id'); - if( $id ) { - $hash = D('ApiList')->where(array('id' => $id))->getField('hash'); - S('ApiInfo_' . $hash, null); - D('ApiList')->del(array('id' => $id)); - S('ApiRequest_' . $hash, null); - S('ApiResponse_' . $hash, null); - D('ApiFields')->where(array('hash' => $hash))->delete(); - $this->ajaxSuccess('操作成功'); - } else { - $this->ajaxError('缺少参数'); - } - } - } -} \ No newline at end of file diff --git a/Application/Admin/Controller/ApiStoreController.class.php b/Application/Admin/Controller/ApiStoreController.class.php deleted file mode 100644 index 5054e05..0000000 --- a/Application/Admin/Controller/ApiStoreController.class.php +++ /dev/null @@ -1,129 +0,0 @@ - - */ - -namespace Admin\Controller; - - -class ApiStoreController extends BaseController { - public function index() { - $keyArr = D('ApiStoreAuth')->select(); - $list = array_column($keyArr, 'name', 'id'); - $list[0] = '暂不绑定'; - $this->assign('list', $list); - $this->display(); - } - - public function ajaxGetIndex() { - $postData = I('post.'); - $start = $postData['start'] ? $postData['start'] : 0; - $limit = $postData['length'] ? $postData['length'] : 20; - $draw = $postData['draw']; - $total = D('ApiStore')->count(); - $info = D('ApiStore')->limit($start, $limit)->select(); - $data = array( - 'draw' => $draw, - 'recordsTotal' => $total, - 'recordsFiltered' => $total, - 'data' => $info - ); - $this->ajaxReturn($data, 'json'); - } - - public function edit() { - if (IS_GET) { - $id = I('get.id'); - if ($id) { - $detail = D('ApiStore')->where(array('id' => $id))->find(); - $this->assign('detail', $detail); - $keyArr = D('ApiStoreAuth')->select(); - $list = array_column($keyArr, 'name', 'id'); - $list[0] = '暂不绑定'; - $this->assign('list', $list); - $this->display('add'); - } else { - $this->redirect('add'); - } - } elseif (IS_POST) { - $data = I('post.'); - $res = D('ApiStore')->where(array('id' => $data['id']))->save($data); - if ($res === false) { - $this->ajaxError('操作失败'); - } else { - $this->ajaxSuccess('操作成功'); - } - } - } - - public function refresh() { - $apiPath = dirname(THINK_PATH) . '/Application/Home/ApiStore/'; - $dir = opendir($apiPath); - if ($dir) { - $preData = array(); - while (($file = readdir($dir)) !== false) { - $filePath = $apiPath . $file; - if (!is_dir($filePath)) { - $prefix = 'Home\\ApiStore\\'; - $moduleName = str_replace('.class.php', '', $file); - $reflection = new \ReflectionClass($prefix . $moduleName); - if ($reflection->hasProperty('apiName')) { - $data['name'] = $reflection->getStaticPropertyValue('apiName'); - } else { - $data['name'] = '未定义'; - } - $data['path'] = $prefix . $moduleName; - $preDataPath[] = $prefix . $moduleName; - $preData[] = $data; - } - } - if (!$preData) { - D('ApiStore')->execute('Truncate Table api_store'); - } else { - $old = D('ApiStore')->select(); - $oldPath = array_column($old, 'path'); - $addArr = array_diff($preDataPath, $oldPath); - $delArr = array_diff($oldPath, $preDataPath); - if ($delArr) { - D('ApiStore')->where(array('path' => array('in', $delArr)))->delete(); - } - if ($addArr) { - $addData = array(); - foreach ($preData as $item) { - if (in_array($item['path'], $addArr)) { - $addData[] = $item; - } - } - D('ApiStore')->addAll($addData); - } - } - } - $this->ajaxSuccess('操作成功'); - } - - public function open() { - if (IS_POST) { - $id = I('post.id'); - if ($id) { - D('ApiStore')->open(array('id' => $id)); - $this->ajaxSuccess('操作成功'); - } else { - $this->ajaxError('缺少参数'); - } - } - } - - public function close() { - if (IS_POST) { - $id = I('post.id'); - if ($id) { - D('ApiStore')->close(array('id' => $id)); - $this->ajaxSuccess('操作成功'); - } else { - $this->ajaxError('缺少参数'); - } - } - } -} \ No newline at end of file diff --git a/Application/Admin/Controller/AppController.class.php b/Application/Admin/Controller/AppController.class.php deleted file mode 100644 index ddd8f8b..0000000 --- a/Application/Admin/Controller/AppController.class.php +++ /dev/null @@ -1,94 +0,0 @@ - - */ - -namespace Admin\Controller; - - -use Home\ORG\Str; - -class AppController extends BaseController { - - public function index(){ - $list = D('ApiApp')->select(); - $this->assign('list', $list); - $this->display(); - } - - public function edit(){ - if( IS_GET ){ - $id = I('get.id'); - if( $id ){ - $detail = D('ApiApp')->where(array('id' => $id))->find(); - $this->assign('detail', $detail); - $this->display('add'); - }else{ - $this->redirect('add'); - } - }elseif( IS_POST ){ - $data = I('post.'); - $res = D('ApiApp')->where(array('id' => $data['id']))->save($data); - if( $res === false ){ - $this->ajaxError('操作失败'); - }else{ - $this->ajaxSuccess('添加成功'); - } - } - } - - public function add(){ - if( IS_POST ){ - $data = I('post.'); - $res = D('ApiApp')->add($data); - if( $res === false ){ - $this->ajaxError('操作失败'); - }else{ - $this->ajaxSuccess('添加成功'); - } - }else{ - $data['app_id'] = Str::randString(8, 1); - $data['app_secret'] = Str::randString(32); - $this->assign('detail', $data); - $this->display(); - } - } - - public function open(){ - if( IS_POST ){ - $id = I('post.id'); - if( $id ){ - D('ApiApp')->open(array('id' => $id)); - $this->ajaxSuccess('操作成功'); - }else{ - $this->ajaxError('缺少参数'); - } - } - } - - public function close(){ - if( IS_POST ){ - $id = I('post.id'); - if( $id ){ - D('ApiApp')->close(array('id' => $id)); - $this->ajaxSuccess('操作成功'); - }else{ - $this->ajaxError('缺少参数'); - } - } - } - - public function del(){ - if( IS_POST ){ - $id = I('post.id'); - if( $id ){ - D('ApiApp')->del(array('id' => $id)); - $this->ajaxSuccess('操作成功'); - }else{ - $this->ajaxError('缺少参数'); - } - } - } -} \ No newline at end of file diff --git a/Application/Admin/Controller/BaseController.class.php b/Application/Admin/Controller/BaseController.class.php deleted file mode 100644 index 577b77d..0000000 --- a/Application/Admin/Controller/BaseController.class.php +++ /dev/null @@ -1,176 +0,0 @@ - - */ - -namespace Admin\Controller; - - -use Think\Controller; -use Admin\ORG\Auth; - -class BaseController extends Controller { - - protected $userInfo; - protected $allMenu; - protected $uid; - - private $url; - private $menuInfo; - - public function _initialize(){ - - //初始化系统 - $this->uid = session('uid'); - $this->assign('uid', $this->uid); - $this->iniSystem(); - - //控制器初始化 - if(method_exists($this, 'myInit')){ - $this->myInit(); - } - } - - /** - * 自定义初始化函数 - */ - public function myInit(){} - - /** - * Ajax正确返回,自动添加debug数据 - * @param $msg - * @param array $data - * @param int $code - */ - public function ajaxSuccess( $msg, $code = 1, $data = array() ){ - $returnData = array( - 'code' => $code, - 'msg' => $msg, - 'data' => $data - ); - if( !empty($this->debug) ){ - $returnData['debug'] = $this->debug; - } - $this->ajaxReturn($returnData, 'json'); - } - - /** - * Ajax错误返回,自动添加debug数据 - * @param $msg - * @param array $data - * @param int $code - */ - public function ajaxError( $msg, $code = 0, $data = array() ){ - $returnData = array( - 'code' => $code, - 'msg' => $msg, - 'data' => $data - ); - if( !empty($this->debug) ){ - $returnData['debug'] = $this->debug; - } - $this->ajaxReturn($returnData, 'json'); - } - - /** - * 将二维数组变成指定key - * @param $array - * @param $keyName - * @author zhaoxiang - * @return array - */ - protected function buildArrByNewKey($array, $keyName = 'id') { - $list = array(); - foreach ($array as $item) { - $list[$item[$keyName]] = $item; - } - return $list; - } - - private function iniSystem() { - $this->url = CONTROLLER_NAME . '/' . ACTION_NAME; - $this->isForbid(); - if (CONTROLLER_NAME != 'Login') { - $this->allMenu = D('ApiMenu')->order('sort asc')->select(); - $this->menuInfo = D('ApiMenu')->where(array('url' => $this->url))->find(); - if (empty($this->menuInfo)) { - if (IS_AJAX) { - $this->ajaxError('当前URL非法'); - } else { - $this->error('当前URL非法'); - } - } - $this->checkLogin(); - $this->checkRule(); - $this->iniLog(); - } - } - - /** - * 封号,或者封IP等特殊需求才用到的 - * @return bool - */ - private function isForbid() { - return true; - } - - /** - * 检测登录 - */ - private function checkLogin() { - if (isset($this->uid) && !empty($this->uid)) { - $sidNow = session_id(); - $sidOld = S($this->uid); - if (isset($sidOld) && !empty($sidOld)) { - if ($sidOld !== $sidNow) { - $this->error("您的账号在别的地方登录了,请重新登录!", U('Login/index')); - } else { - S($this->uid, $sidNow, C('ONLINE_TIME')); - $this->userInfo = $userInfo = D('ApiUser')->where(array('id' => $this->uid))->find(); - $this->assign('userInfo', $this->userInfo); - } - } else { - $this->error("登录超时,请重新登录!", U('Login/index')); - } - } else { - $this->redirect('Login/index'); - } - - } - - /** - * 检测权限 - */ - private function checkRule() { - $isAdmin = isAdministrator(); - if ($isAdmin) { - return true; - } else { - if ($this->menuInfo['level'] !== 0) { - $authObj = new Auth(); - $check = $authObj->check(strtolower($this->url), $this->uid); - if (!$check) { - $this->ajaxError(L('_VALID_ACCESS_')); - } - } - } - } - - /** - * 根据菜单级别进行区别Log记录,当然,如果有更加细节的控制,也可以在这个函数内实现 - */ - private function iniLog() { - $data = array( - 'actionName' => $this->menuInfo['name'], - 'uid' => $this->uid, - 'nickname' => $this->userInfo['nickname'], - 'addTime' => time(), - 'url' => $this->menuInfo['url'], - 'data' => json_encode($_REQUEST) - ); - D('ApiUserAction')->add($data); - } - -} \ No newline at end of file diff --git a/Application/Admin/Controller/DocumentController.class.php b/Application/Admin/Controller/DocumentController.class.php deleted file mode 100644 index 304074f..0000000 --- a/Application/Admin/Controller/DocumentController.class.php +++ /dev/null @@ -1,111 +0,0 @@ - - */ - -namespace Admin\Controller; - - -class DocumentController extends BaseController { - public function index() { - $this->display(); - } - - public function ajaxGetIndex() { - $postData = I('post.'); - $start = $postData['start'] ? $postData['start'] : 0; - $limit = $postData['length'] ? $postData['length'] : 20; - $draw = $postData['draw']; - $total = D('ApiDocument')->count(); - $info = D('ApiDocument')->limit($start, $limit)->select(); - $data = array( - 'draw' => $draw, - 'recordsTotal' => $total, - 'recordsFiltered' => $total, - 'data' => $info - ); - $this->ajaxReturn($data, 'json'); - } - - public function add() { - if (IS_POST) { - $data['createTime'] = NOW_TIME; - $data['endTime'] = I('post.keep') * 3600 + NOW_TIME; - $data['key'] = I('post.key'); - $data['info'] = I('post.info'); - D('ApiDocument')->add($data); - $this->ajaxSuccess('添加成功'); - } else { - $key = md5(microtime()); - $this->assign('key', $key); - $this->display(); - } - } - - /** - * 启用 - * @author zhaoxiang - */ - public function open() { - $key = I('post.key'); - $res = D('ApiDocument')->where(array('key' => $key))->save(array('status' => 1)); - if ($res === false) { - $this->ajaxError('操作失败'); - } else { - S($key, null); - $this->ajaxSuccess('操作成功'); - } - } - - /** - * 禁用 - * @author zhaoxiang - */ - public function close() { - $key = I('post.key'); - $res = D('ApiDocument')->where(array('key' => $key))->save(array('status' => 0)); - if ($res === false) { - $this->ajaxError('操作失败'); - } else { - S($key, null); - $this->ajaxSuccess('操作成功'); - } - } - - /** - * 删除 - * @author zhaoxiang - */ - public function del() { - $key = I('post.key'); - $res = D('ApiDocument')->where(array('key' => $key))->delete(); - if ($res === false) { - $this->ajaxError('操作失败'); - } else { - S($key, null); - $this->ajaxSuccess('操作成功'); - } - } - - /** - * Key延时 - * @author zhaoxiang - */ - public function addTime() { - if (IS_POST) { - $addTime = I('post.keep') * 3600; - $key = I('post.key'); - S($key, null); - D('ApiDocument')->where(array('key' => $key))->save(array('endTime' => array('exp', 'endTime+' . $addTime))); - $this->ajaxSuccess('修改成功'); - } else { - $key = I('get.key'); - $detail = D('ApiDocument')->where(array('key' => $key))->find(); - $this->assign('key', $key); - $this->assign('info', $detail['info']); - $this->display(); - } - } -} \ No newline at end of file diff --git a/Application/Admin/Controller/FieldsManageController.class.php b/Application/Admin/Controller/FieldsManageController.class.php deleted file mode 100644 index 67c5458..0000000 --- a/Application/Admin/Controller/FieldsManageController.class.php +++ /dev/null @@ -1,223 +0,0 @@ - - */ - -namespace Admin\Controller; - - -use Home\ORG\DataType; - -class FieldsManageController extends BaseController { - - private $dataType = array( - DataType::TYPE_INTEGER => 'Integer', - DataType::TYPE_STRING => 'String', - DataType::TYPE_BOOLEAN => 'Boolean', - DataType::TYPE_ENUM => 'Enum', - DataType::TYPE_FLOAT => 'Float', - DataType::TYPE_FILE => 'File', - DataType::TYPE_MOBILE => 'Mobile', - DataType::TYPE_OBJECT => 'Object', - DataType::TYPE_ARRAY => 'Array' - ); - - public function index() { - } - - public function request() { - $hash = I('get.hash'); - $where['type'] = 0; - if (!empty($hash)) { - $where['hash'] = $hash; - } - $res = D('ApiFields')->where($where)->select(); - $this->assign('dataType', $this->dataType); - $this->assign('list', $res); - $this->assign('type', 0); - $this->display('index'); - } - - public function response() { - $hash = I('get.hash'); - $where['type'] = 1; - if (!empty($hash)) { - $where['hash'] = $hash; - } - $res = D('ApiFields')->where($where)->select(); - $this->assign('dataType', $this->dataType); - $this->assign('list', $res); - $this->assign('type', 1); - $this->display('index'); - } - - public function add() { - if (IS_POST) { - $data = I('post.'); - $data['fieldName'] = $data['showName']; - $res = D('ApiFields')->add($data); - if ($res === false) { - $this->ajaxError('操作失败'); - } else { - S('ApiRequest_' . $data['hash'], null); - S('ApiResponse_' . $data['hash'], null); - $this->ajaxSuccess('添加成功'); - } - } else { - $this->assign('dataType', $this->dataType); - $this->display(); - } - } - - public function edit() { - if (IS_POST) { - $data = I('post.'); - $data['fieldName'] = $data['showName']; - $res = D('ApiFields')->where(array('id' => $data['id']))->save($data); - if ($res === false) { - $this->ajaxError('操作失败'); - } else { - if ($data['type'] == 0) { - S('ApiRequest_' . $data['hash'], null); - } else { - S('ApiResponse_' . $data['hash'], null); - } - $this->ajaxSuccess('添加成功'); - } - } else { - $id = I('get.id'); - if ($id) { - $detail = D('ApiFields')->where(array('id' => $id))->find(); - $this->assign('detail', $detail); - $this->assign('dataType', $this->dataType); - $this->display('add'); - } - } - } - - public function del() { - if (IS_POST) { - $id = I('post.id'); - if ($id) { - $detail = D('ApiFields')->where(array('id' => $id))->find(); - if ($detail['type'] == 0) { - S('ApiRequest_' . $detail['hash'], null); - } else { - S('ApiResponse_' . $detail['hash'], null); - } - D('ApiFields')->where(array('id' => $id))->delete(); - $this->ajaxSuccess('操作成功'); - } else { - $this->ajaxError('缺少参数'); - } - } - } - - public function upload() { - if (IS_POST) { - $hash = I('post.hash'); - $type = I('post.type'); - $jsonStr = I('post.jsonStr'); - $jsonStr = html_entity_decode($jsonStr); - $data = json_decode($jsonStr, true); - D('ApiList')->where(array('hash' => $hash))->save(array('returnStr' => json_encode($data))); - $this->handle($data['data'], $dataArr); - $old = D('ApiFields')->where(array( - 'hash' => $hash, - 'type' => $type - ))->select(); - $oldArr = array_column($old, 'showName'); - $newArr = array_column($dataArr, 'showName'); - $addArr = array_diff($newArr, $oldArr); - $delArr = array_diff($oldArr, $newArr); - if ($delArr) { - D('ApiFields')->where(array('showName' => array('in', $delArr)))->delete(); - } - if ($addArr) { - $addData = array(); - foreach ($dataArr as $item) { - if (in_array($item['showName'], $addArr)) { - $addData[] = $item; - } - } - D('ApiFields')->addAll($addData); - } - if ($type == 0) { - S('ApiRequest_' . $hash, null); - } else { - S('ApiResponse_' . $hash, null); - } - S('ApiReturnType_' . $hash, null); - $this->ajaxSuccess('操作成功'); - } else { - $this->display(); - } - } - - private function handle($data, &$dataArr, $prefix = 'data', $index = 'data') { - if (!$this->isAssoc($data)) { - $addArr = array( - 'fieldName' => $index, - 'showName' => $prefix, - 'hash' => I('post.hash'), - 'isMust' => 1, - 'dataType' => DataType::TYPE_ARRAY, - 'type' => I('post.type') - ); - $dataArr[] = $addArr; - $prefix .= '[]'; - if (is_array($data[0])) { - $this->handle($data[0], $dataArr, $prefix); - } - } else { - $addArr = array( - 'fieldName' => $index, - 'showName' => $prefix, - 'hash' => I('post.hash'), - 'isMust' => 1, - 'dataType' => DataType::TYPE_OBJECT, - 'type' => I('post.type') - ); - $dataArr[] = $addArr; - $prefix .= '{}'; - foreach ($data as $index => $datum) { - $myPre = $prefix . $index; - $addArr = array( - 'fieldName' => $index, - 'showName' => $myPre, - 'hash' => I('post.hash'), - 'isMust' => 1, - 'dataType' => DataType::TYPE_STRING, - 'type' => I('post.type') - ); - if (is_numeric($datum)) { - if (preg_match('/^\d*$/', $datum)) { - $addArr['dataType'] = DataType::TYPE_INTEGER; - } else { - $addArr['dataType'] = DataType::TYPE_FLOAT; - } - $dataArr[] = $addArr; - } elseif (is_array($datum)) { - $this->handle($datum, $dataArr, $myPre, $index); - } else { - $addArr['dataType'] = DataType::TYPE_STRING; - $dataArr[] = $addArr; - } - } - } - } - - /** - * 判断是否是关联数组(true表示是关联数组) - * @param array $arr - * @author zhaoxiang - * @return bool - */ - private function isAssoc(array $arr) { - if (array() === $arr) return false; - - return array_keys($arr) !== range(0, count($arr) - 1); - } -} \ No newline at end of file diff --git a/Application/Admin/Controller/IndexController.class.php b/Application/Admin/Controller/IndexController.class.php deleted file mode 100644 index bc2b3a4..0000000 --- a/Application/Admin/Controller/IndexController.class.php +++ /dev/null @@ -1,38 +0,0 @@ -allMenu; - foreach ($menuAll as $menu) { - if ($menu['hide'] == 0) { - if ($isAdmin) { - $menu['url'] = U($menu['url']); - $list[] = $menu; - } else { - $authObj = new Auth(); - $authList = $authObj->getAuthList($this->uid); - if (in_array(strtolower($menu['url']), $authList) || $menu['url'] == '') { - $menu['url'] = U($menu['url']); - $list[] = $menu; - } - } - } - } - $list = listToTree($list); - foreach ($list as $key => $item) { - if(empty($item['_child']) && $item['url'] != U('Index/welcome')){ - unset($list[$key]); - } - } - $list = formatTree($list); - $this->assign('list', $list); - $this->display(); - } -} \ No newline at end of file diff --git a/Application/Admin/Controller/LogController.class.php b/Application/Admin/Controller/LogController.class.php deleted file mode 100644 index d858628..0000000 --- a/Application/Admin/Controller/LogController.class.php +++ /dev/null @@ -1,66 +0,0 @@ - - */ - -namespace Admin\Controller; - - -class LogController extends BaseController { - public function index() { - $this->display(); - } - - public function ajaxGetIndex() { - $postData = I('post.'); - $start = $postData['start'] ? $postData['start'] : 0; - $limit = $postData['length'] ? $postData['length'] : 20; - $draw = $postData['draw']; - $where = array(); - $getInfo = I('get.'); - if (isset($getInfo['type']) && !empty($getInfo['type'])) { - if (isset($getInfo['keyword']) && !empty($getInfo['keyword'])) { - switch ($getInfo['type']) { - case 1: - $where['url'] = array('like', '%' . $getInfo['keyword'] . '%'); - break; - case 2: - $where['nickname'] = array('like', '%' . $getInfo['keyword'] . '%'); - break; - case 3: - $where['uid'] = $getInfo['keyword']; - break; - } - } - } - $total = D('ApiUserAction')->where($where)->count(); - $info = D('ApiUserAction')->where($where)->limit($start, $limit)->select(); - $data = array( - 'draw' => $draw, - 'recordsTotal' => $total, - 'recordsFiltered' => $total, - 'data' => $info - ); - $this->ajaxReturn($data, 'json'); - } - - public function del() { - $id = I('post.id'); - $res = D('ApiUserAction')->where(array('id' => $id))->delete(); - if ($res === false) { - $this->ajaxError('操作失败'); - } else { - $this->ajaxSuccess('操作成功'); - } - } - - public function showDetail() { - if (IS_GET) { - $id = I('get.id'); - $listInfo = D('ApiUserAction')->where(array('id' => $id))->find(); - $this->assign('detail', $listInfo); - $this->display(); - } - } -} \ No newline at end of file diff --git a/Application/Admin/Controller/LoginController.class.php b/Application/Admin/Controller/LoginController.class.php deleted file mode 100644 index 6099839..0000000 --- a/Application/Admin/Controller/LoginController.class.php +++ /dev/null @@ -1,88 +0,0 @@ - - */ -class LoginController extends BaseController { - - public function index() { - $this->display(); - } - - public function login() { - $pass = user_md5(I('post.password')); - $user = I('post.username'); - - $challenge = I('post.geetest_challenge'); - $validate = I('post.geetest_validate'); - if(!$challenge || md5($challenge) != $validate){ - $this->ajaxError('请先通过验证!'); - } - - $userInfo = D('ApiUser')->where(array('username' => $user, 'password' => $pass))->find(); - if (!empty($userInfo)) { - if ($userInfo['status']) { - - //保存用户信息和登录凭证 - S($userInfo['id'], session_id(), C('ONLINE_TIME')); - session('uid', $userInfo['id']); - - //更新用户数据 - $userData = D('ApiUserData')->where(array('uid' => $userInfo['id']))->find(); - $data = array(); - if ($userData) { - $data['loginTimes'] = $userData['loginTimes'] + 1; - $data['lastLoginIp'] = get_client_ip(1); - $data['lastLoginTime'] = NOW_TIME; - D('ApiUserData')->where(array('uid' => $userInfo['id']))->save($data); - } else { - $data['loginTimes'] = 1; - $data['uid'] = $userInfo['id']; - $data['lastLoginIp'] = get_client_ip(1); - $data['lastLoginTime'] = NOW_TIME; - D('ApiUserData')->add($data); - } - $this->ajaxSuccess('登录成功'); - } else { - $this->ajaxError('用户已被封禁,请联系管理员'); - } - } else { - $this->ajaxError('用户名密码不正确'); - } - } - - public function logOut() { - S(session('uid'), null); - session('[destroy]'); - $this->success('退出成功', U('Login/index')); - } - - public function changeUser() { - if (IS_POST) { - $data = I('post.'); - $newData = array(); - if (!empty($data['nickname'])) { - $newData['nickname'] = $data['nickname']; - } - if (!empty($data['password'])) { - $newData['password'] = user_md5($data['password']); - $newData['updateTime'] = time(); - } - $res = D('ApiUser')->where(array('id' => session('uid')))->save($newData); - if ($res === false) { - $this->ajaxError('修改失败'); - } else { - $this->ajaxSuccess('修改成功'); - } - } else { - $userInfo = D('ApiUser')->where(array('id' => session('uid')))->find(); - $this->assign('uname', $userInfo['username']); - $this->display('add'); - } - } - -} \ No newline at end of file diff --git a/Application/Admin/Controller/MenuController.class.php b/Application/Admin/Controller/MenuController.class.php deleted file mode 100644 index 56c8860..0000000 --- a/Application/Admin/Controller/MenuController.class.php +++ /dev/null @@ -1,116 +0,0 @@ - - */ -class MenuController extends BaseController { - - /** - * 获取菜单列表 - * @author zhaoxiang - */ - public function index() { - $list = D('ApiMenu')->order('sort asc')->select(); - $list = formatTree(listToTree($list)); - $this->assign('list', $list); - $this->display(); - } - - /** - * 新增菜单 - * @author zhaoxiang - */ - public function add() { - if (IS_POST) { - $data = I('post.'); - $data['hide'] = isset($data['hide']) ? 1 : 0; - $res = D('ApiMenu')->add($data); - if ($res === false) { - $this->ajaxError('操作失败'); - } else { - $this->ajaxSuccess('添加成功'); - } - } else { - $originList = D('ApiMenu')->order('sort asc')->select(); - $fid = ''; - $id = I('get.id'); - if (!empty($id)) { - $fid = $id; - } - $options = array_column(formatTree(listToTree($originList)), 'showName', 'id'); - $this->assign('options', $options); - $this->assign('fid', $fid); - $this->display(); - } - } - - /** - * 显示菜单 - * @author zhaoxiang - */ - public function open() { - $id = I('post.id'); - $res = D('ApiMenu')->where(array('id' => $id))->save(array('hide' => 0)); - if ($res === false) { - $this->ajaxError('操作失败'); - } else { - $this->ajaxSuccess('添加成功'); - } - } - - /** - * 隐藏菜单 - * @author zhaoxiang - */ - public function close() { - $id = I('post.id'); - $res = D('ApiMenu')->where(array('id' => $id))->save(array('hide' => 1)); - if ($res === false) { - $this->ajaxError('操作失败'); - } else { - $this->ajaxSuccess('添加成功'); - } - } - - /** - * 编辑菜单 - * @author zhaoxiang - */ - public function edit() { - if (IS_GET) { - $originList = D('ApiMenu')->order('sort asc')->select(); - $list = $this->buildArrByNewKey($originList); - $listInfo = $list[I('get.id')]; - $options = array_column(formatTree(listToTree($originList)), 'showName', 'id'); - - $this->assign('detail', $listInfo); - $this->assign('options', $options); - $this->display('add'); - } elseif (IS_POST) { - $postData = I('post.'); - $postData['hide'] = isset($postData['hide']) ? 1 : 0; - $res = D('ApiMenu')->where(array('id' => $postData['id']))->save($postData); - if ($res === false) { - $this->ajaxError('操作失败'); - } else { - $this->ajaxSuccess('编辑成功'); - } - } - } - - public function del() { - $id = I('post.id'); - $childNum = D('ApiMenu')->where(array('fid' => $id))->count(); - if ($childNum) { - $this->ajaxError("当前菜单存在子菜单,不可以被删除!"); - } else { - D('ApiMenu')->where(array('id' => $id))->delete(); - $this->ajaxSuccess('编辑成功'); - } - } - -} \ No newline at end of file diff --git a/Application/Admin/Controller/PermissionController.class.php b/Application/Admin/Controller/PermissionController.class.php deleted file mode 100644 index ff2dc1e..0000000 --- a/Application/Admin/Controller/PermissionController.class.php +++ /dev/null @@ -1,208 +0,0 @@ - - */ -class PermissionController extends BaseController { - - public function index() { - $listInfo = D('ApiAuthGroup')->select(); - $this->assign('list', $listInfo); - $this->display(); - } - - public function add() { - if (IS_POST) { - $res = D('ApiAuthGroup')->add(I('post.')); - if ($res === false) { - $this->ajaxError(L('_OPERATION_FAIL_')); - } else { - $this->ajaxSuccess(L('_OPERATION_SUCCESS_')); - } - } else { - $this->display(); - } - } - - public function close() { - $id = I('post.id'); - if ($id == C('ADMIN_GROUP')) { - $this->ajaxError(L('_VALID_ACCESS_')); - } - $res = D('ApiAuthGroup')->where(array('id' => $id))->save(array('status' => 0)); - if ($res === false) { - $this->ajaxError(L('_OPERATION_FAIL_')); - } else { - $this->ajaxSuccess(L('_OPERATION_SUCCESS_')); - } - } - - public function open() { - $id = I('post.id'); - $res = D('ApiAuthGroup')->where(array('id' => $id))->save(array('status' => 1)); - if ($res === false) { - $this->ajaxError(L('_OPERATION_FAIL_')); - } else { - $this->ajaxSuccess(L('_OPERATION_SUCCESS_')); - } - } - - public function edit() { - if (IS_GET) { - $detail = D('ApiAuthGroup')->where(array('id' => I('get.id')))->find(); - $this->assign('detail', $detail); - $this->display('add'); - } elseif (IS_POST) { - $res = D('ApiAuthGroup')->where(array('id' => I('post.id')))->save(I('post.')); - if ($res === false) { - $this->ajaxError(L('_OPERATION_FAIL_')); - } else { - $this->ajaxSuccess(L('_OPERATION_SUCCESS_')); - } - } else { - $this->ajaxError(L('_ERROR_ACTION_')); - } - } - - public function del() { - $id = I('post.id'); - if ($id == C('ADMIN_GROUP')) { - $this->error(L('_VALID_ACCESS_')); - } - $res = D('ApiAuthGroup')->where(array('id' => $id))->delete(); - if ($res === false) { - $this->ajaxError(L('_OPERATION_FAIL_')); - } else { - $this->ajaxSuccess(L('_OPERATION_SUCCESS_')); - } - } - - /** - * 将管理员加入组的组列表显示 - */ - public function group() { - if (IS_POST) { - $data = I('post.'); - $groupAccess = array_keys($data['groupAccess']); - $groupAccess = implode(',', $groupAccess); - $oldArr = D('ApiAuthGroupAccess')->where(array('uid' => $data['uid']))->find(); - if ($oldArr) { - $insert = D('ApiAuthGroupAccess')->where(array('uid' => $data['uid']))->save(array('groupId' => $groupAccess)); - } else { - $insert = D('ApiAuthGroupAccess')->add(array('uid' => $data['uid'], 'groupId' => $groupAccess)); - } - if ($insert) { - $this->ajaxSuccess(L('_OPERATION_SUCCESS_')); - } else { - $this->ajaxError(L('_OPERATION_FAIL_')); - } - } elseif (IS_GET) { - $uid = I('get.uid'); - $groupAccess = D('ApiAuthGroupAccess')->where(array('uid' => $uid))->find(); - $groupAccess = explode(',', $groupAccess['groupId']); - $allGroup = D('ApiAuthGroup')->select(); - $this->assign('allGroup', $allGroup); - $this->assign('groupAccess', $groupAccess); - $this->display(); - } else { - $this->ajaxError('非法操作'); - } - } - - /** - * 显示当前组下面全部的用户 - */ - public function member() { - $groupId = I('get.group_id'); - if ($groupId) { - $uidArr = array(); - $allGroups = D('ApiAuthGroupAccess')->select(); - foreach ($allGroups as $allGroup) { - $gidArr = explode(',', $allGroup['groupId']); - if (in_array($groupId, $gidArr)) { - $uidArr[] = $allGroup['uid']; - } - } - if (!empty($uidArr)) { - $res = D('ApiUser')->where(array('api_user.id' => array('in', $uidArr)))->join('api_user_data on api_user.id = api_user_data.uid', 'left')->select(); - } else { - $res = array(); - } - $this->assign('list', $res); - $this->display(); - } else { - $this->ajaxError('非法操作'); - } - } - - /** - * 删除指定组下面的指定用户 - */ - public function delMember() { - if (IS_POST) { - $uid = I('post.uid'); - $groupId = I('post.groupId'); - $oldInfo = D('ApiAuthGroupAccess')->where(array('uid' => $uid))->find(); - $oldGroupArr = explode(',', $oldInfo['groupId']); - $key = array_search($groupId, $oldGroupArr); - unset($oldGroupArr[$key]); - $newData = implode(',', $oldGroupArr); - $res = D('ApiAuthGroupAccess')->where(array('uid' => $uid))->save(array('groupId' => $newData)); - if ($res === false) { - $this->ajaxError(L('_OPERATION_FAIL_')); - } else { - $this->ajaxSuccess(L('_OPERATION_SUCCESS_')); - } - } else { - $this->ajaxError('非法操作'); - } - } - - /** - * 当前用户组权限节点配置 - */ - public function rule() { - if (IS_POST) { - $postData = I('post.'); - $needAdd = array(); - $has = D('ApiAuthRule')->where(array('groupId' => $postData['groupId']))->select(); - $hasRule = array_column($has, 'url'); - $needDel = array_flip($hasRule); - foreach ($postData['rule'] as $key => $value) { - if (!empty($value)) { - if (!in_array($value, $hasRule)) { - $data['url'] = $value; - $data['groupId'] = $postData['groupId']; - $needAdd[] = $data; - } else { - unset($needDel[$value]); - } - } - } - if (count($needAdd)) { - D('ApiAuthRule')->addAll($needAdd); - } - if (count($needDel)) { - $urlArr = array_keys($needDel); - D('ApiAuthRule')->where(array('groupId' => $postData['groupId'], 'url' => array('in', $urlArr)))->delete(); - } - $this->ajaxSuccess('操作成功'); - } elseif (IS_GET) { - $groupId = I('get.group_id'); - $has = D('ApiAuthRule')->where(array('groupId' => $groupId))->select(); - $hasRule = array_column($has, 'url'); - $originList = D('ApiMenu')->order('sort asc')->select(); - $list = listToTree($originList); - $this->assign('hasRule', $hasRule); - $this->assign('list', $list); - $this->display(); - } else { - $this->ajaxError('非法操作'); - } - } - -} \ No newline at end of file diff --git a/Application/Admin/Controller/UserController.class.php b/Application/Admin/Controller/UserController.class.php deleted file mode 100644 index 68b2a43..0000000 --- a/Application/Admin/Controller/UserController.class.php +++ /dev/null @@ -1,91 +0,0 @@ - - */ - -namespace Admin\Controller; - -class UserController extends BaseController { - - public function index() { - $listInfo = D('ApiUser')->select(); - $userData = D('ApiUserData')->select(); - $userData = $this->buildArrByNewKey($userData, 'uid'); - foreach ($listInfo as $key => $value) { - if ($userData) { - $listInfo[$key]['lastLoginIp'] = long2ip($userData[$value['id']]['lastLoginIp']); - $listInfo[$key]['loginTimes'] = $userData[$value['id']]['loginTimes']; - $listInfo[$key]['lastLoginTime'] = date('Y-m-d H:i:s', $userData[$value['id']]['lastLoginTime']); - } - } - $this->assign('list', $listInfo); - $this->display(); - } - - public function add() { - if (IS_POST) { - $data = I('post.'); - $has = D('ApiUser')->where(array('username' => $data['username']))->count(); - if ($has) { - $this->ajaxError('用户名已经存在,请重设!'); - } - $data['password'] = user_md5($data['password']); - $data['regIp'] = get_client_ip(1); - $data['regTime'] = time(); - $res = D('ApiUser')->add($data); - if ($res === false) { - $this->ajaxError('操作失败'); - } else { - $this->ajaxSuccess('添加成功'); - } - } else { - $this->display(); - } - } - - public function close() { - $id = I('post.id'); - $isAdmin = isAdministrator($id); - if ($isAdmin) { - $this->ajaxError('超级管理员不可以被操作'); - } - $res = D('ApiUser')->where(array('id' => $id))->save(array('status' => 0)); - if ($res === false) { - $this->ajaxError('操作失败'); - } else { - $this->ajaxSuccess('操作成功'); - } - } - - public function open() { - $id = I('post.id'); - $isAdmin = isAdministrator($id); - if ($isAdmin) { - $this->ajaxError('超级管理员不可以被操作'); - } - $res = D('ApiUser')->where(array('id' => $id))->save(array('status' => 1)); - if ($res === false) { - $this->ajaxError('操作失败'); - } else { - $this->ajaxSuccess('操作成功'); - } - } - - public function del() { - $id = I('post.id'); - $isAdmin = isAdministrator($id); - if ($isAdmin) { - $this->ajaxError('超级管理员不可以被操作'); - } - - $res = D('ApiUser')->where(array('id' => $id))->delete(); - if ($res === false) { - $this->ajaxError('操作失败'); - } else { - $this->ajaxSuccess('操作成功'); - } - } - -} \ No newline at end of file diff --git a/Application/Admin/Controller/UserLogController.class.php b/Application/Admin/Controller/UserLogController.class.php deleted file mode 100644 index 23df898..0000000 --- a/Application/Admin/Controller/UserLogController.class.php +++ /dev/null @@ -1,139 +0,0 @@ - - */ -namespace Home\Controller; - -class UserLogController extends HomeController{ - - public function index(){ - $tableField = [ - [ - 'name' => 'actionName', - 'info' => '行为名称', - 'type' => 'text' - ], - [ - 'name' => 'nickName', - 'info' => '执行者', - 'type' => 'text' - ], - [ - 'name' => 'actionTime', - 'info' => '操作时间', - 'type' => 'text' - ], - [ - 'name' => 'actionIp', - 'info' => '操作IP', - 'type' => 'text' - ], - [ - 'name' => 'action', - 'info' => '操作', - 'type' => 'rightButton' - ] - ]; - $typeRule = [ - 'rightButton' => [ - 'action' => [ - [ - 'desc' => '查看', - 'href' => 'UserLog/show', - 'class'=> 'secondary', - 'param'=> '_id', - 'icon' => 'eye', - 'ajax' => 0, - 'show' => '' - ], - [ - 'desc' => '删除', - 'href' => 'UserLog/del', - 'class'=> 'danger', - 'param'=> '_id', - 'icon' => 'trash', - 'ajax' => 2, - 'show' => '' - ] - ] - ] - ]; - $topList = [ - 'topButton' => [ - [ - 'href' => 'UserLog/del', - 'class'=> 'am-btn-danger del-all', - 'title'=> '删除', - 'icon' => 'trash', - 'ajax' => 1, - ], - ] - ]; - $listNum = D('UserAction')->count(); - $listLimit = $this->_getPage($listNum, 20); - $listInfo = D('UserAction')->order('actionTime desc')->limit($listLimit[0],$listLimit[1])->select(); - foreach( $listInfo as $key => $value ){ - $listInfo[$key]['actionTime'] = date('Y-m-d H:i:s', $value['actionTime']); - $listInfo[$key]['actionIp'] = long2ip($value['actionIp']); - } - $this->_prepareListInfo( $listInfo, $tableField, $typeRule ); - $this->_prepareTopList( $topList ); - $this->assign('tableField', $tableField); - $this->display(); - } - - public function show(){ - if( IS_GET ){ - $map['_id'] = I('get._id'); - $res = D('UserAction')->where($map)->find(); - $formData = [ - [ - 'type' => 'text', - 'info' => '行为名称:', - 'attr' => 'disabled', - 'value'=> $res['actionName'], - ], - [ - 'type' => 'text', - 'info' => '执行者:', - 'attr' => 'disabled', - 'value'=> $res['nickName'], - ], - [ - 'type' => 'text', - 'info' => '操作时间:', - 'attr' => 'disabled', - 'value'=> date('Y-m-d H:i:s',$res['actionTime']), - ], - [ - 'type' => 'text', - 'info' => '操作IP:', - 'attr' => 'disabled', - 'value'=> long2ip($res['actionIp']), - ], - [ - 'type' => 'textarea', - 'info' => '受影响的URL:', - 'attr' => 'readonly', - 'value'=> $res['actionUrl'], - ], - [ - 'type' => 'textarea', - 'info' => 'POST数据:', - 'attr' => 'readonly rows="5"', - 'value'=> $res['data'], - ], - ]; - $this->assign('formData', $formData); - $this->display(); - }else{ - $this->error( L('_ERROR_ACTION_') ); - } - } - - public function del(){ - $this->_del('UserAction', $_REQUEST['_id'], 'UserLog/index'); - } -} \ No newline at end of file diff --git a/Application/Admin/Controller/VerificationController.class.php b/Application/Admin/Controller/VerificationController.class.php deleted file mode 100644 index 2c06a1e..0000000 --- a/Application/Admin/Controller/VerificationController.class.php +++ /dev/null @@ -1,30 +0,0 @@ - - */ - -namespace Admin\Controller; - - -use Think\Controller; - -class VerificationController extends Controller { - - private $gt_captcha_id = 'YourID'; - private $gt_private_key = 'YourKey'; - - public function gt(){ - $rnd1 = md5(rand(0, 100)); - $rnd2 = md5(rand(0, 100)); - $challenge = $rnd1 . substr($rnd2, 0, 2); - $result = array( - 'success' => 0, - 'gt' => $this->gt_captcha_id, - 'challenge' => $challenge, - 'new_captcha'=>1 - ); - $this->ajaxReturn($result); - } -} \ No newline at end of file diff --git a/Application/Admin/Controller/index.html b/Application/Admin/Controller/index.html deleted file mode 100644 index 0519ecb..0000000 --- a/Application/Admin/Controller/index.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/Application/Admin/Model/ApiAppModel.class.php b/Application/Admin/Model/ApiAppModel.class.php deleted file mode 100644 index 6ea7fe6..0000000 --- a/Application/Admin/Model/ApiAppModel.class.php +++ /dev/null @@ -1,23 +0,0 @@ - - */ - -namespace Admin\Model; - - -class ApiAppModel extends BaseModel { - public function open( $where ){ - return $this->where( $where )->save( array('app_status' => 1) ); - } - - public function close( $where ){ - return $this->where( $where )->save( array('app_status' => 0) ); - } - - public function del( $where ){ - return $this->where( $where )->delete(); - } -} \ No newline at end of file diff --git a/Application/Admin/Model/ApiAuthGroupAccessModel.class.php b/Application/Admin/Model/ApiAuthGroupAccessModel.class.php deleted file mode 100644 index e507fb7..0000000 --- a/Application/Admin/Model/ApiAuthGroupAccessModel.class.php +++ /dev/null @@ -1,11 +0,0 @@ - - * Date: 16/1/16 - */ -namespace Admin\Model; - -class ApiAuthGroupAccessModel extends BaseModel{ - -} \ No newline at end of file diff --git a/Application/Admin/Model/ApiAuthGroupModel.class.php b/Application/Admin/Model/ApiAuthGroupModel.class.php deleted file mode 100644 index 1a972f4..0000000 --- a/Application/Admin/Model/ApiAuthGroupModel.class.php +++ /dev/null @@ -1,13 +0,0 @@ - - * Date: 16/1/16 - */ -namespace Admin\Model; - -class ApiAuthGroupModel extends BaseModel{ - - - -} \ No newline at end of file diff --git a/Application/Admin/Model/ApiAuthRuleModel.class.php b/Application/Admin/Model/ApiAuthRuleModel.class.php deleted file mode 100644 index 0c9c620..0000000 --- a/Application/Admin/Model/ApiAuthRuleModel.class.php +++ /dev/null @@ -1,12 +0,0 @@ - - * Date: 16/1/16 - */ -namespace Admin\Model; - -class ApiAuthRuleModel extends BaseModel{ - - -} \ No newline at end of file diff --git a/Application/Admin/Model/ApiDocumentModel.class.php b/Application/Admin/Model/ApiDocumentModel.class.php deleted file mode 100644 index f2a1cf4..0000000 --- a/Application/Admin/Model/ApiDocumentModel.class.php +++ /dev/null @@ -1,13 +0,0 @@ - - */ - -namespace Admin\Model; - - -class ApiDocumentModel extends BaseModel { - -} \ No newline at end of file diff --git a/Application/Admin/Model/ApiFieldsModel.class.php b/Application/Admin/Model/ApiFieldsModel.class.php deleted file mode 100644 index 05d8612..0000000 --- a/Application/Admin/Model/ApiFieldsModel.class.php +++ /dev/null @@ -1,13 +0,0 @@ - - */ - -namespace Admin\Model; - - -class ApiFieldsModel extends BaseModel { - -} \ No newline at end of file diff --git a/Application/Admin/Model/ApiListModel.class.php b/Application/Admin/Model/ApiListModel.class.php deleted file mode 100644 index 586a2f7..0000000 --- a/Application/Admin/Model/ApiListModel.class.php +++ /dev/null @@ -1,23 +0,0 @@ - - */ - -namespace Admin\Model; - - -class ApiListModel extends BaseModel { - public function open( $where ){ - return $this->where( $where )->save( array('status' => 1) ); - } - - public function close( $where ){ - return $this->where( $where )->save( array('status' => 0) ); - } - - public function del( $where ){ - return $this->where( $where )->delete(); - } -} \ No newline at end of file diff --git a/Application/Admin/Model/ApiMenuModel.class.php b/Application/Admin/Model/ApiMenuModel.class.php deleted file mode 100644 index 8a22a87..0000000 --- a/Application/Admin/Model/ApiMenuModel.class.php +++ /dev/null @@ -1,11 +0,0 @@ - - * Date: 16/1/16 - */ -namespace Admin\Model; - -class ApiMenuModel extends BaseModel{ - -} \ No newline at end of file diff --git a/Application/Admin/Model/ApiStoreAuthModel.class.php b/Application/Admin/Model/ApiStoreAuthModel.class.php deleted file mode 100644 index 4450f9a..0000000 --- a/Application/Admin/Model/ApiStoreAuthModel.class.php +++ /dev/null @@ -1,20 +0,0 @@ - - */ - -namespace Admin\Model; - - -class ApiStoreAuthModel extends BaseModel { - - public function open( $where ){ - return $this->where( $where )->save( array('status' => 1) ); - } - - public function close( $where ){ - return $this->where( $where )->save( array('status' => 0) ); - } - -} \ No newline at end of file diff --git a/Application/Admin/Model/ApiStoreModel.class.php b/Application/Admin/Model/ApiStoreModel.class.php deleted file mode 100644 index 9da476d..0000000 --- a/Application/Admin/Model/ApiStoreModel.class.php +++ /dev/null @@ -1,13 +0,0 @@ - - */ - -namespace Admin\Model; - - -class ApiStoreModel extends BaseModel { - -} \ No newline at end of file diff --git a/Application/Admin/Model/ApiUserDataModel.class.php b/Application/Admin/Model/ApiUserDataModel.class.php deleted file mode 100644 index 954e6b3..0000000 --- a/Application/Admin/Model/ApiUserDataModel.class.php +++ /dev/null @@ -1,10 +0,0 @@ - - */ - -namespace Admin\Model; - - -use Think\Model; - -class BaseModel extends Model { - Protected $autoCheckFields = false; - - public function open( $where ){ - return $this->where( $where )->save( array('status' => 1) ); - } - - public function close( $where ){ - return $this->where( $where )->save( array('status' => 0) ); - } -} \ No newline at end of file diff --git a/Application/Admin/Model/index.html b/Application/Admin/Model/index.html deleted file mode 100644 index 0519ecb..0000000 --- a/Application/Admin/Model/index.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/Application/Admin/ORG/Auth.class.php b/Application/Admin/ORG/Auth.class.php deleted file mode 100644 index bf35c18..0000000 --- a/Application/Admin/ORG/Auth.class.php +++ /dev/null @@ -1,143 +0,0 @@ - - */ -class Auth { - - protected $_config = array( - 'AUTH_ON' => true, //认证开关 - 'AUTH_TYPE' => 1, //认证方式,1为时时认证;2为登录认证。 - 'AUTH_GROUP' => 'ApiAuthGroup', //用户组数据表名 - 'AUTH_GROUP_ACCESS' => 'ApiAuthGroupAccess', //用户组明细表 - 'AUTH_RULE' => 'ApiAuthRule', //权限规则表 - 'AUTH_USER' => 'ApiUser' //用户信息表 - ); - - public function __construct() { - $conf = C('AUTH_CONFIG'); - if ($conf) { - $together = array_intersect_key($conf, $this->_config); - $this->_config = array_merge($this->_config, $together); - } - } - - /** - * 权限检测 - * @param string | array $name 获得权限 可以是字符串或数组或逗号分割,只要数组中有一个条件通过则通过 - * @param string $uid 认证的用户id - * @param string $relation - * @return bool - */ - public function check($name, $uid, $relation = 'or') { - - if (!$this->_config['AUTH_ON']) { - return true; - } - - $authList = $this->getAuthList($uid); - if (is_string($name)) { - if (strpos($name, ',') !== false) { - $name = explode(',', $name); - } else { - $name = array($name); - } - } - - $list = array(); - foreach ($authList as $val) { - if (in_array($val, $name)) - $list[] = $val; - } - - if ($relation == 'or' && !empty($list)) { - return true; - } - $diff = array_diff($name, $list); - if ($relation == 'and' && empty($diff)) { - return true; - } - - return false; - } - - /** - * 获取用户组信息 - * @param $uid - * @return mixed - */ - protected function getGroups($uid) { - static $groups = array(); - if (isset($groups[$uid])) { - return $groups[$uid]; - } - $ids = array();$userGroups = array(); - $group_access = D($this->_config['AUTH_GROUP_ACCESS'])->where(array('uid' => $uid))->find(); - if($group_access){ - $groupInfoArr = D($this->_config['AUTH_GROUP'])->where(array('id' => array('in', $group_access['groupId'])))->select(); - foreach ($groupInfoArr as $value) { - if ($value['status'] == 1) { - $ids[] = $value['id']; - $userGroups[] = $value; - } - } - } - - $groups[$uid]['detail'] = $userGroups; //包含组全部信息 - $groups[$uid]['id'] = $ids; //只包含组ID信息 - - return $groups[$uid]; - } - - /** - * 获取权限列表 - * @param $uid - * @return array - */ - public function getAuthList($uid) { - - static $_authList = array(); - if (isset($_authList[$uid])) { - return $_authList[$uid]; - } - if (isset($_SESSION[$uid]['_AUTH_LIST_'])) { - return $_SESSION[$uid]['_AUTH_LIST_']; - } - - $groups = $this->getGroups($uid); - if (empty($groups['id'])) { - $_authList[$uid] = array(); - - return array(); - } - - $rules = D($this->_config['AUTH_RULE'])->where(array( - 'groupId' => array('in', $groups['id']), - 'status' => 1 - ))->select(); - $rules = array_column($rules, 'url'); - $rules = array_unique($rules); - if (empty($rules)) { - $_authList[$uid] = array(); - - return array(); - } - - $authList = array(); - foreach ($rules as $r) { - $authList[] = strtolower($r); - } - - $_authList[$uid] = $authList; - if ($this->_config['AUTH_TYPE'] == 2) { - $_SESSION[$uid]['_AUTH_LIST_'] = $authList; - } - - return $_authList[$uid]; - } - -} \ No newline at end of file diff --git a/Application/Admin/Tpl/exception.tpl b/Application/Admin/Tpl/exception.tpl deleted file mode 100644 index 9986743..0000000 --- a/Application/Admin/Tpl/exception.tpl +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - <?php echo C('APP_NAME') ?> - 系统发生错误 - - - - - -
-

-

- -

错误位置

-

FILE:  LINE:

- - -

TRACE

-

- -
-
-

{ Fast & Simple API Framework } -- [ MANAGE YOUR API EASY ]

-
-
- - \ No newline at end of file diff --git a/Application/Admin/Tpl/jump.tpl b/Application/Admin/Tpl/jump.tpl deleted file mode 100644 index 13dd311..0000000 --- a/Application/Admin/Tpl/jump.tpl +++ /dev/null @@ -1,63 +0,0 @@ - - - - - - <?php echo C('APP_NAME') ?> - 跳转提示 - - - - - - -
- -
- -
- -
- -
- -
- - - - - -
- 将在S后自动跳转 -
-
- -
-
-
-
- - - \ No newline at end of file diff --git a/Application/Admin/View/ApiKey/add.html b/Application/Admin/View/ApiKey/add.html deleted file mode 100644 index 2af8432..0000000 --- a/Application/Admin/View/ApiKey/add.html +++ /dev/null @@ -1,93 +0,0 @@ - - -
- 秘钥管理 - 新增秘钥 -
-
- - - -
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
-
- - -
-
-
-
-
-
- - - - - - - - \ No newline at end of file diff --git a/Application/Admin/View/ApiKey/index.html b/Application/Admin/View/ApiKey/index.html deleted file mode 100644 index b676dbc..0000000 --- a/Application/Admin/View/ApiKey/index.html +++ /dev/null @@ -1,160 +0,0 @@ - - - - -
- 秘钥管理 - 秘钥列表 -
- 新增 - - - - - - - - - - -
秘钥名称AppIdAppSecret秘钥状态操作
-
-
-
- - - \ No newline at end of file diff --git a/Application/Admin/View/ApiManage/add.html b/Application/Admin/View/ApiManage/add.html deleted file mode 100644 index cea7c39..0000000 --- a/Application/Admin/View/ApiManage/add.html +++ /dev/null @@ -1,182 +0,0 @@ - - -
- 接口管理 - 新增接口 -
-
- - - -
- -
- -
-
-
- -
- -
-
-
- -
- -
-
系统自动生成,不允许修改
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
-
- - -
-
-
-
-
-
- - - - - - - - \ No newline at end of file diff --git a/Application/Admin/View/ApiManage/index.html b/Application/Admin/View/ApiManage/index.html deleted file mode 100644 index 8b50e13..0000000 --- a/Application/Admin/View/ApiManage/index.html +++ /dev/null @@ -1,119 +0,0 @@ - - -
- 应用管理 - API列表 -
- 新增 - 接口文档 - - - - - - - - - - - - - - - - - - - - - - - - - -
#接口名称接口映射接口状态请求方式接口说明操作
{$i}{$vo['apiName']}{$vo['hash']} - - 生效 - - 禁用 - - - - - 不限 - - - POST - - - GET - - - {$vo['info']} - - 禁用 - - 启用 - - 请求参数 - 编辑 - 返回参数 - 删除 -
-
-
-
- - - \ No newline at end of file diff --git a/Application/Admin/View/ApiStore/add.html b/Application/Admin/View/ApiStore/add.html deleted file mode 100644 index e1309f1..0000000 --- a/Application/Admin/View/ApiStore/add.html +++ /dev/null @@ -1,99 +0,0 @@ - - -
- 接口管理 - 接口编辑 -
-
- - - -
- -
- -
-
系统自动生成,不允许修改
-
-
- -
- -
-
系统自动生成,不允许修改
-
-
- -
- -
-
-
-
- - -
-
-
-
-
-
- - - - - - - - \ No newline at end of file diff --git a/Application/Admin/View/ApiStore/index.html b/Application/Admin/View/ApiStore/index.html deleted file mode 100644 index 56225cf..0000000 --- a/Application/Admin/View/ApiStore/index.html +++ /dev/null @@ -1,152 +0,0 @@ - - - - -
- 接口仓库 - 接口列表 -
- 刷新 - - - - - - - - - - -
接口名称接口路径适配秘钥接口状态操作
-
-
-
- - - \ No newline at end of file diff --git a/Application/Admin/View/App/add.html b/Application/Admin/View/App/add.html deleted file mode 100644 index d6219c6..0000000 --- a/Application/Admin/View/App/add.html +++ /dev/null @@ -1,101 +0,0 @@ - - -
- 应用管理 - 新增应用 -
-
- - - -
- -
- -
-
-
- -
- -
-
系统自动生成,不允许修改
-
-
- -
- -
-
系统自动生成,不允许修改
-
-
- -
- -
-
-
-
- - -
-
-
-
-
-
- - - - - - - - \ No newline at end of file diff --git a/Application/Admin/View/App/index.html b/Application/Admin/View/App/index.html deleted file mode 100644 index 2c965e3..0000000 --- a/Application/Admin/View/App/index.html +++ /dev/null @@ -1,95 +0,0 @@ - - -
- 应用管理 - 应用列表 -
- 新增 - - - - - - - - - - - - - - - - - - - - - - - - - -
#应用名称AppIdAppSecret应用说明应用状态操作
{$i}{$vo['app_name']}{$vo['app_id']}{$vo['app_secret']}{$vo['app_info']} - - 生效 - - 禁用 - - - - 禁用 - - 启用 - - 编辑 - 删除 -
-
-
-
- - - \ No newline at end of file diff --git a/Application/Admin/View/Document/add.html b/Application/Admin/View/Document/add.html deleted file mode 100644 index 3989fd2..0000000 --- a/Application/Admin/View/Document/add.html +++ /dev/null @@ -1,63 +0,0 @@ -add.html - -
- 文档秘钥管理 - 新增秘钥 -
-
-
- -
- -
-
-
- -
- -
-
系统自动生成,不允许修改
-
-
- -
- -
-
单位:小时
-
-
-
- - -
-
-
-
-
-
- - - \ No newline at end of file diff --git a/Application/Admin/View/Document/addTime.html b/Application/Admin/View/Document/addTime.html deleted file mode 100644 index 066fa07..0000000 --- a/Application/Admin/View/Document/addTime.html +++ /dev/null @@ -1,63 +0,0 @@ -add.html - -
- 文档秘钥管理 - 延时秘钥 -
-
-
- -
- -
-
-
- -
- -
-
系统自动生成,不允许修改
-
-
- -
- -
-
单位:小时
-
-
-
- - -
-
-
-
-
-
- - - \ No newline at end of file diff --git a/Application/Admin/View/Document/index.html b/Application/Admin/View/Document/index.html deleted file mode 100644 index 62ce18c..0000000 --- a/Application/Admin/View/Document/index.html +++ /dev/null @@ -1,178 +0,0 @@ - - - - -
- 秘钥列表 -
- 新增 - - - - - - - - - - - - -
秘钥备注访问秘钥过期时间访问次数最近访问状态操作
-
-
-
- - - \ No newline at end of file diff --git a/Application/Admin/View/FieldsInfoManage/add.html b/Application/Admin/View/FieldsInfoManage/add.html deleted file mode 100644 index 0dc725f..0000000 --- a/Application/Admin/View/FieldsInfoManage/add.html +++ /dev/null @@ -1,129 +0,0 @@ - - -
- 接口管理 - {:(I('get.id')?'编辑':'新增')}{:(I('get.type') == 1?'返回':'请求')}字段 -
-
- - - - - -
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- - - - - - - - -
-
-
- -
- -
-
-
- -
- -
-
-
-
- - -
-
-
-
-
-
- - - - - - - - \ No newline at end of file diff --git a/Application/Admin/View/FieldsInfoManage/index.html b/Application/Admin/View/FieldsInfoManage/index.html deleted file mode 100644 index d881c48..0000000 --- a/Application/Admin/View/FieldsInfoManage/index.html +++ /dev/null @@ -1,61 +0,0 @@ - - -
- 接口管理 - {:($type == 1?'返回':'请求')}字段列表 -
- 新增 - - - - - - - - - - - - - - - - - - - -
#字段名称字段说明操作
{$i}{$vo['field']}{$vo['info']} - 编辑 - 删除 -
-
-
-
- - - \ No newline at end of file diff --git a/Application/Admin/View/FieldsInfoManage/upload.html b/Application/Admin/View/FieldsInfoManage/upload.html deleted file mode 100644 index 785e3cf..0000000 --- a/Application/Admin/View/FieldsInfoManage/upload.html +++ /dev/null @@ -1,94 +0,0 @@ - - - - -
- 接口管理 - 返回字段[批量覆盖] -
-
- - - - - -
- -
- -
-
-
-
- JSON格式化 - 全部收起 - 全部展开 -
-
-
- -
-

-                    
-
-
-
- - -
-
-
-
-
-
- - - \ No newline at end of file diff --git a/Application/Admin/View/FieldsManage/add.html b/Application/Admin/View/FieldsManage/add.html deleted file mode 100644 index 0dc725f..0000000 --- a/Application/Admin/View/FieldsManage/add.html +++ /dev/null @@ -1,129 +0,0 @@ - - -
- 接口管理 - {:(I('get.id')?'编辑':'新增')}{:(I('get.type') == 1?'返回':'请求')}字段 -
-
- - - - - -
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- - - - - - - - -
-
-
- -
- -
-
-
- -
- -
-
-
-
- - -
-
-
-
-
-
- - - - - - - - \ No newline at end of file diff --git a/Application/Admin/View/FieldsManage/index.html b/Application/Admin/View/FieldsManage/index.html deleted file mode 100644 index 7e1d526..0000000 --- a/Application/Admin/View/FieldsManage/index.html +++ /dev/null @@ -1,78 +0,0 @@ - - -
- 接口管理 - {:($type == 1?'返回':'请求')}字段列表 -
- 新增 - - 上传 - - - - - - - - - - - - - - - - - - - - - - - - - - -
#字段名称数据类型是否必须默认值字段说明操作
{$i}{$vo['showName']} - {$dataType[$vo['dataType']]} - - - 必须 - - 不必须 - - {$vo['default']}{$vo['info']} - 编辑 - 删除 -
-
-
-
- - - \ No newline at end of file diff --git a/Application/Admin/View/FieldsManage/upload.html b/Application/Admin/View/FieldsManage/upload.html deleted file mode 100644 index 785e3cf..0000000 --- a/Application/Admin/View/FieldsManage/upload.html +++ /dev/null @@ -1,94 +0,0 @@ - - - - -
- 接口管理 - 返回字段[批量覆盖] -
-
- - - - - -
- -
- -
-
-
-
- JSON格式化 - 全部收起 - 全部展开 -
-
-
- -
-

-                    
-
-
-
- - -
-
-
-
-
-
- - - \ No newline at end of file diff --git a/Application/Admin/View/Index/index.html b/Application/Admin/View/Index/index.html deleted file mode 100644 index b9f3779..0000000 --- a/Application/Admin/View/Index/index.html +++ /dev/null @@ -1,123 +0,0 @@ - - - - - - {:C('APP_NAME')}管理后台 - - - - - - - -
- - - - -
-
-
    -
-
-
- - -
- -
-
    -
    -
    -
    - - - -
    - - - - - \ No newline at end of file diff --git a/Application/Admin/View/Index/welcome.html b/Application/Admin/View/Index/welcome.html deleted file mode 100644 index a9bfefb..0000000 --- a/Application/Admin/View/Index/welcome.html +++ /dev/null @@ -1,10 +0,0 @@ - - - - - Title - - -Welcome - - \ No newline at end of file diff --git a/Application/Admin/View/Log/index.html b/Application/Admin/View/Log/index.html deleted file mode 100644 index 517cd07..0000000 --- a/Application/Admin/View/Log/index.html +++ /dev/null @@ -1,163 +0,0 @@ - - - - -
    - 日志列表 -
    -
    -
    -
    - -
    -
    -
    - -
    -
    -
    - 查询 -
    -
    -
    - - - - - - - - - - - -
    行为名称用户ID用户昵称操作URL执行时间操作
    -
    -
    -
    - - - \ No newline at end of file diff --git a/Application/Admin/View/Log/showDetail.html b/Application/Admin/View/Log/showDetail.html deleted file mode 100644 index ff89ab4..0000000 --- a/Application/Admin/View/Log/showDetail.html +++ /dev/null @@ -1,51 +0,0 @@ - - -
    - 日志详情 -
    -
    -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
    -
    -
    -
    - - - \ No newline at end of file diff --git a/Application/Admin/View/Login/add.html b/Application/Admin/View/Login/add.html deleted file mode 100644 index b61f23f..0000000 --- a/Application/Admin/View/Login/add.html +++ /dev/null @@ -1,61 +0,0 @@ - - -
    - 个人信息维护 -
    -
    -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
    -
    - - -
    -
    -
    -
    -
    -
    - - - \ No newline at end of file diff --git a/Application/Admin/View/Login/index.html b/Application/Admin/View/Login/index.html deleted file mode 100644 index 13ffa61..0000000 --- a/Application/Admin/View/Login/index.html +++ /dev/null @@ -1,186 +0,0 @@ - - - - - - - - {:C('APP_NAME')}管理后台 - - - - - - - - - - - - - \ No newline at end of file diff --git a/Application/Admin/View/Menu/add.html b/Application/Admin/View/Menu/add.html deleted file mode 100644 index dcea19a..0000000 --- a/Application/Admin/View/Menu/add.html +++ /dev/null @@ -1,109 +0,0 @@ - - -
    - 菜单管理 - {:(isset($detail['id'])?'编辑':'新增')}菜单 -
    -
    - - - -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
    -
    - - -
    -
    -
    -
    -
    -
    - - - - - - - \ No newline at end of file diff --git a/Application/Admin/View/Menu/index.html b/Application/Admin/View/Menu/index.html deleted file mode 100644 index bd8524f..0000000 --- a/Application/Admin/View/Menu/index.html +++ /dev/null @@ -1,93 +0,0 @@ - - -
    - 菜单管理 - 菜单列表 -
    - 新增 - - - - - - - - - - - - - - - - - - - - - - - -
    #菜单名称排序菜单URL隐藏操作
    {$i}{$vo['showName']}{$vo['sort']}{$vo['url']} - - 隐藏 - - 显示 - - - - 显示 - - 隐藏 - - 编辑 - 删除 -
    -
    -
    -
    - - - \ No newline at end of file diff --git a/Application/Admin/View/Permission/add.html b/Application/Admin/View/Permission/add.html deleted file mode 100644 index e5d5fe3..0000000 --- a/Application/Admin/View/Permission/add.html +++ /dev/null @@ -1,86 +0,0 @@ - - -
    - 权限管理 - {:(isset($detail['id'])?'编辑':'新增')}权限组 -
    -
    - - - -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
    -
    - - -
    -
    -
    -
    -
    -
    - - - - - - - \ No newline at end of file diff --git a/Application/Admin/View/Permission/group.html b/Application/Admin/View/Permission/group.html deleted file mode 100644 index 4afb736..0000000 --- a/Application/Admin/View/Permission/group.html +++ /dev/null @@ -1,56 +0,0 @@ - - -
    - 授权管理 -
    -
    - -
    - -
    - - - - - - - -
    -
    -
    -
    - - -
    -
    -
    -
    -
    -
    - - - \ No newline at end of file diff --git a/Application/Admin/View/Permission/index.html b/Application/Admin/View/Permission/index.html deleted file mode 100644 index 141a0a9..0000000 --- a/Application/Admin/View/Permission/index.html +++ /dev/null @@ -1,99 +0,0 @@ - - -
    - 权限管理 - 权限组列表 -
    - 新增 - - - - - - - - - - - - - - - - - - - - - - - - - -
    #权限组描述访问授权成员授权状态操作
    {$i}{$vo['name']}{$vo['description']} - 访问授权 - - 成员授权 - - - 启用 - - 禁用 - - - - 禁用 - - 启用 - - 编辑 - 删除 -
    -
    -
    -
    - - - \ No newline at end of file diff --git a/Application/Admin/View/Permission/member.html b/Application/Admin/View/Permission/member.html deleted file mode 100644 index 8248621..0000000 --- a/Application/Admin/View/Permission/member.html +++ /dev/null @@ -1,73 +0,0 @@ - - -
    - 权限管理 - 权限组成员列表 -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    #用户账号用户昵称登录次数最后登录时间最后登录IP状态操作
    {$i}{$vo['username']}{$vo['nickname']}{:intval($vo['loginTimes'])}{:(empty($vo['lastLoginTime'])?'该用户未曾登录过':date('Y-m-d H:i:s', $vo['lastLoginTime']))}{:(empty($vo['lastLoginIp'])?'该用户未曾登录过':long2ip($vo['lastLoginIp']))} - - 启用 - - 禁用 - - - 删除 -
    -
    -
    -
    - - - \ No newline at end of file diff --git a/Application/Admin/View/Permission/rule.html b/Application/Admin/View/Permission/rule.html deleted file mode 100644 index 1304df7..0000000 --- a/Application/Admin/View/Permission/rule.html +++ /dev/null @@ -1,74 +0,0 @@ - - -
    - 权限管理 - 权限组细节配置 -
    -
    - - -
    - -
    - -
    -
    - - - -
    - - - -
    -
    -
    -
    -
    -
    -
    -
    - - -
    -
    -
    -
    -
    - - - \ No newline at end of file diff --git a/Application/Admin/View/Public/base.html b/Application/Admin/View/Public/base.html deleted file mode 100644 index 703256c..0000000 --- a/Application/Admin/View/Public/base.html +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - {:C('APP_NAME')}管理后台 - - - - - - -
    - -
    - - - \ No newline at end of file diff --git a/Application/Admin/View/User/add.html b/Application/Admin/View/User/add.html deleted file mode 100644 index c5b3f83..0000000 --- a/Application/Admin/View/User/add.html +++ /dev/null @@ -1,95 +0,0 @@ - - -
    - 用户管理 - {:(isset($detail['id'])?'编辑':'新增')}用户 -
    -
    - - - -
    - -
    - -
    -
    -
    - -
    - -
    -
    -
    - -
    - -
    -
    默认:123456
    -
    -
    -
    -
    -
    - - -
    -
    -
    -
    -
    -
    - - - - - - - \ No newline at end of file diff --git a/Application/Admin/View/User/index.html b/Application/Admin/View/User/index.html deleted file mode 100644 index 37a7121..0000000 --- a/Application/Admin/View/User/index.html +++ /dev/null @@ -1,97 +0,0 @@ - - -
    - 用户管理 - 用户列表 -
    - 新增 - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    #用户账号用户昵称登录次数最后登录时间最后登录IP状态操作
    {$i}{$vo['username']}{$vo['nickname']}{:intval($vo['loginTimes'])}{:(empty($vo['lastLoginTime'])?'该用户未曾登录过':$vo['lastLoginTime'])}{:(empty($vo['lastLoginIp'])?'该用户未曾登录过':$vo['lastLoginIp'])} - - 启用 - - 禁用 - - - - 禁用 - - 启用 - - 授权 - 删除 -
    -
    -
    -
    - - - \ No newline at end of file diff --git a/Application/Admin/index.html b/Application/Admin/index.html deleted file mode 100644 index 0519ecb..0000000 --- a/Application/Admin/index.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/Application/ApiLog/index.html b/Application/ApiLog/index.html deleted file mode 100644 index e69de29..0000000 diff --git a/Application/Common/Common/function.php b/Application/Common/Common/function.php deleted file mode 100644 index 9413382..0000000 --- a/Application/Common/Common/function.php +++ /dev/null @@ -1,66 +0,0 @@ - $val) { - if (preg_match($rx_http, $key)) { - $arh_key = preg_replace($rx_http, '', $key); - $rx_matches = explode('_', $arh_key); - if (count($rx_matches) > 0 and strlen($arh_key) > 2) { - foreach ($rx_matches as $ak_key => $ak_val) - $rx_matches[$ak_key] = ucfirst($ak_val); - $arh_key = implode('-', $rx_matches); - } - $arh[$arh_key] = $val; - } - } - - return $arh; - } -} - -/** - * 系统非常规MD5加密方法 - * @param string $str 要加密的字符串 - * @param string $auth_key 要加密的字符串 - * @return string - * @author jry <598821125@qq.com> - */ -function user_md5($str, $auth_key = ''){ - if(!$auth_key){ - $auth_key = C('AUTH_KEY'); - } - return '' === $str ? '' : md5(sha1($str) . $auth_key); -} - -/** - * @param $url - * @param int $timeOut - * @return bool|mixed - */ -if (!function_exists('curlGet')) { - function curlGet($url, $timeOut = 10){ - $oCurl = curl_init(); - if (stripos($url, "https://") !== false) { - curl_setopt($oCurl, CURLOPT_SSL_VERIFYPEER, false); - curl_setopt($oCurl, CURLOPT_SSL_VERIFYHOST, false); - curl_setopt($oCurl, CURLOPT_SSLVERSION, 1); - } - curl_setopt($oCurl, CURLOPT_URL, $url); - curl_setopt($oCurl, CURLOPT_RETURNTRANSFER, 1); - curl_setopt($oCurl, CURLOPT_TIMEOUT, $timeOut); - $sContent = curl_exec($oCurl); - $aStatus = curl_getinfo($oCurl); - curl_close($oCurl); - if (intval($aStatus["http_code"]) == 200) { - return $sContent; - } else { - return false; - } - } -} \ No newline at end of file diff --git a/Application/Common/Common/index.html b/Application/Common/Common/index.html deleted file mode 100644 index 0519ecb..0000000 --- a/Application/Common/Common/index.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/Application/Common/Conf/config.php b/Application/Common/Conf/config.php deleted file mode 100644 index f24c027..0000000 --- a/Application/Common/Conf/config.php +++ /dev/null @@ -1,35 +0,0 @@ - 2, - - 'APP_VERSION' => 'v2.0', - 'APP_NAME' => 'apiAdmin', - - 'USER_ADMINISTRATOR' => array(1,2), - 'AUTH_KEY' => 'I&TC{pft>L,C`wFQ>&#ROW>k{Kxlt1>ryW(>r<#R', - - 'COMPANY_NAME' => 'ApiAdmin开发维护团队', - - 'URL_ROUTER_ON' => true, - 'URL_ROUTE_RULES' => array( - 'wiki/:hash' => 'Home/Wiki/apiField', - 'api/:hash' => 'Home/Api/index', - 'wikiList' => 'Home/Wiki/apiList', - 'errorList' => 'Home/Wiki/errorCode', - 'calculation' => 'Home/Wiki/calculation' - ), - - 'LANG_SWITCH_ON' => true, // 开启语言包功能 - 'LANG_LIST' => 'zh-cn', // 允许切换的语言列表 用逗号分隔 - 'VAR_LANGUAGE' => 'l', // 默认语言切换变量 - - /* 数据库设置 */ - 'DB_TYPE' => 'mysql', // 数据库类型 - 'DB_HOST' => '127.0.0.1', // 服务器地址 - 'DB_NAME' => 'demo', // 数据库名 - 'DB_USER' => 'root', // 用户名 - 'DB_PWD' => '123456' // 密码 - -); - diff --git a/Application/Common/Conf/index.html b/Application/Common/Conf/index.html deleted file mode 100644 index 0519ecb..0000000 --- a/Application/Common/Conf/index.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/Application/Common/index.html b/Application/Common/index.html deleted file mode 100644 index 0519ecb..0000000 --- a/Application/Common/index.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/Application/Data/apiAdmin.sql b/Application/Data/apiAdmin.sql deleted file mode 100644 index 7eb9b85..0000000 --- a/Application/Data/apiAdmin.sql +++ /dev/null @@ -1,333 +0,0 @@ -# ************************************************************ -# Sequel Pro SQL dump -# Version 4541 -# -# http://www.sequelpro.com/ -# https://github.com/sequelpro/sequelpro -# -# Host: 127.0.0.1 (MySQL 5.7.14-log) -# Database: apiAdmin -# Generation Time: 2017-05-01 09:04:19 +0000 -# ************************************************************ - - -/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; -/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; -/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; -/*!40101 SET NAMES utf8 */; -/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; -/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; -/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; - - -# Dump of table api_app -# ------------------------------------------------------------ - -DROP TABLE IF EXISTS `api_app`; - -CREATE TABLE `api_app` ( - `id` int(11) unsigned NOT NULL AUTO_INCREMENT, - `app_id` varchar(50) NOT NULL DEFAULT '' COMMENT '应用id', - `app_secret` varchar(50) NOT NULL DEFAULT '' COMMENT '应用密码', - `app_name` varchar(50) NOT NULL DEFAULT '' COMMENT '应用名称', - `app_status` tinyint(2) NOT NULL DEFAULT '1' COMMENT '应用状态:0表示禁用,1表示启用', - `app_info` tinytext NOT NULL COMMENT '应用说明', - PRIMARY KEY (`id`), - UNIQUE KEY `app_id` (`app_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='appId和appSecret表'; - - -# Dump of table api_auth_group -# ------------------------------------------------------------ - -DROP TABLE IF EXISTS `api_auth_group`; - -CREATE TABLE `api_auth_group` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `name` varchar(50) NOT NULL COMMENT '组名称', - `description` varchar(50) NOT NULL COMMENT '组描述', - `status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '组状态:为1正常,为0禁用', - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='权限组'; - - -# Dump of table api_auth_group_access -# ------------------------------------------------------------ - -DROP TABLE IF EXISTS `api_auth_group_access`; - -CREATE TABLE `api_auth_group_access` ( - `id` int(11) unsigned NOT NULL AUTO_INCREMENT, - `uid` mediumint(8) unsigned NOT NULL, - `groupId` varchar(255) NOT NULL DEFAULT '', - PRIMARY KEY (`id`), - KEY `uid` (`uid`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用户和组的对应关系'; - - -# Dump of table api_auth_rule -# ------------------------------------------------------------ - -DROP TABLE IF EXISTS `api_auth_rule`; - -CREATE TABLE `api_auth_rule` ( - `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT, - `url` char(80) NOT NULL DEFAULT '' COMMENT '规则唯一标识', - `groupId` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '权限所属组的ID', - `auth` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '权限数值', - `status` tinyint(1) unsigned NOT NULL DEFAULT '1' COMMENT '状态:为1正常,为0禁用', - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='权限细节'; - - -# Dump of table api_fields -# ------------------------------------------------------------ - -DROP TABLE IF EXISTS `api_fields`; - -CREATE TABLE `api_fields` ( - `id` int(11) unsigned NOT NULL AUTO_INCREMENT, - `fieldName` varchar(50) NOT NULL DEFAULT '' COMMENT '字段名称', - `hash` varchar(50) NOT NULL DEFAULT '' COMMENT '对应接口的唯一标识', - `dataType` tinyint(2) NOT NULL DEFAULT '0' COMMENT '数据类型,来源于DataType类库', - `default` varchar(500) NOT NULL DEFAULT '' COMMENT '默认值', - `isMust` tinyint(2) NOT NULL DEFAULT '0' COMMENT '是否必须 0为不必须,1为必须', - `range` varchar(500) NOT NULL DEFAULT '' COMMENT '范围,Json字符串,根据数据类型有不一样的含义', - `info` varchar(500) NOT NULL DEFAULT '' COMMENT '字段说明', - `type` tinyint(2) NOT NULL DEFAULT '0' COMMENT '字段用处:0为request,1为response', - `showName` varchar(50) NOT NULL DEFAULT '' COMMENT 'wiki显示用字段', - PRIMARY KEY (`id`), - KEY `hash` (`hash`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用于保存各个API的字段规则'; - - -# Dump of table api_list -# ------------------------------------------------------------ - -DROP TABLE IF EXISTS `api_list`; - -CREATE TABLE `api_list` ( - `id` int(11) unsigned NOT NULL AUTO_INCREMENT, - `apiName` varchar(50) NOT NULL DEFAULT '' COMMENT 'api索引,保存了类和方法', - `hash` varchar(50) NOT NULL DEFAULT '' COMMENT 'api唯一标识', - `accessToken` tinyint(2) NOT NULL DEFAULT '1' COMMENT '是否需要认证AccessToken 1:需要,0:不需要', - `needLogin` tinyint(2) NOT NULL DEFAULT '1' COMMENT '是否需要认证用户token 1:需要 0:不需要', - `status` tinyint(2) NOT NULL DEFAULT '1' COMMENT 'API状态:0表示禁用,1表示启用', - `method` tinyint(2) NOT NULL DEFAULT '2' COMMENT '请求方式0:不限1:Post,2:Get', - `info` varchar(500) NOT NULL DEFAULT '' COMMENT 'api中文说明', - `isTest` tinyint(2) NOT NULL DEFAULT '0' COMMENT '是否是测试模式:0:生产模式,1:测试模式', - `returnStr` text COMMENT '返回数据示例', - PRIMARY KEY (`id`), - UNIQUE KEY `hash` (`hash`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用于维护接口信息'; - - -# Dump of table api_menu -# ------------------------------------------------------------ - -DROP TABLE IF EXISTS `api_menu`; - -CREATE TABLE `api_menu` ( - `id` int(11) unsigned NOT NULL AUTO_INCREMENT, - `name` varchar(50) NOT NULL DEFAULT '' COMMENT '菜单名', - `fid` int(11) NOT NULL COMMENT '父级菜单ID', - `url` varchar(50) NOT NULL DEFAULT '' COMMENT '链接', - `auth` tinyint(2) NOT NULL DEFAULT '0' COMMENT '访客权限', - `sort` int(11) NOT NULL DEFAULT '0' COMMENT '排序', - `hide` tinyint(2) NOT NULL DEFAULT '0' COMMENT '是否显示', - `icon` varchar(50) NOT NULL DEFAULT '' COMMENT '菜单图标', - `level` tinyint(2) NOT NULL DEFAULT '0' COMMENT '菜单认证等级', - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='目录信息'; - -LOCK TABLES `api_menu` WRITE; -/*!40000 ALTER TABLE `api_menu` DISABLE KEYS */; - -INSERT INTO `api_menu` (`id`, `name`, `fid`, `url`, `auth`, `sort`, `hide`, `icon`, `level`) -VALUES - (1,'欢迎页',0,'Index/welcome',0,0,0,'',0), - (2,'系统配置',0,'',0,1,0,'',0), - (3,'菜单维护',2,'Menu/index',0,0,0,'',0), - (4,'用户管理',2,'User/index',0,1,0,'',0), - (5,'权限管理',2,'Permission/index',0,2,0,'',0), - (6,'操作日志',2,'Log/index',0,3,0,'',0), - (7,'应用管理',0,'',0,2,0,'',0), - (8,'应用列表',7,'App/index',0,0,0,'',0), - (9,'接口列表',7,'ApiManage/index',0,1,0,'',0), - (10,'字段注解(暂未开放)',7,'FieldsInfoManage/index',0,2,1,'',0), - (11,'首页',0,'Index/index',0,0,1,'',0), - (12,'新增菜单',3,'Menu/add',0,0,1,'',0), - (13,'编辑菜单',3,'Menu/edit',0,0,1,'',0), - (14,'隐藏菜单',3,'Menu/close',0,0,1,'',0), - (15,'显示菜单',3,'Menu/open',0,0,1,'',0), - (16,'删除菜单',3,'Menu/del',0,0,1,'',0), - (17,'新增用户',4,'User/add',0,0,1,'',0), - (18,'账号封停',4,'User/close',0,0,1,'',0), - (19,'账号解封',4,'User/open',0,0,1,'',0), - (20,'账号删除',4,'User/del',0,0,1,'',0), - (21,'编辑应用',8,'App/edit',0,0,1,'',0), - (22,'新增应用',8,'App/add',0,0,1,'',0), - (23,'启用应用',8,'App/open',0,0,1,'',0), - (24,'禁用应用',8,'App/close',0,0,1,'',0), - (25,'删除应用',8,'App/del',0,0,1,'',0), - (26,'新增接口',9,'ApiManage/add',0,0,1,'',0), - (27,'启用接口',9,'ApiManage/open',0,0,1,'',0), - (28,'禁用接口',9,'ApiManage/close',0,0,1,'',0), - (29,'编辑接口',9,'ApiManage/edit',0,0,1,'',0), - (30,'删除接口',9,'ApiManage/del',0,0,1,'',0), - (31,'返回字段编辑',9,'FieldsManage/response',0,0,1,'',0), - (32,'请求字段编辑',9,'FieldsManage/request',0,0,1,'',0), - (33,'新增字段',9,'FieldsManage/add',0,0,1,'',0), - (34,'字段编辑',9,'FieldsManage/edit',0,0,1,'',0), - (35,'批量上传返回字段',9,'FieldsManage/upload',0,0,1,'',0), - (36,'Ajax查询Log列表',6,'Log/ajaxGetIndex',0,0,1,'',0), - (37,'日志删除',6,'Log/del',0,0,1,'',0), - (38,'日志详情查看',6,'Log/showDetail',0,0,1,'',0), - (39,'添加权限组',5,'Permission/add',0,0,1,'',0), - (40,'禁用权限组',5,'Permission/close',0,0,1,'',0), - (41,'启用权限组',5,'Permission/open',0,0,1,'',0), - (42,'编辑权限组',5,'Permission/edit',0,0,1,'',0), - (43,'删除权限组',5,'Permission/del',0,0,1,'',0), - (44,'用户入组',5,'Permission/group',0,0,1,'',0), - (45,'组用户列表',5,'Permission/member',0,0,1,'',0), - (46,'踢出成员',5,'Permission/delMember',0,0,1,'',0), - (47,'权限组权限配置',5,'Permission/rule',0,0,1,'',0), - (48,'三方接口',0,'',0,4,0,'',0), - (49,'接口仓库',48,'ApiStore/index',0,0,0,'',0), - (50,'Ajax获取接口列表',49,'ApiStore/ajaxGetIndex',0,0,1,'',0), - (51,'刷新接口',49,'ApiStore/refresh',0,0,1,'',0), - (52,'编辑接口',49,'ApiStore/edit',0,0,1,'',0), - (53,'启用接口',49,'ApiStore/open',0,0,1,'',0), - (54,'禁用接口',49,'ApiStore/close',0,0,1,'',0), - (55,'Ajax获取秘钥列表',61,'ApiKey/ajaxGetIndex',0,0,1,'',0), - (56,'新增秘钥类别',61,'ApiKey/add',0,0,1,'',0), - (57,'编辑秘钥类别',61,'ApiKey/edit',0,0,1,'',0), - (58,'删除秘钥分类',61,'ApiKey/del',0,0,1,'',0), - (59,'启用秘钥分类',61,'ApiKey/open',0,0,1,'',0), - (60,'禁用秘钥分类',61,'ApiKey/close',0,0,1,'',0), - (61,'秘钥管理',48,'ApiKey/index',0,1,0,'',0), - (66, '文档管理', 0, '', 0, 5, 0, '', 0), - (67, '秘钥管理', 66, 'Document/index', 0, 0, 0, '', 0), - (68, 'Ajax获取文档记录', 67, 'Document/ajaxGetIndex', 0, 1, 1, '', 0), - (69, '创建访问秘钥', 67, 'Document/add', 0, 2, 1, '', 0), - (70, '延长Key时间', 67, 'Document/addTime', 0, 3, 1, '', 0), - (71, '启用Key', 67, 'Document/open', 0, 4, 1, '', 0), - (72, '禁用Key', 67, 'Document/close', 0, 5, 1, '', 0); - -/*!40000 ALTER TABLE `api_menu` ENABLE KEYS */; -UNLOCK TABLES; - - -# Dump of table api_store -# ------------------------------------------------------------ - -DROP TABLE IF EXISTS `api_store`; - -CREATE TABLE `api_store` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `path` varchar(50) NOT NULL DEFAULT '' COMMENT '对应的代码路径', - `auth` int(11) NOT NULL DEFAULT '0' COMMENT '使用的接口秘钥', - `status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '接口状态', - `name` varchar(50) NOT NULL DEFAULT '' COMMENT '接口名称(提供辨识使用)', - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='三方接口仓库'; - - -# Dump of table api_store_auth -# ------------------------------------------------------------ - -DROP TABLE IF EXISTS `api_store_auth`; - -CREATE TABLE `api_store_auth` ( - `id` int(11) unsigned NOT NULL AUTO_INCREMENT, - `name` varchar(50) NOT NULL DEFAULT '' COMMENT '秘钥名称', - `appId` varchar(50) NOT NULL DEFAULT '' COMMENT '应用ID', - `appSecret` varchar(255) NOT NULL DEFAULT '' COMMENT '应用秘钥', - `status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '秘钥状态', - `accessToken` varchar(255) DEFAULT '' COMMENT '授权秘钥(千米)', - `refreshToken` varchar(255) DEFAULT '' COMMENT '刷新秘钥(千米)', - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='三方接口秘钥管理'; - - - -# Dump of table api_user -# ------------------------------------------------------------ - -DROP TABLE IF EXISTS `api_user`; - -CREATE TABLE `api_user` ( - `id` int(11) unsigned NOT NULL AUTO_INCREMENT, - `username` varchar(64) NOT NULL DEFAULT '' COMMENT '用户名', - `nickname` varchar(64) NOT NULL DEFAULT '' COMMENT '用户昵称', - `password` char(32) NOT NULL DEFAULT '' COMMENT '用户密码', - `regTime` int(10) NOT NULL DEFAULT '0' COMMENT '注册时间', - `regIp` varchar(11) NOT NULL DEFAULT '' COMMENT '注册IP', - `updateTime` int(10) NOT NULL DEFAULT '0' COMMENT '更新时间', - `status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '账号状态 0封号 1正常', - `openId` varchar(100) DEFAULT NULL COMMENT '微信唯一ID', - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='管理员认证信息'; -INSERT INTO `api_user` (`username`, `nickname`, `password`, `regTime`, `regIp`, `updateTime`, `status`) -VALUES - ('root', 'root', '912601e4ad1b308c9ae41877cf6ca754', 1492004246, '3682992231', 1492236545, 1); - - -# Dump of table api_user_action -# ------------------------------------------------------------ - -DROP TABLE IF EXISTS `api_user_action`; - -CREATE TABLE `api_user_action` ( - `id` int(11) unsigned NOT NULL AUTO_INCREMENT, - `actionName` varchar(50) NOT NULL DEFAULT '' COMMENT '行为名称', - `uid` int(11) NOT NULL DEFAULT '0' COMMENT '操作用户ID', - `nickname` varchar(50) NOT NULL DEFAULT '' COMMENT '用户昵称', - `addTime` int(11) NOT NULL DEFAULT '0' COMMENT '操作时间', - `data` text COMMENT '用户提交的数据', - `url` varchar(200) NOT NULL DEFAULT '' COMMENT '操作URL', - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用户操作日志'; - - -# Dump of table api_user_data -# ------------------------------------------------------------ - -DROP TABLE IF EXISTS `api_user_data`; - -CREATE TABLE `api_user_data` ( - `id` int(11) unsigned NOT NULL AUTO_INCREMENT, - `loginTimes` int(11) NOT NULL COMMENT '账号登录次数', - `lastLoginIp` varchar(11) NOT NULL DEFAULT '' COMMENT '最后登录IP', - `lastLoginTime` int(11) NOT NULL COMMENT '最后登录时间', - `uid` varchar(11) NOT NULL DEFAULT '' COMMENT '用户ID', - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='管理员数据表'; - - -# Dump of table api_document -# ------------------------------------------------------------ - -DROP TABLE IF EXISTS `api_document`; - -CREATE TABLE `api_document` ( - `id` INT(11) NOT NULL AUTO_INCREMENT, - `key` VARCHAR(50) NOT NULL DEFAULT '' COMMENT '授权秘钥', - `endTime` INT(11) NOT NULL DEFAULT '0' COMMENT '失效时间戳', - `times` INT(11) NOT NULL DEFAULT '0' COMMENT '访问次数', - `lastTime` INT(11) NOT NULL DEFAULT '0' COMMENT '最后访问时间', - `lastIp` VARCHAR(50) NOT NULL DEFAULT '' COMMENT '最后访问IP', - `createTime` INT(11) NOT NULL DEFAULT '0' COMMENT '创建时间', - `info` varchar(50) NOT NULL COMMENT '备注', - `status` TINYINT(1) NOT NULL DEFAULT '1' COMMENT '1生效,0失效', - PRIMARY KEY (`id`), - UNIQUE INDEX `key` (`key`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='文档访问秘钥'; - - -/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; -/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; -/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; -/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; -/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; -/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; diff --git a/Application/Home/Api/Base.class.php b/Application/Home/Api/Base.class.php deleted file mode 100644 index 542b75a..0000000 --- a/Application/Home/Api/Base.class.php +++ /dev/null @@ -1,20 +0,0 @@ - - */ - -namespace Home\Api; - - -class Base { - - protected $city; - protected $userInfo; - - public function __construct() { - $this->city = C('CITY'); - $this->userInfo = C('USER_INFO'); - } -} \ No newline at end of file diff --git a/Application/Home/Api/BuildToken.class.php b/Application/Home/Api/BuildToken.class.php deleted file mode 100644 index a225b1d..0000000 --- a/Application/Home/Api/BuildToken.class.php +++ /dev/null @@ -1,53 +0,0 @@ - - */ - -namespace Home\Api; - -use Admin\Model\ApiAppModel; -use Home\ORG\ApiLog; -use Home\ORG\Crypt; -use Home\ORG\Response; -use Home\ORG\ReturnCode; - -class BuildToken extends Base { - - public function getAccessToken($param) { - if (empty($param['app_id'])) { - Response::error(ReturnCode::EMPTY_PARAMS, '缺少app_id'); - } - $appObj = new ApiAppModel(); - $appInfo = $appObj->where(array('app_id' => $param['app_id'], 'app_status' => 1))->find(); - if (empty($appInfo)) { - Response::error(ReturnCode::INVALID, '应用ID非法'); - } - $crypt = new Crypt(); - $signature = $param['signature']; - unset($param['signature']); - $sign = $crypt->getAuthToken($appInfo['app_secret'], $param); - Response::debug($sign); - if ($sign !== $signature) { - Response::error(ReturnCode::INVALID, '身份令牌验证失败'); - } - $expires = C('ACCESS_TOKEN_EXPIRES'); - $accessToken = S($param['device_id']); - if ($accessToken) { - S($accessToken, null); - S($param['device_id'], null); - } - $accessToken = $crypt->getAccessToken($appInfo['app_id'], $appInfo['app_secret']); - $appInfo['device_id'] = $param['device_id']; - ApiLog::setAppInfo($appInfo); - S($accessToken, $appInfo, $expires); - S($param['device_id'], $accessToken, $expires); - $return['access_token'] = $accessToken; - $return['expires_in'] = $expires; - - return $return; - } - -} \ No newline at end of file diff --git a/Application/Home/Api/Test.class.php b/Application/Home/Api/Test.class.php deleted file mode 100644 index c7dabce..0000000 --- a/Application/Home/Api/Test.class.php +++ /dev/null @@ -1,19 +0,0 @@ - - */ - -namespace Home\Api; - -use Home\ORG\JPush; - -class Test extends Base { - - public function index() { - - } - -} \ No newline at end of file diff --git a/Application/Home/Api/User.class.php b/Application/Home/Api/User.class.php deleted file mode 100644 index ef7f962..0000000 --- a/Application/Home/Api/User.class.php +++ /dev/null @@ -1,48 +0,0 @@ - - */ - -namespace Home\Api; - - -use Home\ORG\Str; - -class User extends Base { - public function index($param) { - $openId = $this->getOpenId($param); - $old = D('ApiUser')->where(array('openId' => $openId))->find(); - if ($old) { - return array('username' => $old['username'], 'password' => '******'); - } - $data['username'] = Str::randString(6, 1); - $pwd = Str::randString(6, 1); - $data['password'] = user_md5($pwd); - $data['regTime'] = time(); - $data['openId'] = $openId; - $newId = D('ApiUser')->add($data); - D('ApiAuthGroupAccess')->add(array('uid' => $newId, 'groupId' => 1)); - - return array('username' => $data['username'], 'password' => $pwd); - } - - public function re($param) { - $openId = $this->getOpenId($param); - $pwd = Str::randString(6, 1); - $data['password'] = user_md5($pwd); - $old = D('ApiUser')->where(array('openId' => $openId))->find(); - D('ApiUser')->where(array('openId' => $openId))->save($data); - - return array('username' => $old['username'], 'password' => $pwd); - } - - private function getOpenId($param) { - $url = "https://api.weixin.qq.com/sns/jscode2session?appid=wx436e089d55174f47&secret=f4684158a0efd56ff2332582dc62f3db&js_code={$param['code']}&grant_type=authorization_code"; - $res = file_get_contents($url); - $resArr = json_decode($res, true); - - return $resArr['openid']; - } -} \ No newline at end of file diff --git a/Application/Home/ApiStore/ApiAdminSDK.class.php b/Application/Home/ApiStore/ApiAdminSDK.class.php deleted file mode 100644 index 2a3ae4f..0000000 --- a/Application/Home/ApiStore/ApiAdminSDK.class.php +++ /dev/null @@ -1,78 +0,0 @@ - - */ - -namespace Home\ApiStore\ApiSDK; - - -use Home\ApiStore\ApiSDK\ApiAdmin\AuthSign; -use Home\ApiStore\ApiSDK\ApiAdmin\Http; - -class ApiAdminSDK { - private $method; //接口名称 - private $baseUrl = 'http://tadmin.365jxj.com/api/'; - private $accessTokenHash = '5937719b95405'; - private $version = 'v2.0'; - private $appInfo = array(); - - /** - * ApiAdminSDK constructor. - * @param string $method 接口名称 - * @param string $appInfo 应用信息 - */ - public function __construct($method, $appInfo) { - $this->method = $method; - $this->appInfo = $appInfo; - } - - public function updateAccessToken() { - $cacheKey = $this->appInfo['appId'] . '_access_token'; - S($cacheKey, null); - } - - public function getHeader($userToken = '') { - $signObj = new AuthSign($this->version, $this->appInfo); - $accessToken = $this->getAccessToken(); - - return $signObj->getHeader($accessToken, $userToken); - } - - public function getAccessToken() { - $cacheKey = $this->appInfo['appId'] . '_access_token'; - $accessToken = S($cacheKey); - if (!$accessToken) { - $signObj = new AuthSign($this->version, $this->appInfo); - $data = $signObj->getAccessTokenData(); - $queryStr = http_build_query($data); - $url = $this->baseUrl . $this->accessTokenHash . '?' . $queryStr; - $header = $signObj->getHeader(); - $returnArr = Http::get($url, $header); - if($returnArr['code'] == 1){ - $accessToken = $returnArr['data']['access_token']; - S($cacheKey, $accessToken, 7000); - } - } - - return $accessToken; - } - - /** - * 处理URL,当需要GET请求,请传入GET参数数组 - * @param $data - * @author zhaoxiang - * @return string - */ - public function buildUrl($data = array()) { - if ($data) { - $queryStr = '?'; - $queryStr .= http_build_query($data); - } else { - $queryStr = ''; - } - - return $this->baseUrl . $this->method . $queryStr; - } -} \ No newline at end of file diff --git a/Application/Home/ApiStore/ApiSDK/ApiAdmin/AuthSign.class.php b/Application/Home/ApiStore/ApiSDK/ApiAdmin/AuthSign.class.php deleted file mode 100644 index 4b911f8..0000000 --- a/Application/Home/ApiStore/ApiSDK/ApiAdmin/AuthSign.class.php +++ /dev/null @@ -1,62 +0,0 @@ - - */ -class AuthSign { - - private $version; - private $appInfo; - - public function __construct($version, $appInfo) { - $this->version = $version; - $this->appInfo = $appInfo; - } - - public function getHeader($accessToken = '', $userToken = false) { - $header['version'] = $this->version; - if ($accessToken) { - $header['access-token'] = $accessToken; - } - $city = cookie('365jxj_city'); - if ($city) { - $header['city'] = $city; - } else { - $header['city'] = 'nj'; - } - if ($userToken) { - $header['user-token'] = $userToken; - } - - return $header; - } - - public function getAccessTokenData() { - $data['app_id'] = $this->appInfo['appId']; - $data['app_secret'] = $this->appInfo['appSecret']; - $data['device_id'] = 'zuAdmin'; - $data['rand_str'] = md5(rand(1, 10000) . microtime()); - $data['timestamp'] = time(); - $sign = $this->getSignature($data); - $data['signature'] = $sign; - - return $data; - } - - /** - * 获取身份秘钥 - * @param array $data - * @author zhaoxiang - * @return string - */ - private function getSignature($data) { - ksort($data); - $preStr = http_build_query($data); - - return md5($preStr); - } - -} \ No newline at end of file diff --git a/Application/Home/ApiStore/ApiSDK/ApiAdmin/Http.class.php b/Application/Home/ApiStore/ApiSDK/ApiAdmin/Http.class.php deleted file mode 100644 index 6a1afb6..0000000 --- a/Application/Home/ApiStore/ApiSDK/ApiAdmin/Http.class.php +++ /dev/null @@ -1,77 +0,0 @@ - - */ - -namespace Home\ApiStore\ApiSDK\ApiAdmin; - - -use Home\ORG\ReturnCode; - -class Http { - - public static function get($url, $header = array()) { - $ch = curl_init(); - curl_setopt($ch, CURLOPT_URL, $url); - curl_setopt($ch, CURLOPT_FAILONERROR, false); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); - - if($header){ - $newHeader = array(); - foreach ($header as $key => $item) { - $newHeader[] = $key.':'.$item; - } - curl_setopt($ch, CURLOPT_HTTPHEADER, $newHeader); - } - - if (strlen($url) > 5 && strtolower(substr($url, 0, 5)) == "https") { - curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); - curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); - } - $response = curl_exec($ch); - - if (curl_errno($ch)) { - E(curl_error($ch), ReturnCode::CURL_ERROR); - } - curl_close($ch); - $resArr = json_decode($response, true); - - return $resArr; - } - - public static function post($url, $header = array(), $body = array()) { - $ch = curl_init(); - curl_setopt($ch, CURLOPT_URL, $url); - curl_setopt($ch, CURLOPT_FAILONERROR, false); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); - - if($header){ - $newHeader = array(); - foreach ($header as $key => $item) { - $newHeader[] = $key.':'.$item; - } - curl_setopt($ch, CURLOPT_HTTPHEADER, $newHeader); - } - - if (strlen($url) > 5 && strtolower(substr($url, 0, 5)) == "https") { - curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); - curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); - } - - curl_setopt($ch, CURLOPT_POST, true); - curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($body)); - - $response = curl_exec($ch); - - if (curl_errno($ch)) { - E(curl_error($ch), ReturnCode::CURL_ERROR); - } - curl_close($ch); - $resArr = json_decode($response, true); - - return $resArr; - } - -} \ No newline at end of file diff --git a/Application/Home/Common/index.html b/Application/Home/Common/index.html deleted file mode 100644 index 0519ecb..0000000 --- a/Application/Home/Common/index.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/Application/Home/Conf/config.php b/Application/Home/Conf/config.php deleted file mode 100644 index cb6d64a..0000000 --- a/Application/Home/Conf/config.php +++ /dev/null @@ -1,14 +0,0 @@ - 10, - - //AccessToken有效期(单位:秒) - 'ACCESS_TOKEN_EXPIRES' => 7200, - - //UserToken有效期(单位:秒) - 'USER_TOKEN_EXPIRES' => null, - -); \ No newline at end of file diff --git a/Application/Home/Conf/index.html b/Application/Home/Conf/index.html deleted file mode 100644 index 0519ecb..0000000 --- a/Application/Home/Conf/index.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/Application/Home/Controller/ApiController.class.php b/Application/Home/Controller/ApiController.class.php deleted file mode 100644 index ca16f85..0000000 --- a/Application/Home/Controller/ApiController.class.php +++ /dev/null @@ -1,181 +0,0 @@ - - */ - -namespace Home\Controller; - - -use Home\ORG\ApiLog; -use Home\ORG\Filter; -use Home\ORG\Response; -use Home\ORG\ReturnCode; - -class ApiController extends BaseController { - - private $apiDetail; //api配置(API路由,是否需要登录,是否需要AccessToken) - private $apiRequest; //请求参数规则 - private $apiResponse; //返回参数规则 - private $param; //根据API配置过滤后的传入参数 - private $header; //http request header信息 - - - public function index() { - $getArr = I('get.'); - $postArr = I('post.'); - - //获取ApiInfo根据 - $this->apiDetail = S('ApiInfo_' . $getArr['hash']); - if (!$this->apiDetail) { - $this->apiDetail = M('ApiList')->where(array('hash' => $getArr['hash'], 'status' => 1))->find(); - S('ApiInfo_' . $getArr['hash'], json_encode($this->apiDetail)); - } else { - $this->apiDetail = json_decode($this->apiDetail, true); - } - - if (empty($this->apiDetail)) { - Response::error(ReturnCode::NOT_EXISTS, '非法的API标识'); - } - ApiLog::setApiInfo($this->apiDetail); - - $this->apiRequest = S('ApiRequest_' . $getArr['hash']); - if (!$this->apiRequest) { - $this->apiRequest = M('ApiFields')->where(array('hash' => $getArr['hash'], 'type' => 0))->select(); - S('ApiRequest_' . $getArr['hash'], json_encode($this->apiRequest)); - } else { - $this->apiRequest = json_decode($this->apiRequest, true); - } - - $this->apiResponse = S('ApiResponse_' . $getArr['hash']); - if (!$this->apiResponse) { - $this->apiResponse = M('ApiFields')->where(array('hash' => $getArr['hash'], 'type' => 1))->select(); - S('ApiResponse_' . $getArr['hash'], json_encode($this->apiResponse)); - } else { - $this->apiResponse = json_decode($this->apiResponse, true); - } - - $returnType = S('ApiReturnType_' . $getArr['hash']); - if (!$returnType) { - $returnType = M('ApiFields')->where(array('hash' => $getArr['hash'], 'showName' => 'data', 'type' => 1))->getField('dataType'); - S('ApiReturnType_' . $getArr['hash'], $returnType); - } - Response::setDataType($returnType['dataType']); - - $this->header = apache_request_headers(); - $this->header = array_change_key_case($this->header, CASE_UPPER); - ApiLog::setHeader($this->header); - - switch ($this->apiDetail['method']) { - case 0: - $this->param = array_merge($getArr, $postArr); - break; - case 1: - $this->param = $postArr; - break; - case 2: - $this->param = $getArr; - break; - } - if ($this->header['AGENT'] == 'wx') { - $data = file_get_contents("php://input"); - $data = json_decode($data, true); - $this->param = $data; - } - ApiLog::setRequest($this->param); - - if ($this->apiDetail['accessToken'] && !$this->apiDetail['isTest']) { - $this->checkAccessToken(); - } - if (!$this->apiDetail['isTest']) { - $this->checkVersion(); - } - $this->checkLogin(); - unset($getArr['hash']); - $this->iniApi(); - } - - /** - * 系统初始化函数(登陆状态检测,权限检测,初始化菜单) - */ - private function iniApi() { - $filterObj = new Filter(); - if (!$this->apiDetail['isTest']) { - $this->checkRule(); - $filterObj->request($this->param, $this->apiRequest); - } - - ApiLog::setRequestAfterFilter($this->param); - list($className, $actionName) = explode('/', $this->apiDetail['apiName']); - - $moduleName = MODULE_NAME . '\\Api\\' . $className; - $reflection = new \ReflectionClass($moduleName); - if (!$reflection->hasMethod($actionName)) { - Response::error(ReturnCode::EXCEPTION, '服务器端配置异常'); - } - $method = $reflection->getMethod($actionName); - $handle = $reflection->newInstance(); - $data = $method->invokeArgs($handle, array($this->param)); - if (!$this->apiDetail['isTest']) { - $data = $filterObj->response($data, $this->apiResponse); - } - Response::success($data); - } - - /** - * Api接口合法性检测 - */ - private function checkAccessToken() { - $access_token = $this->header['ACCESS-TOKEN']; - if (!isset($access_token) || !$access_token) { - Response::error(ReturnCode::ACCESS_TOKEN_TIMEOUT, '缺少参数access-token'); - } else { - $appInfo = S($access_token); - if (!$appInfo) { - Response::error(ReturnCode::ACCESS_TOKEN_TIMEOUT, 'access-token已过期'); - } - ApiLog::setAppInfo($appInfo); - } - } - - /** - * Api版本参数校验 - */ - private function checkVersion() { - $version = $this->header['VERSION']; - if (!isset($version) || !$version) { - Response::error(ReturnCode::EMPTY_PARAMS, '缺少参数version'); - } else { - if ($version != C('APP_VERSION')) { - Response::error(ReturnCode::VERSION_INVALID, 'API版本不匹配'); - } - } - } - - /** - * 检测用户登录情况 检测通过请赋予USER_INFO值 - */ - private function checkLogin() { - if ($this->apiDetail['needLogin']) { - if (!isset($this->header['USER-TOKEN']) || !$this->header['USER-TOKEN']) { - Response::error(ReturnCode::AUTH_ERROR, '缺少user-token'); - } - } - if (isset($this->header['USER-TOKEN']) && $this->header['USER-TOKEN']) { - $userInfo = S($this->header['USER-TOKEN']); - if (!is_array($userInfo) || !isset($userInfo['passport_uid'])) { - Response::error(ReturnCode::AUTH_ERROR, 'user-token不匹配'); - } - ApiLog::setUserInfo($userInfo); - } - } - - /** - * 权限检测&权限验证(暂时预留) - */ - private function checkRule() { - - } - -} \ No newline at end of file diff --git a/Application/Home/Controller/BaseController.class.php b/Application/Home/Controller/BaseController.class.php deleted file mode 100644 index ef2f4fe..0000000 --- a/Application/Home/Controller/BaseController.class.php +++ /dev/null @@ -1,14 +0,0 @@ - - */ - -namespace Home\Controller; - - -use Think\Controller; - -class BaseController extends Controller { -} \ No newline at end of file diff --git a/Application/Home/Controller/IndexController.class.php b/Application/Home/Controller/IndexController.class.php deleted file mode 100644 index 36eb889..0000000 --- a/Application/Home/Controller/IndexController.class.php +++ /dev/null @@ -1,10 +0,0 @@ - - */ - -namespace Home\Controller; - - -use Home\ORG\DataType; -use Home\ORG\ReturnCode; -use Think\Controller; - -class WikiController extends Controller { - - public function _initialize() { - $uid = session('uid'); - if (!$uid) { - $key = session('wikiKey'); - if (!$key) { - $key = I('get.key'); - if(!$key){ - $this->error('缺少授权秘钥!', U('Index/index')); - } - } - $keyInfo = S($key); - if (!$keyInfo) { - $keyInfo = M('ApiDocument')->where(array('key' => $key, 'status' => 1))->find(); - if (!$keyInfo) { - $this->error('当前授权秘钥已失效!', U('Index/index')); - } else { - S($key, $keyInfo); - } - } - if (NOW_TIME > $keyInfo['endTime']) { - $this->error('当前授权秘钥已失效!', U('Index/index')); - } - session('wikiKey', $key); - M('ApiDocument')->where(array('key' => $key))->save(array( - 'lastTime' => NOW_TIME, - 'lastIp' => get_client_ip(), - 'times' => array('exp', 'times+1') - )); - } - } - - public function apiList() { - $listData = M('ApiList')->select(); - $this->assign('list', $listData); - $this->display(); - } - - public function apiField() { - $hash = I('get.hash'); - if (empty($hash)) { - $this->redirect('apiList'); - } else { - $request = M('ApiFields')->where(array('hash' => $hash, 'type' => 0))->select(); - $response = M('ApiFields')->where(array('hash' => $hash, 'type' => 1))->select(); - $apiInfo = M('ApiList')->where(array('hash' => $hash))->find(); - $this->assign('apiInfo', $apiInfo); - $dataType = array( - DataType::TYPE_INTEGER => 'Integer', - DataType::TYPE_STRING => 'String', - DataType::TYPE_BOOLEAN => 'Boolean', - DataType::TYPE_ENUM => 'Enum', - DataType::TYPE_FLOAT => 'Float', - DataType::TYPE_FILE => 'File', - DataType::TYPE_ARRAY => 'Array', - DataType::TYPE_OBJECT => 'Object', - DataType::TYPE_MOBILE => 'Mobile' - ); - $this->assign('dataType', $dataType); - $this->assign('request', $request); - $this->assign('response', $response); - $this->display(); - } - } - - public function errorCode() { - $codeArr = ReturnCode::getConstants(); - $errorInfo = array( - ReturnCode::SUCCESS => '请求成功', - ReturnCode::INVALID => '非法操作', - ReturnCode::DB_SAVE_ERROR => '数据存储失败', - ReturnCode::DB_READ_ERROR => '数据读取失败', - ReturnCode::CACHE_SAVE_ERROR => '缓存存储失败', - ReturnCode::CACHE_READ_ERROR => '缓存读取失败', - ReturnCode::FILE_SAVE_ERROR => '文件读取失败', - ReturnCode::LOGIN_ERROR => '登录失败', - ReturnCode::NOT_EXISTS => '不存在', - ReturnCode::JSON_PARSE_FAIL => 'JSON数据格式错误', - ReturnCode::TYPE_ERROR => '类型错误', - ReturnCode::NUMBER_MATCH_ERROR => '数字匹配失败', - ReturnCode::EMPTY_PARAMS => '丢失必要数据', - ReturnCode::DATA_EXISTS => '数据已经存在', - ReturnCode::AUTH_ERROR => '权限认证失败', - ReturnCode::OTHER_LOGIN => '别的终端登录', - ReturnCode::VERSION_INVALID => 'API版本非法', - ReturnCode::PARAM_INVALID => '数据类型非法', - ReturnCode::ACCESS_TOKEN_TIMEOUT => '身份令牌过期', - ReturnCode::SESSION_TIMEOUT => 'SESSION过期', - ReturnCode::UNKNOWN => '未知错误', - ReturnCode::EXCEPTION => '系统异常', - ReturnCode::CURL_ERROR => 'CURL操作异常' - ); - $this->assign('errorInfo', $errorInfo); - $this->assign('codeArr', $codeArr); - $this->display(); - } - - public function calculation() { - $this->display(); - } - -} \ No newline at end of file diff --git a/Application/Home/Controller/index.html b/Application/Home/Controller/index.html deleted file mode 100644 index 0519ecb..0000000 --- a/Application/Home/Controller/index.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/Application/Home/Model/BaseModel.class.php b/Application/Home/Model/BaseModel.class.php deleted file mode 100644 index 50c23ef..0000000 --- a/Application/Home/Model/BaseModel.class.php +++ /dev/null @@ -1,15 +0,0 @@ - - */ - -namespace Home\Model; - - -use Think\Model; - -class BaseModel extends Model { - -} \ No newline at end of file diff --git a/Application/Home/Model/index.html b/Application/Home/Model/index.html deleted file mode 100644 index 0519ecb..0000000 --- a/Application/Home/Model/index.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/Application/Home/ORG/ApiLog.class.php b/Application/Home/ORG/ApiLog.class.php deleted file mode 100644 index b764242..0000000 --- a/Application/Home/ORG/ApiLog.class.php +++ /dev/null @@ -1,97 +0,0 @@ - - */ - -namespace Home\ORG; - - -class ApiLog { - - private static $appInfo = 'null'; - private static $apiInfo = 'null'; - private static $request = 'null'; - private static $requestAfterFilter = 'null'; - private static $response = 'null'; - private static $header = 'null'; - private static $userInfo = 'null'; - private static $separator = '###'; - - public static function setAppInfo($data) { - self::$appInfo = $data['app_id'] . self::$separator . $data['app_name'] . self::$separator . $data['device_id']; - } - - public static function setHeader($data) { - $userToken = (isset($data['USER-TOKEN']) && !empty($data['USER-TOKEN'])) ? $data['USER-TOKEN'] : 'null'; - $accessToken = (isset($data['ACCESS-TOKEN']) && !empty($data['ACCESS-TOKEN'])) ? $data['ACCESS-TOKEN'] : 'null'; - $cas = (isset($data['CAS']) && !empty($data['CAS'])) ? $data['CAS'] : 'null'; - self::$header = $accessToken . self::$separator . $userToken . self::$separator . $data['VERSION'] . self::$separator . $cas; - } - - public static function setApiInfo($data) { - self::$apiInfo = $data['apiName'] . self::$separator . $data['hash']; - } - - public static function setUserInfo($data) { - if (is_array($data)) { - $data = json_encode($data); - } - self::$userInfo = $data; - } - - public static function setRequest($data) { - if (is_array($data)) { - $data = json_encode($data); - } - self::$request = $data; - } - - public static function setRequestAfterFilter($data) { - if (is_array($data)) { - $data = json_encode($data); - } - self::$requestAfterFilter = $data; - } - - public static function setResponse($data, $code = '') { - if (is_array($data)) { - $data = json_encode($data); - } - self::$response = $code . self::$separator . $data; - } - - public static function save() { - $logPath = APP_PATH . '/ApiLog/' . date('YmdH') . '.log'; - if (self::$appInfo == 'null') { - self::$appInfo = 'null' . self::$separator . 'null' . self::$separator . 'null'; - } - $logStr = implode(self::$separator, array( - self::$apiInfo, - date('Y-m-d H:i:s'), - self::$request, - self::$header, - self::$response, - self::$requestAfterFilter, - self::$appInfo, - self::$userInfo - )); - - @file_put_contents($logPath, $logStr . "\n", FILE_APPEND); - } - - - /** - * @param string $log 被记录的内容 - * @param string $type 日志文件名称 - * @param string $filePath - */ - public static function writeLog($log, $type = 'sql', $filePath = './Application/Runtime/') { - $filename = $filePath . date("Ymd") . '_' . $type . ".log"; - @$handle = fopen($filename, "a+"); - @fwrite($handle, date('Y-m-d H:i:s') . "\t" . $log . "\r\n"); - @fclose($handle); - } - - -} \ No newline at end of file diff --git a/Application/Home/ORG/Crypt.class.php b/Application/Home/ORG/Crypt.class.php deleted file mode 100644 index adac284..0000000 --- a/Application/Home/ORG/Crypt.class.php +++ /dev/null @@ -1,41 +0,0 @@ - - */ - -namespace Home\ORG; - - -class Crypt { - - /** - * 根据AppSecret和数据生成相对应的身份认证秘钥 - * @param $appSecret - * @param $data - * @return string - */ - public function getAuthToken( $appSecret, $data ){ - if(empty($data)){ - return ''; - }else{ - $preArr = array_merge($data, array('app_secret' => $appSecret)); - ksort($preArr); - $preStr = http_build_query($preArr); - return md5($preStr); - } - } - - /** - * 计算出唯一的身份令牌 - * @param $appId - * @param $appSecret - * @return string - */ - public function getAccessToken( $appId, $appSecret ){ - $preStr = $appSecret.$appId.time().Str::keyGen(); - return md5($preStr); - } - -} \ No newline at end of file diff --git a/Application/Home/ORG/DataType.class.php b/Application/Home/ORG/DataType.class.php deleted file mode 100644 index 9678c5a..0000000 --- a/Application/Home/ORG/DataType.class.php +++ /dev/null @@ -1,29 +0,0 @@ - - */ - -namespace Home\ORG; - - -class DataType { - - const TYPE_INTEGER = 1; - const TYPE_STRING = 2; - const TYPE_ARRAY = 3; - const TYPE_FLOAT = 4; - const TYPE_BOOLEAN = 5; - const TYPE_FILE = 6; - const TYPE_ENUM = 7; - const TYPE_MOBILE = 8; - const TYPE_OBJECT = 9; - - //JPush推送消息类型 - const PUSH_SYSTEM_DATA = 1; - const PUSH_ACTIVITY_DATA = 2; - - -} \ No newline at end of file diff --git a/Application/Home/ORG/Date.class.php b/Application/Home/ORG/Date.class.php deleted file mode 100644 index 206674c..0000000 --- a/Application/Home/ORG/Date.class.php +++ /dev/null @@ -1,569 +0,0 @@ - -// +---------------------------------------------------------------------- - -namespace Home\ORG; -/** - * 日期时间操作类 - * @category ORG - * @package ORG - * @subpackage Date - * @author liu21st - * @version $Id: Date.class.php 2662 2012-01-26 06:32:50Z liu21st $ - */ -class Date { - - /** - * 日期的时间戳 - * @var integer - * @access protected - */ - protected $date; - - /** - * 时区 - * @var integer - * @access protected - */ - protected $timezone; - - /** - * 年 - * @var integer - * @access protected - */ - protected $year; - - /** - * 月 - * @var integer - * @access protected - */ - protected $month; - - /** - * 日 - * @var integer - * @access protected - */ - protected $day; - - /** - * 时 - * @var integer - * @access protected - */ - protected $hour; - - /** - * 分 - * @var integer - * @access protected - */ - protected $minute; - - /** - * 秒 - * @var integer - * @access protected - */ - protected $second; - - /** - * 星期的数字表示 - * @var integer - * @access protected - */ - protected $weekday; - - /** - * 星期的完整表示 - * @var string - * @access protected - */ - protected $cWeekday; - - /** - * 一年中的天数 0-365 - * @var integer - * @access protected - */ - protected $yDay; - - /** - * 月份的完整表示 - * @var string - * @access protected - */ - protected $cMonth; - - /** - * 日期CDATE表示 - * @var string - * @access protected - */ - protected $CDATE; - - /** - * 日期的YMD表示 - * @var string - * @access protected - */ - protected $YMD; - - /** - * 时间的输出表示 - * @var string - * @access protected - */ - protected $CTIME; - - // 星期的输出 - protected $Week = array("日","一","二","三","四","五","六"); - - /** - * 架构函数 - * 创建一个Date对象 - * @param mixed $date 日期 - * @static - * @access public - */ - public function __construct($date='') { - //分析日期 - $this->date = $this->parse($date); - $this->setDate($this->date); - } - - /** - * 日期分析 - * 返回时间戳 - * @static - * @access public - * @param mixed $date 日期 - * @return string - */ - public function parse($date) { - if (is_string($date)) { - if (($date == "") || strtotime($date) == -1) { - //为空默认取得当前时间戳 - $tmpDate = time(); - } else { - //把字符串转换成UNIX时间戳 - $tmpDate = strtotime($date); - } - } elseif (is_null($date)) { - //为空默认取得当前时间戳 - $tmpDate = time(); - - } elseif (is_numeric($date)) { - //数字格式直接转换为时间戳 - $tmpDate = $date; - - } else { - if (get_class($date) == "Date") { - //如果是Date对象 - $tmpDate = $date->date; - } else { - //默认取当前时间戳 - $tmpDate = time(); - } - } - return $tmpDate; - } - - /** - * 验证日期数据是否有效 - * @access public - * @param mixed $date 日期数据 - * @return string - */ - public function valid($date) { - - } - - /** - * 日期参数设置 - * @static - * @access public - * @param integer $date 日期时间戳 - * @return void - */ - public function setDate($date) { - $dateArray = getdate($date); - $this->date = $dateArray[0]; //时间戳 - $this->second = $dateArray["seconds"]; //秒 - $this->minute = $dateArray["minutes"]; //分 - $this->hour = $dateArray["hours"]; //时 - $this->day = $dateArray["mday"]; //日 - $this->month = $dateArray["mon"]; //月 - $this->year = $dateArray["year"]; //年 - - $this->weekday = $dateArray["wday"]; //星期 0~6 - $this->cWeekday = '星期'.$this->Week[$this->weekday];//$dateArray["weekday"]; //星期完整表示 - $this->yDay = $dateArray["yday"]; //一年中的天数 0-365 - $this->cMonth = $dateArray["month"]; //月份的完整表示 - - $this->CDATE = $this->format("%Y-%m-%d");//日期表示 - $this->YMD = $this->format("%Y%m%d"); //简单日期 - $this->CTIME = $this->format("%H:%M:%S");//时间表示 - - return ; - } - - /** - * 日期格式化 - * 默认返回 1970-01-01 11:30:45 格式 - * @access public - * @param string $format 格式化参数 - * @return string - */ - public function format($format = "%Y-%m-%d %H:%M:%S") { - return strftime($format, $this->date); - } - - /** - * 是否为闰年 - * @static - * @access public - * @return string - */ - public function isLeapYear($year='') { - if(empty($year)) { - $year = $this->year; - } - return ((($year % 4) == 0) && (($year % 100) != 0) || (($year % 400) == 0)); - } - - /** - * 计算日期差 - * - * w - weeks - * d - days - * h - hours - * m - minutes - * s - seconds - * @static - * @access public - * @param mixed $date 要比较的日期 - * @param string $elaps 比较跨度 - * @return integer - */ - public function dateDiff($date, $elaps = "d") { - $__DAYS_PER_WEEK__ = (7); - $__DAYS_PER_MONTH__ = (30); - $__DAYS_PER_YEAR__ = (365); - $__HOURS_IN_A_DAY__ = (24); - $__MINUTES_IN_A_DAY__ = (1440); - $__SECONDS_IN_A_DAY__ = (86400); - //计算天数差 - $__DAYSELAPS = ($this->parse($date) - $this->date) / $__SECONDS_IN_A_DAY__ ; - switch ($elaps) { - case "y"://转换成年 - $__DAYSELAPS = $__DAYSELAPS / $__DAYS_PER_YEAR__; - break; - case "M"://转换成月 - $__DAYSELAPS = $__DAYSELAPS / $__DAYS_PER_MONTH__; - break; - case "w"://转换成星期 - $__DAYSELAPS = $__DAYSELAPS / $__DAYS_PER_WEEK__; - break; - case "h"://转换成小时 - $__DAYSELAPS = $__DAYSELAPS * $__HOURS_IN_A_DAY__; - break; - case "m"://转换成分钟 - $__DAYSELAPS = $__DAYSELAPS * $__MINUTES_IN_A_DAY__; - break; - case "s"://转换成秒 - $__DAYSELAPS = $__DAYSELAPS * $__SECONDS_IN_A_DAY__; - break; - } - return $__DAYSELAPS; - } - - /** - * 人性化的计算日期差 - * @static - * @access public - * @param mixed $time 要比较的时间 - * @param mixed $precision 返回的精度 - * @return string - */ - public function timeDiff( $time ,$precision=false) { - if(!is_numeric($precision) && !is_bool($precision)) { - static $_diff = array('y'=>'年','M'=>'个月','d'=>'天','w'=>'周','s'=>'秒','h'=>'小时','m'=>'分钟'); - return ceil($this->dateDiff($time,$precision)).$_diff[$precision].'前'; - } - $diff = abs($this->parse($time) - $this->date); - static $chunks = array(array(31536000,'年'),array(2592000,'个月'),array(604800,'周'),array(86400,'天'),array(3600 ,'小时'),array(60,'分钟'),array(1,'秒')); - $count =0; - $since = ''; - for($i=0;$i=$chunks[$i][0]) { - $num = floor($diff/$chunks[$i][0]); - $since .= sprintf('%d'.$chunks[$i][1],$num); - $diff = (int)($diff-$chunks[$i][0]*$num); - $count++; - if(!$precision || $count>=$precision) { - break; - } - } - } - return $since.'前'; - } - - /** - * 返回周的某一天 返回Date对象 - * @access public - * @return Date - */ - public function getDayOfWeek($n){ - $week = array(0=>'sunday',1=>'monday',2=>'tuesday',3=>'wednesday',4=>'thursday',5=>'friday',6=>'saturday'); - return (new Date($week[$n])); - } - - /** - * 计算周的第一天 返回Date对象 - * @access public - * @return Date - */ - public function firstDayOfWeek() { - return $this->getDayOfWeek(1); - } - - /** - * 计算月份的第一天 返回Date对象 - * @access public - * @return Date - */ - public function firstDayOfMonth() { - return (new Date(mktime(0, 0, 0,$this->month,1,$this->year ))); - } - - /** - * 计算年份的第一天 返回Date对象 - * @access public - * @return Date - */ - public function firstDayOfYear() { - return (new Date(mktime(0, 0, 0, 1, 1, $this->year))); - } - - /** - * 计算周的最后一天 返回Date对象 - * @access public - * @return Date - */ - public function lastDayOfWeek() { - return $this->getDayOfWeek(0); - } - - /** - * 计算月份的最后一天 返回Date对象 - * @access public - * @return Date - */ - public function lastDayOfMonth() { - return (new Date(mktime(0, 0, 0, $this->month + 1, 0, $this->year ))); - } - - /** - * 计算年份的最后一天 返回Date对象 - * @access public - * @return Date - */ - public function lastDayOfYear() { - return (new Date(mktime(0, 0, 0, 1, 0, $this->year + 1))); - } - - /** - * 计算月份的最大天数 - * @access public - * @return integer - */ - public function maxDayOfMonth() { - $result = $this->dateDiff(strtotime($this->dateAdd(1,'m')),'d'); - return $result; - } - - /** - * 取得指定间隔日期 - * - * yyyy - 年 - * q - 季度 - * m - 月 - * y - day of year - * d - 日 - * w - 周 - * ww - week of year - * h - 小时 - * n - 分钟 - * s - 秒 - * @access public - * @param integer $number 间隔数目 - * @param string $interval 比较类型 - * @return Date - */ - public function dateAdd($number = 0, $interval = "d") { - $hours = $this->hour; - $minutes = $this->minute; - $seconds = $this->second; - $month = $this->month; - $day = $this->day; - $year = $this->year; - - switch ($interval) { - case "yyyy": - //---Add $number to year - $year += $number; - break; - - case "q": - //---Add $number to quarter - $month += ($number*3); - break; - - case "m": - //---Add $number to month - $month += $number; - break; - - case "y": - case "d": - case "w": - //---Add $number to day of year, day, day of week - $day += $number; - break; - - case "ww": - //---Add $number to week - $day += ($number*7); - break; - - case "h": - //---Add $number to hours - $hours += $number; - break; - - case "n": - //---Add $number to minutes - $minutes += $number; - break; - - case "s": - //---Add $number to seconds - $seconds += $number; - break; - } - - return (new Date(mktime($hours, - $minutes, - $seconds, - $month, - $day, - $year))); - - } - - /** - * 日期数字转中文 - * 用于日和月、周 - * @static - * @access public - * @param integer $number 日期数字 - * @return string - */ - public function numberToCh($number) { - $number = intval($number); - $array = array('一','二','三','四','五','六','七','八','九','十'); - $str = ''; - if($number ==0) { $str .= "十" ;} - if($number < 10){ - $str .= $array[$number-1] ; - } - elseif($number < 20 ){ - $str .= "十".$array[$number-11]; - } - elseif($number < 30 ){ - $str .= "二十".$array[$number-21]; - } - else{ - $str .= "三十".$array[$number-31]; - } - return $str; - } - - /** - * 年份数字转中文 - * @static - * @access public - * @param integer $yearStr 年份数字 - * @param boolean $flag 是否显示公元 - * @return string - */ - public function yearToCh( $yearStr ,$flag=false ) { - $array = array('零','一','二','三','四','五','六','七','八','九'); - $str = $flag? '公元' : ''; - for($i=0;$i<4;$i++){ - $str .= $array[substr($yearStr,$i,1)]; - } - return $str; - } - - /** - * 判断日期 所属 干支 生肖 星座 - * type 参数:XZ 星座 GZ 干支 SX 生肖 - * - * @static - * @access public - * @param string $type 获取信息类型 - * @return string - */ - public function magicInfo($type) { - $result = ''; - $m = $this->month; - $y = $this->year; - $d = $this->day; - - switch ($type) { - case 'XZ'://星座 - $XZDict = array('摩羯','宝瓶','双鱼','白羊','金牛','双子','巨蟹','狮子','处女','天秤','天蝎','射手'); - $Zone = array(1222,122,222,321,421,522,622,722,822,922,1022,1122,1222); - if((100*$m+$d)>=$Zone[0]||(100*$m+$d)<$Zone[1]) - $i=0; - else - for($i=1;$i<12;$i++){ - if((100*$m+$d)>=$Zone[$i]&&(100*$m+$d)<$Zone[$i+1]) - break; - } - $result = $XZDict[$i].'座'; - break; - - case 'GZ'://干支 - $GZDict = array( - array('甲','乙','丙','丁','戊','己','庚','辛','壬','癸'), - array('子','丑','寅','卯','辰','巳','午','未','申','酉','戌','亥') - ); - $i= $y -1900+36 ; - $result = $GZDict[0][$i%10].$GZDict[1][$i%12]; - break; - - case 'SX'://生肖 - $SXDict = array('鼠','牛','虎','兔','龙','蛇','马','羊','猴','鸡','狗','猪'); - $result = $SXDict[($y-4)%12]; - break; - - } - return $result; - } - - public function __toString() { - return $this->format(); - } -} \ No newline at end of file diff --git a/Application/Home/ORG/Filter.class.php b/Application/Home/ORG/Filter.class.php deleted file mode 100644 index 21f298f..0000000 --- a/Application/Home/ORG/Filter.class.php +++ /dev/null @@ -1,156 +0,0 @@ - - */ - -namespace Home\ORG; - - -use Home\ORG\Filter\ArrayFilter; -use Home\ORG\Filter\EnumFilter; -use Home\ORG\Filter\FloatFilter; -use Home\ORG\Filter\IntegerFilter; -use Home\ORG\Filter\OtherFilter; -use Home\ORG\Filter\StringFilter; - -class Filter { - - /** - * 返回参数过滤(主要是将返回参数的数据类型给规范) - * @param array $data - * @param array $rule - * @return array - */ - public function response($data, $rule = array()) { - $newRule = array(); - foreach ($rule as $item) { - $newRule[$item['showName']] = $item['dataType']; - } - if (is_array($data)) { - $this->handle($data, $newRule); - } elseif (empty($data)) { - if ($newRule['data'] == DataType::TYPE_OBJECT) { - $data = (object)array(); - } elseif ($newRule['data'] == DataType::TYPE_ARRAY) { - $data = array(); - } - } - - return $data; - } - - private function handle(&$data, $rule, $prefix = 'data') { - if (empty($data)) { - if ($rule[$prefix] == DataType::TYPE_OBJECT) { - $data = (object)array(); - } - } else { - if ($rule[$prefix] == DataType::TYPE_OBJECT) { - $prefix .= '{}'; - foreach ($data as $index => &$datum) { - $myPre = $prefix . $index; - switch ($rule[$myPre]) { - case DataType::TYPE_INTEGER: - $datum = intval($datum); - break; - case DataType::TYPE_FLOAT: - $datum = floatval($datum); - break; - case DataType::TYPE_STRING: - $datum = strval($datum); - break; - default: - $this->handle($datum, $rule, $myPre); - break; - } - } - } else { - $prefix .= '[]'; - if (is_array($data[0])) { - foreach ($data as &$datum) { - $this->handle($datum, $rule, $prefix); - } - } - } - } - } - - /** - * 请求参数过滤(主要是判断字段的合法性) - * @param $data - * @param array $rule - */ - public function request(&$data, $rule = array()) { - $newData = array(); - foreach ($rule as $value) { - if (!isset($data[$value['fieldName']])) { - if ($value['isMust']) { - Response::error(ReturnCode::EMPTY_PARAMS, '缺少必要参数:' . $value['fieldName']); - } else { - if ($value['default'] === '') { - continue; - } else { - $data[$value['fieldName']] = $value['default']; - } - } - } - if (isset($data[$value['fieldName']])) { - $newData[$value['fieldName']] = $data[$value['fieldName']]; - } - if ($value['range']) { - $value['range'] = htmlspecialchars_decode($value['range']); - } - switch ($value['dataType']) { - case DataType::TYPE_INTEGER: - $checkObj = new IntegerFilter(); - if ($value['isMust'] && $newData[$value['fieldName']] == '') { - Response::error(ReturnCode::EMPTY_PARAMS, '字段[' . $value['fieldName'] . ']不能为空'); - } - if ($newData[$value['fieldName']] != '') { - $checkObj->parse($newData[$value['fieldName']], json_decode($value['range'], true), $value['fieldName']); - } - break; - case DataType::TYPE_STRING: - $checkObj = new StringFilter(); - if ($value['isMust'] && $newData[$value['fieldName']] == '') { - Response::error(ReturnCode::EMPTY_PARAMS, '字段[' . $value['fieldName'] . ']不能为空'); - } - $newData[$value['fieldName']] = trim($newData[$value['fieldName']]); - if ($newData[$value['fieldName']] != '') { - $checkObj->parse($newData[$value['fieldName']], json_decode($value['range'], true), $value['fieldName']); - } - break; - case DataType::TYPE_ENUM: - $checkObj = new EnumFilter(); - if ($value['isMust'] && $newData[$value['fieldName']] == '') { - Response::error(ReturnCode::EMPTY_PARAMS, '字段[' . $value['fieldName'] . ']不能为空'); - } - if ($newData[$value['fieldName']] != '') { - $checkObj->parse($newData[$value['fieldName']], json_decode($value['range'], true), $value['fieldName']); - } - break; - case DataType::TYPE_FLOAT: - $checkObj = new FloatFilter(); - if ($value['isMust'] && empty($newData[$value['fieldName']]) && $newData[$value['fieldName']] != 0) { - Response::error(ReturnCode::EMPTY_PARAMS, '字段[' . $value['fieldName'] . ']不能为空'); - } - $newData[$value['fieldName']] = trim($newData[$value['fieldName']]); - $checkObj->parse($newData[$value['fieldName']], json_decode($value['range'], true), $value['fieldName']); - break; - case DataType::TYPE_ARRAY: - $checkObj = new ArrayFilter(); - $checkObj->parse($newData[$value['fieldName']], json_decode($value['range'], true), $value['fieldName']); - break; - case DataType::TYPE_MOBILE: - $checkObj = new OtherFilter(); - $newData[$value['fieldName']] = trim($newData[$value['fieldName']]); - $checkObj->isMobile($newData[$value['fieldName']], json_decode($value['range'], true), $value['fieldName']); - break; - } - } - $data = $newData; - } - -} \ No newline at end of file diff --git a/Application/Home/ORG/Filter/ArrayFilter.class.php b/Application/Home/ORG/Filter/ArrayFilter.class.php deleted file mode 100644 index 976aebe..0000000 --- a/Application/Home/ORG/Filter/ArrayFilter.class.php +++ /dev/null @@ -1,23 +0,0 @@ - - */ - -namespace Home\ORG\Filter; - -use Home\ORG\Response; -use Home\ORG\ReturnCode; -class ArrayFilter extends Base { - - public function parse(&$value, $rule, $fieldName) { - $this->fieldName = $fieldName; - if(!is_array($value)) { - Response::error(ReturnCode::TYPE_ERROR, "字段[{$fieldName}]字段类型不合法,期望数据类型为:Array"); - } elseif (!empty($rule)) { - $this->filterByRange(count($value), $rule); - } - } - -} \ No newline at end of file diff --git a/Application/Home/ORG/Filter/Base.class.php b/Application/Home/ORG/Filter/Base.class.php deleted file mode 100644 index 18092b6..0000000 --- a/Application/Home/ORG/Filter/Base.class.php +++ /dev/null @@ -1,42 +0,0 @@ - - */ - -namespace Home\ORG\Filter; - - -use Home\ORG\Response; -use Home\ORG\ReturnCode; - -class Base { - - protected $fieldName; - - protected function filterByRange($value, $rule) { - $this->checkSetting($rule); - $this->checkMin($value, $rule); - $this->checkMax($value, $rule); - } - - protected function checkSetting($rule) { - if (isset($rule['min']) && isset($rule['max']) && $rule['min'] > $rule['max']) { - Response::error(ReturnCode::NUMBER_MATCH_ERROR, "字段[{$this->fieldName}]的系统配置矛盾,请检测"); - } - } - - protected function checkMin($value, $rule) { - if (isset($rule['min']) && $value < $rule['min']) { - Response::error(ReturnCode::NUMBER_MATCH_ERROR, "字段[{$this->fieldName}]不合法,系统要求最小值为:". $rule['min']); - } - } - - protected function checkMax($value, $rule) { - if (isset($rule['max']) && $value > $rule['max']) { - Response::error(ReturnCode::NUMBER_MATCH_ERROR, "字段[{$this->fieldName}]不合法,系统要求最大值为:". $rule['max']); - } - } - -} \ No newline at end of file diff --git a/Application/Home/ORG/Filter/EnumFilter.class.php b/Application/Home/ORG/Filter/EnumFilter.class.php deleted file mode 100644 index 9ea525a..0000000 --- a/Application/Home/ORG/Filter/EnumFilter.class.php +++ /dev/null @@ -1,22 +0,0 @@ - - */ - -namespace Home\ORG\Filter; - -use Home\ORG\Response; -use Home\ORG\ReturnCode; - -class EnumFilter extends Base { - - public function parse(&$value, $rule, $fieldName){ - $this->fieldName = $fieldName; - if( !empty($rule) && !in_array($value, $rule) ){ - Response::error(ReturnCode::PARAM_INVALID, "字段[{$fieldName}]取值超出允许范围"); - } - } - -} \ No newline at end of file diff --git a/Application/Home/ORG/Filter/FloatFilter.class.php b/Application/Home/ORG/Filter/FloatFilter.class.php deleted file mode 100644 index b266bda..0000000 --- a/Application/Home/ORG/Filter/FloatFilter.class.php +++ /dev/null @@ -1,20 +0,0 @@ - - */ - -namespace Home\ORG\Filter; - - -class FloatFilter extends Base { - - public function parse(&$value, $rule, $fieldName){ - $this->fieldName = $fieldName; - $value = floatval($value); - if( !empty($rule) ){ - $this->filterByRange($value, $rule); - } - } -} \ No newline at end of file diff --git a/Application/Home/ORG/Filter/IntegerFilter.class.php b/Application/Home/ORG/Filter/IntegerFilter.class.php deleted file mode 100644 index 4bf2dc9..0000000 --- a/Application/Home/ORG/Filter/IntegerFilter.class.php +++ /dev/null @@ -1,20 +0,0 @@ - - */ - -namespace Home\ORG\Filter; - - -class IntegerFilter extends Base { - - public function parse(&$value, $rule, $fieldName){ - $this->fieldName = $fieldName; - $value = intval($value); - if( !empty($rule) ){ - $this->filterByRange($value, $rule); - } - } -} \ No newline at end of file diff --git a/Application/Home/ORG/Filter/OtherFilter.class.php b/Application/Home/ORG/Filter/OtherFilter.class.php deleted file mode 100644 index 918b70b..0000000 --- a/Application/Home/ORG/Filter/OtherFilter.class.php +++ /dev/null @@ -1,23 +0,0 @@ - - */ - -namespace Home\ORG\Filter; - - -use Home\ORG\Response; -use Home\ORG\ReturnCode; - -class OtherFilter extends Base { - - public function isMobile(&$value, $rule, $fieldName){ - $this->fieldName = $fieldName; - if( !preg_match('/^1[34578]\d{9}$/', $value) ){ - Response::error(ReturnCode::PARAM_INVALID, "请输入正确的11位手机号码"); - } - } - -} \ No newline at end of file diff --git a/Application/Home/ORG/Filter/StringFilter.class.php b/Application/Home/ORG/Filter/StringFilter.class.php deleted file mode 100644 index 653faa7..0000000 --- a/Application/Home/ORG/Filter/StringFilter.class.php +++ /dev/null @@ -1,24 +0,0 @@ - - */ - -namespace Home\ORG\Filter; - -use Home\ORG\Response; -use Home\ORG\ReturnCode; -class StringFilter extends Base { - - public function parse(&$value, $rule, $fieldName){ - $this->fieldName = $fieldName; - if (!is_string($value)) { - Response::error(ReturnCode::TYPE_ERROR, "字段[$fieldName]数据类型不合法,期望类型应该为:String"); - } else { - if( !empty($rule) ){ - $this->filterByRange(strlen($value), $rule); - } - } - } -} \ No newline at end of file diff --git a/Application/Home/ORG/Response.class.php b/Application/Home/ORG/Response.class.php deleted file mode 100644 index 35ebbc7..0000000 --- a/Application/Home/ORG/Response.class.php +++ /dev/null @@ -1,92 +0,0 @@ - - */ - -namespace Home\ORG; - - -class Response { - - static private $debugInfo = array(); - static private $dataType; - static private $successMsg = null; - - /** - * 设置Debug信息 - * @param $info - */ - static public function debug($info) { - if (APP_DEBUG) { - array_push(self::$debugInfo, $info); - } - } - - /** - * 设置data字段数据类型(规避空数组json_encode导致的数据类型混乱) - * @param string $msg - */ - static public function setSuccessMsg($msg) { - self::$successMsg = $msg; - } - - /** - * 设置data字段数据类型(规避空数组json_encode导致的数据类型混乱) - * @param int $type - */ - static public function setDataType($type = DataType::TYPE_OBJECT) { - self::$dataType = $type; - } - - /** - * 错误输出 - * @param integer $code 错误码,必填! - * @param string $msg 错误信息,选填,但是建议必须有! - * @param array $data - */ - static public function error($code, $msg = '', $data = array()) { - $returnData = array( - 'code' => $code, - 'msg' => $msg, - 'data' => $data - ); - if (!empty(self::$debugInfo)) { - $returnData['debug'] = self::$debugInfo; - } - header('Content-Type:application/json; charset=utf-8'); - if (self::$dataType == DataType::TYPE_OBJECT && empty($data)) { - $returnStr = json_encode($returnData, JSON_FORCE_OBJECT); - } else { - $returnStr = json_encode($returnData); - } - ApiLog::setResponse($returnStr); - ApiLog::save(); - exit($returnStr); - } - - /** - * 成功返回 - * @param $data - * @param null $code - */ - static public function success($data, $code = null) { - $code = is_null($code) ? ReturnCode::SUCCESS : $code; - $msg = is_null(self::$successMsg) ? '操作成功' : self::$successMsg; - $returnData = array( - 'code' => $code, - 'msg' => $msg, - 'data' => $data - ); - if (!empty(self::$debugInfo)) { - $returnData['debug'] = self::$debugInfo; - } - header('Content-Type:application/json; charset=utf-8'); - $returnStr = json_encode($returnData); - ApiLog::setResponse($returnStr); - ApiLog::save(); - exit($returnStr); - } - -} \ No newline at end of file diff --git a/Application/Home/ORG/ReturnCode.class.php b/Application/Home/ORG/ReturnCode.class.php deleted file mode 100644 index 238d38e..0000000 --- a/Application/Home/ORG/ReturnCode.class.php +++ /dev/null @@ -1,45 +0,0 @@ - - */ - -namespace Home\ORG; - - -class ReturnCode { - - const SUCCESS = 1; - const INVALID = -1; - const DB_SAVE_ERROR = -2; - const DB_READ_ERROR = -3; - const CACHE_SAVE_ERROR = -4; - const CACHE_READ_ERROR = -5; - const FILE_SAVE_ERROR = -6; - const LOGIN_ERROR = -7; - const NOT_EXISTS = -8; - const JSON_PARSE_FAIL = -9; - const TYPE_ERROR = -10; - const NUMBER_MATCH_ERROR = -11; - const EMPTY_PARAMS = -12; - const DATA_EXISTS = -13; - const AUTH_ERROR = -14; - - const OTHER_LOGIN = -16; - const VERSION_INVALID = -17; - - const CURL_ERROR = -18; - - const PARAM_INVALID = -995; - const ACCESS_TOKEN_TIMEOUT = -996; - const SESSION_TIMEOUT = -997; - const UNKNOWN = -998; - const EXCEPTION = -999; - - static public function getConstants() { - $oClass = new \ReflectionClass(__CLASS__); - return $oClass->getConstants(); - } - -} \ No newline at end of file diff --git a/Application/Home/ORG/Str.class.php b/Application/Home/ORG/Str.class.php deleted file mode 100644 index 3bd66ae..0000000 --- a/Application/Home/ORG/Str.class.php +++ /dev/null @@ -1,245 +0,0 @@ - -// +---------------------------------------------------------------------- -namespace Home\ORG; -class Str { - - /** - * 生成UUID 单机使用 - * @access public - * @return string - */ - static public function uuid() { - $charId = md5(uniqid(mt_rand(), true)); - $hyphen = chr(45); - $uuid = chr(123) - .substr($charId, 0, 8).$hyphen - .substr($charId, 8, 4).$hyphen - .substr($charId, 12, 4).$hyphen - .substr($charId, 16, 4).$hyphen - .substr($charId, 20, 12) - .chr(125); - return $uuid; - } - - /** - * 生成Guid主键 - * @return Boolean - */ - static public function keyGen() { - return str_replace('-','',substr(self::uuid(),1,-1)); - } - - /** - * 检查字符串是否是UTF8编码 - * @param string $string 字符串 - * @return Boolean - */ - static public function isUtf8($string) { - $len=strlen($string); - for($i=0; $i<$len; $i++){ - $c=ord($string[$i]); - if($c > 128){ - if(($c >= 254)) return false; - elseif($c >= 252) $bits=6; - elseif($c >= 248) $bits=5; - elseif($c >= 240) $bits=4; - elseif($c >= 224) $bits=3; - elseif($c >= 192) $bits=2; - else return false; - if(($i+$bits) > $len) return false; - while($bits > 1){ - $i++; - $b=ord($string[$i]); - if($b < 128 || $b > 191) return false; - $bits--; - } - } - } - return true; - } - - /** - * 字符串截取,支持中文和其他编码 - * @access public - * @param string $str 需要转换的字符串 - * @param integer $start 开始位置 - * @param string $length 截取长度 - * @param string $charset 编码格式 - * @param bool $suffix 截断显示字符 - * @return string - */ - static public function mSubStr($str, $start=0, $length, $charset="utf-8", $suffix=true) { - if(function_exists("mb_substr")) - $slice = mb_substr($str, $start, $length, $charset); - elseif(function_exists('iconv_substr')) { - $slice = iconv_substr($str,$start,$length,$charset); - }else{ - $re['utf-8'] = "/[\x01-\x7f]|[\xc2-\xdf][\x80-\xbf]|[\xe0-\xef][\x80-\xbf]{2}|[\xf0-\xff][\x80-\xbf]{3}/"; - $re['gb2312'] = "/[\x01-\x7f]|[\xb0-\xf7][\xa0-\xfe]/"; - $re['gbk'] = "/[\x01-\x7f]|[\x81-\xfe][\x40-\xfe]/"; - $re['big5'] = "/[\x01-\x7f]|[\x81-\xfe]([\x40-\x7e]|\xa1-\xfe])/"; - preg_match_all($re[$charset], $str, $match); - $slice = join("",array_slice($match[0], $start, $length)); - } - return $suffix ? $slice.'...' : $slice; - } - - /** - * 产生随机字串,可用来自动生成密码 - * 默认长度6位 字母和数字混合 支持中文 - * @param integer $len 长度 - * @param string $type 字串类型 - * 0 字母 1 数字 其它 混合 - * @param string $addChars 额外字符 - * @return string - */ - static public function randString($len=6,$type='',$addChars='') { - $str =''; - switch($type) { - case 0: - $chars='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.$addChars; - break; - case 1: - $chars= str_repeat('0123456789',3); - break; - case 2: - $chars='ABCDEFGHIJKLMNOPQRSTUVWXYZ'.$addChars; - break; - case 3: - $chars='abcdefghijklmnopqrstuvwxyz'.$addChars; - break; - case 4: - $chars = "们以我到他会作时要动国产的一是工就年阶义发成部民可出能方进在了不和有大这主中人上为来分生对于学下级地个用同行面说种过命度革而多子后自社加小机也经力线本电高量长党得实家定深法表着水理化争现所二起政三好十战无农使性前等反体合斗路图把结第里正新开论之物从当两些还天资事队批点育重其思与间内去因件日利相由压员气业代全组数果期导平各基或月毛然如应形想制心样干都向变关问比展那它最及外没看治提五解系林者米群头意只明四道马认次文通但条较克又公孔领军流入接席位情运器并飞原油放立题质指建区验活众很教决特此常石强极土少已根共直团统式转别造切九你取西持总料连任志观调七么山程百报更见必真保热委手改管处己将修支识病象几先老光专什六型具示复安带每东增则完风回南广劳轮科北打积车计给节做务被整联步类集号列温装即毫知轴研单色坚据速防史拉世设达尔场织历花受求传口断况采精金界品判参层止边清至万确究书术状厂须离再目海交权且儿青才证低越际八试规斯近注办布门铁需走议县兵固除般引齿千胜细影济白格效置推空配刀叶率述今选养德话查差半敌始片施响收华觉备名红续均药标记难存测士身紧液派准斤角降维板许破述技消底床田势端感往神便贺村构照容非搞亚磨族火段算适讲按值美态黄易彪服早班麦削信排台声该击素张密害侯草何树肥继右属市严径螺检左页抗苏显苦英快称坏移约巴材省黑武培著河帝仅针怎植京助升王眼她抓含苗副杂普谈围食射源例致酸旧却充足短划剂宣环落首尺波承粉践府鱼随考刻靠够满夫失包住促枝局菌杆周护岩师举曲春元超负砂封换太模贫减阳扬江析亩木言球朝医校古呢稻宋听唯输滑站另卫字鼓刚写刘微略范供阿块某功套友限项余倒卷创律雨让骨远帮初皮播优占死毒圈伟季训控激找叫云互跟裂粮粒母练塞钢顶策双留误础吸阻故寸盾晚丝女散焊功株亲院冷彻弹错散商视艺灭版烈零室轻血倍缺厘泵察绝富城冲喷壤简否柱李望盘磁雄似困巩益洲脱投送奴侧润盖挥距触星松送获兴独官混纪依未突架宽冬章湿偏纹吃执阀矿寨责熟稳夺硬价努翻奇甲预职评读背协损棉侵灰虽矛厚罗泥辟告卵箱掌氧恩爱停曾溶营终纲孟钱待尽俄缩沙退陈讨奋械载胞幼哪剥迫旋征槽倒握担仍呀鲜吧卡粗介钻逐弱脚怕盐末阴丰雾冠丙街莱贝辐肠付吉渗瑞惊顿挤秒悬姆烂森糖圣凹陶词迟蚕亿矩康遵牧遭幅园腔订香肉弟屋敏恢忘编印蜂急拿扩伤飞露核缘游振操央伍域甚迅辉异序免纸夜乡久隶缸夹念兰映沟乙吗儒杀汽磷艰晶插埃燃欢铁补咱芽永瓦倾阵碳演威附牙芽永瓦斜灌欧献顺猪洋腐请透司危括脉宜笑若尾束壮暴企菜穗楚汉愈绿拖牛份染既秋遍锻玉夏疗尖殖井费州访吹荣铜沿替滚客召旱悟刺脑措贯藏敢令隙炉壳硫煤迎铸粘探临薄旬善福纵择礼愿伏残雷延烟句纯渐耕跑泽慢栽鲁赤繁境潮横掉锥希池败船假亮谓托伙哲怀割摆贡呈劲财仪沉炼麻罪祖息车穿货销齐鼠抽画饲龙库守筑房歌寒喜哥洗蚀废纳腹乎录镜妇恶脂庄擦险赞钟摇典柄辩竹谷卖乱虚桥奥伯赶垂途额壁网截野遗静谋弄挂课镇妄盛耐援扎虑键归符庆聚绕摩忙舞遇索顾胶羊湖钉仁音迹碎伸灯避泛亡答勇频皇柳哈揭甘诺概宪浓岛袭谁洪谢炮浇斑讯懂灵蛋闭孩释乳巨徒私银伊景坦累匀霉杜乐勒隔弯绩招绍胡呼痛峰零柴簧午跳居尚丁秦稍追梁折耗碱殊岗挖氏刃剧堆赫荷胸衡勤膜篇登驻案刊秧缓凸役剪川雪链渔啦脸户洛孢勃盟买杨宗焦赛旗滤硅炭股坐蒸凝竟陷枪黎救冒暗洞犯筒您宋弧爆谬涂味津臂障褐陆啊健尊豆拔莫抵桑坡缝警挑污冰柬嘴啥饭塑寄赵喊垫丹渡耳刨虎笔稀昆浪萨茶滴浅拥穴覆伦娘吨浸袖珠雌妈紫戏塔锤震岁貌洁剖牢锋疑霸闪埔猛诉刷狠忽灾闹乔唐漏闻沈熔氯荒茎男凡抢像浆旁玻亦忠唱蒙予纷捕锁尤乘乌智淡允叛畜俘摸锈扫毕璃宝芯爷鉴秘净蒋钙肩腾枯抛轨堂拌爸循诱祝励肯酒绳穷塘燥泡袋朗喂铝软渠颗惯贸粪综墙趋彼届墨碍启逆卸航衣孙龄岭骗休借".$addChars; - break; - default : - // 默认去掉了容易混淆的字符oOLl和数字01,要添加请使用addChars参数 - $chars='ABCDEFGHIJKMNPQRSTUVWXYZabcdefghijkmnpqrstuvwxyz23456789'.$addChars; - break; - } - if($len>10 ) {//位数过长重复字符串一定次数 - $chars= $type==1? str_repeat($chars,$len) : str_repeat($chars,5); - } - if($type!=4) { - $chars = str_shuffle($chars); - $str = substr($chars,0,$len); - }else{ - // 中文随机字 - for($i=0;$i<$len;$i++){ - $str.= self::msubstr($chars, floor(mt_rand(0,mb_strlen($chars,'utf-8')-1)),1,'utf-8',false); - } - } - return $str; - } - - /** - * 生成一定数量的随机数,并且不重复 - * @param integer $number 数量 - * @param integer $length 长度 - * @param integer $mode 字串类型 - * 0 字母 1 数字 其它 混合 - * @return string - */ - static public function buildCountRand ($number, $length=4, $mode=1) { - if($mode==1 && $length $val) { - $_key = self::autoCharset($key, $from, $to); - $string[$_key] = self::autoCharset($val, $from, $to); - if ($key != $_key) - unset($string[$key]); - } - return $string; - } - else { - return $string; - } - } -} \ No newline at end of file diff --git a/Application/Home/View/Wiki/apiField.html b/Application/Home/View/Wiki/apiField.html deleted file mode 100644 index 14f920d..0000000 --- a/Application/Home/View/Wiki/apiField.html +++ /dev/null @@ -1,153 +0,0 @@ - - - - - {$apiInfo['apiName']} - 在线接口文档 - - - - - - - -
    -
    -
    -

    接口唯一标识:{$apiInfo['hash']}({$apiInfo['apiName']})


    - - POST - GET - 不限 - - {:C('APP_VERSION')} -
    - 接口说明 -
    -

    {$apiInfo['info']}

    -
    -
    - -
    -

    公共请求参数

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    参数名字类型是否必须默认值其他说明
    versionString必填{:C('APP_VERSION')}API版本号【请在Header头里面传递】
    access-tokenString{$apiInfo['accessToken']==1?'必填':'勿填'}APP认证秘钥【请在Header头里面传递】
    user-tokenString{$apiInfo['needLogin']==1?'必填':'勿填'}用户认证秘钥【请在Header头里面传递】
    -

    请求参数

    - - - - - - - - - - - - - - - - -
    参数名字类型是否必须默认值其他说明
    {$vo['fieldName']}{$dataType[$vo['dataType']]}{$vo['isMust']==1?'必填':'可选'}{$vo['default']}{$vo['range']}{$vo['info']}
    -
    -
    -

    公共返回参数

    - - - - - - - - - - - - - - - - - - - - - -
    返回字段类型说明
    codeInteger返回码,详情请参阅错误码说明
    msgString错误描述,当请求成功时可能为空
    debugString调试字段,如果没有调试信息会没有此字段
    -

    返回参数

    - - - - - - - - - - - - - -
    返回字段类型说明
    {$vo['showName']}{$dataType[$vo['dataType']]}{$vo['info']}
    -
    -
    -
    
    -        
    -
    - 温馨提示: 此接口参数列表根据后台代码自动生成,如有疑问请咨询后端开发 -
    -

    © Powered By {:C('APP_NAME')} {:C('APP_VERSION')}

    -

    -
    - - - \ No newline at end of file diff --git a/Application/Home/View/Wiki/apiList.html b/Application/Home/View/Wiki/apiList.html deleted file mode 100644 index a5e285e..0000000 --- a/Application/Home/View/Wiki/apiList.html +++ /dev/null @@ -1,70 +0,0 @@ - - - - - {:MODULE_NAME} - 在线接口列表 - - - -
    -
    -
    -

    接口列表 {:C('APP_VERSION')}

    - - - - - - -
    - $http_type = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') || (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')) ? 'https://' : 'http://'; - API统一访问地址: {$http_type}{$_SERVER['HTTP_HOST']}/api/接口唯一标识 -
    -
    -
    -
    接口状态说明:
    -

    测试 系统将不过滤任何字段,也不进行AccessToken的认证,但在必要的情况下会进行UserToken的认证!

    -

    启用 系统将严格过滤请求字段,并且进行全部必要认证!

    -

    禁用 系统将拒绝所有请求,一般应用于危机处理!

    -
    -
    - - - - - - - - - - - - - - - - - - -
    #请求方法接口唯一标识接口状态真实类库接口说明
    {$i} - - POST - GET - 不限 - - {$vo['hash']} - - 禁用 - - - 测试 - - 启用 - - - {$vo['apiName']}{$vo['info']}
    -

    © Powered By {:C('APP_NAME')} {:C('APP_VERSION')}

    -

    -
    - - \ No newline at end of file diff --git a/Application/Home/View/Wiki/calculation.html b/Application/Home/View/Wiki/calculation.html deleted file mode 100644 index d4f1563..0000000 --- a/Application/Home/View/Wiki/calculation.html +++ /dev/null @@ -1,47 +0,0 @@ - - - - - {:MODULE_NAME} - 算法说明 - - - - - - -
    -
    -
    -

    算法说明 {:C('APP_VERSION')}

    - - - -
    - 特别说明: 此算法文档会根据业务发展需求发生变更,为了服务的稳定运行,请及时关注此文档! -
    -
    -
    简介
    -

    当前算法主要服务于获取身份令牌(AccessToken)所进行的身份认证秘钥的计算。在请求高级接口的时候,系统会验证应用的合法性,也就是验证AccessToken。所以AccessToken是请求API的必要参数。

    -

    在请求获取AccessToken的接口时候,服务器会对用户合法性进行核验,具体的接口请求字段,请参看具体的接口文档。

    -
    一、获取app_id和app_secret
    -

    目前获取应用ID和应用秘钥是人工手动发放,请联系后台开发。请注意:app_secret非常重要请妥善保管

    -
    二、准备加密对象,并且根据字段名降序排序
    -
    //排序好后应当是如下所示的数据
    -{
    -    "app_id":"服务器颁发的应用ID",
    -    "app_secret":"服务器颁发的应用秘钥",   //请注意,此字段只是在计算加密串的时候在被加入,API请求请勿传递此字段值
    -    "device_id":"设备唯一ID",
    -    "rand_str":"随机字符串",
    -    "timestamp":当前系统时间戳
    -}
    -
    三、生成原始串
    -

    将上面的数据构建成HTTP查询字符串,如下所示:

    -

    app_id=服务器颁发的应用ID&app_secret=服务器颁发的应用秘钥&device_id=设备唯一ID&rand_str=随机字符串&timestamp=当前系统时间戳

    -
    四、计算秘钥
    -

    将第三步生成的字符串进行哈希计算(md5)获得最终身份认证秘钥。

    -
    -

    © Powered By {:C('APP_NAME')} {:C('APP_VERSION')}

    -

    -
    - - \ No newline at end of file diff --git a/Application/Home/View/Wiki/errorCode.html b/Application/Home/View/Wiki/errorCode.html deleted file mode 100644 index 91fe3e9..0000000 --- a/Application/Home/View/Wiki/errorCode.html +++ /dev/null @@ -1,48 +0,0 @@ - - - - - {:MODULE_NAME} - 错误码说明 - - - - - - -
    -
    -
    -

    错误码说明 {:C('APP_VERSION')}

    - - - - - - - - - - - - - - - - - - - -
    #英文标识错误码中文说明
    - {$i} - - {$key} - - {$vo} - - {$errorInfo[$vo]} -
    -

    © Powered By {:C('APP_NAME')} {:C('APP_VERSION')}

    -

    -
    - - \ No newline at end of file diff --git a/Application/Home/View/index.html b/Application/Home/View/index.html deleted file mode 100644 index 0519ecb..0000000 --- a/Application/Home/View/index.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/Application/Home/index.html b/Application/Home/index.html deleted file mode 100644 index 0519ecb..0000000 --- a/Application/Home/index.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/Application/index.html b/Application/index.html deleted file mode 100644 index 0519ecb..0000000 --- a/Application/index.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/Public/css/dataTable.css b/Public/css/dataTable.css deleted file mode 100644 index 99edd16..0000000 --- a/Public/css/dataTable.css +++ /dev/null @@ -1,74 +0,0 @@ -.dataTables_length, .dataTables_filter, .dataTables_info, .dataTables_paginate { - margin-bottom: 10px; - display: inline-block; -} - -#list-admin_length{ - float: right; -} - -.dataTables_filter, .dataTables_paginate { - float: right; -} - -.dataTables_length select, .dataTables_filter input[type=search] { - width: 100px; - height: 30px; - border: 1px solid #ccc; - padding: 0 5px; - display: inline-block; -} - -.dataTables_paginate span, .dataTables_paginate a.paginate_button { - border-radius: 2px; - cursor: pointer; -} - -.dataTables_paginate a,.dataTables_paginate>span>span{ - box-sizing: border-box; - display: inline-block; - min-width: 2em; - height: 30px; - line-height: 28px; - border: 1px solid transparent; - padding: 0 0.5em; - margin-left: 2px; - text-align: center; - text-decoration: none; - cursor: pointer; -} - -.dataTables_paginate span a.current, .dataTables_paginate a.paginate_button:hover { - color: white; - background: #009688; -} - -.dataTables_length select { - width: 60px; - border-radius: 2px; -} - -table.dataTable tbody tr.even { - background: #f2f2f2; -} - -table.dataTable tbody tr.selected { - background: #eeeeee; -} - -table.dataTable thead .sorting_asc{ - background-image: url("../images/sort_asc.png"); -} - -table.dataTable thead .sorting_desc{ - background-image: url("../images/sort_desc.png"); -} - -table.dataTable thead .sorting{ - background-image: url("../images/sort_both.png"); -} - -table.dataTable thead .sorting,table.dataTable thead .sorting_desc,table.dataTable thead .sorting_asc{ - background-repeat: no-repeat; - background-position: center right; -} \ No newline at end of file diff --git a/Public/dataTable/jquery.dataTables.min.js b/Public/dataTable/jquery.dataTables.min.js deleted file mode 100644 index 435af7c..0000000 --- a/Public/dataTable/jquery.dataTables.min.js +++ /dev/null @@ -1,152 +0,0 @@ -/*! DataTables 1.10.0 - * ©2008-2014 SpryMedia Ltd - datatables.net/license - */ -(function(za,N,l){var M=function(g){function S(a){var b,c,d={};g.each(a,function(e){if((b=e.match(/^([^A-Z]+?)([A-Z])/))&&-1!=="a aa ai ao as b fn i m o s ".indexOf(b[1]+" "))c=e.replace(b[0],b[2].toLowerCase()),d[c]=e,"o"===b[1]&&S(a[e])});a._hungarianMap=d}function G(a,b,c){a._hungarianMap||S(a);var d;g.each(b,function(e){d=a._hungarianMap[e];if(d!==l&&(c||b[d]===l))"o"===d.charAt(0)?(b[d]||(b[d]={}),g.extend(!0,b[d],b[e]),G(a[d],b[d],c)):b[d]=b[e]})}function M(a){var b=p.defaults.oLanguage,c=a.sZeroRecords; -!a.sEmptyTable&&(c&&"No data available in table"===b.sEmptyTable)&&D(a,a,"sZeroRecords","sEmptyTable");!a.sLoadingRecords&&(c&&"Loading..."===b.sLoadingRecords)&&D(a,a,"sZeroRecords","sLoadingRecords");a.sInfoThousands&&(a.sThousands=a.sInfoThousands);(a=a.sDecimal)&&bb(a)}function cb(a){w(a,"ordering","bSort");w(a,"orderMulti","bSortMulti");w(a,"orderClasses","bSortClasses");w(a,"orderCellsTop","bSortCellsTop");w(a,"order","aaSorting");w(a,"orderFixed","aaSortingFixed");w(a,"paging","bPaginate"); -w(a,"pagingType","sPaginationType");w(a,"pageLength","iDisplayLength");w(a,"searching","bFilter")}function db(a){w(a,"orderable","bSortable");w(a,"orderData","aDataSort");w(a,"orderSequence","asSorting");w(a,"orderDataType","sortDataType")}function eb(a){var a=a.oBrowser,b=g("
    ").css({position:"absolute",top:0,left:0,height:1,width:1,overflow:"hidden"}).append(g("
    ").css({position:"absolute",top:1,left:1,width:100,overflow:"scroll"}).append(g('
    ').css({width:"100%",height:10}))).appendTo("body"), -c=b.find(".test");a.bScrollOversize=100===c[0].offsetWidth;a.bScrollbarLeft=1!==c.offset().left;b.remove()}function fb(a,b,c,d,e,f){var h,i=!1;c!==l&&(h=c,i=!0);for(;d!==e;)a.hasOwnProperty(d)&&(h=i?b(h,a[d],d,a):a[d],i=!0,d+=f);return h}function Aa(a,b){var c=p.defaults.column,d=a.aoColumns.length,c=g.extend({},p.models.oColumn,c,{nTh:b?b:N.createElement("th"),sTitle:c.sTitle?c.sTitle:b?b.innerHTML:"",aDataSort:c.aDataSort?c.aDataSort:[d],mData:c.mData?c.mData:d,idx:d});a.aoColumns.push(c);c=a.aoPreSearchCols; -c[d]=g.extend({},p.models.oSearch,c[d]);fa(a,d,null)}function fa(a,b,c){var d=a.aoColumns[b],b=a.oClasses,e=g(d.nTh);if(!d.sWidthOrig){d.sWidthOrig=e.attr("width")||null;var f=(e.attr("style")||"").match(/width:\s*(\d+[pxem%])/);f&&(d.sWidthOrig=f[1])}c!==l&&null!==c&&(db(c),G(p.defaults.column,c),c.mDataProp!==l&&!c.mData&&(c.mData=c.mDataProp),c.sType&&(d._sManualType=c.sType),c.className&&!c.sClass&&(c.sClass=c.className),g.extend(d,c),D(d,c,"sWidth","sWidthOrig"),"number"===typeof c.iDataSort&& -(d.aDataSort=[c.iDataSort]),D(d,c,"aDataSort"));var c=d.mData,h=T(c),i=d.mRender?T(d.mRender):null,f=function(a){return"string"===typeof a&&-1!==a.indexOf("@")};d._bAttrSrc=g.isPlainObject(c)&&(f(c.sort)||f(c.type)||f(c.filter));d.fnGetData=function(a,b){var c=h(a,b);return d.mRender&&b&&""!==b?i(c,b,a):c};d.fnSetData=Ba(c);a.oFeatures.bSort||(d.bSortable=!1,e.addClass(b.sSortableNone));a=-1!==g.inArray("asc",d.asSorting);e=-1!==g.inArray("desc",d.asSorting);!d.bSortable||!a&&!e?(d.sSortingClass= -b.sSortableNone,d.sSortingClassJUI=""):a&&!e?(d.sSortingClass=b.sSortableAsc,d.sSortingClassJUI=b.sSortJUIAscAllowed):!a&&e?(d.sSortingClass=b.sSortableDesc,d.sSortingClassJUI=b.sSortJUIDescAllowed):(d.sSortingClass=b.sSortable,d.sSortingClassJUI=b.sSortJUI)}function U(a){if(!1!==a.oFeatures.bAutoWidth){var b=a.aoColumns;Ca(a);for(var c=0,d=b.length;co[f])d(m.length+o[f],n);else if("string"===typeof o[f]){i=0;for(j=m.length;ib&&a[e]--; -1!=d&&c===l&&a.splice(d,1)}function la(a,b,c,d){var e=a.aoData[b],f;if("dom"===c||(!c||"auto"===c)&&"dom"===e.src)e._aData=ia(a,e).data;else{var h=e.anCells;if(h){c=0;for(f=h.length;c").appendTo(h));b=0;for(c=m.length;btr").attr("role","row");g(h).find(">tr>th, >tr>td").addClass(n.sHeaderTH);g(i).find(">tr>th, >tr>td").addClass(n.sFooterTH); -if(null!==i){a=a.aoFooter[0];b=0;for(c=a.length;b=a.fnRecordsDisplay()?0:h,a.iInitDisplayStart= --1);var h=a._iDisplayStart,n=a.fnDisplayEnd();if(a.bDeferLoading)a.bDeferLoading=!1,a.iDraw++,C(a,!1);else if(i){if(!a.bDestroying&&!ib(a))return}else a.iDraw++;if(0!==j.length){f=i?a.aoData.length:n;for(i=i?0:h;i",{"class":e?d[0]:""}).append(g("",{valign:"top",colSpan:Y(a),"class":a.oClasses.sRowEmpty}).html(c))[0];t(a,"aoHeaderCallback","header",[g(a.nTHead).children("tr")[0],Ha(a),h,n,j]);t(a,"aoFooterCallback","footer",[g(a.nTFoot).children("tr")[0],Ha(a),h,n,j]);d=g(a.nTBody);d.children().detach();d.append(g(b));t(a,"aoDrawCallback","draw",[a]);a.bSorted=!1;a.bFiltered=!1;a.bDrawing=!1}}function K(a,b){var c=a.oFeatures,d=c.bFilter; -c.bSort&&jb(a);d?aa(a,a.oPreviousSearch):a.aiDisplay=a.aiDisplayMaster.slice();!0!==b&&(a._iDisplayStart=0);J(a)}function kb(a){var b=a.oClasses,c=g(a.nTable),c=g("
    ").insertBefore(c),d=a.oFeatures,e=g("
    ",{id:a.sTableId+"_wrapper","class":b.sWrapper+(a.nTFoot?"":" "+b.sNoFooter)});a.nHolding=c[0];a.nTableWrapper=e[0];a.nTableReinsertBefore=a.nTable.nextSibling;for(var f=a.sDom.split(""),h,i,j,n,m,o,k=0;k")[0];n=f[k+1];if("'"==n||'"'==n){m= -"";for(o=2;f[k+o]!=n;)m+=f[k+o],o++;"H"==m?m=b.sJUIHeader:"F"==m&&(m=b.sJUIFooter);-1!=m.indexOf(".")?(n=m.split("."),j.id=n[0].substr(1,n[0].length-1),j.className=n[1]):"#"==m.charAt(0)?j.id=m.substr(1,m.length-1):j.className=m;k+=o}e.append(j);e=g(j)}else if(">"==i)e=e.parent();else if("l"==i&&d.bPaginate&&d.bLengthChange)h=lb(a);else if("f"==i&&d.bFilter)h=mb(a);else if("r"==i&&d.bProcessing)h=nb(a);else if("t"==i)h=ob(a);else if("i"==i&&d.bInfo)h=pb(a);else if("p"==i&&d.bPaginate)h=qb(a);else if(0!== -p.ext.feature.length){j=p.ext.feature;o=0;for(n=j.length;o',h=a.oLanguage.sSearch,h=h.match(/_INPUT_/)?h.replace("_INPUT_",f):h+f,b=g("
    ",{id:!e.f?c+"_filter":null,"class":b.sFilter}).append(g("
    ").addClass(b.sLength); -a.aanFeatures.l||(j[0].id=c+"_length");b=a.oLanguage.sLengthMenu.split(/(_MENU_)/);j.children().append(1").addClass(a.oClasses.sPaging+b)[0],f=a.aanFeatures;d||c.fnInit(a,b,e);f.p||(b.id= -a.sTableId+"_paginate",a.aoDrawCallback.push({fn:function(a){if(d){var b=a._iDisplayStart,j=a._iDisplayLength,g=a.fnRecordsDisplay(),m=-1===j,b=m?0:Math.ceil(b/j),j=m?1:Math.ceil(g/j),g=c(b,j),o,m=0;for(o=f.p.length;mf&&(d=0)):"first"==b?d=0:"previous"==b?(d=0<=e?d-e:0,0> -d&&(d=0)):"next"==b?d+e",{id:!a.aanFeatures.r?a.sTableId+"_processing":null,"class":a.oClasses.sProcessing}).html(a.oLanguage.sProcessing).insertBefore(a.nTable)[0]}function C(a,b){a.oFeatures.bProcessing&&g(a.aanFeatures.r).css("display",b?"block":"none");t(a,null,"processing",[a,b])}function ob(a){var b= -g(a.nTable);b.attr("role","grid");var c=a.oScroll;if(""===c.sX&&""===c.sY)return a.nTable;var d=c.sX,e=c.sY,f=a.oClasses,h=b.children("caption"),i=h.length?h[0]._captionSide:null,j=g(b[0].cloneNode(!1)),n=g(b[0].cloneNode(!1)),m=b.children("tfoot");c.sX&&"100%"===b.attr("width")&&b.removeAttr("width");m.length||(m=null);c=g("
    ",{"class":f.sScrollWrapper}).append(g("
    ",{"class":f.sScrollHead}).css({overflow:"hidden",position:"relative",border:0,width:d?!d?null:s(d):"100%"}).append(g("
    ", -{"class":f.sScrollHeadInner}).css({"box-sizing":"content-box",width:c.sXInner||"100%"}).append(j.removeAttr("id").css("margin-left",0).append(b.children("thead")))).append("top"===i?h:null)).append(g("
    ",{"class":f.sScrollBody}).css({overflow:"auto",height:!e?null:s(e),width:!d?null:s(d)}).append(b));m&&c.append(g("
    ",{"class":f.sScrollFoot}).css({overflow:"hidden",border:0,width:d?!d?null:s(d):"100%"}).append(g("
    ",{"class":f.sScrollFootInner}).append(n.removeAttr("id").css("margin-left", -0).append(b.children("tfoot")))).append("bottom"===i?h:null));var b=c.children(),o=b[0],f=b[1],k=m?b[2]:null;d&&g(f).scroll(function(){var a=this.scrollLeft;o.scrollLeft=a;m&&(k.scrollLeft=a)});a.nScrollHead=o;a.nScrollBody=f;a.nScrollFoot=k;a.aoDrawCallback.push({fn:V,sName:"scrolling"});return c[0]}function V(a){var b=a.oScroll,c=b.sX,d=b.sXInner,e=b.sY,f=b.iBarWidth,h=g(a.nScrollHead),i=h[0].style,j=h.children("div"),n=j[0].style,m=j.children("table"),j=a.nScrollBody,o=g(j),k=j.style,l=g(a.nScrollFoot).children("div"), -p=l.children("table"),r=g(a.nTHead),q=g(a.nTable),ba=q[0],L=ba.style,t=a.nTFoot?g(a.nTFoot):null,ca=a.oBrowser,v=ca.bScrollOversize,x,u,y,w,z,A=[],B=[],C=[],D,E=function(a){a=a.style;a.paddingTop="0";a.paddingBottom="0";a.borderTopWidth="0";a.borderBottomWidth="0";a.height=0};q.children("thead, tfoot").remove();z=r.clone().prependTo(q);x=r.find("tr");y=z.find("tr");z.find("th, td").removeAttr("tabindex");t&&(w=t.clone().prependTo(q),u=t.find("tr"),w=w.find("tr"));c||(k.width="100%",h[0].style.width= -"100%");g.each(ma(a,z),function(b,c){D=ga(a,b);c.style.width=a.aoColumns[D].sWidth});t&&F(function(a){a.style.width=""},w);b.bCollapse&&""!==e&&(k.height=o[0].offsetHeight+r[0].offsetHeight+"px");h=q.outerWidth();if(""===c){if(L.width="100%",v&&(q.find("tbody").height()>j.offsetHeight||"scroll"==o.css("overflow-y")))L.width=s(q.outerWidth()-f)}else""!==d?L.width=s(d):h==o.width()&&o.height()h-f&&(L.width=s(h))):L.width=s(h);h=q.outerWidth();F(E,y);F(function(a){C.push(a.innerHTML); -A.push(s(g(a).css("width")))},y);F(function(a,b){a.style.width=A[b]},x);g(y).height(0);t&&(F(E,w),F(function(a){B.push(s(g(a).css("width")))},w),F(function(a,b){a.style.width=B[b]},u),g(w).height(0));F(function(a,b){a.innerHTML='
    '+C[b]+"
    ";a.style.width=A[b]},y);t&&F(function(a,b){a.innerHTML="";a.style.width=B[b]},w);if(q.outerWidth()j.offsetHeight||"scroll"==o.css("overflow-y")?h+f:h;if(v&&(j.scrollHeight> -j.offsetHeight||"scroll"==o.css("overflow-y")))L.width=s(u-f);(""===c||""!==d)&&O(a,1,"Possible column misalignment",6)}else u="100%";k.width=s(u);i.width=s(u);t&&(a.nScrollFoot.style.width=s(u));!e&&v&&(k.height=s(ba.offsetHeight+f));e&&b.bCollapse&&(k.height=s(e),b=c&&ba.offsetWidth>j.offsetWidth?f:0,ba.offsetHeightj.clientHeight||"scroll"==o.css("overflow-y");ca="padding"+(ca.bScrollbarLeft? -"Left":"Right");n[ca]=m?f+"px":"0px";t&&(p[0].style.width=s(b),l[0].style.width=s(b),l[0].style[ca]=m?f+"px":"0px");o.scroll();if(a.bSorted||a.bFiltered)j.scrollTop=0}function F(a,b,c){for(var d=0,e=0,f=b.length,h,i;e"));i.find("tfoot th, tfoot td").css("width","");var p=i.find("tbody tr"),j=ma(a,i.find("thead")[0]);for(k=0;k").css("width",s(a)).appendTo(b||N.body),d=c[0].offsetWidth;c.remove(); -return d}function Bb(a,b){var c=a.oScroll;if(c.sX||c.sY)c=!c.sX?c.iBarWidth:0,b.style.width=s(g(b).outerWidth()-c)}function Ab(a,b){var c=Cb(a,b);if(0>c)return null;var d=a.aoData[c];return!d.nTr?g("").html(A(a,c,b,"display"))[0]:d.anCells[b]}function Cb(a,b){for(var c,d=-1,e=-1,f=0,h=a.aoData.length;fd&&(d=c.length,e=f);return e}function s(a){return null===a?"0px":"number"==typeof a?0>a?"0px":a+"px":a.match(/\d$/)?a+"px":a}function Db(){if(!p.__scrollbarWidth){var a= -g("

    ").css({width:"100%",height:200,padding:0})[0],b=g("

    ").css({position:"absolute",top:0,left:0,width:200,height:150,padding:0,overflow:"hidden",visibility:"hidden"}).append(a).appendTo("body"),c=a.offsetWidth;b.css("overflow","scroll");a=a.offsetWidth;c===a&&(a=b[0].clientWidth);b.remove();p.__scrollbarWidth=c-a}return p.__scrollbarWidth}function Q(a){var b,c,d=[],e=a.aoColumns,f,h,i,j;b=a.aaSortingFixed;c=g.isPlainObject(b);var n=[];f=function(a){a.length&&!g.isArray(a[0])?n.push(a):n.push.apply(n, -a)};g.isArray(b)&&f(b);c&&b.pre&&f(b.pre);f(a.aaSorting);c&&b.post&&f(b.post);for(a=0;ae?1:0,0!==c)return"asc"===g.dir?c:-c;c=d[a];e=d[b];return ce?1:0}):g.sort(function(a,b){var c,h,g,i,j=n.length,l=f[a]._aSortData,p=f[b]._aSortData;for(g=0;gh?1:0})}a.bSorted=!0}function Fb(a){for(var b,c, -d=a.aoColumns,e=Q(a),a=a.oLanguage.oAria,f=0,h=d.length;f/g,"");var g=c.nTh;g.removeAttribute("aria-sort");c.bSortable&&(0=f.length?0:b+1};c&&a.oFeatures.bSortMulti?(c=g.inArray(b,B(e,"0")),-1!==c?(b=h(e[c]),e[c][1]=f[b],e[c]._idx=b):(e.push([b,f[0],0]),e[e.length-1]._idx=0)):e.length&&e[0][0]==b?(b=h(e[0]),e.length=1,e[0][1]=f[b],e[0]._idx=b):(e.length=0,e.push([b,f[0]]),e[0]._idx=0);K(a);"function"==typeof d&&d(a)}function Ka(a,b,c,d){var e=a.aoColumns[c];Ta(b,{},function(b){!1!==e.bSortable&&(a.oFeatures.bProcessing?(C(a,!0),setTimeout(function(){Sa(a,c,b.shiftKey,d);"ssp"!==z(a)&&C(a,!1)},0)):Sa(a, -c,b.shiftKey,d))})}function sa(a){var b=a.aLastSort,c=a.oClasses.sSortColumn,d=Q(a),e=a.oFeatures,f,h;if(e.bSort&&e.bSortClasses){e=0;for(f=b.length;ee?e+1:3));e=0;for(f=d.length;ee?e+1:3))}a.aLastSort=d}function Eb(a,b){var c=a.aoColumns[b],d=p.ext.order[c.sSortDataType],e;d&&(e=d.call(a.oInstance,a,b,X(a,b)));for(var f,h=p.ext.type.order[c.sType+"-pre"],g=0,j=a.aoData.length;g< -j;g++)if(c=a.aoData[g],c._aSortData||(c._aSortData=[]),!c._aSortData[b]||d)f=d?e[g]:A(a,g,b,"sort"),c._aSortData[b]=h?h(f):f}function ta(a){if(a.oFeatures.bStateSave&&!a.bDestroying){var b={iCreate:+new Date,iStart:a._iDisplayStart,iLength:a._iDisplayLength,aaSorting:g.extend(!0,[],a.aaSorting),oSearch:g.extend(!0,{},a.oPreviousSearch),aoSearchCols:g.extend(!0,[],a.aoPreSearchCols),abVisCols:B(a.aoColumns,"bVisible")};t(a,"aoStateSaveParams","stateSaveParams",[a,b]);a.fnStateSaveCallback.call(a.oInstance, -a,b)}}function Gb(a){var b,c,d=a.aoColumns;if(a.oFeatures.bStateSave){var e=a.fnStateLoadCallback.call(a.oInstance,a);if(e&&(b=t(a,"aoStateLoadParams","stateLoadParams",[a,e]),-1===g.inArray(!1,b)&&(b=a.iStateDuration,!(0=d.length?[0,a[1]]:a});g.extend(a.oPreviousSearch, -e.oSearch);g.extend(!0,a.aoPreSearchCols,e.aoSearchCols);var f=e.abVisCols;b=0;for(c=f.length;bb)b=0;a._iDisplayStart=b}function La(a,b){var c=a.renderer,d=p.ext.renderer[b];return g.isPlainObject(c)&& -c[b]?d[c[b]]||d._:"string"===typeof c?d[c]||d._:d._}function z(a){return a.oFeatures.bServerSide?"ssp":a.ajax||a.sAjaxSource?"ajax":"dom"}function Ua(a,b){var c=[],c=Ib.numbers_length,d=Math.floor(c/2);b<=c?c=R(0,b):a<=d?(c=R(0,c-2),c.push("ellipsis"),c.push(b-1)):(a>=b-1-d?c=R(b-(c-2),b):(c=R(a-1,a+2),c.push("ellipsis"),c.push(b-1)),c.splice(0,0,"ellipsis"),c.splice(0,0,0));c.DT_el="span";return c}function bb(a){g.each({num:function(b){return va(b,a)},"num-fmt":function(b){return va(b,a,Va)},"html-num":function(b){return va(b, -a,wa)},"html-num-fmt":function(b){return va(b,a,wa,Va)}},function(b,c){u.type.order[b+a+"-pre"]=c})}function Jb(a){return function(){var b=[ua(this[p.ext.iApiIndex])].concat(Array.prototype.slice.call(arguments));return p.ext.internal[a].apply(this,b)}}var p,u,q,r,x,Wa={},Kb=/[\r\n]/g,wa=/<.*?>/g,Vb=/^[\d\+\-a-zA-Z]/,Sb=RegExp("(\\/|\\.|\\*|\\+|\\?|\\||\\(|\\)|\\[|\\]|\\{|\\}|\\\\|\\$|\\^|\\-)","g"),Va=/[',$\u00a3\u20ac\u00a5%\u2009\u202F]/g,da=function(a){return!a||"-"===a?!0:!1},Lb=function(a){var b= -parseInt(a,10);return!isNaN(b)&&isFinite(a)?b:null},Mb=function(a,b){Wa[b]||(Wa[b]=RegExp(Oa(b),"g"));return"string"===typeof a?a.replace(/\./g,"").replace(Wa[b],"."):a},Xa=function(a,b,c){var d="string"===typeof a;b&&d&&(a=Mb(a,b));c&&d&&(a=a.replace(Va,""));return!a||"-"===a||!isNaN(parseFloat(a))&&isFinite(a)},Nb=function(a,b,c){return da(a)?!0:a&&"string"!==typeof a?null:Xa(a.replace(wa,""),b,c)?!0:null},B=function(a,b,c){var d=[],e=0,f=a.length;if(c!==l)for(;e")[0],Tb=qa.textContent!== -l,Ub=/<.*?>/g;p=function(a){this.$=function(a,b){return this.api(!0).$(a,b)};this._=function(a,b){return this.api(!0).rows(a,b).data()};this.api=function(a){return a?new q(ua(this[u.iApiIndex])):new q(this)};this.fnAddData=function(a,b){var c=this.api(!0),d=g.isArray(a)&&(g.isArray(a[0])||g.isPlainObject(a[0]))?c.rows.add(a):c.row.add(a);(b===l||b)&&c.draw();return d.flatten().toArray()};this.fnAdjustColumnSizing=function(a){var b=this.api(!0).columns.adjust(),c=b.settings()[0],d=c.oScroll;a===l|| -a?b.draw(!1):(""!==d.sX||""!==d.sY)&&V(c)};this.fnClearTable=function(a){var b=this.api(!0).clear();(a===l||a)&&b.draw()};this.fnClose=function(a){this.api(!0).row(a).child.hide()};this.fnDeleteRow=function(a,b,c){var d=this.api(!0),a=d.rows(a),e=a.settings()[0],g=e.aoData[a[0][0]];a.remove();b&&b.call(this,e,g);(c===l||c)&&d.draw();return g};this.fnDestroy=function(a){this.api(!0).destroy(a)};this.fnDraw=function(a){this.api(!0).draw(!a)};this.fnFilter=function(a,b,c,d,e,g){e=this.api(!0);null=== -b||b===l?e.search(a,c,d,g):e.column(b).search(a,c,d,g);e.draw()};this.fnGetData=function(a,b){var c=this.api(!0);if(a!==l){var d=a.nodeName?a.nodeName.toLowerCase():"";return b!==l||"td"==d||"th"==d?c.cell(a,b).data():c.row(a).data()||null}return c.data().toArray()};this.fnGetNodes=function(a){var b=this.api(!0);return a!==l?b.row(a).node():b.rows().nodes().flatten().toArray()};this.fnGetPosition=function(a){var b=this.api(!0),c=a.nodeName.toUpperCase();return"TR"==c?b.row(a).index():"TD"==c||"TH"== -c?(a=b.cell(a).index(),[a.row,a.columnVisible,a.column]):null};this.fnIsOpen=function(a){return this.api(!0).row(a).child.isShown()};this.fnOpen=function(a,b,c){return this.api(!0).row(a).child(b,c).show().child()[0]};this.fnPageChange=function(a,b){var c=this.api(!0).page(a);(b===l||b)&&c.draw(!1)};this.fnSetColumnVis=function(a,b,c){a=this.api(!0).column(a).visible(b);(c===l||c)&&a.columns.adjust().draw()};this.fnSettings=function(){return ua(this[u.iApiIndex])};this.fnSort=function(a){this.api(!0).order(a).draw()}; -this.fnSortListener=function(a,b,c){this.api(!0).order.listener(a,b,c)};this.fnUpdate=function(a,b,c,d,e){var g=this.api(!0);c===l||null===c?g.row(b).data(a):g.cell(b,c).data(a);(e===l||e)&&g.columns.adjust();(d===l||d)&&g.draw();return 0};this.fnVersionCheck=u.fnVersionCheck;var b=this,c=a===l,d=this.length;c&&(a={});this.oApi=this.internal=u.internal;for(var e in p.ext.internal)e&&(this[e]=Jb(e));this.each(function(){var e={},h=1t<"F"ip>'),k.renderer)?g.isPlainObject(k.renderer)&&!k.renderer.header&&(k.renderer.header="jqueryui"):k.renderer="jqueryui":g.extend(n,p.ext.classes,h.oClasses);g(this).addClass(n.sTable);if(""!==k.oScroll.sX||""!==k.oScroll.sY)k.oScroll.iBarWidth=Db();!0===k.oScroll.sX&&(k.oScroll.sX= -"100%");k.iInitDisplayStart===l&&(k.iInitDisplayStart=h.iDisplayStart,k._iDisplayStart=h.iDisplayStart);null!==h.iDeferLoading&&(k.bDeferLoading=!0,i=g.isArray(h.iDeferLoading),k._iRecordsDisplay=i?h.iDeferLoading[0]:h.iDeferLoading,k._iRecordsTotal=i?h.iDeferLoading[1]:h.iDeferLoading);""!==h.oLanguage.sUrl?(k.oLanguage.sUrl=h.oLanguage.sUrl,g.getJSON(k.oLanguage.sUrl,null,function(a){M(a);G(m.oLanguage,a);g.extend(true,k.oLanguage,h.oLanguage,a);ra(k)}),e=!0):g.extend(!0,k.oLanguage,h.oLanguage); -null===h.asStripeClasses&&(k.asStripeClasses=[n.sStripeOdd,n.sStripeEven]);var i=k.asStripeClasses,r=g("tbody tr:eq(0)",this);-1!==g.inArray(!0,g.map(i,function(a){return r.hasClass(a)}))&&(g("tbody tr",this).removeClass(i.join(" ")),k.asDestroyStripes=i.slice());var o=[],q,i=this.getElementsByTagName("thead");0!==i.length&&($(k.aoHeader,i[0]),o=ma(k));if(null===h.aoColumns){q=[];i=0;for(j=o.length;i").appendTo(this));k.nTHead= -j[0];j=g(this).children("tbody");0===j.length&&(j=g("").appendTo(this));k.nTBody=j[0];j=g(this).children("tfoot");if(0===j.length&&0").appendTo(this);0===j.length||0===j.children().length?g(this).addClass(n.sNoFooter):0a?new q(b[a],this[a]):null},filter:function(a){var b=[];if(v.filter)b=v.filter.call(this,a,this);else for(var c=0,d=this.length;c");g("td",c).addClass(b).html(a)[0].colSpan=Y(d);e.push(c[0])}};if(g.isArray(a)||a instanceof g)for(var h=0,i=a.length;h=0?c:f.length+c];var e=typeof a==="string"?a.match(Xb):"";if(e)switch(e[2]){case "visIdx":case "visible":a=parseInt(e[1],10); -if(a<0){c=g.map(f,function(a,b){return a.bVisible?b:null});return[c[c.length+a]]}return[ga(b,a)];case "name":return g.map(h,function(a,b){return a===e[1]?b:null})}else return g(i).filter(a).map(function(){return g.inArray(this,i)}).toArray()})});c.selector.cols=a;c.selector.opts=b;return c});x("columns().header()","column().header()",function(){return this.iterator("column",function(a,b){return a.aoColumns[b].nTh})});x("columns().footer()","column().footer()",function(){return this.iterator("column", -function(a,b){return a.aoColumns[b].nTf})});x("columns().data()","column().data()",function(){return this.iterator("column-rows",function(a,b,c,d,e){for(var c=[],d=0,f=e.length;dd;return!0};p.isDataTable=p.fnIsDataTable=function(a){var b=g(a).get(0),c=!1;g.each(p.settings,function(a,e){if(e.nTable===b||e.nScrollHead===b||e.nScrollFoot===b)c=!0});return c};p.tables=p.fnTables=function(a){return jQuery.map(p.settings,function(b){if(!a||a&&g(b.nTable).is(":visible"))return b.nTable})};p.camelToHungarian=G;r("$()",function(a,b){var c=this.rows(b).nodes(), -c=g(c);return g([].concat(c.filter(a).toArray(),c.find(a).toArray()))});g.each(["on","one","off"],function(a,b){r(b+"()",function(){var a=Array.prototype.slice.call(arguments);-1===a[0].indexOf(".dt")&&(a[0]+=".dt");var d=g(this.tables().nodes());d[b].apply(d,a);return this})});r("clear()",function(){return this.iterator("table",function(a){ja(a)})});r("settings()",function(){return new q(this.context,this.context)});r("data()",function(){return this.iterator("table",function(a){return B(a.aoData, -"_aData")}).flatten()});r("destroy()",function(a){a=a||!1;return this.iterator("table",function(b){var c=b.nTableWrapper.parentNode,d=b.oClasses,e=b.nTable,f=b.nTBody,h=b.nTHead,i=b.nTFoot,j=g(e),f=g(f),n=g(b.nTableWrapper),m=g.map(b.aoData,function(a){return a.nTr}),l;b.bDestroying=!0;t(b,"aoDestroyCallback","destroy",[b]);a||(new q(b)).columns().visible(!0);n.unbind(".DT").find(":not(tbody *)").unbind(".DT");g(za).unbind(".DT-"+b.sInstance);e!=h.parentNode&&(j.children("thead").detach(),j.append(h)); -i&&e!=i.parentNode&&(j.children("tfoot").detach(),j.append(i));j.detach();n.detach();b.aaSorting=[];b.aaSortingFixed=[];sa(b);g(m).removeClass(b.asStripeClasses.join(" "));g("th, td",h).removeClass(d.sSortable+" "+d.sSortableAsc+" "+d.sSortableDesc+" "+d.sSortableNone);b.bJUI&&(g("th span."+d.sSortIcon+", td span."+d.sSortIcon,h).detach(),g("th, td",h).each(function(){var a=g("div."+d.sSortJUIWrapper,this);g(this).append(a.contents());a.detach()}));!a&&c&&c.insertBefore(e,b.nTableReinsertBefore); -f.children().detach();f.append(m);j.css("width",b.sDestroyWidth).removeClass(d.sTable);(l=b.asDestroyStripes.length)&&f.children().each(function(a){g(this).addClass(b.asDestroyStripes[a%l])});c=g.inArray(b,p.settings);-1!==c&&p.settings.splice(c,1)})});p.version="1.10.0";p.settings=[];p.models={};p.models.oSearch={bCaseInsensitive:!0,sSearch:"",bRegex:!1,bSmart:!0};p.models.oRow={nTr:null,anCells:null,_aData:[],_aSortData:null,_aFilterData:null,_sFilterRow:null,_sRowStripe:"",src:null};p.models.oColumn= -{idx:null,aDataSort:null,asSorting:null,bSearchable:null,bSortable:null,bVisible:null,_sManualType:null,_bAttrSrc:!1,fnCreatedCell:null,fnGetData:null,fnSetData:null,mData:null,mRender:null,nTh:null,nTf:null,sClass:null,sContentPadding:null,sDefaultContent:null,sName:null,sSortDataType:"std",sSortingClass:null,sSortingClassJUI:null,sTitle:null,sType:null,sWidth:null,sWidthOrig:null};p.defaults={aaData:null,aaSorting:[[0,"asc"]],aaSortingFixed:[],ajax:null,aLengthMenu:[10,25,50,100],aoColumns:null, -aoColumnDefs:null,aoSearchCols:[],asStripeClasses:null,bAutoWidth:!0,bDeferRender:!1,bDestroy:!1,bFilter:!0,bInfo:!0,bJQueryUI:!1,bLengthChange:!0,bPaginate:!0,bProcessing:!1,bRetrieve:!1,bScrollCollapse:!1,bServerSide:!1,bSort:!0,bSortMulti:!0,bSortCellsTop:!1,bSortClasses:!0,bStateSave:!1,fnCreatedRow:null,fnDrawCallback:null,fnFooterCallback:null,fnFormatNumber:function(a){return a.toString().replace(/\B(?=(\d{3})+(?!\d))/g,this.oLanguage.sThousands)},fnHeaderCallback:null,fnInfoCallback:null, -fnInitComplete:null,fnPreDrawCallback:null,fnRowCallback:null,fnServerData:null,fnServerParams:null,fnStateLoadCallback:function(a){try{return JSON.parse((-1===a.iStateDuration?sessionStorage:localStorage).getItem("DataTables_"+a.sInstance+"_"+location.pathname))}catch(b){}},fnStateLoadParams:null,fnStateLoaded:null,fnStateSaveCallback:function(a,b){try{(-1===a.iStateDuration?sessionStorage:localStorage).setItem("DataTables_"+a.sInstance+"_"+location.pathname,JSON.stringify(b))}catch(c){}},fnStateSaveParams:null, -iStateDuration:7200,iDeferLoading:null,iDisplayLength:10,iDisplayStart:0,iTabIndex:0,oClasses:{},oLanguage:{oAria:{sSortAscending:": 升序排列",sSortDescending:":降序排列"},oPaginate:{sFirst:"第一页",sLast:"最后一页",sNext:"下一页",sPrevious:"上一页"},sEmptyTable:"没有数据",sInfo:"显示 _START_ 到 _END_ ,共 _TOTAL_ 条",sInfoEmpty:"没有数据",sInfoFiltered:"(从 _MAX_ 条中过滤)",sInfoPostFix:"",sDecimal:"", -sThousands:",",sLengthMenu:"显示 _MENU_ 条",sLoadingRecords:"加载中...",sProcessing:"处理中...",sSearch:"从当前数据中检索:",sUrl:"",sZeroRecords:"没有找到匹配的记录"},oSearch:g.extend({},p.models.oSearch),sAjaxDataProp:"data",sAjaxSource:null,sDom:"lfrtip",sPaginationType:"simple_numbers",sScrollX:"",sScrollXInner:"",sScrollY:"",sServerMethod:"GET",renderer:null};S(p.defaults);p.defaults.column={aDataSort:null,iDataSort:-1,asSorting:["asc","desc"],bSearchable:!0,bSortable:!0,bVisible:!0,fnCreatedCell:null, -mData:null,mRender:null,sCellType:"td",sClass:"",sContentPadding:"",sDefaultContent:null,sName:"",sSortDataType:"std",sTitle:null,sType:null,sWidth:null};S(p.defaults.column);p.models.oSettings={oFeatures:{bAutoWidth:null,bDeferRender:null,bFilter:null,bInfo:null,bLengthChange:null,bPaginate:null,bProcessing:null,bServerSide:null,bSort:null,bSortMulti:null,bSortClasses:null,bStateSave:null},oScroll:{bCollapse:null,iBarWidth:0,sX:null,sXInner:null,sY:null},oLanguage:{fnInfoCallback:null},oBrowser:{bScrollOversize:!1, -bScrollbarLeft:!1},ajax:null,aanFeatures:[],aoData:[],aiDisplay:[],aiDisplayMaster:[],aoColumns:[],aoHeader:[],aoFooter:[],oPreviousSearch:{},aoPreSearchCols:[],aaSorting:null,aaSortingFixed:[],asStripeClasses:null,asDestroyStripes:[],sDestroyWidth:0,aoRowCallback:[],aoHeaderCallback:[],aoFooterCallback:[],aoDrawCallback:[],aoRowCreatedCallback:[],aoPreDrawCallback:[],aoInitComplete:[],aoStateSaveParams:[],aoStateLoadParams:[],aoStateLoaded:[],sTableId:"",nTable:null,nTHead:null,nTFoot:null,nTBody:null, -nTableWrapper:null,bDeferLoading:!1,bInitialised:!1,aoOpenRows:[],sDom:null,sPaginationType:"two_button",iStateDuration:0,aoStateSave:[],aoStateLoad:[],oLoadedState:null,sAjaxSource:null,sAjaxDataProp:null,bAjaxDataGet:!0,jqXHR:null,json:l,oAjaxData:l,fnServerData:null,aoServerParams:[],sServerMethod:null,fnFormatNumber:null,aLengthMenu:null,iDraw:0,bDrawing:!1,iDrawError:-1,_iDisplayLength:10,_iDisplayStart:0,_iRecordsTotal:0,_iRecordsDisplay:0,bJUI:null,oClasses:{},bFiltered:!1,bSorted:!1,bSortCellsTop:null, -oInit:null,aoDestroyCallback:[],fnRecordsTotal:function(){return"ssp"==z(this)?1*this._iRecordsTotal:this.aiDisplayMaster.length},fnRecordsDisplay:function(){return"ssp"==z(this)?1*this._iRecordsDisplay:this.aiDisplay.length},fnDisplayEnd:function(){var a=this._iDisplayLength,b=this._iDisplayStart,c=b+a,d=this.aiDisplay.length,e=this.oFeatures,f=e.bPaginate;return e.bServerSide?!1===f||-1===a?b+d:Math.min(b+a,this._iRecordsDisplay):!f||c>d||-1===a?d:c},oInstance:null,sInstance:null,iTabIndex:0,nScrollHead:null, -nScrollFoot:null,aLastSort:[],oPlugins:{}};p.ext=u={classes:{},errMode:"alert",feature:[],search:[],internal:{},legacy:{ajax:null},pager:{},renderer:{pageButton:{},header:{}},order:{},type:{detect:[],search:{},order:{}},_unique:0,fnVersionCheck:p.fnVersionCheck,iApiIndex:0,oJUIClasses:{},sVersion:p.version};g.extend(u,{afnFiltering:u.search,aTypes:u.type.detect,ofnSearch:u.type.search,oSort:u.type.order,afnSortData:u.order,aoFeatures:u.feature,oApi:u.internal,oStdClasses:u.classes,oPagination:u.pager}); -g.extend(p.ext.classes,{sTable:"dataTable",sNoFooter:"no-footer",sPageButton:"paginate_button",sPageButtonActive:"current",sPageButtonDisabled:"disabled",sStripeOdd:"odd",sStripeEven:"even",sRowEmpty:"dataTables_empty",sWrapper:"dataTables_wrapper",sFilter:"dataTables_filter",sInfo:"dataTables_info",sPaging:"dataTables_paginate paging_",sLength:"dataTables_length",sProcessing:"dataTables_processing",sSortAsc:"sorting_asc",sSortDesc:"sorting_desc",sSortable:"sorting",sSortableAsc:"sorting_asc_disabled", -sSortableDesc:"sorting_desc_disabled",sSortableNone:"sorting_disabled",sSortColumn:"sorting_",sFilterInput:"",sLengthSelect:"",sScrollWrapper:"dataTables_scroll",sScrollHead:"dataTables_scrollHead",sScrollHeadInner:"dataTables_scrollHeadInner",sScrollBody:"dataTables_scrollBody",sScrollFoot:"dataTables_scrollFoot",sScrollFootInner:"dataTables_scrollFootInner",sHeaderTH:"",sFooterTH:"",sSortJUIAsc:"",sSortJUIDesc:"",sSortJUI:"",sSortJUIAscAllowed:"",sSortJUIDescAllowed:"",sSortJUIWrapper:"",sSortIcon:"", -sJUIHeader:"",sJUIFooter:""});var ya="",ya="",E=ya+"ui-state-default",ea=ya+"css_right ui-icon ui-icon-",Rb=ya+"fg-toolbar ui-toolbar ui-widget-header ui-helper-clearfix";g.extend(p.ext.oJUIClasses,p.ext.classes,{sPageButton:"fg-button ui-button "+E,sPageButtonActive:"ui-state-disabled",sPageButtonDisabled:"ui-state-disabled",sPaging:"dataTables_paginate fg-buttonset ui-buttonset fg-buttonset-multi ui-buttonset-multi paging_",sSortAsc:E+" sorting_asc",sSortDesc:E+" sorting_desc",sSortable:E+" sorting", -sSortableAsc:E+" sorting_asc_disabled",sSortableDesc:E+" sorting_desc_disabled",sSortableNone:E+" sorting_disabled",sSortJUIAsc:ea+"triangle-1-n",sSortJUIDesc:ea+"triangle-1-s",sSortJUI:ea+"carat-2-n-s",sSortJUIAscAllowed:ea+"carat-1-n",sSortJUIDescAllowed:ea+"carat-1-s",sSortJUIWrapper:"DataTables_sort_wrapper",sSortIcon:"DataTables_sort_icon",sScrollHead:"dataTables_scrollHead "+E,sScrollFoot:"dataTables_scrollFoot "+E,sHeaderTH:E,sFooterTH:E,sJUIHeader:Rb+" ui-corner-tl ui-corner-tr",sJUIFooter:Rb+ -" ui-corner-bl ui-corner-br"});var Ib=p.ext.pager;g.extend(Ib,{simple:function(){return["previous","next"]},full:function(){return["first","previous","next","last"]},simple_numbers:function(a,b){return["previous",Ua(a,b),"next"]},full_numbers:function(a,b){return["first","previous",Ua(a,b),"next","last"]},_numbers:Ua,numbers_length:7});g.extend(!0,p.ext.renderer,{pageButton:{_:function(a,b,c,d,e,f){var h=a.oClasses,i=a.oLanguage.oPaginate,j,l,m=0,o=function(b,d){var k,p,r,q,s=function(b){Ra(a,b.data.action, -true)};k=0;for(p=d.length;k").appendTo(b);o(r,q)}else{l=j="";switch(q){case "ellipsis":b.append("");break;case "first":j=i.sFirst;l=q+(e>0?"":" "+h.sPageButtonDisabled);break;case "previous":j=i.sPrevious;l=q+(e>0?"":" "+h.sPageButtonDisabled);break;case "next":j=i.sNext;l=q+(e",{"class":h.sPageButton+" "+l,"aria-controls":a.sTableId,"data-dt-idx":m,tabindex:a.iTabIndex,id:c===0&&typeof q==="string"?a.sTableId+"_"+q:null}).html(j).appendTo(b);Ta(r,{action:q},s);m++}}}},k=g(N.activeElement).data("dt-idx");o(g(b).empty(),d);k!==null&&g(b).find("[data-dt-idx="+k+"]").focus()}}});var va=function(a,b,c,d){if(!a||"-"===a)return-Infinity;b&&(a=Mb(a,b));a.replace&&(c&&(a=a.replace(c,"")),d&&(a=a.replace(d,"")));return 1*a};g.extend(u.type.order,{"date-pre":function(a){return Date.parse(a)|| -0},"html-pre":function(a){return!a?"":a.replace?a.replace(/<.*?>/g,"").toLowerCase():a+""},"string-pre":function(a){return"string"===typeof a?a.toLowerCase():!a||!a.toString?"":a.toString()},"string-asc":function(a,b){return ab?1:0},"string-desc":function(a,b){return ab?-1:0}});bb("");g.extend(p.ext.type.detect,[function(a,b){var c=b.oLanguage.sDecimal;return Xa(a,c)?"num"+c:null},function(a){if(a&&!Vb.test(a))return null;var b=Date.parse(a);return null!==b&&!isNaN(b)||da(a)?"date": -null},function(a,b){var c=b.oLanguage.sDecimal;return Xa(a,c,!0)?"num-fmt"+c:null},function(a,b){var c=b.oLanguage.sDecimal;return Nb(a,c)?"html-num"+c:null},function(a,b){var c=b.oLanguage.sDecimal;return Nb(a,c,!0)?"html-num-fmt"+c:null},function(a){return da(a)||"string"===typeof a&&-1!==a.indexOf("<")?"html":null}]);g.extend(p.ext.type.search,{html:function(a){return da(a)?"":"string"===typeof a?a.replace(Kb," ").replace(wa,""):""},string:function(a){return da(a)?"":"string"===typeof a?a.replace(Kb, -" "):a}});g.extend(!0,p.ext.renderer,{header:{_:function(a,b,c,d){g(a.nTable).on("order.dt.DT",function(a,f,g,i){a=c.idx;b.removeClass(c.sSortingClass+" "+d.sSortAsc+" "+d.sSortDesc).addClass(i[a]=="asc"?d.sSortAsc:i[a]=="desc"?d.sSortDesc:c.sSortingClass)})},jqueryui:function(a,b,c,d){var e=c.idx;g("
    ").addClass(d.sSortJUIWrapper).append(b.contents()).append(g("").addClass(d.sSortIcon+" "+c.sSortingClassJUI)).appendTo(b);g(a.nTable).on("order.dt.DT",function(a,g,i,j){b.removeClass(d.sSortAsc+ -" "+d.sSortDesc).addClass(j[e]=="asc"?d.sSortAsc:j[e]=="desc"?d.sSortDesc:c.sSortingClass);b.find("span."+d.sSortIcon).removeClass(d.sSortJUIAsc+" "+d.sSortJUIDesc+" "+d.sSortJUI+" "+d.sSortJUIAscAllowed+" "+d.sSortJUIDescAllowed).addClass(j[e]=="asc"?d.sSortJUIAsc:j[e]=="desc"?d.sSortJUIDesc:c.sSortingClassJUI)})}}});p.render={number:function(a,b,c,d){return{display:function(e){var e=parseFloat(e),f=parseInt(e,10),e=c?(b+(e-f).toFixed(c)).substring(2):"";return(d||"")+f.toString().replace(/\B(?=(\d{3})+(?!\d))/g, -a)+e}}}};g.extend(p.ext.internal,{_fnExternApiFunc:Jb,_fnBuildAjax:na,_fnAjaxUpdate:ib,_fnAjaxParameters:rb,_fnAjaxUpdateDraw:sb,_fnAjaxDataSrc:oa,_fnAddColumn:Aa,_fnColumnOptions:fa,_fnAdjustColumnSizing:U,_fnVisibleToColumnIndex:ga,_fnColumnIndexToVisible:X,_fnVisbleColumns:Y,_fnGetColumns:W,_fnColumnTypes:Da,_fnApplyColumnDefs:gb,_fnHungarianMap:S,_fnCamelToHungarian:G,_fnLanguageCompat:M,_fnBrowserDetect:eb,_fnAddData:H,_fnAddTr:ha,_fnNodeToDataIndex:function(a,b){return b._DT_RowIndex!==l?b._DT_RowIndex: -null},_fnNodeToColumnIndex:function(a,b,c){return g.inArray(c,a.aoData[b].anCells)},_fnGetCellData:A,_fnSetCellData:Ea,_fnSplitObjNotation:Ga,_fnGetObjectDataFn:T,_fnSetObjectDataFn:Ba,_fnGetDataMaster:Ha,_fnClearTable:ja,_fnDeleteIndex:ka,_fnInvalidateRow:la,_fnGetRowElements:ia,_fnCreateTr:Fa,_fnBuildHead:hb,_fnDrawHead:I,_fnDraw:J,_fnReDraw:K,_fnAddOptionsHtml:kb,_fnDetectHeader:$,_fnGetUniqueThs:ma,_fnFeatureHtmlFilter:mb,_fnFilterComplete:aa,_fnFilterCustom:vb,_fnFilterColumn:ub,_fnFilter:tb, -_fnFilterCreateSearch:Na,_fnEscapeRegex:Oa,_fnFilterData:wb,_fnFeatureHtmlInfo:pb,_fnUpdateInfo:xb,_fnInfoMacros:yb,_fnInitialise:ra,_fnInitComplete:pa,_fnLengthChange:Pa,_fnFeatureHtmlLength:lb,_fnFeatureHtmlPaginate:qb,_fnPageChange:Ra,_fnFeatureHtmlProcessing:nb,_fnProcessingDisplay:C,_fnFeatureHtmlTable:ob,_fnScrollDraw:V,_fnApplyToChildren:F,_fnCalculateColumnWidths:Ca,_fnThrottle:Ma,_fnConvertToWidth:zb,_fnScrollingWidthAdjust:Bb,_fnGetWidestNode:Ab,_fnGetMaxLenString:Cb,_fnStringToCss:s,_fnScrollBarWidth:Db, -_fnSortFlatten:Q,_fnSort:jb,_fnSortAria:Fb,_fnSortListener:Sa,_fnSortAttachListener:Ka,_fnSortingClasses:sa,_fnSortData:Eb,_fnSaveState:ta,_fnLoadState:Gb,_fnSettingsFromNode:ua,_fnLog:O,_fnMap:D,_fnBindAction:Ta,_fnCallbackReg:y,_fnCallbackFire:t,_fnLengthOverflow:Qa,_fnRenderer:La,_fnDataSource:z,_fnRowAttributes:Ia,_fnCalculateEnd:function(){}});g.fn.dataTable=p;g.fn.dataTableSettings=p.settings;g.fn.dataTableExt=p.ext;g.fn.DataTable=function(a){return g(this).dataTable(a).api()};g.each(p,function(a, -b){g.fn.DataTable[a]=b});return g.fn.dataTable};"function"===typeof define&&define.amd?define("datatables",["jquery"],M):"object"===typeof exports?M(require("jquery")):jQuery&&!jQuery.fn.dataTable&&M(jQuery)})(window,document); diff --git a/Public/images/aznyf.jpg b/Public/images/aznyf.jpg deleted file mode 100644 index b06c629..0000000 Binary files a/Public/images/aznyf.jpg and /dev/null differ diff --git a/Public/images/bg.png b/Public/images/bg.png deleted file mode 100644 index 3c598b0..0000000 Binary files a/Public/images/bg.png and /dev/null differ diff --git a/Public/images/icon/bingxiang.png b/Public/images/icon/bingxiang.png deleted file mode 100644 index 3b03656..0000000 Binary files a/Public/images/icon/bingxiang.png and /dev/null differ diff --git a/Public/images/icon/canzhuo.png b/Public/images/icon/canzhuo.png deleted file mode 100644 index 44c0a7e..0000000 Binary files a/Public/images/icon/canzhuo.png and /dev/null differ diff --git a/Public/images/icon/chuang.png b/Public/images/icon/chuang.png deleted file mode 100644 index 904c599..0000000 Binary files a/Public/images/icon/chuang.png and /dev/null differ diff --git a/Public/images/icon/diannaozhuo.png b/Public/images/icon/diannaozhuo.png deleted file mode 100644 index 6811751..0000000 Binary files a/Public/images/icon/diannaozhuo.png and /dev/null differ diff --git a/Public/images/icon/dianshi.png b/Public/images/icon/dianshi.png deleted file mode 100644 index 0bc4cf7..0000000 Binary files a/Public/images/icon/dianshi.png and /dev/null differ diff --git a/Public/images/icon/dianti.png b/Public/images/icon/dianti.png deleted file mode 100644 index ad96432..0000000 Binary files a/Public/images/icon/dianti.png and /dev/null differ diff --git a/Public/images/icon/duwei.png b/Public/images/icon/duwei.png deleted file mode 100644 index 3b8aee5..0000000 Binary files a/Public/images/icon/duwei.png and /dev/null differ diff --git a/Public/images/icon/gongju.png b/Public/images/icon/gongju.png deleted file mode 100644 index 16ea1b6..0000000 Binary files a/Public/images/icon/gongju.png and /dev/null differ diff --git a/Public/images/icon/jiaju.png b/Public/images/icon/jiaju.png deleted file mode 100644 index 90fbbb9..0000000 Binary files a/Public/images/icon/jiaju.png and /dev/null differ diff --git a/Public/images/icon/jianshenqicai.png b/Public/images/icon/jianshenqicai.png deleted file mode 100644 index 0b28e17..0000000 Binary files a/Public/images/icon/jianshenqicai.png and /dev/null differ diff --git a/Public/images/icon/kezuofan.png b/Public/images/icon/kezuofan.png deleted file mode 100644 index 026b7b8..0000000 Binary files a/Public/images/icon/kezuofan.png and /dev/null differ diff --git a/Public/images/icon/kongtiao.png b/Public/images/icon/kongtiao.png deleted file mode 100644 index 851b7ba..0000000 Binary files a/Public/images/icon/kongtiao.png and /dev/null differ diff --git a/Public/images/icon/kuandai.png b/Public/images/icon/kuandai.png deleted file mode 100644 index a802797..0000000 Binary files a/Public/images/icon/kuandai.png and /dev/null differ diff --git a/Public/images/icon/liangyijia.png b/Public/images/icon/liangyijia.png deleted file mode 100644 index 66dd6f8..0000000 Binary files a/Public/images/icon/liangyijia.png and /dev/null differ diff --git a/Public/images/icon/piaochuang.png b/Public/images/icon/piaochuang.png deleted file mode 100644 index 18c6ccc..0000000 Binary files a/Public/images/icon/piaochuang.png and /dev/null differ diff --git a/Public/images/icon/reshuiqi.png b/Public/images/icon/reshuiqi.png deleted file mode 100644 index dab244d..0000000 Binary files a/Public/images/icon/reshuiqi.png and /dev/null differ diff --git a/Public/images/icon/shafa.png b/Public/images/icon/shafa.png deleted file mode 100644 index b5ba3c2..0000000 Binary files a/Public/images/icon/shafa.png and /dev/null differ diff --git a/Public/images/icon/weibolu.png b/Public/images/icon/weibolu.png deleted file mode 100644 index 637f2b1..0000000 Binary files a/Public/images/icon/weibolu.png and /dev/null differ diff --git a/Public/images/icon/xiyiji.png b/Public/images/icon/xiyiji.png deleted file mode 100644 index 147d4bf..0000000 Binary files a/Public/images/icon/xiyiji.png and /dev/null differ diff --git a/Public/images/icon/yangtai.png b/Public/images/icon/yangtai.png deleted file mode 100644 index 19e2ebb..0000000 Binary files a/Public/images/icon/yangtai.png and /dev/null differ diff --git a/Public/images/icon/yigui.png b/Public/images/icon/yigui.png deleted file mode 100644 index 8d21a5d..0000000 Binary files a/Public/images/icon/yigui.png and /dev/null differ diff --git a/Public/images/icon/yinxiang.png b/Public/images/icon/yinxiang.png deleted file mode 100644 index b2152fd..0000000 Binary files a/Public/images/icon/yinxiang.png and /dev/null differ diff --git a/Public/images/icon/zhinengmensuo.png b/Public/images/icon/zhinengmensuo.png deleted file mode 100644 index f1d66d9..0000000 Binary files a/Public/images/icon/zhinengmensuo.png and /dev/null differ diff --git a/Public/images/jsonFormater/Collapsed.gif b/Public/images/jsonFormater/Collapsed.gif deleted file mode 100644 index 17cbc27..0000000 Binary files a/Public/images/jsonFormater/Collapsed.gif and /dev/null differ diff --git a/Public/images/jsonFormater/Expanded.gif b/Public/images/jsonFormater/Expanded.gif deleted file mode 100644 index 2aa7441..0000000 Binary files a/Public/images/jsonFormater/Expanded.gif and /dev/null differ diff --git a/Public/images/sort_asc.png b/Public/images/sort_asc.png deleted file mode 100644 index e1ba61a..0000000 Binary files a/Public/images/sort_asc.png and /dev/null differ diff --git a/Public/images/sort_both.png b/Public/images/sort_both.png deleted file mode 100644 index af5bc7c..0000000 Binary files a/Public/images/sort_both.png and /dev/null differ diff --git a/Public/images/sort_desc.png b/Public/images/sort_desc.png deleted file mode 100644 index 0e156de..0000000 Binary files a/Public/images/sort_desc.png and /dev/null differ diff --git a/Public/js/cms.js b/Public/js/cms.js deleted file mode 100644 index 6eafde2..0000000 --- a/Public/js/cms.js +++ /dev/null @@ -1,149 +0,0 @@ -layui.define(['layer','element', 'forTree'], function(exports) { - var layer = layui.layer; - var element = layui.element(); - var forTree = layui.forTree; - var $ = layui.jquery; - - var nav = null; - var tab = null; - var tabContent = null; - var tabTitle = null; - var navFilter = null; - var tabFilter = null; - - /** - * 添加导航 - */ - function addNav(data, topId, idName, pidName, nodeName, urlName) { - topId = topId || 0; - idName = idName || 'id'; - pidName = pidName || 'pid'; - nodeName = nodeName || 'node'; - urlName = urlName || 'url'; - - var myTree = new forTree(data, idName, pidName, topId); - var html = ''; - - myTree.forBefore = function (v, k, hasChildren) { - html += '
  • '; - }; - - myTree.forCurr = function(v, k, hasChildren) { - html += ''; - html += v[nodeName]; - html += ''; - }; - - myTree.callBefore = function (v, k) { - html += '
      '; - }; - - myTree.callAfter = function (v, k) { - html += '
    '; - }; - - myTree.forAfter = function (v, k, hasChildren) { - html += '
  • '; - }; - - myTree.each(); - - nav.append(html); - - element.init('nav('+navFilter+')'); - } - - /** - * 将侧边栏与顶部切换卡进行绑定 - */ - function bind(height) { - - height = height || 60 + 41 + 44; //头部高度 顶部切换卡标题高度 底部高度 - /** - * iframe自适应 - */ - $(window).resize(function() { - //设置顶部切换卡容器度 - tabContent.height($(this).height() - height); - //设置顶部切换卡容器内每个iframe高度 - tabContent.find('iframe').each(function () { - $(this).height(tabContent.height()); - }); - }).resize(); - - /** - * 监听侧边栏导航点击事件 - */ - element.on('nav('+navFilter+')', function(elem) { - var a = elem.children('a'); - var title = a.text(); - var src = elem.children('a').attr('data-url'); - var id = elem.children('a').attr('data-id'); - var frame = tabContent.find('iframe[data-id='+id+']').eq(0); - var tabIndex = (new Date()).getTime(); - - if(src != undefined && src != null && id != undefined && id != null) { - if(frame.length) { //存在 iframe - //获取iframe身上的tab index - tabIndex = frame.attr('data-tabindex'); - }else{ //不存在 iframe - //显示加载层 - var tmpIndex = layer.load(); - //设置1秒后再次关闭loading - setTimeout(function() { - layer.close(tmpIndex); - }, 1000); - //拼接iframe - var newFrame = '';break;case 3:delete t.title,delete t.closeBtn,t.icon===-1&&0===t.icon,r.closeAll("loading");break;case 4:f||(t.content=[t.content,"body"]),t.follow=t.content[1],t.content=t.content[0]+'',delete t.title,t.tips="object"==typeof t.tips?t.tips:[t.tips,!0],t.tipsMore||r.closeAll("tips")}e.vessel(f,function(n,r,u){c.append(n[0]),f?function(){2==t.type||4==t.type?function(){i("body").append(n[1])}():function(){s.parents("."+l[0])[0]||(s.data("display",s.css("display")).show().addClass("layui-layer-wrap").wrap(n[1]),i("#"+l[0]+a).find("."+l[5]).before(r))}()}():c.append(n[1]),i(".layui-layer-move")[0]||c.append(o.moveElem=u),e.layero=i("#"+l[0]+a),t.scrollbar||l.html.css("overflow","hidden").attr("layer-full",a)}).auto(a),2==t.type&&6==r.ie&&e.layero.find("iframe").attr("src",s[0]),4==t.type?e.tips():e.offset(),t.fixed&&n.on("resize",function(){e.offset(),(/^\d+%$/.test(t.area[0])||/^\d+%$/.test(t.area[1]))&&e.auto(a),4==t.type&&e.tips()}),t.time<=0||setTimeout(function(){r.close(e.index)},t.time),e.move().callback(),l.anim[t.anim]&&e.layero.addClass(l.anim[t.anim]).data("anim",!0)}},s.pt.auto=function(e){function t(e){e=s.find(e),e.height(f[1]-c-u-2*(0|parseFloat(e.css("padding"))))}var a=this,o=a.config,s=i("#"+l[0]+e);""===o.area[0]&&o.maxWidth>0&&(r.ie&&r.ie<8&&o.btn&&s.width(s.innerWidth()),s.outerWidth()>o.maxWidth&&s.width(o.maxWidth));var f=[s.innerWidth(),s.innerHeight()],c=s.find(l[1]).outerHeight()||0,u=s.find("."+l[6]).outerHeight()||0;switch(o.type){case 2:t("iframe");break;default:""===o.area[1]?o.fixed&&f[1]>=n.height()&&(f[1]=n.height(),t("."+l[5])):t("."+l[5])}return a},s.pt.offset=function(){var e=this,t=e.config,i=e.layero,a=[i.outerWidth(),i.outerHeight()],o="object"==typeof t.offset;e.offsetTop=(n.height()-a[1])/2,e.offsetLeft=(n.width()-a[0])/2,o?(e.offsetTop=t.offset[0],e.offsetLeft=t.offset[1]||e.offsetLeft):"auto"!==t.offset&&("t"===t.offset?e.offsetTop=0:"r"===t.offset?e.offsetLeft=n.width()-a[0]:"b"===t.offset?e.offsetTop=n.height()-a[1]:"l"===t.offset?e.offsetLeft=0:"lt"===t.offset?(e.offsetTop=0,e.offsetLeft=0):"lb"===t.offset?(e.offsetTop=n.height()-a[1],e.offsetLeft=0):"rt"===t.offset?(e.offsetTop=0,e.offsetLeft=n.width()-a[0]):"rb"===t.offset?(e.offsetTop=n.height()-a[1],e.offsetLeft=n.width()-a[0]):e.offsetTop=t.offset),t.fixed||(e.offsetTop=/%$/.test(e.offsetTop)?n.height()*parseFloat(e.offsetTop)/100:parseFloat(e.offsetTop),e.offsetLeft=/%$/.test(e.offsetLeft)?n.width()*parseFloat(e.offsetLeft)/100:parseFloat(e.offsetLeft),e.offsetTop+=n.scrollTop(),e.offsetLeft+=n.scrollLeft()),i.attr("minLeft")&&(e.offsetTop=n.height()-(i.find(l[1]).outerHeight()||0),e.offsetLeft=i.css("left")),i.css({top:e.offsetTop,left:e.offsetLeft})},s.pt.tips=function(){var e=this,t=e.config,a=e.layero,o=[a.outerWidth(),a.outerHeight()],r=i(t.follow);r[0]||(r=i("body"));var s={width:r.outerWidth(),height:r.outerHeight(),top:r.offset().top,left:r.offset().left},f=a.find(".layui-layer-TipsG"),c=t.tips[0];t.tips[1]||f.remove(),s.autoLeft=function(){s.left+o[0]-n.width()>0?(s.tipLeft=s.left+s.width-o[0],f.css({right:12,left:"auto"})):s.tipLeft=s.left},s.where=[function(){s.autoLeft(),s.tipTop=s.top-o[1]-10,f.removeClass("layui-layer-TipsB").addClass("layui-layer-TipsT").css("border-right-color",t.tips[1])},function(){s.tipLeft=s.left+s.width+10,s.tipTop=s.top,f.removeClass("layui-layer-TipsL").addClass("layui-layer-TipsR").css("border-bottom-color",t.tips[1])},function(){s.autoLeft(),s.tipTop=s.top+s.height+10,f.removeClass("layui-layer-TipsT").addClass("layui-layer-TipsB").css("border-right-color",t.tips[1])},function(){s.tipLeft=s.left-o[0]-10,s.tipTop=s.top,f.removeClass("layui-layer-TipsR").addClass("layui-layer-TipsL").css("border-bottom-color",t.tips[1])}],s.where[c-1](),1===c?s.top-(n.scrollTop()+o[1]+16)<0&&s.where[2]():2===c?n.width()-(s.left+s.width+o[0]+16)>0||s.where[3]():3===c?s.top-n.scrollTop()+s.height+o[1]+16-n.height()>0&&s.where[0]():4===c&&o[0]+16-s.left>0&&s.where[1](),a.find("."+l[5]).css({"background-color":t.tips[1],"padding-right":t.closeBtn?"30px":""}),a.css({left:s.tipLeft-(t.fixed?n.scrollLeft():0),top:s.tipTop-(t.fixed?n.scrollTop():0)})},s.pt.move=function(){var e=this,t=e.config,a=i(document),s=e.layero,l=s.find(t.move),f=s.find(".layui-layer-resize"),c={};return t.move&&l.css("cursor","move"),l.on("mousedown",function(e){e.preventDefault(),t.move&&(c.moveStart=!0,c.offset=[e.clientX-parseFloat(s.css("left")),e.clientY-parseFloat(s.css("top"))],o.moveElem.css("cursor","move").show())}),f.on("mousedown",function(e){e.preventDefault(),c.resizeStart=!0,c.offset=[e.clientX,e.clientY],c.area=[s.outerWidth(),s.outerHeight()],o.moveElem.css("cursor","se-resize").show()}),a.on("mousemove",function(i){if(c.moveStart){var a=i.clientX-c.offset[0],o=i.clientY-c.offset[1],l="fixed"===s.css("position");if(i.preventDefault(),c.stX=l?0:n.scrollLeft(),c.stY=l?0:n.scrollTop(),!t.moveOut){var f=n.width()-s.outerWidth()+c.stX,u=n.height()-s.outerHeight()+c.stY;af&&(a=f),ou&&(o=u)}s.css({left:a,top:o})}if(t.resize&&c.resizeStart){var a=i.clientX-c.offset[0],o=i.clientY-c.offset[1];i.preventDefault(),r.style(e.index,{width:c.area[0]+a,height:c.area[1]+o}),c.isResize=!0,t.resizing&&t.resizing(s)}}).on("mouseup",function(e){c.moveStart&&(delete c.moveStart,o.moveElem.hide(),t.moveEnd&&t.moveEnd(s)),c.resizeStart&&(delete c.resizeStart,o.moveElem.hide())}),e},s.pt.callback=function(){function e(){var e=a.cancel&&a.cancel(t.index,n);e===!1||r.close(t.index)}var t=this,n=t.layero,a=t.config;t.openLayer(),a.success&&(2==a.type?n.find("iframe").on("load",function(){a.success(n,t.index)}):a.success(n,t.index)),6==r.ie&&t.IE6(n),n.find("."+l[6]).children("a").on("click",function(){var e=i(this).index();if(0===e)a.yes?a.yes(t.index,n):a.btn1?a.btn1(t.index,n):r.close(t.index);else{var o=a["btn"+(e+1)]&&a["btn"+(e+1)](t.index,n);o===!1||r.close(t.index)}}),n.find("."+l[7]).on("click",e),a.shadeClose&&i("#layui-layer-shade"+t.index).on("click",function(){r.close(t.index)}),n.find(".layui-layer-min").on("click",function(){var e=a.min&&a.min(n);e===!1||r.min(t.index,a)}),n.find(".layui-layer-max").on("click",function(){i(this).hasClass("layui-layer-maxmin")?(r.restore(t.index),a.restore&&a.restore(n)):(r.full(t.index,a),setTimeout(function(){a.full&&a.full(n)},100))}),a.end&&(o.end[t.index]=a.end)},o.reselect=function(){i.each(i("select"),function(e,t){var n=i(this);n.parents("."+l[0])[0]||1==n.attr("layer")&&i("."+l[0]).length<1&&n.removeAttr("layer").show(),n=null})},s.pt.IE6=function(e){i("select").each(function(e,t){var n=i(this);n.parents("."+l[0])[0]||"none"===n.css("display")||n.attr({layer:"1"}).hide(),n=null})},s.pt.openLayer=function(){var e=this;r.zIndex=e.config.zIndex,r.setTop=function(e){var t=function(){r.zIndex++,e.css("z-index",r.zIndex+1)};return r.zIndex=parseInt(e[0].style.zIndex),e.on("mousedown",t),r.zIndex}},o.record=function(e){var t=[e.width(),e.height(),e.position().top,e.position().left+parseFloat(e.css("margin-left"))];e.find(".layui-layer-max").addClass("layui-layer-maxmin"),e.attr({area:t})},o.rescollbar=function(e){l.html.attr("layer-full")==e&&(l.html[0].style.removeProperty?l.html[0].style.removeProperty("overflow"):l.html[0].style.removeAttribute("overflow"),l.html.removeAttr("layer-full"))},e.layer=r,r.getChildFrame=function(e,t){return t=t||i("."+l[4]).attr("times"),i("#"+l[0]+t).find("iframe").contents().find(e)},r.getFrameIndex=function(e){return i("#"+e).parents("."+l[4]).attr("times")},r.iframeAuto=function(e){if(e){var t=r.getChildFrame("html",e).outerHeight(),n=i("#"+l[0]+e),a=n.find(l[1]).outerHeight()||0,o=n.find("."+l[6]).outerHeight()||0;n.css({height:t+a+o}),n.find("iframe").css({height:t})}},r.iframeSrc=function(e,t){i("#"+l[0]+e).find("iframe").attr("src",t)},r.style=function(e,t,n){var a=i("#"+l[0]+e),r=a.find(".layui-layer-content"),s=a.attr("type"),f=a.find(l[1]).outerHeight()||0,c=a.find("."+l[6]).outerHeight()||0;a.attr("minLeft");s!==o.type[3]&&s!==o.type[4]&&(n||(parseFloat(t.width)<=260&&(t.width=260),parseFloat(t.height)-f-c<=64&&(t.height=64+f+c)),a.css(t),c=a.find("."+l[6]).outerHeight(),s===o.type[2]?a.find("iframe").css({height:parseFloat(t.height)-f-c}):r.css({height:parseFloat(t.height)-f-c-parseFloat(r.css("padding-top"))-parseFloat(r.css("padding-bottom"))}))},r.min=function(e,t){var a=i("#"+l[0]+e),s=a.find(l[1]).outerHeight()||0,f=a.attr("minLeft")||181*o.minIndex+"px",c=a.css("position");o.record(a),o.minLeft[0]&&(f=o.minLeft[0],o.minLeft.shift()),a.attr("position",c),r.style(e,{width:180,height:s,left:f,top:n.height()-s,position:"fixed",overflow:"hidden"},!0),a.find(".layui-layer-min").hide(),"page"===a.attr("type")&&a.find(l[4]).hide(),o.rescollbar(e),a.attr("minLeft")||o.minIndex++,a.attr("minLeft",f)},r.restore=function(e){var t=i("#"+l[0]+e),n=t.attr("area").split(",");t.attr("type");r.style(e,{width:parseFloat(n[0]),height:parseFloat(n[1]),top:parseFloat(n[2]),left:parseFloat(n[3]),position:t.attr("position"),overflow:"visible"},!0),t.find(".layui-layer-max").removeClass("layui-layer-maxmin"),t.find(".layui-layer-min").show(),"page"===t.attr("type")&&t.find(l[4]).show(),o.rescollbar(e)},r.full=function(e){var t,a=i("#"+l[0]+e);o.record(a),l.html.attr("layer-full")||l.html.css("overflow","hidden").attr("layer-full",e),clearTimeout(t),t=setTimeout(function(){var t="fixed"===a.css("position");r.style(e,{top:t?0:n.scrollTop(),left:t?0:n.scrollLeft(),width:n.width(),height:n.height()},!0),a.find(".layui-layer-min").hide()},100)},r.title=function(e,t){var n=i("#"+l[0]+(t||r.index)).find(l[1]);n.html(e)},r.close=function(e){var t=i("#"+l[0]+e),n=t.attr("type"),a="layer-anim-close";if(t[0]){var s="layui-layer-wrap",f=function(){if(n===o.type[1]&&"object"===t.attr("conType")){t.children(":not(."+l[5]+")").remove();for(var a=t.find("."+s),r=0;r<2;r++)a.unwrap();a.css("display",a.data("display")).removeClass(s)}else{if(n===o.type[2])try{var f=i("#"+l[4]+e)[0];f.contentWindow.document.write(""),f.contentWindow.close(),t.find("."+l[5])[0].removeChild(f)}catch(c){}t[0].innerHTML="",t.remove()}"function"==typeof o.end[e]&&o.end[e](),delete o.end[e]};t.data("anim")&&t.addClass(a),i("#layui-layer-moves, #layui-layer-shade"+e).remove(),6==r.ie&&o.reselect(),o.rescollbar(e),t.attr("minLeft")&&(o.minIndex--,o.minLeft.push(t.attr("minLeft"))),setTimeout(function(){f()},r.ie&&r.ie<10||!t.data("anim")?0:200)}},r.closeAll=function(e){i.each(i("."+l[0]),function(){var t=i(this),n=e?t.attr("type")===e:1;n&&r.close(t.attr("times")),n=null})};var f=r.cache||{},c=function(e){return f.skin?" "+f.skin+" "+f.skin+"-"+e:""};r.prompt=function(e,t){var a="";if(e=e||{},"function"==typeof e&&(t=e),e.area){var o=e.area;a='style="width: '+o[0]+"; height: "+o[1]+';"',delete e.area}var s,l=2==e.formType?'":function(){return''}(),f=e.success;return delete e.success,r.open(i.extend({type:1,btn:["确定","取消"],content:l,skin:"layui-layer-prompt"+c("prompt"),maxWidth:n.width(),success:function(e){s=e.find(".layui-layer-input"),s.focus(),"function"==typeof f&&f(e)},resize:!1,yes:function(i){var n=s.val();""===n?s.focus():n.length>(e.maxlength||500)?r.tips("最多输入"+(e.maxlength||500)+"个字数",s,{tips:1}):t&&t(n,i,s)}},e))},r.tab=function(e){e=e||{};var t=e.tab||{},n=e.success;return delete e.success,r.open(i.extend({type:1,skin:"layui-layer-tab"+c("tab"),resize:!1,title:function(){var e=t.length,i=1,n="";if(e>0)for(n=''+t[0].title+"";i"+t[i].title+"
    ";return n}(),content:'
      '+function(){var e=t.length,i=1,n="";if(e>0)for(n='
    • '+(t[0].content||"no content")+"
    • ";i'+(t[i].content||"no content")+"";return n}()+"
    ",success:function(t){var a=t.find(".layui-layer-title").children(),o=t.find(".layui-layer-tabmain").children();a.on("mousedown",function(t){t.stopPropagation?t.stopPropagation():t.cancelBubble=!0;var n=i(this),a=n.index();n.addClass("layui-layer-tabnow").siblings().removeClass("layui-layer-tabnow"),o.eq(a).show().siblings().hide(),"function"==typeof e.change&&e.change(a)}),"function"==typeof n&&n(t)}},e))},r.photos=function(t,n,a){function o(e,t,i){var n=new Image;return n.src=e,n.complete?t(n):(n.onload=function(){n.onload=null,t(n)},void(n.onerror=function(e){n.onerror=null,i(e)}))}var s={};if(t=t||{},t.photos){var l=t.photos.constructor===Object,f=l?t.photos:{},u=f.data||[],d=f.start||0;s.imgIndex=(0|d)+1,t.img=t.img||"img";var y=t.success;if(delete t.success,l){if(0===u.length)return r.msg("没有图片")}else{var p=i(t.photos),h=function(){u=[],p.find(t.img).each(function(e){var t=i(this);t.attr("layer-index",e),u.push({alt:t.attr("alt"),pid:t.attr("layer-pid"),src:t.attr("layer-src")||t.attr("src"),thumb:t.attr("src")})})};if(h(),0===u.length)return;if(n||p.on("click",t.img,function(){var e=i(this),n=e.attr("layer-index");r.photos(i.extend(t,{photos:{start:n,data:u,tab:t.tab},full:t.full}),!0),h()}),!n)return}s.imgprev=function(e){s.imgIndex--,s.imgIndex<1&&(s.imgIndex=u.length),s.tabimg(e)},s.imgnext=function(e,t){s.imgIndex++,s.imgIndex>u.length&&(s.imgIndex=1,t)||s.tabimg(e)},s.keyup=function(e){if(!s.end){var t=e.keyCode;e.preventDefault(),37===t?s.imgprev(!0):39===t?s.imgnext(!0):27===t&&r.close(s.index)}},s.tabimg=function(e){u.length<=1||(f.start=s.imgIndex-1,r.close(s.index),setTimeout(function(){r.photos(t,!0,e)},200))},s.event=function(){s.bigimg.hover(function(){s.imgsee.show()},function(){s.imgsee.hide()}),s.bigimg.find(".layui-layer-imgprev").on("click",function(e){e.preventDefault(),s.imgprev()}),s.bigimg.find(".layui-layer-imgnext").on("click",function(e){e.preventDefault(),s.imgnext()}),i(document).on("keyup",s.keyup)},s.loadi=r.load(1,{shade:!("shade"in t)&&.9,scrollbar:!1}),o(u[d].src,function(n){r.close(s.loadi),s.index=r.open(i.extend({type:1,id:"layui-layer-photos",area:function(){var a=[n.width,n.height],o=[i(e).width()-100,i(e).height()-100];if(!t.full&&(a[0]>o[0]||a[1]>o[1])){var r=[a[0]/o[0],a[1]/o[1]];r[0]>r[1]?(a[0]=a[0]/r[0],a[1]=a[1]/r[0]):r[0]'+(u[d].alt||
    '+(u.length>1?'':"")+'
    '+(u[d].alt||"")+""+s.imgIndex+"/"+u.length+"
    ",success:function(e,i){s.bigimg=e.find(".layui-layer-phimg"),s.imgsee=e.find(".layui-layer-imguide,.layui-layer-imgbar"),s.event(e),t.tab&&t.tab(u[d],e),"function"==typeof y&&y(e)},end:function(){s.end=!0,i(document).off("keyup",s.keyup)}},t))},function(){r.close(s.loadi),r.msg("当前图片地址异常
    是否继续查看下一张?",{time:3e4,btn:["下一张","不看了"],yes:function(){u.length>1&&s.imgnext(!0,!0)}})})}},o.run=function(t){i=t,n=i(e),l.html=i("html"),r.open=function(e){var t=new s(e);return t.index}},e.layui&&layui.define?(r.ready(),layui.define("jquery",function(t){r.path=layui.cache.dir,o.run(layui.jquery),e.layer=r,t("layer",r)})):"function"==typeof define&&define.amd?define(["jquery"],function(){return o.run(e.jQuery),r}):function(){o.run(e.jQuery),r.ready()}()}(window);!function(e,t){"object"==typeof module&&"object"==typeof module.exports?module.exports=e.document?t(e,!0):function(e){if(!e.document)throw new Error("jQuery requires a window with a document");return t(e)}:t(e)}("undefined"!=typeof window?window:this,function(e,t){function n(e){var t=!!e&&"length"in e&&e.length,n=pe.type(e);return"function"!==n&&!pe.isWindow(e)&&("array"===n||0===t||"number"==typeof t&&t>0&&t-1 in e)}function r(e,t,n){if(pe.isFunction(t))return pe.grep(e,function(e,r){return!!t.call(e,r,e)!==n});if(t.nodeType)return pe.grep(e,function(e){return e===t!==n});if("string"==typeof t){if(Ce.test(t))return pe.filter(t,e,n);t=pe.filter(t,e)}return pe.grep(e,function(e){return pe.inArray(e,t)>-1!==n})}function i(e,t){do e=e[t];while(e&&1!==e.nodeType);return e}function o(e){var t={};return pe.each(e.match(De)||[],function(e,n){t[n]=!0}),t}function a(){re.addEventListener?(re.removeEventListener("DOMContentLoaded",s),e.removeEventListener("load",s)):(re.detachEvent("onreadystatechange",s),e.detachEvent("onload",s))}function s(){(re.addEventListener||"load"===e.event.type||"complete"===re.readyState)&&(a(),pe.ready())}function u(e,t,n){if(void 0===n&&1===e.nodeType){var r="data-"+t.replace(_e,"-$1").toLowerCase();if(n=e.getAttribute(r),"string"==typeof n){try{n="true"===n||"false"!==n&&("null"===n?null:+n+""===n?+n:qe.test(n)?pe.parseJSON(n):n)}catch(i){}pe.data(e,t,n)}else n=void 0}return n}function l(e){var t;for(t in e)if(("data"!==t||!pe.isEmptyObject(e[t]))&&"toJSON"!==t)return!1;return!0}function c(e,t,n,r){if(He(e)){var i,o,a=pe.expando,s=e.nodeType,u=s?pe.cache:e,l=s?e[a]:e[a]&&a;if(l&&u[l]&&(r||u[l].data)||void 0!==n||"string"!=typeof t)return l||(l=s?e[a]=ne.pop()||pe.guid++:a),u[l]||(u[l]=s?{}:{toJSON:pe.noop}),"object"!=typeof t&&"function"!=typeof t||(r?u[l]=pe.extend(u[l],t):u[l].data=pe.extend(u[l].data,t)),o=u[l],r||(o.data||(o.data={}),o=o.data),void 0!==n&&(o[pe.camelCase(t)]=n),"string"==typeof t?(i=o[t],null==i&&(i=o[pe.camelCase(t)])):i=o,i}}function f(e,t,n){if(He(e)){var r,i,o=e.nodeType,a=o?pe.cache:e,s=o?e[pe.expando]:pe.expando;if(a[s]){if(t&&(r=n?a[s]:a[s].data)){pe.isArray(t)?t=t.concat(pe.map(t,pe.camelCase)):t in r?t=[t]:(t=pe.camelCase(t),t=t in r?[t]:t.split(" ")),i=t.length;for(;i--;)delete r[t[i]];if(n?!l(r):!pe.isEmptyObject(r))return}(n||(delete a[s].data,l(a[s])))&&(o?pe.cleanData([e],!0):fe.deleteExpando||a!=a.window?delete a[s]:a[s]=void 0)}}}function d(e,t,n,r){var i,o=1,a=20,s=r?function(){return r.cur()}:function(){return pe.css(e,t,"")},u=s(),l=n&&n[3]||(pe.cssNumber[t]?"":"px"),c=(pe.cssNumber[t]||"px"!==l&&+u)&&Me.exec(pe.css(e,t));if(c&&c[3]!==l){l=l||c[3],n=n||[],c=+u||1;do o=o||".5",c/=o,pe.style(e,t,c+l);while(o!==(o=s()/u)&&1!==o&&--a)}return n&&(c=+c||+u||0,i=n[1]?c+(n[1]+1)*n[2]:+n[2],r&&(r.unit=l,r.start=c,r.end=i)),i}function p(e){var t=ze.split("|"),n=e.createDocumentFragment();if(n.createElement)for(;t.length;)n.createElement(t.pop());return n}function h(e,t){var n,r,i=0,o="undefined"!=typeof e.getElementsByTagName?e.getElementsByTagName(t||"*"):"undefined"!=typeof e.querySelectorAll?e.querySelectorAll(t||"*"):void 0;if(!o)for(o=[],n=e.childNodes||e;null!=(r=n[i]);i++)!t||pe.nodeName(r,t)?o.push(r):pe.merge(o,h(r,t));return void 0===t||t&&pe.nodeName(e,t)?pe.merge([e],o):o}function g(e,t){for(var n,r=0;null!=(n=e[r]);r++)pe._data(n,"globalEval",!t||pe._data(t[r],"globalEval"))}function m(e){Be.test(e.type)&&(e.defaultChecked=e.checked)}function y(e,t,n,r,i){for(var o,a,s,u,l,c,f,d=e.length,y=p(t),v=[],x=0;x"!==f[1]||Ve.test(a)?0:u:u.firstChild,o=a&&a.childNodes.length;o--;)pe.nodeName(c=a.childNodes[o],"tbody")&&!c.childNodes.length&&a.removeChild(c);for(pe.merge(v,u.childNodes),u.textContent="";u.firstChild;)u.removeChild(u.firstChild);u=y.lastChild}else v.push(t.createTextNode(a));for(u&&y.removeChild(u),fe.appendChecked||pe.grep(h(v,"input"),m),x=0;a=v[x++];)if(r&&pe.inArray(a,r)>-1)i&&i.push(a);else if(s=pe.contains(a.ownerDocument,a),u=h(y.appendChild(a),"script"),s&&g(u),n)for(o=0;a=u[o++];)Ie.test(a.type||"")&&n.push(a);return u=null,y}function v(){return!0}function x(){return!1}function b(){try{return re.activeElement}catch(e){}}function w(e,t,n,r,i,o){var a,s;if("object"==typeof t){"string"!=typeof n&&(r=r||n,n=void 0);for(s in t)w(e,s,n,r,t[s],o);return e}if(null==r&&null==i?(i=n,r=n=void 0):null==i&&("string"==typeof n?(i=r,r=void 0):(i=r,r=n,n=void 0)),i===!1)i=x;else if(!i)return e;return 1===o&&(a=i,i=function(e){return pe().off(e),a.apply(this,arguments)},i.guid=a.guid||(a.guid=pe.guid++)),e.each(function(){pe.event.add(this,t,i,r,n)})}function T(e,t){return pe.nodeName(e,"table")&&pe.nodeName(11!==t.nodeType?t:t.firstChild,"tr")?e.getElementsByTagName("tbody")[0]||e.appendChild(e.ownerDocument.createElement("tbody")):e}function C(e){return e.type=(null!==pe.find.attr(e,"type"))+"/"+e.type,e}function E(e){var t=it.exec(e.type);return t?e.type=t[1]:e.removeAttribute("type"),e}function N(e,t){if(1===t.nodeType&&pe.hasData(e)){var n,r,i,o=pe._data(e),a=pe._data(t,o),s=o.events;if(s){delete a.handle,a.events={};for(n in s)for(r=0,i=s[n].length;r1&&"string"==typeof p&&!fe.checkClone&&rt.test(p))return e.each(function(i){var o=e.eq(i);g&&(t[0]=p.call(this,i,o.html())),S(o,t,n,r)});if(f&&(l=y(t,e[0].ownerDocument,!1,e,r),i=l.firstChild,1===l.childNodes.length&&(l=i),i||r)){for(s=pe.map(h(l,"script"),C),a=s.length;c")).appendTo(t.documentElement),t=(ut[0].contentWindow||ut[0].contentDocument).document,t.write(),t.close(),n=D(e,t),ut.detach()),lt[e]=n),n}function L(e,t){return{get:function(){return e()?void delete this.get:(this.get=t).apply(this,arguments)}}}function H(e){if(e in Et)return e;for(var t=e.charAt(0).toUpperCase()+e.slice(1),n=Ct.length;n--;)if(e=Ct[n]+t,e in Et)return e}function q(e,t){for(var n,r,i,o=[],a=0,s=e.length;a=0&&n=0},isEmptyObject:function(e){var t;for(t in e)return!1;return!0},isPlainObject:function(e){var t;if(!e||"object"!==pe.type(e)||e.nodeType||pe.isWindow(e))return!1;try{if(e.constructor&&!ce.call(e,"constructor")&&!ce.call(e.constructor.prototype,"isPrototypeOf"))return!1}catch(n){return!1}if(!fe.ownFirst)for(t in e)return ce.call(e,t);for(t in e);return void 0===t||ce.call(e,t)},type:function(e){return null==e?e+"":"object"==typeof e||"function"==typeof e?ue[le.call(e)]||"object":typeof e},globalEval:function(t){t&&pe.trim(t)&&(e.execScript||function(t){e.eval.call(e,t)})(t)},camelCase:function(e){return e.replace(ge,"ms-").replace(me,ye)},nodeName:function(e,t){return e.nodeName&&e.nodeName.toLowerCase()===t.toLowerCase()},each:function(e,t){var r,i=0;if(n(e))for(r=e.length;iT.cacheLength&&delete e[t.shift()],e[n+" "]=r}var t=[];return e}function r(e){return e[P]=!0,e}function i(e){var t=H.createElement("div");try{return!!e(t)}catch(n){return!1}finally{t.parentNode&&t.parentNode.removeChild(t),t=null}}function o(e,t){for(var n=e.split("|"),r=n.length;r--;)T.attrHandle[n[r]]=t}function a(e,t){var n=t&&e,r=n&&1===e.nodeType&&1===t.nodeType&&(~t.sourceIndex||V)-(~e.sourceIndex||V);if(r)return r;if(n)for(;n=n.nextSibling;)if(n===t)return-1;return e?1:-1}function s(e){return function(t){var n=t.nodeName.toLowerCase();return"input"===n&&t.type===e}}function u(e){return function(t){var n=t.nodeName.toLowerCase();return("input"===n||"button"===n)&&t.type===e}}function l(e){return r(function(t){return t=+t,r(function(n,r){for(var i,o=e([],n.length,t),a=o.length;a--;)n[i=o[a]]&&(n[i]=!(r[i]=n[i]))})})}function c(e){return e&&"undefined"!=typeof e.getElementsByTagName&&e}function f(){}function d(e){for(var t=0,n=e.length,r="";t1?function(t,n,r){for(var i=e.length;i--;)if(!e[i](t,n,r))return!1;return!0}:e[0]}function g(e,n,r){for(var i=0,o=n.length;i-1&&(r[l]=!(a[l]=f))}}else x=m(x===a?x.splice(h,x.length):x),o?o(null,a,x,u):Q.apply(a,x)})}function v(e){for(var t,n,r,i=e.length,o=T.relative[e[0].type],a=o||T.relative[" "],s=o?1:0,u=p(function(e){return e===t},a,!0),l=p(function(e){return ee(t,e)>-1},a,!0),c=[function(e,n,r){var i=!o&&(r||n!==A)||((t=n).nodeType?u(e,n,r):l(e,n,r));return t=null,i}];s1&&h(c),s>1&&d(e.slice(0,s-1).concat({value:" "===e[s-2].type?"*":""})).replace(se,"$1"),n,s0,o=e.length>0,a=function(r,a,s,u,l){var c,f,d,p=0,h="0",g=r&&[],y=[],v=A,x=r||o&&T.find.TAG("*",l),b=W+=null==v?1:Math.random()||.1,w=x.length;for(l&&(A=a===H||a||l);h!==w&&null!=(c=x[h]);h++){if(o&&c){for(f=0,a||c.ownerDocument===H||(L(c),s=!_);d=e[f++];)if(d(c,a||H,s)){u.push(c);break}l&&(W=b)}i&&((c=!d&&c)&&p--,r&&g.push(c))}if(p+=h,i&&h!==p){for(f=0;d=n[f++];)d(g,y,a,s);if(r){if(p>0)for(;h--;)g[h]||y[h]||(y[h]=G.call(u));y=m(y)}Q.apply(u,y),l&&!r&&y.length>0&&p+n.length>1&&t.uniqueSort(u)}return l&&(W=b,A=v),g};return i?r(a):a}var b,w,T,C,E,N,k,S,A,D,j,L,H,q,_,F,M,O,R,P="sizzle"+1*new Date,B=e.document,W=0,I=0,$=n(),z=n(),X=n(),U=function(e,t){return e===t&&(j=!0),0},V=1<<31,Y={}.hasOwnProperty,J=[],G=J.pop,K=J.push,Q=J.push,Z=J.slice,ee=function(e,t){for(var n=0,r=e.length;n+~]|"+ne+")"+ne+"*"),ce=new RegExp("="+ne+"*([^\\]'\"]*?)"+ne+"*\\]","g"),fe=new RegExp(oe),de=new RegExp("^"+re+"$"),pe={ID:new RegExp("^#("+re+")"),CLASS:new RegExp("^\\.("+re+")"),TAG:new RegExp("^("+re+"|[*])"),ATTR:new RegExp("^"+ie),PSEUDO:new RegExp("^"+oe),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+ne+"*(even|odd|(([+-]|)(\\d*)n|)"+ne+"*(?:([+-]|)"+ne+"*(\\d+)|))"+ne+"*\\)|)","i"),bool:new RegExp("^(?:"+te+")$","i"),needsContext:new RegExp("^"+ne+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+ne+"*((?:-\\d)?\\d*)"+ne+"*\\)|)(?=[^-]|$)","i")},he=/^(?:input|select|textarea|button)$/i,ge=/^h\d$/i,me=/^[^{]+\{\s*\[native \w/,ye=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,ve=/[+~]/,xe=/'|\\/g,be=new RegExp("\\\\([\\da-f]{1,6}"+ne+"?|("+ne+")|.)","ig"),we=function(e,t,n){var r="0x"+t-65536;return r!==r||n?t:r<0?String.fromCharCode(r+65536):String.fromCharCode(r>>10|55296,1023&r|56320)},Te=function(){L()};try{Q.apply(J=Z.call(B.childNodes),B.childNodes),J[B.childNodes.length].nodeType}catch(Ce){Q={apply:J.length?function(e,t){K.apply(e,Z.call(t))}:function(e,t){for(var n=e.length,r=0;e[n++]=t[r++];);e.length=n-1}}}w=t.support={},E=t.isXML=function(e){var t=e&&(e.ownerDocument||e).documentElement;return!!t&&"HTML"!==t.nodeName},L=t.setDocument=function(e){var t,n,r=e?e.ownerDocument||e:B;return r!==H&&9===r.nodeType&&r.documentElement?(H=r,q=H.documentElement,_=!E(H),(n=H.defaultView)&&n.top!==n&&(n.addEventListener?n.addEventListener("unload",Te,!1):n.attachEvent&&n.attachEvent("onunload",Te)),w.attributes=i(function(e){return e.className="i",!e.getAttribute("className")}),w.getElementsByTagName=i(function(e){return e.appendChild(H.createComment("")),!e.getElementsByTagName("*").length}),w.getElementsByClassName=me.test(H.getElementsByClassName),w.getById=i(function(e){return q.appendChild(e).id=P,!H.getElementsByName||!H.getElementsByName(P).length}),w.getById?(T.find.ID=function(e,t){if("undefined"!=typeof t.getElementById&&_){var n=t.getElementById(e);return n?[n]:[]}},T.filter.ID=function(e){var t=e.replace(be,we);return function(e){return e.getAttribute("id")===t}}):(delete T.find.ID,T.filter.ID=function(e){var t=e.replace(be,we);return function(e){var n="undefined"!=typeof e.getAttributeNode&&e.getAttributeNode("id");return n&&n.value===t}}),T.find.TAG=w.getElementsByTagName?function(e,t){return"undefined"!=typeof t.getElementsByTagName?t.getElementsByTagName(e):w.qsa?t.querySelectorAll(e):void 0}:function(e,t){var n,r=[],i=0,o=t.getElementsByTagName(e);if("*"===e){for(;n=o[i++];)1===n.nodeType&&r.push(n);return r}return o},T.find.CLASS=w.getElementsByClassName&&function(e,t){if("undefined"!=typeof t.getElementsByClassName&&_)return t.getElementsByClassName(e)},M=[],F=[],(w.qsa=me.test(H.querySelectorAll))&&(i(function(e){q.appendChild(e).innerHTML="",e.querySelectorAll("[msallowcapture^='']").length&&F.push("[*^$]="+ne+"*(?:''|\"\")"),e.querySelectorAll("[selected]").length||F.push("\\["+ne+"*(?:value|"+te+")"),e.querySelectorAll("[id~="+P+"-]").length||F.push("~="),e.querySelectorAll(":checked").length||F.push(":checked"),e.querySelectorAll("a#"+P+"+*").length||F.push(".#.+[+~]")}),i(function(e){var t=H.createElement("input");t.setAttribute("type","hidden"),e.appendChild(t).setAttribute("name","D"),e.querySelectorAll("[name=d]").length&&F.push("name"+ne+"*[*^$|!~]?="),e.querySelectorAll(":enabled").length||F.push(":enabled",":disabled"),e.querySelectorAll("*,:x"),F.push(",.*:")})),(w.matchesSelector=me.test(O=q.matches||q.webkitMatchesSelector||q.mozMatchesSelector||q.oMatchesSelector||q.msMatchesSelector))&&i(function(e){w.disconnectedMatch=O.call(e,"div"),O.call(e,"[s!='']:x"),M.push("!=",oe)}),F=F.length&&new RegExp(F.join("|")),M=M.length&&new RegExp(M.join("|")),t=me.test(q.compareDocumentPosition),R=t||me.test(q.contains)?function(e,t){var n=9===e.nodeType?e.documentElement:e,r=t&&t.parentNode;return e===r||!(!r||1!==r.nodeType||!(n.contains?n.contains(r):e.compareDocumentPosition&&16&e.compareDocumentPosition(r)))}:function(e,t){if(t)for(;t=t.parentNode;)if(t===e)return!0;return!1},U=t?function(e,t){if(e===t)return j=!0,0;var n=!e.compareDocumentPosition-!t.compareDocumentPosition;return n?n:(n=(e.ownerDocument||e)===(t.ownerDocument||t)?e.compareDocumentPosition(t):1,1&n||!w.sortDetached&&t.compareDocumentPosition(e)===n?e===H||e.ownerDocument===B&&R(B,e)?-1:t===H||t.ownerDocument===B&&R(B,t)?1:D?ee(D,e)-ee(D,t):0:4&n?-1:1)}:function(e,t){if(e===t)return j=!0,0;var n,r=0,i=e.parentNode,o=t.parentNode,s=[e],u=[t];if(!i||!o)return e===H?-1:t===H?1:i?-1:o?1:D?ee(D,e)-ee(D,t):0;if(i===o)return a(e,t);for(n=e;n=n.parentNode;)s.unshift(n);for(n=t;n=n.parentNode;)u.unshift(n);for(;s[r]===u[r];)r++;return r?a(s[r],u[r]):s[r]===B?-1:u[r]===B?1:0},H):H},t.matches=function(e,n){return t(e,null,null,n)},t.matchesSelector=function(e,n){if((e.ownerDocument||e)!==H&&L(e),n=n.replace(ce,"='$1']"),w.matchesSelector&&_&&!X[n+" "]&&(!M||!M.test(n))&&(!F||!F.test(n)))try{var r=O.call(e,n);if(r||w.disconnectedMatch||e.document&&11!==e.document.nodeType)return r}catch(i){}return t(n,H,null,[e]).length>0},t.contains=function(e,t){return(e.ownerDocument||e)!==H&&L(e),R(e,t)},t.attr=function(e,t){(e.ownerDocument||e)!==H&&L(e);var n=T.attrHandle[t.toLowerCase()],r=n&&Y.call(T.attrHandle,t.toLowerCase())?n(e,t,!_):void 0;return void 0!==r?r:w.attributes||!_?e.getAttribute(t):(r=e.getAttributeNode(t))&&r.specified?r.value:null},t.error=function(e){throw new Error("Syntax error, unrecognized expression: "+e)},t.uniqueSort=function(e){var t,n=[],r=0,i=0;if(j=!w.detectDuplicates,D=!w.sortStable&&e.slice(0),e.sort(U),j){for(;t=e[i++];)t===e[i]&&(r=n.push(i));for(;r--;)e.splice(n[r],1)}return D=null,e},C=t.getText=function(e){var t,n="",r=0,i=e.nodeType;if(i){if(1===i||9===i||11===i){if("string"==typeof e.textContent)return e.textContent;for(e=e.firstChild;e;e=e.nextSibling)n+=C(e)}else if(3===i||4===i)return e.nodeValue}else for(;t=e[r++];)n+=C(t);return n},T=t.selectors={cacheLength:50,createPseudo:r,match:pe,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(e){return e[1]=e[1].replace(be,we),e[3]=(e[3]||e[4]||e[5]||"").replace(be,we),"~="===e[2]&&(e[3]=" "+e[3]+" "),e.slice(0,4)},CHILD:function(e){return e[1]=e[1].toLowerCase(),"nth"===e[1].slice(0,3)?(e[3]||t.error(e[0]),e[4]=+(e[4]?e[5]+(e[6]||1):2*("even"===e[3]||"odd"===e[3])),e[5]=+(e[7]+e[8]||"odd"===e[3])):e[3]&&t.error(e[0]),e},PSEUDO:function(e){var t,n=!e[6]&&e[2];return pe.CHILD.test(e[0])?null:(e[3]?e[2]=e[4]||e[5]||"":n&&fe.test(n)&&(t=N(n,!0))&&(t=n.indexOf(")",n.length-t)-n.length)&&(e[0]=e[0].slice(0,t),e[2]=n.slice(0,t)),e.slice(0,3))}},filter:{TAG:function(e){var t=e.replace(be,we).toLowerCase();return"*"===e?function(){return!0}:function(e){return e.nodeName&&e.nodeName.toLowerCase()===t}},CLASS:function(e){var t=$[e+" "];return t||(t=new RegExp("(^|"+ne+")"+e+"("+ne+"|$)"))&&$(e,function(e){return t.test("string"==typeof e.className&&e.className||"undefined"!=typeof e.getAttribute&&e.getAttribute("class")||"")})},ATTR:function(e,n,r){return function(i){var o=t.attr(i,e);return null==o?"!="===n:!n||(o+="","="===n?o===r:"!="===n?o!==r:"^="===n?r&&0===o.indexOf(r):"*="===n?r&&o.indexOf(r)>-1:"$="===n?r&&o.slice(-r.length)===r:"~="===n?(" "+o.replace(ae," ")+" ").indexOf(r)>-1:"|="===n&&(o===r||o.slice(0,r.length+1)===r+"-"))}},CHILD:function(e,t,n,r,i){var o="nth"!==e.slice(0,3),a="last"!==e.slice(-4),s="of-type"===t;return 1===r&&0===i?function(e){return!!e.parentNode}:function(t,n,u){var l,c,f,d,p,h,g=o!==a?"nextSibling":"previousSibling",m=t.parentNode,y=s&&t.nodeName.toLowerCase(),v=!u&&!s,x=!1;if(m){if(o){for(;g;){for(d=t;d=d[g];)if(s?d.nodeName.toLowerCase()===y:1===d.nodeType)return!1;h=g="only"===e&&!h&&"nextSibling"}return!0}if(h=[a?m.firstChild:m.lastChild],a&&v){for(d=m,f=d[P]||(d[P]={}),c=f[d.uniqueID]||(f[d.uniqueID]={}), -l=c[e]||[],p=l[0]===W&&l[1],x=p&&l[2],d=p&&m.childNodes[p];d=++p&&d&&d[g]||(x=p=0)||h.pop();)if(1===d.nodeType&&++x&&d===t){c[e]=[W,p,x];break}}else if(v&&(d=t,f=d[P]||(d[P]={}),c=f[d.uniqueID]||(f[d.uniqueID]={}),l=c[e]||[],p=l[0]===W&&l[1],x=p),x===!1)for(;(d=++p&&d&&d[g]||(x=p=0)||h.pop())&&((s?d.nodeName.toLowerCase()!==y:1!==d.nodeType)||!++x||(v&&(f=d[P]||(d[P]={}),c=f[d.uniqueID]||(f[d.uniqueID]={}),c[e]=[W,x]),d!==t)););return x-=i,x===r||x%r===0&&x/r>=0}}},PSEUDO:function(e,n){var i,o=T.pseudos[e]||T.setFilters[e.toLowerCase()]||t.error("unsupported pseudo: "+e);return o[P]?o(n):o.length>1?(i=[e,e,"",n],T.setFilters.hasOwnProperty(e.toLowerCase())?r(function(e,t){for(var r,i=o(e,n),a=i.length;a--;)r=ee(e,i[a]),e[r]=!(t[r]=i[a])}):function(e){return o(e,0,i)}):o}},pseudos:{not:r(function(e){var t=[],n=[],i=k(e.replace(se,"$1"));return i[P]?r(function(e,t,n,r){for(var o,a=i(e,null,r,[]),s=e.length;s--;)(o=a[s])&&(e[s]=!(t[s]=o))}):function(e,r,o){return t[0]=e,i(t,null,o,n),t[0]=null,!n.pop()}}),has:r(function(e){return function(n){return t(e,n).length>0}}),contains:r(function(e){return e=e.replace(be,we),function(t){return(t.textContent||t.innerText||C(t)).indexOf(e)>-1}}),lang:r(function(e){return de.test(e||"")||t.error("unsupported lang: "+e),e=e.replace(be,we).toLowerCase(),function(t){var n;do if(n=_?t.lang:t.getAttribute("xml:lang")||t.getAttribute("lang"))return n=n.toLowerCase(),n===e||0===n.indexOf(e+"-");while((t=t.parentNode)&&1===t.nodeType);return!1}}),target:function(t){var n=e.location&&e.location.hash;return n&&n.slice(1)===t.id},root:function(e){return e===q},focus:function(e){return e===H.activeElement&&(!H.hasFocus||H.hasFocus())&&!!(e.type||e.href||~e.tabIndex)},enabled:function(e){return e.disabled===!1},disabled:function(e){return e.disabled===!0},checked:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&!!e.checked||"option"===t&&!!e.selected},selected:function(e){return e.parentNode&&e.parentNode.selectedIndex,e.selected===!0},empty:function(e){for(e=e.firstChild;e;e=e.nextSibling)if(e.nodeType<6)return!1;return!0},parent:function(e){return!T.pseudos.empty(e)},header:function(e){return ge.test(e.nodeName)},input:function(e){return he.test(e.nodeName)},button:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&"button"===e.type||"button"===t},text:function(e){var t;return"input"===e.nodeName.toLowerCase()&&"text"===e.type&&(null==(t=e.getAttribute("type"))||"text"===t.toLowerCase())},first:l(function(){return[0]}),last:l(function(e,t){return[t-1]}),eq:l(function(e,t,n){return[n<0?n+t:n]}),even:l(function(e,t){for(var n=0;n=0;)e.push(r);return e}),gt:l(function(e,t,n){for(var r=n<0?n+t:n;++r2&&"ID"===(a=o[0]).type&&w.getById&&9===t.nodeType&&_&&T.relative[o[1].type]){if(t=(T.find.ID(a.matches[0].replace(be,we),t)||[])[0],!t)return n;l&&(t=t.parentNode),e=e.slice(o.shift().value.length)}for(i=pe.needsContext.test(e)?0:o.length;i--&&(a=o[i],!T.relative[s=a.type]);)if((u=T.find[s])&&(r=u(a.matches[0].replace(be,we),ve.test(o[0].type)&&c(t.parentNode)||t))){if(o.splice(i,1),e=r.length&&d(o),!e)return Q.apply(n,r),n;break}}return(l||k(e,f))(r,t,!_,n,!t||ve.test(e)&&c(t.parentNode)||t),n},w.sortStable=P.split("").sort(U).join("")===P,w.detectDuplicates=!!j,L(),w.sortDetached=i(function(e){return 1&e.compareDocumentPosition(H.createElement("div"))}),i(function(e){return e.innerHTML="","#"===e.firstChild.getAttribute("href")})||o("type|href|height|width",function(e,t,n){if(!n)return e.getAttribute(t,"type"===t.toLowerCase()?1:2)}),w.attributes&&i(function(e){return e.innerHTML="",e.firstChild.setAttribute("value",""),""===e.firstChild.getAttribute("value")})||o("value",function(e,t,n){if(!n&&"input"===e.nodeName.toLowerCase())return e.defaultValue}),i(function(e){return null==e.getAttribute("disabled")})||o(te,function(e,t,n){var r;if(!n)return e[t]===!0?t.toLowerCase():(r=e.getAttributeNode(t))&&r.specified?r.value:null}),t}(e);pe.find=ve,pe.expr=ve.selectors,pe.expr[":"]=pe.expr.pseudos,pe.uniqueSort=pe.unique=ve.uniqueSort,pe.text=ve.getText,pe.isXMLDoc=ve.isXML,pe.contains=ve.contains;var xe=function(e,t,n){for(var r=[],i=void 0!==n;(e=e[t])&&9!==e.nodeType;)if(1===e.nodeType){if(i&&pe(e).is(n))break;r.push(e)}return r},be=function(e,t){for(var n=[];e;e=e.nextSibling)1===e.nodeType&&e!==t&&n.push(e);return n},we=pe.expr.match.needsContext,Te=/^<([\w-]+)\s*\/?>(?:<\/\1>|)$/,Ce=/^.[^:#\[\.,]*$/;pe.filter=function(e,t,n){var r=t[0];return n&&(e=":not("+e+")"),1===t.length&&1===r.nodeType?pe.find.matchesSelector(r,e)?[r]:[]:pe.find.matches(e,pe.grep(t,function(e){return 1===e.nodeType}))},pe.fn.extend({find:function(e){var t,n=[],r=this,i=r.length;if("string"!=typeof e)return this.pushStack(pe(e).filter(function(){for(t=0;t1?pe.unique(n):n),n.selector=this.selector?this.selector+" "+e:e,n},filter:function(e){return this.pushStack(r(this,e||[],!1))},not:function(e){return this.pushStack(r(this,e||[],!0))},is:function(e){return!!r(this,"string"==typeof e&&we.test(e)?pe(e):e||[],!1).length}});var Ee,Ne=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,ke=pe.fn.init=function(e,t,n){var r,i;if(!e)return this;if(n=n||Ee,"string"==typeof e){if(r="<"===e.charAt(0)&&">"===e.charAt(e.length-1)&&e.length>=3?[null,e,null]:Ne.exec(e),!r||!r[1]&&t)return!t||t.jquery?(t||n).find(e):this.constructor(t).find(e);if(r[1]){if(t=t instanceof pe?t[0]:t,pe.merge(this,pe.parseHTML(r[1],t&&t.nodeType?t.ownerDocument||t:re,!0)),Te.test(r[1])&&pe.isPlainObject(t))for(r in t)pe.isFunction(this[r])?this[r](t[r]):this.attr(r,t[r]);return this}if(i=re.getElementById(r[2]),i&&i.parentNode){if(i.id!==r[2])return Ee.find(e);this.length=1,this[0]=i}return this.context=re,this.selector=e,this}return e.nodeType?(this.context=this[0]=e,this.length=1,this):pe.isFunction(e)?"undefined"!=typeof n.ready?n.ready(e):e(pe):(void 0!==e.selector&&(this.selector=e.selector,this.context=e.context),pe.makeArray(e,this))};ke.prototype=pe.fn,Ee=pe(re);var Se=/^(?:parents|prev(?:Until|All))/,Ae={children:!0,contents:!0,next:!0,prev:!0};pe.fn.extend({has:function(e){var t,n=pe(e,this),r=n.length;return this.filter(function(){for(t=0;t-1:1===n.nodeType&&pe.find.matchesSelector(n,e))){o.push(n);break}return this.pushStack(o.length>1?pe.uniqueSort(o):o)},index:function(e){return e?"string"==typeof e?pe.inArray(this[0],pe(e)):pe.inArray(e.jquery?e[0]:e,this):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(e,t){return this.pushStack(pe.uniqueSort(pe.merge(this.get(),pe(e,t))))},addBack:function(e){return this.add(null==e?this.prevObject:this.prevObject.filter(e))}}),pe.each({parent:function(e){var t=e.parentNode;return t&&11!==t.nodeType?t:null},parents:function(e){return xe(e,"parentNode")},parentsUntil:function(e,t,n){return xe(e,"parentNode",n)},next:function(e){return i(e,"nextSibling")},prev:function(e){return i(e,"previousSibling")},nextAll:function(e){return xe(e,"nextSibling")},prevAll:function(e){return xe(e,"previousSibling")},nextUntil:function(e,t,n){return xe(e,"nextSibling",n)},prevUntil:function(e,t,n){return xe(e,"previousSibling",n)},siblings:function(e){return be((e.parentNode||{}).firstChild,e)},children:function(e){return be(e.firstChild)},contents:function(e){return pe.nodeName(e,"iframe")?e.contentDocument||e.contentWindow.document:pe.merge([],e.childNodes)}},function(e,t){pe.fn[e]=function(n,r){var i=pe.map(this,t,n);return"Until"!==e.slice(-5)&&(r=n),r&&"string"==typeof r&&(i=pe.filter(r,i)),this.length>1&&(Ae[e]||(i=pe.uniqueSort(i)),Se.test(e)&&(i=i.reverse())),this.pushStack(i)}});var De=/\S+/g;pe.Callbacks=function(e){e="string"==typeof e?o(e):pe.extend({},e);var t,n,r,i,a=[],s=[],u=-1,l=function(){for(i=e.once,r=t=!0;s.length;u=-1)for(n=s.shift();++u-1;)a.splice(n,1),n<=u&&u--}),this},has:function(e){return e?pe.inArray(e,a)>-1:a.length>0},empty:function(){return a&&(a=[]),this},disable:function(){return i=s=[],a=n="",this},disabled:function(){return!a},lock:function(){return i=!0,n||c.disable(),this},locked:function(){return!!i},fireWith:function(e,n){return i||(n=n||[],n=[e,n.slice?n.slice():n],s.push(n),t||l()),this},fire:function(){return c.fireWith(this,arguments),this},fired:function(){return!!r}};return c},pe.extend({Deferred:function(e){var t=[["resolve","done",pe.Callbacks("once memory"),"resolved"],["reject","fail",pe.Callbacks("once memory"),"rejected"],["notify","progress",pe.Callbacks("memory")]],n="pending",r={state:function(){return n},always:function(){return i.done(arguments).fail(arguments),this},then:function(){var e=arguments;return pe.Deferred(function(n){pe.each(t,function(t,o){var a=pe.isFunction(e[t])&&e[t];i[o[1]](function(){var e=a&&a.apply(this,arguments);e&&pe.isFunction(e.promise)?e.promise().progress(n.notify).done(n.resolve).fail(n.reject):n[o[0]+"With"](this===r?n.promise():this,a?[e]:arguments)})}),e=null}).promise()},promise:function(e){return null!=e?pe.extend(e,r):r}},i={};return r.pipe=r.then,pe.each(t,function(e,o){var a=o[2],s=o[3];r[o[1]]=a.add,s&&a.add(function(){n=s},t[1^e][2].disable,t[2][2].lock),i[o[0]]=function(){return i[o[0]+"With"](this===i?r:this,arguments),this},i[o[0]+"With"]=a.fireWith}),r.promise(i),e&&e.call(i,i),i},when:function(e){var t,n,r,i=0,o=ie.call(arguments),a=o.length,s=1!==a||e&&pe.isFunction(e.promise)?a:0,u=1===s?e:pe.Deferred(),l=function(e,n,r){return function(i){n[e]=this,r[e]=arguments.length>1?ie.call(arguments):i,r===t?u.notifyWith(n,r):--s||u.resolveWith(n,r)}};if(a>1)for(t=new Array(a),n=new Array(a),r=new Array(a);i0||(je.resolveWith(re,[pe]),pe.fn.triggerHandler&&(pe(re).triggerHandler("ready"),pe(re).off("ready"))))}}),pe.ready.promise=function(t){if(!je)if(je=pe.Deferred(),"complete"===re.readyState||"loading"!==re.readyState&&!re.documentElement.doScroll)e.setTimeout(pe.ready);else if(re.addEventListener)re.addEventListener("DOMContentLoaded",s),e.addEventListener("load",s);else{re.attachEvent("onreadystatechange",s),e.attachEvent("onload",s);var n=!1;try{n=null==e.frameElement&&re.documentElement}catch(r){}n&&n.doScroll&&!function i(){if(!pe.isReady){try{n.doScroll("left")}catch(t){return e.setTimeout(i,50)}a(),pe.ready()}}()}return je.promise(t)},pe.ready.promise();var Le;for(Le in pe(fe))break;fe.ownFirst="0"===Le,fe.inlineBlockNeedsLayout=!1,pe(function(){var e,t,n,r;n=re.getElementsByTagName("body")[0],n&&n.style&&(t=re.createElement("div"),r=re.createElement("div"),r.style.cssText="position:absolute;border:0;width:0;height:0;top:0;left:-9999px",n.appendChild(r).appendChild(t),"undefined"!=typeof t.style.zoom&&(t.style.cssText="display:inline;margin:0;border:0;padding:1px;width:1px;zoom:1",fe.inlineBlockNeedsLayout=e=3===t.offsetWidth,e&&(n.style.zoom=1)),n.removeChild(r))}),function(){var e=re.createElement("div");fe.deleteExpando=!0;try{delete e.test}catch(t){fe.deleteExpando=!1}e=null}();var He=function(e){var t=pe.noData[(e.nodeName+" ").toLowerCase()],n=+e.nodeType||1;return(1===n||9===n)&&(!t||t!==!0&&e.getAttribute("classid")===t)},qe=/^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,_e=/([A-Z])/g;pe.extend({cache:{},noData:{"applet ":!0,"embed ":!0,"object ":"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"},hasData:function(e){return e=e.nodeType?pe.cache[e[pe.expando]]:e[pe.expando],!!e&&!l(e)},data:function(e,t,n){return c(e,t,n)},removeData:function(e,t){return f(e,t)},_data:function(e,t,n){return c(e,t,n,!0)},_removeData:function(e,t){return f(e,t,!0)}}),pe.fn.extend({data:function(e,t){var n,r,i,o=this[0],a=o&&o.attributes;if(void 0===e){if(this.length&&(i=pe.data(o),1===o.nodeType&&!pe._data(o,"parsedAttrs"))){for(n=a.length;n--;)a[n]&&(r=a[n].name,0===r.indexOf("data-")&&(r=pe.camelCase(r.slice(5)),u(o,r,i[r])));pe._data(o,"parsedAttrs",!0)}return i}return"object"==typeof e?this.each(function(){pe.data(this,e)}):arguments.length>1?this.each(function(){pe.data(this,e,t)}):o?u(o,e,pe.data(o,e)):void 0},removeData:function(e){return this.each(function(){pe.removeData(this,e)})}}),pe.extend({queue:function(e,t,n){var r;if(e)return t=(t||"fx")+"queue",r=pe._data(e,t),n&&(!r||pe.isArray(n)?r=pe._data(e,t,pe.makeArray(n)):r.push(n)),r||[]},dequeue:function(e,t){t=t||"fx";var n=pe.queue(e,t),r=n.length,i=n.shift(),o=pe._queueHooks(e,t),a=function(){pe.dequeue(e,t)};"inprogress"===i&&(i=n.shift(),r--),i&&("fx"===t&&n.unshift("inprogress"),delete o.stop,i.call(e,a,o)),!r&&o&&o.empty.fire()},_queueHooks:function(e,t){var n=t+"queueHooks";return pe._data(e,n)||pe._data(e,n,{empty:pe.Callbacks("once memory").add(function(){pe._removeData(e,t+"queue"),pe._removeData(e,n)})})}}),pe.fn.extend({queue:function(e,t){var n=2;return"string"!=typeof e&&(t=e,e="fx",n--),arguments.length
    a",fe.leadingWhitespace=3===e.firstChild.nodeType,fe.tbody=!e.getElementsByTagName("tbody").length,fe.htmlSerialize=!!e.getElementsByTagName("link").length,fe.html5Clone="<:nav>"!==re.createElement("nav").cloneNode(!0).outerHTML,n.type="checkbox",n.checked=!0,t.appendChild(n),fe.appendChecked=n.checked,e.innerHTML="",fe.noCloneChecked=!!e.cloneNode(!0).lastChild.defaultValue,t.appendChild(e),n=re.createElement("input"),n.setAttribute("type","radio"),n.setAttribute("checked","checked"),n.setAttribute("name","t"),e.appendChild(n),fe.checkClone=e.cloneNode(!0).cloneNode(!0).lastChild.checked,fe.noCloneEvent=!!e.addEventListener,e[pe.expando]=1,fe.attributes=!e.getAttribute(pe.expando)}();var Xe={option:[1,""],legend:[1,"
    ","
    "],area:[1,"",""],param:[1,"",""],thead:[1,"","
    "],tr:[2,"","
    "],col:[2,"","
    "],td:[3,"","
    "],_default:fe.htmlSerialize?[0,"",""]:[1,"X
    ","
    "]};Xe.optgroup=Xe.option,Xe.tbody=Xe.tfoot=Xe.colgroup=Xe.caption=Xe.thead,Xe.th=Xe.td;var Ue=/<|&#?\w+;/,Ve=/-1&&(h=p.split("."),p=h.shift(),h.sort()),a=p.indexOf(":")<0&&"on"+p,t=t[pe.expando]?t:new pe.Event(p,"object"==typeof t&&t),t.isTrigger=i?2:3,t.namespace=h.join("."),t.rnamespace=t.namespace?new RegExp("(^|\\.)"+h.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,t.result=void 0,t.target||(t.target=r),n=null==n?[t]:pe.makeArray(n,[t]),l=pe.event.special[p]||{},i||!l.trigger||l.trigger.apply(r,n)!==!1)){if(!i&&!l.noBubble&&!pe.isWindow(r)){for(u=l.delegateType||p,Ke.test(u+p)||(s=s.parentNode);s;s=s.parentNode)d.push(s),c=s;c===(r.ownerDocument||re)&&d.push(c.defaultView||c.parentWindow||e)}for(f=0;(s=d[f++])&&!t.isPropagationStopped();)t.type=f>1?u:l.bindType||p,o=(pe._data(s,"events")||{})[t.type]&&pe._data(s,"handle"),o&&o.apply(s,n),o=a&&s[a],o&&o.apply&&He(s)&&(t.result=o.apply(s,n),t.result===!1&&t.preventDefault());if(t.type=p,!i&&!t.isDefaultPrevented()&&(!l._default||l._default.apply(d.pop(),n)===!1)&&He(r)&&a&&r[p]&&!pe.isWindow(r)){c=r[a],c&&(r[a]=null),pe.event.triggered=p;try{r[p]()}catch(g){}pe.event.triggered=void 0,c&&(r[a]=c)}return t.result}},dispatch:function(e){e=pe.event.fix(e);var t,n,r,i,o,a=[],s=ie.call(arguments),u=(pe._data(this,"events")||{})[e.type]||[],l=pe.event.special[e.type]||{};if(s[0]=e,e.delegateTarget=this,!l.preDispatch||l.preDispatch.call(this,e)!==!1){for(a=pe.event.handlers.call(this,e,u),t=0;(i=a[t++])&&!e.isPropagationStopped();)for(e.currentTarget=i.elem,n=0;(o=i.handlers[n++])&&!e.isImmediatePropagationStopped();)e.rnamespace&&!e.rnamespace.test(o.namespace)||(e.handleObj=o,e.data=o.data,r=((pe.event.special[o.origType]||{}).handle||o.handler).apply(i.elem,s),void 0!==r&&(e.result=r)===!1&&(e.preventDefault(),e.stopPropagation()));return l.postDispatch&&l.postDispatch.call(this,e),e.result}},handlers:function(e,t){var n,r,i,o,a=[],s=t.delegateCount,u=e.target;if(s&&u.nodeType&&("click"!==e.type||isNaN(e.button)||e.button<1))for(;u!=this;u=u.parentNode||this)if(1===u.nodeType&&(u.disabled!==!0||"click"!==e.type)){for(r=[],n=0;n-1:pe.find(i,this,null,[u]).length),r[i]&&r.push(o);r.length&&a.push({elem:u,handlers:r})}return s]","i"),tt=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:-]+)[^>]*)\/>/gi,nt=/\s*$/g,at=p(re),st=at.appendChild(re.createElement("div"));pe.extend({htmlPrefilter:function(e){return e.replace(tt,"<$1>")},clone:function(e,t,n){var r,i,o,a,s,u=pe.contains(e.ownerDocument,e);if(fe.html5Clone||pe.isXMLDoc(e)||!et.test("<"+e.nodeName+">")?o=e.cloneNode(!0):(st.innerHTML=e.outerHTML,st.removeChild(o=st.firstChild)),!(fe.noCloneEvent&&fe.noCloneChecked||1!==e.nodeType&&11!==e.nodeType||pe.isXMLDoc(e)))for(r=h(o),s=h(e),a=0;null!=(i=s[a]);++a)r[a]&&k(i,r[a]);if(t)if(n)for(s=s||h(e),r=r||h(o),a=0;null!=(i=s[a]);a++)N(i,r[a]);else N(e,o);return r=h(o,"script"),r.length>0&&g(r,!u&&h(e,"script")),r=s=i=null,o},cleanData:function(e,t){for(var n,r,i,o,a=0,s=pe.expando,u=pe.cache,l=fe.attributes,c=pe.event.special;null!=(n=e[a]);a++)if((t||He(n))&&(i=n[s],o=i&&u[i])){if(o.events)for(r in o.events)c[r]?pe.event.remove(n,r):pe.removeEvent(n,r,o.handle);u[i]&&(delete u[i],l||"undefined"==typeof n.removeAttribute?n[s]=void 0:n.removeAttribute(s),ne.push(i))}}}),pe.fn.extend({domManip:S,detach:function(e){return A(this,e,!0)},remove:function(e){return A(this,e)},text:function(e){return Pe(this,function(e){return void 0===e?pe.text(this):this.empty().append((this[0]&&this[0].ownerDocument||re).createTextNode(e))},null,e,arguments.length)},append:function(){return S(this,arguments,function(e){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var t=T(this,e);t.appendChild(e)}})},prepend:function(){return S(this,arguments,function(e){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var t=T(this,e);t.insertBefore(e,t.firstChild)}})},before:function(){return S(this,arguments,function(e){this.parentNode&&this.parentNode.insertBefore(e,this)})},after:function(){return S(this,arguments,function(e){this.parentNode&&this.parentNode.insertBefore(e,this.nextSibling)})},empty:function(){for(var e,t=0;null!=(e=this[t]);t++){for(1===e.nodeType&&pe.cleanData(h(e,!1));e.firstChild;)e.removeChild(e.firstChild);e.options&&pe.nodeName(e,"select")&&(e.options.length=0)}return this},clone:function(e,t){return e=null!=e&&e,t=null==t?e:t,this.map(function(){return pe.clone(this,e,t)})},html:function(e){return Pe(this,function(e){var t=this[0]||{},n=0,r=this.length;if(void 0===e)return 1===t.nodeType?t.innerHTML.replace(Ze,""):void 0;if("string"==typeof e&&!nt.test(e)&&(fe.htmlSerialize||!et.test(e))&&(fe.leadingWhitespace||!$e.test(e))&&!Xe[(We.exec(e)||["",""])[1].toLowerCase()]){e=pe.htmlPrefilter(e);try{for(;nt",t=l.getElementsByTagName("td"),t[0].style.cssText="margin:0;border:0;padding:0;display:none",o=0===t[0].offsetHeight,o&&(t[0].style.display="",t[1].style.display="none",o=0===t[0].offsetHeight)),f.removeChild(u)}var n,r,i,o,a,s,u=re.createElement("div"),l=re.createElement("div");l.style&&(l.style.cssText="float:left;opacity:.5",fe.opacity="0.5"===l.style.opacity,fe.cssFloat=!!l.style.cssFloat,l.style.backgroundClip="content-box",l.cloneNode(!0).style.backgroundClip="",fe.clearCloneStyle="content-box"===l.style.backgroundClip,u=re.createElement("div"),u.style.cssText="border:0;width:8px;height:0;top:0;left:-9999px;padding:0;margin-top:1px;position:absolute",l.innerHTML="",u.appendChild(l),fe.boxSizing=""===l.style.boxSizing||""===l.style.MozBoxSizing||""===l.style.WebkitBoxSizing,pe.extend(fe,{reliableHiddenOffsets:function(){return null==n&&t(),o},boxSizingReliable:function(){return null==n&&t(),i},pixelMarginRight:function(){return null==n&&t(),r},pixelPosition:function(){return null==n&&t(),n},reliableMarginRight:function(){return null==n&&t(),a},reliableMarginLeft:function(){return null==n&&t(),s}}))}();var ht,gt,mt=/^(top|right|bottom|left)$/;e.getComputedStyle?(ht=function(t){var n=t.ownerDocument.defaultView;return n&&n.opener||(n=e),n.getComputedStyle(t)},gt=function(e,t,n){var r,i,o,a,s=e.style;return n=n||ht(e),a=n?n.getPropertyValue(t)||n[t]:void 0,""!==a&&void 0!==a||pe.contains(e.ownerDocument,e)||(a=pe.style(e,t)),n&&!fe.pixelMarginRight()&&ft.test(a)&&ct.test(t)&&(r=s.width,i=s.minWidth,o=s.maxWidth,s.minWidth=s.maxWidth=s.width=a,a=n.width,s.width=r,s.minWidth=i,s.maxWidth=o),void 0===a?a:a+""}):pt.currentStyle&&(ht=function(e){return e.currentStyle},gt=function(e,t,n){var r,i,o,a,s=e.style;return n=n||ht(e),a=n?n[t]:void 0,null==a&&s&&s[t]&&(a=s[t]),ft.test(a)&&!mt.test(t)&&(r=s.left,i=e.runtimeStyle,o=i&&i.left,o&&(i.left=e.currentStyle.left),s.left="fontSize"===t?"1em":a,a=s.pixelLeft+"px",s.left=r,o&&(i.left=o)),void 0===a?a:a+""||"auto"});var yt=/alpha\([^)]*\)/i,vt=/opacity\s*=\s*([^)]*)/i,xt=/^(none|table(?!-c[ea]).+)/,bt=new RegExp("^("+Fe+")(.*)$","i"),wt={position:"absolute",visibility:"hidden",display:"block"},Tt={letterSpacing:"0",fontWeight:"400"},Ct=["Webkit","O","Moz","ms"],Et=re.createElement("div").style;pe.extend({cssHooks:{opacity:{get:function(e,t){if(t){var n=gt(e,"opacity");return""===n?"1":n}}}},cssNumber:{animationIterationCount:!0,columnCount:!0,fillOpacity:!0,flexGrow:!0,flexShrink:!0,fontWeight:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{"float":fe.cssFloat?"cssFloat":"styleFloat"},style:function(e,t,n,r){if(e&&3!==e.nodeType&&8!==e.nodeType&&e.style){var i,o,a,s=pe.camelCase(t),u=e.style;if(t=pe.cssProps[s]||(pe.cssProps[s]=H(s)||s),a=pe.cssHooks[t]||pe.cssHooks[s],void 0===n)return a&&"get"in a&&void 0!==(i=a.get(e,!1,r))?i:u[t];if(o=typeof n,"string"===o&&(i=Me.exec(n))&&i[1]&&(n=d(e,t,i),o="number"),null!=n&&n===n&&("number"===o&&(n+=i&&i[3]||(pe.cssNumber[s]?"":"px")),fe.clearCloneStyle||""!==n||0!==t.indexOf("background")||(u[t]="inherit"),!(a&&"set"in a&&void 0===(n=a.set(e,n,r)))))try{u[t]=n}catch(l){}}},css:function(e,t,n,r){var i,o,a,s=pe.camelCase(t);return t=pe.cssProps[s]||(pe.cssProps[s]=H(s)||s),a=pe.cssHooks[t]||pe.cssHooks[s],a&&"get"in a&&(o=a.get(e,!0,n)),void 0===o&&(o=gt(e,t,r)),"normal"===o&&t in Tt&&(o=Tt[t]),""===n||n?(i=parseFloat(o),n===!0||isFinite(i)?i||0:o):o}}),pe.each(["height","width"],function(e,t){pe.cssHooks[t]={get:function(e,n,r){if(n)return xt.test(pe.css(e,"display"))&&0===e.offsetWidth?dt(e,wt,function(){return M(e,t,r)}):M(e,t,r)},set:function(e,n,r){var i=r&&ht(e);return _(e,n,r?F(e,t,r,fe.boxSizing&&"border-box"===pe.css(e,"boxSizing",!1,i),i):0)}}}),fe.opacity||(pe.cssHooks.opacity={get:function(e,t){return vt.test((t&&e.currentStyle?e.currentStyle.filter:e.style.filter)||"")?.01*parseFloat(RegExp.$1)+"":t?"1":""},set:function(e,t){var n=e.style,r=e.currentStyle,i=pe.isNumeric(t)?"alpha(opacity="+100*t+")":"",o=r&&r.filter||n.filter||"";n.zoom=1,(t>=1||""===t)&&""===pe.trim(o.replace(yt,""))&&n.removeAttribute&&(n.removeAttribute("filter"),""===t||r&&!r.filter)||(n.filter=yt.test(o)?o.replace(yt,i):o+" "+i)}}),pe.cssHooks.marginRight=L(fe.reliableMarginRight,function(e,t){if(t)return dt(e,{display:"inline-block"},gt,[e,"marginRight"])}),pe.cssHooks.marginLeft=L(fe.reliableMarginLeft,function(e,t){if(t)return(parseFloat(gt(e,"marginLeft"))||(pe.contains(e.ownerDocument,e)?e.getBoundingClientRect().left-dt(e,{marginLeft:0},function(){return e.getBoundingClientRect().left}):0))+"px"}),pe.each({margin:"",padding:"",border:"Width"},function(e,t){pe.cssHooks[e+t]={expand:function(n){for(var r=0,i={},o="string"==typeof n?n.split(" "):[n];r<4;r++)i[e+Oe[r]+t]=o[r]||o[r-2]||o[0];return i}},ct.test(e)||(pe.cssHooks[e+t].set=_)}),pe.fn.extend({css:function(e,t){return Pe(this,function(e,t,n){var r,i,o={},a=0;if(pe.isArray(t)){for(r=ht(e),i=t.length;a1)},show:function(){return q(this,!0)},hide:function(){return q(this)},toggle:function(e){return"boolean"==typeof e?e?this.show():this.hide():this.each(function(){Re(this)?pe(this).show():pe(this).hide()})}}),pe.Tween=O,O.prototype={constructor:O,init:function(e,t,n,r,i,o){this.elem=e,this.prop=n,this.easing=i||pe.easing._default,this.options=t,this.start=this.now=this.cur(),this.end=r,this.unit=o||(pe.cssNumber[n]?"":"px")},cur:function(){var e=O.propHooks[this.prop];return e&&e.get?e.get(this):O.propHooks._default.get(this)},run:function(e){var t,n=O.propHooks[this.prop];return this.options.duration?this.pos=t=pe.easing[this.easing](e,this.options.duration*e,0,1,this.options.duration):this.pos=t=e,this.now=(this.end-this.start)*t+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),n&&n.set?n.set(this):O.propHooks._default.set(this),this}},O.prototype.init.prototype=O.prototype,O.propHooks={_default:{get:function(e){var t;return 1!==e.elem.nodeType||null!=e.elem[e.prop]&&null==e.elem.style[e.prop]?e.elem[e.prop]:(t=pe.css(e.elem,e.prop,""),t&&"auto"!==t?t:0)},set:function(e){pe.fx.step[e.prop]?pe.fx.step[e.prop](e):1!==e.elem.nodeType||null==e.elem.style[pe.cssProps[e.prop]]&&!pe.cssHooks[e.prop]?e.elem[e.prop]=e.now:pe.style(e.elem,e.prop,e.now+e.unit)}}},O.propHooks.scrollTop=O.propHooks.scrollLeft={set:function(e){e.elem.nodeType&&e.elem.parentNode&&(e.elem[e.prop]=e.now)}},pe.easing={linear:function(e){return e},swing:function(e){return.5-Math.cos(e*Math.PI)/2},_default:"swing"},pe.fx=O.prototype.init,pe.fx.step={};var Nt,kt,St=/^(?:toggle|show|hide)$/,At=/queueHooks$/;pe.Animation=pe.extend($,{tweeners:{"*":[function(e,t){var n=this.createTween(e,t);return d(n.elem,e,Me.exec(t),n),n}]},tweener:function(e,t){pe.isFunction(e)?(t=e,e=["*"]):e=e.match(De);for(var n,r=0,i=e.length;r
    a",e=n.getElementsByTagName("a")[0],t.setAttribute("type","checkbox"),n.appendChild(t),e=n.getElementsByTagName("a")[0],e.style.cssText="top:1px",fe.getSetAttribute="t"!==n.className,fe.style=/top/.test(e.getAttribute("style")),fe.hrefNormalized="/a"===e.getAttribute("href"),fe.checkOn=!!t.value,fe.optSelected=i.selected,fe.enctype=!!re.createElement("form").enctype,r.disabled=!0,fe.optDisabled=!i.disabled,t=re.createElement("input"),t.setAttribute("value",""),fe.input=""===t.getAttribute("value"),t.value="t",t.setAttribute("type","radio"),fe.radioValue="t"===t.value}();var Dt=/\r/g,jt=/[\x20\t\r\n\f]+/g;pe.fn.extend({val:function(e){var t,n,r,i=this[0];{if(arguments.length)return r=pe.isFunction(e),this.each(function(n){var i;1===this.nodeType&&(i=r?e.call(this,n,pe(this).val()):e,null==i?i="":"number"==typeof i?i+="":pe.isArray(i)&&(i=pe.map(i,function(e){return null==e?"":e+""})),t=pe.valHooks[this.type]||pe.valHooks[this.nodeName.toLowerCase()],t&&"set"in t&&void 0!==t.set(this,i,"value")||(this.value=i))});if(i)return t=pe.valHooks[i.type]||pe.valHooks[i.nodeName.toLowerCase()],t&&"get"in t&&void 0!==(n=t.get(i,"value"))?n:(n=i.value,"string"==typeof n?n.replace(Dt,""):null==n?"":n)}}}),pe.extend({valHooks:{option:{get:function(e){var t=pe.find.attr(e,"value");return null!=t?t:pe.trim(pe.text(e)).replace(jt," ")}},select:{get:function(e){for(var t,n,r=e.options,i=e.selectedIndex,o="select-one"===e.type||i<0,a=o?null:[],s=o?i+1:r.length,u=i<0?s:o?i:0;u-1)try{r.selected=n=!0}catch(s){r.scrollHeight}else r.selected=!1;return n||(e.selectedIndex=-1),i}}}}),pe.each(["radio","checkbox"],function(){pe.valHooks[this]={set:function(e,t){if(pe.isArray(t))return e.checked=pe.inArray(pe(e).val(),t)>-1}},fe.checkOn||(pe.valHooks[this].get=function(e){return null===e.getAttribute("value")?"on":e.value})});var Lt,Ht,qt=pe.expr.attrHandle,_t=/^(?:checked|selected)$/i,Ft=fe.getSetAttribute,Mt=fe.input;pe.fn.extend({attr:function(e,t){return Pe(this,pe.attr,e,t,arguments.length>1)},removeAttr:function(e){return this.each(function(){pe.removeAttr(this,e)})}}),pe.extend({attr:function(e,t,n){var r,i,o=e.nodeType;if(3!==o&&8!==o&&2!==o)return"undefined"==typeof e.getAttribute?pe.prop(e,t,n):(1===o&&pe.isXMLDoc(e)||(t=t.toLowerCase(),i=pe.attrHooks[t]||(pe.expr.match.bool.test(t)?Ht:Lt)),void 0!==n?null===n?void pe.removeAttr(e,t):i&&"set"in i&&void 0!==(r=i.set(e,n,t))?r:(e.setAttribute(t,n+""),n):i&&"get"in i&&null!==(r=i.get(e,t))?r:(r=pe.find.attr(e,t),null==r?void 0:r))},attrHooks:{type:{set:function(e,t){if(!fe.radioValue&&"radio"===t&&pe.nodeName(e,"input")){var n=e.value;return e.setAttribute("type",t),n&&(e.value=n),t}}}},removeAttr:function(e,t){var n,r,i=0,o=t&&t.match(De);if(o&&1===e.nodeType)for(;n=o[i++];)r=pe.propFix[n]||n,pe.expr.match.bool.test(n)?Mt&&Ft||!_t.test(n)?e[r]=!1:e[pe.camelCase("default-"+n)]=e[r]=!1:pe.attr(e,n,""),e.removeAttribute(Ft?n:r)}}),Ht={set:function(e,t,n){return t===!1?pe.removeAttr(e,n):Mt&&Ft||!_t.test(n)?e.setAttribute(!Ft&&pe.propFix[n]||n,n):e[pe.camelCase("default-"+n)]=e[n]=!0,n}},pe.each(pe.expr.match.bool.source.match(/\w+/g),function(e,t){var n=qt[t]||pe.find.attr;Mt&&Ft||!_t.test(t)?qt[t]=function(e,t,r){var i,o;return r||(o=qt[t],qt[t]=i,i=null!=n(e,t,r)?t.toLowerCase():null,qt[t]=o),i}:qt[t]=function(e,t,n){if(!n)return e[pe.camelCase("default-"+t)]?t.toLowerCase():null}}),Mt&&Ft||(pe.attrHooks.value={set:function(e,t,n){return pe.nodeName(e,"input")?void(e.defaultValue=t):Lt&&Lt.set(e,t,n)}}),Ft||(Lt={set:function(e,t,n){var r=e.getAttributeNode(n);if(r||e.setAttributeNode(r=e.ownerDocument.createAttribute(n)),r.value=t+="","value"===n||t===e.getAttribute(n))return t}},qt.id=qt.name=qt.coords=function(e,t,n){var r;if(!n)return(r=e.getAttributeNode(t))&&""!==r.value?r.value:null},pe.valHooks.button={get:function(e,t){var n=e.getAttributeNode(t);if(n&&n.specified)return n.value},set:Lt.set},pe.attrHooks.contenteditable={set:function(e,t,n){Lt.set(e,""!==t&&t,n)}},pe.each(["width","height"],function(e,t){pe.attrHooks[t]={set:function(e,n){if(""===n)return e.setAttribute(t,"auto"),n}}})),fe.style||(pe.attrHooks.style={get:function(e){return e.style.cssText||void 0},set:function(e,t){return e.style.cssText=t+""}});var Ot=/^(?:input|select|textarea|button|object)$/i,Rt=/^(?:a|area)$/i;pe.fn.extend({prop:function(e,t){return Pe(this,pe.prop,e,t,arguments.length>1)},removeProp:function(e){return e=pe.propFix[e]||e,this.each(function(){try{this[e]=void 0,delete this[e]}catch(t){}})}}),pe.extend({prop:function(e,t,n){var r,i,o=e.nodeType;if(3!==o&&8!==o&&2!==o)return 1===o&&pe.isXMLDoc(e)||(t=pe.propFix[t]||t,i=pe.propHooks[t]),void 0!==n?i&&"set"in i&&void 0!==(r=i.set(e,n,t))?r:e[t]=n:i&&"get"in i&&null!==(r=i.get(e,t))?r:e[t]},propHooks:{tabIndex:{get:function(e){var t=pe.find.attr(e,"tabindex");return t?parseInt(t,10):Ot.test(e.nodeName)||Rt.test(e.nodeName)&&e.href?0:-1}}},propFix:{"for":"htmlFor","class":"className"}}),fe.hrefNormalized||pe.each(["href","src"],function(e,t){pe.propHooks[t]={get:function(e){return e.getAttribute(t,4)}}}),fe.optSelected||(pe.propHooks.selected={get:function(e){var t=e.parentNode;return t&&(t.selectedIndex,t.parentNode&&t.parentNode.selectedIndex),null},set:function(e){var t=e.parentNode;t&&(t.selectedIndex,t.parentNode&&t.parentNode.selectedIndex)}}),pe.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],function(){pe.propFix[this.toLowerCase()]=this}),fe.enctype||(pe.propFix.enctype="encoding");var Pt=/[\t\r\n\f]/g;pe.fn.extend({addClass:function(e){var t,n,r,i,o,a,s,u=0;if(pe.isFunction(e))return this.each(function(t){pe(this).addClass(e.call(this,t,z(this)))});if("string"==typeof e&&e)for(t=e.match(De)||[];n=this[u++];)if(i=z(n),r=1===n.nodeType&&(" "+i+" ").replace(Pt," ")){for(a=0;o=t[a++];)r.indexOf(" "+o+" ")<0&&(r+=o+" ");s=pe.trim(r),i!==s&&pe.attr(n,"class",s)}return this},removeClass:function(e){var t,n,r,i,o,a,s,u=0;if(pe.isFunction(e))return this.each(function(t){pe(this).removeClass(e.call(this,t,z(this)))});if(!arguments.length)return this.attr("class","");if("string"==typeof e&&e)for(t=e.match(De)||[];n=this[u++];)if(i=z(n),r=1===n.nodeType&&(" "+i+" ").replace(Pt," ")){for(a=0;o=t[a++];)for(;r.indexOf(" "+o+" ")>-1;)r=r.replace(" "+o+" "," ");s=pe.trim(r),i!==s&&pe.attr(n,"class",s)}return this},toggleClass:function(e,t){var n=typeof e;return"boolean"==typeof t&&"string"===n?t?this.addClass(e):this.removeClass(e):pe.isFunction(e)?this.each(function(n){pe(this).toggleClass(e.call(this,n,z(this),t),t)}):this.each(function(){var t,r,i,o;if("string"===n)for(r=0,i=pe(this),o=e.match(De)||[];t=o[r++];)i.hasClass(t)?i.removeClass(t):i.addClass(t);else void 0!==e&&"boolean"!==n||(t=z(this),t&&pe._data(this,"__className__",t),pe.attr(this,"class",t||e===!1?"":pe._data(this,"__className__")||""))})},hasClass:function(e){var t,n,r=0;for(t=" "+e+" ";n=this[r++];)if(1===n.nodeType&&(" "+z(n)+" ").replace(Pt," ").indexOf(t)>-1)return!0;return!1}}),pe.each("blur focus focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup error contextmenu".split(" "),function(e,t){pe.fn[t]=function(e,n){return arguments.length>0?this.on(t,null,e,n):this.trigger(t)}}),pe.fn.extend({hover:function(e,t){return this.mouseenter(e).mouseleave(t||e)}});var Bt=e.location,Wt=pe.now(),It=/\?/,$t=/(,)|(\[|{)|(}|])|"(?:[^"\\\r\n]|\\["\\\/bfnrt]|\\u[\da-fA-F]{4})*"\s*:?|true|false|null|-?(?!0\d)\d+(?:\.\d+|)(?:[eE][+-]?\d+|)/g;pe.parseJSON=function(t){if(e.JSON&&e.JSON.parse)return e.JSON.parse(t+"");var n,r=null,i=pe.trim(t+"");return i&&!pe.trim(i.replace($t,function(e,t,i,o){return n&&t&&(r=0),0===r?e:(n=i||t,r+=!o-!i,"")}))?Function("return "+i)():pe.error("Invalid JSON: "+t)},pe.parseXML=function(t){var n,r;if(!t||"string"!=typeof t)return null;try{e.DOMParser?(r=new e.DOMParser,n=r.parseFromString(t,"text/xml")):(n=new e.ActiveXObject("Microsoft.XMLDOM"),n.async="false",n.loadXML(t))}catch(i){n=void 0}return n&&n.documentElement&&!n.getElementsByTagName("parsererror").length||pe.error("Invalid XML: "+t),n};var zt=/#.*$/,Xt=/([?&])_=[^&]*/,Ut=/^(.*?):[ \t]*([^\r\n]*)\r?$/gm,Vt=/^(?:about|app|app-storage|.+-extension|file|res|widget):$/,Yt=/^(?:GET|HEAD)$/,Jt=/^\/\//,Gt=/^([\w.+-]+:)(?:\/\/(?:[^\/?#]*@|)([^\/?#:]*)(?::(\d+)|)|)/,Kt={},Qt={},Zt="*/".concat("*"),en=Bt.href,tn=Gt.exec(en.toLowerCase())||[];pe.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:en,type:"GET",isLocal:Vt.test(tn[1]),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":Zt,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/\bxml\b/,html:/\bhtml/,json:/\bjson\b/},responseFields:{xml:"responseXML",text:"responseText",json:"responseJSON"},converters:{"* text":String,"text html":!0,"text json":pe.parseJSON,"text xml":pe.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(e,t){return t?V(V(e,pe.ajaxSettings),t):V(pe.ajaxSettings,e)},ajaxPrefilter:X(Kt),ajaxTransport:X(Qt),ajax:function(t,n){function r(t,n,r,i){var o,f,v,x,w,C=n;2!==b&&(b=2,u&&e.clearTimeout(u),c=void 0,s=i||"",T.readyState=t>0?4:0,o=t>=200&&t<300||304===t,r&&(x=Y(d,T,r)),x=J(d,x,T,o),o?(d.ifModified&&(w=T.getResponseHeader("Last-Modified"),w&&(pe.lastModified[a]=w),w=T.getResponseHeader("etag"),w&&(pe.etag[a]=w)),204===t||"HEAD"===d.type?C="nocontent":304===t?C="notmodified":(C=x.state,f=x.data,v=x.error,o=!v)):(v=C,!t&&C||(C="error",t<0&&(t=0))),T.status=t,T.statusText=(n||C)+"",o?g.resolveWith(p,[f,C,T]):g.rejectWith(p,[T,C,v]),T.statusCode(y),y=void 0,l&&h.trigger(o?"ajaxSuccess":"ajaxError",[T,d,o?f:v]),m.fireWith(p,[T,C]),l&&(h.trigger("ajaxComplete",[T,d]),--pe.active||pe.event.trigger("ajaxStop")))}"object"==typeof t&&(n=t,t=void 0),n=n||{};var i,o,a,s,u,l,c,f,d=pe.ajaxSetup({},n),p=d.context||d,h=d.context&&(p.nodeType||p.jquery)?pe(p):pe.event,g=pe.Deferred(),m=pe.Callbacks("once memory"),y=d.statusCode||{},v={},x={},b=0,w="canceled",T={readyState:0,getResponseHeader:function(e){var t;if(2===b){if(!f)for(f={};t=Ut.exec(s);)f[t[1].toLowerCase()]=t[2];t=f[e.toLowerCase()]}return null==t?null:t},getAllResponseHeaders:function(){return 2===b?s:null},setRequestHeader:function(e,t){var n=e.toLowerCase();return b||(e=x[n]=x[n]||e,v[e]=t),this},overrideMimeType:function(e){return b||(d.mimeType=e),this},statusCode:function(e){var t;if(e)if(b<2)for(t in e)y[t]=[y[t],e[t]];else T.always(e[T.status]);return this},abort:function(e){var t=e||w;return c&&c.abort(t),r(0,t),this}};if(g.promise(T).complete=m.add,T.success=T.done,T.error=T.fail,d.url=((t||d.url||en)+"").replace(zt,"").replace(Jt,tn[1]+"//"),d.type=n.method||n.type||d.method||d.type,d.dataTypes=pe.trim(d.dataType||"*").toLowerCase().match(De)||[""],null==d.crossDomain&&(i=Gt.exec(d.url.toLowerCase()),d.crossDomain=!(!i||i[1]===tn[1]&&i[2]===tn[2]&&(i[3]||("http:"===i[1]?"80":"443"))===(tn[3]||("http:"===tn[1]?"80":"443")))),d.data&&d.processData&&"string"!=typeof d.data&&(d.data=pe.param(d.data,d.traditional)),U(Kt,d,n,T),2===b)return T;l=pe.event&&d.global,l&&0===pe.active++&&pe.event.trigger("ajaxStart"),d.type=d.type.toUpperCase(),d.hasContent=!Yt.test(d.type),a=d.url,d.hasContent||(d.data&&(a=d.url+=(It.test(a)?"&":"?")+d.data,delete d.data),d.cache===!1&&(d.url=Xt.test(a)?a.replace(Xt,"$1_="+Wt++):a+(It.test(a)?"&":"?")+"_="+Wt++)),d.ifModified&&(pe.lastModified[a]&&T.setRequestHeader("If-Modified-Since",pe.lastModified[a]),pe.etag[a]&&T.setRequestHeader("If-None-Match",pe.etag[a])),(d.data&&d.hasContent&&d.contentType!==!1||n.contentType)&&T.setRequestHeader("Content-Type",d.contentType),T.setRequestHeader("Accept",d.dataTypes[0]&&d.accepts[d.dataTypes[0]]?d.accepts[d.dataTypes[0]]+("*"!==d.dataTypes[0]?", "+Zt+"; q=0.01":""):d.accepts["*"]);for(o in d.headers)T.setRequestHeader(o,d.headers[o]);if(d.beforeSend&&(d.beforeSend.call(p,T,d)===!1||2===b))return T.abort();w="abort";for(o in{success:1,error:1,complete:1})T[o](d[o]);if(c=U(Qt,d,n,T)){if(T.readyState=1,l&&h.trigger("ajaxSend",[T,d]),2===b)return T;d.async&&d.timeout>0&&(u=e.setTimeout(function(){T.abort("timeout")},d.timeout));try{b=1,c.send(v,r)}catch(C){if(!(b<2))throw C;r(-1,C)}}else r(-1,"No Transport");return T},getJSON:function(e,t,n){return pe.get(e,t,n,"json")},getScript:function(e,t){return pe.get(e,void 0,t,"script")}}),pe.each(["get","post"],function(e,t){pe[t]=function(e,n,r,i){return pe.isFunction(n)&&(i=i||r,r=n,n=void 0),pe.ajax(pe.extend({url:e,type:t,dataType:i,data:n,success:r},pe.isPlainObject(e)&&e))}}),pe._evalUrl=function(e){return pe.ajax({url:e,type:"GET",dataType:"script",cache:!0,async:!1,global:!1,"throws":!0})},pe.fn.extend({wrapAll:function(e){if(pe.isFunction(e))return this.each(function(t){pe(this).wrapAll(e.call(this,t))});if(this[0]){var t=pe(e,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&t.insertBefore(this[0]),t.map(function(){for(var e=this;e.firstChild&&1===e.firstChild.nodeType;)e=e.firstChild;return e}).append(this)}return this},wrapInner:function(e){return pe.isFunction(e)?this.each(function(t){pe(this).wrapInner(e.call(this,t))}):this.each(function(){var t=pe(this),n=t.contents();n.length?n.wrapAll(e):t.append(e)})},wrap:function(e){var t=pe.isFunction(e);return this.each(function(n){pe(this).wrapAll(t?e.call(this,n):e)})},unwrap:function(){return this.parent().each(function(){pe.nodeName(this,"body")||pe(this).replaceWith(this.childNodes)}).end()}}),pe.expr.filters.hidden=function(e){return fe.reliableHiddenOffsets()?e.offsetWidth<=0&&e.offsetHeight<=0&&!e.getClientRects().length:K(e)},pe.expr.filters.visible=function(e){return!pe.expr.filters.hidden(e)};var nn=/%20/g,rn=/\[\]$/,on=/\r?\n/g,an=/^(?:submit|button|image|reset|file)$/i,sn=/^(?:input|select|textarea|keygen)/i;pe.param=function(e,t){var n,r=[],i=function(e,t){t=pe.isFunction(t)?t():null==t?"":t,r[r.length]=encodeURIComponent(e)+"="+encodeURIComponent(t)};if(void 0===t&&(t=pe.ajaxSettings&&pe.ajaxSettings.traditional),pe.isArray(e)||e.jquery&&!pe.isPlainObject(e))pe.each(e,function(){i(this.name,this.value)});else for(n in e)Q(n,e[n],t,i);return r.join("&").replace(nn,"+")},pe.fn.extend({serialize:function(){return pe.param(this.serializeArray())},serializeArray:function(){return this.map(function(){var e=pe.prop(this,"elements");return e?pe.makeArray(e):this}).filter(function(){var e=this.type;return this.name&&!pe(this).is(":disabled")&&sn.test(this.nodeName)&&!an.test(e)&&(this.checked||!Be.test(e))}).map(function(e,t){var n=pe(this).val();return null==n?null:pe.isArray(n)?pe.map(n,function(e){return{name:t.name,value:e.replace(on,"\r\n")}}):{name:t.name,value:n.replace(on,"\r\n")}}).get()}}),pe.ajaxSettings.xhr=void 0!==e.ActiveXObject?function(){return this.isLocal?ee():re.documentMode>8?Z():/^(get|post|head|put|delete|options)$/i.test(this.type)&&Z()||ee()}:Z;var un=0,ln={},cn=pe.ajaxSettings.xhr();e.attachEvent&&e.attachEvent("onunload",function(){for(var e in ln)ln[e](void 0,!0)}),fe.cors=!!cn&&"withCredentials"in cn,cn=fe.ajax=!!cn,cn&&pe.ajaxTransport(function(t){if(!t.crossDomain||fe.cors){var n;return{send:function(r,i){var o,a=t.xhr(),s=++un;if(a.open(t.type,t.url,t.async,t.username,t.password),t.xhrFields)for(o in t.xhrFields)a[o]=t.xhrFields[o];t.mimeType&&a.overrideMimeType&&a.overrideMimeType(t.mimeType),t.crossDomain||r["X-Requested-With"]||(r["X-Requested-With"]="XMLHttpRequest");for(o in r)void 0!==r[o]&&a.setRequestHeader(o,r[o]+"");a.send(t.hasContent&&t.data||null),n=function(e,r){var o,u,l;if(n&&(r||4===a.readyState))if(delete ln[s],n=void 0,a.onreadystatechange=pe.noop,r)4!==a.readyState&&a.abort();else{l={},o=a.status,"string"==typeof a.responseText&&(l.text=a.responseText);try{u=a.statusText}catch(c){u=""}o||!t.isLocal||t.crossDomain?1223===o&&(o=204):o=l.text?200:404}l&&i(o,u,l,a.getAllResponseHeaders())},t.async?4===a.readyState?e.setTimeout(n):a.onreadystatechange=ln[s]=n:n()},abort:function(){n&&n(void 0,!0)}}}}),pe.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/\b(?:java|ecma)script\b/},converters:{"text script":function(e){return pe.globalEval(e),e}}}),pe.ajaxPrefilter("script",function(e){void 0===e.cache&&(e.cache=!1),e.crossDomain&&(e.type="GET",e.global=!1)}),pe.ajaxTransport("script",function(e){if(e.crossDomain){var t,n=re.head||pe("head")[0]||re.documentElement;return{send:function(r,i){t=re.createElement("script"),t.async=!0,e.scriptCharset&&(t.charset=e.scriptCharset),t.src=e.url,t.onload=t.onreadystatechange=function(e,n){(n||!t.readyState||/loaded|complete/.test(t.readyState))&&(t.onload=t.onreadystatechange=null,t.parentNode&&t.parentNode.removeChild(t),t=null,n||i(200,"success"))},n.insertBefore(t,n.firstChild)},abort:function(){t&&t.onload(void 0,!0)}}}});var fn=[],dn=/(=)\?(?=&|$)|\?\?/;pe.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var e=fn.pop()||pe.expando+"_"+Wt++;return this[e]=!0,e}}),pe.ajaxPrefilter("json jsonp",function(t,n,r){var i,o,a,s=t.jsonp!==!1&&(dn.test(t.url)?"url":"string"==typeof t.data&&0===(t.contentType||"").indexOf("application/x-www-form-urlencoded")&&dn.test(t.data)&&"data");if(s||"jsonp"===t.dataTypes[0])return i=t.jsonpCallback=pe.isFunction(t.jsonpCallback)?t.jsonpCallback():t.jsonpCallback,s?t[s]=t[s].replace(dn,"$1"+i):t.jsonp!==!1&&(t.url+=(It.test(t.url)?"&":"?")+t.jsonp+"="+i),t.converters["script json"]=function(){return a||pe.error(i+" was not called"),a[0]},t.dataTypes[0]="json",o=e[i],e[i]=function(){a=arguments},r.always(function(){void 0===o?pe(e).removeProp(i):e[i]=o,t[i]&&(t.jsonpCallback=n.jsonpCallback,fn.push(i)),a&&pe.isFunction(o)&&o(a[0]),a=o=void 0}),"script"}),pe.parseHTML=function(e,t,n){if(!e||"string"!=typeof e)return null;"boolean"==typeof t&&(n=t,t=!1),t=t||re;var r=Te.exec(e),i=!n&&[];return r?[t.createElement(r[1])]:(r=y([e],t,i),i&&i.length&&pe(i).remove(),pe.merge([],r.childNodes))};var pn=pe.fn.load;return pe.fn.load=function(e,t,n){if("string"!=typeof e&&pn)return pn.apply(this,arguments);var r,i,o,a=this,s=e.indexOf(" ");return s>-1&&(r=pe.trim(e.slice(s,e.length)),e=e.slice(0,s)),pe.isFunction(t)?(n=t,t=void 0):t&&"object"==typeof t&&(i="POST"),a.length>0&&pe.ajax({url:e,type:i||"GET",dataType:"html",data:t}).done(function(e){o=arguments,a.html(r?pe("
    ").append(pe.parseHTML(e)).find(r):e)}).always(n&&function(e,t){a.each(function(){n.apply(this,o||[e.responseText,t,e])})}),this},pe.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(e,t){pe.fn[t]=function(e){return this.on(t,e)}}),pe.expr.filters.animated=function(e){return pe.grep(pe.timers,function(t){return e===t.elem}).length},pe.offset={setOffset:function(e,t,n){var r,i,o,a,s,u,l,c=pe.css(e,"position"),f=pe(e),d={};"static"===c&&(e.style.position="relative"),s=f.offset(),o=pe.css(e,"top"),u=pe.css(e,"left"),l=("absolute"===c||"fixed"===c)&&pe.inArray("auto",[o,u])>-1,l?(r=f.position(),a=r.top,i=r.left):(a=parseFloat(o)||0,i=parseFloat(u)||0),pe.isFunction(t)&&(t=t.call(e,n,pe.extend({},s))),null!=t.top&&(d.top=t.top-s.top+a),null!=t.left&&(d.left=t.left-s.left+i),"using"in t?t.using.call(e,d):f.css(d)}},pe.fn.extend({offset:function(e){if(arguments.length)return void 0===e?this:this.each(function(t){pe.offset.setOffset(this,e,t)});var t,n,r={top:0,left:0},i=this[0],o=i&&i.ownerDocument;if(o)return t=o.documentElement,pe.contains(t,i)?("undefined"!=typeof i.getBoundingClientRect&&(r=i.getBoundingClientRect()),n=te(o),{top:r.top+(n.pageYOffset||t.scrollTop)-(t.clientTop||0),left:r.left+(n.pageXOffset||t.scrollLeft)-(t.clientLeft||0)}):r},position:function(){if(this[0]){var e,t,n={top:0,left:0},r=this[0];return"fixed"===pe.css(r,"position")?t=r.getBoundingClientRect():(e=this.offsetParent(),t=this.offset(),pe.nodeName(e[0],"html")||(n=e.offset()),n.top+=pe.css(e[0],"borderTopWidth",!0),n.left+=pe.css(e[0],"borderLeftWidth",!0)),{top:t.top-n.top-pe.css(r,"marginTop",!0),left:t.left-n.left-pe.css(r,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){ -for(var e=this.offsetParent;e&&!pe.nodeName(e,"html")&&"static"===pe.css(e,"position");)e=e.offsetParent;return e||pt})}}),pe.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(e,t){var n=/Y/.test(t);pe.fn[e]=function(r){return Pe(this,function(e,r,i){var o=te(e);return void 0===i?o?t in o?o[t]:o.document.documentElement[r]:e[r]:void(o?o.scrollTo(n?pe(o).scrollLeft():i,n?i:pe(o).scrollTop()):e[r]=i)},e,r,arguments.length,null)}}),pe.each(["top","left"],function(e,t){pe.cssHooks[t]=L(fe.pixelPosition,function(e,n){if(n)return n=gt(e,t),ft.test(n)?pe(e).position()[t]+"px":n})}),pe.each({Height:"height",Width:"width"},function(e,t){pe.each({padding:"inner"+e,content:t,"":"outer"+e},function(n,r){pe.fn[r]=function(r,i){var o=arguments.length&&(n||"boolean"!=typeof r),a=n||(r===!0||i===!0?"margin":"border");return Pe(this,function(t,n,r){var i;return pe.isWindow(t)?t.document.documentElement["client"+e]:9===t.nodeType?(i=t.documentElement,Math.max(t.body["scroll"+e],i["scroll"+e],t.body["offset"+e],i["offset"+e],i["client"+e])):void 0===r?pe.css(t,n,a):pe.style(t,n,r,a)},t,o?r:void 0,o,null)}})}),pe.fn.extend({bind:function(e,t,n){return this.on(e,null,t,n)},unbind:function(e,t){return this.off(e,null,t)},delegate:function(e,t,n,r){return this.on(t,e,n,r)},undelegate:function(e,t,n){return 1===arguments.length?this.off(e,"**"):this.off(t,e||"**",n)}}),pe.fn.size=function(){return this.length},pe.fn.andSelf=pe.fn.addBack,layui.define(function(e){e("jquery",pe)}),pe});layui.define("jquery",function(i){"use strict";var a=layui.jquery,t=(layui.hint(),layui.device()),l="element",e="layui-this",n="layui-show",s=function(){this.config={}};s.prototype.set=function(i){var t=this;return a.extend(!0,t.config,i),t},s.prototype.on=function(i,a){return layui.onevent(l,i,a)},s.prototype.tabAdd=function(i,t){var l=".layui-tab-title",e=a(".layui-tab[lay-filter="+i+"]"),n=e.children(l),s=e.children(".layui-tab-content");return n.append('
  • '+(t.title||"unnaming")+"
  • "),s.append('
    '+(t.content||"")+"
    "),f.hideTabMore(!0),f.tabAuto(),this},s.prototype.tabDelete=function(i,t){var l=".layui-tab-title",e=a(".layui-tab[lay-filter="+i+"]"),n=e.children(l),s=n.find('>li[lay-id="'+t+'"]');return f.tabDelete(null,s),this},s.prototype.tabChange=function(i,t){var l=".layui-tab-title",e=a(".layui-tab[lay-filter="+i+"]"),n=e.children(l),s=n.find('>li[lay-id="'+t+'"]');return f.tabClick(null,null,s),this},s.prototype.progress=function(i,t){var l="layui-progress",e=a("."+l+"[lay-filter="+i+"]"),n=e.find("."+l+"-bar"),s=n.find("."+l+"-text");return n.css("width",t),s.text(t),this};var o=".layui-nav",c="layui-nav-item",r="layui-nav-bar",u="layui-nav-tree",d="layui-nav-child",h="layui-nav-more",y="layui-anim layui-anim-upbit",f={tabClick:function(i,t,s){var o=s||a(this),t=t||o.parent().children("li").index(o),c=o.parents(".layui-tab").eq(0),r=c.children(".layui-tab-content").children(".layui-tab-item"),u=c.attr("lay-filter");o.addClass(e).siblings().removeClass(e),r.eq(t).addClass(n).siblings().removeClass(n),layui.event.call(this,l,"tab("+u+")",{elem:c,index:t})},tabDelete:function(i,t){var l=t||a(this).parent(),n=l.index(),s=l.parents(".layui-tab").eq(0),o=s.children(".layui-tab-content").children(".layui-tab-item");l.hasClass(e)&&(l.next()[0]?f.tabClick.call(l.next()[0],null,n+1):l.prev()[0]&&f.tabClick.call(l.prev()[0],null,n-1)),l.remove(),o.eq(n).remove(),setTimeout(function(){f.tabAuto()},50)},tabAuto:function(){var i="layui-tab-more",l="layui-tab-bar",e="layui-tab-close",n=this;a(".layui-tab").each(function(){var s=a(this),o=s.children(".layui-tab-title"),c=(s.children(".layui-tab-content").children(".layui-tab-item"),'lay-stope="tabmore"'),r=a('');if(n===window&&8!=t.ie&&f.hideTabMore(!0),s.attr("lay-allowClose")&&o.find("li").each(function(){var i=a(this);if(!i.find("."+e)[0]){var t=a('');t.on("click",f.tabDelete),i.append(t)}}),o.prop("scrollWidth")>o.outerWidth()+1){if(o.find("."+l)[0])return;o.append(r),s.attr("overflow",""),r.on("click",function(a){o[this.title?"removeClass":"addClass"](i),this.title=this.title?"":"收缩"})}else o.find("."+l).remove(),s.removeAttr("overflow")})},hideTabMore:function(i){var t=a(".layui-tab-title");i!==!0&&"tabmore"===a(i.target).attr("lay-stope")||(t.removeClass("layui-tab-more"),t.find(".layui-tab-bar").attr("title",""))},clickThis:function(){var i=a(this),t=i.parents(o),n=t.attr("lay-filter");i.find("."+d)[0]||(t.find("."+e).removeClass(e),i.addClass(e),layui.event.call(this,l,"nav("+n+")",i))},clickChild:function(){var i=a(this),t=i.parents(o),n=t.attr("lay-filter");t.find("."+e).removeClass(e),i.addClass(e),layui.event.call(this,l,"nav("+n+")",i)},showChild:function(){var i=a(this),t=i.parents(o),l=i.parent(),e=i.siblings("."+d);t.hasClass(u)&&(e.removeClass(y),l["none"===e.css("display")?"addClass":"removeClass"](c+"ed"))},collapse:function(){var i=a(this),t=i.find(".layui-colla-icon"),e=i.siblings(".layui-colla-content"),s=i.parents(".layui-collapse").eq(0),o=s.attr("lay-filter"),c="none"===e.css("display");if("string"==typeof s.attr("lay-accordion")){var r=s.children(".layui-colla-item").children("."+n);r.siblings(".layui-colla-title").children(".layui-colla-icon").html(""),r.removeClass(n)}e[c?"addClass":"removeClass"](n),t.html(c?"":""),layui.event.call(this,l,"collapse("+o+")",{title:i,content:e,show:c})}};s.prototype.init=function(i){var l={tab:function(){f.tabAuto.call({})},nav:function(){var i,l,e,s=200,p=function(o,c){var r=a(this),f=r.find("."+d);c.hasClass(u)?o.css({top:r.position().top,height:r.children("a").height(),opacity:1}):(f.addClass(y),o.css({left:r.position().left+parseFloat(r.css("marginLeft")),top:r.position().top+r.height()-5}),i=setTimeout(function(){o.css({width:r.width(),opacity:1})},t.ie&&t.ie<10?0:s),clearTimeout(e),"block"===f.css("display")&&clearTimeout(l),l=setTimeout(function(){f.addClass(n),r.find("."+h).addClass(h+"d")},300))};a(o).each(function(){var t=a(this),o=a(''),y=t.find("."+c);t.find("."+r)[0]||(t.append(o),y.on("mouseenter",function(){p.call(this,o,t)}).on("mouseleave",function(){t.hasClass(u)||(clearTimeout(l),l=setTimeout(function(){t.find("."+d).removeClass(n),t.find("."+h).removeClass(h+"d")},300))}),t.on("mouseleave",function(){clearTimeout(i),e=setTimeout(function(){t.hasClass(u)?o.css({height:0,top:o.position().top+o.height()/2,opacity:0}):o.css({width:0,left:o.position().left+o.width()/2,opacity:0})},s)})),y.each(function(){var i=a(this),t=i.find("."+d);if(t[0]&&!i.find("."+h)[0]){var l=i.children("a");l.append('')}i.off("click",f.clickThis).on("click",f.clickThis),i.children("a").off("click",f.showChild).on("click",f.showChild),t.children("dd").off("click",f.clickChild).on("click",f.clickChild)})})},breadcrumb:function(){var i=".layui-breadcrumb";a(i).each(function(){var i=a(this),t=i.attr("lay-separator")||">",l=i.find("a");l.find(".layui-box")[0]||(l.each(function(i){i!==l.length-1&&a(this).append(''+t+"")}),i.css("visibility","visible"))})},progress:function(){var i="layui-progress";a("."+i).each(function(){var t=a(this),l=t.find(".layui-progress-bar"),e=l.attr("lay-percent");l.css("width",e),t.attr("lay-showPercent")&&setTimeout(function(){var a=Math.round(l.width()/t.width()*100);a>100&&(a=100),l.html(''+a+"%")},350)})},collapse:function(){var i="layui-collapse";a("."+i).each(function(){var i=a(this).find(".layui-colla-item");i.each(function(){var i=a(this),t=i.find(".layui-colla-title"),l=i.find(".layui-colla-content"),e="none"===l.css("display");t.find(".layui-colla-icon").remove(),t.append(''+(e?"":"")+""),t.off("click",f.collapse).on("click",f.collapse)})})}};return layui.each(l,function(i,a){a()})};var p=new s,v=a(document);p.init();var b=".layui-tab-title li";v.on("click",b,f.tabClick),v.on("click",f.hideTabMore),a(window).on("resize",f.tabAuto),i(l,function(i){return p.set(i)})});layui.define("layer",function(e){"use strict";var a=layui.jquery,t=layui.layer,i=(layui.device(),"layui-upload-enter"),n="layui-upload-iframe",r={icon:2,shift:6},o={file:"文件",video:"视频",audio:"音频"},s=function(e){this.options=e};s.prototype.init=function(){var e=this,t=e.options,r=a("body"),s=a(t.elem||".layui-upload-file"),u=a('');return a("#"+n)[0]||r.append(u),s.each(function(r,s){s=a(s);var u='
    ',l=s.attr("lay-type")||t.type;t.unwrap||(u='
    '+u+''+(s.attr("lay-title")||t.title||"上传"+(o[l]||"图片"))+"
    "),u=a(u),t.unwrap||u.on("dragover",function(e){e.preventDefault(),a(this).addClass(i)}).on("dragleave",function(){a(this).removeClass(i)}).on("drop",function(){a(this).removeClass(i)}),s.parent("form").attr("target")===n&&(t.unwrap?s.unwrap():(s.parent().next().remove(),s.unwrap().unwrap())),s.wrap(u),s.off("change").on("change",function(){e.action(this,l)})})},s.prototype.action=function(e,i){var o=this,s=o.options,u=e.value,l=a(e),p=l.attr("lay-ext")||s.ext||"";if(u){switch(i){case"file":if(p&&!RegExp("\\w\\.("+p+")$","i").test(escape(u)))return t.msg("不支持该文件格式",r),e.value="";break;case"video":if(!RegExp("\\w\\.("+(p||"avi|mp4|wma|rmvb|rm|flash|3gp|flv")+")$","i").test(escape(u)))return t.msg("不支持该视频格式",r),e.value="";break;case"audio":if(!RegExp("\\w\\.("+(p||"mp3|wav|mid")+")$","i").test(escape(u)))return t.msg("不支持该音频格式",r),e.value="";break;default:if(!RegExp("\\w\\.("+(p||"jpg|png|gif|bmp|jpeg")+")$","i").test(escape(u)))return t.msg("不支持该图片格式",r),e.value=""}s.before&&s.before(e),l.parent().submit();var c=a("#"+n),f=setInterval(function(){var a;try{a=c.contents().find("body").text()}catch(i){t.msg("上传接口存在跨域",r),clearInterval(f)}if(a){clearInterval(f),c.contents().find("body").html("");try{a=JSON.parse(a)}catch(i){return a={},t.msg("请对上传接口返回JSON字符",r)}"function"==typeof s.success&&s.success(a,e)}},30);e.value=""}},e("upload",function(e){var a=new s(e=e||{});a.init()})});layui.define("layer",function(e){"use strict";var i=layui.jquery,t=layui.layer,a=layui.hint(),n=layui.device(),l="form",r=".layui-form",s="layui-this",o="layui-hide",c="layui-disabled",u=function(){this.config={verify:{required:[/[\S]+/,"必填项不能为空"],phone:[/^1\d{10}$/,"请输入正确的手机号"],email:[/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/,"邮箱格式不正确"],url:[/(^#)|(^http(s*):\/\/[^\s]+\.[^\s]+)/,"链接格式不正确"],number:[/^\d+$/,"只能填写数字"],date:[/^(\d{4})[-\/](\d{1}|0\d{1}|1[0-2])([-\/](\d{1}|0\d{1}|[1-2][0-9]|3[0-1]))*$/,"日期格式不正确"],identity:[/(^\d{15}$)|(^\d{17}(x|X|\d)$)/,"请输入正确的身份证号"]}}};u.prototype.set=function(e){var t=this;return i.extend(!0,t.config,e),t},u.prototype.verify=function(e){var t=this;return i.extend(!0,t.config.verify,e),t},u.prototype.on=function(e,i){return layui.onevent(l,e,i)},u.prototype.render=function(e){var t=this,n={select:function(){var e,t="请选择",a="layui-form-select",n="layui-select-title",u="layui-select-none",d="",f=i(r).find("select"),y=function(t,l){i(t.target).parent().hasClass(n)&&!l||(i("."+a).removeClass(a+"ed"),e&&d&&e.val(d)),e=null},v=function(t,r,f){var v=i(this),h=t.find("."+n),p=h.find("input"),m=t.find("dl"),k=m.children("dd");if(!r){var b=function(){t.addClass(a+"ed"),k.removeClass(o)},x=function(){t.removeClass(a+"ed"),p.blur(),g(p.val(),function(e){e&&(d=m.find("."+s).html(),p&&p.val(d))})};h.on("click",function(e){t.hasClass(a+"ed")?x():(y(e,!0),b()),m.find("."+u).remove()}),h.find(".layui-edge").on("click",function(){p.focus()}),p.on("keyup",function(e){var i=e.keyCode;9===i&&b()}).on("keydown",function(e){var i=e.keyCode;9===i?x():13===i&&e.preventDefault()});var g=function(e,t,a){var n=0;layui.each(k,function(){var t=i(this),l=t.text(),r=l.indexOf(e)===-1;(""===e||"blur"===a?e!==l:r)&&n++,"keyup"===a&&t[r?"addClass":"removeClass"](o)});var l=n===k.length;return t(l),l},C=function(e){var i=this.value,t=e.keyCode;return 9!==t&&13!==t&&37!==t&&38!==t&&39!==t&&40!==t&&(g(i,function(e){e?m.find("."+u)[0]||m.append('

    无匹配项

    '):m.find("."+u).remove()},"keyup"),void(""===i&&m.find("."+u).remove()))};f&&p.on("keyup",C).on("blur",function(i){e=p,d=m.find("."+s).html(),setTimeout(function(){g(p.val(),function(e){e&&!d&&p.val("")},"blur")},200)}),k.on("click",function(){var e=i(this),a=e.attr("lay-value"),n=v.attr("lay-filter");return!e.hasClass(c)&&(v.val(a).removeClass("layui-form-danger"),p.val(e.text()),e.addClass(s).siblings().removeClass(s),layui.event.call(this,l,"select("+n+")",{elem:v[0],value:a,othis:t}),x(),!1)}),t.find("dl>dt").on("click",function(e){return!1}),i(document).off("click",y).on("click",y)}};f.each(function(e,l){var r=i(this),o=r.next("."+a),u=this.disabled,d=l.value,f=i(l.options[l.selectedIndex]);if("string"==typeof r.attr("lay-ignore"))return r.show();var y="string"==typeof r.attr("lay-search"),h=i(['
    ','
    ','
    ','
    '+function(e){var i=[];return layui.each(e,function(e,t){(0!==e||t.value)&&("optgroup"===t.tagName.toLowerCase()?i.push("
    "+t.label+"
    "):i.push('
    '+t.innerHTML+"
    "))}),i.join("")}(r.find("*"))+"
    ","
    "].join(""));o[0]&&o.remove(),r.after(h),v.call(this,h,u,y)})},checkbox:function(){var e={checkbox:["layui-form-checkbox","layui-form-checked","checkbox"],_switch:["layui-form-switch","layui-form-onswitch","switch"]},t=i(r).find("input[type=checkbox]"),a=function(e,t){var a=i(this);e.on("click",function(){var i=a.attr("lay-filter"),n=(a.attr("lay-text")||"").split("|");a[0].disabled||(a[0].checked?(a[0].checked=!1,e.removeClass(t[1]).find("em").text(n[1])):(a[0].checked=!0,e.addClass(t[1]).find("em").text(n[0])),layui.event.call(a[0],l,t[2]+"("+i+")",{elem:a[0],value:a[0].value,othis:e}))})};t.each(function(t,n){var l=i(this),r=l.attr("lay-skin"),s=(l.attr("lay-text")||"").split("|"),o=this.disabled;"switch"===r&&(r="_"+r);var u=e[r]||e.checkbox;if("string"==typeof l.attr("lay-ignore"))return l.show();var d=l.next("."+u[0]),f=i(['
    ',{_switch:""+((n.checked?s[0]:s[1])||"")+""}[r]||(n.title.replace(/\s/g,"")?""+n.title+"":"")+''+(r?"":"")+"","
    "].join(""));d[0]&&d.remove(),l.after(f),a.call(this,f,u)})},radio:function(){var e="layui-form-radio",t=["",""],a=i(r).find("input[type=radio]"),n=function(a){var n=i(this),s="layui-anim-scaleSpring";a.on("click",function(){var o=n[0].name,c=n.parents(r),u=n.attr("lay-filter"),d=c.find("input[name="+o.replace(/(\.|#|\[|\])/g,"\\$1")+"]");n[0].disabled||(layui.each(d,function(){var a=i(this).next("."+e);this.checked=!1,a.removeClass(e+"ed"),a.find(".layui-icon").removeClass(s).html(t[1])}),n[0].checked=!0,a.addClass(e+"ed"),a.find(".layui-icon").addClass(s).html(t[0]),layui.event.call(n[0],l,"radio("+u+")",{elem:n[0],value:n[0].value,othis:a}))})};a.each(function(a,l){var r=i(this),s=r.next("."+e),o=this.disabled;if("string"==typeof r.attr("lay-ignore"))return r.show();var u=i(['
    ',''+t[l.checked?0:1]+"",""+(l.title||"未命名")+"","
    "].join(""));s[0]&&s.remove(),r.after(u),n.call(this,u)})}};return e?n[e]?n[e]():a.error("不支持的"+e+"表单渲染"):layui.each(n,function(e,i){i()}),t};var d=function(){var e=i(this),a=f.config.verify,s=null,o="layui-form-danger",c={},u=e.parents(r),d=u.find("*[lay-verify]"),y=e.parents("form")[0],v=u.find("input,select,textarea"),h=e.attr("lay-filter");return layui.each(d,function(e,l){var r=i(this),c=r.attr("lay-verify").split("|"),u="",d=r.val();if(r.removeClass(o),layui.each(c,function(e,i){var c="function"==typeof a[i];if(a[i]&&(c?u=a[i](d,l):!a[i][0].test(d)))return t.msg(u||a[i][1],{icon:5,shift:6}),n.android||n.ios||l.focus(),r.addClass(o),s=!0}),s)return s}),!s&&(layui.each(v,function(e,i){i.name&&(/^checkbox|radio$/.test(i.type)&&!i.checked||(c[i.name]=i.value))}),layui.event.call(this,l,"submit("+h+")",{elem:this,form:y,field:c}))},f=new u,y=i(document);f.render(),y.on("reset",r,function(){setTimeout(function(){f.render()},50)}),y.on("submit",r,d).on("click","*[lay-submit]",d),e(l,function(e){return f.set(e)})});layui.define("jquery",function(e){"use strict";var o=layui.jquery,a=layui.hint(),r="layui-tree-enter",i=function(e){this.options=e},t={arrow:["",""],checkbox:["",""],radio:["",""],branch:["",""],leaf:""};i.prototype.init=function(e){var o=this;e.addClass("layui-box layui-tree"),o.options.skin&&e.addClass("layui-tree-skin-"+o.options.skin),o.tree(e),o.on(e)},i.prototype.tree=function(e,a){var r=this,i=r.options,n=a||i.nodes;layui.each(n,function(a,n){var l=n.children&&n.children.length>0,c=o('
      '),s=o(["
    • ",function(){return l?''+(n.spread?t.arrow[1]:t.arrow[0])+"":""}(),function(){return i.check?''+("checkbox"===i.check?t.checkbox[0]:"radio"===i.check?t.radio[0]:"")+"":""}(),function(){return'"+(''+(l?n.spread?t.branch[1]:t.branch[0]:t.leaf)+"")+(""+(n.name||"未命名")+"")}(),"
    • "].join(""));l&&(s.append(c),r.tree(c,n.children)),e.append(s),"function"==typeof i.click&&r.click(s,n),r.spread(s,n),i.drag&&r.drag(s,n)})},i.prototype.click=function(e,o){var a=this,r=a.options;e.children("a").on("click",function(e){layui.stope(e),r.click(o)})},i.prototype.spread=function(e,o){var a=this,r=(a.options,e.children(".layui-tree-spread")),i=e.children("ul"),n=e.children("a"),l=function(){e.data("spread")?(e.data("spread",null),i.removeClass("layui-show"),r.html(t.arrow[0]),n.find(".layui-icon").html(t.branch[0])):(e.data("spread",!0),i.addClass("layui-show"),r.html(t.arrow[1]),n.find(".layui-icon").html(t.branch[1]))};i[0]&&(r.on("click",l),n.on("dblclick",l))},i.prototype.on=function(e){var a=this,i=a.options,t="layui-tree-drag";e.find("i").on("selectstart",function(e){return!1}),i.drag&&o(document).on("mousemove",function(e){var r=a.move;if(r.from){var i=(r.to,o('
      '));e.preventDefault(),o("."+t)[0]||o("body").append(i);var n=o("."+t)[0]?o("."+t):i;n.addClass("layui-show").html(r.from.elem.children("a").html()),n.css({left:e.pageX+10,top:e.pageY+10})}}).on("mouseup",function(){var e=a.move;e.from&&(e.from.elem.children("a").removeClass(r),e.to&&e.to.elem.children("a").removeClass(r),a.move={},o("."+t).remove())})},i.prototype.move={},i.prototype.drag=function(e,a){var i=this,t=(i.options,e.children("a")),n=function(){var t=o(this),n=i.move;n.from&&(n.to={item:a,elem:e},t.addClass(r))};t.on("mousedown",function(){var o=i.move;o.from={item:a,elem:e}}),t.on("mouseenter",n).on("mousemove",n).on("mouseleave",function(){var e=o(this),a=i.move;a.from&&(delete a.to,e.removeClass(r))})},e("tree",function(e){var r=new i(e=e||{}),t=o(e.elem);return t[0]?void r.init(t):a.error("layui.tree 没有找到"+e.elem+"元素")})});layui.define("jquery",function(l){"use strict";var o=layui.jquery,i={fixbar:function(l){l=l||{},l.bgcolor=l.bgcolor?"background-color:"+l.bgcolor:"";var i,a,c="layui-fixbar-top",t=[l.bar1===!0?"":l.bar1,l.bar2===!0?"":l.bar2,""],r=o(['
        ',l.bar1?'
      • '+t[0]+"
      • ":"",l.bar2?'
      • '+t[1]+"
      • ":"",'
      • '+t[2]+"
      • ","
      "].join("")),e=r.find("."+c),s=function(){var i=o(document).scrollTop();i>=(l.showHeight||200)?a||(e.show(),a=1):a&&(e.hide(),a=0)};o(".layui-fixbar")[0]||("object"==typeof l.css&&r.css(l.css),o("body").append(r),s(),r.find("li").on("click",function(){var i=o(this),a=i.attr("lay-type");"top"===a&&o("html,body").animate({scrollTop:0},200),l.click&&l.click.call(this,a)}),o(document).on("scroll",function(){i&&clearTimeout(i),i=setTimeout(function(){s()},100)}))}};l("util",i)});layui.define("jquery",function(e){"use strict";var l=layui.jquery,o=function(e){},t='';o.prototype.load=function(e){var o,i,n,r,a=this,c=0;e=e||{};var u=l(e.elem);if(u[0]){var f=l(e.scrollElem||document),m=e.mb||50,s=!("isAuto"in e)||e.isAuto,y=e.end||"没有更多了",v=e.scrollElem&&e.scrollElem!==document,d="加载更多",h=l('");u.find(".layui-flow-more")[0]||u.append(h);var p=function(e,t){e=l(e),h.before(e),t=0==t||null,t?h.html(y):h.find("a").html(d),i=t,o=null,n&&n()},g=function(){o=!0,h.find("a").html(t),"function"==typeof e.done&&e.done(++c,p)};if(g(),h.find("a").on("click",function(){l(this);i||o||g()}),e.isLazyimg)var n=a.lazyimg({elem:e.elem+" img",scrollElem:e.scrollElem});return s?(f.on("scroll",function(){var e=l(this),t=e.scrollTop();r&&clearTimeout(r),i||(r=setTimeout(function(){var i=v?e.height():l(window).height(),n=v?e.prop("scrollHeight"):document.documentElement.scrollHeight;n-t-i<=m&&(o||g())},100))}),a):a}},o.prototype.lazyimg=function(e){var o,t=this,i=0;e=e||{};var n=l(e.scrollElem||document),r=e.elem||"img",a=e.scrollElem&&e.scrollElem!==document,c=function(e,l){var o=n.scrollTop(),r=o+l,c=a?function(){return e.offset().top-n.offset().top+o}():e.offset().top;if(c>=o&&c<=r&&!e.attr("src")){var f=e.attr("lay-src");layui.img(f,function(){var l=t.lazyimg.elem.eq(i);e.attr("src",f).removeAttr("lay-src"),l[0]&&u(l),i++})}},u=function(e,o){var u=a?(o||n).height():l(window).height(),f=n.scrollTop(),m=f+u;if(t.lazyimg.elem=l(r),e)c(e,u);else for(var s=0;sm)break}};if(u(),!o){var f;n.on("scroll",function(){var e=l(this);f&&clearTimeout(f),f=setTimeout(function(){u(null,e)},50)}),o=!0}return u},e("flow",new o)});layui.define(["layer","form"],function(t){"use strict";var e=layui.jquery,i=layui.layer,a=layui.form(),l=(layui.hint(),layui.device()),n="layedit",o="layui-show",r="layui-disabled",s=function(){var t=this;t.index=0,t.config={tool:["strong","italic","underline","del","|","left","center","right","|","link","unlink","face","image"],hideTool:[],height:280}};s.prototype.set=function(t){var i=this;return e.extend(!0,i.config,t),i},s.prototype.on=function(t,e){return layui.onevent(n,t,e)},s.prototype.build=function(t,i){i=i||{};var a=this,n=a.config,r="layui-layedit",s=e("#"+t),u="LAY_layedit_"+ ++a.index,d=s.next("."+r),y=e.extend({},n,i),f=function(){var t=[],e={};return layui.each(y.hideTool,function(t,i){e[i]=!0}),layui.each(y.tool,function(i,a){C[a]&&!e[a]&&t.push(C[a])}),t.join("")}(),m=e(['
      ','
      '+f+"
      ",'
      ','',"
      ","
      "].join(""));return l.ie&&l.ie<8?s.removeClass("layui-hide").addClass(o):(d[0]&&d.remove(),c.call(a,m,s[0],y),s.addClass("layui-hide").after(m),a.index)},s.prototype.getContent=function(t){var e=u(t);if(e[0])return d(e[0].document.body.innerHTML)},s.prototype.getText=function(t){var i=u(t);if(i[0])return e(i[0].document.body).text()},s.prototype.sync=function(t){var i=u(t);if(i[0]){var a=e("#"+i[1].attr("textarea"));a.val(d(i[0].document.body.innerHTML))}},s.prototype.getSelection=function(t){var e=u(t);if(e[0]){var i=m(e[0].document);return document.selection?i.text:i.toString()}};var c=function(t,i,a){var l=this,n=t.find("iframe");n.css({height:a.height}).on("load",function(){var o=n.contents(),r=n.prop("contentWindow"),s=o.find("head"),c=e([""].join("")),u=o.find("body");s.append(c),u.attr("contenteditable","true").css({"min-height":a.height}).html(i.value||""),y.apply(l,[r,n,i,a]),g.call(l,r,t,a)})},u=function(t){var i=e("#LAY_layedit_"+t),a=i.prop("contentWindow");return[a,i]},d=function(t){return 8==l.ie&&(t=t.replace(/<.+>/g,function(t){return t.toLowerCase()})),t},y=function(t,a,n,o){var r=t.document,s=e(r.body);s.on("keydown",function(t){var e=t.keyCode;if(13===e){var a=m(r),l=p(a),n=l.parentNode;if("pre"===n.tagName.toLowerCase()){if(t.shiftKey)return;return i.msg("请暂时用shift+enter"),!1}r.execCommand("formatBlock",!1,"

      ")}}),e(n).parents("form").on("submit",function(){var t=s.html();8==l.ie&&(t=t.replace(/<.+>/g,function(t){return t.toLowerCase()})),n.value=t}),s.on("paste",function(e){r.execCommand("formatBlock",!1,"

      "),setTimeout(function(){f.call(t,s),n.value=s.html()},100)})},f=function(t){var i=this;i.document;t.find("*[style]").each(function(){var t=this.style.textAlign;this.removeAttribute("style"),e(this).css({"text-align":t||""})}),t.find("table").addClass("layui-table"),t.find("script,link").remove()},m=function(t){return t.selection?t.selection.createRange():t.getSelection().getRangeAt(0)},p=function(t){return t.endContainer||t.parentElement().childNodes[0]},v=function(t,i,a){var l=this.document,n=document.createElement(t);for(var o in i)n.setAttribute(o,i[o]);if(n.removeAttribute("text"),l.selection){var r=a.text||i.text;if("a"===t&&!r)return;r&&(n.innerHTML=r),a.pasteHTML(e(n).prop("outerHTML")),a.select()}else{var r=a.toString()||i.text;if("a"===t&&!r)return;r&&(n.innerHTML=r),a.deleteContents(),a.insertNode(n)}},h=function(t,i){var a=this.document,l="layedit-tool-active",n=p(m(a)),o=function(e){return t.find(".layedit-tool-"+e)};i&&i[i.hasClass(l)?"removeClass":"addClass"](l),t.find(">i").removeClass(l),o("unlink").addClass(r),e(n).parents().each(function(){var t=this.tagName.toLowerCase(),e=this.style.textAlign;"b"!==t&&"strong"!==t||o("b").addClass(l),"i"!==t&&"em"!==t||o("i").addClass(l),"u"===t&&o("u").addClass(l),"strike"===t&&o("d").addClass(l),"p"===t&&("center"===e?o("center").addClass(l):"right"===e?o("right").addClass(l):o("left").addClass(l)),"a"===t&&(o("link").addClass(l),o("unlink").removeClass(r))})},g=function(t,a,l){var n=t.document,o=e(n.body),s={link:function(i){var a=p(i),l=e(a).parent();b.call(o,{href:l.attr("href"),target:l.attr("target")},function(e){var a=l[0];"A"===a.tagName?a.href=e.url:v.call(t,"a",{target:e.target,href:e.url,text:e.url},i)})},unlink:function(t){n.execCommand("unlink")},face:function(e){x.call(this,function(i){v.call(t,"img",{src:i.src,alt:i.alt},e)})},image:function(a){var n=this;layui.use("upload",function(o){var r=l.uploadImage||{};o({url:r.url,method:r.type,elem:e(n).find("input")[0],unwrap:!0,success:function(e){0==e.code?(e.data=e.data||{},v.call(t,"img",{src:e.data.src,alt:e.data.title},a)):i.msg(e.msg||"上传失败")}})})},code:function(e){k.call(o,function(i){v.call(t,"pre",{text:i.code,"lay-lang":i.lang},e)})},help:function(){i.open({type:2,title:"帮助",area:["600px","380px"],shadeClose:!0,shade:.1,skin:"layui-layer-msg",content:["http://www.layui.com/about/layedit/help.html","no"]})}},c=a.find(".layui-layedit-tool"),u=function(){var i=e(this),a=i.attr("layedit-event"),l=i.attr("lay-command");if(!i.hasClass(r)){o.focus();var u=m(n);u.commonAncestorContainer;l?(n.execCommand(l),/justifyLeft|justifyCenter|justifyRight/.test(l)&&n.execCommand("formatBlock",!1,"

      "),setTimeout(function(){o.focus()},10)):s[a]&&s[a].call(this,u),h.call(t,c,i)}},d=/image/;c.find(">i").on("mousedown",function(){var t=e(this),i=t.attr("layedit-event");d.test(i)||u.call(this)}).on("click",function(){var t=e(this),i=t.attr("layedit-event");d.test(i)&&u.call(this)}),o.on("click",function(){h.call(t,c),i.close(x.index)})},b=function(t,e){var l=this,n=i.open({type:1,id:"LAY_layedit_link",area:"350px",shade:.05,shadeClose:!0,moveType:1,title:"超链接",skin:"layui-layer-msg",content:['

        ','
      • ','','
        ','',"
        ","
      • ",'
      • ','','
        ','",'","
        ","
      • ",'
      • ','','',"
      • ","
      "].join(""),success:function(t,n){var o="submit(layedit-link-yes)";a.render("radio"),t.find(".layui-btn-primary").on("click",function(){i.close(n),l.focus()}),a.on(o,function(t){i.close(b.index),e&&e(t.field)})}});b.index=n},x=function(t){var a=function(){var t=["[微笑]","[嘻嘻]","[哈哈]","[可爱]","[可怜]","[挖鼻]","[吃惊]","[害羞]","[挤眼]","[闭嘴]","[鄙视]","[爱你]","[泪]","[偷笑]","[亲亲]","[生病]","[太开心]","[白眼]","[右哼哼]","[左哼哼]","[嘘]","[衰]","[委屈]","[吐]","[哈欠]","[抱抱]","[怒]","[疑问]","[馋嘴]","[拜拜]","[思考]","[汗]","[困]","[睡]","[钱]","[失望]","[酷]","[色]","[哼]","[鼓掌]","[晕]","[悲伤]","[抓狂]","[黑线]","[阴险]","[怒骂]","[互粉]","[心]","[伤心]","[猪头]","[熊猫]","[兔子]","[ok]","[耶]","[good]","[NO]","[赞]","[来]","[弱]","[草泥马]","[神马]","[囧]","[浮云]","[给力]","[围观]","[威武]","[奥特曼]","[礼物]","[钟]","[话筒]","[蜡烛]","[蛋糕]"],e={};return layui.each(t,function(t,i){e[i]=layui.cache.dir+"images/face/"+t+".gif"}),e}();return x.hide=x.hide||function(t){"face"!==e(t.target).attr("layedit-event")&&i.close(x.index)},x.index=i.tips(function(){var t=[];return layui.each(a,function(e,i){t.push('
    • '+e+'
    • ')}),'
        '+t.join("")+"
      "}(),this,{tips:1,time:0,skin:"layui-box layui-util-face",maxWidth:500,success:function(l,n){l.css({marginTop:-4,marginLeft:-10}).find(".layui-clear>li").on("click",function(){t&&t({src:a[this.title],alt:this.title}),i.close(n)}),e(document).off("click",x.hide).on("click",x.hide)}})},k=function(t){var e=this,l=i.open({type:1,id:"LAY_layedit_code",area:"550px",shade:.05,shadeClose:!0,moveType:1,title:"插入代码",skin:"layui-layer-msg",content:['
        ','
      • ','','
        ','","
        ","
      • ",'
      • ','','
        ','',"
        ","
      • ",'
      • ','','',"
      • ","
      "].join(""),success:function(l,n){var o="submit(layedit-code-yes)";a.render("select"),l.find(".layui-btn-primary").on("click",function(){i.close(n),e.focus()}),a.on(o,function(e){i.close(k.index),t&&t(e.field)})}});k.index=l},C={html:'',strong:'',italic:'',underline:'',del:'',"|":'',left:'',center:'',right:'',link:'',unlink:'',face:'',image:'',code:'',help:''},w=new s;t(n,w)});layui.define("jquery",function(e){"use strict";var a=layui.jquery,l="http://www.layui.com/doc/modules/code.html";e("code",function(e){var t=[];e=e||{},e.elem=a(e.elem||".layui-code"),e.about=!("about"in e)||e.about,e.elem.each(function(){t.push(this)}),layui.each(t.reverse(),function(t,i){var c=a(i),o=c.html();(c.attr("lay-encode")||e.encode)&&(o=o.replace(/&(?!#?[a-zA-Z0-9]+;)/g,"&").replace(//g,">").replace(/'/g,"'").replace(/"/g,""")),c.html('
      1. '+o.replace(/[\r\t\n]+/g,"
      2. ")+"
      "),c.find(">.layui-code-h3")[0]||c.prepend('

      '+(c.attr("lay-title")||e.title||"code")+(e.about?'layui.code':"")+"

      ");var d=c.find(">.layui-code-ol");c.addClass("layui-box layui-code-view"),(c.attr("lay-skin")||e.skin)&&c.addClass("layui-code-"+(c.attr("lay-skin")||e.skin)),(d.find("li").length/100|0)>0&&d.css("margin-left",(d.find("li").length/100|0)+"px"),(c.attr("lay-height")||e.height)&&d.css("max-height",c.attr("lay-height")||e.height)})})}).addcss("modules/code.css","skincodecss"); \ No newline at end of file diff --git a/Public/layui/lay/modules/code.js b/Public/layui/lay/modules/code.js deleted file mode 100644 index 1e41610..0000000 --- a/Public/layui/lay/modules/code.js +++ /dev/null @@ -1,2 +0,0 @@ -/** layui-v1.0.9_rls MIT License By http://www.layui.com */ - ;layui.define("jquery",function(e){"use strict";var a=layui.jquery,l="http://www.layui.com/doc/modules/code.html";e("code",function(e){var t=[];e=e||{},e.elem=a(e.elem||".layui-code"),e.about=!("about"in e)||e.about,e.elem.each(function(){t.push(this)}),layui.each(t.reverse(),function(t,i){var c=a(i),o=c.html();(c.attr("lay-encode")||e.encode)&&(o=o.replace(/&(?!#?[a-zA-Z0-9]+;)/g,"&").replace(//g,">").replace(/'/g,"'").replace(/"/g,""")),c.html('
      1. '+o.replace(/[\r\t\n]+/g,"
      2. ")+"
      "),c.find(">.layui-code-h3")[0]||c.prepend('

      '+(c.attr("lay-title")||e.title||"code")+(e.about?'layui.code':"")+"

      ");var d=c.find(">.layui-code-ol");c.addClass("layui-box layui-code-view"),(c.attr("lay-skin")||e.skin)&&c.addClass("layui-code-"+(c.attr("lay-skin")||e.skin)),(d.find("li").length/100|0)>0&&d.css("margin-left",(d.find("li").length/100|0)+"px"),(c.attr("lay-height")||e.height)&&d.css("max-height",c.attr("lay-height")||e.height)})})}).addcss("modules/code.css","skincodecss"); \ No newline at end of file diff --git a/Public/layui/lay/modules/element.js b/Public/layui/lay/modules/element.js deleted file mode 100644 index e724324..0000000 --- a/Public/layui/lay/modules/element.js +++ /dev/null @@ -1,2 +0,0 @@ -/** layui-v1.0.9_rls MIT License By http://www.layui.com */ - ;layui.define("jquery",function(i){"use strict";var a=layui.jquery,t=(layui.hint(),layui.device()),l="element",e="layui-this",n="layui-show",s=function(){this.config={}};s.prototype.set=function(i){var t=this;return a.extend(!0,t.config,i),t},s.prototype.on=function(i,a){return layui.onevent(l,i,a)},s.prototype.tabAdd=function(i,t){var l=".layui-tab-title",e=a(".layui-tab[lay-filter="+i+"]"),n=e.children(l),s=e.children(".layui-tab-content");return n.append('
    • '+(t.title||"unnaming")+"
    • "),s.append('
      '+(t.content||"")+"
      "),f.hideTabMore(!0),f.tabAuto(),this},s.prototype.tabDelete=function(i,t){var l=".layui-tab-title",e=a(".layui-tab[lay-filter="+i+"]"),n=e.children(l),s=n.find('>li[lay-id="'+t+'"]');return f.tabDelete(null,s),this},s.prototype.tabChange=function(i,t){var l=".layui-tab-title",e=a(".layui-tab[lay-filter="+i+"]"),n=e.children(l),s=n.find('>li[lay-id="'+t+'"]');return f.tabClick(null,null,s),this},s.prototype.progress=function(i,t){var l="layui-progress",e=a("."+l+"[lay-filter="+i+"]"),n=e.find("."+l+"-bar"),s=n.find("."+l+"-text");return n.css("width",t),s.text(t),this};var o=".layui-nav",c="layui-nav-item",r="layui-nav-bar",u="layui-nav-tree",d="layui-nav-child",h="layui-nav-more",y="layui-anim layui-anim-upbit",f={tabClick:function(i,t,s){var o=s||a(this),t=t||o.parent().children("li").index(o),c=o.parents(".layui-tab").eq(0),r=c.children(".layui-tab-content").children(".layui-tab-item"),u=c.attr("lay-filter");o.addClass(e).siblings().removeClass(e),r.eq(t).addClass(n).siblings().removeClass(n),layui.event.call(this,l,"tab("+u+")",{elem:c,index:t})},tabDelete:function(i,t){var l=t||a(this).parent(),n=l.index(),s=l.parents(".layui-tab").eq(0),o=s.children(".layui-tab-content").children(".layui-tab-item");l.hasClass(e)&&(l.next()[0]?f.tabClick.call(l.next()[0],null,n+1):l.prev()[0]&&f.tabClick.call(l.prev()[0],null,n-1)),l.remove(),o.eq(n).remove(),setTimeout(function(){f.tabAuto()},50)},tabAuto:function(){var i="layui-tab-more",l="layui-tab-bar",e="layui-tab-close",n=this;a(".layui-tab").each(function(){var s=a(this),o=s.children(".layui-tab-title"),c=(s.children(".layui-tab-content").children(".layui-tab-item"),'lay-stope="tabmore"'),r=a('');if(n===window&&8!=t.ie&&f.hideTabMore(!0),s.attr("lay-allowClose")&&o.find("li").each(function(){var i=a(this);if(!i.find("."+e)[0]){var t=a('');t.on("click",f.tabDelete),i.append(t)}}),o.prop("scrollWidth")>o.outerWidth()+1){if(o.find("."+l)[0])return;o.append(r),s.attr("overflow",""),r.on("click",function(a){o[this.title?"removeClass":"addClass"](i),this.title=this.title?"":"收缩"})}else o.find("."+l).remove(),s.removeAttr("overflow")})},hideTabMore:function(i){var t=a(".layui-tab-title");i!==!0&&"tabmore"===a(i.target).attr("lay-stope")||(t.removeClass("layui-tab-more"),t.find(".layui-tab-bar").attr("title",""))},clickThis:function(){var i=a(this),t=i.parents(o),n=t.attr("lay-filter");i.find("."+d)[0]||(t.find("."+e).removeClass(e),i.addClass(e),layui.event.call(this,l,"nav("+n+")",i))},clickChild:function(){var i=a(this),t=i.parents(o),n=t.attr("lay-filter");t.find("."+e).removeClass(e),i.addClass(e),layui.event.call(this,l,"nav("+n+")",i)},showChild:function(){var i=a(this),t=i.parents(o),l=i.parent(),e=i.siblings("."+d);t.hasClass(u)&&(e.removeClass(y),l["none"===e.css("display")?"addClass":"removeClass"](c+"ed"))},collapse:function(){var i=a(this),t=i.find(".layui-colla-icon"),e=i.siblings(".layui-colla-content"),s=i.parents(".layui-collapse").eq(0),o=s.attr("lay-filter"),c="none"===e.css("display");if("string"==typeof s.attr("lay-accordion")){var r=s.children(".layui-colla-item").children("."+n);r.siblings(".layui-colla-title").children(".layui-colla-icon").html(""),r.removeClass(n)}e[c?"addClass":"removeClass"](n),t.html(c?"":""),layui.event.call(this,l,"collapse("+o+")",{title:i,content:e,show:c})}};s.prototype.init=function(i){var l={tab:function(){f.tabAuto.call({})},nav:function(){var i,l,e,s=200,p=function(o,c){var r=a(this),f=r.find("."+d);c.hasClass(u)?o.css({top:r.position().top,height:r.children("a").height(),opacity:1}):(f.addClass(y),o.css({left:r.position().left+parseFloat(r.css("marginLeft")),top:r.position().top+r.height()-5}),i=setTimeout(function(){o.css({width:r.width(),opacity:1})},t.ie&&t.ie<10?0:s),clearTimeout(e),"block"===f.css("display")&&clearTimeout(l),l=setTimeout(function(){f.addClass(n),r.find("."+h).addClass(h+"d")},300))};a(o).each(function(){var t=a(this),o=a(''),y=t.find("."+c);t.find("."+r)[0]||(t.append(o),y.on("mouseenter",function(){p.call(this,o,t)}).on("mouseleave",function(){t.hasClass(u)||(clearTimeout(l),l=setTimeout(function(){t.find("."+d).removeClass(n),t.find("."+h).removeClass(h+"d")},300))}),t.on("mouseleave",function(){clearTimeout(i),e=setTimeout(function(){t.hasClass(u)?o.css({height:0,top:o.position().top+o.height()/2,opacity:0}):o.css({width:0,left:o.position().left+o.width()/2,opacity:0})},s)})),y.each(function(){var i=a(this),t=i.find("."+d);if(t[0]&&!i.find("."+h)[0]){var l=i.children("a");l.append('')}i.off("click",f.clickThis).on("click",f.clickThis),i.children("a").off("click",f.showChild).on("click",f.showChild),t.children("dd").off("click",f.clickChild).on("click",f.clickChild)})})},breadcrumb:function(){var i=".layui-breadcrumb";a(i).each(function(){var i=a(this),t=i.attr("lay-separator")||">",l=i.find("a");l.find(".layui-box")[0]||(l.each(function(i){i!==l.length-1&&a(this).append(''+t+"")}),i.css("visibility","visible"))})},progress:function(){var i="layui-progress";a("."+i).each(function(){var t=a(this),l=t.find(".layui-progress-bar"),e=l.attr("lay-percent");l.css("width",e),t.attr("lay-showPercent")&&setTimeout(function(){var a=Math.round(l.width()/t.width()*100);a>100&&(a=100),l.html(''+a+"%")},350)})},collapse:function(){var i="layui-collapse";a("."+i).each(function(){var i=a(this).find(".layui-colla-item");i.each(function(){var i=a(this),t=i.find(".layui-colla-title"),l=i.find(".layui-colla-content"),e="none"===l.css("display");t.find(".layui-colla-icon").remove(),t.append(''+(e?"":"")+""),t.off("click",f.collapse).on("click",f.collapse)})})}};return layui.each(l,function(i,a){a()})};var p=new s,v=a(document);p.init();var b=".layui-tab-title li";v.on("click",b,f.tabClick),v.on("click",f.hideTabMore),a(window).on("resize",f.tabAuto),i(l,function(i){return p.set(i)})}); \ No newline at end of file diff --git a/Public/layui/lay/modules/flow.js b/Public/layui/lay/modules/flow.js deleted file mode 100644 index 295d084..0000000 --- a/Public/layui/lay/modules/flow.js +++ /dev/null @@ -1,2 +0,0 @@ -/** layui-v1.0.9_rls MIT License By http://www.layui.com */ - ;layui.define("jquery",function(e){"use strict";var l=layui.jquery,o=function(e){},t='';o.prototype.load=function(e){var o,i,n,r,a=this,c=0;e=e||{};var u=l(e.elem);if(u[0]){var f=l(e.scrollElem||document),m=e.mb||50,s=!("isAuto"in e)||e.isAuto,y=e.end||"没有更多了",v=e.scrollElem&&e.scrollElem!==document,d="加载更多",h=l('");u.find(".layui-flow-more")[0]||u.append(h);var p=function(e,t){e=l(e),h.before(e),t=0==t||null,t?h.html(y):h.find("a").html(d),i=t,o=null,n&&n()},g=function(){o=!0,h.find("a").html(t),"function"==typeof e.done&&e.done(++c,p)};if(g(),h.find("a").on("click",function(){l(this);i||o||g()}),e.isLazyimg)var n=a.lazyimg({elem:e.elem+" img",scrollElem:e.scrollElem});return s?(f.on("scroll",function(){var e=l(this),t=e.scrollTop();r&&clearTimeout(r),i||(r=setTimeout(function(){var i=v?e.height():l(window).height(),n=v?e.prop("scrollHeight"):document.documentElement.scrollHeight;n-t-i<=m&&(o||g())},100))}),a):a}},o.prototype.lazyimg=function(e){var o,t=this,i=0;e=e||{};var n=l(e.scrollElem||document),r=e.elem||"img",a=e.scrollElem&&e.scrollElem!==document,c=function(e,l){var o=n.scrollTop(),r=o+l,c=a?function(){return e.offset().top-n.offset().top+o}():e.offset().top;if(c>=o&&c<=r&&!e.attr("src")){var f=e.attr("lay-src");layui.img(f,function(){var l=t.lazyimg.elem.eq(i);e.attr("src",f).removeAttr("lay-src"),l[0]&&u(l),i++})}},u=function(e,o){var u=a?(o||n).height():l(window).height(),f=n.scrollTop(),m=f+u;if(t.lazyimg.elem=l(r),e)c(e,u);else for(var s=0;sm)break}};if(u(),!o){var f;n.on("scroll",function(){var e=l(this);f&&clearTimeout(f),f=setTimeout(function(){u(null,e)},50)}),o=!0}return u},e("flow",new o)}); \ No newline at end of file diff --git a/Public/layui/lay/modules/form.js b/Public/layui/lay/modules/form.js deleted file mode 100644 index a47339a..0000000 --- a/Public/layui/lay/modules/form.js +++ /dev/null @@ -1,2 +0,0 @@ -/** layui-v1.0.9_rls MIT License By http://www.layui.com */ - ;layui.define("layer",function(e){"use strict";var i=layui.jquery,t=layui.layer,a=layui.hint(),n=layui.device(),l="form",r=".layui-form",s="layui-this",o="layui-hide",c="layui-disabled",u=function(){this.config={verify:{required:[/[\S]+/,"必填项不能为空"],phone:[/^1\d{10}$/,"请输入正确的手机号"],email:[/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/,"邮箱格式不正确"],url:[/(^#)|(^http(s*):\/\/[^\s]+\.[^\s]+)/,"链接格式不正确"],number:[/^\d+$/,"只能填写数字"],date:[/^(\d{4})[-\/](\d{1}|0\d{1}|1[0-2])([-\/](\d{1}|0\d{1}|[1-2][0-9]|3[0-1]))*$/,"日期格式不正确"],identity:[/(^\d{15}$)|(^\d{17}(x|X|\d)$)/,"请输入正确的身份证号"]}}};u.prototype.set=function(e){var t=this;return i.extend(!0,t.config,e),t},u.prototype.verify=function(e){var t=this;return i.extend(!0,t.config.verify,e),t},u.prototype.on=function(e,i){return layui.onevent(l,e,i)},u.prototype.render=function(e){var t=this,n={select:function(){var e,t="请选择",a="layui-form-select",n="layui-select-title",u="layui-select-none",d="",f=i(r).find("select"),y=function(t,l){i(t.target).parent().hasClass(n)&&!l||(i("."+a).removeClass(a+"ed"),e&&d&&e.val(d)),e=null},v=function(t,r,f){var v=i(this),h=t.find("."+n),p=h.find("input"),m=t.find("dl"),k=m.children("dd");if(!r){var b=function(){t.addClass(a+"ed"),k.removeClass(o)},x=function(){t.removeClass(a+"ed"),p.blur(),g(p.val(),function(e){e&&(d=m.find("."+s).html(),p&&p.val(d))})};h.on("click",function(e){t.hasClass(a+"ed")?x():(y(e,!0),b()),m.find("."+u).remove()}),h.find(".layui-edge").on("click",function(){p.focus()}),p.on("keyup",function(e){var i=e.keyCode;9===i&&b()}).on("keydown",function(e){var i=e.keyCode;9===i?x():13===i&&e.preventDefault()});var g=function(e,t,a){var n=0;layui.each(k,function(){var t=i(this),l=t.text(),r=l.indexOf(e)===-1;(""===e||"blur"===a?e!==l:r)&&n++,"keyup"===a&&t[r?"addClass":"removeClass"](o)});var l=n===k.length;return t(l),l},C=function(e){var i=this.value,t=e.keyCode;return 9!==t&&13!==t&&37!==t&&38!==t&&39!==t&&40!==t&&(g(i,function(e){e?m.find("."+u)[0]||m.append('

      无匹配项

      '):m.find("."+u).remove()},"keyup"),void(""===i&&m.find("."+u).remove()))};f&&p.on("keyup",C).on("blur",function(i){e=p,d=m.find("."+s).html(),setTimeout(function(){g(p.val(),function(e){e&&!d&&p.val("")},"blur")},200)}),k.on("click",function(){var e=i(this),a=e.attr("lay-value"),n=v.attr("lay-filter");return!e.hasClass(c)&&(v.val(a).removeClass("layui-form-danger"),p.val(e.text()),e.addClass(s).siblings().removeClass(s),layui.event.call(this,l,"select("+n+")",{elem:v[0],value:a,othis:t}),x(),!1)}),t.find("dl>dt").on("click",function(e){return!1}),i(document).off("click",y).on("click",y)}};f.each(function(e,l){var r=i(this),o=r.next("."+a),u=this.disabled,d=l.value,f=i(l.options[l.selectedIndex]);if("string"==typeof r.attr("lay-ignore"))return r.show();var y="string"==typeof r.attr("lay-search"),h=i(['
      ','
      ','
      ','
      '+function(e){var i=[];return layui.each(e,function(e,t){(0!==e||t.value)&&("optgroup"===t.tagName.toLowerCase()?i.push("
      "+t.label+"
      "):i.push('
      '+t.innerHTML+"
      "))}),i.join("")}(r.find("*"))+"
      ","
      "].join(""));o[0]&&o.remove(),r.after(h),v.call(this,h,u,y)})},checkbox:function(){var e={checkbox:["layui-form-checkbox","layui-form-checked","checkbox"],_switch:["layui-form-switch","layui-form-onswitch","switch"]},t=i(r).find("input[type=checkbox]"),a=function(e,t){var a=i(this);e.on("click",function(){var i=a.attr("lay-filter"),n=(a.attr("lay-text")||"").split("|");a[0].disabled||(a[0].checked?(a[0].checked=!1,e.removeClass(t[1]).find("em").text(n[1])):(a[0].checked=!0,e.addClass(t[1]).find("em").text(n[0])),layui.event.call(a[0],l,t[2]+"("+i+")",{elem:a[0],value:a[0].value,othis:e}))})};t.each(function(t,n){var l=i(this),r=l.attr("lay-skin"),s=(l.attr("lay-text")||"").split("|"),o=this.disabled;"switch"===r&&(r="_"+r);var u=e[r]||e.checkbox;if("string"==typeof l.attr("lay-ignore"))return l.show();var d=l.next("."+u[0]),f=i(['
      ',{_switch:""+((n.checked?s[0]:s[1])||"")+""}[r]||(n.title.replace(/\s/g,"")?""+n.title+"":"")+''+(r?"":"")+"","
      "].join(""));d[0]&&d.remove(),l.after(f),a.call(this,f,u)})},radio:function(){var e="layui-form-radio",t=["",""],a=i(r).find("input[type=radio]"),n=function(a){var n=i(this),s="layui-anim-scaleSpring";a.on("click",function(){var o=n[0].name,c=n.parents(r),u=n.attr("lay-filter"),d=c.find("input[name="+o.replace(/(\.|#|\[|\])/g,"\\$1")+"]");n[0].disabled||(layui.each(d,function(){var a=i(this).next("."+e);this.checked=!1,a.removeClass(e+"ed"),a.find(".layui-icon").removeClass(s).html(t[1])}),n[0].checked=!0,a.addClass(e+"ed"),a.find(".layui-icon").addClass(s).html(t[0]),layui.event.call(n[0],l,"radio("+u+")",{elem:n[0],value:n[0].value,othis:a}))})};a.each(function(a,l){var r=i(this),s=r.next("."+e),o=this.disabled;if("string"==typeof r.attr("lay-ignore"))return r.show();var u=i(['
      ',''+t[l.checked?0:1]+"",""+(l.title||"未命名")+"","
      "].join(""));s[0]&&s.remove(),r.after(u),n.call(this,u)})}};return e?n[e]?n[e]():a.error("不支持的"+e+"表单渲染"):layui.each(n,function(e,i){i()}),t};var d=function(){var e=i(this),a=f.config.verify,s=null,o="layui-form-danger",c={},u=e.parents(r),d=u.find("*[lay-verify]"),y=e.parents("form")[0],v=u.find("input,select,textarea"),h=e.attr("lay-filter");return layui.each(d,function(e,l){var r=i(this),c=r.attr("lay-verify").split("|"),u="",d=r.val();if(r.removeClass(o),layui.each(c,function(e,i){var c="function"==typeof a[i];if(a[i]&&(c?u=a[i](d,l):!a[i][0].test(d)))return t.msg(u||a[i][1],{icon:5,shift:6}),n.android||n.ios||l.focus(),r.addClass(o),s=!0}),s)return s}),!s&&(layui.each(v,function(e,i){i.name&&(/^checkbox|radio$/.test(i.type)&&!i.checked||(c[i.name]=i.value))}),layui.event.call(this,l,"submit("+h+")",{elem:this,form:y,field:c}))},f=new u,y=i(document);f.render(),y.on("reset",r,function(){setTimeout(function(){f.render()},50)}),y.on("submit",r,d).on("click","*[lay-submit]",d),e(l,function(e){return f.set(e)})}); \ No newline at end of file diff --git a/Public/layui/lay/modules/jquery.js b/Public/layui/lay/modules/jquery.js deleted file mode 100644 index 015155e..0000000 --- a/Public/layui/lay/modules/jquery.js +++ /dev/null @@ -1,5 +0,0 @@ -/** layui-v1.0.9_rls MIT License By http://www.layui.com */ - ;!function(e,t){"object"==typeof module&&"object"==typeof module.exports?module.exports=e.document?t(e,!0):function(e){if(!e.document)throw new Error("jQuery requires a window with a document");return t(e)}:t(e)}("undefined"!=typeof window?window:this,function(e,t){function n(e){var t=!!e&&"length"in e&&e.length,n=pe.type(e);return"function"!==n&&!pe.isWindow(e)&&("array"===n||0===t||"number"==typeof t&&t>0&&t-1 in e)}function r(e,t,n){if(pe.isFunction(t))return pe.grep(e,function(e,r){return!!t.call(e,r,e)!==n});if(t.nodeType)return pe.grep(e,function(e){return e===t!==n});if("string"==typeof t){if(Ce.test(t))return pe.filter(t,e,n);t=pe.filter(t,e)}return pe.grep(e,function(e){return pe.inArray(e,t)>-1!==n})}function i(e,t){do e=e[t];while(e&&1!==e.nodeType);return e}function o(e){var t={};return pe.each(e.match(De)||[],function(e,n){t[n]=!0}),t}function a(){re.addEventListener?(re.removeEventListener("DOMContentLoaded",s),e.removeEventListener("load",s)):(re.detachEvent("onreadystatechange",s),e.detachEvent("onload",s))}function s(){(re.addEventListener||"load"===e.event.type||"complete"===re.readyState)&&(a(),pe.ready())}function u(e,t,n){if(void 0===n&&1===e.nodeType){var r="data-"+t.replace(_e,"-$1").toLowerCase();if(n=e.getAttribute(r),"string"==typeof n){try{n="true"===n||"false"!==n&&("null"===n?null:+n+""===n?+n:qe.test(n)?pe.parseJSON(n):n)}catch(i){}pe.data(e,t,n)}else n=void 0}return n}function l(e){var t;for(t in e)if(("data"!==t||!pe.isEmptyObject(e[t]))&&"toJSON"!==t)return!1;return!0}function c(e,t,n,r){if(He(e)){var i,o,a=pe.expando,s=e.nodeType,u=s?pe.cache:e,l=s?e[a]:e[a]&&a;if(l&&u[l]&&(r||u[l].data)||void 0!==n||"string"!=typeof t)return l||(l=s?e[a]=ne.pop()||pe.guid++:a),u[l]||(u[l]=s?{}:{toJSON:pe.noop}),"object"!=typeof t&&"function"!=typeof t||(r?u[l]=pe.extend(u[l],t):u[l].data=pe.extend(u[l].data,t)),o=u[l],r||(o.data||(o.data={}),o=o.data),void 0!==n&&(o[pe.camelCase(t)]=n),"string"==typeof t?(i=o[t],null==i&&(i=o[pe.camelCase(t)])):i=o,i}}function f(e,t,n){if(He(e)){var r,i,o=e.nodeType,a=o?pe.cache:e,s=o?e[pe.expando]:pe.expando;if(a[s]){if(t&&(r=n?a[s]:a[s].data)){pe.isArray(t)?t=t.concat(pe.map(t,pe.camelCase)):t in r?t=[t]:(t=pe.camelCase(t),t=t in r?[t]:t.split(" ")),i=t.length;for(;i--;)delete r[t[i]];if(n?!l(r):!pe.isEmptyObject(r))return}(n||(delete a[s].data,l(a[s])))&&(o?pe.cleanData([e],!0):fe.deleteExpando||a!=a.window?delete a[s]:a[s]=void 0)}}}function d(e,t,n,r){var i,o=1,a=20,s=r?function(){return r.cur()}:function(){return pe.css(e,t,"")},u=s(),l=n&&n[3]||(pe.cssNumber[t]?"":"px"),c=(pe.cssNumber[t]||"px"!==l&&+u)&&Me.exec(pe.css(e,t));if(c&&c[3]!==l){l=l||c[3],n=n||[],c=+u||1;do o=o||".5",c/=o,pe.style(e,t,c+l);while(o!==(o=s()/u)&&1!==o&&--a)}return n&&(c=+c||+u||0,i=n[1]?c+(n[1]+1)*n[2]:+n[2],r&&(r.unit=l,r.start=c,r.end=i)),i}function p(e){var t=ze.split("|"),n=e.createDocumentFragment();if(n.createElement)for(;t.length;)n.createElement(t.pop());return n}function h(e,t){var n,r,i=0,o="undefined"!=typeof e.getElementsByTagName?e.getElementsByTagName(t||"*"):"undefined"!=typeof e.querySelectorAll?e.querySelectorAll(t||"*"):void 0;if(!o)for(o=[],n=e.childNodes||e;null!=(r=n[i]);i++)!t||pe.nodeName(r,t)?o.push(r):pe.merge(o,h(r,t));return void 0===t||t&&pe.nodeName(e,t)?pe.merge([e],o):o}function g(e,t){for(var n,r=0;null!=(n=e[r]);r++)pe._data(n,"globalEval",!t||pe._data(t[r],"globalEval"))}function m(e){Be.test(e.type)&&(e.defaultChecked=e.checked)}function y(e,t,n,r,i){for(var o,a,s,u,l,c,f,d=e.length,y=p(t),v=[],x=0;x"!==f[1]||Ve.test(a)?0:u:u.firstChild,o=a&&a.childNodes.length;o--;)pe.nodeName(c=a.childNodes[o],"tbody")&&!c.childNodes.length&&a.removeChild(c);for(pe.merge(v,u.childNodes),u.textContent="";u.firstChild;)u.removeChild(u.firstChild);u=y.lastChild}else v.push(t.createTextNode(a));for(u&&y.removeChild(u),fe.appendChecked||pe.grep(h(v,"input"),m),x=0;a=v[x++];)if(r&&pe.inArray(a,r)>-1)i&&i.push(a);else if(s=pe.contains(a.ownerDocument,a),u=h(y.appendChild(a),"script"),s&&g(u),n)for(o=0;a=u[o++];)Ie.test(a.type||"")&&n.push(a);return u=null,y}function v(){return!0}function x(){return!1}function b(){try{return re.activeElement}catch(e){}}function w(e,t,n,r,i,o){var a,s;if("object"==typeof t){"string"!=typeof n&&(r=r||n,n=void 0);for(s in t)w(e,s,n,r,t[s],o);return e}if(null==r&&null==i?(i=n,r=n=void 0):null==i&&("string"==typeof n?(i=r,r=void 0):(i=r,r=n,n=void 0)),i===!1)i=x;else if(!i)return e;return 1===o&&(a=i,i=function(e){return pe().off(e),a.apply(this,arguments)},i.guid=a.guid||(a.guid=pe.guid++)),e.each(function(){pe.event.add(this,t,i,r,n)})}function T(e,t){return pe.nodeName(e,"table")&&pe.nodeName(11!==t.nodeType?t:t.firstChild,"tr")?e.getElementsByTagName("tbody")[0]||e.appendChild(e.ownerDocument.createElement("tbody")):e}function C(e){return e.type=(null!==pe.find.attr(e,"type"))+"/"+e.type,e}function E(e){var t=it.exec(e.type);return t?e.type=t[1]:e.removeAttribute("type"),e}function N(e,t){if(1===t.nodeType&&pe.hasData(e)){var n,r,i,o=pe._data(e),a=pe._data(t,o),s=o.events;if(s){delete a.handle,a.events={};for(n in s)for(r=0,i=s[n].length;r1&&"string"==typeof p&&!fe.checkClone&&rt.test(p))return e.each(function(i){var o=e.eq(i);g&&(t[0]=p.call(this,i,o.html())),S(o,t,n,r)});if(f&&(l=y(t,e[0].ownerDocument,!1,e,r),i=l.firstChild,1===l.childNodes.length&&(l=i),i||r)){for(s=pe.map(h(l,"script"),C),a=s.length;c")).appendTo(t.documentElement),t=(ut[0].contentWindow||ut[0].contentDocument).document,t.write(),t.close(),n=D(e,t),ut.detach()),lt[e]=n),n}function L(e,t){return{get:function(){return e()?void delete this.get:(this.get=t).apply(this,arguments)}}}function H(e){if(e in Et)return e;for(var t=e.charAt(0).toUpperCase()+e.slice(1),n=Ct.length;n--;)if(e=Ct[n]+t,e in Et)return e}function q(e,t){for(var n,r,i,o=[],a=0,s=e.length;a=0&&n=0},isEmptyObject:function(e){var t;for(t in e)return!1;return!0},isPlainObject:function(e){var t;if(!e||"object"!==pe.type(e)||e.nodeType||pe.isWindow(e))return!1;try{if(e.constructor&&!ce.call(e,"constructor")&&!ce.call(e.constructor.prototype,"isPrototypeOf"))return!1}catch(n){return!1}if(!fe.ownFirst)for(t in e)return ce.call(e,t);for(t in e);return void 0===t||ce.call(e,t)},type:function(e){return null==e?e+"":"object"==typeof e||"function"==typeof e?ue[le.call(e)]||"object":typeof e},globalEval:function(t){t&&pe.trim(t)&&(e.execScript||function(t){e.eval.call(e,t)})(t)},camelCase:function(e){return e.replace(ge,"ms-").replace(me,ye)},nodeName:function(e,t){return e.nodeName&&e.nodeName.toLowerCase()===t.toLowerCase()},each:function(e,t){var r,i=0;if(n(e))for(r=e.length;iT.cacheLength&&delete e[t.shift()],e[n+" "]=r}var t=[];return e}function r(e){return e[P]=!0,e}function i(e){var t=H.createElement("div");try{return!!e(t)}catch(n){return!1}finally{t.parentNode&&t.parentNode.removeChild(t),t=null}}function o(e,t){for(var n=e.split("|"),r=n.length;r--;)T.attrHandle[n[r]]=t}function a(e,t){var n=t&&e,r=n&&1===e.nodeType&&1===t.nodeType&&(~t.sourceIndex||V)-(~e.sourceIndex||V);if(r)return r;if(n)for(;n=n.nextSibling;)if(n===t)return-1;return e?1:-1}function s(e){return function(t){var n=t.nodeName.toLowerCase();return"input"===n&&t.type===e}}function u(e){return function(t){var n=t.nodeName.toLowerCase();return("input"===n||"button"===n)&&t.type===e}}function l(e){return r(function(t){return t=+t,r(function(n,r){for(var i,o=e([],n.length,t),a=o.length;a--;)n[i=o[a]]&&(n[i]=!(r[i]=n[i]))})})}function c(e){return e&&"undefined"!=typeof e.getElementsByTagName&&e}function f(){}function d(e){for(var t=0,n=e.length,r="";t1?function(t,n,r){for(var i=e.length;i--;)if(!e[i](t,n,r))return!1;return!0}:e[0]}function g(e,n,r){for(var i=0,o=n.length;i-1&&(r[l]=!(a[l]=f))}}else x=m(x===a?x.splice(h,x.length):x),o?o(null,a,x,u):Q.apply(a,x)})}function v(e){for(var t,n,r,i=e.length,o=T.relative[e[0].type],a=o||T.relative[" "],s=o?1:0,u=p(function(e){return e===t},a,!0),l=p(function(e){return ee(t,e)>-1},a,!0),c=[function(e,n,r){var i=!o&&(r||n!==A)||((t=n).nodeType?u(e,n,r):l(e,n,r));return t=null,i}];s1&&h(c),s>1&&d(e.slice(0,s-1).concat({value:" "===e[s-2].type?"*":""})).replace(se,"$1"),n,s0,o=e.length>0,a=function(r,a,s,u,l){var c,f,d,p=0,h="0",g=r&&[],y=[],v=A,x=r||o&&T.find.TAG("*",l),b=W+=null==v?1:Math.random()||.1,w=x.length;for(l&&(A=a===H||a||l);h!==w&&null!=(c=x[h]);h++){if(o&&c){for(f=0,a||c.ownerDocument===H||(L(c),s=!_);d=e[f++];)if(d(c,a||H,s)){u.push(c);break}l&&(W=b)}i&&((c=!d&&c)&&p--,r&&g.push(c))}if(p+=h,i&&h!==p){for(f=0;d=n[f++];)d(g,y,a,s);if(r){if(p>0)for(;h--;)g[h]||y[h]||(y[h]=G.call(u));y=m(y)}Q.apply(u,y),l&&!r&&y.length>0&&p+n.length>1&&t.uniqueSort(u)}return l&&(W=b,A=v),g};return i?r(a):a}var b,w,T,C,E,N,k,S,A,D,j,L,H,q,_,F,M,O,R,P="sizzle"+1*new Date,B=e.document,W=0,I=0,$=n(),z=n(),X=n(),U=function(e,t){return e===t&&(j=!0),0},V=1<<31,Y={}.hasOwnProperty,J=[],G=J.pop,K=J.push,Q=J.push,Z=J.slice,ee=function(e,t){for(var n=0,r=e.length;n+~]|"+ne+")"+ne+"*"),ce=new RegExp("="+ne+"*([^\\]'\"]*?)"+ne+"*\\]","g"),fe=new RegExp(oe),de=new RegExp("^"+re+"$"),pe={ID:new RegExp("^#("+re+")"),CLASS:new RegExp("^\\.("+re+")"),TAG:new RegExp("^("+re+"|[*])"),ATTR:new RegExp("^"+ie),PSEUDO:new RegExp("^"+oe),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+ne+"*(even|odd|(([+-]|)(\\d*)n|)"+ne+"*(?:([+-]|)"+ne+"*(\\d+)|))"+ne+"*\\)|)","i"),bool:new RegExp("^(?:"+te+")$","i"),needsContext:new RegExp("^"+ne+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+ne+"*((?:-\\d)?\\d*)"+ne+"*\\)|)(?=[^-]|$)","i")},he=/^(?:input|select|textarea|button)$/i,ge=/^h\d$/i,me=/^[^{]+\{\s*\[native \w/,ye=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,ve=/[+~]/,xe=/'|\\/g,be=new RegExp("\\\\([\\da-f]{1,6}"+ne+"?|("+ne+")|.)","ig"),we=function(e,t,n){var r="0x"+t-65536;return r!==r||n?t:r<0?String.fromCharCode(r+65536):String.fromCharCode(r>>10|55296,1023&r|56320)},Te=function(){L()};try{Q.apply(J=Z.call(B.childNodes),B.childNodes),J[B.childNodes.length].nodeType}catch(Ce){Q={apply:J.length?function(e,t){K.apply(e,Z.call(t))}:function(e,t){for(var n=e.length,r=0;e[n++]=t[r++];);e.length=n-1}}}w=t.support={},E=t.isXML=function(e){var t=e&&(e.ownerDocument||e).documentElement;return!!t&&"HTML"!==t.nodeName},L=t.setDocument=function(e){var t,n,r=e?e.ownerDocument||e:B;return r!==H&&9===r.nodeType&&r.documentElement?(H=r,q=H.documentElement,_=!E(H),(n=H.defaultView)&&n.top!==n&&(n.addEventListener?n.addEventListener("unload",Te,!1):n.attachEvent&&n.attachEvent("onunload",Te)),w.attributes=i(function(e){return e.className="i",!e.getAttribute("className")}),w.getElementsByTagName=i(function(e){return e.appendChild(H.createComment("")),!e.getElementsByTagName("*").length}),w.getElementsByClassName=me.test(H.getElementsByClassName),w.getById=i(function(e){return q.appendChild(e).id=P,!H.getElementsByName||!H.getElementsByName(P).length}),w.getById?(T.find.ID=function(e,t){if("undefined"!=typeof t.getElementById&&_){var n=t.getElementById(e);return n?[n]:[]}},T.filter.ID=function(e){var t=e.replace(be,we);return function(e){return e.getAttribute("id")===t}}):(delete T.find.ID,T.filter.ID=function(e){var t=e.replace(be,we);return function(e){var n="undefined"!=typeof e.getAttributeNode&&e.getAttributeNode("id");return n&&n.value===t}}),T.find.TAG=w.getElementsByTagName?function(e,t){return"undefined"!=typeof t.getElementsByTagName?t.getElementsByTagName(e):w.qsa?t.querySelectorAll(e):void 0}:function(e,t){var n,r=[],i=0,o=t.getElementsByTagName(e);if("*"===e){for(;n=o[i++];)1===n.nodeType&&r.push(n);return r}return o},T.find.CLASS=w.getElementsByClassName&&function(e,t){if("undefined"!=typeof t.getElementsByClassName&&_)return t.getElementsByClassName(e)},M=[],F=[],(w.qsa=me.test(H.querySelectorAll))&&(i(function(e){q.appendChild(e).innerHTML="",e.querySelectorAll("[msallowcapture^='']").length&&F.push("[*^$]="+ne+"*(?:''|\"\")"),e.querySelectorAll("[selected]").length||F.push("\\["+ne+"*(?:value|"+te+")"),e.querySelectorAll("[id~="+P+"-]").length||F.push("~="),e.querySelectorAll(":checked").length||F.push(":checked"),e.querySelectorAll("a#"+P+"+*").length||F.push(".#.+[+~]")}),i(function(e){var t=H.createElement("input");t.setAttribute("type","hidden"),e.appendChild(t).setAttribute("name","D"),e.querySelectorAll("[name=d]").length&&F.push("name"+ne+"*[*^$|!~]?="),e.querySelectorAll(":enabled").length||F.push(":enabled",":disabled"),e.querySelectorAll("*,:x"),F.push(",.*:")})),(w.matchesSelector=me.test(O=q.matches||q.webkitMatchesSelector||q.mozMatchesSelector||q.oMatchesSelector||q.msMatchesSelector))&&i(function(e){w.disconnectedMatch=O.call(e,"div"),O.call(e,"[s!='']:x"),M.push("!=",oe)}),F=F.length&&new RegExp(F.join("|")),M=M.length&&new RegExp(M.join("|")),t=me.test(q.compareDocumentPosition),R=t||me.test(q.contains)?function(e,t){var n=9===e.nodeType?e.documentElement:e,r=t&&t.parentNode;return e===r||!(!r||1!==r.nodeType||!(n.contains?n.contains(r):e.compareDocumentPosition&&16&e.compareDocumentPosition(r)))}:function(e,t){if(t)for(;t=t.parentNode;)if(t===e)return!0;return!1},U=t?function(e,t){if(e===t)return j=!0,0;var n=!e.compareDocumentPosition-!t.compareDocumentPosition;return n?n:(n=(e.ownerDocument||e)===(t.ownerDocument||t)?e.compareDocumentPosition(t):1,1&n||!w.sortDetached&&t.compareDocumentPosition(e)===n?e===H||e.ownerDocument===B&&R(B,e)?-1:t===H||t.ownerDocument===B&&R(B,t)?1:D?ee(D,e)-ee(D,t):0:4&n?-1:1)}:function(e,t){if(e===t)return j=!0,0;var n,r=0,i=e.parentNode,o=t.parentNode,s=[e],u=[t];if(!i||!o)return e===H?-1:t===H?1:i?-1:o?1:D?ee(D,e)-ee(D,t):0;if(i===o)return a(e,t);for(n=e;n=n.parentNode;)s.unshift(n);for(n=t;n=n.parentNode;)u.unshift(n);for(;s[r]===u[r];)r++;return r?a(s[r],u[r]):s[r]===B?-1:u[r]===B?1:0},H):H},t.matches=function(e,n){return t(e,null,null,n)},t.matchesSelector=function(e,n){if((e.ownerDocument||e)!==H&&L(e),n=n.replace(ce,"='$1']"),w.matchesSelector&&_&&!X[n+" "]&&(!M||!M.test(n))&&(!F||!F.test(n)))try{var r=O.call(e,n);if(r||w.disconnectedMatch||e.document&&11!==e.document.nodeType)return r}catch(i){}return t(n,H,null,[e]).length>0},t.contains=function(e,t){return(e.ownerDocument||e)!==H&&L(e),R(e,t)},t.attr=function(e,t){(e.ownerDocument||e)!==H&&L(e);var n=T.attrHandle[t.toLowerCase()],r=n&&Y.call(T.attrHandle,t.toLowerCase())?n(e,t,!_):void 0;return void 0!==r?r:w.attributes||!_?e.getAttribute(t):(r=e.getAttributeNode(t))&&r.specified?r.value:null},t.error=function(e){throw new Error("Syntax error, unrecognized expression: "+e)},t.uniqueSort=function(e){var t,n=[],r=0,i=0;if(j=!w.detectDuplicates,D=!w.sortStable&&e.slice(0),e.sort(U),j){for(;t=e[i++];)t===e[i]&&(r=n.push(i));for(;r--;)e.splice(n[r],1)}return D=null,e},C=t.getText=function(e){var t,n="",r=0,i=e.nodeType;if(i){if(1===i||9===i||11===i){if("string"==typeof e.textContent)return e.textContent;for(e=e.firstChild;e;e=e.nextSibling)n+=C(e)}else if(3===i||4===i)return e.nodeValue}else for(;t=e[r++];)n+=C(t);return n},T=t.selectors={cacheLength:50,createPseudo:r,match:pe,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(e){return e[1]=e[1].replace(be,we),e[3]=(e[3]||e[4]||e[5]||"").replace(be,we),"~="===e[2]&&(e[3]=" "+e[3]+" "),e.slice(0,4)},CHILD:function(e){return e[1]=e[1].toLowerCase(),"nth"===e[1].slice(0,3)?(e[3]||t.error(e[0]),e[4]=+(e[4]?e[5]+(e[6]||1):2*("even"===e[3]||"odd"===e[3])),e[5]=+(e[7]+e[8]||"odd"===e[3])):e[3]&&t.error(e[0]),e},PSEUDO:function(e){var t,n=!e[6]&&e[2];return pe.CHILD.test(e[0])?null:(e[3]?e[2]=e[4]||e[5]||"":n&&fe.test(n)&&(t=N(n,!0))&&(t=n.indexOf(")",n.length-t)-n.length)&&(e[0]=e[0].slice(0,t),e[2]=n.slice(0,t)),e.slice(0,3))}},filter:{TAG:function(e){var t=e.replace(be,we).toLowerCase();return"*"===e?function(){return!0}:function(e){return e.nodeName&&e.nodeName.toLowerCase()===t}},CLASS:function(e){var t=$[e+" "];return t||(t=new RegExp("(^|"+ne+")"+e+"("+ne+"|$)"))&&$(e,function(e){return t.test("string"==typeof e.className&&e.className||"undefined"!=typeof e.getAttribute&&e.getAttribute("class")||"")})},ATTR:function(e,n,r){return function(i){var o=t.attr(i,e);return null==o?"!="===n:!n||(o+="","="===n?o===r:"!="===n?o!==r:"^="===n?r&&0===o.indexOf(r):"*="===n?r&&o.indexOf(r)>-1:"$="===n?r&&o.slice(-r.length)===r:"~="===n?(" "+o.replace(ae," ")+" ").indexOf(r)>-1:"|="===n&&(o===r||o.slice(0,r.length+1)===r+"-"))}},CHILD:function(e,t,n,r,i){var o="nth"!==e.slice(0,3),a="last"!==e.slice(-4),s="of-type"===t;return 1===r&&0===i?function(e){return!!e.parentNode}:function(t,n,u){var l,c,f,d,p,h,g=o!==a?"nextSibling":"previousSibling",m=t.parentNode,y=s&&t.nodeName.toLowerCase(),v=!u&&!s,x=!1;if(m){if(o){for(;g;){for(d=t;d=d[g];)if(s?d.nodeName.toLowerCase()===y:1===d.nodeType)return!1;h=g="only"===e&&!h&&"nextSibling"}return!0}if(h=[a?m.firstChild:m.lastChild],a&&v){for(d=m,f=d[P]||(d[P]={}),c=f[d.uniqueID]||(f[d.uniqueID]={}), -l=c[e]||[],p=l[0]===W&&l[1],x=p&&l[2],d=p&&m.childNodes[p];d=++p&&d&&d[g]||(x=p=0)||h.pop();)if(1===d.nodeType&&++x&&d===t){c[e]=[W,p,x];break}}else if(v&&(d=t,f=d[P]||(d[P]={}),c=f[d.uniqueID]||(f[d.uniqueID]={}),l=c[e]||[],p=l[0]===W&&l[1],x=p),x===!1)for(;(d=++p&&d&&d[g]||(x=p=0)||h.pop())&&((s?d.nodeName.toLowerCase()!==y:1!==d.nodeType)||!++x||(v&&(f=d[P]||(d[P]={}),c=f[d.uniqueID]||(f[d.uniqueID]={}),c[e]=[W,x]),d!==t)););return x-=i,x===r||x%r===0&&x/r>=0}}},PSEUDO:function(e,n){var i,o=T.pseudos[e]||T.setFilters[e.toLowerCase()]||t.error("unsupported pseudo: "+e);return o[P]?o(n):o.length>1?(i=[e,e,"",n],T.setFilters.hasOwnProperty(e.toLowerCase())?r(function(e,t){for(var r,i=o(e,n),a=i.length;a--;)r=ee(e,i[a]),e[r]=!(t[r]=i[a])}):function(e){return o(e,0,i)}):o}},pseudos:{not:r(function(e){var t=[],n=[],i=k(e.replace(se,"$1"));return i[P]?r(function(e,t,n,r){for(var o,a=i(e,null,r,[]),s=e.length;s--;)(o=a[s])&&(e[s]=!(t[s]=o))}):function(e,r,o){return t[0]=e,i(t,null,o,n),t[0]=null,!n.pop()}}),has:r(function(e){return function(n){return t(e,n).length>0}}),contains:r(function(e){return e=e.replace(be,we),function(t){return(t.textContent||t.innerText||C(t)).indexOf(e)>-1}}),lang:r(function(e){return de.test(e||"")||t.error("unsupported lang: "+e),e=e.replace(be,we).toLowerCase(),function(t){var n;do if(n=_?t.lang:t.getAttribute("xml:lang")||t.getAttribute("lang"))return n=n.toLowerCase(),n===e||0===n.indexOf(e+"-");while((t=t.parentNode)&&1===t.nodeType);return!1}}),target:function(t){var n=e.location&&e.location.hash;return n&&n.slice(1)===t.id},root:function(e){return e===q},focus:function(e){return e===H.activeElement&&(!H.hasFocus||H.hasFocus())&&!!(e.type||e.href||~e.tabIndex)},enabled:function(e){return e.disabled===!1},disabled:function(e){return e.disabled===!0},checked:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&!!e.checked||"option"===t&&!!e.selected},selected:function(e){return e.parentNode&&e.parentNode.selectedIndex,e.selected===!0},empty:function(e){for(e=e.firstChild;e;e=e.nextSibling)if(e.nodeType<6)return!1;return!0},parent:function(e){return!T.pseudos.empty(e)},header:function(e){return ge.test(e.nodeName)},input:function(e){return he.test(e.nodeName)},button:function(e){var t=e.nodeName.toLowerCase();return"input"===t&&"button"===e.type||"button"===t},text:function(e){var t;return"input"===e.nodeName.toLowerCase()&&"text"===e.type&&(null==(t=e.getAttribute("type"))||"text"===t.toLowerCase())},first:l(function(){return[0]}),last:l(function(e,t){return[t-1]}),eq:l(function(e,t,n){return[n<0?n+t:n]}),even:l(function(e,t){for(var n=0;n=0;)e.push(r);return e}),gt:l(function(e,t,n){for(var r=n<0?n+t:n;++r2&&"ID"===(a=o[0]).type&&w.getById&&9===t.nodeType&&_&&T.relative[o[1].type]){if(t=(T.find.ID(a.matches[0].replace(be,we),t)||[])[0],!t)return n;l&&(t=t.parentNode),e=e.slice(o.shift().value.length)}for(i=pe.needsContext.test(e)?0:o.length;i--&&(a=o[i],!T.relative[s=a.type]);)if((u=T.find[s])&&(r=u(a.matches[0].replace(be,we),ve.test(o[0].type)&&c(t.parentNode)||t))){if(o.splice(i,1),e=r.length&&d(o),!e)return Q.apply(n,r),n;break}}return(l||k(e,f))(r,t,!_,n,!t||ve.test(e)&&c(t.parentNode)||t),n},w.sortStable=P.split("").sort(U).join("")===P,w.detectDuplicates=!!j,L(),w.sortDetached=i(function(e){return 1&e.compareDocumentPosition(H.createElement("div"))}),i(function(e){return e.innerHTML="","#"===e.firstChild.getAttribute("href")})||o("type|href|height|width",function(e,t,n){if(!n)return e.getAttribute(t,"type"===t.toLowerCase()?1:2)}),w.attributes&&i(function(e){return e.innerHTML="",e.firstChild.setAttribute("value",""),""===e.firstChild.getAttribute("value")})||o("value",function(e,t,n){if(!n&&"input"===e.nodeName.toLowerCase())return e.defaultValue}),i(function(e){return null==e.getAttribute("disabled")})||o(te,function(e,t,n){var r;if(!n)return e[t]===!0?t.toLowerCase():(r=e.getAttributeNode(t))&&r.specified?r.value:null}),t}(e);pe.find=ve,pe.expr=ve.selectors,pe.expr[":"]=pe.expr.pseudos,pe.uniqueSort=pe.unique=ve.uniqueSort,pe.text=ve.getText,pe.isXMLDoc=ve.isXML,pe.contains=ve.contains;var xe=function(e,t,n){for(var r=[],i=void 0!==n;(e=e[t])&&9!==e.nodeType;)if(1===e.nodeType){if(i&&pe(e).is(n))break;r.push(e)}return r},be=function(e,t){for(var n=[];e;e=e.nextSibling)1===e.nodeType&&e!==t&&n.push(e);return n},we=pe.expr.match.needsContext,Te=/^<([\w-]+)\s*\/?>(?:<\/\1>|)$/,Ce=/^.[^:#\[\.,]*$/;pe.filter=function(e,t,n){var r=t[0];return n&&(e=":not("+e+")"),1===t.length&&1===r.nodeType?pe.find.matchesSelector(r,e)?[r]:[]:pe.find.matches(e,pe.grep(t,function(e){return 1===e.nodeType}))},pe.fn.extend({find:function(e){var t,n=[],r=this,i=r.length;if("string"!=typeof e)return this.pushStack(pe(e).filter(function(){for(t=0;t1?pe.unique(n):n),n.selector=this.selector?this.selector+" "+e:e,n},filter:function(e){return this.pushStack(r(this,e||[],!1))},not:function(e){return this.pushStack(r(this,e||[],!0))},is:function(e){return!!r(this,"string"==typeof e&&we.test(e)?pe(e):e||[],!1).length}});var Ee,Ne=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,ke=pe.fn.init=function(e,t,n){var r,i;if(!e)return this;if(n=n||Ee,"string"==typeof e){if(r="<"===e.charAt(0)&&">"===e.charAt(e.length-1)&&e.length>=3?[null,e,null]:Ne.exec(e),!r||!r[1]&&t)return!t||t.jquery?(t||n).find(e):this.constructor(t).find(e);if(r[1]){if(t=t instanceof pe?t[0]:t,pe.merge(this,pe.parseHTML(r[1],t&&t.nodeType?t.ownerDocument||t:re,!0)),Te.test(r[1])&&pe.isPlainObject(t))for(r in t)pe.isFunction(this[r])?this[r](t[r]):this.attr(r,t[r]);return this}if(i=re.getElementById(r[2]),i&&i.parentNode){if(i.id!==r[2])return Ee.find(e);this.length=1,this[0]=i}return this.context=re,this.selector=e,this}return e.nodeType?(this.context=this[0]=e,this.length=1,this):pe.isFunction(e)?"undefined"!=typeof n.ready?n.ready(e):e(pe):(void 0!==e.selector&&(this.selector=e.selector,this.context=e.context),pe.makeArray(e,this))};ke.prototype=pe.fn,Ee=pe(re);var Se=/^(?:parents|prev(?:Until|All))/,Ae={children:!0,contents:!0,next:!0,prev:!0};pe.fn.extend({has:function(e){var t,n=pe(e,this),r=n.length;return this.filter(function(){for(t=0;t-1:1===n.nodeType&&pe.find.matchesSelector(n,e))){o.push(n);break}return this.pushStack(o.length>1?pe.uniqueSort(o):o)},index:function(e){return e?"string"==typeof e?pe.inArray(this[0],pe(e)):pe.inArray(e.jquery?e[0]:e,this):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(e,t){return this.pushStack(pe.uniqueSort(pe.merge(this.get(),pe(e,t))))},addBack:function(e){return this.add(null==e?this.prevObject:this.prevObject.filter(e))}}),pe.each({parent:function(e){var t=e.parentNode;return t&&11!==t.nodeType?t:null},parents:function(e){return xe(e,"parentNode")},parentsUntil:function(e,t,n){return xe(e,"parentNode",n)},next:function(e){return i(e,"nextSibling")},prev:function(e){return i(e,"previousSibling")},nextAll:function(e){return xe(e,"nextSibling")},prevAll:function(e){return xe(e,"previousSibling")},nextUntil:function(e,t,n){return xe(e,"nextSibling",n)},prevUntil:function(e,t,n){return xe(e,"previousSibling",n)},siblings:function(e){return be((e.parentNode||{}).firstChild,e)},children:function(e){return be(e.firstChild)},contents:function(e){return pe.nodeName(e,"iframe")?e.contentDocument||e.contentWindow.document:pe.merge([],e.childNodes)}},function(e,t){pe.fn[e]=function(n,r){var i=pe.map(this,t,n);return"Until"!==e.slice(-5)&&(r=n),r&&"string"==typeof r&&(i=pe.filter(r,i)),this.length>1&&(Ae[e]||(i=pe.uniqueSort(i)),Se.test(e)&&(i=i.reverse())),this.pushStack(i)}});var De=/\S+/g;pe.Callbacks=function(e){e="string"==typeof e?o(e):pe.extend({},e);var t,n,r,i,a=[],s=[],u=-1,l=function(){for(i=e.once,r=t=!0;s.length;u=-1)for(n=s.shift();++u-1;)a.splice(n,1),n<=u&&u--}),this},has:function(e){return e?pe.inArray(e,a)>-1:a.length>0},empty:function(){return a&&(a=[]),this},disable:function(){return i=s=[],a=n="",this},disabled:function(){return!a},lock:function(){return i=!0,n||c.disable(),this},locked:function(){return!!i},fireWith:function(e,n){return i||(n=n||[],n=[e,n.slice?n.slice():n],s.push(n),t||l()),this},fire:function(){return c.fireWith(this,arguments),this},fired:function(){return!!r}};return c},pe.extend({Deferred:function(e){var t=[["resolve","done",pe.Callbacks("once memory"),"resolved"],["reject","fail",pe.Callbacks("once memory"),"rejected"],["notify","progress",pe.Callbacks("memory")]],n="pending",r={state:function(){return n},always:function(){return i.done(arguments).fail(arguments),this},then:function(){var e=arguments;return pe.Deferred(function(n){pe.each(t,function(t,o){var a=pe.isFunction(e[t])&&e[t];i[o[1]](function(){var e=a&&a.apply(this,arguments);e&&pe.isFunction(e.promise)?e.promise().progress(n.notify).done(n.resolve).fail(n.reject):n[o[0]+"With"](this===r?n.promise():this,a?[e]:arguments)})}),e=null}).promise()},promise:function(e){return null!=e?pe.extend(e,r):r}},i={};return r.pipe=r.then,pe.each(t,function(e,o){var a=o[2],s=o[3];r[o[1]]=a.add,s&&a.add(function(){n=s},t[1^e][2].disable,t[2][2].lock),i[o[0]]=function(){return i[o[0]+"With"](this===i?r:this,arguments),this},i[o[0]+"With"]=a.fireWith}),r.promise(i),e&&e.call(i,i),i},when:function(e){var t,n,r,i=0,o=ie.call(arguments),a=o.length,s=1!==a||e&&pe.isFunction(e.promise)?a:0,u=1===s?e:pe.Deferred(),l=function(e,n,r){return function(i){n[e]=this,r[e]=arguments.length>1?ie.call(arguments):i,r===t?u.notifyWith(n,r):--s||u.resolveWith(n,r)}};if(a>1)for(t=new Array(a),n=new Array(a),r=new Array(a);i0||(je.resolveWith(re,[pe]),pe.fn.triggerHandler&&(pe(re).triggerHandler("ready"),pe(re).off("ready"))))}}),pe.ready.promise=function(t){if(!je)if(je=pe.Deferred(),"complete"===re.readyState||"loading"!==re.readyState&&!re.documentElement.doScroll)e.setTimeout(pe.ready);else if(re.addEventListener)re.addEventListener("DOMContentLoaded",s),e.addEventListener("load",s);else{re.attachEvent("onreadystatechange",s),e.attachEvent("onload",s);var n=!1;try{n=null==e.frameElement&&re.documentElement}catch(r){}n&&n.doScroll&&!function i(){if(!pe.isReady){try{n.doScroll("left")}catch(t){return e.setTimeout(i,50)}a(),pe.ready()}}()}return je.promise(t)},pe.ready.promise();var Le;for(Le in pe(fe))break;fe.ownFirst="0"===Le,fe.inlineBlockNeedsLayout=!1,pe(function(){var e,t,n,r;n=re.getElementsByTagName("body")[0],n&&n.style&&(t=re.createElement("div"),r=re.createElement("div"),r.style.cssText="position:absolute;border:0;width:0;height:0;top:0;left:-9999px",n.appendChild(r).appendChild(t),"undefined"!=typeof t.style.zoom&&(t.style.cssText="display:inline;margin:0;border:0;padding:1px;width:1px;zoom:1",fe.inlineBlockNeedsLayout=e=3===t.offsetWidth,e&&(n.style.zoom=1)),n.removeChild(r))}),function(){var e=re.createElement("div");fe.deleteExpando=!0;try{delete e.test}catch(t){fe.deleteExpando=!1}e=null}();var He=function(e){var t=pe.noData[(e.nodeName+" ").toLowerCase()],n=+e.nodeType||1;return(1===n||9===n)&&(!t||t!==!0&&e.getAttribute("classid")===t)},qe=/^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,_e=/([A-Z])/g;pe.extend({cache:{},noData:{"applet ":!0,"embed ":!0,"object ":"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"},hasData:function(e){return e=e.nodeType?pe.cache[e[pe.expando]]:e[pe.expando],!!e&&!l(e)},data:function(e,t,n){return c(e,t,n)},removeData:function(e,t){return f(e,t)},_data:function(e,t,n){return c(e,t,n,!0)},_removeData:function(e,t){return f(e,t,!0)}}),pe.fn.extend({data:function(e,t){var n,r,i,o=this[0],a=o&&o.attributes;if(void 0===e){if(this.length&&(i=pe.data(o),1===o.nodeType&&!pe._data(o,"parsedAttrs"))){for(n=a.length;n--;)a[n]&&(r=a[n].name,0===r.indexOf("data-")&&(r=pe.camelCase(r.slice(5)),u(o,r,i[r])));pe._data(o,"parsedAttrs",!0)}return i}return"object"==typeof e?this.each(function(){pe.data(this,e)}):arguments.length>1?this.each(function(){pe.data(this,e,t)}):o?u(o,e,pe.data(o,e)):void 0},removeData:function(e){return this.each(function(){pe.removeData(this,e)})}}),pe.extend({queue:function(e,t,n){var r;if(e)return t=(t||"fx")+"queue",r=pe._data(e,t),n&&(!r||pe.isArray(n)?r=pe._data(e,t,pe.makeArray(n)):r.push(n)),r||[]},dequeue:function(e,t){t=t||"fx";var n=pe.queue(e,t),r=n.length,i=n.shift(),o=pe._queueHooks(e,t),a=function(){pe.dequeue(e,t)};"inprogress"===i&&(i=n.shift(),r--),i&&("fx"===t&&n.unshift("inprogress"),delete o.stop,i.call(e,a,o)),!r&&o&&o.empty.fire()},_queueHooks:function(e,t){var n=t+"queueHooks";return pe._data(e,n)||pe._data(e,n,{empty:pe.Callbacks("once memory").add(function(){pe._removeData(e,t+"queue"),pe._removeData(e,n)})})}}),pe.fn.extend({queue:function(e,t){var n=2;return"string"!=typeof e&&(t=e,e="fx",n--),arguments.length
      a",fe.leadingWhitespace=3===e.firstChild.nodeType,fe.tbody=!e.getElementsByTagName("tbody").length,fe.htmlSerialize=!!e.getElementsByTagName("link").length,fe.html5Clone="<:nav>"!==re.createElement("nav").cloneNode(!0).outerHTML,n.type="checkbox",n.checked=!0,t.appendChild(n),fe.appendChecked=n.checked,e.innerHTML="",fe.noCloneChecked=!!e.cloneNode(!0).lastChild.defaultValue,t.appendChild(e),n=re.createElement("input"),n.setAttribute("type","radio"),n.setAttribute("checked","checked"),n.setAttribute("name","t"),e.appendChild(n),fe.checkClone=e.cloneNode(!0).cloneNode(!0).lastChild.checked,fe.noCloneEvent=!!e.addEventListener,e[pe.expando]=1,fe.attributes=!e.getAttribute(pe.expando)}();var Xe={option:[1,""],legend:[1,"
      ","
      "],area:[1,"",""],param:[1,"",""],thead:[1,"","
      "],tr:[2,"","
      "],col:[2,"","
      "],td:[3,"","
      "],_default:fe.htmlSerialize?[0,"",""]:[1,"X
      ","
      "]};Xe.optgroup=Xe.option,Xe.tbody=Xe.tfoot=Xe.colgroup=Xe.caption=Xe.thead,Xe.th=Xe.td;var Ue=/<|&#?\w+;/,Ve=/-1&&(h=p.split("."),p=h.shift(),h.sort()),a=p.indexOf(":")<0&&"on"+p,t=t[pe.expando]?t:new pe.Event(p,"object"==typeof t&&t),t.isTrigger=i?2:3,t.namespace=h.join("."),t.rnamespace=t.namespace?new RegExp("(^|\\.)"+h.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,t.result=void 0,t.target||(t.target=r),n=null==n?[t]:pe.makeArray(n,[t]),l=pe.event.special[p]||{},i||!l.trigger||l.trigger.apply(r,n)!==!1)){if(!i&&!l.noBubble&&!pe.isWindow(r)){for(u=l.delegateType||p,Ke.test(u+p)||(s=s.parentNode);s;s=s.parentNode)d.push(s),c=s;c===(r.ownerDocument||re)&&d.push(c.defaultView||c.parentWindow||e)}for(f=0;(s=d[f++])&&!t.isPropagationStopped();)t.type=f>1?u:l.bindType||p,o=(pe._data(s,"events")||{})[t.type]&&pe._data(s,"handle"),o&&o.apply(s,n),o=a&&s[a],o&&o.apply&&He(s)&&(t.result=o.apply(s,n),t.result===!1&&t.preventDefault());if(t.type=p,!i&&!t.isDefaultPrevented()&&(!l._default||l._default.apply(d.pop(),n)===!1)&&He(r)&&a&&r[p]&&!pe.isWindow(r)){c=r[a],c&&(r[a]=null),pe.event.triggered=p;try{r[p]()}catch(g){}pe.event.triggered=void 0,c&&(r[a]=c)}return t.result}},dispatch:function(e){e=pe.event.fix(e);var t,n,r,i,o,a=[],s=ie.call(arguments),u=(pe._data(this,"events")||{})[e.type]||[],l=pe.event.special[e.type]||{};if(s[0]=e,e.delegateTarget=this,!l.preDispatch||l.preDispatch.call(this,e)!==!1){for(a=pe.event.handlers.call(this,e,u),t=0;(i=a[t++])&&!e.isPropagationStopped();)for(e.currentTarget=i.elem,n=0;(o=i.handlers[n++])&&!e.isImmediatePropagationStopped();)e.rnamespace&&!e.rnamespace.test(o.namespace)||(e.handleObj=o,e.data=o.data,r=((pe.event.special[o.origType]||{}).handle||o.handler).apply(i.elem,s),void 0!==r&&(e.result=r)===!1&&(e.preventDefault(),e.stopPropagation()));return l.postDispatch&&l.postDispatch.call(this,e),e.result}},handlers:function(e,t){var n,r,i,o,a=[],s=t.delegateCount,u=e.target;if(s&&u.nodeType&&("click"!==e.type||isNaN(e.button)||e.button<1))for(;u!=this;u=u.parentNode||this)if(1===u.nodeType&&(u.disabled!==!0||"click"!==e.type)){for(r=[],n=0;n-1:pe.find(i,this,null,[u]).length),r[i]&&r.push(o);r.length&&a.push({elem:u,handlers:r})}return s]","i"),tt=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:-]+)[^>]*)\/>/gi,nt=/\s*$/g,at=p(re),st=at.appendChild(re.createElement("div"));pe.extend({htmlPrefilter:function(e){return e.replace(tt,"<$1>")},clone:function(e,t,n){var r,i,o,a,s,u=pe.contains(e.ownerDocument,e);if(fe.html5Clone||pe.isXMLDoc(e)||!et.test("<"+e.nodeName+">")?o=e.cloneNode(!0):(st.innerHTML=e.outerHTML,st.removeChild(o=st.firstChild)),!(fe.noCloneEvent&&fe.noCloneChecked||1!==e.nodeType&&11!==e.nodeType||pe.isXMLDoc(e)))for(r=h(o),s=h(e),a=0;null!=(i=s[a]);++a)r[a]&&k(i,r[a]);if(t)if(n)for(s=s||h(e),r=r||h(o),a=0;null!=(i=s[a]);a++)N(i,r[a]);else N(e,o);return r=h(o,"script"),r.length>0&&g(r,!u&&h(e,"script")),r=s=i=null,o},cleanData:function(e,t){for(var n,r,i,o,a=0,s=pe.expando,u=pe.cache,l=fe.attributes,c=pe.event.special;null!=(n=e[a]);a++)if((t||He(n))&&(i=n[s],o=i&&u[i])){if(o.events)for(r in o.events)c[r]?pe.event.remove(n,r):pe.removeEvent(n,r,o.handle);u[i]&&(delete u[i],l||"undefined"==typeof n.removeAttribute?n[s]=void 0:n.removeAttribute(s),ne.push(i))}}}),pe.fn.extend({domManip:S,detach:function(e){return A(this,e,!0)},remove:function(e){return A(this,e)},text:function(e){return Pe(this,function(e){return void 0===e?pe.text(this):this.empty().append((this[0]&&this[0].ownerDocument||re).createTextNode(e))},null,e,arguments.length)},append:function(){return S(this,arguments,function(e){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var t=T(this,e);t.appendChild(e)}})},prepend:function(){return S(this,arguments,function(e){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var t=T(this,e);t.insertBefore(e,t.firstChild)}})},before:function(){return S(this,arguments,function(e){this.parentNode&&this.parentNode.insertBefore(e,this)})},after:function(){return S(this,arguments,function(e){this.parentNode&&this.parentNode.insertBefore(e,this.nextSibling)})},empty:function(){for(var e,t=0;null!=(e=this[t]);t++){for(1===e.nodeType&&pe.cleanData(h(e,!1));e.firstChild;)e.removeChild(e.firstChild);e.options&&pe.nodeName(e,"select")&&(e.options.length=0)}return this},clone:function(e,t){return e=null!=e&&e,t=null==t?e:t,this.map(function(){return pe.clone(this,e,t)})},html:function(e){return Pe(this,function(e){var t=this[0]||{},n=0,r=this.length;if(void 0===e)return 1===t.nodeType?t.innerHTML.replace(Ze,""):void 0;if("string"==typeof e&&!nt.test(e)&&(fe.htmlSerialize||!et.test(e))&&(fe.leadingWhitespace||!$e.test(e))&&!Xe[(We.exec(e)||["",""])[1].toLowerCase()]){e=pe.htmlPrefilter(e);try{for(;nt",t=l.getElementsByTagName("td"),t[0].style.cssText="margin:0;border:0;padding:0;display:none",o=0===t[0].offsetHeight,o&&(t[0].style.display="",t[1].style.display="none",o=0===t[0].offsetHeight)),f.removeChild(u)}var n,r,i,o,a,s,u=re.createElement("div"),l=re.createElement("div");l.style&&(l.style.cssText="float:left;opacity:.5",fe.opacity="0.5"===l.style.opacity,fe.cssFloat=!!l.style.cssFloat,l.style.backgroundClip="content-box",l.cloneNode(!0).style.backgroundClip="",fe.clearCloneStyle="content-box"===l.style.backgroundClip,u=re.createElement("div"),u.style.cssText="border:0;width:8px;height:0;top:0;left:-9999px;padding:0;margin-top:1px;position:absolute",l.innerHTML="",u.appendChild(l),fe.boxSizing=""===l.style.boxSizing||""===l.style.MozBoxSizing||""===l.style.WebkitBoxSizing,pe.extend(fe,{reliableHiddenOffsets:function(){return null==n&&t(),o},boxSizingReliable:function(){return null==n&&t(),i},pixelMarginRight:function(){return null==n&&t(),r},pixelPosition:function(){return null==n&&t(),n},reliableMarginRight:function(){return null==n&&t(),a},reliableMarginLeft:function(){return null==n&&t(),s}}))}();var ht,gt,mt=/^(top|right|bottom|left)$/;e.getComputedStyle?(ht=function(t){var n=t.ownerDocument.defaultView;return n&&n.opener||(n=e),n.getComputedStyle(t)},gt=function(e,t,n){var r,i,o,a,s=e.style;return n=n||ht(e),a=n?n.getPropertyValue(t)||n[t]:void 0,""!==a&&void 0!==a||pe.contains(e.ownerDocument,e)||(a=pe.style(e,t)),n&&!fe.pixelMarginRight()&&ft.test(a)&&ct.test(t)&&(r=s.width,i=s.minWidth,o=s.maxWidth,s.minWidth=s.maxWidth=s.width=a,a=n.width,s.width=r,s.minWidth=i,s.maxWidth=o),void 0===a?a:a+""}):pt.currentStyle&&(ht=function(e){return e.currentStyle},gt=function(e,t,n){var r,i,o,a,s=e.style;return n=n||ht(e),a=n?n[t]:void 0,null==a&&s&&s[t]&&(a=s[t]),ft.test(a)&&!mt.test(t)&&(r=s.left,i=e.runtimeStyle,o=i&&i.left,o&&(i.left=e.currentStyle.left),s.left="fontSize"===t?"1em":a,a=s.pixelLeft+"px",s.left=r,o&&(i.left=o)),void 0===a?a:a+""||"auto"});var yt=/alpha\([^)]*\)/i,vt=/opacity\s*=\s*([^)]*)/i,xt=/^(none|table(?!-c[ea]).+)/,bt=new RegExp("^("+Fe+")(.*)$","i"),wt={position:"absolute",visibility:"hidden",display:"block"},Tt={letterSpacing:"0",fontWeight:"400"},Ct=["Webkit","O","Moz","ms"],Et=re.createElement("div").style;pe.extend({cssHooks:{opacity:{get:function(e,t){if(t){var n=gt(e,"opacity");return""===n?"1":n}}}},cssNumber:{animationIterationCount:!0,columnCount:!0,fillOpacity:!0,flexGrow:!0,flexShrink:!0,fontWeight:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{"float":fe.cssFloat?"cssFloat":"styleFloat"},style:function(e,t,n,r){if(e&&3!==e.nodeType&&8!==e.nodeType&&e.style){var i,o,a,s=pe.camelCase(t),u=e.style;if(t=pe.cssProps[s]||(pe.cssProps[s]=H(s)||s),a=pe.cssHooks[t]||pe.cssHooks[s],void 0===n)return a&&"get"in a&&void 0!==(i=a.get(e,!1,r))?i:u[t];if(o=typeof n,"string"===o&&(i=Me.exec(n))&&i[1]&&(n=d(e,t,i),o="number"),null!=n&&n===n&&("number"===o&&(n+=i&&i[3]||(pe.cssNumber[s]?"":"px")),fe.clearCloneStyle||""!==n||0!==t.indexOf("background")||(u[t]="inherit"),!(a&&"set"in a&&void 0===(n=a.set(e,n,r)))))try{u[t]=n}catch(l){}}},css:function(e,t,n,r){var i,o,a,s=pe.camelCase(t);return t=pe.cssProps[s]||(pe.cssProps[s]=H(s)||s),a=pe.cssHooks[t]||pe.cssHooks[s],a&&"get"in a&&(o=a.get(e,!0,n)),void 0===o&&(o=gt(e,t,r)),"normal"===o&&t in Tt&&(o=Tt[t]),""===n||n?(i=parseFloat(o),n===!0||isFinite(i)?i||0:o):o}}),pe.each(["height","width"],function(e,t){pe.cssHooks[t]={get:function(e,n,r){if(n)return xt.test(pe.css(e,"display"))&&0===e.offsetWidth?dt(e,wt,function(){return M(e,t,r)}):M(e,t,r)},set:function(e,n,r){var i=r&&ht(e);return _(e,n,r?F(e,t,r,fe.boxSizing&&"border-box"===pe.css(e,"boxSizing",!1,i),i):0)}}}),fe.opacity||(pe.cssHooks.opacity={get:function(e,t){return vt.test((t&&e.currentStyle?e.currentStyle.filter:e.style.filter)||"")?.01*parseFloat(RegExp.$1)+"":t?"1":""},set:function(e,t){var n=e.style,r=e.currentStyle,i=pe.isNumeric(t)?"alpha(opacity="+100*t+")":"",o=r&&r.filter||n.filter||"";n.zoom=1,(t>=1||""===t)&&""===pe.trim(o.replace(yt,""))&&n.removeAttribute&&(n.removeAttribute("filter"),""===t||r&&!r.filter)||(n.filter=yt.test(o)?o.replace(yt,i):o+" "+i)}}),pe.cssHooks.marginRight=L(fe.reliableMarginRight,function(e,t){if(t)return dt(e,{display:"inline-block"},gt,[e,"marginRight"])}),pe.cssHooks.marginLeft=L(fe.reliableMarginLeft,function(e,t){if(t)return(parseFloat(gt(e,"marginLeft"))||(pe.contains(e.ownerDocument,e)?e.getBoundingClientRect().left-dt(e,{marginLeft:0},function(){return e.getBoundingClientRect().left}):0))+"px"}),pe.each({margin:"",padding:"",border:"Width"},function(e,t){pe.cssHooks[e+t]={expand:function(n){for(var r=0,i={},o="string"==typeof n?n.split(" "):[n];r<4;r++)i[e+Oe[r]+t]=o[r]||o[r-2]||o[0];return i}},ct.test(e)||(pe.cssHooks[e+t].set=_)}),pe.fn.extend({css:function(e,t){return Pe(this,function(e,t,n){var r,i,o={},a=0;if(pe.isArray(t)){for(r=ht(e),i=t.length;a1)},show:function(){return q(this,!0)},hide:function(){return q(this)},toggle:function(e){return"boolean"==typeof e?e?this.show():this.hide():this.each(function(){Re(this)?pe(this).show():pe(this).hide()})}}),pe.Tween=O,O.prototype={constructor:O,init:function(e,t,n,r,i,o){this.elem=e,this.prop=n,this.easing=i||pe.easing._default,this.options=t,this.start=this.now=this.cur(),this.end=r,this.unit=o||(pe.cssNumber[n]?"":"px")},cur:function(){var e=O.propHooks[this.prop];return e&&e.get?e.get(this):O.propHooks._default.get(this)},run:function(e){var t,n=O.propHooks[this.prop];return this.options.duration?this.pos=t=pe.easing[this.easing](e,this.options.duration*e,0,1,this.options.duration):this.pos=t=e,this.now=(this.end-this.start)*t+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),n&&n.set?n.set(this):O.propHooks._default.set(this),this}},O.prototype.init.prototype=O.prototype,O.propHooks={_default:{get:function(e){var t;return 1!==e.elem.nodeType||null!=e.elem[e.prop]&&null==e.elem.style[e.prop]?e.elem[e.prop]:(t=pe.css(e.elem,e.prop,""),t&&"auto"!==t?t:0)},set:function(e){pe.fx.step[e.prop]?pe.fx.step[e.prop](e):1!==e.elem.nodeType||null==e.elem.style[pe.cssProps[e.prop]]&&!pe.cssHooks[e.prop]?e.elem[e.prop]=e.now:pe.style(e.elem,e.prop,e.now+e.unit)}}},O.propHooks.scrollTop=O.propHooks.scrollLeft={set:function(e){e.elem.nodeType&&e.elem.parentNode&&(e.elem[e.prop]=e.now)}},pe.easing={linear:function(e){return e},swing:function(e){return.5-Math.cos(e*Math.PI)/2},_default:"swing"},pe.fx=O.prototype.init,pe.fx.step={};var Nt,kt,St=/^(?:toggle|show|hide)$/,At=/queueHooks$/;pe.Animation=pe.extend($,{tweeners:{"*":[function(e,t){var n=this.createTween(e,t);return d(n.elem,e,Me.exec(t),n),n}]},tweener:function(e,t){pe.isFunction(e)?(t=e,e=["*"]):e=e.match(De);for(var n,r=0,i=e.length;r
      a",e=n.getElementsByTagName("a")[0],t.setAttribute("type","checkbox"),n.appendChild(t),e=n.getElementsByTagName("a")[0],e.style.cssText="top:1px",fe.getSetAttribute="t"!==n.className,fe.style=/top/.test(e.getAttribute("style")),fe.hrefNormalized="/a"===e.getAttribute("href"),fe.checkOn=!!t.value,fe.optSelected=i.selected,fe.enctype=!!re.createElement("form").enctype,r.disabled=!0,fe.optDisabled=!i.disabled,t=re.createElement("input"),t.setAttribute("value",""),fe.input=""===t.getAttribute("value"),t.value="t",t.setAttribute("type","radio"),fe.radioValue="t"===t.value}();var Dt=/\r/g,jt=/[\x20\t\r\n\f]+/g;pe.fn.extend({val:function(e){var t,n,r,i=this[0];{if(arguments.length)return r=pe.isFunction(e),this.each(function(n){var i;1===this.nodeType&&(i=r?e.call(this,n,pe(this).val()):e,null==i?i="":"number"==typeof i?i+="":pe.isArray(i)&&(i=pe.map(i,function(e){return null==e?"":e+""})),t=pe.valHooks[this.type]||pe.valHooks[this.nodeName.toLowerCase()],t&&"set"in t&&void 0!==t.set(this,i,"value")||(this.value=i))});if(i)return t=pe.valHooks[i.type]||pe.valHooks[i.nodeName.toLowerCase()],t&&"get"in t&&void 0!==(n=t.get(i,"value"))?n:(n=i.value,"string"==typeof n?n.replace(Dt,""):null==n?"":n)}}}),pe.extend({valHooks:{option:{get:function(e){var t=pe.find.attr(e,"value");return null!=t?t:pe.trim(pe.text(e)).replace(jt," ")}},select:{get:function(e){for(var t,n,r=e.options,i=e.selectedIndex,o="select-one"===e.type||i<0,a=o?null:[],s=o?i+1:r.length,u=i<0?s:o?i:0;u-1)try{r.selected=n=!0}catch(s){r.scrollHeight}else r.selected=!1;return n||(e.selectedIndex=-1),i}}}}),pe.each(["radio","checkbox"],function(){pe.valHooks[this]={set:function(e,t){if(pe.isArray(t))return e.checked=pe.inArray(pe(e).val(),t)>-1}},fe.checkOn||(pe.valHooks[this].get=function(e){return null===e.getAttribute("value")?"on":e.value})});var Lt,Ht,qt=pe.expr.attrHandle,_t=/^(?:checked|selected)$/i,Ft=fe.getSetAttribute,Mt=fe.input;pe.fn.extend({attr:function(e,t){return Pe(this,pe.attr,e,t,arguments.length>1)},removeAttr:function(e){return this.each(function(){pe.removeAttr(this,e)})}}),pe.extend({attr:function(e,t,n){var r,i,o=e.nodeType;if(3!==o&&8!==o&&2!==o)return"undefined"==typeof e.getAttribute?pe.prop(e,t,n):(1===o&&pe.isXMLDoc(e)||(t=t.toLowerCase(),i=pe.attrHooks[t]||(pe.expr.match.bool.test(t)?Ht:Lt)),void 0!==n?null===n?void pe.removeAttr(e,t):i&&"set"in i&&void 0!==(r=i.set(e,n,t))?r:(e.setAttribute(t,n+""),n):i&&"get"in i&&null!==(r=i.get(e,t))?r:(r=pe.find.attr(e,t),null==r?void 0:r))},attrHooks:{type:{set:function(e,t){if(!fe.radioValue&&"radio"===t&&pe.nodeName(e,"input")){var n=e.value;return e.setAttribute("type",t),n&&(e.value=n),t}}}},removeAttr:function(e,t){var n,r,i=0,o=t&&t.match(De);if(o&&1===e.nodeType)for(;n=o[i++];)r=pe.propFix[n]||n,pe.expr.match.bool.test(n)?Mt&&Ft||!_t.test(n)?e[r]=!1:e[pe.camelCase("default-"+n)]=e[r]=!1:pe.attr(e,n,""),e.removeAttribute(Ft?n:r)}}),Ht={set:function(e,t,n){return t===!1?pe.removeAttr(e,n):Mt&&Ft||!_t.test(n)?e.setAttribute(!Ft&&pe.propFix[n]||n,n):e[pe.camelCase("default-"+n)]=e[n]=!0,n}},pe.each(pe.expr.match.bool.source.match(/\w+/g),function(e,t){var n=qt[t]||pe.find.attr;Mt&&Ft||!_t.test(t)?qt[t]=function(e,t,r){var i,o;return r||(o=qt[t],qt[t]=i,i=null!=n(e,t,r)?t.toLowerCase():null,qt[t]=o),i}:qt[t]=function(e,t,n){if(!n)return e[pe.camelCase("default-"+t)]?t.toLowerCase():null}}),Mt&&Ft||(pe.attrHooks.value={set:function(e,t,n){return pe.nodeName(e,"input")?void(e.defaultValue=t):Lt&&Lt.set(e,t,n)}}),Ft||(Lt={set:function(e,t,n){var r=e.getAttributeNode(n);if(r||e.setAttributeNode(r=e.ownerDocument.createAttribute(n)),r.value=t+="","value"===n||t===e.getAttribute(n))return t}},qt.id=qt.name=qt.coords=function(e,t,n){var r;if(!n)return(r=e.getAttributeNode(t))&&""!==r.value?r.value:null},pe.valHooks.button={get:function(e,t){var n=e.getAttributeNode(t);if(n&&n.specified)return n.value},set:Lt.set},pe.attrHooks.contenteditable={set:function(e,t,n){Lt.set(e,""!==t&&t,n)}},pe.each(["width","height"],function(e,t){pe.attrHooks[t]={set:function(e,n){if(""===n)return e.setAttribute(t,"auto"),n}}})),fe.style||(pe.attrHooks.style={get:function(e){return e.style.cssText||void 0},set:function(e,t){return e.style.cssText=t+""}});var Ot=/^(?:input|select|textarea|button|object)$/i,Rt=/^(?:a|area)$/i;pe.fn.extend({prop:function(e,t){return Pe(this,pe.prop,e,t,arguments.length>1)},removeProp:function(e){return e=pe.propFix[e]||e,this.each(function(){try{this[e]=void 0,delete this[e]}catch(t){}})}}),pe.extend({prop:function(e,t,n){var r,i,o=e.nodeType;if(3!==o&&8!==o&&2!==o)return 1===o&&pe.isXMLDoc(e)||(t=pe.propFix[t]||t,i=pe.propHooks[t]),void 0!==n?i&&"set"in i&&void 0!==(r=i.set(e,n,t))?r:e[t]=n:i&&"get"in i&&null!==(r=i.get(e,t))?r:e[t]},propHooks:{tabIndex:{get:function(e){var t=pe.find.attr(e,"tabindex");return t?parseInt(t,10):Ot.test(e.nodeName)||Rt.test(e.nodeName)&&e.href?0:-1}}},propFix:{"for":"htmlFor","class":"className"}}),fe.hrefNormalized||pe.each(["href","src"],function(e,t){pe.propHooks[t]={get:function(e){return e.getAttribute(t,4)}}}),fe.optSelected||(pe.propHooks.selected={get:function(e){var t=e.parentNode;return t&&(t.selectedIndex,t.parentNode&&t.parentNode.selectedIndex),null},set:function(e){var t=e.parentNode;t&&(t.selectedIndex,t.parentNode&&t.parentNode.selectedIndex)}}),pe.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],function(){pe.propFix[this.toLowerCase()]=this}),fe.enctype||(pe.propFix.enctype="encoding");var Pt=/[\t\r\n\f]/g;pe.fn.extend({addClass:function(e){var t,n,r,i,o,a,s,u=0;if(pe.isFunction(e))return this.each(function(t){pe(this).addClass(e.call(this,t,z(this)))});if("string"==typeof e&&e)for(t=e.match(De)||[];n=this[u++];)if(i=z(n),r=1===n.nodeType&&(" "+i+" ").replace(Pt," ")){for(a=0;o=t[a++];)r.indexOf(" "+o+" ")<0&&(r+=o+" ");s=pe.trim(r),i!==s&&pe.attr(n,"class",s)}return this},removeClass:function(e){var t,n,r,i,o,a,s,u=0;if(pe.isFunction(e))return this.each(function(t){pe(this).removeClass(e.call(this,t,z(this)))});if(!arguments.length)return this.attr("class","");if("string"==typeof e&&e)for(t=e.match(De)||[];n=this[u++];)if(i=z(n),r=1===n.nodeType&&(" "+i+" ").replace(Pt," ")){for(a=0;o=t[a++];)for(;r.indexOf(" "+o+" ")>-1;)r=r.replace(" "+o+" "," ");s=pe.trim(r),i!==s&&pe.attr(n,"class",s)}return this},toggleClass:function(e,t){var n=typeof e;return"boolean"==typeof t&&"string"===n?t?this.addClass(e):this.removeClass(e):pe.isFunction(e)?this.each(function(n){pe(this).toggleClass(e.call(this,n,z(this),t),t)}):this.each(function(){var t,r,i,o;if("string"===n)for(r=0,i=pe(this),o=e.match(De)||[];t=o[r++];)i.hasClass(t)?i.removeClass(t):i.addClass(t);else void 0!==e&&"boolean"!==n||(t=z(this),t&&pe._data(this,"__className__",t),pe.attr(this,"class",t||e===!1?"":pe._data(this,"__className__")||""))})},hasClass:function(e){var t,n,r=0;for(t=" "+e+" ";n=this[r++];)if(1===n.nodeType&&(" "+z(n)+" ").replace(Pt," ").indexOf(t)>-1)return!0;return!1}}),pe.each("blur focus focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup error contextmenu".split(" "),function(e,t){pe.fn[t]=function(e,n){return arguments.length>0?this.on(t,null,e,n):this.trigger(t)}}),pe.fn.extend({hover:function(e,t){return this.mouseenter(e).mouseleave(t||e)}});var Bt=e.location,Wt=pe.now(),It=/\?/,$t=/(,)|(\[|{)|(}|])|"(?:[^"\\\r\n]|\\["\\\/bfnrt]|\\u[\da-fA-F]{4})*"\s*:?|true|false|null|-?(?!0\d)\d+(?:\.\d+|)(?:[eE][+-]?\d+|)/g;pe.parseJSON=function(t){if(e.JSON&&e.JSON.parse)return e.JSON.parse(t+"");var n,r=null,i=pe.trim(t+"");return i&&!pe.trim(i.replace($t,function(e,t,i,o){return n&&t&&(r=0),0===r?e:(n=i||t,r+=!o-!i,"")}))?Function("return "+i)():pe.error("Invalid JSON: "+t)},pe.parseXML=function(t){var n,r;if(!t||"string"!=typeof t)return null;try{e.DOMParser?(r=new e.DOMParser,n=r.parseFromString(t,"text/xml")):(n=new e.ActiveXObject("Microsoft.XMLDOM"),n.async="false",n.loadXML(t))}catch(i){n=void 0}return n&&n.documentElement&&!n.getElementsByTagName("parsererror").length||pe.error("Invalid XML: "+t),n};var zt=/#.*$/,Xt=/([?&])_=[^&]*/,Ut=/^(.*?):[ \t]*([^\r\n]*)\r?$/gm,Vt=/^(?:about|app|app-storage|.+-extension|file|res|widget):$/,Yt=/^(?:GET|HEAD)$/,Jt=/^\/\//,Gt=/^([\w.+-]+:)(?:\/\/(?:[^\/?#]*@|)([^\/?#:]*)(?::(\d+)|)|)/,Kt={},Qt={},Zt="*/".concat("*"),en=Bt.href,tn=Gt.exec(en.toLowerCase())||[];pe.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:en,type:"GET",isLocal:Vt.test(tn[1]),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":Zt,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/\bxml\b/,html:/\bhtml/,json:/\bjson\b/},responseFields:{xml:"responseXML",text:"responseText",json:"responseJSON"},converters:{"* text":String,"text html":!0,"text json":pe.parseJSON,"text xml":pe.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(e,t){return t?V(V(e,pe.ajaxSettings),t):V(pe.ajaxSettings,e)},ajaxPrefilter:X(Kt),ajaxTransport:X(Qt),ajax:function(t,n){function r(t,n,r,i){var o,f,v,x,w,C=n;2!==b&&(b=2,u&&e.clearTimeout(u),c=void 0,s=i||"",T.readyState=t>0?4:0,o=t>=200&&t<300||304===t,r&&(x=Y(d,T,r)),x=J(d,x,T,o),o?(d.ifModified&&(w=T.getResponseHeader("Last-Modified"),w&&(pe.lastModified[a]=w),w=T.getResponseHeader("etag"),w&&(pe.etag[a]=w)),204===t||"HEAD"===d.type?C="nocontent":304===t?C="notmodified":(C=x.state,f=x.data,v=x.error,o=!v)):(v=C,!t&&C||(C="error",t<0&&(t=0))),T.status=t,T.statusText=(n||C)+"",o?g.resolveWith(p,[f,C,T]):g.rejectWith(p,[T,C,v]),T.statusCode(y),y=void 0,l&&h.trigger(o?"ajaxSuccess":"ajaxError",[T,d,o?f:v]),m.fireWith(p,[T,C]),l&&(h.trigger("ajaxComplete",[T,d]),--pe.active||pe.event.trigger("ajaxStop")))}"object"==typeof t&&(n=t,t=void 0),n=n||{};var i,o,a,s,u,l,c,f,d=pe.ajaxSetup({},n),p=d.context||d,h=d.context&&(p.nodeType||p.jquery)?pe(p):pe.event,g=pe.Deferred(),m=pe.Callbacks("once memory"),y=d.statusCode||{},v={},x={},b=0,w="canceled",T={readyState:0,getResponseHeader:function(e){var t;if(2===b){if(!f)for(f={};t=Ut.exec(s);)f[t[1].toLowerCase()]=t[2];t=f[e.toLowerCase()]}return null==t?null:t},getAllResponseHeaders:function(){return 2===b?s:null},setRequestHeader:function(e,t){var n=e.toLowerCase();return b||(e=x[n]=x[n]||e,v[e]=t),this},overrideMimeType:function(e){return b||(d.mimeType=e),this},statusCode:function(e){var t;if(e)if(b<2)for(t in e)y[t]=[y[t],e[t]];else T.always(e[T.status]);return this},abort:function(e){var t=e||w;return c&&c.abort(t),r(0,t),this}};if(g.promise(T).complete=m.add,T.success=T.done,T.error=T.fail,d.url=((t||d.url||en)+"").replace(zt,"").replace(Jt,tn[1]+"//"),d.type=n.method||n.type||d.method||d.type,d.dataTypes=pe.trim(d.dataType||"*").toLowerCase().match(De)||[""],null==d.crossDomain&&(i=Gt.exec(d.url.toLowerCase()),d.crossDomain=!(!i||i[1]===tn[1]&&i[2]===tn[2]&&(i[3]||("http:"===i[1]?"80":"443"))===(tn[3]||("http:"===tn[1]?"80":"443")))),d.data&&d.processData&&"string"!=typeof d.data&&(d.data=pe.param(d.data,d.traditional)),U(Kt,d,n,T),2===b)return T;l=pe.event&&d.global,l&&0===pe.active++&&pe.event.trigger("ajaxStart"),d.type=d.type.toUpperCase(),d.hasContent=!Yt.test(d.type),a=d.url,d.hasContent||(d.data&&(a=d.url+=(It.test(a)?"&":"?")+d.data,delete d.data),d.cache===!1&&(d.url=Xt.test(a)?a.replace(Xt,"$1_="+Wt++):a+(It.test(a)?"&":"?")+"_="+Wt++)),d.ifModified&&(pe.lastModified[a]&&T.setRequestHeader("If-Modified-Since",pe.lastModified[a]),pe.etag[a]&&T.setRequestHeader("If-None-Match",pe.etag[a])),(d.data&&d.hasContent&&d.contentType!==!1||n.contentType)&&T.setRequestHeader("Content-Type",d.contentType),T.setRequestHeader("Accept",d.dataTypes[0]&&d.accepts[d.dataTypes[0]]?d.accepts[d.dataTypes[0]]+("*"!==d.dataTypes[0]?", "+Zt+"; q=0.01":""):d.accepts["*"]);for(o in d.headers)T.setRequestHeader(o,d.headers[o]);if(d.beforeSend&&(d.beforeSend.call(p,T,d)===!1||2===b))return T.abort();w="abort";for(o in{success:1,error:1,complete:1})T[o](d[o]);if(c=U(Qt,d,n,T)){if(T.readyState=1,l&&h.trigger("ajaxSend",[T,d]),2===b)return T;d.async&&d.timeout>0&&(u=e.setTimeout(function(){T.abort("timeout")},d.timeout));try{b=1,c.send(v,r)}catch(C){if(!(b<2))throw C;r(-1,C)}}else r(-1,"No Transport");return T},getJSON:function(e,t,n){return pe.get(e,t,n,"json")},getScript:function(e,t){return pe.get(e,void 0,t,"script")}}),pe.each(["get","post"],function(e,t){pe[t]=function(e,n,r,i){return pe.isFunction(n)&&(i=i||r,r=n,n=void 0),pe.ajax(pe.extend({url:e,type:t,dataType:i,data:n,success:r},pe.isPlainObject(e)&&e))}}),pe._evalUrl=function(e){return pe.ajax({url:e,type:"GET",dataType:"script",cache:!0,async:!1,global:!1,"throws":!0})},pe.fn.extend({wrapAll:function(e){if(pe.isFunction(e))return this.each(function(t){pe(this).wrapAll(e.call(this,t))});if(this[0]){var t=pe(e,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&t.insertBefore(this[0]),t.map(function(){for(var e=this;e.firstChild&&1===e.firstChild.nodeType;)e=e.firstChild;return e}).append(this)}return this},wrapInner:function(e){return pe.isFunction(e)?this.each(function(t){pe(this).wrapInner(e.call(this,t))}):this.each(function(){var t=pe(this),n=t.contents();n.length?n.wrapAll(e):t.append(e)})},wrap:function(e){var t=pe.isFunction(e);return this.each(function(n){pe(this).wrapAll(t?e.call(this,n):e)})},unwrap:function(){return this.parent().each(function(){pe.nodeName(this,"body")||pe(this).replaceWith(this.childNodes)}).end()}}),pe.expr.filters.hidden=function(e){return fe.reliableHiddenOffsets()?e.offsetWidth<=0&&e.offsetHeight<=0&&!e.getClientRects().length:K(e)},pe.expr.filters.visible=function(e){return!pe.expr.filters.hidden(e)};var nn=/%20/g,rn=/\[\]$/,on=/\r?\n/g,an=/^(?:submit|button|image|reset|file)$/i,sn=/^(?:input|select|textarea|keygen)/i;pe.param=function(e,t){var n,r=[],i=function(e,t){t=pe.isFunction(t)?t():null==t?"":t,r[r.length]=encodeURIComponent(e)+"="+encodeURIComponent(t)};if(void 0===t&&(t=pe.ajaxSettings&&pe.ajaxSettings.traditional),pe.isArray(e)||e.jquery&&!pe.isPlainObject(e))pe.each(e,function(){i(this.name,this.value)});else for(n in e)Q(n,e[n],t,i);return r.join("&").replace(nn,"+")},pe.fn.extend({serialize:function(){return pe.param(this.serializeArray())},serializeArray:function(){return this.map(function(){var e=pe.prop(this,"elements");return e?pe.makeArray(e):this}).filter(function(){var e=this.type;return this.name&&!pe(this).is(":disabled")&&sn.test(this.nodeName)&&!an.test(e)&&(this.checked||!Be.test(e))}).map(function(e,t){var n=pe(this).val();return null==n?null:pe.isArray(n)?pe.map(n,function(e){return{name:t.name,value:e.replace(on,"\r\n")}}):{name:t.name,value:n.replace(on,"\r\n")}}).get()}}),pe.ajaxSettings.xhr=void 0!==e.ActiveXObject?function(){return this.isLocal?ee():re.documentMode>8?Z():/^(get|post|head|put|delete|options)$/i.test(this.type)&&Z()||ee()}:Z;var un=0,ln={},cn=pe.ajaxSettings.xhr();e.attachEvent&&e.attachEvent("onunload",function(){for(var e in ln)ln[e](void 0,!0)}),fe.cors=!!cn&&"withCredentials"in cn,cn=fe.ajax=!!cn,cn&&pe.ajaxTransport(function(t){if(!t.crossDomain||fe.cors){var n;return{send:function(r,i){var o,a=t.xhr(),s=++un;if(a.open(t.type,t.url,t.async,t.username,t.password),t.xhrFields)for(o in t.xhrFields)a[o]=t.xhrFields[o];t.mimeType&&a.overrideMimeType&&a.overrideMimeType(t.mimeType),t.crossDomain||r["X-Requested-With"]||(r["X-Requested-With"]="XMLHttpRequest");for(o in r)void 0!==r[o]&&a.setRequestHeader(o,r[o]+"");a.send(t.hasContent&&t.data||null),n=function(e,r){var o,u,l;if(n&&(r||4===a.readyState))if(delete ln[s],n=void 0,a.onreadystatechange=pe.noop,r)4!==a.readyState&&a.abort();else{l={},o=a.status,"string"==typeof a.responseText&&(l.text=a.responseText);try{u=a.statusText}catch(c){u=""}o||!t.isLocal||t.crossDomain?1223===o&&(o=204):o=l.text?200:404}l&&i(o,u,l,a.getAllResponseHeaders())},t.async?4===a.readyState?e.setTimeout(n):a.onreadystatechange=ln[s]=n:n()},abort:function(){n&&n(void 0,!0)}}}}),pe.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/\b(?:java|ecma)script\b/},converters:{"text script":function(e){return pe.globalEval(e),e}}}),pe.ajaxPrefilter("script",function(e){void 0===e.cache&&(e.cache=!1),e.crossDomain&&(e.type="GET",e.global=!1)}),pe.ajaxTransport("script",function(e){if(e.crossDomain){var t,n=re.head||pe("head")[0]||re.documentElement;return{send:function(r,i){t=re.createElement("script"),t.async=!0,e.scriptCharset&&(t.charset=e.scriptCharset),t.src=e.url,t.onload=t.onreadystatechange=function(e,n){(n||!t.readyState||/loaded|complete/.test(t.readyState))&&(t.onload=t.onreadystatechange=null,t.parentNode&&t.parentNode.removeChild(t),t=null,n||i(200,"success"))},n.insertBefore(t,n.firstChild)},abort:function(){t&&t.onload(void 0,!0)}}}});var fn=[],dn=/(=)\?(?=&|$)|\?\?/;pe.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var e=fn.pop()||pe.expando+"_"+Wt++;return this[e]=!0,e}}),pe.ajaxPrefilter("json jsonp",function(t,n,r){var i,o,a,s=t.jsonp!==!1&&(dn.test(t.url)?"url":"string"==typeof t.data&&0===(t.contentType||"").indexOf("application/x-www-form-urlencoded")&&dn.test(t.data)&&"data");if(s||"jsonp"===t.dataTypes[0])return i=t.jsonpCallback=pe.isFunction(t.jsonpCallback)?t.jsonpCallback():t.jsonpCallback,s?t[s]=t[s].replace(dn,"$1"+i):t.jsonp!==!1&&(t.url+=(It.test(t.url)?"&":"?")+t.jsonp+"="+i),t.converters["script json"]=function(){return a||pe.error(i+" was not called"),a[0]},t.dataTypes[0]="json",o=e[i],e[i]=function(){a=arguments},r.always(function(){void 0===o?pe(e).removeProp(i):e[i]=o,t[i]&&(t.jsonpCallback=n.jsonpCallback,fn.push(i)),a&&pe.isFunction(o)&&o(a[0]),a=o=void 0}),"script"}),pe.parseHTML=function(e,t,n){if(!e||"string"!=typeof e)return null;"boolean"==typeof t&&(n=t,t=!1),t=t||re;var r=Te.exec(e),i=!n&&[];return r?[t.createElement(r[1])]:(r=y([e],t,i),i&&i.length&&pe(i).remove(),pe.merge([],r.childNodes))};var pn=pe.fn.load;return pe.fn.load=function(e,t,n){if("string"!=typeof e&&pn)return pn.apply(this,arguments);var r,i,o,a=this,s=e.indexOf(" ");return s>-1&&(r=pe.trim(e.slice(s,e.length)),e=e.slice(0,s)),pe.isFunction(t)?(n=t,t=void 0):t&&"object"==typeof t&&(i="POST"),a.length>0&&pe.ajax({url:e,type:i||"GET",dataType:"html",data:t}).done(function(e){o=arguments,a.html(r?pe("
      ").append(pe.parseHTML(e)).find(r):e)}).always(n&&function(e,t){a.each(function(){n.apply(this,o||[e.responseText,t,e])})}),this},pe.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(e,t){pe.fn[t]=function(e){return this.on(t,e)}}),pe.expr.filters.animated=function(e){return pe.grep(pe.timers,function(t){return e===t.elem}).length},pe.offset={setOffset:function(e,t,n){var r,i,o,a,s,u,l,c=pe.css(e,"position"),f=pe(e),d={};"static"===c&&(e.style.position="relative"),s=f.offset(),o=pe.css(e,"top"),u=pe.css(e,"left"),l=("absolute"===c||"fixed"===c)&&pe.inArray("auto",[o,u])>-1,l?(r=f.position(),a=r.top,i=r.left):(a=parseFloat(o)||0,i=parseFloat(u)||0),pe.isFunction(t)&&(t=t.call(e,n,pe.extend({},s))),null!=t.top&&(d.top=t.top-s.top+a),null!=t.left&&(d.left=t.left-s.left+i),"using"in t?t.using.call(e,d):f.css(d)}},pe.fn.extend({offset:function(e){if(arguments.length)return void 0===e?this:this.each(function(t){pe.offset.setOffset(this,e,t)});var t,n,r={top:0,left:0},i=this[0],o=i&&i.ownerDocument;if(o)return t=o.documentElement,pe.contains(t,i)?("undefined"!=typeof i.getBoundingClientRect&&(r=i.getBoundingClientRect()),n=te(o),{top:r.top+(n.pageYOffset||t.scrollTop)-(t.clientTop||0),left:r.left+(n.pageXOffset||t.scrollLeft)-(t.clientLeft||0)}):r},position:function(){if(this[0]){var e,t,n={top:0,left:0},r=this[0];return"fixed"===pe.css(r,"position")?t=r.getBoundingClientRect():(e=this.offsetParent(),t=this.offset(),pe.nodeName(e[0],"html")||(n=e.offset()),n.top+=pe.css(e[0],"borderTopWidth",!0),n.left+=pe.css(e[0],"borderLeftWidth",!0)),{top:t.top-n.top-pe.css(r,"marginTop",!0),left:t.left-n.left-pe.css(r,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){ -for(var e=this.offsetParent;e&&!pe.nodeName(e,"html")&&"static"===pe.css(e,"position");)e=e.offsetParent;return e||pt})}}),pe.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(e,t){var n=/Y/.test(t);pe.fn[e]=function(r){return Pe(this,function(e,r,i){var o=te(e);return void 0===i?o?t in o?o[t]:o.document.documentElement[r]:e[r]:void(o?o.scrollTo(n?pe(o).scrollLeft():i,n?i:pe(o).scrollTop()):e[r]=i)},e,r,arguments.length,null)}}),pe.each(["top","left"],function(e,t){pe.cssHooks[t]=L(fe.pixelPosition,function(e,n){if(n)return n=gt(e,t),ft.test(n)?pe(e).position()[t]+"px":n})}),pe.each({Height:"height",Width:"width"},function(e,t){pe.each({padding:"inner"+e,content:t,"":"outer"+e},function(n,r){pe.fn[r]=function(r,i){var o=arguments.length&&(n||"boolean"!=typeof r),a=n||(r===!0||i===!0?"margin":"border");return Pe(this,function(t,n,r){var i;return pe.isWindow(t)?t.document.documentElement["client"+e]:9===t.nodeType?(i=t.documentElement,Math.max(t.body["scroll"+e],i["scroll"+e],t.body["offset"+e],i["offset"+e],i["client"+e])):void 0===r?pe.css(t,n,a):pe.style(t,n,r,a)},t,o?r:void 0,o,null)}})}),pe.fn.extend({bind:function(e,t,n){return this.on(e,null,t,n)},unbind:function(e,t){return this.off(e,null,t)},delegate:function(e,t,n,r){return this.on(t,e,n,r)},undelegate:function(e,t,n){return 1===arguments.length?this.off(e,"**"):this.off(t,e||"**",n)}}),pe.fn.size=function(){return this.length},pe.fn.andSelf=pe.fn.addBack,layui.define(function(e){e("jquery",pe)}),pe}); \ No newline at end of file diff --git a/Public/layui/lay/modules/laydate.js b/Public/layui/lay/modules/laydate.js deleted file mode 100644 index 40b83f4..0000000 --- a/Public/layui/lay/modules/laydate.js +++ /dev/null @@ -1,2 +0,0 @@ -/** layui-v1.0.9_rls MIT License By http://www.layui.com */ - ;layui.define(function(e){"use strict";var t=window,a={path:"",skin:"default",format:"YYYY-MM-DD",min:"1900-01-01 00:00:00",max:"2099-12-31 23:59:59",isv:!1,init:!0},n={},s=document,i="createElement",o="getElementById",l="getElementsByTagName",d=["laydate_box","laydate_void","laydate_click","LayDateSkin","skins/","/laydate.css"];t.laydate=function(e){return e=e||{},n.run(e),laydate},laydate.v="1.1",n.trim=function(e){return e=e||"",e.replace(/^\s|\s$/g,"").replace(/\s+/g," ")},n.digit=function(e){return e<10?"0"+(0|e):e},n.stopmp=function(e){return e=e||t.event,e.stopPropagation?e.stopPropagation():e.cancelBubble=!0,this},n.each=function(e,t){for(var a=0,n=e.length;an.maxs[0]?s=["y",1]:e>=n.mins[0]&&e<=n.maxs[0]&&(e==n.mins[0]&&(tn.maxs[1]?s=["m",1]:t==n.maxs[1]&&a>n.maxs[2]&&(s=["d",1]))),s},n.timeVoid=function(e,t){if(n.ymd[1]+1==n.mins[1]&&n.ymd[2]==n.mins[2]){if(0===t&&en.maxs[3])return 1;if(1===t&&e>n.maxs[4])return 1;if(2===t&&e>n.maxs[5])return 1}if(e>(t?59:23))return 1},n.check=function(){var e=n.options.format.replace(/YYYY|MM|DD|hh|mm|ss/g,"\\d+\\").replace(/\\$/g,""),t=new RegExp(e),a=n.elem[d.elemv],s=a.match(/\d+/g)||[],i=n.checkVoid(s[0],s[1],s[2]);if(""!==a.replace(/\s/g,"")){if(!t.test(a))return n.elem[d.elemv]="",n.msg("日期不符合格式,请重新选择。"),1;if(i[0])return n.elem[d.elemv]="",n.msg("日期不在有效期内,请重新选择。"),1;i.value=n.elem[d.elemv].match(t).join(),s=i.value.match(/\d+/g),s[1]<1?(s[1]=1,i.auto=1):s[1]>12?(s[1]=12,i.auto=1):s[1].length<2&&(i.auto=1),s[2]<1?(s[2]=1,i.auto=1):s[2]>n.months[(0|s[1])-1]?(s[2]=31,i.auto=1):s[2].length<2&&(i.auto=1),s.length>3&&(n.timeVoid(s[3],0)&&(i.auto=1),n.timeVoid(s[4],1)&&(i.auto=1),n.timeVoid(s[5],2)&&(i.auto=1)),i.auto?n.creation([s[0],0|s[1],0|s[2]],1):i.value!==n.elem[d.elemv]&&(n.elem[d.elemv]=i.value)}},n.months=[31,null,31,30,31,30,31,31,30,31,30,31],n.viewDate=function(e,t,a){var s=(n.query,{}),i=new Date;e<(0|n.mins[0])&&(e=0|n.mins[0]),e>(0|n.maxs[0])&&(e=0|n.maxs[0]),i.setFullYear(e,t,a),s.ymd=[i.getFullYear(),i.getMonth(),i.getDate()],n.months[1]=n.isleap(s.ymd[0])?29:28,i.setFullYear(s.ymd[0],s.ymd[1],1),s.FDay=i.getDay(),s.PDay=n.months[0===t?11:t-1]-s.FDay+1,s.NDay=1,n.each(d.tds,function(e,t){var a,i=s.ymd[0],o=s.ymd[1]+1;t.className="",e=s.FDay&&e'+e+"年":'
    • '+(e-7+t)+"年
    • "}),t("#laydate_ys").innerHTML=a,n.each(t("#laydate_ys li"),function(e,t){"y"===n.checkVoid(t.getAttribute("y"))[0]?n.addClass(t,d[1]):n.on(t,"click",function(e){n.stopmp(e).reshow(),n.viewDate(0|this.getAttribute("y"),n.ymd[1],n.ymd[2])})})},n.initDate=function(){var e=(n.query,new Date),t=n.elem[d.elemv].match(/\d+/g)||[];t.length<3&&(t=n.options.start.match(/\d+/g)||[],t.length<3&&(t=[e.getFullYear(),e.getMonth()+1,e.getDate()])),n.inymd=t,n.viewDate(t[0],t[1]-1,t[2])},n.iswrite=function(){var e=n.query,t={time:e("#laydate_hms")};n.shde(t.time,!n.options.istime),n.shde(d.oclear,!("isclear"in n.options?n.options.isclear:1)),n.shde(d.otoday,!("istoday"in n.options?n.options.istoday:1)),n.shde(d.ok,!("issure"in n.options?n.options.issure:1))},n.orien=function(e,t){var a,s=n.elem.getBoundingClientRect();e.style.left=s.left+(t?0:n.scroll(1))+"px",a=s.bottom+e.offsetHeight/1.5<=n.winarea()?s.bottom-1:s.top>e.offsetHeight/1.5?s.top-e.offsetHeight+1:n.winarea()-e.offsetHeight,e.style.top=Math.max(a+(t?0:n.scroll()),1)+"px"},n.follow=function(e){n.options.fixed?(e.style.position="fixed",n.orien(e,1)):(e.style.position="absolute",n.orien(e))},n.viewtb=function(){var e,t=[],a=["日","一","二","三","四","五","六"],o={},d=s[i]("table"),r=s[i]("thead");return r.appendChild(s[i]("tr")),o.creath=function(e){var t=s[i]("th");t.innerHTML=a[e],r[l]("tr")[0].appendChild(t),t=null},n.each(new Array(6),function(a){t.push([]),e=d.insertRow(0),n.each(new Array(7),function(n){t[a][n]=0,0===a&&o.creath(n),e.insertCell(n)})}),d.insertBefore(r,d.children[0]),d.id=d.className="laydate_table",e=t=null,d.outerHTML.toLowerCase()}(),n.view=function(e,t){var o,l=n.query,r={};t=t||e,n.elem=e,n.options=t,n.options.format||(n.options.format=a.format),n.options.start=n.options.start||"",n.mm=r.mm=[n.options.min||a.min,n.options.max||a.max],n.mins=r.mm[0].match(/\d+/g),n.maxs=r.mm[1].match(/\d+/g),n.box?n.shde(n.box):(o=s[i]("div"),o.id=d[0],o.className=d[0],o.style.cssText="position: absolute;",o.setAttribute("name","laydate-v"+laydate.v),o.innerHTML=r.html='
        '+function(){var e="";return n.each(new Array(12),function(t){e+=''+n.digit(t+1)+"月"}),e}()+"
        "+n.viewtb+'",s.body.appendChild(o),n.box=l("#"+d[0]),n.events(),o=null),n.follow(n.box),t.zIndex?n.box.style.zIndex=t.zIndex:n.removeCssAttr(n.box,"z-index"),n.stopMosup("click",n.box),n.initDate(),n.iswrite(),n.check()},n.reshow=function(){return n.each(n.query("#"+d[0]+" .laydate_show"),function(e,t){n.removeClass(t,"laydate_show")}),this},n.close=function(){n.reshow(),n.shde(n.query("#"+d[0]),1),n.elem=null},n.parse=function(e,t,s){return e=e.concat(t),s=s||(n.options?n.options.format:a.format),s.replace(/YYYY|MM|DD|hh|mm|ss/g,function(t,a){return e.index=0|++e.index,n.digit(e[e.index])})},n.creation=function(e,t){var a=(n.query,n.hmsin),s=n.parse(e,[a[0].value,a[1].value,a[2].value]);n.elem[d.elemv]=s,t||(n.close(),"function"==typeof n.options.choose&&n.options.choose(s))},n.events=function(){var e=n.query,a={box:"#"+d[0]};n.addClass(s.body,"laydate_body"),d.tds=e("#laydate_table td"),d.mms=e("#laydate_ms span"),d.year=e("#laydate_y"),d.month=e("#laydate_m"),n.each(e(a.box+" .laydate_ym"),function(e,t){n.on(t,"click",function(t){n.stopmp(t).reshow(),n.addClass(this[l]("div")[0],"laydate_show"),e||(a.YY=parseInt(d.year.value),n.viewYears(a.YY))})}),n.on(e(a.box),"click",function(){n.reshow()}),a.tabYear=function(e){0===e?n.ymd[0]--:1===e?n.ymd[0]++:2===e?a.YY-=14:a.YY+=14,e<2?(n.viewDate(n.ymd[0],n.ymd[1],n.ymd[2]),n.reshow()):n.viewYears(a.YY)},n.each(e("#laydate_YY .laydate_tab"),function(e,t){n.on(t,"click",function(t){n.stopmp(t),a.tabYear(e)})}),a.tabMonth=function(e){e?(n.ymd[1]++,12===n.ymd[1]&&(n.ymd[0]++,n.ymd[1]=0)):(n.ymd[1]--,n.ymd[1]===-1&&(n.ymd[0]--,n.ymd[1]=11)),n.viewDate(n.ymd[0],n.ymd[1],n.ymd[2])},n.each(e("#laydate_MM .laydate_tab"),function(e,t){n.on(t,"click",function(t){n.stopmp(t).reshow(),a.tabMonth(e)})}),n.each(e("#laydate_ms span"),function(e,t){n.on(t,"click",function(e){n.stopmp(e).reshow(),n.hasClass(this,d[1])||n.viewDate(n.ymd[0],0|this.getAttribute("m"),n.ymd[2])})}),n.each(e("#laydate_table td"),function(e,t){n.on(t,"click",function(e){n.hasClass(this,d[1])||(n.stopmp(e),n.creation([0|this.getAttribute("y"),0|this.getAttribute("m"),0|this.getAttribute("d")]))})}),d.oclear=e("#laydate_clear"),n.on(d.oclear,"click",function(){n.elem[d.elemv]="",n.close()}),d.otoday=e("#laydate_today"),n.on(d.otoday,"click",function(){var e=new Date;n.creation([e.getFullYear(),e.getMonth()+1,e.getDate()])}),d.ok=e("#laydate_ok"),n.on(d.ok,"click",function(){n.valid&&n.creation([n.ymd[0],n.ymd[1]+1,n.ymd[2]])}),a.times=e("#laydate_time"),n.hmsin=a.hmsin=e("#laydate_hms input"),a.hmss=["小时","分钟","秒数"],a.hmsarr=[],n.msg=function(t,s){var i='
        '+(s||"提示")+"×
        ";"string"==typeof t?(i+="

        "+t+"

        ",n.shde(e("#"+d[0])),n.removeClass(a.times,"laydate_time1").addClass(a.times,"laydate_msg")):(a.hmsarr[t]?i=a.hmsarr[t]:(i+='
        ',n.each(new Array(0===t?24:60),function(e){i+=""+e+""}),i+="
        ",a.hmsarr[t]=i),n.removeClass(a.times,"laydate_msg"),n[0===t?"removeClass":"addClass"](a.times,"laydate_time1")),n.addClass(a.times,"laydate_show"),a.times.innerHTML=i},a.hmson=function(t,a){var s=e("#laydate_hmsno span"),i=n.valid?null:1;n.each(s,function(e,s){i?n.addClass(s,d[1]):n.timeVoid(e,a)?n.addClass(s,d[1]):n.on(s,"click",function(e){n.hasClass(this,d[1])||(t.value=n.digit(0|this.innerHTML))})}),n.addClass(s[0|t.value],"laydate_click")},n.each(a.hmsin,function(e,t){n.on(t,"click",function(t){n.stopmp(t).reshow(),n.msg(e,a.hmss[e]),a.hmson(this,e)})}),n.on(s,"mouseup",function(){var t=e("#"+d[0]);t&&"none"!==t.style.display&&(n.check()||n.close())}).on(s,"keydown",function(e){e=e||t.event;var a=e.keyCode;13===a&&n.elem&&n.creation([n.ymd[0],n.ymd[1]+1,n.ymd[2]])})},laydate.reset=function(){n.box&&n.elem&&n.follow(n.box)},laydate.now=function(e,t){var a=new Date(0|e?function(e){return e<864e5?+new Date+864e5*e:e}(parseInt(e)):+new Date);return n.parse([a.getFullYear(),a.getMonth()+1,a.getDate()],[a.getHours(),a.getMinutes(),a.getSeconds()],t)},layui.addcss("modules/laydate/laydate.css",function(){},"laydatecss"),e("laydate",laydate)}); \ No newline at end of file diff --git a/Public/layui/lay/modules/layedit.js b/Public/layui/lay/modules/layedit.js deleted file mode 100644 index 891d287..0000000 --- a/Public/layui/lay/modules/layedit.js +++ /dev/null @@ -1,2 +0,0 @@ -/** layui-v1.0.9_rls MIT License By http://www.layui.com */ - ;layui.define(["layer","form"],function(t){"use strict";var e=layui.jquery,i=layui.layer,a=layui.form(),l=(layui.hint(),layui.device()),n="layedit",o="layui-show",r="layui-disabled",s=function(){var t=this;t.index=0,t.config={tool:["strong","italic","underline","del","|","left","center","right","|","link","unlink","face","image"],hideTool:[],height:280}};s.prototype.set=function(t){var i=this;return e.extend(!0,i.config,t),i},s.prototype.on=function(t,e){return layui.onevent(n,t,e)},s.prototype.build=function(t,i){i=i||{};var a=this,n=a.config,r="layui-layedit",s=e("#"+t),u="LAY_layedit_"+ ++a.index,d=s.next("."+r),y=e.extend({},n,i),f=function(){var t=[],e={};return layui.each(y.hideTool,function(t,i){e[i]=!0}),layui.each(y.tool,function(i,a){C[a]&&!e[a]&&t.push(C[a])}),t.join("")}(),m=e(['
        ','
        '+f+"
        ",'
        ','',"
        ","
        "].join(""));return l.ie&&l.ie<8?s.removeClass("layui-hide").addClass(o):(d[0]&&d.remove(),c.call(a,m,s[0],y),s.addClass("layui-hide").after(m),a.index)},s.prototype.getContent=function(t){var e=u(t);if(e[0])return d(e[0].document.body.innerHTML)},s.prototype.getText=function(t){var i=u(t);if(i[0])return e(i[0].document.body).text()},s.prototype.sync=function(t){var i=u(t);if(i[0]){var a=e("#"+i[1].attr("textarea"));a.val(d(i[0].document.body.innerHTML))}},s.prototype.getSelection=function(t){var e=u(t);if(e[0]){var i=m(e[0].document);return document.selection?i.text:i.toString()}};var c=function(t,i,a){var l=this,n=t.find("iframe");n.css({height:a.height}).on("load",function(){var o=n.contents(),r=n.prop("contentWindow"),s=o.find("head"),c=e([""].join("")),u=o.find("body");s.append(c),u.attr("contenteditable","true").css({"min-height":a.height}).html(i.value||""),y.apply(l,[r,n,i,a]),g.call(l,r,t,a)})},u=function(t){var i=e("#LAY_layedit_"+t),a=i.prop("contentWindow");return[a,i]},d=function(t){return 8==l.ie&&(t=t.replace(/<.+>/g,function(t){return t.toLowerCase()})),t},y=function(t,a,n,o){var r=t.document,s=e(r.body);s.on("keydown",function(t){var e=t.keyCode;if(13===e){var a=m(r),l=p(a),n=l.parentNode;if("pre"===n.tagName.toLowerCase()){if(t.shiftKey)return;return i.msg("请暂时用shift+enter"),!1}r.execCommand("formatBlock",!1,"

        ")}}),e(n).parents("form").on("submit",function(){var t=s.html();8==l.ie&&(t=t.replace(/<.+>/g,function(t){return t.toLowerCase()})),n.value=t}),s.on("paste",function(e){r.execCommand("formatBlock",!1,"

        "),setTimeout(function(){f.call(t,s),n.value=s.html()},100)})},f=function(t){var i=this;i.document;t.find("*[style]").each(function(){var t=this.style.textAlign;this.removeAttribute("style"),e(this).css({"text-align":t||""})}),t.find("table").addClass("layui-table"),t.find("script,link").remove()},m=function(t){return t.selection?t.selection.createRange():t.getSelection().getRangeAt(0)},p=function(t){return t.endContainer||t.parentElement().childNodes[0]},v=function(t,i,a){var l=this.document,n=document.createElement(t);for(var o in i)n.setAttribute(o,i[o]);if(n.removeAttribute("text"),l.selection){var r=a.text||i.text;if("a"===t&&!r)return;r&&(n.innerHTML=r),a.pasteHTML(e(n).prop("outerHTML")),a.select()}else{var r=a.toString()||i.text;if("a"===t&&!r)return;r&&(n.innerHTML=r),a.deleteContents(),a.insertNode(n)}},h=function(t,i){var a=this.document,l="layedit-tool-active",n=p(m(a)),o=function(e){return t.find(".layedit-tool-"+e)};i&&i[i.hasClass(l)?"removeClass":"addClass"](l),t.find(">i").removeClass(l),o("unlink").addClass(r),e(n).parents().each(function(){var t=this.tagName.toLowerCase(),e=this.style.textAlign;"b"!==t&&"strong"!==t||o("b").addClass(l),"i"!==t&&"em"!==t||o("i").addClass(l),"u"===t&&o("u").addClass(l),"strike"===t&&o("d").addClass(l),"p"===t&&("center"===e?o("center").addClass(l):"right"===e?o("right").addClass(l):o("left").addClass(l)),"a"===t&&(o("link").addClass(l),o("unlink").removeClass(r))})},g=function(t,a,l){var n=t.document,o=e(n.body),s={link:function(i){var a=p(i),l=e(a).parent();b.call(o,{href:l.attr("href"),target:l.attr("target")},function(e){var a=l[0];"A"===a.tagName?a.href=e.url:v.call(t,"a",{target:e.target,href:e.url,text:e.url},i)})},unlink:function(t){n.execCommand("unlink")},face:function(e){x.call(this,function(i){v.call(t,"img",{src:i.src,alt:i.alt},e)})},image:function(a){var n=this;layui.use("upload",function(o){var r=l.uploadImage||{};o({url:r.url,method:r.type,elem:e(n).find("input")[0],unwrap:!0,success:function(e){0==e.code?(e.data=e.data||{},v.call(t,"img",{src:e.data.src,alt:e.data.title},a)):i.msg(e.msg||"上传失败")}})})},code:function(e){k.call(o,function(i){v.call(t,"pre",{text:i.code,"lay-lang":i.lang},e)})},help:function(){i.open({type:2,title:"帮助",area:["600px","380px"],shadeClose:!0,shade:.1,skin:"layui-layer-msg",content:["http://www.layui.com/about/layedit/help.html","no"]})}},c=a.find(".layui-layedit-tool"),u=function(){var i=e(this),a=i.attr("layedit-event"),l=i.attr("lay-command");if(!i.hasClass(r)){o.focus();var u=m(n);u.commonAncestorContainer;l?(n.execCommand(l),/justifyLeft|justifyCenter|justifyRight/.test(l)&&n.execCommand("formatBlock",!1,"

        "),setTimeout(function(){o.focus()},10)):s[a]&&s[a].call(this,u),h.call(t,c,i)}},d=/image/;c.find(">i").on("mousedown",function(){var t=e(this),i=t.attr("layedit-event");d.test(i)||u.call(this)}).on("click",function(){var t=e(this),i=t.attr("layedit-event");d.test(i)&&u.call(this)}),o.on("click",function(){h.call(t,c),i.close(x.index)})},b=function(t,e){var l=this,n=i.open({type:1,id:"LAY_layedit_link",area:"350px",shade:.05,shadeClose:!0,moveType:1,title:"超链接",skin:"layui-layer-msg",content:['

          ','
        • ','','
          ','',"
          ","
        • ",'
        • ','','
          ','",'","
          ","
        • ",'
        • ','','',"
        • ","
        "].join(""),success:function(t,n){var o="submit(layedit-link-yes)";a.render("radio"),t.find(".layui-btn-primary").on("click",function(){i.close(n),l.focus()}),a.on(o,function(t){i.close(b.index),e&&e(t.field)})}});b.index=n},x=function(t){var a=function(){var t=["[微笑]","[嘻嘻]","[哈哈]","[可爱]","[可怜]","[挖鼻]","[吃惊]","[害羞]","[挤眼]","[闭嘴]","[鄙视]","[爱你]","[泪]","[偷笑]","[亲亲]","[生病]","[太开心]","[白眼]","[右哼哼]","[左哼哼]","[嘘]","[衰]","[委屈]","[吐]","[哈欠]","[抱抱]","[怒]","[疑问]","[馋嘴]","[拜拜]","[思考]","[汗]","[困]","[睡]","[钱]","[失望]","[酷]","[色]","[哼]","[鼓掌]","[晕]","[悲伤]","[抓狂]","[黑线]","[阴险]","[怒骂]","[互粉]","[心]","[伤心]","[猪头]","[熊猫]","[兔子]","[ok]","[耶]","[good]","[NO]","[赞]","[来]","[弱]","[草泥马]","[神马]","[囧]","[浮云]","[给力]","[围观]","[威武]","[奥特曼]","[礼物]","[钟]","[话筒]","[蜡烛]","[蛋糕]"],e={};return layui.each(t,function(t,i){e[i]=layui.cache.dir+"images/face/"+t+".gif"}),e}();return x.hide=x.hide||function(t){"face"!==e(t.target).attr("layedit-event")&&i.close(x.index)},x.index=i.tips(function(){var t=[];return layui.each(a,function(e,i){t.push('
      • '+e+'
      • ')}),'
          '+t.join("")+"
        "}(),this,{tips:1,time:0,skin:"layui-box layui-util-face",maxWidth:500,success:function(l,n){l.css({marginTop:-4,marginLeft:-10}).find(".layui-clear>li").on("click",function(){t&&t({src:a[this.title],alt:this.title}),i.close(n)}),e(document).off("click",x.hide).on("click",x.hide)}})},k=function(t){var e=this,l=i.open({type:1,id:"LAY_layedit_code",area:"550px",shade:.05,shadeClose:!0,moveType:1,title:"插入代码",skin:"layui-layer-msg",content:['
          ','
        • ','','
          ','","
          ","
        • ",'
        • ','','
          ','',"
          ","
        • ",'
        • ','','',"
        • ","
        "].join(""),success:function(l,n){var o="submit(layedit-code-yes)";a.render("select"),l.find(".layui-btn-primary").on("click",function(){i.close(n),e.focus()}),a.on(o,function(e){i.close(k.index),t&&t(e.field)})}});k.index=l},C={html:'',strong:'',italic:'',underline:'',del:'',"|":'',left:'',center:'',right:'',link:'',unlink:'',face:'',image:'',code:'',help:''},w=new s;t(n,w)}); \ No newline at end of file diff --git a/Public/layui/lay/modules/layer.js b/Public/layui/lay/modules/layer.js deleted file mode 100644 index 7b036ff..0000000 --- a/Public/layui/lay/modules/layer.js +++ /dev/null @@ -1,2 +0,0 @@ -/** layui-v1.0.9_rls MIT License By http://www.layui.com */ - ;!function(e,t){"use strict";var i,n,a=e.layui&&layui.define,o={getPath:function(){var e=document.scripts,t=e[e.length-1],i=t.src;if(!t.getAttribute("merge"))return i.substring(0,i.lastIndexOf("/")+1)}(),config:{},end:{},minIndex:0,minLeft:[],btn:["确定","取消"],type:["dialog","page","iframe","loading","tips"]},r={v:"3.0.2",ie:function(){var t=navigator.userAgent.toLowerCase();return!!(e.ActiveXObject||"ActiveXObject"in e)&&((t.match(/msie\s(\d+)/)||[])[1]||"11")}(),index:e.layer&&e.layer.v?1e5:0,path:o.getPath,config:function(e,t){return e=e||{},r.cache=o.config=i.extend({},o.config,e),r.path=o.config.path||r.path,"string"==typeof e.extend&&(e.extend=[e.extend]),o.config.path&&r.ready(),e.extend?(a?layui.addcss("modules/layer/"+e.extend):r.link("skin/"+e.extend),this):this},link:function(t,n,a){if(r.path){var o=i("head")[0],s=document.createElement("link");"string"==typeof n&&(a=n);var l=(a||t).replace(/\.|\//g,""),f="layuicss-"+l,c=0;s.rel="stylesheet",s.href=r.path+t,s.id=f,i("#"+f)[0]||o.appendChild(s),"function"==typeof n&&!function u(){return++c>80?e.console&&console.error("layer.css: Invalid"):void(1989===parseInt(i("#"+f).css("width"))?n():setTimeout(u,100))}()}},ready:function(e){var t="skinlayercss",i="302";return a?layui.addcss("modules/layer/default/layer.css?v="+r.v+i,e,t):r.link("skin/default/layer.css?v="+r.v+i,e,t),this},alert:function(e,t,n){var a="function"==typeof t;return a&&(n=t),r.open(i.extend({content:e,yes:n},a?{}:t))},confirm:function(e,t,n,a){var s="function"==typeof t;return s&&(a=n,n=t),r.open(i.extend({content:e,btn:o.btn,yes:n,btn2:a},s?{}:t))},msg:function(e,n,a){var s="function"==typeof n,f=o.config.skin,c=(f?f+" "+f+"-msg":"")||"layui-layer-msg",u=l.anim.length-1;return s&&(a=n),r.open(i.extend({content:e,time:3e3,shade:!1,skin:c,title:!1,closeBtn:!1,btn:!1,resize:!1,end:a},s&&!o.config.skin?{skin:c+" layui-layer-hui",anim:u}:function(){return n=n||{},(n.icon===-1||n.icon===t&&!o.config.skin)&&(n.skin=c+" "+(n.skin||"layui-layer-hui")),n}()))},load:function(e,t){return r.open(i.extend({type:3,icon:e||0,resize:!1,shade:.01},t))},tips:function(e,t,n){return r.open(i.extend({type:4,content:[e,t],closeBtn:!1,time:3e3,shade:!1,resize:!1,fixed:!1,maxWidth:210},n))}},s=function(e){var t=this;t.index=++r.index,t.config=i.extend({},t.config,o.config,e),r.ready(function(){document.body?t.creat():setTimeout(function(){t.creat()},50)})};s.pt=s.prototype;var l=["layui-layer",".layui-layer-title",".layui-layer-main",".layui-layer-dialog","layui-layer-iframe","layui-layer-content","layui-layer-btn","layui-layer-close"];l.anim=["layer-anim","layer-anim-01","layer-anim-02","layer-anim-03","layer-anim-04","layer-anim-05","layer-anim-06"],s.pt.config={type:0,shade:.3,fixed:!0,move:l[1],title:"信息",offset:"auto",area:"auto",closeBtn:1,time:0,zIndex:19891014,maxWidth:360,anim:0,icon:-1,moveType:1,resize:!0,scrollbar:!0,tips:2},s.pt.vessel=function(e,t){var n=this,a=n.index,r=n.config,s=r.zIndex+a,f="object"==typeof r.title,c=r.maxmin&&(1===r.type||2===r.type),u=r.title?'
        '+(f?r.title[0]:r.title)+"
        ":"";return r.zIndex=s,t([r.shade?'
        ':"",'
        '+(e&&2!=r.type?"":u)+'
        '+(0==r.type&&r.icon!==-1?'':"")+(1==r.type&&e?"":r.content||"")+'
        '+function(){var e=c?'':"";return r.closeBtn&&(e+=''),e}()+""+(r.btn?function(){var e="";"string"==typeof r.btn&&(r.btn=[r.btn]);for(var t=0,i=r.btn.length;t'+r.btn[t]+"";return'
        '+e+"
        "}():"")+(r.resize?'':"")+"
        "],u,i('
        ')),n},s.pt.creat=function(){var e=this,t=e.config,a=e.index,s=t.content,f="object"==typeof s,c=i("body");if(!t.id||!i("#"+t.id)[0]){switch("string"==typeof t.area&&(t.area="auto"===t.area?["",""]:[t.area,""]),t.shift&&(t.anim=t.shift),6==r.ie&&(t.fixed=!1),t.type){case 0:t.btn="btn"in t?t.btn:o.btn[0],r.closeAll("dialog");break;case 2:var s=t.content=f?t.content:[t.content||"http://layer.layui.com","auto"];t.content='';break;case 3:delete t.title,delete t.closeBtn,t.icon===-1&&0===t.icon,r.closeAll("loading");break;case 4:f||(t.content=[t.content,"body"]),t.follow=t.content[1],t.content=t.content[0]+'',delete t.title,t.tips="object"==typeof t.tips?t.tips:[t.tips,!0],t.tipsMore||r.closeAll("tips")}e.vessel(f,function(n,r,u){c.append(n[0]),f?function(){2==t.type||4==t.type?function(){i("body").append(n[1])}():function(){s.parents("."+l[0])[0]||(s.data("display",s.css("display")).show().addClass("layui-layer-wrap").wrap(n[1]),i("#"+l[0]+a).find("."+l[5]).before(r))}()}():c.append(n[1]),i(".layui-layer-move")[0]||c.append(o.moveElem=u),e.layero=i("#"+l[0]+a),t.scrollbar||l.html.css("overflow","hidden").attr("layer-full",a)}).auto(a),2==t.type&&6==r.ie&&e.layero.find("iframe").attr("src",s[0]),4==t.type?e.tips():e.offset(),t.fixed&&n.on("resize",function(){e.offset(),(/^\d+%$/.test(t.area[0])||/^\d+%$/.test(t.area[1]))&&e.auto(a),4==t.type&&e.tips()}),t.time<=0||setTimeout(function(){r.close(e.index)},t.time),e.move().callback(),l.anim[t.anim]&&e.layero.addClass(l.anim[t.anim]).data("anim",!0)}},s.pt.auto=function(e){function t(e){e=s.find(e),e.height(f[1]-c-u-2*(0|parseFloat(e.css("padding"))))}var a=this,o=a.config,s=i("#"+l[0]+e);""===o.area[0]&&o.maxWidth>0&&(r.ie&&r.ie<8&&o.btn&&s.width(s.innerWidth()),s.outerWidth()>o.maxWidth&&s.width(o.maxWidth));var f=[s.innerWidth(),s.innerHeight()],c=s.find(l[1]).outerHeight()||0,u=s.find("."+l[6]).outerHeight()||0;switch(o.type){case 2:t("iframe");break;default:""===o.area[1]?o.fixed&&f[1]>=n.height()&&(f[1]=n.height(),t("."+l[5])):t("."+l[5])}return a},s.pt.offset=function(){var e=this,t=e.config,i=e.layero,a=[i.outerWidth(),i.outerHeight()],o="object"==typeof t.offset;e.offsetTop=(n.height()-a[1])/2,e.offsetLeft=(n.width()-a[0])/2,o?(e.offsetTop=t.offset[0],e.offsetLeft=t.offset[1]||e.offsetLeft):"auto"!==t.offset&&("t"===t.offset?e.offsetTop=0:"r"===t.offset?e.offsetLeft=n.width()-a[0]:"b"===t.offset?e.offsetTop=n.height()-a[1]:"l"===t.offset?e.offsetLeft=0:"lt"===t.offset?(e.offsetTop=0,e.offsetLeft=0):"lb"===t.offset?(e.offsetTop=n.height()-a[1],e.offsetLeft=0):"rt"===t.offset?(e.offsetTop=0,e.offsetLeft=n.width()-a[0]):"rb"===t.offset?(e.offsetTop=n.height()-a[1],e.offsetLeft=n.width()-a[0]):e.offsetTop=t.offset),t.fixed||(e.offsetTop=/%$/.test(e.offsetTop)?n.height()*parseFloat(e.offsetTop)/100:parseFloat(e.offsetTop),e.offsetLeft=/%$/.test(e.offsetLeft)?n.width()*parseFloat(e.offsetLeft)/100:parseFloat(e.offsetLeft),e.offsetTop+=n.scrollTop(),e.offsetLeft+=n.scrollLeft()),i.attr("minLeft")&&(e.offsetTop=n.height()-(i.find(l[1]).outerHeight()||0),e.offsetLeft=i.css("left")),i.css({top:e.offsetTop,left:e.offsetLeft})},s.pt.tips=function(){var e=this,t=e.config,a=e.layero,o=[a.outerWidth(),a.outerHeight()],r=i(t.follow);r[0]||(r=i("body"));var s={width:r.outerWidth(),height:r.outerHeight(),top:r.offset().top,left:r.offset().left},f=a.find(".layui-layer-TipsG"),c=t.tips[0];t.tips[1]||f.remove(),s.autoLeft=function(){s.left+o[0]-n.width()>0?(s.tipLeft=s.left+s.width-o[0],f.css({right:12,left:"auto"})):s.tipLeft=s.left},s.where=[function(){s.autoLeft(),s.tipTop=s.top-o[1]-10,f.removeClass("layui-layer-TipsB").addClass("layui-layer-TipsT").css("border-right-color",t.tips[1])},function(){s.tipLeft=s.left+s.width+10,s.tipTop=s.top,f.removeClass("layui-layer-TipsL").addClass("layui-layer-TipsR").css("border-bottom-color",t.tips[1])},function(){s.autoLeft(),s.tipTop=s.top+s.height+10,f.removeClass("layui-layer-TipsT").addClass("layui-layer-TipsB").css("border-right-color",t.tips[1])},function(){s.tipLeft=s.left-o[0]-10,s.tipTop=s.top,f.removeClass("layui-layer-TipsR").addClass("layui-layer-TipsL").css("border-bottom-color",t.tips[1])}],s.where[c-1](),1===c?s.top-(n.scrollTop()+o[1]+16)<0&&s.where[2]():2===c?n.width()-(s.left+s.width+o[0]+16)>0||s.where[3]():3===c?s.top-n.scrollTop()+s.height+o[1]+16-n.height()>0&&s.where[0]():4===c&&o[0]+16-s.left>0&&s.where[1](),a.find("."+l[5]).css({"background-color":t.tips[1],"padding-right":t.closeBtn?"30px":""}),a.css({left:s.tipLeft-(t.fixed?n.scrollLeft():0),top:s.tipTop-(t.fixed?n.scrollTop():0)})},s.pt.move=function(){var e=this,t=e.config,a=i(document),s=e.layero,l=s.find(t.move),f=s.find(".layui-layer-resize"),c={};return t.move&&l.css("cursor","move"),l.on("mousedown",function(e){e.preventDefault(),t.move&&(c.moveStart=!0,c.offset=[e.clientX-parseFloat(s.css("left")),e.clientY-parseFloat(s.css("top"))],o.moveElem.css("cursor","move").show())}),f.on("mousedown",function(e){e.preventDefault(),c.resizeStart=!0,c.offset=[e.clientX,e.clientY],c.area=[s.outerWidth(),s.outerHeight()],o.moveElem.css("cursor","se-resize").show()}),a.on("mousemove",function(i){if(c.moveStart){var a=i.clientX-c.offset[0],o=i.clientY-c.offset[1],l="fixed"===s.css("position");if(i.preventDefault(),c.stX=l?0:n.scrollLeft(),c.stY=l?0:n.scrollTop(),!t.moveOut){var f=n.width()-s.outerWidth()+c.stX,u=n.height()-s.outerHeight()+c.stY;af&&(a=f),ou&&(o=u)}s.css({left:a,top:o})}if(t.resize&&c.resizeStart){var a=i.clientX-c.offset[0],o=i.clientY-c.offset[1];i.preventDefault(),r.style(e.index,{width:c.area[0]+a,height:c.area[1]+o}),c.isResize=!0,t.resizing&&t.resizing(s)}}).on("mouseup",function(e){c.moveStart&&(delete c.moveStart,o.moveElem.hide(),t.moveEnd&&t.moveEnd(s)),c.resizeStart&&(delete c.resizeStart,o.moveElem.hide())}),e},s.pt.callback=function(){function e(){var e=a.cancel&&a.cancel(t.index,n);e===!1||r.close(t.index)}var t=this,n=t.layero,a=t.config;t.openLayer(),a.success&&(2==a.type?n.find("iframe").on("load",function(){a.success(n,t.index)}):a.success(n,t.index)),6==r.ie&&t.IE6(n),n.find("."+l[6]).children("a").on("click",function(){var e=i(this).index();if(0===e)a.yes?a.yes(t.index,n):a.btn1?a.btn1(t.index,n):r.close(t.index);else{var o=a["btn"+(e+1)]&&a["btn"+(e+1)](t.index,n);o===!1||r.close(t.index)}}),n.find("."+l[7]).on("click",e),a.shadeClose&&i("#layui-layer-shade"+t.index).on("click",function(){r.close(t.index)}),n.find(".layui-layer-min").on("click",function(){var e=a.min&&a.min(n);e===!1||r.min(t.index,a)}),n.find(".layui-layer-max").on("click",function(){i(this).hasClass("layui-layer-maxmin")?(r.restore(t.index),a.restore&&a.restore(n)):(r.full(t.index,a),setTimeout(function(){a.full&&a.full(n)},100))}),a.end&&(o.end[t.index]=a.end)},o.reselect=function(){i.each(i("select"),function(e,t){var n=i(this);n.parents("."+l[0])[0]||1==n.attr("layer")&&i("."+l[0]).length<1&&n.removeAttr("layer").show(),n=null})},s.pt.IE6=function(e){i("select").each(function(e,t){var n=i(this);n.parents("."+l[0])[0]||"none"===n.css("display")||n.attr({layer:"1"}).hide(),n=null})},s.pt.openLayer=function(){var e=this;r.zIndex=e.config.zIndex,r.setTop=function(e){var t=function(){r.zIndex++,e.css("z-index",r.zIndex+1)};return r.zIndex=parseInt(e[0].style.zIndex),e.on("mousedown",t),r.zIndex}},o.record=function(e){var t=[e.width(),e.height(),e.position().top,e.position().left+parseFloat(e.css("margin-left"))];e.find(".layui-layer-max").addClass("layui-layer-maxmin"),e.attr({area:t})},o.rescollbar=function(e){l.html.attr("layer-full")==e&&(l.html[0].style.removeProperty?l.html[0].style.removeProperty("overflow"):l.html[0].style.removeAttribute("overflow"),l.html.removeAttr("layer-full"))},e.layer=r,r.getChildFrame=function(e,t){return t=t||i("."+l[4]).attr("times"),i("#"+l[0]+t).find("iframe").contents().find(e)},r.getFrameIndex=function(e){return i("#"+e).parents("."+l[4]).attr("times")},r.iframeAuto=function(e){if(e){var t=r.getChildFrame("html",e).outerHeight(),n=i("#"+l[0]+e),a=n.find(l[1]).outerHeight()||0,o=n.find("."+l[6]).outerHeight()||0;n.css({height:t+a+o}),n.find("iframe").css({height:t})}},r.iframeSrc=function(e,t){i("#"+l[0]+e).find("iframe").attr("src",t)},r.style=function(e,t,n){var a=i("#"+l[0]+e),r=a.find(".layui-layer-content"),s=a.attr("type"),f=a.find(l[1]).outerHeight()||0,c=a.find("."+l[6]).outerHeight()||0;a.attr("minLeft");s!==o.type[3]&&s!==o.type[4]&&(n||(parseFloat(t.width)<=260&&(t.width=260),parseFloat(t.height)-f-c<=64&&(t.height=64+f+c)),a.css(t),c=a.find("."+l[6]).outerHeight(),s===o.type[2]?a.find("iframe").css({height:parseFloat(t.height)-f-c}):r.css({height:parseFloat(t.height)-f-c-parseFloat(r.css("padding-top"))-parseFloat(r.css("padding-bottom"))}))},r.min=function(e,t){var a=i("#"+l[0]+e),s=a.find(l[1]).outerHeight()||0,f=a.attr("minLeft")||181*o.minIndex+"px",c=a.css("position");o.record(a),o.minLeft[0]&&(f=o.minLeft[0],o.minLeft.shift()),a.attr("position",c),r.style(e,{width:180,height:s,left:f,top:n.height()-s,position:"fixed",overflow:"hidden"},!0),a.find(".layui-layer-min").hide(),"page"===a.attr("type")&&a.find(l[4]).hide(),o.rescollbar(e),a.attr("minLeft")||o.minIndex++,a.attr("minLeft",f)},r.restore=function(e){var t=i("#"+l[0]+e),n=t.attr("area").split(",");t.attr("type");r.style(e,{width:parseFloat(n[0]),height:parseFloat(n[1]),top:parseFloat(n[2]),left:parseFloat(n[3]),position:t.attr("position"),overflow:"visible"},!0),t.find(".layui-layer-max").removeClass("layui-layer-maxmin"),t.find(".layui-layer-min").show(),"page"===t.attr("type")&&t.find(l[4]).show(),o.rescollbar(e)},r.full=function(e){var t,a=i("#"+l[0]+e);o.record(a),l.html.attr("layer-full")||l.html.css("overflow","hidden").attr("layer-full",e),clearTimeout(t),t=setTimeout(function(){var t="fixed"===a.css("position");r.style(e,{top:t?0:n.scrollTop(),left:t?0:n.scrollLeft(),width:n.width(),height:n.height()},!0),a.find(".layui-layer-min").hide()},100)},r.title=function(e,t){var n=i("#"+l[0]+(t||r.index)).find(l[1]);n.html(e)},r.close=function(e){var t=i("#"+l[0]+e),n=t.attr("type"),a="layer-anim-close";if(t[0]){var s="layui-layer-wrap",f=function(){if(n===o.type[1]&&"object"===t.attr("conType")){t.children(":not(."+l[5]+")").remove();for(var a=t.find("."+s),r=0;r<2;r++)a.unwrap();a.css("display",a.data("display")).removeClass(s)}else{if(n===o.type[2])try{var f=i("#"+l[4]+e)[0];f.contentWindow.document.write(""),f.contentWindow.close(),t.find("."+l[5])[0].removeChild(f)}catch(c){}t[0].innerHTML="",t.remove()}"function"==typeof o.end[e]&&o.end[e](),delete o.end[e]};t.data("anim")&&t.addClass(a),i("#layui-layer-moves, #layui-layer-shade"+e).remove(),6==r.ie&&o.reselect(),o.rescollbar(e),t.attr("minLeft")&&(o.minIndex--,o.minLeft.push(t.attr("minLeft"))),setTimeout(function(){f()},r.ie&&r.ie<10||!t.data("anim")?0:200)}},r.closeAll=function(e){i.each(i("."+l[0]),function(){var t=i(this),n=e?t.attr("type")===e:1;n&&r.close(t.attr("times")),n=null})};var f=r.cache||{},c=function(e){return f.skin?" "+f.skin+" "+f.skin+"-"+e:""};r.prompt=function(e,t){var a="";if(e=e||{},"function"==typeof e&&(t=e),e.area){var o=e.area;a='style="width: '+o[0]+"; height: "+o[1]+';"',delete e.area}var s,l=2==e.formType?'":function(){return''}(),f=e.success;return delete e.success,r.open(i.extend({type:1,btn:["确定","取消"],content:l,skin:"layui-layer-prompt"+c("prompt"),maxWidth:n.width(),success:function(e){s=e.find(".layui-layer-input"),s.focus(),"function"==typeof f&&f(e)},resize:!1,yes:function(i){var n=s.val();""===n?s.focus():n.length>(e.maxlength||500)?r.tips("最多输入"+(e.maxlength||500)+"个字数",s,{tips:1}):t&&t(n,i,s)}},e))},r.tab=function(e){e=e||{};var t=e.tab||{},n=e.success;return delete e.success,r.open(i.extend({type:1,skin:"layui-layer-tab"+c("tab"),resize:!1,title:function(){var e=t.length,i=1,n="";if(e>0)for(n=''+t[0].title+"";i"+t[i].title+"";return n}(),content:'
          '+function(){var e=t.length,i=1,n="";if(e>0)for(n='
        • '+(t[0].content||"no content")+"
        • ";i'+(t[i].content||"no content")+"";return n}()+"
        ",success:function(t){var a=t.find(".layui-layer-title").children(),o=t.find(".layui-layer-tabmain").children();a.on("mousedown",function(t){t.stopPropagation?t.stopPropagation():t.cancelBubble=!0;var n=i(this),a=n.index();n.addClass("layui-layer-tabnow").siblings().removeClass("layui-layer-tabnow"),o.eq(a).show().siblings().hide(),"function"==typeof e.change&&e.change(a)}),"function"==typeof n&&n(t)}},e))},r.photos=function(t,n,a){function o(e,t,i){var n=new Image;return n.src=e,n.complete?t(n):(n.onload=function(){n.onload=null,t(n)},void(n.onerror=function(e){n.onerror=null,i(e)}))}var s={};if(t=t||{},t.photos){var l=t.photos.constructor===Object,f=l?t.photos:{},u=f.data||[],d=f.start||0;s.imgIndex=(0|d)+1,t.img=t.img||"img";var y=t.success;if(delete t.success,l){if(0===u.length)return r.msg("没有图片")}else{var p=i(t.photos),h=function(){u=[],p.find(t.img).each(function(e){var t=i(this);t.attr("layer-index",e),u.push({alt:t.attr("alt"),pid:t.attr("layer-pid"),src:t.attr("layer-src")||t.attr("src"),thumb:t.attr("src")})})};if(h(),0===u.length)return;if(n||p.on("click",t.img,function(){var e=i(this),n=e.attr("layer-index");r.photos(i.extend(t,{photos:{start:n,data:u,tab:t.tab},full:t.full}),!0),h()}),!n)return}s.imgprev=function(e){s.imgIndex--,s.imgIndex<1&&(s.imgIndex=u.length),s.tabimg(e)},s.imgnext=function(e,t){s.imgIndex++,s.imgIndex>u.length&&(s.imgIndex=1,t)||s.tabimg(e)},s.keyup=function(e){if(!s.end){var t=e.keyCode;e.preventDefault(),37===t?s.imgprev(!0):39===t?s.imgnext(!0):27===t&&r.close(s.index)}},s.tabimg=function(e){u.length<=1||(f.start=s.imgIndex-1,r.close(s.index),setTimeout(function(){r.photos(t,!0,e)},200))},s.event=function(){s.bigimg.hover(function(){s.imgsee.show()},function(){s.imgsee.hide()}),s.bigimg.find(".layui-layer-imgprev").on("click",function(e){e.preventDefault(),s.imgprev()}),s.bigimg.find(".layui-layer-imgnext").on("click",function(e){e.preventDefault(),s.imgnext()}),i(document).on("keyup",s.keyup)},s.loadi=r.load(1,{shade:!("shade"in t)&&.9,scrollbar:!1}),o(u[d].src,function(n){r.close(s.loadi),s.index=r.open(i.extend({type:1,id:"layui-layer-photos",area:function(){var a=[n.width,n.height],o=[i(e).width()-100,i(e).height()-100];if(!t.full&&(a[0]>o[0]||a[1]>o[1])){var r=[a[0]/o[0],a[1]/o[1]];r[0]>r[1]?(a[0]=a[0]/r[0],a[1]=a[1]/r[0]):r[0]'+(u[d].alt||
        '+(u.length>1?'':"")+'
        '+(u[d].alt||"")+""+s.imgIndex+"/"+u.length+"
        ",success:function(e,i){s.bigimg=e.find(".layui-layer-phimg"),s.imgsee=e.find(".layui-layer-imguide,.layui-layer-imgbar"),s.event(e),t.tab&&t.tab(u[d],e),"function"==typeof y&&y(e)},end:function(){s.end=!0,i(document).off("keyup",s.keyup)}},t))},function(){r.close(s.loadi),r.msg("当前图片地址异常
        是否继续查看下一张?",{time:3e4,btn:["下一张","不看了"],yes:function(){u.length>1&&s.imgnext(!0,!0)}})})}},o.run=function(t){i=t,n=i(e),l.html=i("html"),r.open=function(e){var t=new s(e);return t.index}},e.layui&&layui.define?(r.ready(),layui.define("jquery",function(t){r.path=layui.cache.dir,o.run(layui.jquery),e.layer=r,t("layer",r)})):"function"==typeof define&&define.amd?define(["jquery"],function(){return o.run(e.jQuery),r}):function(){o.run(e.jQuery),r.ready()}()}(window); \ No newline at end of file diff --git a/Public/layui/lay/modules/laypage.js b/Public/layui/lay/modules/laypage.js deleted file mode 100644 index ed2ffa3..0000000 --- a/Public/layui/lay/modules/laypage.js +++ /dev/null @@ -1,2 +0,0 @@ -/** layui-v1.0.9_rls MIT License By http://www.layui.com */ - ;layui.define(function(a){"use strict";function t(a){new p(a)}var e=document,r="getElementById",n="getElementsByTagName",s=0,p=function(a){var t=this,e=t.config=a||{};e.item=s++,t.render(!0)};p.on=function(a,t,e){return a.attachEvent?a.attachEvent("on"+t,function(){e.call(a,window.even)}):a.addEventListener(t,e,!1),p},p.prototype.type=function(){var a=this.config;if("object"==typeof a.cont)return void 0===a.cont.length?2:3},p.prototype.view=function(){var a=this,t=a.config,e=[],r={};if(t.pages=0|t.pages,t.curr=0|t.curr||1,t.groups="groups"in t?0|t.groups:5,t.first="first"in t?t.first:"首页",t.last="last"in t?t.last:"末页",t.prev="prev"in t?t.prev:"上一页",t.next="next"in t?t.next:"下一页",t.pages<=1)return"";for(t.groups>t.pages&&(t.groups=t.pages),r.index=Math.ceil((t.curr+(t.groups>1&&t.groups!==t.pages?1:0))/(0===t.groups?1:t.groups)),t.curr>1&&t.prev&&e.push(''+t.prev+""),r.index>1&&t.first&&0!==t.groups&&e.push(''+t.first+""),r.poor=Math.floor((t.groups-1)/2),r.start=r.index>1?t.curr-r.poor:1,r.end=r.index>1?function(){var a=t.curr+(t.groups-r.poor-1);return a>t.pages?t.pages:a}():t.groups,r.end-r.start"+r.start+""):e.push(''+r.start+"");return t.pages>t.groups&&r.end'+t.last+""),r.flow=!t.prev&&0===t.groups,(t.curr!==t.pages&&t.next||r.flow)&&e.push(function(){return r.flow&&t.curr===t.pages?''+t.next+"":''+t.next+""}()),'
        '+e.join("")+function(){return t.skip?'到第 ':""}()+"
        "},p.prototype.jump=function(a){if(a){for(var t=this,e=t.config,r=a.children,s=a[n]("button")[0],i=a[n]("input")[0],u=0,o=r.length;u/g,">").replace(/'/g,"'").replace(/"/g,""")},error:function(e,r){var n="Laytpl Error:";return"object"==typeof console&&console.error(n+e+"\n"+(r||"")),n+e}},c=n.exp,t=function(e){this.tpl=e};t.pt=t.prototype,window.errors=0,t.pt.parse=function(e,t){var o=this,p=e,a=c("^"+r.open+"#",""),l=c(r.close+"$","");e=e.replace(/\s+|\r|\t|\n/g," ").replace(c(r.open+"#"),r.open+"# ").replace(c(r.close+"}"),"} "+r.close).replace(/\\/g,"\\\\").replace(/(?="|')/g,"\\").replace(n.query(),function(e){return e=e.replace(a,"").replace(l,""),'";'+e.replace(/\\/g,"")+';view+="'}).replace(n.query(1),function(e){var n='"+(';return e.replace(/\s/g,"")===r.open+r.close?"":(e=e.replace(c(r.open+"|"+r.close),""),/^=/.test(e)&&(e=e.replace(/^=/,""),n='"+_escape_('),n+e.replace(/\\/g,"")+')+"')}),e='"use strict";var view = "'+e+'";return view;';try{return o.cache=e=new Function("d, _escape_",e),e(t,n.escape)}catch(u){return delete o.cache,n.error(u,p)}},t.pt.render=function(e,r){var c,t=this;return e?(c=t.cache?t.cache(e,n.escape):t.parse(t.tpl,e),r?void r(c):c):n.error("no data")};var o=function(e){return"string"!=typeof e?n.error("Template not found"):new t(e)};o.config=function(e){e=e||{};for(var n in e)r[n]=e[n]},o.v="1.2.0",e("laytpl",o)}); \ No newline at end of file diff --git a/Public/layui/lay/modules/mobile.js b/Public/layui/lay/modules/mobile.js deleted file mode 100644 index 56e98b6..0000000 --- a/Public/layui/lay/modules/mobile.js +++ /dev/null @@ -1,2 +0,0 @@ -/** layui-v1.0.9_rls MIT License By http://www.layui.com */ - ;layui.define(function(i){i("layui.mobile",layui.v)});layui.define(function(e){"use strict";var r={open:"{{",close:"}}"},n={exp:function(e){return new RegExp(e,"g")},query:function(e,n,t){var o=["#([\\s\\S])+?","([^{#}])*?"][e||0];return c((n||"")+r.open+o+r.close+(t||""))},escape:function(e){return String(e||"").replace(/&(?!#?[a-zA-Z0-9]+;)/g,"&").replace(//g,">").replace(/'/g,"'").replace(/"/g,""")},error:function(e,r){var n="Laytpl Error:";return"object"==typeof console&&console.error(n+e+"\n"+(r||"")),n+e}},c=n.exp,t=function(e){this.tpl=e};t.pt=t.prototype,window.errors=0,t.pt.parse=function(e,t){var o=this,p=e,a=c("^"+r.open+"#",""),l=c(r.close+"$","");e=e.replace(/\s+|\r|\t|\n/g," ").replace(c(r.open+"#"),r.open+"# ").replace(c(r.close+"}"),"} "+r.close).replace(/\\/g,"\\\\").replace(/(?="|')/g,"\\").replace(n.query(),function(e){return e=e.replace(a,"").replace(l,""),'";'+e.replace(/\\/g,"")+';view+="'}).replace(n.query(1),function(e){var n='"+(';return e.replace(/\s/g,"")===r.open+r.close?"":(e=e.replace(c(r.open+"|"+r.close),""),/^=/.test(e)&&(e=e.replace(/^=/,""),n='"+_escape_('),n+e.replace(/\\/g,"")+')+"')}),e='"use strict";var view = "'+e+'";return view;';try{return o.cache=e=new Function("d, _escape_",e),e(t,n.escape)}catch(u){return delete o.cache,n.error(u,p)}},t.pt.render=function(e,r){var c,t=this;return e?(c=t.cache?t.cache(e,n.escape):t.parse(t.tpl,e),r?void r(c):c):n.error("no data")};var o=function(e){return"string"!=typeof e?n.error("Template not found"):new t(e)};o.config=function(e){e=e||{};for(var n in e)r[n]=e[n]},o.v="1.2.0",e("laytpl",o)});layui.define(function(e){"use strict";var t=(window,document),i="querySelectorAll",n="getElementsByClassName",a=function(e){return t[i](e)},s={type:0,shade:!0,shadeClose:!0,fixed:!0,anim:"scale"},l={extend:function(e){var t=JSON.parse(JSON.stringify(s));for(var i in e)t[i]=e[i];return t},timer:{},end:{}};l.touch=function(e,t){e.addEventListener("click",function(e){t.call(this,e)},!1)};var o=0,r=["layui-m-layer"],d=function(e){var t=this;t.config=l.extend(e),t.view()};d.prototype.view=function(){var e=this,i=e.config,s=t.createElement("div");e.id=s.id=r[0]+o,s.setAttribute("class",r[0]+" "+r[0]+(i.type||0)),s.setAttribute("index",o);var l=function(){var e="object"==typeof i.title;return i.title?'

        '+(e?i.title[0]:i.title)+"

        ":""}(),d=function(){"string"==typeof i.btn&&(i.btn=[i.btn]);var e,t=(i.btn||[]).length;return 0!==t&&i.btn?(e=''+i.btn[0]+"",2===t&&(e=''+i.btn[1]+""+e),'
        '+e+"
        "):""}();if(i.fixed||(i.top=i.hasOwnProperty("top")?i.top:100,i.style=i.style||"",i.style+=" top:"+(t.body.scrollTop+i.top)+"px"),2===i.type&&(i.content='

        '+(i.content||"")+"

        "),i.skin&&(i.anim="up"),"msg"===i.skin&&(i.shade=!1),s.innerHTML=(i.shade?"
        ':"")+'
        "+l+'
        '+i.content+"
        "+d+"
        ",!i.type||2===i.type){var y=t[n](r[0]+i.type),u=y.length;u>=1&&c.close(y[0].getAttribute("index"))}document.body.appendChild(s);var m=e.elem=a("#"+e.id)[0];i.success&&i.success(m),e.index=o++,e.action(i,m)},d.prototype.action=function(e,t){var i=this;e.time&&(l.timer[i.index]=setTimeout(function(){c.close(i.index)},1e3*e.time));var a=function(){var t=this.getAttribute("type");0==t?(e.no&&e.no(),c.close(i.index)):e.yes?e.yes(i.index):c.close(i.index)};if(e.btn)for(var s=t[n]("layui-m-layerbtn")[0].children,o=s.length,r=0;r0&&e-1 in t)}function s(t){return A.call(t,function(t){return null!=t})}function u(t){return t.length>0?T.fn.concat.apply([],t):t}function c(t){return t.replace(/::/g,"/").replace(/([A-Z]+)([A-Z][a-z])/g,"$1_$2").replace(/([a-z\d])([A-Z])/g,"$1_$2").replace(/_/g,"-").toLowerCase()}function l(t){return t in F?F[t]:F[t]=new RegExp("(^|\\s)"+t+"(\\s|$)")}function f(t,e){return"number"!=typeof e||k[c(t)]?e:e+"px"}function h(t){var e,n;return $[t]||(e=L.createElement(t),L.body.appendChild(e),n=getComputedStyle(e,"").getPropertyValue("display"),e.parentNode.removeChild(e),"none"==n&&(n="block"),$[t]=n),$[t]}function p(t){return"children"in t?D.call(t.children):T.map(t.childNodes,function(t){if(1==t.nodeType)return t})}function d(t,e){var n,r=t?t.length:0;for(n=0;n]*>/,R=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,z=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,Z=/^(?:body|html)$/i,q=/([A-Z])/g,H=["val","css","html","text","data","width","height","offset"],I=["after","prepend","before","append"],V=L.createElement("table"),_=L.createElement("tr"),B={tr:L.createElement("tbody"),tbody:V,thead:V,tfoot:V,td:_,th:_,"*":L.createElement("div")},U=/complete|loaded|interactive/,X=/^[\w-]*$/,J={},W=J.toString,Y={},G=L.createElement("div"),K={tabindex:"tabIndex",readonly:"readOnly","for":"htmlFor","class":"className",maxlength:"maxLength",cellspacing:"cellSpacing",cellpadding:"cellPadding",rowspan:"rowSpan",colspan:"colSpan",usemap:"useMap",frameborder:"frameBorder",contenteditable:"contentEditable"},Q=Array.isArray||function(t){return t instanceof Array};return Y.matches=function(t,e){if(!e||!t||1!==t.nodeType)return!1;var n=t.matches||t.webkitMatchesSelector||t.mozMatchesSelector||t.oMatchesSelector||t.matchesSelector;if(n)return n.call(t,e);var r,i=t.parentNode,o=!i;return o&&(i=G).appendChild(t),r=~Y.qsa(i,e).indexOf(t),o&&G.removeChild(t),r},C=function(t){return t.replace(/-+(.)?/g,function(t,e){return e?e.toUpperCase():""})},N=function(t){return A.call(t,function(e,n){return t.indexOf(e)==n})},Y.fragment=function(t,e,n){var r,i,a;return R.test(t)&&(r=T(L.createElement(RegExp.$1))),r||(t.replace&&(t=t.replace(z,"<$1>")),e===E&&(e=M.test(t)&&RegExp.$1),e in B||(e="*"),a=B[e],a.innerHTML=""+t,r=T.each(D.call(a.childNodes),function(){a.removeChild(this)})),o(n)&&(i=T(r),T.each(n,function(t,e){H.indexOf(t)>-1?i[t](e):i.attr(t,e)})),r},Y.Z=function(t,e){return new d(t,e)},Y.isZ=function(t){return t instanceof Y.Z},Y.init=function(t,n){var r;if(!t)return Y.Z();if("string"==typeof t)if(t=t.trim(),"<"==t[0]&&M.test(t))r=Y.fragment(t,RegExp.$1,n),t=null;else{if(n!==E)return T(n).find(t);r=Y.qsa(L,t)}else{if(e(t))return T(L).ready(t);if(Y.isZ(t))return t;if(Q(t))r=s(t);else if(i(t))r=[t],t=null;else if(M.test(t))r=Y.fragment(t.trim(),RegExp.$1,n),t=null;else{if(n!==E)return T(n).find(t);r=Y.qsa(L,t)}}return Y.Z(r,t)},T=function(t,e){return Y.init(t,e)},T.extend=function(t){var e,n=D.call(arguments,1);return"boolean"==typeof t&&(e=t,t=n.shift()),n.forEach(function(n){m(t,n,e)}),t},Y.qsa=function(t,e){var n,r="#"==e[0],i=!r&&"."==e[0],o=r||i?e.slice(1):e,a=X.test(o);return t.getElementById&&a&&r?(n=t.getElementById(o))?[n]:[]:1!==t.nodeType&&9!==t.nodeType&&11!==t.nodeType?[]:D.call(a&&!r&&t.getElementsByClassName?i?t.getElementsByClassName(o):t.getElementsByTagName(e):t.querySelectorAll(e))},T.contains=L.documentElement.contains?function(t,e){return t!==e&&t.contains(e)}:function(t,e){for(;e&&(e=e.parentNode);)if(e===t)return!0;return!1},T.type=t,T.isFunction=e,T.isWindow=n,T.isArray=Q,T.isPlainObject=o,T.isEmptyObject=function(t){var e;for(e in t)return!1;return!0},T.isNumeric=function(t){var e=Number(t),n=typeof t;return null!=t&&"boolean"!=n&&("string"!=n||t.length)&&!isNaN(e)&&isFinite(e)||!1},T.inArray=function(t,e,n){return O.indexOf.call(e,t,n)},T.camelCase=C,T.trim=function(t){return null==t?"":String.prototype.trim.call(t)},T.uuid=0,T.support={},T.expr={},T.noop=function(){},T.map=function(t,e){var n,r,i,o=[];if(a(t))for(r=0;r=0?t:t+this.length]},toArray:function(){return this.get()},size:function(){return this.length},remove:function(){return this.each(function(){null!=this.parentNode&&this.parentNode.removeChild(this)})},each:function(t){return O.every.call(this,function(e,n){return t.call(e,n,e)!==!1}),this},filter:function(t){return e(t)?this.not(this.not(t)):T(A.call(this,function(e){return Y.matches(e,t)}))},add:function(t,e){return T(N(this.concat(T(t,e))))},is:function(t){return this.length>0&&Y.matches(this[0],t)},not:function(t){var n=[];if(e(t)&&t.call!==E)this.each(function(e){t.call(this,e)||n.push(this)});else{var r="string"==typeof t?this.filter(t):a(t)&&e(t.item)?D.call(t):T(t);this.forEach(function(t){r.indexOf(t)<0&&n.push(t)})}return T(n)},has:function(t){return this.filter(function(){return i(t)?T.contains(this,t):T(this).find(t).size()})},eq:function(t){return t===-1?this.slice(t):this.slice(t,+t+1)},first:function(){var t=this[0];return t&&!i(t)?t:T(t)},last:function(){var t=this[this.length-1];return t&&!i(t)?t:T(t)},find:function(t){var e,n=this;return e=t?"object"==typeof t?T(t).filter(function(){var t=this;return O.some.call(n,function(e){return T.contains(e,t)})}):1==this.length?T(Y.qsa(this[0],t)):this.map(function(){return Y.qsa(this,t)}):T()},closest:function(t,e){var n=[],i="object"==typeof t&&T(t);return this.each(function(o,a){for(;a&&!(i?i.indexOf(a)>=0:Y.matches(a,t));)a=a!==e&&!r(a)&&a.parentNode;a&&n.indexOf(a)<0&&n.push(a)}),T(n)},parents:function(t){for(var e=[],n=this;n.length>0;)n=T.map(n,function(t){if((t=t.parentNode)&&!r(t)&&e.indexOf(t)<0)return e.push(t),t});return v(e,t)},parent:function(t){return v(N(this.pluck("parentNode")),t)},children:function(t){return v(this.map(function(){return p(this)}),t)},contents:function(){return this.map(function(){return this.contentDocument||D.call(this.childNodes)})},siblings:function(t){return v(this.map(function(t,e){return A.call(p(e.parentNode),function(t){return t!==e})}),t)},empty:function(){return this.each(function(){this.innerHTML=""})},pluck:function(t){return T.map(this,function(e){return e[t]})},show:function(){return this.each(function(){"none"==this.style.display&&(this.style.display=""),"none"==getComputedStyle(this,"").getPropertyValue("display")&&(this.style.display=h(this.nodeName))})},replaceWith:function(t){return this.before(t).remove()},wrap:function(t){var n=e(t);if(this[0]&&!n)var r=T(t).get(0),i=r.parentNode||this.length>1;return this.each(function(e){T(this).wrapAll(n?t.call(this,e):i?r.cloneNode(!0):r)})},wrapAll:function(t){if(this[0]){T(this[0]).before(t=T(t));for(var e;(e=t.children()).length;)t=e.first();T(t).append(this)}return this},wrapInner:function(t){var n=e(t);return this.each(function(e){var r=T(this),i=r.contents(),o=n?t.call(this,e):t;i.length?i.wrapAll(o):r.append(o)})},unwrap:function(){return this.parent().each(function(){T(this).replaceWith(T(this).children())}),this},clone:function(){return this.map(function(){return this.cloneNode(!0)})},hide:function(){return this.css("display","none")},toggle:function(t){return this.each(function(){var e=T(this);(t===E?"none"==e.css("display"):t)?e.show():e.hide()})},prev:function(t){return T(this.pluck("previousElementSibling")).filter(t||"*")},next:function(t){return T(this.pluck("nextElementSibling")).filter(t||"*")},html:function(t){return 0 in arguments?this.each(function(e){var n=this.innerHTML;T(this).empty().append(g(this,t,e,n))}):0 in this?this[0].innerHTML:null},text:function(t){return 0 in arguments?this.each(function(e){var n=g(this,t,e,this.textContent);this.textContent=null==n?"":""+n}):0 in this?this.pluck("textContent").join(""):null},attr:function(t,e){var n;return"string"!=typeof t||1 in arguments?this.each(function(n){if(1===this.nodeType)if(i(t))for(j in t)y(this,j,t[j]);else y(this,t,g(this,e,n,this.getAttribute(t)))}):0 in this&&1==this[0].nodeType&&null!=(n=this[0].getAttribute(t))?n:E},removeAttr:function(t){return this.each(function(){1===this.nodeType&&t.split(" ").forEach(function(t){y(this,t)},this)})},prop:function(t,e){return t=K[t]||t,1 in arguments?this.each(function(n){this[t]=g(this,e,n,this[t])}):this[0]&&this[0][t]},removeProp:function(t){return t=K[t]||t,this.each(function(){delete this[t]})},data:function(t,e){var n="data-"+t.replace(q,"-$1").toLowerCase(),r=1 in arguments?this.attr(n,e):this.attr(n);return null!==r?b(r):E},val:function(t){return 0 in arguments?(null==t&&(t=""),this.each(function(e){this.value=g(this,t,e,this.value)})):this[0]&&(this[0].multiple?T(this[0]).find("option").filter(function(){return this.selected}).pluck("value"):this[0].value)},offset:function(t){if(t)return this.each(function(e){var n=T(this),r=g(this,t,e,n.offset()),i=n.offsetParent().offset(),o={top:r.top-i.top,left:r.left-i.left};"static"==n.css("position")&&(o.position="relative"),n.css(o)});if(!this.length)return null;if(L.documentElement!==this[0]&&!T.contains(L.documentElement,this[0]))return{top:0,left:0};var e=this[0].getBoundingClientRect();return{left:e.left+window.pageXOffset,top:e.top+window.pageYOffset,width:Math.round(e.width),height:Math.round(e.height)}},css:function(e,n){if(arguments.length<2){var r=this[0];if("string"==typeof e){if(!r)return;return r.style[C(e)]||getComputedStyle(r,"").getPropertyValue(e)}if(Q(e)){if(!r)return;var i={},o=getComputedStyle(r,"");return T.each(e,function(t,e){i[e]=r.style[C(e)]||o.getPropertyValue(e)}),i}}var a="";if("string"==t(e))n||0===n?a=c(e)+":"+f(e,n):this.each(function(){this.style.removeProperty(c(e))});else for(j in e)e[j]||0===e[j]?a+=c(j)+":"+f(j,e[j])+";":this.each(function(){this.style.removeProperty(c(j))});return this.each(function(){this.style.cssText+=";"+a})},index:function(t){return t?this.indexOf(T(t)[0]):this.parent().children().indexOf(this[0])},hasClass:function(t){return!!t&&O.some.call(this,function(t){return this.test(x(t))},l(t))},addClass:function(t){return t?this.each(function(e){if("className"in this){S=[];var n=x(this),r=g(this,t,e,n);r.split(/\s+/g).forEach(function(t){T(this).hasClass(t)||S.push(t)},this),S.length&&x(this,n+(n?" ":"")+S.join(" "))}}):this},removeClass:function(t){return this.each(function(e){if("className"in this){if(t===E)return x(this,"");S=x(this),g(this,t,e,S).split(/\s+/g).forEach(function(t){S=S.replace(l(t)," ")}),x(this,S.trim())}})},toggleClass:function(t,e){return t?this.each(function(n){var r=T(this),i=g(this,t,n,x(this));i.split(/\s+/g).forEach(function(t){(e===E?!r.hasClass(t):e)?r.addClass(t):r.removeClass(t)})}):this},scrollTop:function(t){if(this.length){var e="scrollTop"in this[0];return t===E?e?this[0].scrollTop:this[0].pageYOffset:this.each(e?function(){this.scrollTop=t}:function(){this.scrollTo(this.scrollX,t)})}},scrollLeft:function(t){if(this.length){var e="scrollLeft"in this[0];return t===E?e?this[0].scrollLeft:this[0].pageXOffset:this.each(e?function(){this.scrollLeft=t}:function(){this.scrollTo(t,this.scrollY)})}},position:function(){if(this.length){var t=this[0],e=this.offsetParent(),n=this.offset(),r=Z.test(e[0].nodeName)?{top:0,left:0}:e.offset();return n.top-=parseFloat(T(t).css("margin-top"))||0,n.left-=parseFloat(T(t).css("margin-left"))||0,r.top+=parseFloat(T(e[0]).css("border-top-width"))||0,r.left+=parseFloat(T(e[0]).css("border-left-width"))||0,{top:n.top-r.top,left:n.left-r.left}}},offsetParent:function(){return this.map(function(){for(var t=this.offsetParent||L.body;t&&!Z.test(t.nodeName)&&"static"==T(t).css("position");)t=t.offsetParent;return t})}},T.fn.detach=T.fn.remove,["width","height"].forEach(function(t){var e=t.replace(/./,function(t){return t[0].toUpperCase()});T.fn[t]=function(i){var o,a=this[0];return i===E?n(a)?a["inner"+e]:r(a)?a.documentElement["scroll"+e]:(o=this.offset())&&o[t]:this.each(function(e){a=T(this),a.css(t,g(this,i,e,a[t]()))})}}),I.forEach(function(e,n){var r=n%2;T.fn[e]=function(){var e,i,o=T.map(arguments,function(n){var r=[];return e=t(n),"array"==e?(n.forEach(function(t){return t.nodeType!==E?r.push(t):T.zepto.isZ(t)?r=r.concat(t.get()):void(r=r.concat(Y.fragment(t)))}),r):"object"==e||null==n?n:Y.fragment(n)}),a=this.length>1;return o.length<1?this:this.each(function(t,e){i=r?e:e.parentNode,e=0==n?e.nextSibling:1==n?e.firstChild:2==n?e:null;var s=T.contains(L.documentElement,i);o.forEach(function(t){if(a)t=t.cloneNode(!0);else if(!i)return T(t).remove();i.insertBefore(t,e),s&&w(t,function(t){if(!(null==t.nodeName||"SCRIPT"!==t.nodeName.toUpperCase()||t.type&&"text/javascript"!==t.type||t.src)){var e=t.ownerDocument?t.ownerDocument.defaultView:window;e.eval.call(e,t.innerHTML)}})})})},T.fn[r?e+"To":"insert"+(n?"Before":"After")]=function(t){return T(t)[e](this),this}}),Y.Z.prototype=d.prototype=T.fn,Y.uniq=N,Y.deserializeValue=b,T.zepto=Y,T}();!function(t){function e(t){return t._zid||(t._zid=h++)}function n(t,n,o,a){if(n=r(n),n.ns)var s=i(n.ns);return(v[e(t)]||[]).filter(function(t){return t&&(!n.e||t.e==n.e)&&(!n.ns||s.test(t.ns))&&(!o||e(t.fn)===e(o))&&(!a||t.sel==a)})}function r(t){var e=(""+t).split(".");return{e:e[0],ns:e.slice(1).sort().join(" ")}}function i(t){return new RegExp("(?:^| )"+t.replace(" "," .* ?")+"(?: |$)")}function o(t,e){return t.del&&!y&&t.e in x||!!e}function a(t){return b[t]||y&&x[t]||t}function s(n,i,s,u,l,h,p){var d=e(n),m=v[d]||(v[d]=[]);i.split(/\s/).forEach(function(e){if("ready"==e)return t(document).ready(s);var i=r(e);i.fn=s,i.sel=l,i.e in b&&(s=function(e){var n=e.relatedTarget;if(!n||n!==this&&!t.contains(this,n))return i.fn.apply(this,arguments)}),i.del=h;var d=h||s;i.proxy=function(t){if(t=c(t),!t.isImmediatePropagationStopped()){t.data=u;var e=d.apply(n,t._args==f?[t]:[t].concat(t._args));return e===!1&&(t.preventDefault(),t.stopPropagation()),e}},i.i=m.length,m.push(i),"addEventListener"in n&&n.addEventListener(a(i.e),i.proxy,o(i,p))})}function u(t,r,i,s,u){var c=e(t);(r||"").split(/\s/).forEach(function(e){n(t,e,i,s).forEach(function(e){delete v[c][e.i],"removeEventListener"in t&&t.removeEventListener(a(e.e),e.proxy,o(e,u))})})}function c(e,n){return!n&&e.isDefaultPrevented||(n||(n=e),t.each(T,function(t,r){var i=n[t];e[t]=function(){return this[r]=w,i&&i.apply(n,arguments)},e[r]=E}),e.timeStamp||(e.timeStamp=Date.now()),(n.defaultPrevented!==f?n.defaultPrevented:"returnValue"in n?n.returnValue===!1:n.getPreventDefault&&n.getPreventDefault())&&(e.isDefaultPrevented=w)),e}function l(t){var e,n={originalEvent:t};for(e in t)j.test(e)||t[e]===f||(n[e]=t[e]);return c(n,t)}var f,h=1,p=Array.prototype.slice,d=t.isFunction,m=function(t){return"string"==typeof t},v={},g={},y="onfocusin"in window,x={focus:"focusin",blur:"focusout"},b={mouseenter:"mouseover",mouseleave:"mouseout"};g.click=g.mousedown=g.mouseup=g.mousemove="MouseEvents",t.event={add:s,remove:u},t.proxy=function(n,r){var i=2 in arguments&&p.call(arguments,2);if(d(n)){var o=function(){return n.apply(r,i?i.concat(p.call(arguments)):arguments)};return o._zid=e(n),o}if(m(r))return i?(i.unshift(n[r],n),t.proxy.apply(null,i)):t.proxy(n[r],n);throw new TypeError("expected function")},t.fn.bind=function(t,e,n){return this.on(t,e,n)},t.fn.unbind=function(t,e){return this.off(t,e)},t.fn.one=function(t,e,n,r){return this.on(t,e,n,r,1)};var w=function(){return!0},E=function(){return!1},j=/^([A-Z]|returnValue$|layer[XY]$|webkitMovement[XY]$)/,T={preventDefault:"isDefaultPrevented",stopImmediatePropagation:"isImmediatePropagationStopped",stopPropagation:"isPropagationStopped"};t.fn.delegate=function(t,e,n){return this.on(e,t,n)},t.fn.undelegate=function(t,e,n){return this.off(e,t,n)},t.fn.live=function(e,n){return t(document.body).delegate(this.selector,e,n),this},t.fn.die=function(e,n){return t(document.body).undelegate(this.selector,e,n),this},t.fn.on=function(e,n,r,i,o){var a,c,h=this;return e&&!m(e)?(t.each(e,function(t,e){h.on(t,n,r,e,o)}),h):(m(n)||d(i)||i===!1||(i=r,r=n,n=f),i!==f&&r!==!1||(i=r,r=f),i===!1&&(i=E),h.each(function(f,h){o&&(a=function(t){return u(h,t.type,i),i.apply(this,arguments)}),n&&(c=function(e){var r,o=t(e.target).closest(n,h).get(0);if(o&&o!==h)return r=t.extend(l(e),{currentTarget:o,liveFired:h}),(a||i).apply(o,[r].concat(p.call(arguments,1)))}),s(h,e,i,r,n,c||a)}))},t.fn.off=function(e,n,r){var i=this;return e&&!m(e)?(t.each(e,function(t,e){i.off(t,n,e)}),i):(m(n)||d(r)||r===!1||(r=n,n=f),r===!1&&(r=E),i.each(function(){u(this,e,r,n)}))},t.fn.trigger=function(e,n){return e=m(e)||t.isPlainObject(e)?t.Event(e):c(e),e._args=n,this.each(function(){e.type in x&&"function"==typeof this[e.type]?this[e.type]():"dispatchEvent"in this?this.dispatchEvent(e):t(this).triggerHandler(e,n)})},t.fn.triggerHandler=function(e,r){var i,o;return this.each(function(a,s){i=l(m(e)?t.Event(e):e),i._args=r,i.target=s,t.each(n(s,e.type||e),function(t,e){if(o=e.proxy(i),i.isImmediatePropagationStopped())return!1})}),o},"focusin focusout focus blur load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select keydown keypress keyup error".split(" ").forEach(function(e){t.fn[e]=function(t){return 0 in arguments?this.bind(e,t):this.trigger(e)}}),t.Event=function(t,e){m(t)||(e=t,t=e.type);var n=document.createEvent(g[t]||"Events"),r=!0;if(e)for(var i in e)"bubbles"==i?r=!!e[i]:n[i]=e[i];return n.initEvent(t,r,!0),c(n)}}(e),function(t){function e(e,n,r){var i=t.Event(n);return t(e).trigger(i,r),!i.isDefaultPrevented()}function n(t,n,r,i){if(t.global)return e(n||x,r,i)}function r(e){e.global&&0===t.active++&&n(e,null,"ajaxStart")}function i(e){e.global&&!--t.active&&n(e,null,"ajaxStop")}function o(t,e){var r=e.context;return e.beforeSend.call(r,t,e)!==!1&&n(e,r,"ajaxBeforeSend",[t,e])!==!1&&void n(e,r,"ajaxSend",[t,e])}function a(t,e,r,i){var o=r.context,a="success";r.success.call(o,t,a,e),i&&i.resolveWith(o,[t,a,e]),n(r,o,"ajaxSuccess",[e,r,t]),u(a,e,r)}function s(t,e,r,i,o){var a=i.context;i.error.call(a,r,e,t),o&&o.rejectWith(a,[r,e,t]),n(i,a,"ajaxError",[r,i,t||e]),u(e,r,i)}function u(t,e,r){var o=r.context;r.complete.call(o,e,t),n(r,o,"ajaxComplete",[e,r]),i(r)}function c(t,e,n){if(n.dataFilter==l)return t;var r=n.context;return n.dataFilter.call(r,t,e)}function l(){}function f(t){return t&&(t=t.split(";",2)[0]),t&&(t==T?"html":t==j?"json":w.test(t)?"script":E.test(t)&&"xml")||"text"}function h(t,e){return""==e?t:(t+"&"+e).replace(/[&?]{1,2}/,"?")}function p(e){e.processData&&e.data&&"string"!=t.type(e.data)&&(e.data=t.param(e.data,e.traditional)),!e.data||e.type&&"GET"!=e.type.toUpperCase()&&"jsonp"!=e.dataType||(e.url=h(e.url,e.data),e.data=void 0)}function d(e,n,r,i){return t.isFunction(n)&&(i=r,r=n,n=void 0),t.isFunction(r)||(i=r,r=void 0),{url:e,data:n,success:r,dataType:i}}function m(e,n,r,i){var o,a=t.isArray(n),s=t.isPlainObject(n);t.each(n,function(n,u){o=t.type(u),i&&(n=r?i:i+"["+(s||"object"==o||"array"==o?n:"")+"]"),!i&&a?e.add(u.name,u.value):"array"==o||!r&&"object"==o?m(e,u,r,n):e.add(n,u)})}var v,g,y=+new Date,x=window.document,b=/)<[^<]*)*<\/script>/gi,w=/^(?:text|application)\/javascript/i,E=/^(?:text|application)\/xml/i,j="application/json",T="text/html",S=/^\s*$/,C=x.createElement("a");C.href=window.location.href,t.active=0,t.ajaxJSONP=function(e,n){if(!("type"in e))return t.ajax(e);var r,i,u=e.jsonpCallback,c=(t.isFunction(u)?u():u)||"Zepto"+y++,l=x.createElement("script"),f=window[c],h=function(e){t(l).triggerHandler("error",e||"abort")},p={abort:h};return n&&n.promise(p),t(l).on("load error",function(o,u){clearTimeout(i),t(l).off().remove(),"error"!=o.type&&r?a(r[0],p,e,n):s(null,u||"error",p,e,n),window[c]=f,r&&t.isFunction(f)&&f(r[0]),f=r=void 0}),o(p,e)===!1?(h("abort"),p):(window[c]=function(){r=arguments},l.src=e.url.replace(/\?(.+)=\?/,"?$1="+c),x.head.appendChild(l),e.timeout>0&&(i=setTimeout(function(){h("timeout")},e.timeout)),p)},t.ajaxSettings={type:"GET",beforeSend:l,success:l,error:l,complete:l,context:null,global:!0,xhr:function(){return new window.XMLHttpRequest},accepts:{script:"text/javascript, application/javascript, application/x-javascript",json:j,xml:"application/xml, text/xml",html:T,text:"text/plain"},crossDomain:!1,timeout:0,processData:!0,cache:!0,dataFilter:l},t.ajax=function(e){var n,i,u=t.extend({},e||{}),d=t.Deferred&&t.Deferred();for(v in t.ajaxSettings)void 0===u[v]&&(u[v]=t.ajaxSettings[v]);r(u),u.crossDomain||(n=x.createElement("a"),n.href=u.url,n.href=n.href,u.crossDomain=C.protocol+"//"+C.host!=n.protocol+"//"+n.host),u.url||(u.url=window.location.toString()),(i=u.url.indexOf("#"))>-1&&(u.url=u.url.slice(0,i)),p(u);var m=u.dataType,y=/\?.+=\?/.test(u.url);if(y&&(m="jsonp"),u.cache!==!1&&(e&&e.cache===!0||"script"!=m&&"jsonp"!=m)||(u.url=h(u.url,"_="+Date.now())),"jsonp"==m)return y||(u.url=h(u.url,u.jsonp?u.jsonp+"=?":u.jsonp===!1?"":"callback=?")),t.ajaxJSONP(u,d);var b,w=u.accepts[m],E={},j=function(t,e){E[t.toLowerCase()]=[t,e]},T=/^([\w-]+:)\/\//.test(u.url)?RegExp.$1:window.location.protocol,N=u.xhr(),O=N.setRequestHeader;if(d&&d.promise(N),u.crossDomain||j("X-Requested-With","XMLHttpRequest"),j("Accept",w||"*/*"),(w=u.mimeType||w)&&(w.indexOf(",")>-1&&(w=w.split(",",2)[0]),N.overrideMimeType&&N.overrideMimeType(w)),(u.contentType||u.contentType!==!1&&u.data&&"GET"!=u.type.toUpperCase())&&j("Content-Type",u.contentType||"application/x-www-form-urlencoded"),u.headers)for(g in u.headers)j(g,u.headers[g]);if(N.setRequestHeader=j,N.onreadystatechange=function(){if(4==N.readyState){N.onreadystatechange=l,clearTimeout(b);var e,n=!1;if(N.status>=200&&N.status<300||304==N.status||0==N.status&&"file:"==T){if(m=m||f(u.mimeType||N.getResponseHeader("content-type")),"arraybuffer"==N.responseType||"blob"==N.responseType)e=N.response;else{e=N.responseText;try{e=c(e,m,u),"script"==m?(0,eval)(e):"xml"==m?e=N.responseXML:"json"==m&&(e=S.test(e)?null:t.parseJSON(e))}catch(r){n=r}if(n)return s(n,"parsererror",N,u,d)}a(e,N,u,d)}else s(N.statusText||null,N.status?"error":"abort",N,u,d)}},o(N,u)===!1)return N.abort(),s(null,"abort",N,u,d),N;var P=!("async"in u)||u.async;if(N.open(u.type,u.url,P,u.username,u.password),u.xhrFields)for(g in u.xhrFields)N[g]=u.xhrFields[g];for(g in E)O.apply(N,E[g]);return u.timeout>0&&(b=setTimeout(function(){N.onreadystatechange=l,N.abort(),s(null,"timeout",N,u,d)},u.timeout)),N.send(u.data?u.data:null),N},t.get=function(){return t.ajax(d.apply(null,arguments))},t.post=function(){var e=d.apply(null,arguments);return e.type="POST",t.ajax(e)},t.getJSON=function(){var e=d.apply(null,arguments);return e.dataType="json",t.ajax(e)},t.fn.load=function(e,n,r){if(!this.length)return this;var i,o=this,a=e.split(/\s/),s=d(e,n,r),u=s.success;return a.length>1&&(s.url=a[0],i=a[1]),s.success=function(e){o.html(i?t("
        ").html(e.replace(b,"")).find(i):e),u&&u.apply(o,arguments)},t.ajax(s),this};var N=encodeURIComponent;t.param=function(e,n){var r=[];return r.add=function(e,n){t.isFunction(n)&&(n=n()),null==n&&(n=""),this.push(N(e)+"="+N(n))},m(r,e,n),r.join("&").replace(/%20/g,"+")}}(e),function(t){t.fn.serializeArray=function(){var e,n,r=[],i=function(t){return t.forEach?t.forEach(i):void r.push({name:e,value:t})};return this[0]&&t.each(this[0].elements,function(r,o){n=o.type,e=o.name,e&&"fieldset"!=o.nodeName.toLowerCase()&&!o.disabled&&"submit"!=n&&"reset"!=n&&"button"!=n&&"file"!=n&&("radio"!=n&&"checkbox"!=n||o.checked)&&i(t(o).val())}),r},t.fn.serialize=function(){var t=[];return this.serializeArray().forEach(function(e){t.push(encodeURIComponent(e.name)+"="+encodeURIComponent(e.value))}),t.join("&")},t.fn.submit=function(e){if(0 in arguments)this.bind("submit",e);else if(this.length){var n=t.Event("submit");this.eq(0).trigger(n),n.isDefaultPrevented()||this.get(0).submit()}return this}}(e),function(){try{getComputedStyle(void 0)}catch(t){var e=getComputedStyle;window.getComputedStyle=function(t,n){try{return e(t,n)}catch(r){return null}}}}(),t("zepto",e)});layui.define(["layer-mobile","zepto"],function(e){"use strict";var t=layui.zepto,a=layui["layer-mobile"],i=(layui.device(),"layui-upload-enter"),n="layui-upload-iframe",r={icon:2,shift:6},o={file:"文件",video:"视频",audio:"音频"};a.msg=function(e){return a.open({content:e||"",skin:"msg",time:0})};var s=function(e){this.options=e};s.prototype.init=function(){var e=this,a=e.options,r=t("body"),s=t(a.elem||".layui-upload-file"),u=t('');return t("#"+n)[0]||r.append(u),s.each(function(r,s){s=t(s);var u='
        ',l=s.attr("lay-type")||a.type;a.unwrap||(u='
        '+u+''+(s.attr("lay-title")||a.title||"上传"+(o[l]||"图片"))+"
        "),u=t(u),a.unwrap||u.on("dragover",function(e){e.preventDefault(),t(this).addClass(i)}).on("dragleave",function(){t(this).removeClass(i)}).on("drop",function(){t(this).removeClass(i)}),s.parent("form").attr("target")===n&&(a.unwrap?s.unwrap():(s.parent().next().remove(),s.unwrap().unwrap())),s.wrap(u),s.off("change").on("change",function(){e.action(this,l)})})},s.prototype.action=function(e,i){var o=this,s=o.options,u=e.value,l=t(e),p=l.attr("lay-ext")||s.ext||"";if(u){switch(i){case"file":if(p&&!RegExp("\\w\\.("+p+")$","i").test(escape(u)))return a.msg("不支持该文件格式",r),e.value="";break;case"video":if(!RegExp("\\w\\.("+(p||"avi|mp4|wma|rmvb|rm|flash|3gp|flv")+")$","i").test(escape(u)))return a.msg("不支持该视频格式",r),e.value="";break;case"audio":if(!RegExp("\\w\\.("+(p||"mp3|wav|mid")+")$","i").test(escape(u)))return a.msg("不支持该音频格式",r),e.value="";break;default:if(!RegExp("\\w\\.("+(p||"jpg|png|gif|bmp|jpeg")+")$","i").test(escape(u)))return a.msg("不支持该图片格式",r),e.value=""}s.before&&s.before(e),l.parent().submit();var c=t("#"+n),f=setInterval(function(){var t;try{t=c.contents().find("body").text()}catch(i){a.msg("上传接口存在跨域",r),clearInterval(f)}if(t){clearInterval(f),c.contents().find("body").html("");try{t=JSON.parse(t)}catch(i){return t={},a.msg("请对上传接口返回JSON字符",r)}"function"==typeof s.success&&s.success(t,e)}},30);e.value=""}},e("upload-mobile",function(e){var t=new s(e=e||{});t.init()})});layui.define(function(i){i("layim-mobile",layui.v)});layui["layui.mobile"]||layui.config({base:layui.cache.dir+"lay/modules/mobile/"}).extend({"layer-mobile":"layer-mobile",zepto:"zepto","upload-mobile":"upload-mobile","layim-mobile":"layim-mobile"}),layui.define(["layer-mobile","zepto","layim-mobile"],function(l){l("mobile",{layer:layui["layer-mobile"],layim:layui["layim-mobile"]})}); \ No newline at end of file diff --git a/Public/layui/lay/modules/tree.js b/Public/layui/lay/modules/tree.js deleted file mode 100644 index 221c062..0000000 --- a/Public/layui/lay/modules/tree.js +++ /dev/null @@ -1,2 +0,0 @@ -/** layui-v1.0.9_rls MIT License By http://www.layui.com */ - ;layui.define("jquery",function(e){"use strict";var o=layui.jquery,a=layui.hint(),r="layui-tree-enter",i=function(e){this.options=e},t={arrow:["",""],checkbox:["",""],radio:["",""],branch:["",""],leaf:""};i.prototype.init=function(e){var o=this;e.addClass("layui-box layui-tree"),o.options.skin&&e.addClass("layui-tree-skin-"+o.options.skin),o.tree(e),o.on(e)},i.prototype.tree=function(e,a){var r=this,i=r.options,n=a||i.nodes;layui.each(n,function(a,n){var l=n.children&&n.children.length>0,c=o('
          '),s=o(["
        • ",function(){return l?''+(n.spread?t.arrow[1]:t.arrow[0])+"":""}(),function(){return i.check?''+("checkbox"===i.check?t.checkbox[0]:"radio"===i.check?t.radio[0]:"")+"":""}(),function(){return'"+(''+(l?n.spread?t.branch[1]:t.branch[0]:t.leaf)+"")+(""+(n.name||"未命名")+"")}(),"
        • "].join(""));l&&(s.append(c),r.tree(c,n.children)),e.append(s),"function"==typeof i.click&&r.click(s,n),r.spread(s,n),i.drag&&r.drag(s,n)})},i.prototype.click=function(e,o){var a=this,r=a.options;e.children("a").on("click",function(e){layui.stope(e),r.click(o)})},i.prototype.spread=function(e,o){var a=this,r=(a.options,e.children(".layui-tree-spread")),i=e.children("ul"),n=e.children("a"),l=function(){e.data("spread")?(e.data("spread",null),i.removeClass("layui-show"),r.html(t.arrow[0]),n.find(".layui-icon").html(t.branch[0])):(e.data("spread",!0),i.addClass("layui-show"),r.html(t.arrow[1]),n.find(".layui-icon").html(t.branch[1]))};i[0]&&(r.on("click",l),n.on("dblclick",l))},i.prototype.on=function(e){var a=this,i=a.options,t="layui-tree-drag";e.find("i").on("selectstart",function(e){return!1}),i.drag&&o(document).on("mousemove",function(e){var r=a.move;if(r.from){var i=(r.to,o('
          '));e.preventDefault(),o("."+t)[0]||o("body").append(i);var n=o("."+t)[0]?o("."+t):i;n.addClass("layui-show").html(r.from.elem.children("a").html()),n.css({left:e.pageX+10,top:e.pageY+10})}}).on("mouseup",function(){var e=a.move;e.from&&(e.from.elem.children("a").removeClass(r),e.to&&e.to.elem.children("a").removeClass(r),a.move={},o("."+t).remove())})},i.prototype.move={},i.prototype.drag=function(e,a){var i=this,t=(i.options,e.children("a")),n=function(){var t=o(this),n=i.move;n.from&&(n.to={item:a,elem:e},t.addClass(r))};t.on("mousedown",function(){var o=i.move;o.from={item:a,elem:e}}),t.on("mouseenter",n).on("mousemove",n).on("mouseleave",function(){var e=o(this),a=i.move;a.from&&(delete a.to,e.removeClass(r))})},e("tree",function(e){var r=new i(e=e||{}),t=o(e.elem);return t[0]?void r.init(t):a.error("layui.tree 没有找到"+e.elem+"元素")})}); \ No newline at end of file diff --git a/Public/layui/lay/modules/upload.js b/Public/layui/lay/modules/upload.js deleted file mode 100644 index d5b78f9..0000000 --- a/Public/layui/lay/modules/upload.js +++ /dev/null @@ -1,2 +0,0 @@ -/** layui-v1.0.9_rls MIT License By http://www.layui.com */ - ;layui.define("layer",function(e){"use strict";var a=layui.jquery,t=layui.layer,i=(layui.device(),"layui-upload-enter"),n="layui-upload-iframe",r={icon:2,shift:6},o={file:"文件",video:"视频",audio:"音频"},s=function(e){this.options=e};s.prototype.init=function(){var e=this,t=e.options,r=a("body"),s=a(t.elem||".layui-upload-file"),u=a('');return a("#"+n)[0]||r.append(u),s.each(function(r,s){s=a(s);var u='
          ',l=s.attr("lay-type")||t.type;t.unwrap||(u='
          '+u+''+(s.attr("lay-title")||t.title||"上传"+(o[l]||"图片"))+"
          "),u=a(u),t.unwrap||u.on("dragover",function(e){e.preventDefault(),a(this).addClass(i)}).on("dragleave",function(){a(this).removeClass(i)}).on("drop",function(){a(this).removeClass(i)}),s.parent("form").attr("target")===n&&(t.unwrap?s.unwrap():(s.parent().next().remove(),s.unwrap().unwrap())),s.wrap(u),s.off("change").on("change",function(){e.action(this,l)})})},s.prototype.action=function(e,i){var o=this,s=o.options,u=e.value,l=a(e),p=l.attr("lay-ext")||s.ext||"";if(u){switch(i){case"file":if(p&&!RegExp("\\w\\.("+p+")$","i").test(escape(u)))return t.msg("不支持该文件格式",r),e.value="";break;case"video":if(!RegExp("\\w\\.("+(p||"avi|mp4|wma|rmvb|rm|flash|3gp|flv")+")$","i").test(escape(u)))return t.msg("不支持该视频格式",r),e.value="";break;case"audio":if(!RegExp("\\w\\.("+(p||"mp3|wav|mid")+")$","i").test(escape(u)))return t.msg("不支持该音频格式",r),e.value="";break;default:if(!RegExp("\\w\\.("+(p||"jpg|png|gif|bmp|jpeg")+")$","i").test(escape(u)))return t.msg("不支持该图片格式",r),e.value=""}s.before&&s.before(e),l.parent().submit();var c=a("#"+n),f=setInterval(function(){var a;try{a=c.contents().find("body").text()}catch(i){t.msg("上传接口存在跨域",r),clearInterval(f)}if(a){clearInterval(f),c.contents().find("body").html("");try{a=JSON.parse(a)}catch(i){return a={},t.msg("请对上传接口返回JSON字符",r)}"function"==typeof s.success&&s.success(a,e)}},30);e.value=""}},e("upload",function(e){var a=new s(e=e||{});a.init()})}); \ No newline at end of file diff --git a/Public/layui/lay/modules/util.js b/Public/layui/lay/modules/util.js deleted file mode 100644 index 2f6938f..0000000 --- a/Public/layui/lay/modules/util.js +++ /dev/null @@ -1,2 +0,0 @@ -/** layui-v1.0.9_rls MIT License By http://www.layui.com */ - ;layui.define("jquery",function(l){"use strict";var o=layui.jquery,i={fixbar:function(l){l=l||{},l.bgcolor=l.bgcolor?"background-color:"+l.bgcolor:"";var i,a,c="layui-fixbar-top",t=[l.bar1===!0?"":l.bar1,l.bar2===!0?"":l.bar2,""],r=o(['
            ',l.bar1?'
          • '+t[0]+"
          • ":"",l.bar2?'
          • '+t[1]+"
          • ":"",'
          • '+t[2]+"
          • ","
          "].join("")),e=r.find("."+c),s=function(){var i=o(document).scrollTop();i>=(l.showHeight||200)?a||(e.show(),a=1):a&&(e.hide(),a=0)};o(".layui-fixbar")[0]||("object"==typeof l.css&&r.css(l.css),o("body").append(r),s(),r.find("li").on("click",function(){var i=o(this),a=i.attr("lay-type");"top"===a&&o("html,body").animate({scrollTop:0},200),l.click&&l.click.call(this,a)}),o(document).on("scroll",function(){i&&clearTimeout(i),i=setTimeout(function(){s()},100)}))}};l("util",i)}); \ No newline at end of file diff --git a/Public/layui/layui.js b/Public/layui/layui.js deleted file mode 100644 index ed8835f..0000000 --- a/Public/layui/layui.js +++ /dev/null @@ -1,2 +0,0 @@ -/** layui-v1.0.9_rls MIT License By http://www.layui.com */ - ;!function(e){"use strict";var t=function(){this.v="1.0.9_rls"};t.fn=t.prototype;var n=document,o=t.fn.cache={},i=function(){var e=n.scripts,t=e[e.length-1].src;return t.substring(0,t.lastIndexOf("/")+1)}(),r=function(t){e.console&&console.error&&console.error("Layui hint: "+t)},l="undefined"!=typeof opera&&"[object Opera]"===opera.toString(),a={layer:"modules/layer",laydate:"modules/laydate",laypage:"modules/laypage",laytpl:"modules/laytpl",layim:"modules/layim",layedit:"modules/layedit",form:"modules/form",upload:"modules/upload",tree:"modules/tree",table:"modules/table",element:"modules/element",util:"modules/util",flow:"modules/flow",carousel:"modules/carousel",code:"modules/code",jquery:"modules/jquery",mobile:"modules/mobile","layui.all":"dest/layui.all"};o.modules={},o.status={},o.timeout=10,o.event={},t.fn.define=function(e,t){var n=this,i="function"==typeof e,r=function(){return"function"==typeof t&&t(function(e,t){layui[e]=t,o.status[e]=!0}),this};return i&&(t=e,e=[]),layui["layui.all"]||!layui["layui.all"]&&layui["layui.mobile"]?r.call(n):(n.use(e,r),n)},t.fn.use=function(e,t,u){function s(e,t){var n="PLaySTATION 3"===navigator.platform?/^complete$/:/^(complete|loaded)$/;("load"===e.type||n.test((e.currentTarget||e.srcElement).readyState))&&(o.modules[m]=t,y.removeChild(p),function i(){return++v>1e3*o.timeout/4?r(m+" is not a valid module"):void(o.status[m]?c():setTimeout(i,4))}())}function c(){u.push(layui[m]),e.length>1?f.use(e.slice(1),t,u):"function"==typeof t&&t.apply(layui,u)}var f=this,d=o.dir=o.dir?o.dir:i,y=n.getElementsByTagName("head")[0];e="string"==typeof e?[e]:e,window.jQuery&&jQuery.fn.on&&(f.each(e,function(t,n){"jquery"===n&&e.splice(t,1)}),layui.jquery=jQuery);var m=e[0],v=0;if(u=u||[],o.host=o.host||(d.match(/\/\/([\s\S]+?)\//)||["//"+location.host+"/"])[0],0===e.length||layui["layui.all"]&&a[m]||!layui["layui.all"]&&layui["layui.mobile"]&&a[m])return c(),f;var p=n.createElement("script"),h=(a[m]?d+"lay/":o.base||"")+(f.modules[m]||m)+".js";return p.async=!0,p.charset="utf-8",p.src=h+function(){var e=o.version===!0?o.v||(new Date).getTime():o.version||"";return e?"?v="+e:""}(),o.modules[m]?!function g(){return++v>1e3*o.timeout/4?r(m+" is not a valid module"):void("string"==typeof o.modules[m]&&o.status[m]?c():setTimeout(g,4))}():(y.appendChild(p),!p.attachEvent||p.attachEvent.toString&&p.attachEvent.toString().indexOf("[native code")<0||l?p.addEventListener("load",function(e){s(e,h)},!1):p.attachEvent("onreadystatechange",function(e){s(e,h)})),o.modules[m]=h,f},t.fn.getStyle=function(t,n){var o=t.currentStyle?t.currentStyle:e.getComputedStyle(t,null);return o[o.getPropertyValue?"getPropertyValue":"getAttribute"](n)},t.fn.link=function(e,t,i){var l=this,a=n.createElement("link"),u=n.getElementsByTagName("head")[0];"string"==typeof t&&(i=t);var s=(i||e).replace(/\.|\//g,""),c=a.id="layuicss-"+s,f=0;a.rel="stylesheet",a.href=e+(o.debug?"?v="+(new Date).getTime():""),a.media="all",n.getElementById(c)||u.appendChild(a),"function"==typeof t&&!function d(){return++f>1e3*o.timeout/100?r(e+" timeout"):void(1989===parseInt(l.getStyle(n.getElementById(c),"width"))?function(){t()}():setTimeout(d,100))}()},t.fn.addcss=function(e,t,n){layui.link(o.dir+"css/"+e,t,n)},t.fn.img=function(e,t,n){var o=new Image;return o.src=e,o.complete?t(o):(o.onload=function(){o.onload=null,t(o)},void(o.onerror=function(e){o.onerror=null,n(e)}))},t.fn.config=function(e){e=e||{};for(var t in e)o[t]=e[t];return this},t.fn.modules=function(){var e={};for(var t in a)e[t]=a[t];return e}(),t.fn.extend=function(e){var t=this;e=e||{};for(var n in e)t[n]||t.modules[n]?r("模块名 "+n+" 已被占用"):t.modules[n]=e[n];return t},t.fn.router=function(e){for(var t,n=(e||location.hash).replace(/^#/,"").split("/")||[],o={dir:[]},i=0;i 站在巨人的肩膀上,并不是高的表现,反而使自己变得渺小~只有吸收了巨人的营养,茁壮自己才是真正的高大! --笔者 - -## 灵 感 - -首先自我介绍下吧,我是一个PHP程序员,一个刚刚干了两年左右的小菜鸟。我第一份工作是做微信开发的,这也是我入行以来第一次做的商业上线项目,虽然我只是充当了其中一个不是太重要的角色,但是感谢它让我第一次接触了API,也让我第一次对于API产生了浓厚的兴趣。之后的一段时间内甚至疯狂的收集过各种免费的API接口!然而一直只是在用API,却没有为API贡献过些什么。 - -开源框架用了很多,开源代码看了很多,github、git@osc、Stack Overflow这些优秀的平台帮助了我很多,所以,我觉得是时候为开源做点什么。2015年初,我遇到了PhalApi,一个非常有生命力的API项目,是PHP语言写的,当时的它还是一个宝宝,在项目组的细心呵护下茁壮成长,很荣幸的是,我也是项目组成员之一,然而在它的成长中,我输送的营养简直不值一提~也感谢创始人 [@dogstar][1] 对我的信任,一直没有把我踢出项目组。既然API这么火,既然未来的互联网世界中API占了很重要的地位,既然越来越多的人开始开发API,那么无状态的API如何去管理呢?因此**ApiAdmin**来了~ - -## 愿 景 - -> 希望有人用它,希望更多的人用它。 -> 希望它能帮助到你,希望它能帮助到更多的你。 - -## 项目简介 - -**体验地址** - -[https://admin.apiadmin.org/](https://admin.apiadmin.org/) - -注:线上体验项目的账号密码请移步:[http://git.oschina.net/apiadmin/apiadmin-wxpro](http://git.oschina.net/apiadmin/apiadmin-wxpro) 获取微信小程序二维码,扫描二维码获取体验账号! - -**二次开发文档** - -[http://www.w3cschool.cn/apiadmin_v2/](http://www.w3cschool.cn/apiadmin_v2/) - -**源码地址** - -国内OSC:[http://git.oschina.net/apiadmin/ApiAdmin](http://git.oschina.net/apiadmin/ApiAdmin) - -国际GitHub:[https://github.com/Zhao-github/ApiAdmin](https://github.com/Zhao-github/ApiAdmin) - -**下载地址** - -国内OSC:[http://git.oschina.net/apiadmin/ApiAdmin/releases](http://git.oschina.net/apiadmin/ApiAdmin) - -国际GitHub:[https://github.com/Zhao-github/ApiAdmin/releases](https://github.com/Zhao-github/ApiAdmin/releases) - -**项目构成** - -- ThinkPHP v3.2.3 -- LayUI -- semanticUI -- ... - -**功能简介** - - 1. 接口文档自动生成 - 2. 接口输入参数自动检查 - 3. 接口输出参数数据类型自动规整 - 4. 灵活的参数规则设定 - 5. 支持三方Api无缝融合 - 6. 本地二次开发友好 - 7. 使用Datatables完成数据JS加载 - 8. .... - - ``` - ApiAdmin(PHP部分) - ├─ 系统维护 - | ├─ 菜单管理 - 编辑访客权限,处理菜单父子关系,被权限系统依赖(极为重要) - | ├─ 用户管理 - 添加新用户,封号,删号以及给账号分配权限组 - | ├─ 权限管理 - 权限组管理,给权限组添加权限,将用户提出权限组 - | └─ 操作日志 - 记录管理员的操作,用于追责,回溯和备案 - | ... - ``` - -**页面截图** - -![输入图片说明](https://git.oschina.net/uploads/images/2017/0415/221526_c2090391_110856.png "在这里输入图片标题") -![输入图片说明](https://git.oschina.net/uploads/images/2017/0415/221536_be4efd42_110856.png "在这里输入图片标题") -![输入图片说明](https://git.oschina.net/uploads/images/2017/0415/221550_5d92dbdf_110856.png "在这里输入图片标题") -![输入图片说明](https://git.oschina.net/uploads/images/2017/0415/221559_44530e0b_110856.png "在这里输入图片标题") -![输入图片说明](https://git.oschina.net/uploads/images/2017/0415/221609_fd20b776_110856.png "在这里输入图片标题") -![输入图片说明](https://git.oschina.net/uploads/images/2017/0415/221618_bcfd94b5_110856.png "在这里输入图片标题") - -**项目特性** - -- 开放源码 -- 保持生机 -- 不断更新 -- 响应市场 - -**开源,我们在路上!** - -[1]: http://my.oschina.net/dogstar/blog \ No newline at end of file diff --git a/ThinkPHP/Common/functions.php b/ThinkPHP/Common/functions.php deleted file mode 100644 index 417f046..0000000 --- a/ThinkPHP/Common/functions.php +++ /dev/null @@ -1,1550 +0,0 @@ - -// +---------------------------------------------------------------------- - -/** - * Think 系统函数库 - */ - -/** - * 获取和设置配置参数 支持批量定义 - * @param string|array $name 配置变量 - * @param mixed $value 配置值 - * @param mixed $default 默认值 - * @return mixed - */ -function C($name=null, $value=null,$default=null) { - static $_config = array(); - // 无参数时获取所有 - if (empty($name)) { - return $_config; - } - // 优先执行设置获取或赋值 - if (is_string($name)) { - if (!strpos($name, '.')) { - $name = strtoupper($name); - if (is_null($value)) - return isset($_config[$name]) ? $_config[$name] : $default; - $_config[$name] = $value; - return null; - } - // 二维数组设置和获取支持 - $name = explode('.', $name); - $name[0] = strtoupper($name[0]); - if (is_null($value)) - return isset($_config[$name[0]][$name[1]]) ? $_config[$name[0]][$name[1]] : $default; - $_config[$name[0]][$name[1]] = $value; - return null; - } - // 批量设置 - if (is_array($name)){ - $_config = array_merge($_config, array_change_key_case($name,CASE_UPPER)); - return null; - } - return null; // 避免非法参数 -} - -/** - * 加载配置文件 支持格式转换 仅支持一级配置 - * @param string $file 配置文件名 - * @param string $parse 配置解析方法 有些格式需要用户自己解析 - * @return array - */ -function load_config($file,$parse=CONF_PARSE){ - $ext = pathinfo($file,PATHINFO_EXTENSION); - switch($ext){ - case 'php': - return include $file; - case 'ini': - return parse_ini_file($file); - case 'yaml': - return yaml_parse_file($file); - case 'xml': - return (array)simplexml_load_file($file); - case 'json': - return json_decode(file_get_contents($file), true); - default: - if(function_exists($parse)){ - return $parse($file); - }else{ - E(L('_NOT_SUPPORT_').':'.$ext); - } - } -} - -/** - * 解析yaml文件返回一个数组 - * @param string $file 配置文件名 - * @return array - */ -if (!function_exists('yaml_parse_file')) { - function yaml_parse_file($file) { - vendor('spyc.Spyc'); - return Spyc::YAMLLoad($file); - } -} - -/** - * 抛出异常处理 - * @param string $msg 异常消息 - * @param integer $code 异常代码 默认为0 - * @throws Think\Exception - * @return void - */ -function E($msg, $code=0) { - throw new Think\Exception($msg, $code); -} - -/** - * 记录和统计时间(微秒)和内存使用情况 - * 使用方法: - * - * G('begin'); // 记录开始标记位 - * // ... 区间运行代码 - * G('end'); // 记录结束标签位 - * echo G('begin','end',6); // 统计区间运行时间 精确到小数后6位 - * echo G('begin','end','m'); // 统计区间内存使用情况 - * 如果end标记位没有定义,则会自动以当前作为标记位 - * 其中统计内存使用需要 MEMORY_LIMIT_ON 常量为true才有效 - * - * @param string $start 开始标签 - * @param string $end 结束标签 - * @param integer|string $dec 小数位或者m - * @return mixed - */ -function G($start,$end='',$dec=4) { - static $_info = array(); - static $_mem = array(); - if(is_float($end)) { // 记录时间 - $_info[$start] = $end; - }elseif(!empty($end)){ // 统计时间和内存使用 - if(!isset($_info[$end])) $_info[$end] = microtime(TRUE); - if(MEMORY_LIMIT_ON && $dec=='m'){ - if(!isset($_mem[$end])) $_mem[$end] = memory_get_usage(); - return number_format(($_mem[$end]-$_mem[$start])/1024); - }else{ - return number_format(($_info[$end]-$_info[$start]),$dec); - } - - }else{ // 记录时间和内存使用 - $_info[$start] = microtime(TRUE); - if(MEMORY_LIMIT_ON) $_mem[$start] = memory_get_usage(); - } - return null; -} - -/** - * 获取和设置语言定义(不区分大小写) - * @param string|array $name 语言变量 - * @param mixed $value 语言值或者变量 - * @return mixed - */ -function L($name=null, $value=null) { - static $_lang = array(); - // 空参数返回所有定义 - if (empty($name)) - return $_lang; - // 判断语言获取(或设置) - // 若不存在,直接返回全大写$name - if (is_string($name)) { - $name = strtoupper($name); - if (is_null($value)){ - return isset($_lang[$name]) ? $_lang[$name] : $name; - }elseif(is_array($value)){ - // 支持变量 - $replace = array_keys($value); - foreach($replace as &$v){ - $v = '{$'.$v.'}'; - } - return str_replace($replace,$value,isset($_lang[$name]) ? $_lang[$name] : $name); - } - $_lang[$name] = $value; // 语言定义 - return null; - } - // 批量定义 - if (is_array($name)) - $_lang = array_merge($_lang, array_change_key_case($name, CASE_UPPER)); - return null; -} - -/** - * 添加和获取页面Trace记录 - * @param string $value 变量 - * @param string $label 标签 - * @param string $level 日志级别 - * @param boolean $record 是否记录日志 - * @return void|array - */ -function trace($value='[think]',$label='',$level='DEBUG',$record=false) { - return Think\Think::trace($value,$label,$level,$record); -} - -/** - * 编译文件 - * @param string $filename 文件名 - * @return string - */ -function compile($filename) { - $content = php_strip_whitespace($filename); - $content = trim(substr($content, 5)); - // 替换预编译指令 - $content = preg_replace('/\/\/\[RUNTIME\](.*?)\/\/\[\/RUNTIME\]/s', '', $content); - if(0===strpos($content,'namespace')){ - $content = preg_replace('/namespace\s(.*?);/','namespace \\1{',$content,1); - }else{ - $content = 'namespace {'.$content; - } - if ('?>' == substr($content, -2)) - $content = substr($content, 0, -2); - return $content.'}'; -} - -/** - * 获取模版文件 格式 资源://模块@主题/控制器/操作 - * @param string $template 模版资源地址 - * @param string $layer 视图层(目录)名称 - * @return string - */ -function T($template='',$layer=''){ - - // 解析模版资源地址 - if(false === strpos($template,'://')){ - $template = 'http://'.str_replace(':', '/',$template); - } - $info = parse_url($template); - $file = $info['host'].(isset($info['path'])?$info['path']:''); - $module = isset($info['user'])?$info['user'].'/':MODULE_NAME.'/'; - $extend = $info['scheme']; - $layer = $layer?$layer:C('DEFAULT_V_LAYER'); - - // 获取当前主题的模版路径 - $auto = C('AUTOLOAD_NAMESPACE'); - if($auto && isset($auto[$extend])){ // 扩展资源 - $baseUrl = $auto[$extend].$module.$layer.'/'; - }elseif(C('VIEW_PATH')){ - // 改变模块视图目录 - $baseUrl = C('VIEW_PATH'); - }elseif(defined('TMPL_PATH')){ - // 指定全局视图目录 - $baseUrl = TMPL_PATH.$module; - }else{ - $baseUrl = APP_PATH.$module.$layer.'/'; - } - - // 获取主题 - $theme = substr_count($file,'/')<2 ? C('DEFAULT_THEME') : ''; - - // 分析模板文件规则 - $depr = C('TMPL_FILE_DEPR'); - if('' == $file) { - // 如果模板文件名为空 按照默认规则定位 - $file = CONTROLLER_NAME . $depr . ACTION_NAME; - }elseif(false === strpos($file, '/')){ - $file = CONTROLLER_NAME . $depr . $file; - }elseif('/' != $depr){ - $file = substr_count($file,'/')>1 ? substr_replace($file,$depr,strrpos($file,'/'),1) : str_replace('/', $depr, $file); - } - return $baseUrl.($theme?$theme.'/':'').$file.C('TMPL_TEMPLATE_SUFFIX'); -} - -/** - * 获取输入参数 支持过滤和默认值 - * 使用方法: - * - * I('id',0); 获取id参数 自动判断get或者post - * I('post.name','','htmlspecialchars'); 获取$_POST['name'] - * I('get.'); 获取$_GET - * - * @param string $name 变量的名称 支持指定类型 - * @param mixed $default 不存在的时候默认值 - * @param mixed $filter 参数过滤方法 - * @param mixed $datas 要获取的额外数据源 - * @return mixed - */ -function I($name,$default='',$filter=null,$datas=null) { - static $_PUT = null; - if(strpos($name,'/')){ // 指定修饰符 - list($name,$type) = explode('/',$name,2); - }elseif(C('VAR_AUTO_STRING')){ // 默认强制转换为字符串 - $type = 's'; - } - if(strpos($name,'.')) { // 指定参数来源 - list($method,$name) = explode('.',$name,2); - }else{ // 默认为自动判断 - $method = 'param'; - } - switch(strtolower($method)) { - case 'get' : - $input =& $_GET; - break; - case 'post' : - $input =& $_POST; - break; - case 'put' : - if(is_null($_PUT)){ - parse_str(file_get_contents('php://input'), $_PUT); - } - $input = $_PUT; - break; - case 'param' : - switch($_SERVER['REQUEST_METHOD']) { - case 'POST': - $input = $_POST; - break; - case 'PUT': - if(is_null($_PUT)){ - parse_str(file_get_contents('php://input'), $_PUT); - } - $input = $_PUT; - break; - default: - $input = $_GET; - } - break; - case 'path' : - $input = array(); - if(!empty($_SERVER['PATH_INFO'])){ - $depr = C('URL_PATHINFO_DEPR'); - $input = explode($depr,trim($_SERVER['PATH_INFO'],$depr)); - } - break; - case 'request' : - $input =& $_REQUEST; - break; - case 'session' : - $input =& $_SESSION; - break; - case 'cookie' : - $input =& $_COOKIE; - break; - case 'server' : - $input =& $_SERVER; - break; - case 'globals' : - $input =& $GLOBALS; - break; - case 'data' : - $input =& $datas; - break; - default: - return null; - } - if(''==$name) { // 获取全部变量 - $data = $input; - $filters = isset($filter)?$filter:C('DEFAULT_FILTER'); - if($filters) { - if(is_string($filters)){ - $filters = explode(',',$filters); - } - foreach($filters as $filter){ - $data = array_map_recursive($filter,$data); // 参数过滤 - } - } - }elseif(isset($input[$name])) { // 取值操作 - $data = $input[$name]; - $filters = isset($filter)?$filter:C('DEFAULT_FILTER'); - if($filters) { - if(is_string($filters)){ - if(0 === strpos($filters,'/')){ - if(1 !== preg_match($filters,(string)$data)){ - // 支持正则验证 - return isset($default) ? $default : null; - } - }else{ - $filters = explode(',',$filters); - } - }elseif(is_int($filters)){ - $filters = array($filters); - } - - if(is_array($filters)){ - foreach($filters as $filter){ - if(function_exists($filter)) { - $data = is_array($data) ? array_map_recursive($filter,$data) : $filter($data); // 参数过滤 - }else{ - $data = filter_var($data,is_int($filter) ? $filter : filter_id($filter)); - if(false === $data) { - return isset($default) ? $default : null; - } - } - } - } - } - if(!empty($type)){ - switch(strtolower($type)){ - case 'a': // 数组 - $data = (array)$data; - break; - case 'd': // 数字 - $data = (int)$data; - break; - case 'f': // 浮点 - $data = (float)$data; - break; - case 'b': // 布尔 - $data = (boolean)$data; - break; - case 's': // 字符串 - default: - $data = (string)$data; - } - } - }else{ // 变量默认值 - $data = isset($default)?$default:null; - } - is_array($data) && array_walk_recursive($data,'think_filter'); - return $data; -} - -function array_map_recursive($filter, $data) { - $result = array(); - foreach ($data as $key => $val) { - $result[$key] = is_array($val) - ? array_map_recursive($filter, $val) - : call_user_func($filter, $val); - } - return $result; - } - -/** - * 设置和获取统计数据 - * 使用方法: - * - * N('db',1); // 记录数据库操作次数 - * N('read',1); // 记录读取次数 - * echo N('db'); // 获取当前页面数据库的所有操作次数 - * echo N('read'); // 获取当前页面读取次数 - * - * @param string $key 标识位置 - * @param integer $step 步进值 - * @param boolean $save 是否保存结果 - * @return mixed - */ -function N($key, $step=0,$save=false) { - static $_num = array(); - if (!isset($_num[$key])) { - $_num[$key] = (false !== $save)? S('N_'.$key) : 0; - } - if (empty($step)){ - return $_num[$key]; - }else{ - $_num[$key] = $_num[$key] + (int)$step; - } - if(false !== $save){ // 保存结果 - S('N_'.$key,$_num[$key],$save); - } - return null; -} - -/** - * 字符串命名风格转换 - * type 0 将Java风格转换为C的风格 1 将C风格转换为Java的风格 - * @param string $name 字符串 - * @param integer $type 转换类型 - * @return string - */ -function parse_name($name, $type=0) { - if ($type) { - return ucfirst(preg_replace_callback('/_([a-zA-Z])/', function($match){return strtoupper($match[1]);}, $name)); - } else { - return strtolower(trim(preg_replace("/[A-Z]/", "_\\0", $name), "_")); - } -} - -/** - * 优化的require_once - * @param string $filename 文件地址 - * @return boolean - */ -function require_cache($filename) { - static $_importFiles = array(); - if (!isset($_importFiles[$filename])) { - if (file_exists_case($filename)) { - require $filename; - $_importFiles[$filename] = true; - } else { - $_importFiles[$filename] = false; - } - } - return $_importFiles[$filename]; -} - -/** - * 区分大小写的文件存在判断 - * @param string $filename 文件地址 - * @return boolean - */ -function file_exists_case($filename) { - if (is_file($filename)) { - if (IS_WIN && APP_DEBUG) { - if (basename(realpath($filename)) != basename($filename)) - return false; - } - return true; - } - return false; -} - -/** - * 导入所需的类库 同java的Import 本函数有缓存功能 - * @param string $class 类库命名空间字符串 - * @param string $baseUrl 起始路径 - * @param string $ext 导入的文件扩展名 - * @return boolean - */ -function import($class, $baseUrl = '', $ext=EXT) { - static $_file = array(); - $class = str_replace(array('.', '#'), array('/', '.'), $class); - if (isset($_file[$class . $baseUrl])) - return true; - else - $_file[$class . $baseUrl] = true; - $class_strut = explode('/', $class); - if (empty($baseUrl)) { - if ('@' == $class_strut[0] || MODULE_NAME == $class_strut[0]) { - //加载当前模块的类库 - $baseUrl = MODULE_PATH; - $class = substr_replace($class, '', 0, strlen($class_strut[0]) + 1); - }elseif ('Common' == $class_strut[0]) { - //加载公共模块的类库 - $baseUrl = COMMON_PATH; - $class = substr($class, 7); - }elseif (in_array($class_strut[0],array('Think','Org','Behavior','Com','Vendor')) || is_dir(LIB_PATH.$class_strut[0])) { - // 系统类库包和第三方类库包 - $baseUrl = LIB_PATH; - }else { // 加载其他模块的类库 - $baseUrl = APP_PATH; - } - } - if (substr($baseUrl, -1) != '/') - $baseUrl .= '/'; - $classfile = $baseUrl . $class . $ext; - if (!class_exists(basename($class),false)) { - // 如果类不存在 则导入类库文件 - return require_cache($classfile); - } - return null; -} - -/** - * 基于命名空间方式导入函数库 - * load('@.Util.Array') - * @param string $name 函数库命名空间字符串 - * @param string $baseUrl 起始路径 - * @param string $ext 导入的文件扩展名 - * @return void - */ -function load($name, $baseUrl='', $ext='.php') { - $name = str_replace(array('.', '#'), array('/', '.'), $name); - if (empty($baseUrl)) { - if (0 === strpos($name, '@/')) {//加载当前模块函数库 - $baseUrl = MODULE_PATH.'Common/'; - $name = substr($name, 2); - } else { //加载其他模块函数库 - $array = explode('/', $name); - $baseUrl = APP_PATH . array_shift($array).'/Common/'; - $name = implode('/',$array); - } - } - if (substr($baseUrl, -1) != '/') - $baseUrl .= '/'; - require_cache($baseUrl . $name . $ext); -} - -/** - * 快速导入第三方框架类库 所有第三方框架的类库文件统一放到 系统的Vendor目录下面 - * @param string $class 类库 - * @param string $baseUrl 基础目录 - * @param string $ext 类库后缀 - * @return boolean - */ -function vendor($class, $baseUrl = '', $ext='.php') { - if (empty($baseUrl)) - $baseUrl = VENDOR_PATH; - return import($class, $baseUrl, $ext); -} - -/** - * 实例化模型类 格式 [资源://][模块/]模型 - * @param string $name 资源地址 - * @param string $layer 模型层名称 - * @return Think\Model - */ -function D($name='',$layer='') { - if(empty($name)) return new Think\Model; - static $_model = array(); - $layer = $layer? : C('DEFAULT_M_LAYER'); - if(isset($_model[$name.$layer])) - return $_model[$name.$layer]; - $class = parse_res_name($name,$layer); - if(class_exists($class)) { - $model = new $class(basename($name)); - }elseif(false === strpos($name,'/')){ - // 自动加载公共模块下面的模型 - if(!C('APP_USE_NAMESPACE')){ - import('Common/'.$layer.'/'.$class); - }else{ - $class = '\\Common\\'.$layer.'\\'.$name.$layer; - } - $model = class_exists($class)? new $class($name) : new Think\Model($name); - }else { - Think\Log::record('D方法实例化没找到模型类'.$class,Think\Log::NOTICE); - $model = new Think\Model(basename($name)); - } - $_model[$name.$layer] = $model; - return $model; -} - -/** - * 实例化一个没有模型文件的Model - * @param string $name Model名称 支持指定基础模型 例如 MongoModel:User - * @param string $tablePrefix 表前缀 - * @param mixed $connection 数据库连接信息 - * @return Think\Model - */ -function M($name='', $tablePrefix='',$connection='') { - static $_model = array(); - if(strpos($name,':')) { - list($class,$name) = explode(':',$name); - }else{ - $class = 'Think\\Model'; - } - $guid = (is_array($connection)?implode('',$connection):$connection).$tablePrefix . $name . '_' . $class; - if (!isset($_model[$guid])) - $_model[$guid] = new $class($name,$tablePrefix,$connection); - return $_model[$guid]; -} - -/** - * 解析资源地址并导入类库文件 - * 例如 module/controller addon://module/behavior - * @param string $name 资源地址 格式:[扩展://][模块/]资源名 - * @param string $layer 分层名称 - * @param integer $level 控制器层次 - * @return string - */ -function parse_res_name($name,$layer,$level=1){ - if(strpos($name,'://')) {// 指定扩展资源 - list($extend,$name) = explode('://',$name); - }else{ - $extend = ''; - } - if(strpos($name,'/') && substr_count($name, '/')>=$level){ // 指定模块 - list($module,$name) = explode('/',$name,2); - }else{ - $module = defined('MODULE_NAME') ? MODULE_NAME : '' ; - } - $array = explode('/',$name); - if(!C('APP_USE_NAMESPACE')){ - $class = parse_name($name, 1); - import($module.'/'.$layer.'/'.$class.$layer); - }else{ - $class = $module.'\\'.$layer; - foreach($array as $name){ - $class .= '\\'.parse_name($name, 1); - } - // 导入资源类库 - if($extend){ // 扩展资源 - $class = $extend.'\\'.$class; - } - } - return $class.$layer; -} - -/** - * 用于实例化访问控制器 - * @param string $name 控制器名 - * @param string $path 控制器命名空间(路径) - * @return Think\Controller|false - */ -function controller($name,$path=''){ - $layer = C('DEFAULT_C_LAYER'); - if(!C('APP_USE_NAMESPACE')){ - $class = parse_name($name, 1).$layer; - import(MODULE_NAME.'/'.$layer.'/'.$class); - }else{ - $class = ( $path ? basename(ADDON_PATH).'\\'.$path : MODULE_NAME ).'\\'.$layer; - $array = explode('/',$name); - foreach($array as $name){ - $class .= '\\'.parse_name($name, 1); - } - $class .= $layer; - } - if(class_exists($class)) { - return new $class(); - }else { - return false; - } -} - -/** - * 实例化多层控制器 格式:[资源://][模块/]控制器 - * @param string $name 资源地址 - * @param string $layer 控制层名称 - * @param integer $level 控制器层次 - * @return Think\Controller|false - */ -function A($name,$layer='',$level=0) { - static $_action = array(); - $layer = $layer? : C('DEFAULT_C_LAYER'); - $level = $level? : ($layer == C('DEFAULT_C_LAYER')?C('CONTROLLER_LEVEL'):1); - if(isset($_action[$name.$layer])) - return $_action[$name.$layer]; - - $class = parse_res_name($name,$layer,$level); - if(class_exists($class)) { - $action = new $class(); - $_action[$name.$layer] = $action; - return $action; - }else { - return false; - } -} - - -/** - * 远程调用控制器的操作方法 URL 参数格式 [资源://][模块/]控制器/操作 - * @param string $url 调用地址 - * @param string|array $vars 调用参数 支持字符串和数组 - * @param string $layer 要调用的控制层名称 - * @return mixed - */ -function R($url,$vars=array(),$layer='') { - $info = pathinfo($url); - $action = $info['basename']; - $module = $info['dirname']; - $class = A($module,$layer); - if($class){ - if(is_string($vars)) { - parse_str($vars,$vars); - } - return call_user_func_array(array(&$class,$action.C('ACTION_SUFFIX')),$vars); - }else{ - return false; - } -} - -/** - * 处理标签扩展 - * @param string $tag 标签名称 - * @param mixed $params 传入参数 - * @return void - */ -function tag($tag, &$params=NULL) { - \Think\Hook::listen($tag,$params); -} - -/** - * 执行某个行为 - * @param string $name 行为名称 - * @param string $tag 标签名称(行为类无需传入) - * @param Mixed $params 传入的参数 - * @return void - */ -function B($name, $tag='',&$params=NULL) { - if(''==$tag){ - $name .= 'Behavior'; - } - return \Think\Hook::exec($name,$tag,$params); -} - -/** - * 去除代码中的空白和注释 - * @param string $content 代码内容 - * @return string - */ -function strip_whitespace($content) { - $stripStr = ''; - //分析php源码 - $tokens = token_get_all($content); - $last_space = false; - for ($i = 0, $j = count($tokens); $i < $j; $i++) { - if (is_string($tokens[$i])) { - $last_space = false; - $stripStr .= $tokens[$i]; - } else { - switch ($tokens[$i][0]) { - //过滤各种PHP注释 - case T_COMMENT: - case T_DOC_COMMENT: - break; - //过滤空格 - case T_WHITESPACE: - if (!$last_space) { - $stripStr .= ' '; - $last_space = true; - } - break; - case T_START_HEREDOC: - $stripStr .= "<<'; - } else { - $output = $label . print_r($var, true); - } - } else { - ob_start(); - var_dump($var); - $output = ob_get_clean(); - if (!extension_loaded('xdebug')) { - $output = preg_replace('/\]\=\>\n(\s+)/m', '] => ', $output); - $output = '
          ' . $label . htmlspecialchars($output, ENT_QUOTES) . '
          '; - } - } - if ($echo) { - echo($output); - return null; - }else - return $output; -} - -/** - * 设置当前页面的布局 - * @param string|false $layout 布局名称 为false的时候表示关闭布局 - * @return void - */ -function layout($layout) { - if(false !== $layout) { - // 开启布局 - C('LAYOUT_ON',true); - if(is_string($layout)) { // 设置新的布局模板 - C('LAYOUT_NAME',$layout); - } - }else{// 临时关闭布局 - C('LAYOUT_ON',false); - } -} - -/** - * URL组装 支持不同URL模式 - * @param string $url URL表达式,格式:'[模块/控制器/操作#锚点@域名]?参数1=值1&参数2=值2...' - * @param string|array $vars 传入的参数,支持数组和字符串 - * @param string|boolean $suffix 伪静态后缀,默认为true表示获取配置值 - * @param boolean $domain 是否显示域名 - * @return string - */ -function U($url='',$vars='',$suffix=true,$domain=false) { - // 解析URL - $info = parse_url($url); - $url = !empty($info['path'])?$info['path']:ACTION_NAME; - if(isset($info['fragment'])) { // 解析锚点 - $anchor = $info['fragment']; - if(false !== strpos($anchor,'?')) { // 解析参数 - list($anchor,$info['query']) = explode('?',$anchor,2); - } - if(false !== strpos($anchor,'@')) { // 解析域名 - list($anchor,$host) = explode('@',$anchor, 2); - } - }elseif(false !== strpos($url,'@')) { // 解析域名 - list($url,$host) = explode('@',$info['path'], 2); - } - // 解析子域名 - if(isset($host)) { - $domain = $host.(strpos($host,'.')?'':strstr($_SERVER['HTTP_HOST'],'.')); - }elseif($domain===true){ - $domain = $_SERVER['HTTP_HOST']; - if(C('APP_SUB_DOMAIN_DEPLOY') ) { // 开启子域名部署 - $domain = $domain=='localhost'?'localhost':'www'.strstr($_SERVER['HTTP_HOST'],'.'); - // '子域名'=>array('模块[/控制器]'); - foreach (C('APP_SUB_DOMAIN_RULES') as $key => $rule) { - $rule = is_array($rule)?$rule[0]:$rule; - if(false === strpos($key,'*') && 0=== strpos($url,$rule)) { - $domain = $key.strstr($domain,'.'); // 生成对应子域名 - $url = substr_replace($url,'',0,strlen($rule)); - break; - } - } - } - } - - // 解析参数 - if(is_string($vars)) { // aaa=1&bbb=2 转换成数组 - parse_str($vars,$vars); - }elseif(!is_array($vars)){ - $vars = array(); - } - if(isset($info['query'])) { // 解析地址里面参数 合并到vars - parse_str($info['query'],$params); - $vars = array_merge($params,$vars); - } - - // URL组装 - $depr = C('URL_PATHINFO_DEPR'); - $urlCase = C('URL_CASE_INSENSITIVE'); - if($url) { - if(0=== strpos($url,'/')) {// 定义路由 - $route = true; - $url = substr($url,1); - if('/' != $depr) { - $url = str_replace('/',$depr,$url); - } - }else{ - if('/' != $depr) { // 安全替换 - $url = str_replace('/',$depr,$url); - } - // 解析模块、控制器和操作 - $url = trim($url,$depr); - $path = explode($depr,$url); - $var = array(); - $varModule = C('VAR_MODULE'); - $varController = C('VAR_CONTROLLER'); - $varAction = C('VAR_ACTION'); - $var[$varAction] = !empty($path)?array_pop($path):ACTION_NAME; - $var[$varController] = !empty($path)?array_pop($path):CONTROLLER_NAME; - if($maps = C('URL_ACTION_MAP')) { - if(isset($maps[strtolower($var[$varController])])) { - $maps = $maps[strtolower($var[$varController])]; - if($action = array_search(strtolower($var[$varAction]),$maps)){ - $var[$varAction] = $action; - } - } - } - if($maps = C('URL_CONTROLLER_MAP')) { - if($controller = array_search(strtolower($var[$varController]),$maps)){ - $var[$varController] = $controller; - } - } - if($urlCase) { - $var[$varController] = parse_name($var[$varController]); - } - $module = ''; - - if(!empty($path)) { - $var[$varModule] = implode($depr,$path); - }else{ - if(C('MULTI_MODULE')) { - if(MODULE_NAME != C('DEFAULT_MODULE') || !C('MODULE_ALLOW_LIST')){ - $var[$varModule]= MODULE_NAME; - } - } - } - if($maps = C('URL_MODULE_MAP')) { - if($_module = array_search(strtolower($var[$varModule]),$maps)){ - $var[$varModule] = $_module; - } - } - if(isset($var[$varModule])){ - $module = $var[$varModule]; - unset($var[$varModule]); - } - - } - } - - if(C('URL_MODEL') == 0) { // 普通模式URL转换 - $url = __APP__.'?'.C('VAR_MODULE')."={$module}&".http_build_query(array_reverse($var)); - if($urlCase){ - $url = strtolower($url); - } - if(!empty($vars)) { - $vars = http_build_query($vars); - $url .= '&'.$vars; - } - }else{ // PATHINFO模式或者兼容URL模式 - if(isset($route)) { - $url = __APP__.'/'.rtrim($url,$depr); - }else{ - $module = (defined('BIND_MODULE') && BIND_MODULE==$module )? '' : $module; - $url = __APP__.'/'.($module?$module.MODULE_PATHINFO_DEPR:'').implode($depr,array_reverse($var)); - } - if($urlCase){ - $url = strtolower($url); - } - if(!empty($vars)) { // 添加参数 - foreach ($vars as $var => $val){ - if('' !== trim($val)) $url .= $depr . $var . $depr . urlencode($val); - } - } - if($suffix) { - $suffix = $suffix===true?C('URL_HTML_SUFFIX'):$suffix; - if($pos = strpos($suffix, '|')){ - $suffix = substr($suffix, 0, $pos); - } - if($suffix && '/' != substr($url,-1)){ - $url .= '.'.ltrim($suffix,'.'); - } - } - } - if(isset($anchor)){ - $url .= '#'.$anchor; - } - if($domain) { - $url = (is_ssl()?'https://':'http://').$domain.$url; - } - return $url; -} - -/** - * 渲染输出Widget - * @param string $name Widget名称 - * @param array $data 传入的参数 - * @return void - */ -function W($name, $data=array()) { - return R($name,$data,'Widget'); -} - -/** - * 判断是否SSL协议 - * @return boolean - */ -function is_ssl() { - if(isset($_SERVER['HTTPS']) && ('1' == $_SERVER['HTTPS'] || 'on' == strtolower($_SERVER['HTTPS']))){ - return true; - }elseif(isset($_SERVER['SERVER_PORT']) && ('443' == $_SERVER['SERVER_PORT'] )) { - return true; - } - return false; -} - -/** - * URL重定向 - * @param string $url 重定向的URL地址 - * @param integer $time 重定向的等待时间(秒) - * @param string $msg 重定向前的提示信息 - * @return void - */ -function redirect($url, $time=0, $msg='') { - //多行URL地址支持 - $url = str_replace(array("\n", "\r"), '', $url); - if (empty($msg)) - $msg = "系统将在{$time}秒之后自动跳转到{$url}!"; - if (!headers_sent()) { - // redirect - if (0 === $time) { - header('Location: ' . $url); - } else { - header("refresh:{$time};url={$url}"); - echo($msg); - } - exit(); - } else { - $str = ""; - if ($time != 0) - $str .= $msg; - exit($str); - } -} - -/** - * 缓存管理 - * @param mixed $name 缓存名称,如果为数组表示进行缓存设置 - * @param mixed $value 缓存值 - * @param mixed $options 缓存参数 - * @return mixed - */ -function S($name,$value='',$options=null) { - static $cache = ''; - if(is_array($options)){ - // 缓存操作的同时初始化 - $type = isset($options['type'])?$options['type']:''; - $cache = Think\Cache::getInstance($type,$options); - }elseif(is_array($name)) { // 缓存初始化 - $type = isset($name['type'])?$name['type']:''; - $cache = Think\Cache::getInstance($type,$name); - return $cache; - }elseif(empty($cache)) { // 自动初始化 - $cache = Think\Cache::getInstance(); - } - if(''=== $value){ // 获取缓存 - return $cache->get($name); - }elseif(is_null($value)) { // 删除缓存 - return $cache->rm($name); - }else { // 缓存数据 - if(is_array($options)) { - $expire = isset($options['expire'])?$options['expire']:NULL; - }else{ - $expire = is_numeric($options)?$options:NULL; - } - return $cache->set($name, $value, $expire); - } -} - -/** - * 快速文件数据读取和保存 针对简单类型数据 字符串、数组 - * @param string $name 缓存名称 - * @param mixed $value 缓存值 - * @param string $path 缓存路径 - * @return mixed - */ -function F($name, $value='', $path=DATA_PATH) { - static $_cache = array(); - $filename = $path . $name . '.php'; - if ('' !== $value) { - if (is_null($value)) { - // 删除缓存 - if(false !== strpos($name,'*')){ - return false; // TODO - }else{ - unset($_cache[$name]); - return Think\Storage::unlink($filename,'F'); - } - } else { - Think\Storage::put($filename,serialize($value),'F'); - // 缓存数据 - $_cache[$name] = $value; - return null; - } - } - // 获取缓存数据 - if (isset($_cache[$name])) - return $_cache[$name]; - if (Think\Storage::has($filename,'F')){ - $value = unserialize(Think\Storage::read($filename,'F')); - $_cache[$name] = $value; - } else { - $value = false; - } - return $value; -} - -/** - * 根据PHP各种类型变量生成唯一标识号 - * @param mixed $mix 变量 - * @return string - */ -function to_guid_string($mix) { - if (is_object($mix)) { - return spl_object_hash($mix); - } elseif (is_resource($mix)) { - $mix = get_resource_type($mix) . strval($mix); - } else { - $mix = serialize($mix); - } - return md5($mix); -} - -/** - * XML编码 - * @param mixed $data 数据 - * @param string $root 根节点名 - * @param string $item 数字索引的子节点名 - * @param string $attr 根节点属性 - * @param string $id 数字索引子节点key转换的属性名 - * @param string $encoding 数据编码 - * @return string - */ -function xml_encode($data, $root='think', $item='item', $attr='', $id='id', $encoding='utf-8') { - if(is_array($attr)){ - $_attr = array(); - foreach ($attr as $key => $value) { - $_attr[] = "{$key}=\"{$value}\""; - } - $attr = implode(' ', $_attr); - } - $attr = trim($attr); - $attr = empty($attr) ? '' : " {$attr}"; - $xml = ""; - $xml .= "<{$root}{$attr}>"; - $xml .= data_to_xml($data, $item, $id); - $xml .= ""; - return $xml; -} - -/** - * 数据XML编码 - * @param mixed $data 数据 - * @param string $item 数字索引时的节点名称 - * @param string $id 数字索引key转换为的属性名 - * @return string - */ -function data_to_xml($data, $item='item', $id='id') { - $xml = $attr = ''; - foreach ($data as $key => $val) { - if(is_numeric($key)){ - $id && $attr = " {$id}=\"{$key}\""; - $key = $item; - } - $xml .= "<{$key}{$attr}>"; - $xml .= (is_array($val) || is_object($val)) ? data_to_xml($val, $item, $id) : $val; - $xml .= ""; - } - return $xml; -} - -/** - * session管理函数 - * @param string|array $name session名称 如果为数组则表示进行session设置 - * @param mixed $value session值 - * @return mixed - */ -function session($name='',$value='') { - $prefix = C('SESSION_PREFIX'); - if(is_array($name)) { // session初始化 在session_start 之前调用 - if(isset($name['prefix'])) C('SESSION_PREFIX',$name['prefix']); - if(C('VAR_SESSION_ID') && isset($_REQUEST[C('VAR_SESSION_ID')])){ - session_id($_REQUEST[C('VAR_SESSION_ID')]); - }elseif(isset($name['id'])) { - session_id($name['id']); - } - if('common' == APP_MODE){ // 其它模式可能不支持 - ini_set('session.auto_start', 0); - } - if(isset($name['name'])) session_name($name['name']); - if(isset($name['path'])) session_save_path($name['path']); - if(isset($name['domain'])) ini_set('session.cookie_domain', $name['domain']); - if(isset($name['expire'])) { - ini_set('session.gc_maxlifetime', $name['expire']); - ini_set('session.cookie_lifetime', $name['expire']); - } - if(isset($name['use_trans_sid'])) ini_set('session.use_trans_sid', $name['use_trans_sid']?1:0); - if(isset($name['use_cookies'])) ini_set('session.use_cookies', $name['use_cookies']?1:0); - if(isset($name['cache_limiter'])) session_cache_limiter($name['cache_limiter']); - if(isset($name['cache_expire'])) session_cache_expire($name['cache_expire']); - if(isset($name['type'])) C('SESSION_TYPE',$name['type']); - if(C('SESSION_TYPE')) { // 读取session驱动 - $type = C('SESSION_TYPE'); - $class = strpos($type,'\\')? $type : 'Think\\Session\\Driver\\'. ucwords(strtolower($type)); - $hander = new $class(); - session_set_save_handler( - array(&$hander,"open"), - array(&$hander,"close"), - array(&$hander,"read"), - array(&$hander,"write"), - array(&$hander,"destroy"), - array(&$hander,"gc")); - } - // 启动session - if(C('SESSION_AUTO_START')) session_start(); - }elseif('' === $value){ - if(''===$name){ - // 获取全部的session - return $prefix ? $_SESSION[$prefix] : $_SESSION; - }elseif(0===strpos($name,'[')) { // session 操作 - if('[pause]'==$name){ // 暂停session - session_write_close(); - }elseif('[start]'==$name){ // 启动session - session_start(); - }elseif('[destroy]'==$name){ // 销毁session - $_SESSION = array(); - session_unset(); - session_destroy(); - }elseif('[regenerate]'==$name){ // 重新生成id - session_regenerate_id(); - } - }elseif(0===strpos($name,'?')){ // 检查session - $name = substr($name,1); - if(strpos($name,'.')){ // 支持数组 - list($name1,$name2) = explode('.',$name); - return $prefix?isset($_SESSION[$prefix][$name1][$name2]):isset($_SESSION[$name1][$name2]); - }else{ - return $prefix?isset($_SESSION[$prefix][$name]):isset($_SESSION[$name]); - } - }elseif(is_null($name)){ // 清空session - if($prefix) { - unset($_SESSION[$prefix]); - }else{ - $_SESSION = array(); - } - }elseif($prefix){ // 获取session - if(strpos($name,'.')){ - list($name1,$name2) = explode('.',$name); - return isset($_SESSION[$prefix][$name1][$name2])?$_SESSION[$prefix][$name1][$name2]:null; - }else{ - return isset($_SESSION[$prefix][$name])?$_SESSION[$prefix][$name]:null; - } - }else{ - if(strpos($name,'.')){ - list($name1,$name2) = explode('.',$name); - return isset($_SESSION[$name1][$name2])?$_SESSION[$name1][$name2]:null; - }else{ - return isset($_SESSION[$name])?$_SESSION[$name]:null; - } - } - }elseif(is_null($value)){ // 删除session - if(strpos($name,'.')){ - list($name1,$name2) = explode('.',$name); - if($prefix){ - unset($_SESSION[$prefix][$name1][$name2]); - }else{ - unset($_SESSION[$name1][$name2]); - } - }else{ - if($prefix){ - unset($_SESSION[$prefix][$name]); - }else{ - unset($_SESSION[$name]); - } - } - }else{ // 设置session - if(strpos($name,'.')){ - list($name1,$name2) = explode('.',$name); - if($prefix){ - $_SESSION[$prefix][$name1][$name2] = $value; - }else{ - $_SESSION[$name1][$name2] = $value; - } - }else{ - if($prefix){ - $_SESSION[$prefix][$name] = $value; - }else{ - $_SESSION[$name] = $value; - } - } - } - return null; -} - -/** - * Cookie 设置、获取、删除 - * @param string $name cookie名称 - * @param mixed $value cookie值 - * @param mixed $option cookie参数 - * @return mixed - */ -function cookie($name='', $value='', $option=null) { - // 默认设置 - $config = array( - 'prefix' => C('COOKIE_PREFIX'), // cookie 名称前缀 - 'expire' => C('COOKIE_EXPIRE'), // cookie 保存时间 - 'path' => C('COOKIE_PATH'), // cookie 保存路径 - 'domain' => C('COOKIE_DOMAIN'), // cookie 有效域名 - 'secure' => C('COOKIE_SECURE'), // cookie 启用安全传输 - 'httponly' => C('COOKIE_HTTPONLY'), // httponly设置 - ); - // 参数设置(会覆盖黙认设置) - if (!is_null($option)) { - if (is_numeric($option)) - $option = array('expire' => $option); - elseif (is_string($option)) - parse_str($option, $option); - $config = array_merge($config, array_change_key_case($option)); - } - if(!empty($config['httponly'])){ - ini_set("session.cookie_httponly", 1); - } - // 清除指定前缀的所有cookie - if (is_null($name)) { - if (empty($_COOKIE)) - return null; - // 要删除的cookie前缀,不指定则删除config设置的指定前缀 - $prefix = empty($value) ? $config['prefix'] : $value; - if (!empty($prefix)) {// 如果前缀为空字符串将不作处理直接返回 - foreach ($_COOKIE as $key => $val) { - if (0 === stripos($key, $prefix)) { - setcookie($key, '', time() - 3600, $config['path'], $config['domain'],$config['secure'],$config['httponly']); - unset($_COOKIE[$key]); - } - } - } - return null; - }elseif('' === $name){ - // 获取全部的cookie - return $_COOKIE; - } - $name = $config['prefix'] . str_replace('.', '_', $name); - if ('' === $value) { - if(isset($_COOKIE[$name])){ - $value = $_COOKIE[$name]; - if(0===strpos($value,'think:')){ - $value = substr($value,6); - return array_map('urldecode',json_decode(MAGIC_QUOTES_GPC?stripslashes($value):$value,true)); - }else{ - return $value; - } - }else{ - return null; - } - } else { - if (is_null($value)) { - setcookie($name, '', time() - 3600, $config['path'], $config['domain'],$config['secure'],$config['httponly']); - unset($_COOKIE[$name]); // 删除指定cookie - } else { - // 设置cookie - if(is_array($value)){ - $value = 'think:'.json_encode(array_map('urlencode',$value)); - } - $expire = !empty($config['expire']) ? time() + intval($config['expire']) : 0; - setcookie($name, $value, $expire, $config['path'], $config['domain'],$config['secure'],$config['httponly']); - $_COOKIE[$name] = $value; - } - } - return null; -} - -/** - * 加载动态扩展文件 - * @var string $path 文件路径 - * @return void - */ -function load_ext_file($path) { - // 加载自定义外部文件 - if($files = C('LOAD_EXT_FILE')) { - $files = explode(',',$files); - foreach ($files as $file){ - $file = $path.'Common/'.$file.'.php'; - if(is_file($file)) include $file; - } - } - // 加载自定义的动态配置文件 - if($configs = C('LOAD_EXT_CONFIG')) { - if(is_string($configs)) $configs = explode(',',$configs); - foreach ($configs as $key=>$config){ - $file = is_file($config)? $config : $path.'Conf/'.$config.CONF_EXT; - if(is_file($file)) { - is_numeric($key)?C(load_config($file)):C($key,load_config($file)); - } - } - } -} - -/** - * 获取客户端IP地址 - * @param integer $type 返回类型 0 返回IP地址 1 返回IPV4地址数字 - * @param boolean $adv 是否进行高级模式获取(有可能被伪装) - * @return mixed - */ -function get_client_ip($type = 0,$adv=false) { - $type = $type ? 1 : 0; - static $ip = NULL; - if ($ip !== NULL) return $ip[$type]; - if($adv){ - if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) { - $arr = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']); - $pos = array_search('unknown',$arr); - if(false !== $pos) unset($arr[$pos]); - $ip = trim($arr[0]); - }elseif (isset($_SERVER['HTTP_CLIENT_IP'])) { - $ip = $_SERVER['HTTP_CLIENT_IP']; - }elseif (isset($_SERVER['REMOTE_ADDR'])) { - $ip = $_SERVER['REMOTE_ADDR']; - } - }elseif (isset($_SERVER['REMOTE_ADDR'])) { - $ip = $_SERVER['REMOTE_ADDR']; - } - // IP地址合法验证 - $long = sprintf("%u",ip2long($ip)); - $ip = $long ? array($ip, $long) : array('0.0.0.0', 0); - return $ip[$type]; -} - -/** - * 发送HTTP状态 - * @param integer $code 状态码 - * @return void - */ -function send_http_status($code) { - static $_status = array( - // Informational 1xx - 100 => 'Continue', - 101 => 'Switching Protocols', - // Success 2xx - 200 => 'OK', - 201 => 'Created', - 202 => 'Accepted', - 203 => 'Non-Authoritative Information', - 204 => 'No Content', - 205 => 'Reset Content', - 206 => 'Partial Content', - // Redirection 3xx - 300 => 'Multiple Choices', - 301 => 'Moved Permanently', - 302 => 'Moved Temporarily ', // 1.1 - 303 => 'See Other', - 304 => 'Not Modified', - 305 => 'Use Proxy', - // 306 is deprecated but reserved - 307 => 'Temporary Redirect', - // Client Error 4xx - 400 => 'Bad Request', - 401 => 'Unauthorized', - 402 => 'Payment Required', - 403 => 'Forbidden', - 404 => 'Not Found', - 405 => 'Method Not Allowed', - 406 => 'Not Acceptable', - 407 => 'Proxy Authentication Required', - 408 => 'Request Timeout', - 409 => 'Conflict', - 410 => 'Gone', - 411 => 'Length Required', - 412 => 'Precondition Failed', - 413 => 'Request Entity Too Large', - 414 => 'Request-URI Too Long', - 415 => 'Unsupported Media Type', - 416 => 'Requested Range Not Satisfiable', - 417 => 'Expectation Failed', - // Server Error 5xx - 500 => 'Internal Server Error', - 501 => 'Not Implemented', - 502 => 'Bad Gateway', - 503 => 'Service Unavailable', - 504 => 'Gateway Timeout', - 505 => 'HTTP Version Not Supported', - 509 => 'Bandwidth Limit Exceeded' - ); - if(isset($_status[$code])) { - header('HTTP/1.1 '.$code.' '.$_status[$code]); - // 确保FastCGI模式下正常 - header('Status:'.$code.' '.$_status[$code]); - } -} - -function think_filter(&$value){ - // TODO 其他安全过滤 - - // 过滤查询特殊字符 - if(preg_match('/^(EXP|NEQ|GT|EGT|LT|ELT|OR|XOR|LIKE|NOTLIKE|NOT BETWEEN|NOTBETWEEN|BETWEEN|NOTIN|NOT IN|IN)$/i',$value)){ - $value .= ' '; - } -} - -// 不区分大小写的in_array实现 -function in_array_case($value,$array){ - return in_array(strtolower($value),array_map('strtolower',$array)); -} diff --git a/ThinkPHP/Conf/convention.php b/ThinkPHP/Conf/convention.php deleted file mode 100644 index 4061933..0000000 --- a/ThinkPHP/Conf/convention.php +++ /dev/null @@ -1,167 +0,0 @@ - -// +---------------------------------------------------------------------- - -/** - * ThinkPHP惯例配置文件 - * 该文件请不要修改,如果要覆盖惯例配置的值,可在应用配置文件中设定和惯例不符的配置项 - * 配置名称大小写任意,系统会统一转换成小写 - * 所有配置参数都可以在生效前动态改变 - */ -defined('THINK_PATH') or exit(); -return array( - /* 应用设定 */ - 'APP_USE_NAMESPACE' => true, // 应用类库是否使用命名空间 - 'APP_SUB_DOMAIN_DEPLOY' => false, // 是否开启子域名部署 - 'APP_SUB_DOMAIN_RULES' => array(), // 子域名部署规则 - 'APP_DOMAIN_SUFFIX' => '', // 域名后缀 如果是com.cn net.cn 之类的后缀必须设置 - 'ACTION_SUFFIX' => '', // 操作方法后缀 - 'MULTI_MODULE' => true, // 是否允许多模块 如果为false 则必须设置 DEFAULT_MODULE - 'MODULE_DENY_LIST' => array('Common','Runtime'), - 'CONTROLLER_LEVEL' => 1, - 'APP_AUTOLOAD_LAYER' => 'Controller,Model', // 自动加载的应用类库层 关闭APP_USE_NAMESPACE后有效 - 'APP_AUTOLOAD_PATH' => '', // 自动加载的路径 关闭APP_USE_NAMESPACE后有效 - - /* Cookie设置 */ - 'COOKIE_EXPIRE' => 0, // Cookie有效期 - 'COOKIE_DOMAIN' => '', // Cookie有效域名 - 'COOKIE_PATH' => '/', // Cookie路径 - 'COOKIE_PREFIX' => '', // Cookie前缀 避免冲突 - 'COOKIE_SECURE' => false, // Cookie安全传输 - 'COOKIE_HTTPONLY' => '', // Cookie httponly设置 - - /* 默认设定 */ - 'DEFAULT_M_LAYER' => 'Model', // 默认的模型层名称 - 'DEFAULT_C_LAYER' => 'Controller', // 默认的控制器层名称 - 'DEFAULT_V_LAYER' => 'View', // 默认的视图层名称 - 'DEFAULT_LANG' => 'zh-cn', // 默认语言 - 'DEFAULT_THEME' => '', // 默认模板主题名称 - 'DEFAULT_MODULE' => 'Home', // 默认模块 - 'DEFAULT_CONTROLLER' => 'Index', // 默认控制器名称 - 'DEFAULT_ACTION' => 'index', // 默认操作名称 - 'DEFAULT_CHARSET' => 'utf-8', // 默认输出编码 - 'DEFAULT_TIMEZONE' => 'PRC', // 默认时区 - 'DEFAULT_AJAX_RETURN' => 'JSON', // 默认AJAX 数据返回格式,可选JSON XML ... - 'DEFAULT_JSONP_HANDLER' => 'jsonpReturn', // 默认JSONP格式返回的处理方法 - 'DEFAULT_FILTER' => 'htmlspecialchars', // 默认参数过滤方法 用于I函数... - - /* 数据库设置 */ - 'DB_TYPE' => '', // 数据库类型 - 'DB_HOST' => '', // 服务器地址 - 'DB_NAME' => '', // 数据库名 - 'DB_USER' => '', // 用户名 - 'DB_PWD' => '', // 密码 - 'DB_PORT' => '', // 端口 - 'DB_PREFIX' => '', // 数据库表前缀 - 'DB_PARAMS' => array(), // 数据库连接参数 - 'DB_DEBUG' => TRUE, // 数据库调试模式 开启后可以记录SQL日志 - 'DB_FIELDS_CACHE' => true, // 启用字段缓存 - 'DB_CHARSET' => 'utf8', // 数据库编码默认采用utf8 - 'DB_DEPLOY_TYPE' => 0, // 数据库部署方式:0 集中式(单一服务器),1 分布式(主从服务器) - 'DB_RW_SEPARATE' => false, // 数据库读写是否分离 主从式有效 - 'DB_MASTER_NUM' => 1, // 读写分离后 主服务器数量 - 'DB_SLAVE_NO' => '', // 指定从服务器序号 - - /* 数据缓存设置 */ - 'DATA_CACHE_TIME' => 0, // 数据缓存有效期 0表示永久缓存 - 'DATA_CACHE_COMPRESS' => false, // 数据缓存是否压缩缓存 - 'DATA_CACHE_CHECK' => false, // 数据缓存是否校验缓存 - 'DATA_CACHE_PREFIX' => '', // 缓存前缀 - 'DATA_CACHE_TYPE' => 'File', // 数据缓存类型,支持:File|Db|Apc|Memcache|Shmop|Sqlite|Xcache|Apachenote|Eaccelerator - 'DATA_CACHE_PATH' => TEMP_PATH,// 缓存路径设置 (仅对File方式缓存有效) - 'DATA_CACHE_KEY' => '', // 缓存文件KEY (仅对File方式缓存有效) - 'DATA_CACHE_SUBDIR' => false, // 使用子目录缓存 (自动根据缓存标识的哈希创建子目录) - 'DATA_PATH_LEVEL' => 1, // 子目录缓存级别 - - /* 错误设置 */ - 'ERROR_MESSAGE' => '页面错误!请稍后再试~',//错误显示信息,非调试模式有效 - 'ERROR_PAGE' => '', // 错误定向页面 - 'SHOW_ERROR_MSG' => false, // 显示错误信息 - 'TRACE_MAX_RECORD' => 100, // 每个级别的错误信息 最大记录数 - - /* 日志设置 */ - 'LOG_RECORD' => false, // 默认不记录日志 - 'LOG_TYPE' => 'File', // 日志记录类型 默认为文件方式 - 'LOG_LEVEL' => 'EMERG,ALERT,CRIT,ERR',// 允许记录的日志级别 - 'LOG_FILE_SIZE' => 2097152, // 日志文件大小限制 - 'LOG_EXCEPTION_RECORD' => false, // 是否记录异常信息日志 - - /* SESSION设置 */ - 'SESSION_AUTO_START' => true, // 是否自动开启Session - 'SESSION_OPTIONS' => array(), // session 配置数组 支持type name id path expire domain 等参数 - 'SESSION_TYPE' => '', // session hander类型 默认无需设置 除非扩展了session hander驱动 - 'SESSION_PREFIX' => '', // session 前缀 - //'VAR_SESSION_ID' => 'session_id', //sessionID的提交变量 - - /* 模板引擎设置 */ - 'TMPL_CONTENT_TYPE' => 'text/html', // 默认模板输出类型 - 'TMPL_ACTION_ERROR' => THINK_PATH.'Tpl/dispatch_jump.tpl', // 默认错误跳转对应的模板文件 - 'TMPL_ACTION_SUCCESS' => THINK_PATH.'Tpl/dispatch_jump.tpl', // 默认成功跳转对应的模板文件 - 'TMPL_EXCEPTION_FILE' => THINK_PATH.'Tpl/think_exception.tpl',// 异常页面的模板文件 - 'TMPL_DETECT_THEME' => false, // 自动侦测模板主题 - 'TMPL_TEMPLATE_SUFFIX' => '.html', // 默认模板文件后缀 - 'TMPL_FILE_DEPR' => '/', //模板文件CONTROLLER_NAME与ACTION_NAME之间的分割符 - // 布局设置 - 'TMPL_ENGINE_TYPE' => 'Think', // 默认模板引擎 以下设置仅对使用Think模板引擎有效 - 'TMPL_CACHFILE_SUFFIX' => '.php', // 默认模板缓存后缀 - 'TMPL_DENY_FUNC_LIST' => 'echo,exit', // 模板引擎禁用函数 - 'TMPL_DENY_PHP' => false, // 默认模板引擎是否禁用PHP原生代码 - 'TMPL_L_DELIM' => '{', // 模板引擎普通标签开始标记 - 'TMPL_R_DELIM' => '}', // 模板引擎普通标签结束标记 - 'TMPL_VAR_IDENTIFY' => 'array', // 模板变量识别。留空自动判断,参数为'obj'则表示对象 - 'TMPL_STRIP_SPACE' => true, // 是否去除模板文件里面的html空格与换行 - 'TMPL_CACHE_ON' => true, // 是否开启模板编译缓存,设为false则每次都会重新编译 - 'TMPL_CACHE_PREFIX' => '', // 模板缓存前缀标识,可以动态改变 - 'TMPL_CACHE_TIME' => 0, // 模板缓存有效期 0 为永久,(以数字为值,单位:秒) - 'TMPL_LAYOUT_ITEM' => '{__CONTENT__}', // 布局模板的内容替换标识 - 'LAYOUT_ON' => false, // 是否启用布局 - 'LAYOUT_NAME' => 'layout', // 当前布局名称 默认为layout - - // Think模板引擎标签库相关设定 - 'TAGLIB_BEGIN' => '<', // 标签库标签开始标记 - 'TAGLIB_END' => '>', // 标签库标签结束标记 - 'TAGLIB_LOAD' => true, // 是否使用内置标签库之外的其它标签库,默认自动检测 - 'TAGLIB_BUILD_IN' => 'cx', // 内置标签库名称(标签使用不必指定标签库名称),以逗号分隔 注意解析顺序 - 'TAGLIB_PRE_LOAD' => '', // 需要额外加载的标签库(须指定标签库名称),多个以逗号分隔 - - /* URL设置 */ - 'URL_CASE_INSENSITIVE' => true, // 默认false 表示URL区分大小写 true则表示不区分大小写 - 'URL_MODEL' => 1, // URL访问模式,可选参数0、1、2、3,代表以下四种模式: - // 0 (普通模式); 1 (PATHINFO 模式); 2 (REWRITE 模式); 3 (兼容模式) 默认为PATHINFO 模式 - 'URL_PATHINFO_DEPR' => '/', // PATHINFO模式下,各参数之间的分割符号 - 'URL_PATHINFO_FETCH' => 'ORIG_PATH_INFO,REDIRECT_PATH_INFO,REDIRECT_URL', // 用于兼容判断PATH_INFO 参数的SERVER替代变量列表 - 'URL_REQUEST_URI' => 'REQUEST_URI', // 获取当前页面地址的系统变量 默认为REQUEST_URI - 'URL_HTML_SUFFIX' => 'html', // URL伪静态后缀设置 - 'URL_DENY_SUFFIX' => 'ico|png|gif|jpg', // URL禁止访问的后缀设置 - 'URL_PARAMS_BIND' => true, // URL变量绑定到Action方法参数 - 'URL_PARAMS_BIND_TYPE' => 0, // URL变量绑定的类型 0 按变量名绑定 1 按变量顺序绑定 - 'URL_PARAMS_FILTER' => false, // URL变量绑定过滤 - 'URL_PARAMS_FILTER_TYPE'=> '', // URL变量绑定过滤方法 如果为空 调用DEFAULT_FILTER - 'URL_ROUTER_ON' => false, // 是否开启URL路由 - 'URL_ROUTE_RULES' => array(), // 默认路由规则 针对模块 - 'URL_MAP_RULES' => array(), // URL映射定义规则 - - /* 系统变量名称设置 */ - 'VAR_MODULE' => 'm', // 默认模块获取变量 - 'VAR_ADDON' => 'addon', // 默认的插件控制器命名空间变量 - 'VAR_CONTROLLER' => 'c', // 默认控制器获取变量 - 'VAR_ACTION' => 'a', // 默认操作获取变量 - 'VAR_AJAX_SUBMIT' => 'ajax', // 默认的AJAX提交变量 - 'VAR_JSONP_HANDLER' => 'callback', - 'VAR_PATHINFO' => 's', // 兼容模式PATHINFO获取变量例如 ?s=/module/action/id/1 后面的参数取决于URL_PATHINFO_DEPR - 'VAR_TEMPLATE' => 't', // 默认模板切换变量 - 'VAR_AUTO_STRING' => false, // 输入变量是否自动强制转换为字符串 如果开启则数组变量需要手动传入变量修饰符获取变量 - - 'HTTP_CACHE_CONTROL' => 'private', // 网页缓存控制 - 'CHECK_APP_DIR' => true, // 是否检查应用目录是否创建 - 'FILE_UPLOAD_TYPE' => 'Local', // 文件上传方式 - 'DATA_CRYPT_TYPE' => 'Think', // 数据加密方式 - -); diff --git a/ThinkPHP/Conf/debug.php b/ThinkPHP/Conf/debug.php deleted file mode 100644 index 06674b9..0000000 --- a/ThinkPHP/Conf/debug.php +++ /dev/null @@ -1,27 +0,0 @@ - -// +---------------------------------------------------------------------- - -/** - * ThinkPHP 默认的调试模式配置文件 - */ -defined('THINK_PATH') or exit(); -// 调试模式下面默认设置 可以在应用配置目录下重新定义 debug.php 覆盖 -return array( - 'LOG_RECORD' => true, // 进行日志记录 - 'LOG_EXCEPTION_RECORD' => true, // 是否记录异常信息日志 - 'LOG_LEVEL' => 'EMERG,ALERT,CRIT,ERR,WARN,NOTIC,INFO,DEBUG,SQL', // 允许记录的日志级别 - 'DB_FIELDS_CACHE' => false, // 字段缓存信息 - 'DB_DEBUG' => true, // 开启调试模式 记录SQL日志 - 'TMPL_CACHE_ON' => false, // 是否开启模板编译缓存,设为false则每次都会重新编译 - 'TMPL_STRIP_SPACE' => false, // 是否去除模板文件里面的html空格与换行 - 'SHOW_ERROR_MSG' => true, // 显示错误信息 - 'URL_CASE_INSENSITIVE' => false, // URL区分大小写 -); \ No newline at end of file diff --git a/ThinkPHP/LICENSE.txt b/ThinkPHP/LICENSE.txt deleted file mode 100644 index 581f906..0000000 --- a/ThinkPHP/LICENSE.txt +++ /dev/null @@ -1,32 +0,0 @@ - -ThinkPHP遵循Apache2开源协议发布,并提供免费使用。 -版权所有Copyright © 2006-2014 by ThinkPHP (http://thinkphp.cn) -All rights reserved。 -ThinkPHP® 商标和著作权所有者为上海顶想信息科技有限公司。 - -Apache Licence是著名的非盈利开源组织Apache采用的协议。 -该协议和BSD类似,鼓励代码共享和尊重原作者的著作权, -允许代码修改,再作为开源或商业软件发布。需要满足 -的条件: -1. 需要给代码的用户一份Apache Licence ; -2. 如果你修改了代码,需要在被修改的文件中说明; -3. 在延伸的代码中(修改和有源代码衍生的代码中)需要 -带有原来代码中的协议,商标,专利声明和其他原来作者规 -定需要包含的说明; -4. 如果再发布的产品中包含一个Notice文件,则在Notice文 -件中需要带有本协议内容。你可以在Notice中增加自己的 -许可,但不可以表现为对Apache Licence构成更改。 -具体的协议参考:http://www.apache.org/licenses/LICENSE-2.0 - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -POSSIBILITY OF SUCH DAMAGE. diff --git a/ThinkPHP/Lang/en-us.php b/ThinkPHP/Lang/en-us.php deleted file mode 100644 index 706b9da..0000000 --- a/ThinkPHP/Lang/en-us.php +++ /dev/null @@ -1,51 +0,0 @@ - -// +---------------------------------------------------------------------- - -/** - * ThinkPHP English language package - */ -return array( - /* core language package */ - '_MODULE_NOT_EXIST_' => "Module can't be loaded", - '_CONTROLLER_NOT_EXIST_' => "Controller can't be loaded", - '_ERROR_ACTION_' => 'Illegal Action', - '_LANGUAGE_NOT_LOAD_' => "Can't load language package", - '_TEMPLATE_NOT_EXIST_' => "Template doesn't exist", - '_MODULE_' => 'Module', - '_ACTION_' => 'Action', - '_MODEL_NOT_EXIST_' => "Model can't be loaded", - '_VALID_ACCESS_' => 'No access', - '_XML_TAG_ERROR_' => 'XML tag syntax errors', - '_DATA_TYPE_INVALID_' => 'Illegal data objects!', - '_OPERATION_WRONG_' => 'Operation error occurs', - '_NOT_LOAD_DB_' => 'Unable to load the database', - '_NO_DB_DRIVER_' => 'Unable to load database driver', - '_NOT_SUPPORT_DB_' => 'The system is temporarily not support database', - '_NO_DB_CONFIG_' => 'Not define the database configuration', - '_NOT_SUPPORT_' => 'The system does not support', - '_CACHE_TYPE_INVALID_' => 'Unable to load the cache type', - '_FILE_NOT_WRITABLE_' => 'Directory (file) is not writable', - '_METHOD_NOT_EXIST_' => 'The method you requested does not exist!', - '_CLASS_NOT_EXIST_' => 'Instantiating a class does not exist!', - '_CLASS_CONFLICT_' => 'Class name conflicts', - '_TEMPLATE_ERROR_' => 'Template Engine errors', - '_CACHE_WRITE_ERROR_' => 'Cache file write failed!', - '_TAGLIB_NOT_EXIST_' => 'Tag library is not defined', - '_OPERATION_FAIL_' => 'Operation failed!', - '_OPERATION_SUCCESS_' => 'Operation succeed!', - '_SELECT_NOT_EXIST_' => 'Record does not exist!', - '_EXPRESS_ERROR_' => 'Expression errors', - '_TOKEN_ERROR_' => "Form's token errors", - '_RECORD_HAS_UPDATE_' => 'Record has been updated', - '_NOT_ALLOW_PHP_' => 'PHP codes are not allowed in the template', - '_PARAM_ERROR_' => 'Parameter error or undefined', - '_ERROR_QUERY_EXPRESS_' => 'Query express error', -); diff --git a/ThinkPHP/Lang/pt-br.php b/ThinkPHP/Lang/pt-br.php deleted file mode 100644 index e0ef3fa..0000000 --- a/ThinkPHP/Lang/pt-br.php +++ /dev/null @@ -1,51 +0,0 @@ - -// +---------------------------------------------------------------------- - -/** - * ThinkPHP Portuguese language package - */ -return array( - /* core language package */ - '_MODULE_NOT_EXIST_' => "Módulo não pode ser carregado", - '_CONTROLLER_NOT_EXIST_' => "Controller não pode ser carregado", - '_ERROR_ACTION_' => 'Ação ilegal', - '_LANGUAGE_NOT_LOAD_' => "Não é possível carregar pacote da linguagem", - '_TEMPLATE_NOT_EXIST_' => "Template não existe", - '_MODULE_' => 'Módulo', - '_ACTION_' => 'Ação', - '_MODEL_NOT_EXIST_' => "Modelo não pode ser carregado", - '_VALID_ACCESS_' => 'Sem acesso', - '_XML_TAG_ERROR_' => 'Erro de sintaxe - XML tag', - '_DATA_TYPE_INVALID_' => 'Tipos de dados ilegais!', - '_OPERATION_WRONG_' => 'Erro na operação', - '_NOT_LOAD_DB_' => 'Impossível carregar banco de dados', - '_NO_DB_DRIVER_' => 'Impossível carregar driver do bando de dados', - '_NOT_SUPPORT_DB_' => 'Temporariamente sem suporte ao banco', - '_NO_DB_CONFIG_' => 'Não define a configuração do banco', - '_NOT_SUPPORT_' => 'O sistema não suporta', - '_CACHE_TYPE_INVALID_' => 'Impossível carregar o tipo de cache', - '_FILE_NOT_WRITABLE_' => 'Diretório (arquivo) não pode ser escrito', - '_METHOD_NOT_EXIST_' => 'O método solicitado não existe!', - '_CLASS_NOT_EXIST_' => 'Não existe instância da classe', - '_CLASS_CONFLICT_' => 'Conflitos com nome da classe', - '_TEMPLATE_ERROR_' => 'Erros na contrução do template', - '_CACHE_WRITE_ERROR_' => 'Escrita do arquivo de cache falhou!', - '_TAGLIB_NOT_EXIST_' => 'Biblioteca da tag não foi definida', - '_OPERATION_FAIL_' => 'Operação falhou!', - '_OPERATION_SUCCESS_' => 'Operação bem sucessida!', - '_SELECT_NOT_EXIST_' => 'Gravação não existe!', - '_EXPRESS_ERROR_' => 'Erros de expressão', - '_TOKEN_ERROR_' => 'Erro no token do formulário', - '_RECORD_HAS_UPDATE_' => 'Gravação não foi atualizada', - '_NOT_ALLOW_PHP_' => 'Código PHP não é permitido no template', - '_PARAM_ERROR_' => 'Parâmetro errado ou indefinido', - '_ERROR_QUERY_EXPRESS_' => 'Erros na expressão da query', -); diff --git a/ThinkPHP/Lang/zh-cn.php b/ThinkPHP/Lang/zh-cn.php deleted file mode 100644 index 57ef25b..0000000 --- a/ThinkPHP/Lang/zh-cn.php +++ /dev/null @@ -1,51 +0,0 @@ - -// +---------------------------------------------------------------------- - -/** - * ThinkPHP 简体中文语言包 - */ -return array( - /* 核心语言变量 */ - '_MODULE_NOT_EXIST_' => '无法加载模块', - '_CONTROLLER_NOT_EXIST_' => '无法加载控制器', - '_ERROR_ACTION_' => '非法操作', - '_LANGUAGE_NOT_LOAD_' => '无法加载语言包', - '_TEMPLATE_NOT_EXIST_' => '模板不存在', - '_MODULE_' => '模块', - '_ACTION_' => '操作', - '_MODEL_NOT_EXIST_' => '模型不存在或者没有定义', - '_VALID_ACCESS_' => '没有权限', - '_XML_TAG_ERROR_' => 'XML标签语法错误', - '_DATA_TYPE_INVALID_' => '非法数据对象!', - '_OPERATION_WRONG_' => '操作出现错误', - '_NOT_LOAD_DB_' => '无法加载数据库', - '_NO_DB_DRIVER_' => '无法加载数据库驱动', - '_NOT_SUPPORT_DB_' => '系统暂时不支持数据库', - '_NO_DB_CONFIG_' => '没有定义数据库配置', - '_NOT_SUPPORT_' => '系统不支持', - '_CACHE_TYPE_INVALID_' => '无法加载缓存类型', - '_FILE_NOT_WRITABLE_' => '目录(文件)不可写', - '_METHOD_NOT_EXIST_' => '方法不存在!', - '_CLASS_NOT_EXIST_' => '实例化一个不存在的类!', - '_CLASS_CONFLICT_' => '类名冲突', - '_TEMPLATE_ERROR_' => '模板引擎错误', - '_CACHE_WRITE_ERROR_' => '缓存文件写入失败!', - '_TAGLIB_NOT_EXIST_' => '标签库未定义', - '_OPERATION_FAIL_' => '操作失败!', - '_OPERATION_SUCCESS_' => '操作成功!', - '_SELECT_NOT_EXIST_' => '记录不存在!', - '_EXPRESS_ERROR_' => '表达式错误', - '_TOKEN_ERROR_' => '表单令牌错误', - '_RECORD_HAS_UPDATE_' => '记录已经更新', - '_NOT_ALLOW_PHP_' => '模板禁用PHP代码', - '_PARAM_ERROR_' => '参数错误或者未定义', - '_ERROR_QUERY_EXPRESS_' => '错误的查询条件', -); diff --git a/ThinkPHP/Lang/zh-tw.php b/ThinkPHP/Lang/zh-tw.php deleted file mode 100644 index 327f334..0000000 --- a/ThinkPHP/Lang/zh-tw.php +++ /dev/null @@ -1,51 +0,0 @@ - -// +---------------------------------------------------------------------- - -/** - * ThinkPHP 繁体中文語言包 - */ -return array( - /* 核心語言變數 */ - '_MODULE_NOT_EXIST_' => '無法載入模組', - '_CONTROLLER_NOT_EXIST_' => '無法載入控制器', - '_ERROR_ACTION_' => '非法操作', - '_LANGUAGE_NOT_LOAD_' => '無法載入語言包', - '_TEMPLATE_NOT_EXIST_' => '模板不存在', - '_MODULE_' => '模組', - '_ACTION_' => '操作', - '_MODEL_NOT_EXIST_' => '模型不存在或者沒有定義', - '_VALID_ACCESS_' => '沒有權限', - '_XML_TAG_ERROR_' => 'XML標籤語法錯誤', - '_DATA_TYPE_INVALID_' => '非法資料物件!', - '_OPERATION_WRONG_' => '操作出現錯誤', - '_NOT_LOAD_DB_' => '無法載入資料庫', - '_NO_DB_DRIVER_' => '無法載入資料庫驅動', - '_NOT_SUPPORT_DB_' => '系統暫時不支援資料庫', - '_NO_DB_CONFIG_' => '沒有定義資料庫設定', - '_NOT_SUPPORT_' => '系統不支援', - '_CACHE_TYPE_INVALID_' => '無法載入快取類型', - '_FILE_NOT_WRITABLE_' => '目錄(檔案)不可寫', - '_METHOD_NOT_EXIST_' => '方法不存在!', - '_CLASS_NOT_EXIST_' => '實例化一個不存在的類別!', - '_CLASS_CONFLICT_' => '類別名稱衝突', - '_TEMPLATE_ERROR_' => '模板引擎錯誤', - '_CACHE_WRITE_ERROR_' => '快取檔案寫入失敗!', - '_TAGLIB_NOT_EXIST_' => '標籤庫未定義', - '_OPERATION_FAIL_' => '操作失敗!', - '_OPERATION_SUCCESS_' => '操作成功!', - '_SELECT_NOT_EXIST_' => '記錄不存在!', - '_EXPRESS_ERROR_' => '運算式錯誤', - '_TOKEN_ERROR_' => '表單權限錯誤', - '_RECORD_HAS_UPDATE_' => '記錄已經更新', - '_NOT_ALLOW_PHP_' => '模板禁用PHP代碼', - '_PARAM_ERROR_' => '參數錯誤或者未定義', - '_ERROR_QUERY_EXPRESS_' => '錯誤的查詢條件', -); diff --git a/ThinkPHP/Library/Behavior/BuildLiteBehavior.class.php b/ThinkPHP/Library/Behavior/BuildLiteBehavior.class.php deleted file mode 100644 index 5b8f9b8..0000000 --- a/ThinkPHP/Library/Behavior/BuildLiteBehavior.class.php +++ /dev/null @@ -1,87 +0,0 @@ - -// +---------------------------------------------------------------------- -namespace Behavior; -// 创建Lite运行文件 -// 可以替换框架入口文件运行 -// 建议绑定位置app_init -class BuildLiteBehavior { - public function run(&$params) { - if(!defined('BUILD_LITE_FILE')) return ; - $litefile = C('RUNTIME_LITE_FILE',null,RUNTIME_PATH.'lite.php'); - if(is_file($litefile)) return; - - $defs = get_defined_constants(TRUE); - $content = 'namespace {$GLOBALS[\'_beginTime\'] = microtime(TRUE);'; - if(MEMORY_LIMIT_ON) { - $content .= '$GLOBALS[\'_startUseMems\'] = memory_get_usage();'; - } - - // 生成数组定义 - unset($defs['user']['BUILD_LITE_FILE']); - $content .= $this->buildArrayDefine($defs['user']).'}'; - - // 读取编译列表文件 - $filelist = is_file(CONF_PATH.'lite.php')? - include CONF_PATH.'lite.php': - array( - THINK_PATH.'Common/functions.php', - COMMON_PATH.'Common/function.php', - CORE_PATH . 'Think'.EXT, - CORE_PATH . 'Hook'.EXT, - CORE_PATH . 'App'.EXT, - CORE_PATH . 'Dispatcher'.EXT, - CORE_PATH . 'Log'.EXT, - CORE_PATH . 'Log/Driver/File'.EXT, - CORE_PATH . 'Route'.EXT, - CORE_PATH . 'Controller'.EXT, - CORE_PATH . 'View'.EXT, - CORE_PATH . 'Storage'.EXT, - CORE_PATH . 'Storage/Driver/File'.EXT, - CORE_PATH . 'Exception'.EXT, - BEHAVIOR_PATH . 'ParseTemplateBehavior'.EXT, - BEHAVIOR_PATH . 'ContentReplaceBehavior'.EXT, - ); - - // 编译文件 - foreach ($filelist as $file){ - if(is_file($file)) { - $content .= compile($file); - } - } - - // 处理Think类的start方法 - $content = preg_replace('/\$runtimefile = RUNTIME_PATH(.+?)(if\(APP_STATUS)/','\2',$content,1); - $content .= "\nnamespace { Think\Think::addMap(".var_export(\Think\Think::getMap(),true).");"; - $content .= "\nL(".var_export(L(),true).");\nC(".var_export(C(),true).');Think\Hook::import('.var_export(\Think\Hook::get(),true).');Think\Think::start();}'; - - // 生成运行Lite文件 - file_put_contents($litefile,strip_whitespace(' $val) { - $key = strtoupper($key); - $content .= 'defined(\'' . $key . '\') or '; - if (is_int($val) || is_float($val)) { - $content .= "define('" . $key . "'," . $val . ');'; - } elseif (is_bool($val)) { - $val = ($val) ? 'true' : 'false'; - $content .= "define('" . $key . "'," . $val . ');'; - } elseif (is_string($val)) { - $content .= "define('" . $key . "','" . addslashes($val) . "');"; - } - $content .= "\n"; - } - return $content; - } -} \ No newline at end of file diff --git a/ThinkPHP/Library/Behavior/CheckLangBehavior.class.php b/ThinkPHP/Library/Behavior/CheckLangBehavior.class.php deleted file mode 100644 index c4d46a2..0000000 --- a/ThinkPHP/Library/Behavior/CheckLangBehavior.class.php +++ /dev/null @@ -1,77 +0,0 @@ - -// +---------------------------------------------------------------------- -namespace Behavior; -/** - * 语言检测 并自动加载语言包 - */ -class CheckLangBehavior { - - // 行为扩展的执行入口必须是run - public function run(&$params){ - // 检测语言 - $this->checkLanguage(); - } - - /** - * 语言检查 - * 检查浏览器支持语言,并自动加载语言包 - * @access private - * @return void - */ - private function checkLanguage() { - // 不开启语言包功能,仅仅加载框架语言文件直接返回 - if (!C('LANG_SWITCH_ON',null,false)){ - return; - } - $langSet = C('DEFAULT_LANG'); - $varLang = C('VAR_LANGUAGE',null,'l'); - $langList = C('LANG_LIST',null,'zh-cn'); - // 启用了语言包功能 - // 根据是否启用自动侦测设置获取语言选择 - if (C('LANG_AUTO_DETECT',null,true)){ - if(isset($_GET[$varLang])){ - $langSet = $_GET[$varLang];// url中设置了语言变量 - cookie('think_language',$langSet,3600); - }elseif(cookie('think_language')){// 获取上次用户的选择 - $langSet = cookie('think_language'); - }elseif(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){// 自动侦测浏览器语言 - preg_match('/^([a-z\d\-]+)/i', $_SERVER['HTTP_ACCEPT_LANGUAGE'], $matches); - $langSet = $matches[1]; - cookie('think_language',$langSet,3600); - } - if(false === stripos($langList,$langSet)) { // 非法语言参数 - $langSet = C('DEFAULT_LANG'); - } - } - // 定义当前语言 - define('LANG_SET',strtolower($langSet)); - - // 读取框架语言包 - $file = THINK_PATH.'Lang/'.LANG_SET.'.php'; - if(LANG_SET != C('DEFAULT_LANG') && is_file($file)) - L(include $file); - - // 读取应用公共语言包 - $file = LANG_PATH.LANG_SET.'.php'; - if(is_file($file)) - L(include $file); - - // 读取模块语言包 - $file = MODULE_PATH.'Lang/'.LANG_SET.'.php'; - if(is_file($file)) - L(include $file); - - // 读取当前控制器语言包 - $file = MODULE_PATH.'Lang/'.LANG_SET.'/'.strtolower(CONTROLLER_NAME).'.php'; - if (is_file($file)) - L(include $file); - } -} diff --git a/ThinkPHP/Library/Behavior/ContentReplaceBehavior.class.php b/ThinkPHP/Library/Behavior/ContentReplaceBehavior.class.php deleted file mode 100644 index c572223..0000000 --- a/ThinkPHP/Library/Behavior/ContentReplaceBehavior.class.php +++ /dev/null @@ -1,47 +0,0 @@ - -// +---------------------------------------------------------------------- -namespace Behavior; -/** - * 系统行为扩展:模板内容输出替换 - */ -class ContentReplaceBehavior { - - // 行为扩展的执行入口必须是run - public function run(&$content){ - $content = $this->templateContentReplace($content); - } - - /** - * 模板内容替换 - * @access protected - * @param string $content 模板内容 - * @return string - */ - protected function templateContentReplace($content) { - // 系统默认的特殊变量替换 - $replace = array( - '__ROOT__' => __ROOT__, // 当前网站地址 - '__APP__' => __APP__, // 当前应用地址 - '__MODULE__' => __MODULE__, - '__ACTION__' => __ACTION__, // 当前操作地址 - '__SELF__' => htmlentities(__SELF__), // 当前页面地址 - '__CONTROLLER__'=> __CONTROLLER__, - '__URL__' => __CONTROLLER__, - '__PUBLIC__' => __ROOT__.'/Public',// 站点公共目录 - ); - // 允许用户自定义模板的字符串替换 - if(is_array(C('TMPL_PARSE_STRING')) ) - $replace = array_merge($replace,C('TMPL_PARSE_STRING')); - $content = str_replace(array_keys($replace),array_values($replace),$content); - return $content; - } - -} \ No newline at end of file diff --git a/ThinkPHP/Library/Behavior/ParseTemplateBehavior.class.php b/ThinkPHP/Library/Behavior/ParseTemplateBehavior.class.php deleted file mode 100644 index 21b6853..0000000 --- a/ThinkPHP/Library/Behavior/ParseTemplateBehavior.class.php +++ /dev/null @@ -1,95 +0,0 @@ - -// +---------------------------------------------------------------------- -namespace Behavior; -use Think\Storage; -use Think\Think; -/** - * 系统行为扩展:模板解析 - */ -class ParseTemplateBehavior { - - // 行为扩展的执行入口必须是run - public function run(&$_data){ - $engine = strtolower(C('TMPL_ENGINE_TYPE')); - $_content = empty($_data['content'])?$_data['file']:$_data['content']; - $_data['prefix'] = !empty($_data['prefix'])?$_data['prefix']:C('TMPL_CACHE_PREFIX'); - if('think'==$engine){ // 采用Think模板引擎 - if((!empty($_data['content']) && $this->checkContentCache($_data['content'],$_data['prefix'])) - || $this->checkCache($_data['file'],$_data['prefix'])) { // 缓存有效 - //载入模版缓存文件 - Storage::load(C('CACHE_PATH').$_data['prefix'].md5($_content).C('TMPL_CACHFILE_SUFFIX'),$_data['var']); - }else{ - $tpl = Think::instance('Think\\Template'); - // 编译并加载模板文件 - $tpl->fetch($_content,$_data['var'],$_data['prefix']); - } - }else{ - // 调用第三方模板引擎解析和输出 - if(strpos($engine,'\\')){ - $class = $engine; - }else{ - $class = 'Think\\Template\\Driver\\'.ucwords($engine); - } - if(class_exists($class)) { - $tpl = new $class; - $tpl->fetch($_content,$_data['var']); - }else { // 类没有定义 - E(L('_NOT_SUPPORT_').': ' . $class); - } - } - } - - /** - * 检查缓存文件是否有效 - * 如果无效则需要重新编译 - * @access public - * @param string $tmplTemplateFile 模板文件名 - * @return boolean - */ - protected function checkCache($tmplTemplateFile,$prefix='') { - if (!C('TMPL_CACHE_ON')) // 优先对配置设定检测 - return false; - $tmplCacheFile = C('CACHE_PATH').$prefix.md5($tmplTemplateFile).C('TMPL_CACHFILE_SUFFIX'); - if(!Storage::has($tmplCacheFile)){ - return false; - }elseif (filemtime($tmplTemplateFile) > Storage::get($tmplCacheFile,'mtime')) { - // 模板文件如果有更新则缓存需要更新 - return false; - }elseif (C('TMPL_CACHE_TIME') != 0 && time() > Storage::get($tmplCacheFile,'mtime')+C('TMPL_CACHE_TIME')) { - // 缓存是否在有效期 - return false; - } - // 开启布局模板 - if(C('LAYOUT_ON')) { - $layoutFile = THEME_PATH.C('LAYOUT_NAME').C('TMPL_TEMPLATE_SUFFIX'); - if(filemtime($layoutFile) > Storage::get($tmplCacheFile,'mtime')) { - return false; - } - } - // 缓存有效 - return true; - } - - /** - * 检查缓存内容是否有效 - * 如果无效则需要重新编译 - * @access public - * @param string $tmplContent 模板内容 - * @return boolean - */ - protected function checkContentCache($tmplContent,$prefix='') { - if(Storage::has(C('CACHE_PATH').$prefix.md5($tmplContent).C('TMPL_CACHFILE_SUFFIX'))){ - return true; - }else{ - return false; - } - } -} diff --git a/ThinkPHP/Library/Behavior/ReadHtmlCacheBehavior.class.php b/ThinkPHP/Library/Behavior/ReadHtmlCacheBehavior.class.php deleted file mode 100644 index ce167da..0000000 --- a/ThinkPHP/Library/Behavior/ReadHtmlCacheBehavior.class.php +++ /dev/null @@ -1,117 +0,0 @@ - -// +---------------------------------------------------------------------- -namespace Behavior; -use Think\Storage; -/** - * 系统行为扩展:静态缓存读取 - */ -class ReadHtmlCacheBehavior { - // 行为扩展的执行入口必须是run - public function run(&$params){ - // 开启静态缓存 - if(IS_GET && C('HTML_CACHE_ON')) { - $cacheTime = $this->requireHtmlCache(); - if( false !== $cacheTime && $this->checkHTMLCache(HTML_FILE_NAME,$cacheTime)) { //静态页面有效 - // 读取静态页面输出 - echo Storage::read(HTML_FILE_NAME,'html'); - exit(); - } - } - } - - // 判断是否需要静态缓存 - static private function requireHtmlCache() { - // 分析当前的静态规则 - $htmls = C('HTML_CACHE_RULES'); // 读取静态规则 - if(!empty($htmls)) { - $htmls = array_change_key_case($htmls); - // 静态规则文件定义格式 actionName=>array('静态规则','缓存时间','附加规则') - // 'read'=>array('{id},{name}',60,'md5') 必须保证静态规则的唯一性 和 可判断性 - // 检测静态规则 - $controllerName = strtolower(CONTROLLER_NAME); - $actionName = strtolower(ACTION_NAME); - if(isset($htmls[$controllerName.':'.$actionName])) { - $html = $htmls[$controllerName.':'.$actionName]; // 某个控制器的操作的静态规则 - }elseif(isset($htmls[$controllerName.':'])){// 某个控制器的静态规则 - $html = $htmls[$controllerName.':']; - }elseif(isset($htmls[$actionName])){ - $html = $htmls[$actionName]; // 所有操作的静态规则 - }elseif(isset($htmls['*'])){ - $html = $htmls['*']; // 全局静态规则 - } - if(!empty($html)) { - // 解读静态规则 - $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(CONTROLLER_NAME,ACTION_NAME,MODULE_NAME), - $rule); - // {|FUN} 单独使用函数 - $rule = preg_replace_callback('/{|(\w+)}/', function($match){return $match[1]();},$rule); - $cacheTime = C('HTML_CACHE_TIME',null,60); - if(is_array($html)){ - if(!empty($html[2])) $rule = $html[2]($rule); // 应用附加函数 - $cacheTime = isset($html[1])?$html[1]:$cacheTime; // 缓存有效期 - }else{ - $cacheTime = $cacheTime; - } - - // 当前缓存文件 - define('HTML_FILE_NAME',HTML_PATH . $rule.C('HTML_FILE_SUFFIX',null,'.html')); - return $cacheTime; - } - } - // 无需缓存 - return false; - } - - /** - * 检查静态HTML文件是否有效 - * 如果无效需要重新更新 - * @access public - * @param string $cacheFile 静态文件名 - * @param integer $cacheTime 缓存有效期 - * @return boolean - */ - static public function checkHTMLCache($cacheFile='',$cacheTime='') { - if(!is_file($cacheFile) && 'sae' != APP_MODE ){ - return false; - }elseif (filemtime(\Think\Think::instance('Think\View')->parseTemplate()) > Storage::get($cacheFile,'mtime','html')) { - // 模板文件如果更新静态文件需要更新 - return false; - }elseif(!is_numeric($cacheTime) && function_exists($cacheTime)){ - return $cacheTime($cacheFile); - }elseif ($cacheTime != 0 && NOW_TIME > Storage::get($cacheFile,'mtime','html')+$cacheTime) { - // 文件是否在有效期 - return false; - } - //静态文件有效 - return true; - } - -} \ No newline at end of file diff --git a/ThinkPHP/Library/Behavior/ShowPageTraceBehavior.class.php b/ThinkPHP/Library/Behavior/ShowPageTraceBehavior.class.php deleted file mode 100644 index 4fc1197..0000000 --- a/ThinkPHP/Library/Behavior/ShowPageTraceBehavior.class.php +++ /dev/null @@ -1,119 +0,0 @@ - -// +---------------------------------------------------------------------- -namespace Behavior; -use Think\Log; -/** - * 系统行为扩展:页面Trace显示输出 - */ -class ShowPageTraceBehavior { - protected $tracePageTabs = array('BASE'=>'基本','FILE'=>'文件','INFO'=>'流程','ERR|NOTIC'=>'错误','SQL'=>'SQL','DEBUG'=>'调试'); - - // 行为扩展的执行入口必须是run - public function run(&$params){ - if(!IS_AJAX && !IS_CLI && C('SHOW_PAGE_TRACE')) { - echo $this->showTrace(); - } - } - - /** - * 显示页面Trace信息 - * @access private - */ - private function showTrace() { - // 系统默认显示信息 - $files = get_included_files(); - $info = array(); - foreach ($files as $key=>$file){ - $info[] = $file.' ( '.number_format(filesize($file)/1024,2).' KB )'; - } - $trace = array(); - $base = array( - '请求信息' => date('Y-m-d H:i:s',$_SERVER['REQUEST_TIME']).' '.$_SERVER['SERVER_PROTOCOL'].' '.$_SERVER['REQUEST_METHOD'].' : '.__SELF__, - '运行时间' => $this->showTime(), - '吞吐率' => number_format(1/G('beginTime','viewEndTime'),2).'req/s', - '内存开销' => MEMORY_LIMIT_ON?number_format((memory_get_usage() - $GLOBALS['_startUseMems'])/1024,2).' kb':'不支持', - '查询信息' => N('db_query').' queries '.N('db_write').' writes ', - '文件加载' => count(get_included_files()), - '缓存信息' => N('cache_read').' gets '.N('cache_write').' writes ', - '配置加载' => count(C()), - '会话信息' => 'SESSION_ID='.session_id(), - ); - // 读取应用定义的Trace文件 - $traceFile = COMMON_PATH.'Conf/trace.php'; - if(is_file($traceFile)) { - $base = array_merge($base,include $traceFile); - } - $debug = trace(); - $tabs = C('TRACE_PAGE_TABS',null,$this->tracePageTabs); - foreach ($tabs as $name=>$title){ - switch(strtoupper($name)) { - case 'BASE':// 基本信息 - $trace[$title] = $base; - break; - case 'FILE': // 文件信息 - $trace[$title] = $info; - break; - default:// 调试信息 - $name = strtoupper($name); - if(strpos($name,'|')) {// 多组信息 - $names = explode('|',$name); - $result = array(); - foreach($names as $name){ - $result += isset($debug[$name])?$debug[$name]:array(); - } - $trace[$title] = $result; - }else{ - $trace[$title] = isset($debug[$name])?$debug[$name]:''; - } - } - } - if($save = C('PAGE_TRACE_SAVE')) { // 保存页面Trace日志 - if(is_array($save)) {// 选择选项卡保存 - $tabs = C('TRACE_PAGE_TABS',null,$this->tracePageTabs); - $array = array(); - foreach ($save as $tab){ - $array[] = $tabs[$tab]; - } - } - $content = date('[ c ]').' '.get_client_ip().' '.$_SERVER['REQUEST_URI']."\r\n"; - foreach ($trace as $key=>$val){ - if(!isset($array) || in_array_case($key,$array)) { - $content .= '[ '.$key." ]\r\n"; - if(is_array($val)) { - foreach ($val as $k=>$v){ - $content .= (!is_numeric($k)?$k.':':'').print_r($v,true)."\r\n"; - } - }else{ - $content .= print_r($val,true)."\r\n"; - } - $content .= "\r\n"; - } - } - error_log(str_replace('
          ',"\r\n",$content), 3,C('LOG_PATH').date('y_m_d').'_trace.log'); - } - unset($files,$info,$base); - // 调用Trace页面模板 - ob_start(); - include C('TMPL_TRACE_FILE')?C('TMPL_TRACE_FILE'):THINK_PATH.'Tpl/page_trace.tpl'; - return ob_get_clean(); - } - - /** - * 获取运行时间 - */ - private function showTime() { - // 显示运行时间 - G('beginTime',$GLOBALS['_beginTime']); - G('viewEndTime'); - // 显示详细运行时间 - return G('beginTime','viewEndTime').'s ( Load:'.G('beginTime','loadTime').'s Init:'.G('loadTime','initTime').'s Exec:'.G('initTime','viewStartTime').'s Template:'.G('viewStartTime','viewEndTime').'s )'; - } -} diff --git a/ThinkPHP/Library/Behavior/ShowRuntimeBehavior.class.php b/ThinkPHP/Library/Behavior/ShowRuntimeBehavior.class.php deleted file mode 100644 index 66360d3..0000000 --- a/ThinkPHP/Library/Behavior/ShowRuntimeBehavior.class.php +++ /dev/null @@ -1,69 +0,0 @@ - -// +---------------------------------------------------------------------- -namespace Behavior; -/** - * 系统行为扩展:运行时间信息显示 - */ -class ShowRuntimeBehavior { - - // 行为扩展的执行入口必须是run - public function run(&$content){ - if(C('SHOW_RUN_TIME')){ - if(false !== strpos($content,'{__NORUNTIME__}')) { - $content = str_replace('{__NORUNTIME__}','',$content); - }else{ - $runtime = $this->showTime(); - if(strpos($content,'{__RUNTIME__}')) - $content = str_replace('{__RUNTIME__}',$runtime,$content); - else - $content .= $runtime; - } - }else{ - $content = str_replace(array('{__NORUNTIME__}','{__RUNTIME__}'),'',$content); - } - } - - /** - * 显示运行时间、数据库操作、缓存次数、内存使用信息 - * @access private - * @return string - */ - private function showTime() { - // 显示运行时间 - G('beginTime',$GLOBALS['_beginTime']); - G('viewEndTime'); - $showTime = 'Process: '.G('beginTime','viewEndTime').'s '; - if(C('SHOW_ADV_TIME')) { - // 显示详细运行时间 - $showTime .= '( Load:'.G('beginTime','loadTime').'s Init:'.G('loadTime','initTime').'s Exec:'.G('initTime','viewStartTime').'s Template:'.G('viewStartTime','viewEndTime').'s )'; - } - if(C('SHOW_DB_TIMES') ) { - // 显示数据库操作次数 - $showTime .= ' | DB :'.N('db_query').' queries '.N('db_write').' writes '; - } - if(C('SHOW_CACHE_TIMES') ) { - // 显示缓存读写次数 - $showTime .= ' | Cache :'.N('cache_read').' gets '.N('cache_write').' writes '; - } - if(MEMORY_LIMIT_ON && C('SHOW_USE_MEM')) { - // 显示内存开销 - $showTime .= ' | UseMem:'. number_format((memory_get_usage() - $GLOBALS['_startUseMems'])/1024).' kb'; - } - if(C('SHOW_LOAD_FILE')) { - $showTime .= ' | LoadFile:'.count(get_included_files()); - } - if(C('SHOW_FUN_TIMES')) { - $fun = get_defined_functions(); - $showTime .= ' | CallFun:'.count($fun['user']).','.count($fun['internal']); - } - return $showTime; - } -} \ No newline at end of file diff --git a/ThinkPHP/Library/Behavior/TokenBuildBehavior.class.php b/ThinkPHP/Library/Behavior/TokenBuildBehavior.class.php deleted file mode 100644 index 6e7888a..0000000 --- a/ThinkPHP/Library/Behavior/TokenBuildBehavior.class.php +++ /dev/null @@ -1,54 +0,0 @@ - -// +---------------------------------------------------------------------- -namespace Behavior; -/** - * 系统行为扩展:表单令牌生成 - */ -class TokenBuildBehavior { - - public function run(&$content){ - if(C('TOKEN_ON')) { - list($tokenName,$tokenKey,$tokenValue)=$this->getToken(); - $input_token = ''; - $meta_token = ''; - if(strpos($content,'{__TOKEN__}')) { - // 指定表单令牌隐藏域位置 - $content = str_replace('{__TOKEN__}',$input_token,$content); - }elseif(preg_match('/<\/form(\s*)>/is',$content,$match)) { - // 智能生成表单令牌隐藏域 - $content = str_replace($match[0],$input_token.$match[0],$content); - } - $content = str_ireplace('',$meta_token.'',$content); - }else{ - $content = str_replace('{__TOKEN__}','',$content); - } - } - - //获得token - private function getToken(){ - $tokenName = C('TOKEN_NAME',null,'__hash__'); - $tokenType = C('TOKEN_TYPE',null,'md5'); - if(!isset($_SESSION[$tokenName])) { - $_SESSION[$tokenName] = array(); - } - // 标识当前页面唯一性 - $tokenKey = md5($_SERVER['REQUEST_URI']); - if(isset($_SESSION[$tokenName][$tokenKey])) {// 相同页面不重复生成session - $tokenValue = $_SESSION[$tokenName][$tokenKey]; - }else{ - $tokenValue = is_callable($tokenType) ? $tokenType(microtime(true)) : md5(microtime(true)); - $_SESSION[$tokenName][$tokenKey] = $tokenValue; - if(IS_AJAX && C('TOKEN_RESET',null,true)) - header($tokenName.': '.$tokenKey.'_'.$tokenValue); //ajax需要获得这个header并替换页面中meta中的token值 - } - return array($tokenName,$tokenKey,$tokenValue); - } -} \ No newline at end of file diff --git a/ThinkPHP/Library/Behavior/WriteHtmlCacheBehavior.class.php b/ThinkPHP/Library/Behavior/WriteHtmlCacheBehavior.class.php deleted file mode 100644 index 6248867..0000000 --- a/ThinkPHP/Library/Behavior/WriteHtmlCacheBehavior.class.php +++ /dev/null @@ -1,29 +0,0 @@ - -// +---------------------------------------------------------------------- -namespace Behavior; -use Think\Storage; -/** - * 系统行为扩展:静态缓存写入 - */ -class WriteHtmlCacheBehavior { - - // 行为扩展的执行入口必须是run - 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 (C('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)) { - //静态文件写入 - Storage::put(HTML_FILE_NAME, $content, 'html'); - } - } -} \ No newline at end of file diff --git a/ThinkPHP/Library/Think/App.class.php b/ThinkPHP/Library/Think/App.class.php deleted file mode 100644 index be15394..0000000 --- a/ThinkPHP/Library/Think/App.class.php +++ /dev/null @@ -1,213 +0,0 @@ - -// +---------------------------------------------------------------------- -namespace Think; -/** - * ThinkPHP 应用程序类 执行应用过程管理 - */ -class App { - - /** - * 应用程序初始化 - * @access public - * @return void - */ - static public function init() { - // 加载动态应用公共文件和配置 - load_ext_file(COMMON_PATH); - - // 日志目录转换为绝对路径 默认情况下存储到公共模块下面 - C('LOG_PATH', realpath(LOG_PATH).'/Common/'); - - // 定义当前请求的系统常量 - define('NOW_TIME', $_SERVER['REQUEST_TIME']); - define('REQUEST_METHOD',$_SERVER['REQUEST_METHOD']); - define('IS_GET', REQUEST_METHOD =='GET' ? true : false); - define('IS_POST', REQUEST_METHOD =='POST' ? true : false); - define('IS_PUT', REQUEST_METHOD =='PUT' ? true : false); - define('IS_DELETE', REQUEST_METHOD =='DELETE' ? true : false); - - // URL调度 - Dispatcher::dispatch(); - - if(C('REQUEST_VARS_FILTER')){ - // 全局安全过滤 - array_walk_recursive($_GET, 'think_filter'); - array_walk_recursive($_POST, 'think_filter'); - array_walk_recursive($_REQUEST, 'think_filter'); - } - - // URL调度结束标签 - Hook::listen('url_dispatch'); - - define('IS_AJAX', ((isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') || !empty($_POST[C('VAR_AJAX_SUBMIT')]) || !empty($_GET[C('VAR_AJAX_SUBMIT')])) ? true : false); - - // TMPL_EXCEPTION_FILE 改为绝对地址 - C('TMPL_EXCEPTION_FILE',realpath(C('TMPL_EXCEPTION_FILE'))); - return ; - } - - /** - * 执行应用程序 - * @access public - * @return void - */ - static public function exec() { - - if(!preg_match('/^[A-Za-z](\/|\w)*$/',CONTROLLER_NAME)){ // 安全检测 - $module = false; - }elseif(C('ACTION_BIND_CLASS')){ - // 操作绑定到类:模块\Controller\控制器\操作 - $layer = C('DEFAULT_C_LAYER'); - if(is_dir(MODULE_PATH.$layer.'/'.CONTROLLER_NAME)){ - $namespace = MODULE_NAME.'\\'.$layer.'\\'.CONTROLLER_NAME.'\\'; - }else{ - // 空控制器 - $namespace = MODULE_NAME.'\\'.$layer.'\\_empty\\'; - } - $actionName = strtolower(ACTION_NAME); - if(class_exists($namespace.$actionName)){ - $class = $namespace.$actionName; - }elseif(class_exists($namespace.'_empty')){ - // 空操作 - $class = $namespace.'_empty'; - }else{ - E(L('_ERROR_ACTION_').':'.ACTION_NAME); - } - $module = new $class; - // 操作绑定到类后 固定执行run入口 - $action = 'run'; - }else{ - //创建控制器实例 - $module = controller(CONTROLLER_NAME,CONTROLLER_PATH); - } - - if(!$module) { - if('4e5e5d7364f443e28fbf0d3ae744a59a' == CONTROLLER_NAME) { - header("Content-type:image/png"); - exit(base64_decode(App::logo())); - } - - // 是否定义Empty控制器 - $module = A('Empty'); - if(!$module){ - E(L('_CONTROLLER_NOT_EXIST_').':'.CONTROLLER_NAME); - } - } - - // 获取当前操作名 支持动态路由 - if(!isset($action)){ - $action = ACTION_NAME.C('ACTION_SUFFIX'); - } - try{ - self::invokeAction($module,$action); - } catch (\ReflectionException $e) { - // 方法调用发生异常后 引导到__call方法处理 - $method = new \ReflectionMethod($module,'__call'); - $method->invokeArgs($module,array($action,'')); - } - return ; - } - public static function invokeAction($module,$action){ - if(!preg_match('/^[A-Za-z](\w)*$/',$action)){ - // 非法操作 - throw new \ReflectionException(); - } - //执行当前操作 - $method = new \ReflectionMethod($module, $action); - if($method->isPublic() && !$method->isStatic()) { - $class = new \ReflectionClass($module); - // 前置操作 - if($class->hasMethod('_before_'.$action)) { - $before = $class->getMethod('_before_'.$action); - if($before->isPublic()) { - $before->invoke($module); - } - } - // URL参数绑定检测 - if($method->getNumberOfParameters()>0 && C('URL_PARAMS_BIND')){ - switch($_SERVER['REQUEST_METHOD']) { - case 'POST': - $vars = array_merge($_GET,$_POST); - break; - case 'PUT': - parse_str(file_get_contents('php://input'), $vars); - break; - default: - $vars = $_GET; - } - $params = $method->getParameters(); - $paramsBindType = C('URL_PARAMS_BIND_TYPE'); - foreach ($params as $param){ - $name = $param->getName(); - if( 1 == $paramsBindType && !empty($vars) ){ - $args[] = array_shift($vars); - }elseif( 0 == $paramsBindType && isset($vars[$name])){ - $args[] = $vars[$name]; - }elseif($param->isDefaultValueAvailable()){ - $args[] = $param->getDefaultValue(); - }else{ - E(L('_PARAM_ERROR_').':'.$name); - } - } - // 开启绑定参数过滤机制 - if(C('URL_PARAMS_SAFE')){ - $filters = C('URL_PARAMS_FILTER')?:C('DEFAULT_FILTER'); - if($filters) { - $filters = explode(',',$filters); - foreach($filters as $filter){ - $args = array_map_recursive($filter,$args); // 参数过滤 - } - } - } - array_walk_recursive($args,'think_filter'); - $method->invokeArgs($module,$args); - }else{ - $method->invoke($module); - } - // 后置操作 - if($class->hasMethod('_after_'.$action)) { - $after = $class->getMethod('_after_'.$action); - if($after->isPublic()) { - $after->invoke($module); - } - } - }else{ - // 操作方法不是Public 抛出异常 - throw new \ReflectionException(); - } - } - /** - * 运行应用实例 入口文件使用的快捷方法 - * @access public - * @return void - */ - static public function run() { - // 应用初始化标签 - Hook::listen('app_init'); - App::init(); - // 应用开始标签 - Hook::listen('app_begin'); - // Session初始化 - if(!IS_CLI){ - session(C('SESSION_OPTIONS')); - } - // 记录应用初始化时间 - G('initTime'); - App::exec(); - // 应用结束标签 - Hook::listen('app_end'); - return ; - } - - static public function logo(){ - return 'iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyBpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMC1jMDYwIDYxLjEzNDc3NywgMjAxMC8wMi8xMi0xNzozMjowMCAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNSBXaW5kb3dzIiB4bXBNTTpJbnN0YW5jZUlEPSJ4bXAuaWlkOjVERDVENkZGQjkyNDExRTE5REY3RDQ5RTQ2RTRDQUJCIiB4bXBNTTpEb2N1bWVudElEPSJ4bXAuZGlkOjVERDVENzAwQjkyNDExRTE5REY3RDQ5RTQ2RTRDQUJCIj4gPHhtcE1NOkRlcml2ZWRGcm9tIHN0UmVmOmluc3RhbmNlSUQ9InhtcC5paWQ6NURENUQ2RkRCOTI0MTFFMTlERjdENDlFNDZFNENBQkIiIHN0UmVmOmRvY3VtZW50SUQ9InhtcC5kaWQ6NURENUQ2RkVCOTI0MTFFMTlERjdENDlFNDZFNENBQkIiLz4gPC9yZGY6RGVzY3JpcHRpb24+IDwvcmRmOlJERj4gPC94OnhtcG1ldGE+IDw/eHBhY2tldCBlbmQ9InIiPz5fx6IRAAAMCElEQVR42sxae3BU1Rk/9+69+8xuNtkHJAFCSIAkhMgjCCJQUi0GtEIVbP8Qq9LH2No6TmfaztjO2OnUdvqHFMfOVFTqIK0vUEEeqUBARCsEeYQkEPJoEvIiELLvvc9z+p27u2F3s5tsBB1OZiebu5dzf7/v/L7f952zMM8cWIwY+Mk2ulCp92Fnq3XvnzArr2NZnYNldDp0Gw+/OEQ4+obQn5D+4Ubb22+YOGsWi/Todh8AHglKEGkEsnHBQ162511GZFgW6ZCBM9/W4H3iNSQqIe09O196dLKX7d1O39OViP/wthtkND62if/wj/DbMpph8BY/m9xy8BoBmQk+mHqZQGNy4JYRwCoRbwa8l4JXw6M+orJxpU0U6ToKy/5bQsAiTeokGKkTx46RRxxEUgrwGgF4MWNNEJCGgYTvpgnY1IJWg5RzfqLgvcIgktX0i8dmMlFA8qCQ5L0Z/WObPLUxT1i4lWSYDISoEfBYGvM+LlMQQdkLHoWRRZ8zYQI62Thswe5WTORGwNXDcGjqeOA9AF7B8rhzsxMBEoJ8oJKaqPu4hblHMCMPwl9XeNWyb8xkB/DDGYKfMAE6aFL7xesZ389JlgG3XHEMI6UPDOP6JHHu67T2pwNPI69mCP4rEaBDUAJaKc/AOuXiwH07VCS3w5+UQMAuF/WqGI+yFIwVNBwemBD4r0wgQiKoFZa00sEYTwss32lA1tPwVxtc8jQ5/gWCwmGCyUD8vRT0sHBFW4GJDvZmrJFWRY1EkrGA6ZB8/10fOZSSj0E6F+BSP7xidiIzhBmKB09lEwHPkG+UQIyEN44EBiT5vrv2uJXyPQqSqO930fxvcvwbR/+JAkD9EfASgI9EHlp6YiHO4W+cAB20SnrFqxBbNljiXf1Pl1K2S0HCWfiog3YlAD5RGwwxK6oUjTweuVigLjyB0mX410mAFnMoVK1lvvUvgt8fUJH0JVyjuvcmg4dE5mUiFtD24AZ4qBVELxXKS+pMxN43kSdzNwudJ+bQbLlmnxvPOQoCugSap1GnSRoG8KOiKbH+rIA0lEeSAg3y6eeQ6XI2nrYnrPM89bUTgI0Pdqvl50vlNbtZxDUBcLBK0kPd5jPziyLdojJIN0pq5/mdzwL4UVvVInV5ncQEPNOUxa9d0TU+CW5l+FoI0GSDKHVVSOs+0KOsZoxwOzSZNFGv0mQ9avyLCh2Hpm+70Y0YJoJVgmQv822wnDC8Miq6VjJ5IFed0QD1YiAbT+nQE8v/RMZfmgmcCRHIIu7Bmcp39oM9fqEychcA747KxQ/AEyqQonl7hATtJmnhO2XYtgcia01aSbVMenAXrIomPcLgEBA4liGBzFZAT8zBYqW6brI67wg8sFVhxBhwLwBP2+tqBQqqK7VJKGh/BRrfTr6nWL7nYBaZdBJHqrX3kPEPap56xwE/GvjJTRMADeMCdcGpGXL1Xh4ZL8BDOlWkUpegfi0CeDzeA5YITzEnddv+IXL+UYCmqIvqC9UlUC/ki9FipwVjunL3yX7dOTLeXmVMAhbsGporPfyOBTm/BJ23gTVehsvXRnSewagUfpBXF3p5pygKS7OceqTjb7h2vjr/XKm0ZofKSI2Q/J102wHzatZkJPYQ5JoKsuK+EoHJakVzubzuLQDepCKllTZi9AG0DYg9ZLxhFaZsOu7bvlmVI5oPXJMQJcHxHClSln1apFTvAimeg48u0RWFeZW4lVcjbQWZuIQK1KozZfIDO6CSQmQQXdpBaiKZyEWThVK1uEc6v7V7uK0ysduExPZx4vysDR+4SelhBYm0R6LBuR4PXts8MYMcJPsINo4YZCDLj0sgB0/vLpPXvA2Tn42Cv5rsLulGubzW0sEd3d4W/mJt2Kck+DzDMijfPLOjyrDhXSh852B+OvflqAkoyXO1cYfujtc/i3jJSAwhgfFlp20laMLOku/bC7prgqW7lCn4auE5NhcXPd3M7x70+IceSgZvNljCd9k3fLjYsPElqLR14PXQZqD2ZNkkrAB79UeJUebFQmXpf8ZcAQt2XrMQdyNUVBqZoUzAFyp3V3xi/MubUA/mCT4Fhf038PC8XplhWnCmnK/ZzyC2BSTRSqKVOuY2kB8Jia0lvvRIVoP+vVWJbYarf6p655E2/nANBMCWkgD49DA0VAMyI1OLFMYCXiU9bmzi9/y5i/vsaTpHPHidTofzLbM65vMPva9HlovgXp0AvjtaqYMfDD0/4mAsYE92pxa+9k1QgCnRVObCpojpzsKTPvayPetTEgBdwnssjuc0kOBFX+q3HwRQxdrOLAqeYRjkMk/trTSu2Z9Lik7CfF0AvjtqAhS4NHobGXUnB5DQs8hG8p/wMX1r4+8xkmyvQ50JVq72TVeXbz3HvpWaQJi57hJYTw4kGbtS+C2TigQUtZUX+X27QQq2ePBZBru/0lxTm8fOOQ5yaZOZMAV+he4FqIMB+LQB0UgMSajANX29j+vbmly8ipRvHeSQoQOkM5iFXcPQCVwDMs5RBCQmaPOyvbNd6uwvQJ183BZQG3Zc+Eiv7vQOKu8YeDmMcJlt2ckyftVeMIGLBCmdMHl/tFILYwGPjXWO3zOfSq/+om+oa7Mlh2fpSsRGLp7RAW3FUVjNHgiMhyE6zBFjM2BdkdJGO7nP1kJXWAtBuBpPIAu7f+hhu7bFXIuC5xWrf0X2xreykOsUyKkF2gwadbrXDcXrfKxR43zGcSj4t/cCgr+a1iy6EjE5GYktUCl9fwfMeylyooGF48bN2IGLTw8x7StS7sj8TF9FmPGWQhm3rRR+o9lhvjJvSYAdfDUevI1M6bnX/OwWaDMOQ8RPgKRo0eulBTdT8AW2kl8e9L7UHghHwMfLiZPNoSpx0yugpQZaFqKWqxVSM3a2pN1SAhC2jf94I7ybBI7EL5A2Wvu5ht3xsoEt4+Ay/abXgCQAxyOeDsDlTCQzy75ohcGgv9Tra9uiymRUYTLrswOLlCdfAQf7HPDQQ4ErAH5EDXB9cMxWYpjtXApRncojS0sbV/cCgHTHwGNBJy+1PQE2x56FpaVR7wfQGZ37V+V+19EiHNvR6q1fRUjqvbjbMq1/qfHxbTrE10ePY2gPFk48D2CVMTf1AF4PXvyYR9dV6Wf7H413m3xTWQvYGhQ7mfYwA5mAX+18Vue05v/8jG/fZX/IW5MKPKtjSYlt0ellxh+/BOCPAwYaeVr0QofZFxJWVWC8znG70au6llVmktsF0bfHF6k8fvZ5esZJbwHwwnjg59tXz6sL/P0NUZDuSNu1mnJ8Vab17+cy005A9wtOpp3i0bZdpJLUil00semAwN45LgEViZYe3amNye0B6A9chviSlzXVsFtyN5/1H3gaNmMpn8Fz0GpYFp6Zw615H/LpUuRQQDMCL82n5DpBSawkvzIdN2ypiT8nSLth8Pk9jnjwdFzH3W4XW6KMBfwB569NdcGX93mC16tTflcArcYUc/mFuYbV+8zY0SAjAVoNErNgWjtwumJ3wbn/HlBFYdxHvSkJJEc+Ngal9opSwyo9YlITX2C/P/+gf8sxURSLR+mcZUmeqaS9wrh6vxW5zxFCOqFi90RbDWq/YwZmnu1+a6OvdpvRqkNxxe44lyl4OobEnpKA6Uox5EfH9xzPs/HRKrTPWdIQrK1VZDU7ETiD3Obpl+8wPPCRBbkbwNtpW9AbBe5L1SMlj3tdTxk/9W47JUmqS5HU+JzYymUKXjtWVmT9RenIhgXc+nroWLyxXJhmL112OdB8GCsk4f8oZJucnvmmtR85mBn10GZ0EKSCMUSAR3ukcXd5s7LvLD3me61WkuTCpJzYAyRurMB44EdEJzTfU271lUJC03YjXJXzYOGZwN4D8eB5jlfLrdWfzGRW7icMPfiSO6Oe7s20bmhdgLX4Z23B+s3JgQESzUDiMboSzDMHFpNMwccGePauhfwjzwnI2wu9zKGgEFg80jcZ7MHllk07s1H+5yojtUQTlH4nFdLKTGwDmPbIklOb1L1zO4T6N8NCuDLFLS/C63c0eNRimZ++s5BMBHxU11jHchI9oFVUxRh/eMDzHEzGYu0Lg8gJ7oS/tFCwoic44fyUtix0n/46vP4bf+//BRgAYwDDar4ncHIAAAAASUVORK5CYII='; - } -} diff --git a/ThinkPHP/Library/Think/Build.class.php b/ThinkPHP/Library/Think/Build.class.php deleted file mode 100644 index 6528107..0000000 --- a/ThinkPHP/Library/Think/Build.class.php +++ /dev/null @@ -1,165 +0,0 @@ - -// +---------------------------------------------------------------------- -namespace Think; -/** - * 用于ThinkPHP的自动生成 - */ -class Build { - - static protected $controller = 'show(\'

          :)

          欢迎使用 ThinkPHP


          版本 V{$Think.version}
          \',\'utf-8\'); - } -}'; - - static protected $model = ''配置值'\n);":''); - // 写入模块配置文件 - if(!is_file(APP_PATH.$module.'/Conf/config'.CONF_EXT)) - file_put_contents(APP_PATH.$module.'/Conf/config'.CONF_EXT,'.php' == CONF_EXT ? "'配置值'\n);":''); - // 生成模块的测试控制器 - if(defined('BUILD_CONTROLLER_LIST')){ - // 自动生成的控制器列表(注意大小写) - $list = explode(',',BUILD_CONTROLLER_LIST); - foreach($list as $controller){ - self::buildController($module,$controller); - } - }else{ - // 生成默认的控制器 - self::buildController($module); - } - // 生成模块的模型 - if(defined('BUILD_MODEL_LIST')){ - // 自动生成的控制器列表(注意大小写) - $list = explode(',',BUILD_MODEL_LIST); - foreach($list as $model){ - self::buildModel($module,$model); - } - } - }else{ - header('Content-Type:text/html; charset=utf-8'); - exit('应用目录['.APP_PATH.']不可写,目录无法自动生成!
          请手动生成项目目录~'); - } - } - - // 检查缓存目录(Runtime) 如果不存在则自动创建 - static public function buildRuntime() { - if(!is_dir(RUNTIME_PATH)) { - mkdir(RUNTIME_PATH); - }elseif(!is_writeable(RUNTIME_PATH)) { - header('Content-Type:text/html; charset=utf-8'); - exit('目录 [ '.RUNTIME_PATH.' ] 不可写!'); - } - mkdir(CACHE_PATH); // 模板缓存目录 - if(!is_dir(LOG_PATH)) mkdir(LOG_PATH); // 日志目录 - if(!is_dir(TEMP_PATH)) mkdir(TEMP_PATH); // 数据缓存目录 - if(!is_dir(DATA_PATH)) mkdir(DATA_PATH); // 数据文件目录 - return true; - } - - // 创建控制器类 - static public function buildController($module,$controller='Index') { - $file = APP_PATH.$module.'/Controller/'.$controller.'Controller'.EXT; - if(!is_file($file)){ - $content = str_replace(array('[MODULE]','[CONTROLLER]'),array($module,$controller),self::$controller); - if(!C('APP_USE_NAMESPACE')){ - $content = preg_replace('/namespace\s(.*?);/','',$content,1); - } - $dir = dirname($file); - if(!is_dir($dir)){ - mkdir($dir, 0755, true); - } - file_put_contents($file,$content); - } - } - - // 创建模型类 - static public function buildModel($module,$model) { - $file = APP_PATH.$module.'/Model/'.$model.'Model'.EXT; - if(!is_file($file)){ - $content = str_replace(array('[MODULE]','[MODEL]'),array($module,$model),self::$model); - if(!C('APP_USE_NAMESPACE')){ - $content = preg_replace('/namespace\s(.*?);/','',$content,1); - } - $dir = dirname($file); - if(!is_dir($dir)){ - mkdir($dir, 0755, true); - } - file_put_contents($file,$content); - } - } - - // 生成目录安全文件 - static public function buildDirSecure($dirs=array()) { - // 目录安全写入(默认开启) - defined('BUILD_DIR_SECURE') or define('BUILD_DIR_SECURE', true); - if(BUILD_DIR_SECURE) { - defined('DIR_SECURE_FILENAME') or define('DIR_SECURE_FILENAME', 'index.html'); - defined('DIR_SECURE_CONTENT') or define('DIR_SECURE_CONTENT', ' '); - // 自动写入目录安全文件 - $content = DIR_SECURE_CONTENT; - $files = explode(',', DIR_SECURE_FILENAME); - foreach ($files as $filename){ - foreach ($dirs as $dir) - file_put_contents($dir.$filename,$content); - } - } - } -} diff --git a/ThinkPHP/Library/Think/Cache.class.php b/ThinkPHP/Library/Think/Cache.class.php deleted file mode 100644 index b098261..0000000 --- a/ThinkPHP/Library/Think/Cache.class.php +++ /dev/null @@ -1,127 +0,0 @@ - -// +---------------------------------------------------------------------- -namespace Think; -/** - * 缓存管理类 - */ -class Cache { - - /** - * 操作句柄 - * @var string - * @access protected - */ - protected $handler ; - - /** - * 缓存连接参数 - * @var integer - * @access protected - */ - protected $options = array(); - - /** - * 连接缓存 - * @access public - * @param string $type 缓存类型 - * @param array $options 配置数组 - * @return object - */ - public function connect($type='',$options=array()) { - if(empty($type)) $type = C('DATA_CACHE_TYPE'); - $class = strpos($type,'\\')? $type : 'Think\\Cache\\Driver\\'.ucwords(strtolower($type)); - if(class_exists($class)) - $cache = new $class($options); - else - E(L('_CACHE_TYPE_INVALID_').':'.$type); - return $cache; - } - - /** - * 取得缓存类实例 - * @static - * @access public - * @return mixed - */ - static function getInstance($type='',$options=array()) { - static $_instance = array(); - $guid = $type.to_guid_string($options); - if(!isset($_instance[$guid])){ - $obj = new Cache(); - $_instance[$guid] = $obj->connect($type,$options); - } - return $_instance[$guid]; - } - - public function __get($name) { - return $this->get($name); - } - - public function __set($name,$value) { - return $this->set($name,$value); - } - - public function __unset($name) { - $this->rm($name); - } - public function setOptions($name,$value) { - $this->options[$name] = $value; - } - - public function getOptions($name) { - return $this->options[$name]; - } - - /** - * 队列缓存 - * @access protected - * @param string $key 队列名 - * @return mixed - */ - // - protected function queue($key) { - static $_handler = array( - 'file' => array('F','F'), - 'xcache'=> array('xcache_get','xcache_set'), - 'apc' => array('apc_fetch','apc_store'), - ); - $queue = isset($this->options['queue'])?$this->options['queue']:'file'; - $fun = isset($_handler[$queue])?$_handler[$queue]:$_handler['file']; - $queue_name = isset($this->options['queue_name'])?$this->options['queue_name']:'think_queue'; - $value = $fun[0]($queue_name); - if(!$value) { - $value = array(); - } - // 进列 - if(false===array_search($key, $value)) array_push($value,$key); - if(count($value) > $this->options['length']) { - // 出列 - $key = array_shift($value); - // 删除缓存 - $this->rm($key); - if(APP_DEBUG){ - //调试模式下,记录出列次数 - N($queue_name.'_out_times',1); - } - } - return $fun[1]($queue_name,$value); - } - - public function __call($method,$args){ - //调用缓存类型自己的方法 - if(method_exists($this->handler, $method)){ - return call_user_func_array(array($this->handler,$method), $args); - }else{ - E(__CLASS__.':'.$method.L('_METHOD_NOT_EXIST_')); - return; - } - } -} \ No newline at end of file diff --git a/ThinkPHP/Library/Think/Cache/Driver/Apachenote.class.php b/ThinkPHP/Library/Think/Cache/Driver/Apachenote.class.php deleted file mode 100644 index 4ad3fd7..0000000 --- a/ThinkPHP/Library/Think/Cache/Driver/Apachenote.class.php +++ /dev/null @@ -1,124 +0,0 @@ - -// +---------------------------------------------------------------------- -namespace Think\Cache\Driver; -use Think\Cache; -defined('THINK_PATH') or exit(); -/** - * Apachenote缓存驱动 - */ -class Apachenote extends Cache { - - /** - * 架构函数 - * @param array $options 缓存参数 - * @access public - */ - public function __construct($options=array()) { - if(!empty($options)) { - $this->options = $options; - } - if(empty($options)) { - $options = array ( - 'host' => '127.0.0.1', - 'port' => 1042, - 'timeout' => 10, - ); - } - $this->options = $options; - $this->options['prefix'] = isset($options['prefix'])? $options['prefix'] : C('DATA_CACHE_PREFIX'); - $this->options['length'] = isset($options['length'])? $options['length'] : 0; - $this->handler = null; - $this->open(); - } - - /** - * 读取缓存 - * @access public - * @param string $name 缓存变量名 - * @return mixed - */ - public function get($name) { - $this->open(); - $name = $this->options['prefix'].$name; - $s = 'F' . pack('N', strlen($name)) . $name; - fwrite($this->handler, $s); - - for ($data = ''; !feof($this->handler);) { - $data .= fread($this->handler, 4096); - } - N('cache_read',1); - $this->close(); - return $data === '' ? '' : unserialize($data); - } - - /** - * 写入缓存 - * @access public - * @param string $name 缓存变量名 - * @param mixed $value 存储数据 - * @return boolean - */ - public function set($name, $value) { - N('cache_write',1); - $this->open(); - $value = serialize($value); - $name = $this->options['prefix'].$name; - $s = 'S' . pack('NN', strlen($name), strlen($value)) . $name . $value; - - fwrite($this->handler, $s); - $ret = fgets($this->handler); - $this->close(); - if($ret === "OK\n") { - if($this->options['length']>0) { - // 记录缓存队列 - $this->queue($name); - } - return true; - } - return false; - } - - /** - * 删除缓存 - * @access public - * @param string $name 缓存变量名 - * @return boolean - */ - public function rm($name) { - $this->open(); - $name = $this->options['prefix'].$name; - $s = 'D' . pack('N', strlen($name)) . $name; - fwrite($this->handler, $s); - $ret = fgets($this->handler); - $this->close(); - return $ret === "OK\n"; - } - - /** - * 关闭缓存 - * @access private - */ - private function close() { - fclose($this->handler); - $this->handler = false; - } - - /** - * 打开缓存 - * @access private - */ - private function open() { - if (!is_resource($this->handler)) { - $this->handler = fsockopen($this->options['host'], $this->options['port'], $_, $_, $this->options['timeout']); - } - } - -} \ No newline at end of file diff --git a/ThinkPHP/Library/Think/Cache/Driver/Apc.class.php b/ThinkPHP/Library/Think/Cache/Driver/Apc.class.php deleted file mode 100644 index 4ccb941..0000000 --- a/ThinkPHP/Library/Think/Cache/Driver/Apc.class.php +++ /dev/null @@ -1,86 +0,0 @@ - -// +---------------------------------------------------------------------- -namespace Think\Cache\Driver; -use Think\Cache; -defined('THINK_PATH') or exit(); -/** - * Apc缓存驱动 - */ -class Apc extends Cache { - - /** - * 架构函数 - * @param array $options 缓存参数 - * @access public - */ - public function __construct($options=array()) { - if(!function_exists('apc_cache_info')) { - E(L('_NOT_SUPPORT_').':Apc'); - } - $this->options['prefix'] = isset($options['prefix'])? $options['prefix'] : C('DATA_CACHE_PREFIX'); - $this->options['length'] = isset($options['length'])? $options['length'] : 0; - $this->options['expire'] = isset($options['expire'])? $options['expire'] : C('DATA_CACHE_TIME'); - } - - /** - * 读取缓存 - * @access public - * @param string $name 缓存变量名 - * @return mixed - */ - public function get($name) { - N('cache_read',1); - return apc_fetch($this->options['prefix'].$name); - } - - /** - * 写入缓存 - * @access public - * @param string $name 缓存变量名 - * @param mixed $value 存储数据 - * @param integer $expire 有效时间(秒) - * @return boolean - */ - public function set($name, $value, $expire = null) { - N('cache_write',1); - if(is_null($expire)) { - $expire = $this->options['expire']; - } - $name = $this->options['prefix'].$name; - if($result = apc_store($name, $value, $expire)) { - if($this->options['length']>0) { - // 记录缓存队列 - $this->queue($name); - } - } - return $result; - } - - /** - * 删除缓存 - * @access public - * @param string $name 缓存变量名 - * @return boolean - */ - public function rm($name) { - return apc_delete($this->options['prefix'].$name); - } - - /** - * 清除缓存 - * @access public - * @return boolean - */ - public function clear() { - return apc_clear_cache(); - } - -} diff --git a/ThinkPHP/Library/Think/Cache/Driver/Db.class.php b/ThinkPHP/Library/Think/Cache/Driver/Db.class.php deleted file mode 100644 index fc2f210..0000000 --- a/ThinkPHP/Library/Think/Cache/Driver/Db.class.php +++ /dev/null @@ -1,138 +0,0 @@ - -// +---------------------------------------------------------------------- -namespace Think\Cache\Driver; -use Think\Cache; -defined('THINK_PATH') or exit(); -/** - * 数据库方式缓存驱动 - * CREATE TABLE think_cache ( - * cachekey varchar(255) NOT NULL, - * expire int(11) NOT NULL, - * data blob, - * datacrc int(32), - * UNIQUE KEY `cachekey` (`cachekey`) - * ); - */ -class Db extends Cache { - - /** - * 架构函数 - * @param array $options 缓存参数 - * @access public - */ - public function __construct($options=array()) { - if(empty($options)) { - $options = array ( - 'table' => C('DATA_CACHE_TABLE'), - ); - } - $this->options = $options; - $this->options['prefix'] = isset($options['prefix'])? $options['prefix'] : C('DATA_CACHE_PREFIX'); - $this->options['length'] = isset($options['length'])? $options['length'] : 0; - $this->options['expire'] = isset($options['expire'])? $options['expire'] : C('DATA_CACHE_TIME'); - $this->handler = \Think\Db::getInstance(); - } - - /** - * 读取缓存 - * @access public - * @param string $name 缓存变量名 - * @return mixed - */ - public function get($name) { - $name = $this->options['prefix'].addslashes($name); - N('cache_read',1); - $result = $this->handler->query('SELECT `data`,`datacrc` FROM `'.$this->options['table'].'` WHERE `cachekey`=\''.$name.'\' AND (`expire` =0 OR `expire`>'.time().') LIMIT 0,1'); - if(false !== $result ) { - $result = $result[0]; - if(C('DATA_CACHE_CHECK')) {//开启数据校验 - if($result['datacrc'] != md5($result['data'])) {//校验错误 - return false; - } - } - $content = $result['data']; - if(C('DATA_CACHE_COMPRESS') && function_exists('gzcompress')) { - //启用数据压缩 - $content = gzuncompress($content); - } - $content = unserialize($content); - return $content; - } - else { - return false; - } - } - - /** - * 写入缓存 - * @access public - * @param string $name 缓存变量名 - * @param mixed $value 存储数据 - * @param integer $expire 有效时间(秒) - * @return boolean - */ - public function set($name, $value,$expire=null) { - $data = serialize($value); - $name = $this->options['prefix'].addslashes($name); - N('cache_write',1); - if( C('DATA_CACHE_COMPRESS') && function_exists('gzcompress')) { - //数据压缩 - $data = gzcompress($data,3); - } - if(C('DATA_CACHE_CHECK')) {//开启数据校验 - $crc = md5($data); - }else { - $crc = ''; - } - if(is_null($expire)) { - $expire = $this->options['expire']; - } - $expire = ($expire==0)?0: (time()+$expire) ;//缓存有效期为0表示永久缓存 - $result = $this->handler->query('select `cachekey` from `'.$this->options['table'].'` where `cachekey`=\''.$name.'\' limit 0,1'); - if(!empty($result) ) { - //更新记录 - $result = $this->handler->execute('UPDATE '.$this->options['table'].' SET data=\''.$data.'\' ,datacrc=\''.$crc.'\',expire='.$expire.' WHERE `cachekey`=\''.$name.'\''); - }else { - //新增记录 - $result = $this->handler->execute('INSERT INTO '.$this->options['table'].' (`cachekey`,`data`,`datacrc`,`expire`) VALUES (\''.$name.'\',\''.$data.'\',\''.$crc.'\','.$expire.')'); - } - if($result) { - if($this->options['length']>0) { - // 记录缓存队列 - $this->queue($name); - } - return true; - }else { - return false; - } - } - - /** - * 删除缓存 - * @access public - * @param string $name 缓存变量名 - * @return boolean - */ - public function rm($name) { - $name = $this->options['prefix'].addslashes($name); - return $this->handler->execute('DELETE FROM `'.$this->options['table'].'` WHERE `cachekey`=\''.$name.'\''); - } - - /** - * 清除缓存 - * @access public - * @return boolean - */ - public function clear() { - return $this->handler->execute('TRUNCATE TABLE `'.$this->options['table'].'`'); - } - -} \ No newline at end of file diff --git a/ThinkPHP/Library/Think/Cache/Driver/Eaccelerator.class.php b/ThinkPHP/Library/Think/Cache/Driver/Eaccelerator.class.php deleted file mode 100644 index 751ef24..0000000 --- a/ThinkPHP/Library/Think/Cache/Driver/Eaccelerator.class.php +++ /dev/null @@ -1,77 +0,0 @@ - -// +---------------------------------------------------------------------- -namespace Think\Cache\Driver; -use Think\Cache; -defined('THINK_PATH') or exit(); -/** - * Eaccelerator缓存驱动 - */ -class Eaccelerator extends Cache { - - /** - * 架构函数 - * @param array $options 缓存参数 - * @access public - */ - public function __construct($options=array()) { - $this->options['expire'] = isset($options['expire'])? $options['expire'] : C('DATA_CACHE_TIME'); - $this->options['prefix'] = isset($options['prefix'])? $options['prefix'] : C('DATA_CACHE_PREFIX'); - $this->options['length'] = isset($options['length'])? $options['length'] : 0; - } - - /** - * 读取缓存 - * @access public - * @param string $name 缓存变量名 - * @return mixed - */ - public function get($name) { - N('cache_read',1); - return eaccelerator_get($this->options['prefix'].$name); - } - - /** - * 写入缓存 - * @access public - * @param string $name 缓存变量名 - * @param mixed $value 存储数据 - * @param integer $expire 有效时间(秒) - * @return boolean - */ - public function set($name, $value, $expire = null) { - N('cache_write',1); - if(is_null($expire)) { - $expire = $this->options['expire']; - } - $name = $this->options['prefix'].$name; - eaccelerator_lock($name); - if(eaccelerator_put($name, $value, $expire)) { - if($this->options['length']>0) { - // 记录缓存队列 - $this->queue($name); - } - return true; - } - return false; - } - - - /** - * 删除缓存 - * @access public - * @param string $name 缓存变量名 - * @return boolean - */ - public function rm($name) { - return eaccelerator_rm($this->options['prefix'].$name); - } - -} \ No newline at end of file diff --git a/ThinkPHP/Library/Think/Cache/Driver/File.class.php b/ThinkPHP/Library/Think/Cache/Driver/File.class.php deleted file mode 100644 index c5c64ef..0000000 --- a/ThinkPHP/Library/Think/Cache/Driver/File.class.php +++ /dev/null @@ -1,181 +0,0 @@ - -// +---------------------------------------------------------------------- -namespace Think\Cache\Driver; -use Think\Cache; -defined('THINK_PATH') or exit(); -/** - * 文件类型缓存类 - */ -class File extends Cache { - - /** - * 架构函数 - * @access public - */ - public function __construct($options=array()) { - if(!empty($options)) { - $this->options = $options; - } - $this->options['temp'] = !empty($options['temp'])? $options['temp'] : C('DATA_CACHE_PATH'); - $this->options['prefix'] = isset($options['prefix'])? $options['prefix'] : C('DATA_CACHE_PREFIX'); - $this->options['expire'] = isset($options['expire'])? $options['expire'] : C('DATA_CACHE_TIME'); - $this->options['length'] = isset($options['length'])? $options['length'] : 0; - if(substr($this->options['temp'], -1) != '/') $this->options['temp'] .= '/'; - $this->init(); - } - - /** - * 初始化检查 - * @access private - * @return boolean - */ - private function init() { - // 创建应用缓存目录 - if (!is_dir($this->options['temp'])) { - mkdir($this->options['temp']); - } - } - - /** - * 取得变量的存储文件名 - * @access private - * @param string $name 缓存变量名 - * @return string - */ - private function filename($name) { - $name = md5(C('DATA_CACHE_KEY').$name); - if(C('DATA_CACHE_SUBDIR')) { - // 使用子目录 - $dir =''; - for($i=0;$ioptions['temp'].$dir)) { - mkdir($this->options['temp'].$dir,0755,true); - } - $filename = $dir.$this->options['prefix'].$name.'.php'; - }else{ - $filename = $this->options['prefix'].$name.'.php'; - } - return $this->options['temp'].$filename; - } - - /** - * 读取缓存 - * @access public - * @param string $name 缓存变量名 - * @return mixed - */ - public function get($name) { - $filename = $this->filename($name); - if (!is_file($filename)) { - return false; - } - N('cache_read',1); - $content = file_get_contents($filename); - if( false !== $content) { - $expire = (int)substr($content,8, 12); - if($expire != 0 && time() > filemtime($filename) + $expire) { - //缓存过期删除缓存文件 - unlink($filename); - return false; - } - if(C('DATA_CACHE_CHECK')) {//开启数据校验 - $check = substr($content,20, 32); - $content = substr($content,52, -3); - if($check != md5($content)) {//校验错误 - return false; - } - }else { - $content = substr($content,20, -3); - } - if(C('DATA_CACHE_COMPRESS') && function_exists('gzcompress')) { - //启用数据压缩 - $content = gzuncompress($content); - } - $content = unserialize($content); - return $content; - } - else { - return false; - } - } - - /** - * 写入缓存 - * @access public - * @param string $name 缓存变量名 - * @param mixed $value 存储数据 - * @param int $expire 有效时间 0为永久 - * @return boolean - */ - public function set($name,$value,$expire=null) { - N('cache_write',1); - if(is_null($expire)) { - $expire = $this->options['expire']; - } - $filename = $this->filename($name); - $data = serialize($value); - if( C('DATA_CACHE_COMPRESS') && function_exists('gzcompress')) { - //数据压缩 - $data = gzcompress($data,3); - } - if(C('DATA_CACHE_CHECK')) {//开启数据校验 - $check = md5($data); - }else { - $check = ''; - } - $data = ""; - $result = file_put_contents($filename,$data); - if($result) { - if($this->options['length']>0) { - // 记录缓存队列 - $this->queue($name); - } - clearstatcache(); - return true; - }else { - return false; - } - } - - /** - * 删除缓存 - * @access public - * @param string $name 缓存变量名 - * @return boolean - */ - public function rm($name) { - return unlink($this->filename($name)); - } - - /** - * 清除缓存 - * @access public - * @param string $name 缓存变量名 - * @return boolean - */ - public function clear() { - $path = $this->options['temp']; - $files = scandir($path); - if($files){ - foreach($files as $file){ - if ($file != '.' && $file != '..' && is_dir($path.$file) ){ - array_map( 'unlink', glob( $path.$file.'/*.*' ) ); - }elseif(is_file($path.$file)){ - unlink( $path . $file ); - } - } - return true; - } - return false; - } -} \ No newline at end of file diff --git a/ThinkPHP/Library/Think/Cache/Driver/Memcache.class.php b/ThinkPHP/Library/Think/Cache/Driver/Memcache.class.php deleted file mode 100644 index ff53ebe..0000000 --- a/ThinkPHP/Library/Think/Cache/Driver/Memcache.class.php +++ /dev/null @@ -1,103 +0,0 @@ - -// +---------------------------------------------------------------------- -namespace Think\Cache\Driver; -use Think\Cache; -defined('THINK_PATH') or exit(); -/** - * Memcache缓存驱动 - */ -class Memcache extends Cache { - - /** - * 架构函数 - * @param array $options 缓存参数 - * @access public - */ - function __construct($options=array()) { - if ( !extension_loaded('memcache') ) { - E(L('_NOT_SUPPORT_').':memcache'); - } - - $options = array_merge(array ( - 'host' => C('MEMCACHE_HOST') ? : '127.0.0.1', - 'port' => C('MEMCACHE_PORT') ? : 11211, - 'timeout' => C('DATA_CACHE_TIMEOUT') ? : false, - 'persistent' => false, - ),$options); - - $this->options = $options; - $this->options['expire'] = isset($options['expire'])? $options['expire'] : C('DATA_CACHE_TIME'); - $this->options['prefix'] = isset($options['prefix'])? $options['prefix'] : C('DATA_CACHE_PREFIX'); - $this->options['length'] = isset($options['length'])? $options['length'] : 0; - $func = $options['persistent'] ? 'pconnect' : 'connect'; - $this->handler = new \Memcache; - $options['timeout'] === false ? - $this->handler->$func($options['host'], $options['port']) : - $this->handler->$func($options['host'], $options['port'], $options['timeout']); - } - - /** - * 读取缓存 - * @access public - * @param string $name 缓存变量名 - * @return mixed - */ - public function get($name) { - N('cache_read',1); - return $this->handler->get($this->options['prefix'].$name); - } - - /** - * 写入缓存 - * @access public - * @param string $name 缓存变量名 - * @param mixed $value 存储数据 - * @param integer $expire 有效时间(秒) - * @return boolean - */ - public function set($name, $value, $expire = null) { - N('cache_write',1); - if(is_null($expire)) { - $expire = $this->options['expire']; - } - $name = $this->options['prefix'].$name; - if($this->handler->set($name, $value, 0, $expire)) { - if($this->options['length']>0) { - // 记录缓存队列 - $this->queue($name); - } - return true; - } - return false; - } - - /** - * 删除缓存 - * @access public - * @param string $name 缓存变量名 - * @return boolean - */ - public function rm($name, $ttl = false) { - $name = $this->options['prefix'].$name; - return $ttl === false ? - $this->handler->delete($name) : - $this->handler->delete($name, $ttl); - } - - /** - * 清除缓存 - * @access public - * @return boolean - */ - public function clear() { - return $this->handler->flush(); - } -} diff --git a/ThinkPHP/Library/Think/Cache/Driver/Memcached.class.php b/ThinkPHP/Library/Think/Cache/Driver/Memcached.class.php deleted file mode 100644 index 929bdca..0000000 --- a/ThinkPHP/Library/Think/Cache/Driver/Memcached.class.php +++ /dev/null @@ -1,102 +0,0 @@ - -// +---------------------------------------------------------------------- - -namespace Think\Cache\Driver; - -use Memcached as MemcachedResource; -use Think\Cache; - -/** - * Memcached缓存驱动 - */ -class Memcached extends Cache { - - /** - * - * @param array $options - */ - public function __construct($options = array()) { - if ( !extension_loaded('memcached') ) { - E(L('_NOT_SUPPORT_').':memcached'); - } - - $options = array_merge(array( - 'servers' => C('MEMCACHED_SERVER') ? : null, - 'lib_options' => C('MEMCACHED_LIB') ? : null - ), $options); - - $this->options = $options; - $this->options['expire'] = isset($options['expire'])? $options['expire'] : C('DATA_CACHE_TIME'); - $this->options['prefix'] = isset($options['prefix'])? $options['prefix'] : C('DATA_CACHE_PREFIX'); - $this->options['length'] = isset($options['length'])? $options['length'] : 0; - - $this->handler = new MemcachedResource; - $options['servers'] && $this->handler->addServers($options['servers']); - $options['lib_options'] && $this->handler->setOptions($options['lib_options']); - } - - /** - * 读取缓存 - * @access public - * @param string $name 缓存变量名 - * @return mixed - */ - public function get($name) { - N('cache_read',1); - return $this->handler->get($this->options['prefix'].$name); - } - - /** - * 写入缓存 - * @access public - * @param string $name 缓存变量名 - * @param mixed $value 存储数据 - * @param integer $expire 有效时间(秒) - * @return boolean - */ - public function set($name, $value, $expire = null) { - N('cache_write',1); - if(is_null($expire)) { - $expire = $this->options['expire']; - } - $name = $this->options['prefix'].$name; - if($this->handler->set($name, $value, time() + $expire)) { - if($this->options['length']>0) { - // 记录缓存队列 - $this->queue($name); - } - return true; - } - return false; - } - - /** - * 删除缓存 - * @access public - * @param string $name 缓存变量名 - * @return boolean - */ - public function rm($name, $ttl = false) { - $name = $this->options['prefix'].$name; - return $ttl === false ? - $this->handler->delete($name) : - $this->handler->delete($name, $ttl); - } - - /** - * 清除缓存 - * @access public - * @return boolean - */ - public function clear() { - return $this->handler->flush(); - } -} diff --git a/ThinkPHP/Library/Think/Cache/Driver/Memcachesae.class.php b/ThinkPHP/Library/Think/Cache/Driver/Memcachesae.class.php deleted file mode 100644 index a1d1c56..0000000 --- a/ThinkPHP/Library/Think/Cache/Driver/Memcachesae.class.php +++ /dev/null @@ -1,144 +0,0 @@ - -// +---------------------------------------------------------------------- -namespace Think\Cache\Driver; -use Think\Cache; - -defined('THINK_PATH') or exit(); -/** - * Memcache缓存驱动 - * @category Extend - * @package Extend - * @subpackage Driver.Cache - * @author liu21st - */ -class Memcachesae extends Cache { - - /** - * 架构函数 - * @param array $options 缓存参数 - * @access public - */ - function __construct($options=array()) { - $options = array_merge(array ( - 'host' => C('MEMCACHE_HOST') ? : '127.0.0.1', - 'port' => C('MEMCACHE_PORT') ? : 11211, - 'timeout' => C('DATA_CACHE_TIMEOUT') ? : false, - 'persistent' => false, - ),$options); - - $this->options = $options; - $this->options['expire'] = isset($options['expire'])? $options['expire'] : C('DATA_CACHE_TIME'); - $this->options['prefix'] = isset($options['prefix'])? $options['prefix'] : C('DATA_CACHE_PREFIX'); - $this->options['length'] = isset($options['length'])? $options['length'] : 0; - $this->handler = memcache_init();//[sae] 下实例化 - //[sae] 下不用链接 - $this->connected=true; - } - - /** - * 是否连接 - * @access private - * @return boolean - */ - private function isConnected() { - return $this->connected; - } - - /** - * 读取缓存 - * @access public - * @param string $name 缓存变量名 - * @return mixed - */ - public function get($name) { - N('cache_read',1); - return $this->handler->get($_SERVER['HTTP_APPVERSION'].'/'.$this->options['prefix'].$name); - } - - /** - * 写入缓存 - * @access public - * @param string $name 缓存变量名 - * @param mixed $value 存储数据 - * @param integer $expire 有效时间(秒) - * @return boolean - */ - public function set($name, $value, $expire = null) { - N('cache_write',1); - if(is_null($expire)) { - $expire = $this->options['expire']; - } - $name = $this->options['prefix'].$name; - if($this->handler->set($_SERVER['HTTP_APPVERSION'].'/'.$name, $value, 0, $expire)) { - if($this->options['length']>0) { - // 记录缓存队列 - $this->queue($name); - } - return true; - } - return false; - } - - /** - * 删除缓存 - * @access public - * @param string $name 缓存变量名 - * @return boolean - */ - public function rm($name, $ttl = false) { - $name = $_SERVER['HTTP_APPVERSION'].'/'.$this->options['prefix'].$name; - return $ttl === false ? - $this->handler->delete($name) : - $this->handler->delete($name, $ttl); - } - - /** - * 清除缓存 - * @access public - * @return boolean - */ - public function clear() { - return $this->handler->flush(); - } - - /** - * 队列缓存 - * @access protected - * @param string $key 队列名 - * @return mixed - */ - //[sae] 下重写queque队列缓存方法 - protected function queue($key) { - $queue_name=isset($this->options['queue_name'])?$this->options['queue_name']:'think_queue'; - $value = F($queue_name); - if(!$value) { - $value = array(); - } - // 进列 - if(false===array_search($key, $value)) array_push($value,$key); - if(count($value) > $this->options['length']) { - // 出列 - $key = array_shift($value); - // 删除缓存 - $this->rm($key); - if (APP_DEBUG) { - //调试模式下记录出队次数 - $counter = Think::instance('SaeCounter'); - if ($counter->exists($queue_name.'_out_times')) - $counter->incr($queue_name.'_out_times'); - else - $counter->create($queue_name.'_out_times', 1); - } - } - return F($queue_name,$value); - } - -} diff --git a/ThinkPHP/Library/Think/Cache/Driver/Redis.class.php b/ThinkPHP/Library/Think/Cache/Driver/Redis.class.php deleted file mode 100644 index 132cefb..0000000 --- a/ThinkPHP/Library/Think/Cache/Driver/Redis.class.php +++ /dev/null @@ -1,107 +0,0 @@ - -// +---------------------------------------------------------------------- -namespace Think\Cache\Driver; -use Think\Cache; -defined('THINK_PATH') or exit(); - -/** - * Redis缓存驱动 - * 要求安装phpredis扩展:https://github.com/nicolasff/phpredis - */ -class Redis extends Cache { - /** - * 架构函数 - * @param array $options 缓存参数 - * @access public - */ - public function __construct($options=array()) { - if ( !extension_loaded('redis') ) { - E(L('_NOT_SUPPORT_').':redis'); - } - $options = array_merge(array ( - 'host' => C('REDIS_HOST') ? : '127.0.0.1', - 'port' => C('REDIS_PORT') ? : 6379, - 'timeout' => C('DATA_CACHE_TIMEOUT') ? : false, - 'persistent' => false, - ),$options); - - $this->options = $options; - $this->options['expire'] = isset($options['expire'])? $options['expire'] : C('DATA_CACHE_TIME'); - $this->options['prefix'] = isset($options['prefix'])? $options['prefix'] : C('DATA_CACHE_PREFIX'); - $this->options['length'] = isset($options['length'])? $options['length'] : 0; - $func = $options['persistent'] ? 'pconnect' : 'connect'; - $this->handler = new \Redis; - $options['timeout'] === false ? - $this->handler->$func($options['host'], $options['port']) : - $this->handler->$func($options['host'], $options['port'], $options['timeout']); - } - - /** - * 读取缓存 - * @access public - * @param string $name 缓存变量名 - * @return mixed - */ - public function get($name) { - N('cache_read',1); - $value = $this->handler->get($this->options['prefix'].$name); - $jsonData = json_decode( $value, true ); - return ($jsonData === NULL) ? $value : $jsonData; //检测是否为JSON数据 true 返回JSON解析数组, false返回源数据 - } - - /** - * 写入缓存 - * @access public - * @param string $name 缓存变量名 - * @param mixed $value 存储数据 - * @param integer $expire 有效时间(秒) - * @return boolean - */ - public function set($name, $value, $expire = null) { - N('cache_write',1); - if(is_null($expire)) { - $expire = $this->options['expire']; - } - $name = $this->options['prefix'].$name; - //对数组/对象数据进行缓存处理,保证数据完整性 - $value = (is_object($value) || is_array($value)) ? json_encode($value) : $value; - if(is_int($expire) && $expire) { - $result = $this->handler->setex($name, $expire, $value); - }else{ - $result = $this->handler->set($name, $value); - } - if($result && $this->options['length']>0) { - // 记录缓存队列 - $this->queue($name); - } - return $result; - } - - /** - * 删除缓存 - * @access public - * @param string $name 缓存变量名 - * @return boolean - */ - public function rm($name) { - return $this->handler->delete($this->options['prefix'].$name); - } - - /** - * 清除缓存 - * @access public - * @return boolean - */ - public function clear() { - return $this->handler->flushDB(); - } - -} diff --git a/ThinkPHP/Library/Think/Cache/Driver/Shmop.class.php b/ThinkPHP/Library/Think/Cache/Driver/Shmop.class.php deleted file mode 100644 index 60927c3..0000000 --- a/ThinkPHP/Library/Think/Cache/Driver/Shmop.class.php +++ /dev/null @@ -1,186 +0,0 @@ - -// +---------------------------------------------------------------------- -namespace Think\Cache\Driver; -use Think\Cache; -defined('THINK_PATH') or exit(); -/** - * Shmop缓存驱动 - */ -class Shmop extends Cache { - - /** - * 架构函数 - * @param array $options 缓存参数 - * @access public - */ - public function __construct($options=array()) { - if ( !extension_loaded('shmop') ) { - E(L('_NOT_SUPPORT_').':shmop'); - } - if(!empty($options)){ - $options = array( - 'size' => C('SHARE_MEM_SIZE'), - 'temp' => TEMP_PATH, - 'project' => 's', - 'length' => 0, - ); - } - $this->options = $options; - $this->options['prefix'] = isset($options['prefix'])? $options['prefix'] : C('DATA_CACHE_PREFIX'); - $this->options['length'] = isset($options['length'])? $options['length'] : 0; - $this->handler = $this->_ftok($this->options['project']); - } - - /** - * 读取缓存 - * @access public - * @param string $name 缓存变量名 - * @return mixed - */ - public function get($name = false) { - N('cache_read',1); - $id = shmop_open($this->handler, 'c', 0600, 0); - if ($id !== false) { - $ret = unserialize(shmop_read($id, 0, shmop_size($id))); - shmop_close($id); - - if ($name === false) { - return $ret; - } - $name = $this->options['prefix'].$name; - if(isset($ret[$name])) { - $content = $ret[$name]; - if(C('DATA_CACHE_COMPRESS') && function_exists('gzcompress')) { - //启用数据压缩 - $content = gzuncompress($content); - } - return $content; - }else { - return null; - } - }else { - return false; - } - } - - /** - * 写入缓存 - * @access public - * @param string $name 缓存变量名 - * @param mixed $value 存储数据 - * @return boolean - */ - public function set($name, $value) { - N('cache_write',1); - $lh = $this->_lock(); - $val = $this->get(); - if (!is_array($val)) $val = array(); - if( C('DATA_CACHE_COMPRESS') && function_exists('gzcompress')) { - //数据压缩 - $value = gzcompress($value,3); - } - $name = $this->options['prefix'].$name; - $val[$name] = $value; - $val = serialize($val); - if($this->_write($val, $lh)) { - if($this->options['length']>0) { - // 记录缓存队列 - $this->queue($name); - } - return true; - } - return false; - } - - /** - * 删除缓存 - * @access public - * @param string $name 缓存变量名 - * @return boolean - */ - public function rm($name) { - $lh = $this->_lock(); - $val = $this->get(); - if (!is_array($val)) $val = array(); - $name = $this->options['prefix'].$name; - unset($val[$name]); - $val = serialize($val); - return $this->_write($val, $lh); - } - - /** - * 生成IPC key - * @access private - * @param string $project 项目标识名 - * @return integer - */ - private function _ftok($project) { - if (function_exists('ftok')) return ftok(__FILE__, $project); - if(strtoupper(PHP_OS) == 'WINNT'){ - $s = stat(__FILE__); - return sprintf("%u", (($s['ino'] & 0xffff) | (($s['dev'] & 0xff) << 16) | - (($project & 0xff) << 24))); - }else { - $filename = __FILE__ . (string) $project; - for($key = array(); sizeof($key) < strlen($filename); $key[] = ord(substr($filename, sizeof($key), 1))); - return dechex(array_sum($key)); - } - } - - /** - * 写入操作 - * @access private - * @param string $name 缓存变量名 - * @return integer|boolean - */ - private function _write(&$val, &$lh) { - $id = shmop_open($this->handler, 'c', 0600, $this->options['size']); - if ($id) { - $ret = shmop_write($id, $val, 0) == strlen($val); - shmop_close($id); - $this->_unlock($lh); - return $ret; - } - $this->_unlock($lh); - return false; - } - - /** - * 共享锁定 - * @access private - * @param string $name 缓存变量名 - * @return boolean - */ - private function _lock() { - if (function_exists('sem_get')) { - $fp = sem_get($this->handler, 1, 0600, 1); - sem_acquire ($fp); - } else { - $fp = fopen($this->options['temp'].$this->options['prefix'].md5($this->handler), 'w'); - flock($fp, LOCK_EX); - } - return $fp; - } - - /** - * 解除共享锁定 - * @access private - * @param string $name 缓存变量名 - * @return boolean - */ - private function _unlock(&$fp) { - if (function_exists('sem_release')) { - sem_release($fp); - } else { - fclose($fp); - } - } -} diff --git a/ThinkPHP/Library/Think/Cache/Driver/Sqlite.class.php b/ThinkPHP/Library/Think/Cache/Driver/Sqlite.class.php deleted file mode 100644 index 33bd222..0000000 --- a/ThinkPHP/Library/Think/Cache/Driver/Sqlite.class.php +++ /dev/null @@ -1,119 +0,0 @@ - -// +---------------------------------------------------------------------- -namespace Think\Cache\Driver; -use Think\Cache; -defined('THINK_PATH') or exit(); -/** - * Sqlite缓存驱动 - */ -class Sqlite extends Cache { - - /** - * 架构函数 - * @param array $options 缓存参数 - * @access public - */ - public function __construct($options=array()) { - if ( !extension_loaded('sqlite') ) { - E(L('_NOT_SUPPORT_').':sqlite'); - } - if(empty($options)) { - $options = array ( - 'db' => ':memory:', - 'table' => 'sharedmemory', - ); - } - $this->options = $options; - $this->options['prefix'] = isset($options['prefix'])? $options['prefix'] : C('DATA_CACHE_PREFIX'); - $this->options['length'] = isset($options['length'])? $options['length'] : 0; - $this->options['expire'] = isset($options['expire'])? $options['expire'] : C('DATA_CACHE_TIME'); - - $func = $this->options['persistent'] ? 'sqlite_popen' : 'sqlite_open'; - $this->handler = $func($this->options['db']); - } - - /** - * 读取缓存 - * @access public - * @param string $name 缓存变量名 - * @return mixed - */ - public function get($name) { - N('cache_read',1); - $name = $this->options['prefix'].sqlite_escape_string($name); - $sql = 'SELECT value FROM '.$this->options['table'].' WHERE var=\''.$name.'\' AND (expire=0 OR expire >'.time().') LIMIT 1'; - $result = sqlite_query($this->handler, $sql); - if (sqlite_num_rows($result)) { - $content = sqlite_fetch_single($result); - if(C('DATA_CACHE_COMPRESS') && function_exists('gzcompress')) { - //启用数据压缩 - $content = gzuncompress($content); - } - return unserialize($content); - } - return false; - } - - /** - * 写入缓存 - * @access public - * @param string $name 缓存变量名 - * @param mixed $value 存储数据 - * @param integer $expire 有效时间(秒) - * @return boolean - */ - public function set($name, $value,$expire=null) { - N('cache_write',1); - $name = $this->options['prefix'].sqlite_escape_string($name); - $value = sqlite_escape_string(serialize($value)); - if(is_null($expire)) { - $expire = $this->options['expire']; - } - $expire = ($expire==0)?0: (time()+$expire) ;//缓存有效期为0表示永久缓存 - if( C('DATA_CACHE_COMPRESS') && function_exists('gzcompress')) { - //数据压缩 - $value = gzcompress($value,3); - } - $sql = 'REPLACE INTO '.$this->options['table'].' (var, value,expire) VALUES (\''.$name.'\', \''.$value.'\', \''.$expire.'\')'; - if(sqlite_query($this->handler, $sql)){ - if($this->options['length']>0) { - // 记录缓存队列 - $this->queue($name); - } - return true; - } - return false; - } - - /** - * 删除缓存 - * @access public - * @param string $name 缓存变量名 - * @return boolean - */ - public function rm($name) { - $name = $this->options['prefix'].sqlite_escape_string($name); - $sql = 'DELETE FROM '.$this->options['table'].' WHERE var=\''.$name.'\''; - sqlite_query($this->handler, $sql); - return true; - } - - /** - * 清除缓存 - * @access public - * @return boolean - */ - public function clear() { - $sql = 'DELETE FROM '.$this->options['table']; - sqlite_query($this->handler, $sql); - return ; - } -} diff --git a/ThinkPHP/Library/Think/Cache/Driver/Wincache.class.php b/ThinkPHP/Library/Think/Cache/Driver/Wincache.class.php deleted file mode 100644 index 9d118e9..0000000 --- a/ThinkPHP/Library/Think/Cache/Driver/Wincache.class.php +++ /dev/null @@ -1,88 +0,0 @@ - -// +---------------------------------------------------------------------- -namespace Think\Cache\Driver; -use Think\Cache; -defined('THINK_PATH') or exit(); -/** - * Wincache缓存驱动 - */ -class Wincache extends Cache { - - /** - * 架构函数 - * @param array $options 缓存参数 - * @access public - */ - public function __construct($options=array()) { - if ( !function_exists('wincache_ucache_info') ) { - E(L('_NOT_SUPPORT_').':WinCache'); - } - $this->options['expire'] = isset($options['expire'])? $options['expire'] : C('DATA_CACHE_TIME'); - $this->options['prefix'] = isset($options['prefix'])? $options['prefix'] : C('DATA_CACHE_PREFIX'); - $this->options['length'] = isset($options['length'])? $options['length'] : 0; - } - - /** - * 读取缓存 - * @access public - * @param string $name 缓存变量名 - * @return mixed - */ - public function get($name) { - N('cache_read',1); - $name = $this->options['prefix'].$name; - return wincache_ucache_exists($name)? wincache_ucache_get($name) : false; - } - - /** - * 写入缓存 - * @access public - * @param string $name 缓存变量名 - * @param mixed $value 存储数据 - * @param integer $expire 有效时间(秒) - * @return boolean - */ - public function set($name, $value,$expire=null) { - N('cache_write',1); - if(is_null($expire)) { - $expire = $this->options['expire']; - } - $name = $this->options['prefix'].$name; - if(wincache_ucache_set($name, $value, $expire)) { - if($this->options['length']>0) { - // 记录缓存队列 - $this->queue($name); - } - return true; - } - return false; - } - - /** - * 删除缓存 - * @access public - * @param string $name 缓存变量名 - * @return boolean - */ - public function rm($name) { - return wincache_ucache_delete($this->options['prefix'].$name); - } - - /** - * 清除缓存 - * @access public - * @return boolean - */ - public function clear() { - return wincache_ucache_clear(); - } - -} diff --git a/ThinkPHP/Library/Think/Cache/Driver/Xcache.class.php b/ThinkPHP/Library/Think/Cache/Driver/Xcache.class.php deleted file mode 100644 index ccb1fdd..0000000 --- a/ThinkPHP/Library/Think/Cache/Driver/Xcache.class.php +++ /dev/null @@ -1,90 +0,0 @@ - -// +---------------------------------------------------------------------- -namespace Think\Cache\Driver; -use Think\Cache; -defined('THINK_PATH') or exit(); -/** - * Xcache缓存驱动 - */ -class Xcache extends Cache { - - /** - * 架构函数 - * @param array $options 缓存参数 - * @access public - */ - public function __construct($options=array()) { - if ( !function_exists('xcache_info') ) { - E(L('_NOT_SUPPORT_').':Xcache'); - } - $this->options['expire'] = isset($options['expire'])?$options['expire']:C('DATA_CACHE_TIME'); - $this->options['prefix'] = isset($options['prefix'])?$options['prefix']:C('DATA_CACHE_PREFIX'); - $this->options['length'] = isset($options['length'])?$options['length']:0; - } - - /** - * 读取缓存 - * @access public - * @param string $name 缓存变量名 - * @return mixed - */ - public function get($name) { - N('cache_read',1); - $name = $this->options['prefix'].$name; - if (xcache_isset($name)) { - return xcache_get($name); - } - return false; - } - - /** - * 写入缓存 - * @access public - * @param string $name 缓存变量名 - * @param mixed $value 存储数据 - * @param integer $expire 有效时间(秒) - * @return boolean - */ - public function set($name, $value,$expire=null) { - N('cache_write',1); - if(is_null($expire)) { - $expire = $this->options['expire'] ; - } - $name = $this->options['prefix'].$name; - if(xcache_set($name, $value, $expire)) { - if($this->options['length']>0) { - // 记录缓存队列 - $this->queue($name); - } - return true; - } - return false; - } - - /** - * 删除缓存 - * @access public - * @param string $name 缓存变量名 - * @return boolean - */ - public function rm($name) { - return xcache_unset($this->options['prefix'].$name); - } - - /** - * 清除缓存 - * @access public - * @return boolean - */ - public function clear() { - return xcache_clear_cache(1, -1); - } -} diff --git a/ThinkPHP/Library/Think/Controller.class.php b/ThinkPHP/Library/Think/Controller.class.php deleted file mode 100644 index ce0f2a1..0000000 --- a/ThinkPHP/Library/Think/Controller.class.php +++ /dev/null @@ -1,307 +0,0 @@ - -// +---------------------------------------------------------------------- -namespace Think; -/** - * ThinkPHP 控制器基类 抽象类 - */ -abstract class Controller { - - /** - * 视图实例对象 - * @var view - * @access protected - */ - protected $view = null; - - /** - * 控制器参数 - * @var config - * @access protected - */ - protected $config = array(); - - /** - * 架构函数 取得模板对象实例 - * @access public - */ - public function __construct() { - Hook::listen('action_begin',$this->config); - //实例化视图类 - $this->view = Think::instance('Think\View'); - //控制器初始化 - if(method_exists($this,'_initialize')) - $this->_initialize(); - } - - /** - * 模板显示 调用内置的模板引擎显示方法, - * @access protected - * @param string $templateFile 指定要调用的模板文件 - * 默认为空 由系统自动定位模板文件 - * @param string $charset 输出编码 - * @param string $contentType 输出类型 - * @param string $content 输出内容 - * @param string $prefix 模板缓存前缀 - * @return void - */ - protected function display($templateFile='',$charset='',$contentType='',$content='',$prefix='') { - $this->view->display($templateFile,$charset,$contentType,$content,$prefix); - } - - /** - * 输出内容文本可以包括Html 并支持内容解析 - * @access protected - * @param string $content 输出内容 - * @param string $charset 模板输出字符集 - * @param string $contentType 输出类型 - * @param string $prefix 模板缓存前缀 - * @return mixed - */ - protected function show($content,$charset='',$contentType='',$prefix='') { - $this->view->display('',$charset,$contentType,$content,$prefix); - } - - /** - * 获取输出页面内容 - * 调用内置的模板引擎fetch方法, - * @access protected - * @param string $templateFile 指定要调用的模板文件 - * 默认为空 由系统自动定位模板文件 - * @param string $content 模板输出内容 - * @param string $prefix 模板缓存前缀* - * @return string - */ - protected function fetch($templateFile='',$content='',$prefix='') { - return $this->view->fetch($templateFile,$content,$prefix); - } - - /** - * 创建静态页面 - * @access protected - * @htmlfile 生成的静态文件名称 - * @htmlpath 生成的静态文件路径 - * @param string $templateFile 指定要调用的模板文件 - * 默认为空 由系统自动定位模板文件 - * @return string - */ - protected function buildHtml($htmlfile='',$htmlpath='',$templateFile='') { - $content = $this->fetch($templateFile); - $htmlpath = !empty($htmlpath)?$htmlpath:HTML_PATH; - $htmlfile = $htmlpath.$htmlfile.C('HTML_FILE_SUFFIX'); - Storage::put($htmlfile,$content,'html'); - return $content; - } - - /** - * 模板主题设置 - * @access protected - * @param string $theme 模版主题 - * @return Action - */ - protected function theme($theme){ - $this->view->theme($theme); - return $this; - } - - /** - * 模板变量赋值 - * @access protected - * @param mixed $name 要显示的模板变量 - * @param mixed $value 变量的值 - * @return Action - */ - protected function assign($name,$value='') { - $this->view->assign($name,$value); - return $this; - } - - public function __set($name,$value) { - $this->assign($name,$value); - } - - /** - * 取得模板显示变量的值 - * @access protected - * @param string $name 模板显示变量 - * @return mixed - */ - public function get($name='') { - return $this->view->get($name); - } - - public function __get($name) { - return $this->get($name); - } - - /** - * 检测模板变量的值 - * @access public - * @param string $name 名称 - * @return boolean - */ - public function __isset($name) { - return $this->get($name); - } - - /** - * 魔术方法 有不存在的操作的时候执行 - * @access public - * @param string $method 方法名 - * @param array $args 参数 - * @return mixed - */ - public function __call($method,$args) { - if( 0 === strcasecmp($method,ACTION_NAME.C('ACTION_SUFFIX'))) { - if(method_exists($this,'_empty')) { - // 如果定义了_empty操作 则调用 - $this->_empty($method,$args); - }elseif(file_exists_case($this->view->parseTemplate())){ - // 检查是否存在默认模版 如果有直接输出模版 - $this->display(); - }else{ - E(L('_ERROR_ACTION_').':'.ACTION_NAME); - } - }else{ - E(__CLASS__.':'.$method.L('_METHOD_NOT_EXIST_')); - return; - } - } - - /** - * 操作错误跳转的快捷方法 - * @access protected - * @param string $message 错误信息 - * @param string $jumpUrl 页面跳转地址 - * @param mixed $ajax 是否为Ajax方式 当数字时指定跳转时间 - * @return void - */ - protected function error($message='',$jumpUrl='',$ajax=false) { - $this->dispatchJump($message,0,$jumpUrl,$ajax); - } - - /** - * 操作成功跳转的快捷方法 - * @access protected - * @param string $message 提示信息 - * @param string $jumpUrl 页面跳转地址 - * @param mixed $ajax 是否为Ajax方式 当数字时指定跳转时间 - * @return void - */ - protected function success($message='',$jumpUrl='',$ajax=false) { - $this->dispatchJump($message,1,$jumpUrl,$ajax); - } - - /** - * Ajax方式返回数据到客户端 - * @access protected - * @param mixed $data 要返回的数据 - * @param String $type AJAX返回数据格式 - * @param int $json_option 传递给json_encode的option参数 - * @return void - */ - protected function ajaxReturn($data,$type='',$json_option=0) { - if(empty($type)) $type = C('DEFAULT_AJAX_RETURN'); - switch (strtoupper($type)){ - case 'JSON' : - // 返回JSON数据格式到客户端 包含状态信息 - header('Content-Type:application/json; charset=utf-8'); - exit(json_encode($data,$json_option)); - case 'XML' : - // 返回xml格式数据 - header('Content-Type:text/xml; charset=utf-8'); - exit(xml_encode($data)); - case 'JSONP': - // 返回JSON数据格式到客户端 包含状态信息 - header('Content-Type:application/json; charset=utf-8'); - $handler = isset($_GET[C('VAR_JSONP_HANDLER')]) ? $_GET[C('VAR_JSONP_HANDLER')] : C('DEFAULT_JSONP_HANDLER'); - exit($handler.'('.json_encode($data,$json_option).');'); - case 'EVAL' : - // 返回可执行的js脚本 - header('Content-Type:text/html; charset=utf-8'); - exit($data); - default : - // 用于扩展其他返回格式数据 - Hook::listen('ajax_return',$data); - } - } - - /** - * Action跳转(URL重定向) 支持指定模块和延时跳转 - * @access protected - * @param string $url 跳转的URL表达式 - * @param array $params 其它URL参数 - * @param integer $delay 延时跳转的时间 单位为秒 - * @param string $msg 跳转提示信息 - * @return void - */ - protected function redirect($url,$params=array(),$delay=0,$msg='') { - $url = U($url,$params); - redirect($url,$delay,$msg); - } - - /** - * 默认跳转操作 支持错误导向和正确跳转 - * 调用模板显示 默认为public目录下面的success页面 - * 提示页面为可配置 支持模板标签 - * @param string $message 提示信息 - * @param Boolean $status 状态 - * @param string $jumpUrl 页面跳转地址 - * @param mixed $ajax 是否为Ajax方式 当数字时指定跳转时间 - * @access private - * @return void - */ - private function dispatchJump($message,$status=1,$jumpUrl='',$ajax=false) { - if(true === $ajax || IS_AJAX) {// AJAX提交 - $data = is_array($ajax)?$ajax:array(); - $data['info'] = $message; - $data['status'] = $status; - $data['url'] = $jumpUrl; - $this->ajaxReturn($data); - } - if(is_int($ajax)) $this->assign('waitSecond',$ajax); - if(!empty($jumpUrl)) $this->assign('jumpUrl',$jumpUrl); - // 提示标题 - $this->assign('msgTitle',$status? L('_OPERATION_SUCCESS_') : L('_OPERATION_FAIL_')); - //如果设置了关闭窗口,则提示完毕后自动关闭窗口 - if($this->get('closeWin')) $this->assign('jumpUrl','javascript:window.close();'); - $this->assign('status',$status); // 状态 - //保证输出不受静态缓存影响 - C('HTML_CACHE_ON',false); - if($status) { //发送成功信息 - $this->assign('message',$message);// 提示信息 - // 成功操作后默认停留1秒 - if(!isset($this->waitSecond)) $this->assign('waitSecond','1'); - // 默认操作成功自动返回操作前页面 - if(!isset($this->jumpUrl)) $this->assign("jumpUrl",$_SERVER["HTTP_REFERER"]); - $this->display(C('TMPL_ACTION_SUCCESS')); - }else{ - $this->assign('error',$message);// 提示信息 - //发生错误时候默认停留3秒 - if(!isset($this->waitSecond)) $this->assign('waitSecond','3'); - // 默认发生错误的话自动返回上页 - if(!isset($this->jumpUrl)) $this->assign('jumpUrl',"javascript:history.back(-1);"); - $this->display(C('TMPL_ACTION_ERROR')); - // 中止执行 避免出错后继续执行 - exit ; - } - } - - /** - * 析构方法 - * @access public - */ - public function __destruct() { - // 执行后续操作 - Hook::listen('action_end'); - } -} -// 设置控制器别名 便于升级 -class_alias('Think\Controller','Think\Action'); diff --git a/ThinkPHP/Library/Think/Db.class.php b/ThinkPHP/Library/Think/Db.class.php deleted file mode 100644 index 5c46e2f..0000000 --- a/ThinkPHP/Library/Think/Db.class.php +++ /dev/null @@ -1,137 +0,0 @@ - -// +---------------------------------------------------------------------- - -namespace Think; - -/** - * ThinkPHP 数据库中间层实现类 - */ -class Db { - - static private $instance = array(); // 数据库连接实例 - static private $_instance = null; // 当前数据库连接实例 - - /** - * 取得数据库类实例 - * @static - * @access public - * @param mixed $config 连接配置 - * @return Object 返回数据库驱动类 - */ - static public function getInstance($config=array()) { - $md5 = md5(serialize($config)); - if(!isset(self::$instance[$md5])) { - // 解析连接参数 支持数组和字符串 - $options = self::parseConfig($config); - // 兼容mysqli - if('mysqli' == $options['type']) $options['type'] = 'mysql'; - // 如果采用lite方式 仅支持原生SQL 包括query和execute方法 - $class = !empty($options['lite'])? 'Think\Db\Lite' : 'Think\\Db\\Driver\\'.ucwords(strtolower($options['type'])); - if(class_exists($class)){ - self::$instance[$md5] = new $class($options); - }else{ - // 类没有定义 - E(L('_NO_DB_DRIVER_').': ' . $class); - } - } - self::$_instance = self::$instance[$md5]; - return self::$_instance; - } - - /** - * 数据库连接参数解析 - * @static - * @access private - * @param mixed $config - * @return array - */ - static private function parseConfig($config){ - if(!empty($config)){ - if(is_string($config)) { - return self::parseDsn($config); - } - $config = array_change_key_case($config); - $config = array ( - 'type' => $config['db_type'], - 'username' => $config['db_user'], - 'password' => $config['db_pwd'], - 'hostname' => $config['db_host'], - 'hostport' => $config['db_port'], - 'database' => $config['db_name'], - 'dsn' => isset($config['db_dsn'])?$config['db_dsn']:null, - 'params' => isset($config['db_params'])?$config['db_params']:null, - 'charset' => isset($config['db_charset'])?$config['db_charset']:'utf8', - 'deploy' => isset($config['db_deploy_type'])?$config['db_deploy_type']:0, - 'rw_separate' => isset($config['db_rw_separate'])?$config['db_rw_separate']:false, - 'master_num' => isset($config['db_master_num'])?$config['db_master_num']:1, - 'slave_no' => isset($config['db_slave_no'])?$config['db_slave_no']:'', - 'debug' => isset($config['db_debug'])?$config['db_debug']:APP_DEBUG, - 'lite' => isset($config['db_lite'])?$config['db_lite']:false, - ); - }else { - $config = array ( - 'type' => C('DB_TYPE'), - 'username' => C('DB_USER'), - 'password' => C('DB_PWD'), - 'hostname' => C('DB_HOST'), - 'hostport' => C('DB_PORT'), - 'database' => C('DB_NAME'), - 'dsn' => C('DB_DSN'), - 'params' => C('DB_PARAMS'), - 'charset' => C('DB_CHARSET'), - 'deploy' => C('DB_DEPLOY_TYPE'), - 'rw_separate' => C('DB_RW_SEPARATE'), - 'master_num' => C('DB_MASTER_NUM'), - 'slave_no' => C('DB_SLAVE_NO'), - 'debug' => C('DB_DEBUG',null,APP_DEBUG), - 'lite' => C('DB_LITE'), - ); - } - return $config; - } - - /** - * DSN解析 - * 格式: mysql://username:passwd@localhost:3306/DbName?param1=val1¶m2=val2#utf8 - * @static - * @access private - * @param string $dsnStr - * @return array - */ - static private function parseDsn($dsnStr) { - if( empty($dsnStr) ){return false;} - $info = parse_url($dsnStr); - if(!$info) { - return false; - } - $dsn = array( - 'type' => $info['scheme'], - 'username' => isset($info['user']) ? $info['user'] : '', - 'password' => isset($info['pass']) ? $info['pass'] : '', - 'hostname' => isset($info['host']) ? $info['host'] : '', - 'hostport' => isset($info['port']) ? $info['port'] : '', - 'database' => isset($info['path']) ? substr($info['path'],1) : '', - 'charset' => isset($info['fragment'])?$info['fragment']:'utf8', - ); - - if(isset($info['query'])) { - parse_str($info['query'],$dsn['params']); - }else{ - $dsn['params'] = array(); - } - return $dsn; - } - - // 调用驱动类的方法 - static public function __callStatic($method, $params){ - return call_user_func_array(array(self::$_instance, $method), $params); - } -} diff --git a/ThinkPHP/Library/Think/Db/Driver.class.php b/ThinkPHP/Library/Think/Db/Driver.class.php deleted file mode 100644 index 42d835d..0000000 --- a/ThinkPHP/Library/Think/Db/Driver.class.php +++ /dev/null @@ -1,1148 +0,0 @@ - -// +---------------------------------------------------------------------- - -namespace Think\Db; -use Think\Config; -use Think\Debug; -use Think\Log; -use PDO; - -abstract class Driver { - // PDO操作实例 - protected $PDOStatement = null; - // 当前操作所属的模型名 - protected $model = '_think_'; - // 当前SQL指令 - protected $queryStr = ''; - protected $modelSql = array(); - // 最后插入ID - protected $lastInsID = null; - // 返回或者影响记录数 - protected $numRows = 0; - // 事务指令数 - protected $transTimes = 0; - // 错误信息 - protected $error = ''; - // 数据库连接ID 支持多个连接 - protected $linkID = array(); - // 当前连接ID - protected $_linkID = null; - // 数据库连接参数配置 - protected $config = array( - 'type' => '', // 数据库类型 - 'hostname' => '127.0.0.1', // 服务器地址 - 'database' => '', // 数据库名 - 'username' => '', // 用户名 - 'password' => '', // 密码 - 'hostport' => '', // 端口 - 'dsn' => '', // - 'params' => array(), // 数据库连接参数 - 'charset' => 'utf8', // 数据库编码默认采用utf8 - 'prefix' => '', // 数据库表前缀 - 'debug' => false, // 数据库调试模式 - 'deploy' => 0, // 数据库部署方式:0 集中式(单一服务器),1 分布式(主从服务器) - 'rw_separate' => false, // 数据库读写是否分离 主从式有效 - 'master_num' => 1, // 读写分离后 主服务器数量 - 'slave_no' => '', // 指定从服务器序号 - 'db_like_fields' => '', - ); - // 数据库表达式 - protected $exp = array('eq'=>'=','neq'=>'<>','gt'=>'>','egt'=>'>=','lt'=>'<','elt'=>'<=','notlike'=>'NOT LIKE','like'=>'LIKE','in'=>'IN','notin'=>'NOT IN','not in'=>'NOT IN','between'=>'BETWEEN','not between'=>'NOT BETWEEN','notbetween'=>'NOT BETWEEN'); - // 查询表达式 - protected $selectSql = 'SELECT%DISTINCT% %FIELD% FROM %TABLE%%FORCE%%JOIN%%WHERE%%GROUP%%HAVING%%ORDER%%LIMIT% %UNION%%LOCK%%COMMENT%'; - // 查询次数 - protected $queryTimes = 0; - // 执行次数 - protected $executeTimes = 0; - // PDO连接参数 - protected $options = array( - PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, - PDO::ATTR_ORACLE_NULLS => PDO::NULL_NATURAL, - PDO::ATTR_STRINGIFY_FETCHES => false, - ); - protected $bind = array(); // 参数绑定 - - /** - * 架构函数 读取数据库配置信息 - * @access public - * @param array $config 数据库配置数组 - */ - public function __construct($config=''){ - if(!empty($config)) { - $this->config = array_merge($this->config,$config); - if(is_array($this->config['params'])){ - $this->options = $this->config['params'] + $this->options; - } - } - } - - /** - * 连接数据库方法 - * @access public - */ - public function connect($config='',$linkNum=0,$autoConnection=false) { - if ( !isset($this->linkID[$linkNum]) ) { - if(empty($config)) $config = $this->config; - try{ - if(empty($config['dsn'])) { - $config['dsn'] = $this->parseDsn($config); - } - if(version_compare(PHP_VERSION,'5.3.6','<=')){ - // 禁用模拟预处理语句 - $this->options[PDO::ATTR_EMULATE_PREPARES] = false; - } - $this->linkID[$linkNum] = new PDO( $config['dsn'], $config['username'], $config['password'],$this->options); - }catch (\PDOException $e) { - if($autoConnection){ - trace($e->getMessage(),'','ERR'); - return $this->connect($autoConnection,$linkNum); - }elseif($config['debug']){ - E($e->getMessage()); - } - } - } - return $this->linkID[$linkNum]; - } - - /** - * 解析pdo连接的dsn信息 - * @access public - * @param array $config 连接信息 - * @return string - */ - protected function parseDsn($config){} - - /** - * 释放查询结果 - * @access public - */ - public function free() { - $this->PDOStatement = null; - } - - /** - * 执行查询 返回数据集 - * @access public - * @param string $str sql指令 - * @param boolean $fetchSql 不执行只是获取SQL - * @return mixed - */ - public function query($str,$fetchSql=false) { - $this->initConnect(false); - if ( !$this->_linkID ) return false; - $this->queryStr = $str; - if(!empty($this->bind)){ - $that = $this; - $this->queryStr = strtr($this->queryStr,array_map(function($val) use($that){ return '\''.$that->escapeString($val).'\''; },$this->bind)); - } - if($fetchSql){ - return $this->queryStr; - } - //释放前次的查询结果 - if ( !empty($this->PDOStatement) ) $this->free(); - $this->queryTimes++; - N('db_query',1); // 兼容代码 - // 调试开始 - $this->debug(true); - $this->PDOStatement = $this->_linkID->prepare($str); - if(false === $this->PDOStatement){ - $this->error(); - return false; - } - foreach ($this->bind as $key => $val) { - if(is_array($val)){ - $this->PDOStatement->bindValue($key, $val[0], $val[1]); - }else{ - $this->PDOStatement->bindValue($key, $val); - } - } - $this->bind = array(); - try{ - $result = $this->PDOStatement->execute(); - // 调试结束 - $this->debug(false); - if ( false === $result ) { - $this->error(); - return false; - } else { - return $this->getResult(); - } - }catch (\PDOException $e) { - $this->error(); - return false; - } - } - - /** - * 执行语句 - * @access public - * @param string $str sql指令 - * @param boolean $fetchSql 不执行只是获取SQL - * @return mixed - */ - public function execute($str,$fetchSql=false) { - $this->initConnect(true); - if ( !$this->_linkID ) return false; - $this->queryStr = $str; - if(!empty($this->bind)){ - $that = $this; - $this->queryStr = strtr($this->queryStr,array_map(function($val) use($that){ return '\''.$that->escapeString($val).'\''; },$this->bind)); - } - if($fetchSql){ - return $this->queryStr; - } - //释放前次的查询结果 - if ( !empty($this->PDOStatement) ) $this->free(); - $this->executeTimes++; - N('db_write',1); // 兼容代码 - // 记录开始执行时间 - $this->debug(true); - $this->PDOStatement = $this->_linkID->prepare($str); - if(false === $this->PDOStatement) { - $this->error(); - return false; - } - foreach ($this->bind as $key => $val) { - if(is_array($val)){ - $this->PDOStatement->bindValue($key, $val[0], $val[1]); - }else{ - $this->PDOStatement->bindValue($key, $val); - } - } - $this->bind = array(); - try{ - $result = $this->PDOStatement->execute(); - // 调试结束 - $this->debug(false); - if ( false === $result) { - $this->error(); - return false; - } else { - $this->numRows = $this->PDOStatement->rowCount(); - if(preg_match("/^\s*(INSERT\s+INTO|REPLACE\s+INTO)\s+/i", $str)) { - $this->lastInsID = $this->_linkID->lastInsertId(); - } - return $this->numRows; - } - }catch (\PDOException $e) { - $this->error(); - return false; - } - } - - /** - * 启动事务 - * @access public - * @return void - */ - public function startTrans() { - $this->initConnect(true); - if ( !$this->_linkID ) return false; - //数据rollback 支持 - if ($this->transTimes == 0) { - $this->_linkID->beginTransaction(); - } - $this->transTimes++; - return ; - } - - /** - * 用于非自动提交状态下面的查询提交 - * @access public - * @return boolean - */ - public function commit() { - if ($this->transTimes > 0) { - $result = $this->_linkID->commit(); - $this->transTimes = 0; - if(!$result){ - $this->error(); - return false; - } - } - return true; - } - - /** - * 事务回滚 - * @access public - * @return boolean - */ - public function rollback() { - if ($this->transTimes > 0) { - $result = $this->_linkID->rollback(); - $this->transTimes = 0; - if(!$result){ - $this->error(); - return false; - } - } - return true; - } - - /** - * 获得所有的查询数据 - * @access private - * @return array - */ - private function getResult() { - //返回数据集 - $result = $this->PDOStatement->fetchAll(PDO::FETCH_ASSOC); - $this->numRows = count( $result ); - return $result; - } - - /** - * 获得查询次数 - * @access public - * @param boolean $execute 是否包含所有查询 - * @return integer - */ - public function getQueryTimes($execute=false){ - return $execute?$this->queryTimes+$this->executeTimes:$this->queryTimes; - } - - /** - * 获得执行次数 - * @access public - * @return integer - */ - public function getExecuteTimes(){ - return $this->executeTimes; - } - - /** - * 关闭数据库 - * @access public - */ - public function close() { - $this->_linkID = null; - } - - /** - * 数据库错误信息 - * 并显示当前的SQL语句 - * @access public - * @return string - */ - public function error() { - if($this->PDOStatement) { - $error = $this->PDOStatement->errorInfo(); - $this->error = $error[1].':'.$error[2]; - }else{ - $this->error = ''; - } - if('' != $this->queryStr){ - $this->error .= "\n [ SQL语句 ] : ".$this->queryStr; - } - // 记录错误日志 - trace($this->error,'','ERR'); - if($this->config['debug']) {// 开启数据库调试模式 - E($this->error); - }else{ - return $this->error; - } - } - - /** - * 设置锁机制 - * @access protected - * @return string - */ - protected function parseLock($lock=false) { - return $lock? ' FOR UPDATE ' : ''; - } - - /** - * set分析 - * @access protected - * @param array $data - * @return string - */ - protected function parseSet($data) { - foreach ($data as $key=>$val){ - if(is_array($val) && 'exp' == $val[0]){ - $set[] = $this->parseKey($key).'='.$val[1]; - }elseif(is_null($val)){ - $set[] = $this->parseKey($key).'=NULL'; - }elseif(is_scalar($val)) {// 过滤非标量数据 - if(0===strpos($val,':') && in_array($val,array_keys($this->bind)) ){ - $set[] = $this->parseKey($key).'='.$this->escapeString($val); - }else{ - $name = count($this->bind); - $set[] = $this->parseKey($key).'=:'.$name; - $this->bindParam($name,$val); - } - } - } - return ' SET '.implode(',',$set); - } - - /** - * 参数绑定 - * @access protected - * @param string $name 绑定参数名 - * @param mixed $value 绑定值 - * @return void - */ - protected function bindParam($name,$value){ - $this->bind[':'.$name] = $value; - } - - /** - * 字段名分析 - * @access protected - * @param string $key - * @return string - */ - protected function parseKey(&$key) { - return $key; - } - - /** - * value分析 - * @access protected - * @param mixed $value - * @return string - */ - protected function parseValue($value) { - if(is_string($value)) { - $value = strpos($value,':') === 0 && in_array($value,array_keys($this->bind))? $this->escapeString($value) : '\''.$this->escapeString($value).'\''; - }elseif(isset($value[0]) && is_string($value[0]) && strtolower($value[0]) == 'exp'){ - $value = $this->escapeString($value[1]); - }elseif(is_array($value)) { - $value = array_map(array($this, 'parseValue'),$value); - }elseif(is_bool($value)){ - $value = $value ? '1' : '0'; - }elseif(is_null($value)){ - $value = 'null'; - } - return $value; - } - - /** - * field分析 - * @access protected - * @param mixed $fields - * @return string - */ - protected function parseField($fields) { - if(is_string($fields) && '' !== $fields) { - $fields = explode(',',$fields); - } - if(is_array($fields)) { - // 完善数组方式传字段名的支持 - // 支持 'field1'=>'field2' 这样的字段别名定义 - $array = array(); - foreach ($fields as $key=>$field){ - if(!is_numeric($key)) - $array[] = $this->parseKey($key).' AS '.$this->parseKey($field); - else - $array[] = $this->parseKey($field); - } - $fieldsStr = implode(',', $array); - }else{ - $fieldsStr = '*'; - } - //TODO 如果是查询全部字段,并且是join的方式,那么就把要查的表加个别名,以免字段被覆盖 - return $fieldsStr; - } - - /** - * table分析 - * @access protected - * @param mixed $table - * @return string - */ - protected function parseTable($tables) { - if(is_array($tables)) {// 支持别名定义 - $array = array(); - foreach ($tables as $table=>$alias){ - if(!is_numeric($table)) - $array[] = $this->parseKey($table).' '.$this->parseKey($alias); - else - $array[] = $this->parseKey($alias); - } - $tables = $array; - }elseif(is_string($tables)){ - $tables = explode(',',$tables); - array_walk($tables, array(&$this, 'parseKey')); - } - return implode(',',$tables); - } - - /** - * where分析 - * @access protected - * @param mixed $where - * @return string - */ - protected function parseWhere($where) { - $whereStr = ''; - if(is_string($where)) { - // 直接使用字符串条件 - $whereStr = $where; - }else{ // 使用数组表达式 - $operate = isset($where['_logic'])?strtoupper($where['_logic']):''; - if(in_array($operate,array('AND','OR','XOR'))){ - // 定义逻辑运算规则 例如 OR XOR AND NOT - $operate = ' '.$operate.' '; - unset($where['_logic']); - }else{ - // 默认进行 AND 运算 - $operate = ' AND '; - } - foreach ($where as $key=>$val){ - if(is_numeric($key)){ - $key = '_complex'; - } - if(0===strpos($key,'_')) { - // 解析特殊条件表达式 - $whereStr .= $this->parseThinkWhere($key,$val); - }else{ - // 查询字段的安全过滤 - // if(!preg_match('/^[A-Z_\|\&\-.a-z0-9\(\)\,]+$/',trim($key))){ - // E(L('_EXPRESS_ERROR_').':'.$key); - // } - // 多条件支持 - $multi = is_array($val) && isset($val['_multi']); - $key = trim($key); - if(strpos($key,'|')) { // 支持 name|title|nickname 方式定义查询字段 - $array = explode('|',$key); - $str = array(); - foreach ($array as $m=>$k){ - $v = $multi?$val[$m]:$val; - $str[] = $this->parseWhereItem($this->parseKey($k),$v); - } - $whereStr .= '( '.implode(' OR ',$str).' )'; - }elseif(strpos($key,'&')){ - $array = explode('&',$key); - $str = array(); - foreach ($array as $m=>$k){ - $v = $multi?$val[$m]:$val; - $str[] = '('.$this->parseWhereItem($this->parseKey($k),$v).')'; - } - $whereStr .= '( '.implode(' AND ',$str).' )'; - }else{ - $whereStr .= $this->parseWhereItem($this->parseKey($key),$val); - } - } - $whereStr .= $operate; - } - $whereStr = substr($whereStr,0,-strlen($operate)); - } - return empty($whereStr)?'':' WHERE '.$whereStr; - } - - // where子单元分析 - protected function parseWhereItem($key,$val) { - $whereStr = ''; - if(is_array($val)) { - if(is_string($val[0])) { - $exp = strtolower($val[0]); - if(preg_match('/^(eq|neq|gt|egt|lt|elt)$/',$exp)) { // 比较运算 - $whereStr .= $key.' '.$this->exp[$exp].' '.$this->parseValue($val[1]); - }elseif(preg_match('/^(notlike|like)$/',$exp)){// 模糊查找 - if(is_array($val[1])) { - $likeLogic = isset($val[2])?strtoupper($val[2]):'OR'; - if(in_array($likeLogic,array('AND','OR','XOR'))){ - $like = array(); - foreach ($val[1] as $item){ - $like[] = $key.' '.$this->exp[$exp].' '.$this->parseValue($item); - } - $whereStr .= '('.implode(' '.$likeLogic.' ',$like).')'; - } - }else{ - $whereStr .= $key.' '.$this->exp[$exp].' '.$this->parseValue($val[1]); - } - }elseif('bind' == $exp ){ // 使用表达式 - $whereStr .= $key.' = :'.$val[1]; - }elseif('exp' == $exp ){ // 使用表达式 - $whereStr .= $key.' '.$val[1]; - }elseif(preg_match('/^(notin|not in|in)$/',$exp)){ // IN 运算 - if(isset($val[2]) && 'exp'==$val[2]) { - $whereStr .= $key.' '.$this->exp[$exp].' '.$val[1]; - }else{ - if(is_string($val[1])) { - $val[1] = explode(',',$val[1]); - } - $zone = implode(',',$this->parseValue($val[1])); - $whereStr .= $key.' '.$this->exp[$exp].' ('.$zone.')'; - } - }elseif(preg_match('/^(notbetween|not between|between)$/',$exp)){ // BETWEEN运算 - $data = is_string($val[1])? explode(',',$val[1]):$val[1]; - $whereStr .= $key.' '.$this->exp[$exp].' '.$this->parseValue($data[0]).' AND '.$this->parseValue($data[1]); - }else{ - E(L('_EXPRESS_ERROR_').':'.$val[0]); - } - }else { - $count = count($val); - $rule = isset($val[$count-1]) ? (is_array($val[$count-1]) ? strtoupper($val[$count-1][0]) : strtoupper($val[$count-1]) ) : '' ; - if(in_array($rule,array('AND','OR','XOR'))) { - $count = $count -1; - }else{ - $rule = 'AND'; - } - for($i=0;$i<$count;$i++) { - $data = is_array($val[$i])?$val[$i][1]:$val[$i]; - if('exp'==strtolower($val[$i][0])) { - $whereStr .= $key.' '.$data.' '.$rule.' '; - }else{ - $whereStr .= $this->parseWhereItem($key,$val[$i]).' '.$rule.' '; - } - } - $whereStr = '( '.substr($whereStr,0,-4).' )'; - } - }else { - //对字符串类型字段采用模糊匹配 - $likeFields = $this->config['db_like_fields']; - if($likeFields && preg_match('/^('.$likeFields.')$/i',$key)) { - $whereStr .= $key.' LIKE '.$this->parseValue('%'.$val.'%'); - }else { - $whereStr .= $key.' = '.$this->parseValue($val); - } - } - return $whereStr; - } - - /** - * 特殊条件分析 - * @access protected - * @param string $key - * @param mixed $val - * @return string - */ - protected function parseThinkWhere($key,$val) { - $whereStr = ''; - switch($key) { - case '_string': - // 字符串模式查询条件 - $whereStr = $val; - break; - case '_complex': - // 复合查询条件 - $whereStr = substr($this->parseWhere($val),6); - break; - case '_query': - // 字符串模式查询条件 - parse_str($val,$where); - if(isset($where['_logic'])) { - $op = ' '.strtoupper($where['_logic']).' '; - unset($where['_logic']); - }else{ - $op = ' AND '; - } - $array = array(); - foreach ($where as $field=>$data) - $array[] = $this->parseKey($field).' = '.$this->parseValue($data); - $whereStr = implode($op,$array); - break; - } - return '( '.$whereStr.' )'; - } - - /** - * limit分析 - * @access protected - * @param mixed $lmit - * @return string - */ - protected function parseLimit($limit) { - return !empty($limit)? ' LIMIT '.$limit.' ':''; - } - - /** - * join分析 - * @access protected - * @param mixed $join - * @return string - */ - protected function parseJoin($join) { - $joinStr = ''; - if(!empty($join)) { - $joinStr = ' '.implode(' ',$join).' '; - } - return $joinStr; - } - - /** - * order分析 - * @access protected - * @param mixed $order - * @return string - */ - protected function parseOrder($order) { - if(is_array($order)) { - $array = array(); - foreach ($order as $key=>$val){ - if(is_numeric($key)) { - $array[] = $this->parseKey($val); - }else{ - $array[] = $this->parseKey($key).' '.$val; - } - } - $order = implode(',',$array); - } - return !empty($order)? ' ORDER BY '.$order:''; - } - - /** - * group分析 - * @access protected - * @param mixed $group - * @return string - */ - protected function parseGroup($group) { - return !empty($group)? ' GROUP BY '.$group:''; - } - - /** - * having分析 - * @access protected - * @param string $having - * @return string - */ - protected function parseHaving($having) { - return !empty($having)? ' HAVING '.$having:''; - } - - /** - * comment分析 - * @access protected - * @param string $comment - * @return string - */ - protected function parseComment($comment) { - return !empty($comment)? ' /* '.$comment.' */':''; - } - - /** - * distinct分析 - * @access protected - * @param mixed $distinct - * @return string - */ - protected function parseDistinct($distinct) { - return !empty($distinct)? ' DISTINCT ' :''; - } - - /** - * union分析 - * @access protected - * @param mixed $union - * @return string - */ - protected function parseUnion($union) { - if(empty($union)) return ''; - if(isset($union['_all'])) { - $str = 'UNION ALL '; - unset($union['_all']); - }else{ - $str = 'UNION '; - } - foreach ($union as $u){ - $sql[] = $str.(is_array($u)?$this->buildSelectSql($u):$u); - } - return implode(' ',$sql); - } - - /** - * 参数绑定分析 - * @access protected - * @param array $bind - * @return array - */ - protected function parseBind($bind){ - $this->bind = array_merge($this->bind,$bind); - } - - /** - * index分析,可在操作链中指定需要强制使用的索引 - * @access protected - * @param mixed $index - * @return string - */ - protected function parseForce($index) { - if(empty($index)) return ''; - if(is_array($index)) $index = join(",", $index); - return sprintf(" FORCE INDEX ( %s ) ", $index); - } - - /** - * ON DUPLICATE KEY UPDATE 分析 - * @access protected - * @param mixed $duplicate - * @return string - */ - protected function parseDuplicate($duplicate){ - return ''; - } - - /** - * 插入记录 - * @access public - * @param mixed $data 数据 - * @param array $options 参数表达式 - * @param boolean $replace 是否replace - * @return false | integer - */ - public function insert($data,$options=array(),$replace=false) { - $values = $fields = array(); - $this->model = $options['model']; - $this->parseBind(!empty($options['bind'])?$options['bind']:array()); - foreach ($data as $key=>$val){ - if(is_array($val) && 'exp' == $val[0]){ - $fields[] = $this->parseKey($key); - $values[] = $val[1]; - }elseif(is_null($val)){ - $fields[] = $this->parseKey($key); - $values[] = 'NULL'; - }elseif(is_scalar($val)) { // 过滤非标量数据 - $fields[] = $this->parseKey($key); - if(0===strpos($val,':') && in_array($val,array_keys($this->bind))){ - $values[] = $this->parseValue($val); - }else{ - $name = count($this->bind); - $values[] = ':'.$name; - $this->bindParam($name,$val); - } - } - } - // 兼容数字传入方式 - $replace= (is_numeric($replace) && $replace>0)?true:$replace; - $sql = (true===$replace?'REPLACE':'INSERT').' INTO '.$this->parseTable($options['table']).' ('.implode(',', $fields).') VALUES ('.implode(',', $values).')'.$this->parseDuplicate($replace); - $sql .= $this->parseComment(!empty($options['comment'])?$options['comment']:''); - return $this->execute($sql,!empty($options['fetch_sql']) ? true : false); - } - - - /** - * 批量插入记录 - * @access public - * @param mixed $dataSet 数据集 - * @param array $options 参数表达式 - * @param boolean $replace 是否replace - * @return false | integer - */ - public function insertAll($dataSet,$options=array(),$replace=false) { - $values = array(); - $this->model = $options['model']; - if(!is_array($dataSet[0])) return false; - $this->parseBind(!empty($options['bind'])?$options['bind']:array()); - $fields = array_map(array($this,'parseKey'),array_keys($dataSet[0])); - foreach ($dataSet as $data){ - $value = array(); - foreach ($data as $key=>$val){ - if(is_array($val) && 'exp' == $val[0]){ - $value[] = $val[1]; - }elseif(is_null($val)){ - $value[] = 'NULL'; - }elseif(is_scalar($val)){ - if(0===strpos($val,':') && in_array($val,array_keys($this->bind))){ - $value[] = $this->parseValue($val); - }else{ - $name = count($this->bind); - $value[] = ':'.$name; - $this->bindParam($name,$val); - } - } - } - $values[] = 'SELECT '.implode(',', $value); - } - $sql = 'INSERT INTO '.$this->parseTable($options['table']).' ('.implode(',', $fields).') '.implode(' UNION ALL ',$values); - $sql .= $this->parseComment(!empty($options['comment'])?$options['comment']:''); - return $this->execute($sql,!empty($options['fetch_sql']) ? true : false); - } - - /** - * 通过Select方式插入记录 - * @access public - * @param string $fields 要插入的数据表字段名 - * @param string $table 要插入的数据表名 - * @param array $option 查询数据参数 - * @return false | integer - */ - public function selectInsert($fields,$table,$options=array()) { - $this->model = $options['model']; - $this->parseBind(!empty($options['bind'])?$options['bind']:array()); - if(is_string($fields)) $fields = explode(',',$fields); - array_walk($fields, array($this, 'parseKey')); - $sql = 'INSERT INTO '.$this->parseTable($table).' ('.implode(',', $fields).') '; - $sql .= $this->buildSelectSql($options); - return $this->execute($sql,!empty($options['fetch_sql']) ? true : false); - } - - /** - * 更新记录 - * @access public - * @param mixed $data 数据 - * @param array $options 表达式 - * @return false | integer - */ - public function update($data,$options) { - $this->model = $options['model']; - $this->parseBind(!empty($options['bind'])?$options['bind']:array()); - $table = $this->parseTable($options['table']); - $sql = 'UPDATE ' . $table . $this->parseSet($data); - if(strpos($table,',')){// 多表更新支持JOIN操作 - $sql .= $this->parseJoin(!empty($options['join'])?$options['join']:''); - } - $sql .= $this->parseWhere(!empty($options['where'])?$options['where']:''); - if(!strpos($table,',')){ - // 单表更新支持order和lmit - $sql .= $this->parseOrder(!empty($options['order'])?$options['order']:'') - .$this->parseLimit(!empty($options['limit'])?$options['limit']:''); - } - $sql .= $this->parseComment(!empty($options['comment'])?$options['comment']:''); - return $this->execute($sql,!empty($options['fetch_sql']) ? true : false); - } - - /** - * 删除记录 - * @access public - * @param array $options 表达式 - * @return false | integer - */ - public function delete($options=array()) { - $this->model = $options['model']; - $this->parseBind(!empty($options['bind'])?$options['bind']:array()); - $table = $this->parseTable($options['table']); - $sql = 'DELETE FROM '.$table; - if(strpos($table,',')){// 多表删除支持USING和JOIN操作 - if(!empty($options['using'])){ - $sql .= ' USING '.$this->parseTable($options['using']).' '; - } - $sql .= $this->parseJoin(!empty($options['join'])?$options['join']:''); - } - $sql .= $this->parseWhere(!empty($options['where'])?$options['where']:''); - if(!strpos($table,',')){ - // 单表删除支持order和limit - $sql .= $this->parseOrder(!empty($options['order'])?$options['order']:'') - .$this->parseLimit(!empty($options['limit'])?$options['limit']:''); - } - $sql .= $this->parseComment(!empty($options['comment'])?$options['comment']:''); - return $this->execute($sql,!empty($options['fetch_sql']) ? true : false); - } - - /** - * 查找记录 - * @access public - * @param array $options 表达式 - * @return mixed - */ - public function select($options=array()) { - $this->model = $options['model']; - $this->parseBind(!empty($options['bind'])?$options['bind']:array()); - $sql = $this->buildSelectSql($options); - $result = $this->query($sql,!empty($options['fetch_sql']) ? true : false); - return $result; - } - - /** - * 生成查询SQL - * @access public - * @param array $options 表达式 - * @return string - */ - public function buildSelectSql($options=array()) { - if(isset($options['page'])) { - // 根据页数计算limit - list($page,$listRows) = $options['page']; - $page = $page>0 ? $page : 1; - $listRows= $listRows>0 ? $listRows : (is_numeric($options['limit'])?$options['limit']:20); - $offset = $listRows*($page-1); - $options['limit'] = $offset.','.$listRows; - } - $sql = $this->parseSql($this->selectSql,$options); - return $sql; - } - - /** - * 替换SQL语句中表达式 - * @access public - * @param array $options 表达式 - * @return string - */ - public function parseSql($sql,$options=array()){ - $sql = str_replace( - array('%TABLE%','%DISTINCT%','%FIELD%','%JOIN%','%WHERE%','%GROUP%','%HAVING%','%ORDER%','%LIMIT%','%UNION%','%LOCK%','%COMMENT%','%FORCE%'), - array( - $this->parseTable($options['table']), - $this->parseDistinct(isset($options['distinct'])?$options['distinct']:false), - $this->parseField(!empty($options['field'])?$options['field']:'*'), - $this->parseJoin(!empty($options['join'])?$options['join']:''), - $this->parseWhere(!empty($options['where'])?$options['where']:''), - $this->parseGroup(!empty($options['group'])?$options['group']:''), - $this->parseHaving(!empty($options['having'])?$options['having']:''), - $this->parseOrder(!empty($options['order'])?$options['order']:''), - $this->parseLimit(!empty($options['limit'])?$options['limit']:''), - $this->parseUnion(!empty($options['union'])?$options['union']:''), - $this->parseLock(isset($options['lock'])?$options['lock']:false), - $this->parseComment(!empty($options['comment'])?$options['comment']:''), - $this->parseForce(!empty($options['force'])?$options['force']:'') - ),$sql); - return $sql; - } - - /** - * 获取最近一次查询的sql语句 - * @param string $model 模型名 - * @access public - * @return string - */ - public function getLastSql($model='') { - return $model?$this->modelSql[$model]:$this->queryStr; - } - - /** - * 获取最近插入的ID - * @access public - * @return string - */ - public function getLastInsID() { - return $this->lastInsID; - } - - /** - * 获取最近的错误信息 - * @access public - * @return string - */ - public function getError() { - return $this->error; - } - - /** - * SQL指令安全过滤 - * @access public - * @param string $str SQL字符串 - * @return string - */ - public function escapeString($str) { - return addslashes($str); - } - - /** - * 设置当前操作模型 - * @access public - * @param string $model 模型名 - * @return void - */ - public function setModel($model){ - $this->model = $model; - } - - /** - * 数据库调试 记录当前SQL - * @access protected - * @param boolean $start 调试开始标记 true 开始 false 结束 - */ - protected function debug($start) { - if($this->config['debug']) {// 开启数据库调试模式 - if($start) { - G('queryStartTime'); - }else{ - $this->modelSql[$this->model] = $this->queryStr; - //$this->model = '_think_'; - // 记录操作结束时间 - G('queryEndTime'); - trace($this->queryStr.' [ RunTime:'.G('queryStartTime','queryEndTime').'s ]','','SQL'); - } - } - } - - /** - * 初始化数据库连接 - * @access protected - * @param boolean $master 主服务器 - * @return void - */ - protected function initConnect($master=true) { - if(!empty($this->config['deploy'])) - // 采用分布式数据库 - $this->_linkID = $this->multiConnect($master); - else - // 默认单数据库 - if ( !$this->_linkID ) $this->_linkID = $this->connect(); - } - - /** - * 连接分布式服务器 - * @access protected - * @param boolean $master 主服务器 - * @return void - */ - protected function multiConnect($master=false) { - // 分布式数据库配置解析 - $_config['username'] = explode(',',$this->config['username']); - $_config['password'] = explode(',',$this->config['password']); - $_config['hostname'] = explode(',',$this->config['hostname']); - $_config['hostport'] = explode(',',$this->config['hostport']); - $_config['database'] = explode(',',$this->config['database']); - $_config['dsn'] = explode(',',$this->config['dsn']); - $_config['charset'] = explode(',',$this->config['charset']); - - $m = floor(mt_rand(0,$this->config['master_num']-1)); - // 数据库读写是否分离 - if($this->config['rw_separate']){ - // 主从式采用读写分离 - if($master) - // 主服务器写入 - $r = $m; - else{ - if(is_numeric($this->config['slave_no'])) {// 指定服务器读 - $r = $this->config['slave_no']; - }else{ - // 读操作连接从服务器 - $r = floor(mt_rand($this->config['master_num'],count($_config['hostname'])-1)); // 每次随机连接的数据库 - } - } - }else{ - // 读写操作不区分服务器 - $r = floor(mt_rand(0,count($_config['hostname'])-1)); // 每次随机连接的数据库 - } - - if($m != $r ){ - $db_master = array( - 'username' => isset($_config['username'][$m])?$_config['username'][$m]:$_config['username'][0], - 'password' => isset($_config['password'][$m])?$_config['password'][$m]:$_config['password'][0], - 'hostname' => isset($_config['hostname'][$m])?$_config['hostname'][$m]:$_config['hostname'][0], - 'hostport' => isset($_config['hostport'][$m])?$_config['hostport'][$m]:$_config['hostport'][0], - 'database' => isset($_config['database'][$m])?$_config['database'][$m]:$_config['database'][0], - 'dsn' => isset($_config['dsn'][$m])?$_config['dsn'][$m]:$_config['dsn'][0], - 'charset' => isset($_config['charset'][$m])?$_config['charset'][$m]:$_config['charset'][0], - ); - } - $db_config = array( - 'username' => isset($_config['username'][$r])?$_config['username'][$r]:$_config['username'][0], - 'password' => isset($_config['password'][$r])?$_config['password'][$r]:$_config['password'][0], - 'hostname' => isset($_config['hostname'][$r])?$_config['hostname'][$r]:$_config['hostname'][0], - 'hostport' => isset($_config['hostport'][$r])?$_config['hostport'][$r]:$_config['hostport'][0], - 'database' => isset($_config['database'][$r])?$_config['database'][$r]:$_config['database'][0], - 'dsn' => isset($_config['dsn'][$r])?$_config['dsn'][$r]:$_config['dsn'][0], - 'charset' => isset($_config['charset'][$r])?$_config['charset'][$r]:$_config['charset'][0], - ); - return $this->connect($db_config,$r,$r == $m ? false : $db_master); - } - - /** - * 析构方法 - * @access public - */ - public function __destruct() { - // 释放查询 - if ($this->PDOStatement){ - $this->free(); - } - // 关闭连接 - $this->close(); - } -} diff --git a/ThinkPHP/Library/Think/Db/Driver/Firebird.class.php b/ThinkPHP/Library/Think/Db/Driver/Firebird.class.php deleted file mode 100644 index 6cc281d..0000000 --- a/ThinkPHP/Library/Think/Db/Driver/Firebird.class.php +++ /dev/null @@ -1,151 +0,0 @@ - -// +---------------------------------------------------------------------- -namespace Think\Db\Driver; -use Think\Db\Driver; - -/** - * Firebird数据库驱动 - */ -class Firebird extends Driver{ - protected $selectSql = 'SELECT %LIMIT% %DISTINCT% %FIELD% FROM %TABLE%%JOIN%%WHERE%%GROUP%%HAVING%%ORDER%'; - - /** - * 解析pdo连接的dsn信息 - * @access public - * @param array $config 连接信息 - * @return string - */ - protected function parseDsn($config){ - $dsn = 'firebird:dbname='.$config['hostname'].'/'.($config['hostport']?:3050).':'.$config['database']; - return $dsn; - } - - /** - * 执行语句 - * @access public - * @param string $str sql指令 - * @param boolean $fetchSql 不执行只是获取SQL - * @return mixed - */ - public function execute($str,$fetchSql=false) { - $this->initConnect(true); - if ( !$this->_linkID ) return false; - $this->queryStr = $str; - if(!empty($this->bind)){ - $that = $this; - $this->queryStr = strtr($this->queryStr,array_map(function($val) use($that){ return '\''.$that->escapeString($val).'\''; },$this->bind)); - } - if($fetchSql){ - return $this->queryStr; - } - //释放前次的查询结果 - if ( !empty($this->PDOStatement) ) $this->free(); - $this->executeTimes++; - N('db_write',1); // 兼容代码 - // 记录开始执行时间 - $this->debug(true); - $this->PDOStatement = $this->_linkID->prepare($str); - if(false === $this->PDOStatement) { - E($this->error()); - } - foreach ($this->bind as $key => $val) { - if(is_array($val)){ - $this->PDOStatement->bindValue($key, $val[0], $val[1]); - }else{ - $this->PDOStatement->bindValue($key, $val); - } - } - $this->bind = array(); - $result = $this->PDOStatement->execute(); - $this->debug(false); - if ( false === $result) { - $this->error(); - return false; - } else { - $this->numRows = $this->PDOStatement->rowCount(); - return $this->numRows; - } - } - - /** - * 取得数据表的字段信息 - * @access public - */ - public function getFields($tableName) { - $this->initConnect(true); - list($tableName) = explode(' ', $tableName); - $sql='SELECT RF.RDB$FIELD_NAME AS FIELD,RF.RDB$DEFAULT_VALUE AS DEFAULT1,RF.RDB$NULL_FLAG AS NULL1,TRIM(T.RDB$TYPE_NAME) || \'(\' || F.RDB$FIELD_LENGTH || \')\' as TYPE FROM RDB$RELATION_FIELDS RF LEFT JOIN RDB$FIELDS F ON (F.RDB$FIELD_NAME = RF.RDB$FIELD_SOURCE) LEFT JOIN RDB$TYPES T ON (T.RDB$TYPE = F.RDB$FIELD_TYPE) WHERE RDB$RELATION_NAME=UPPER(\''.$tableName.'\') AND T.RDB$FIELD_NAME = \'RDB$FIELD_TYPE\' ORDER By RDB$FIELD_POSITION'; - $result = $this->query($sql); - $info = array(); - if($result){ - foreach($result as $key => $val){ - $info[trim($val['field'])] = array( - 'name' => trim($val['field']), - 'type' => $val['type'], - 'notnull' => (bool) ($val['null1'] ==1), // 1表示不为Null - 'default' => $val['default1'], - 'primary' => false, - 'autoinc' => false, - ); - } - } - //获取主键 - $sql='select b.rdb$field_name as field_name from rdb$relation_constraints a join rdb$index_segments b on a.rdb$index_name=b.rdb$index_name where a.rdb$constraint_type=\'PRIMARY KEY\' and a.rdb$relation_name=UPPER(\''.$tableName.'\')'; - $rs_temp = $this->query($sql); - foreach($rs_temp as $row) { - $info[trim($row['field_name'])]['primary']= true; - } - return $info; - } - - /** - * 取得数据库的表信息 - * @access public - */ - public function getTables($dbName='') { - $sql='SELECT DISTINCT RDB$RELATION_NAME FROM RDB$RELATION_FIELDS WHERE RDB$SYSTEM_FLAG=0'; - $result = $this->query($sql); - $info = array(); - foreach ($result as $key => $val) { - $info[$key] = trim(current($val)); - } - return $info; - } - - /** - * SQL指令安全过滤 - * @access public - * @param string $str SQL指令 - * @return string - */ - public function escapeString($str) { - return str_replace("'", "''", $str); - } - - /** - * limit - * @access public - * @param $limit limit表达式 - * @return string - */ - public function parseLimit($limit) { - $limitStr = ''; - if(!empty($limit)) { - $limit = explode(',',$limit); - if(count($limit)>1) { - $limitStr = ' FIRST '.$limit[1].' SKIP '.$limit[0].' '; - }else{ - $limitStr = ' FIRST '.$limit[0].' '; - } - } - return $limitStr; - } -} diff --git a/ThinkPHP/Library/Think/Db/Driver/Mongo.class.php b/ThinkPHP/Library/Think/Db/Driver/Mongo.class.php deleted file mode 100644 index a070b8c..0000000 --- a/ThinkPHP/Library/Think/Db/Driver/Mongo.class.php +++ /dev/null @@ -1,821 +0,0 @@ - -// +---------------------------------------------------------------------- - -namespace Think\Db\Driver; -use Think\Db\Driver; - -/** - * Mongo数据库驱动 - */ -class Mongo extends Driver { - - protected $_mongo = null; // MongoDb Object - protected $_collection = null; // MongoCollection Object - protected $_dbName = ''; // dbName - protected $_collectionName = ''; // collectionName - protected $_cursor = null; // MongoCursor Object - protected $comparison = array('neq'=>'ne','ne'=>'ne','gt'=>'gt','egt'=>'gte','gte'=>'gte','lt'=>'lt','elt'=>'lte','lte'=>'lte','in'=>'in','not in'=>'nin','nin'=>'nin'); - - /** - * 架构函数 读取数据库配置信息 - * @access public - * @param array $config 数据库配置数组 - */ - public function __construct($config=''){ - if ( !class_exists('mongoClient') ) { - E(L('_NOT_SUPPORT_').':Mongo'); - } - if(!empty($config)) { - $this->config = array_merge($this->config,$config); - if(empty($this->config['params'])){ - $this->config['params'] = array(); - } - } - } - - /** - * 连接数据库方法 - * @access public - */ - public function connect($config='',$linkNum=0) { - if ( !isset($this->linkID[$linkNum]) ) { - if(empty($config)) $config = $this->config; - $host = 'mongodb://'.($config['username']?"{$config['username']}":'').($config['password']?":{$config['password']}@":'').$config['hostname'].($config['hostport']?":{$config['hostport']}":'').'/'.($config['database']?"{$config['database']}":''); - try{ - $this->linkID[$linkNum] = new \mongoClient( $host,$this->config['params']); - }catch (\MongoConnectionException $e){ - E($e->getmessage()); - } - } - return $this->linkID[$linkNum]; - } - - /** - * 切换当前操作的Db和Collection - * @access public - * @param string $collection collection - * @param string $db db - * @param boolean $master 是否主服务器 - * @return void - */ - public function switchCollection($collection,$db='',$master=true){ - // 当前没有连接 则首先进行数据库连接 - if ( !$this->_linkID ) $this->initConnect($master); - try{ - if(!empty($db)) { // 传人Db则切换数据库 - // 当前MongoDb对象 - $this->_dbName = $db; - $this->_mongo = $this->_linkID->selectDb($db); - } - // 当前MongoCollection对象 - if($this->config['debug']) { - $this->queryStr = $this->_dbName.'.getCollection('.$collection.')'; - } - if($this->_collectionName != $collection) { - $this->queryTimes++; - N('db_query',1); // 兼容代码 - $this->debug(true); - $this->_collection = $this->_mongo->selectCollection($collection); - $this->debug(false); - $this->_collectionName = $collection; // 记录当前Collection名称 - } - }catch (MongoException $e){ - E($e->getMessage()); - } - } - - /** - * 释放查询结果 - * @access public - */ - public function free() { - $this->_cursor = null; - } - - /** - * 执行命令 - * @access public - * @param array $command 指令 - * @return array - */ - public function command($command=array(), $options=array()) { - $cache = isset($options['cache'])?$options['cache']:false; - if($cache) { // 查询缓存检测 - $key = is_string($cache['key'])?$cache['key']:md5(serialize($command)); - $value = S($key,'','',$cache['type']); - if(false !== $value) { - return $value; - } - } - N('db_write',1); // 兼容代码 - $this->executeTimes++; - try{ - if($this->config['debug']) { - $this->queryStr = $this->_dbName.'.'.$this->_collectionName.'.runCommand('; - $this->queryStr .= json_encode($command); - $this->queryStr .= ')'; - } - $this->debug(true); - $result = $this->_mongo->command($command); - $this->debug(false); - - if($cache && $result['ok']) { // 查询缓存写入 - S($key,$result,$cache['expire'],$cache['type']); - } - return $result; - } catch (\MongoCursorException $e) { - E($e->getMessage()); - } - } - - /** - * 执行语句 - * @access public - * @param string $code sql指令 - * @param array $args 参数 - * @return mixed - */ - public function execute($code,$args=array()) { - $this->executeTimes++; - N('db_write',1); // 兼容代码 - $this->debug(true); - $this->queryStr = 'execute:'.$code; - $result = $this->_mongo->execute($code,$args); - $this->debug(false); - if($result['ok']) { - return $result['retval']; - }else{ - E($result['errmsg']); - } - } - - /** - * 关闭数据库 - * @access public - */ - public function close() { - if($this->_linkID) { - $this->_linkID->close(); - $this->_linkID = null; - $this->_mongo = null; - $this->_collection = null; - $this->_cursor = null; - } - } - - /** - * 数据库错误信息 - * @access public - * @return string - */ - public function error() { - $this->error = $this->_mongo->lastError(); - trace($this->error,'','ERR'); - return $this->error; - } - - /** - * 插入记录 - * @access public - * @param mixed $data 数据 - * @param array $options 参数表达式 - * @param boolean $replace 是否replace - * @return false | integer - */ - public function insert($data,$options=array(),$replace=false) { - if(isset($options['table'])) { - $this->switchCollection($options['table']); - } - $this->model = $options['model']; - $this->executeTimes++; - N('db_write',1); // 兼容代码 - if($this->config['debug']) { - $this->queryStr = $this->_dbName.'.'.$this->_collectionName.'.insert('; - $this->queryStr .= $data?json_encode($data):'{}'; - $this->queryStr .= ')'; - } - try{ - $this->debug(true); - $result = $replace? $this->_collection->save($data): $this->_collection->insert($data); - $this->debug(false); - if($result) { - $_id = $data['_id']; - if(is_object($_id)) { - $_id = $_id->__toString(); - } - $this->lastInsID = $_id; - } - return $result; - } catch (\MongoCursorException $e) { - E($e->getMessage()); - } - } - - /** - * 插入多条记录 - * @access public - * @param array $dataList 数据 - * @param array $options 参数表达式 - * @return bool - */ - public function insertAll($dataList,$options=array()) { - if(isset($options['table'])) { - $this->switchCollection($options['table']); - } - $this->model = $options['model']; - $this->executeTimes++; - N('db_write',1); // 兼容代码 - try{ - $this->debug(true); - $result = $this->_collection->batchInsert($dataList); - $this->debug(false); - return $result; - } catch (\MongoCursorException $e) { - E($e->getMessage()); - } - } - - /** - * 生成下一条记录ID 用于自增非MongoId主键 - * @access public - * @param string $pk 主键名 - * @return integer - */ - public function getMongoNextId($pk) { - if($this->config['debug']) { - $this->queryStr = $this->_dbName.'.'.$this->_collectionName.'.find({},{'.$pk.':1}).sort({'.$pk.':-1}).limit(1)'; - } - try{ - $this->debug(true); - $result = $this->_collection->find(array(),array($pk=>1))->sort(array($pk=>-1))->limit(1); - $this->debug(false); - } catch (\MongoCursorException $e) { - E($e->getMessage()); - } - $data = $result->getNext(); - return isset($data[$pk])?$data[$pk]+1:1; - } - - /** - * 更新记录 - * @access public - * @param mixed $data 数据 - * @param array $options 表达式 - * @return bool - */ - public function update($data,$options) { - if(isset($options['table'])) { - $this->switchCollection($options['table']); - } - $this->executeTimes++; - N('db_write',1); // 兼容代码 - $this->model = $options['model']; - $query = $this->parseWhere(isset($options['where'])?$options['where']:array()); - $set = $this->parseSet($data); - if($this->config['debug']) { - $this->queryStr = $this->_dbName.'.'.$this->_collectionName.'.update('; - $this->queryStr .= $query?json_encode($query):'{}'; - $this->queryStr .= ','.json_encode($set).')'; - } - try{ - $this->debug(true); - if(isset($options['limit']) && $options['limit'] == 1) { - $multiple = array("multiple" => false); - }else{ - $multiple = array("multiple" => true); - } - $result = $this->_collection->update($query,$set,$multiple); - $this->debug(false); - return $result; - } catch (\MongoCursorException $e) { - E($e->getMessage()); - } - } - - /** - * 删除记录 - * @access public - * @param array $options 表达式 - * @return false | integer - */ - public function delete($options=array()) { - if(isset($options['table'])) { - $this->switchCollection($options['table']); - } - $query = $this->parseWhere(isset($options['where'])?$options['where']:array()); - $this->model = $options['model']; - $this->executeTimes++; - N('db_write',1); // 兼容代码 - if($this->config['debug']) { - $this->queryStr = $this->_dbName.'.'.$this->_collectionName.'.remove('.json_encode($query).')'; - } - try{ - $this->debug(true); - $result = $this->_collection->remove($query); - $this->debug(false); - return $result; - } catch (\MongoCursorException $e) { - E($e->getMessage()); - } - } - - /** - * 清空记录 - * @access public - * @param array $options 表达式 - * @return false | integer - */ - public function clear($options=array()){ - if(isset($options['table'])) { - $this->switchCollection($options['table']); - } - $this->model = $options['model']; - $this->executeTimes++; - N('db_write',1); // 兼容代码 - if($this->config['debug']) { - $this->queryStr = $this->_dbName.'.'.$this->_collectionName.'.remove({})'; - } - try{ - $this->debug(true); - $result = $this->_collection->drop(); - $this->debug(false); - return $result; - } catch (\MongoCursorException $e) { - E($e->getMessage()); - } - } - - /** - * 查找记录 - * @access public - * @param array $options 表达式 - * @return iterator - */ - public function select($options=array()) { - if(isset($options['table'])) { - $this->switchCollection($options['table'],'',false); - } - $this->model = $options['model']; - $this->queryTimes++; - N('db_query',1); // 兼容代码 - $query = $this->parseWhere(isset($options['where'])?$options['where']:array()); - $field = $this->parseField(isset($options['field'])?$options['field']:array()); - try{ - if($this->config['debug']) { - $this->queryStr = $this->_dbName.'.'.$this->_collectionName.'.find('; - $this->queryStr .= $query? json_encode($query):'{}'; - if(is_array($field) && count($field)) { - foreach ($field as $f=>$v) - $_field_array[$f] = $v ? 1 : 0; - - $this->queryStr .= $field? ', '.json_encode($_field_array):', {}'; - } - $this->queryStr .= ')'; - } - $this->debug(true); - $_cursor = $this->_collection->find($query,$field); - if(!empty($options['order'])) { - $order = $this->parseOrder($options['order']); - if($this->config['debug']) { - $this->queryStr .= '.sort('.json_encode($order).')'; - } - $_cursor = $_cursor->sort($order); - } - if(isset($options['page'])) { // 根据页数计算limit - list($page,$length) = $options['page']; - $page = $page>0 ? $page : 1; - $length = $length>0 ? $length : (is_numeric($options['limit'])?$options['limit']:20); - $offset = $length*((int)$page-1); - $options['limit'] = $offset.','.$length; - } - if(isset($options['limit'])) { - list($offset,$length) = $this->parseLimit($options['limit']); - if(!empty($offset)) { - if($this->config['debug']) { - $this->queryStr .= '.skip('.intval($offset).')'; - } - $_cursor = $_cursor->skip(intval($offset)); - } - if($this->config['debug']) { - $this->queryStr .= '.limit('.intval($length).')'; - } - $_cursor = $_cursor->limit(intval($length)); - } - $this->debug(false); - $this->_cursor = $_cursor; - $resultSet = iterator_to_array($_cursor); - return $resultSet; - } catch (\MongoCursorException $e) { - E($e->getMessage()); - } - } - - /** - * 查找某个记录 - * @access public - * @param array $options 表达式 - * @return array - */ - public function find($options=array()){ - $options['limit'] = 1; - $find = $this->select($options); - return array_shift($find); - } - - /** - * 统计记录数 - * @access public - * @param array $options 表达式 - * @return iterator - */ - public function count($options=array()){ - if(isset($options['table'])) { - $this->switchCollection($options['table'],'',false); - } - $this->model = $options['model']; - $this->queryTimes++; - N('db_query',1); // 兼容代码 - $query = $this->parseWhere(isset($options['where'])?$options['where']:array()); - if($this->config['debug']) { - $this->queryStr = $this->_dbName.'.'.$this->_collectionName; - $this->queryStr .= $query?'.find('.json_encode($query).')':''; - $this->queryStr .= '.count()'; - } - try{ - $this->debug(true); - $count = $this->_collection->count($query); - $this->debug(false); - return $count; - } catch (\MongoCursorException $e) { - E($e->getMessage()); - } - } - - public function group($keys,$initial,$reduce,$options=array()){ - if(isset($options['table']) && $this->_collectionName != $options['table']) { - $this->switchCollection($options['table'],'',false); - } - - $cache = isset($options['cache'])?$options['cache']:false; - if($cache) { - $key = is_string($cache['key'])?$cache['key']:md5(serialize($options)); - $value = S($key,'','',$cache['type']); - if(false !== $value) { - return $value; - } - } - - $this->model = $options['model']; - $this->queryTimes++; - N('db_query',1); // 兼容代码 - $query = $this->parseWhere(isset($options['where'])?$options['where']:array()); - - if($this->config['debug']) { - $this->queryStr = $this->_dbName.'.'.$this->_collectionName.'.group({key:'.json_encode($keys).',cond:'. - json_encode($options['condition']) . ',reduce:' . - json_encode($reduce).',initial:'. - json_encode($initial).'})'; - } - try{ - $this->debug(true); - $option = array('condition'=>$options['condition'], 'finalize'=>$options['finalize'], 'maxTimeMS'=>$options['maxTimeMS']); - $group = $this->_collection->group($keys,$initial,$reduce,$options); - $this->debug(false); - - if($cache && $group['ok']) - S($key,$group,$cache['expire'],$cache['type']); - - return $group; - } catch (\MongoCursorException $e) { - E($e->getMessage()); - } - } - - /** - * 取得数据表的字段信息 - * @access public - * @return array - */ - public function getFields($collection=''){ - if(!empty($collection) && $collection != $this->_collectionName) { - $this->switchCollection($collection,'',false); - } - $this->queryTimes++; - N('db_query',1); // 兼容代码 - if($this->config['debug']) { - $this->queryStr = $this->_dbName.'.'.$this->_collectionName.'.findOne()'; - } - try{ - $this->debug(true); - $result = $this->_collection->findOne(); - $this->debug(false); - } catch (\MongoCursorException $e) { - E($e->getMessage()); - } - if($result) { // 存在数据则分析字段 - $info = array(); - foreach ($result as $key=>$val){ - $info[$key] = array( - 'name' => $key, - 'type' => getType($val), - ); - } - return $info; - } - // 暂时没有数据 返回false - return false; - } - - /** - * 取得当前数据库的collection信息 - * @access public - */ - public function getTables(){ - if($this->config['debug']) { - $this->queryStr = $this->_dbName.'.getCollenctionNames()'; - } - $this->queryTimes++; - N('db_query',1); // 兼容代码 - $this->debug(true); - $list = $this->_mongo->listCollections(); - $this->debug(false); - $info = array(); - foreach ($list as $collection){ - $info[] = $collection->getName(); - } - return $info; - } - - /** - * 取得当前数据库的对象 - * @access public - * @return object mongoClient - */ - public function getDB(){ - return $this->_mongo; - } - - /** - * 取得当前集合的对象 - * @access public - * @return object MongoCollection - */ - public function getCollection(){ - return $this->_collection; - } - - /** - * set分析 - * @access protected - * @param array $data - * @return string - */ - protected function parseSet($data) { - $result = array(); - foreach ($data as $key=>$val){ - if(is_array($val)) { - switch($val[0]) { - case 'inc': - $result['$inc'][$key] = (int)$val[1]; - break; - case 'set': - case 'unset': - case 'push': - case 'pushall': - case 'addtoset': - case 'pop': - case 'pull': - case 'pullall': - $result['$'.$val[0]][$key] = $val[1]; - break; - default: - $result['$set'][$key] = $val; - } - }else{ - $result['$set'][$key] = $val; - } - } - return $result; - } - - /** - * order分析 - * @access protected - * @param mixed $order - * @return array - */ - protected function parseOrder($order) { - if(is_string($order)) { - $array = explode(',',$order); - $order = array(); - foreach ($array as $key=>$val){ - $arr = explode(' ',trim($val)); - if(isset($arr[1])) { - $arr[1] = $arr[1]=='asc'?1:-1; - }else{ - $arr[1] = 1; - } - $order[$arr[0]] = $arr[1]; - } - } - return $order; - } - - /** - * limit分析 - * @access protected - * @param mixed $limit - * @return array - */ - protected function parseLimit($limit) { - if(strpos($limit,',')) { - $array = explode(',',$limit); - }else{ - $array = array(0,$limit); - } - return $array; - } - - /** - * field分析 - * @access protected - * @param mixed $fields - * @return array - */ - public function parseField($fields){ - if(empty($fields)) { - $fields = array(); - } - if(is_string($fields)) { - $_fields = explode(',',$fields); - $fields = array(); - foreach ($_fields as $f) - $fields[$f] = true; - }elseif(is_array($fields)) { - $_fields = $fields; - $fields = array(); - foreach ($_fields as $f=>$v) { - if(is_numeric($f)) - $fields[$v] = true; - else - $fields[$f] = $v ? true : false; - } - } - return $fields; - } - - /** - * where分析 - * @access protected - * @param mixed $where - * @return array - */ - public function parseWhere($where){ - $query = array(); - $return = array(); - $_logic = '$and'; - if(isset($where['_logic'])){ - $where['_logic'] = strtolower($where['_logic']); - $_logic = in_array($where['_logic'], array('or','xor','nor', 'and'))?'$'.$where['_logic']:$_logic; - unset($where['_logic']); - } - foreach ($where as $key=>$val){ - if('_id' != $key && 0===strpos($key,'_')) { - // 解析特殊条件表达式 - $parse = $this->parseThinkWhere($key,$val); - $query = array_merge($query,$parse); - }else{ - // 查询字段的安全过滤 - if(!preg_match('/^[A-Z_\|\&\-.a-z0-9]+$/',trim($key))){ - E(L('_ERROR_QUERY_').':'.$key); - } - $key = trim($key); - if(strpos($key,'|')) { - $array = explode('|',$key); - $str = array(); - foreach ($array as $k){ - $str[] = $this->parseWhereItem($k,$val); - } - $query['$or'] = $str; - }elseif(strpos($key,'&')){ - $array = explode('&',$key); - $str = array(); - foreach ($array as $k){ - $str[] = $this->parseWhereItem($k,$val); - } - $query = array_merge($query,$str); - }else{ - $str = $this->parseWhereItem($key,$val); - $query = array_merge($query,$str); - } - } - } - if($_logic == '$and') - return $query; - - foreach($query as $key=>$val) - $return[$_logic][] = array($key=>$val); - - return $return; - } - - /** - * 特殊条件分析 - * @access protected - * @param string $key - * @param mixed $val - * @return string - */ - protected function parseThinkWhere($key,$val) { - $query = array(); - $_logic = array('or','xor','nor', 'and'); - - switch($key) { - case '_query': // 字符串模式查询条件 - parse_str($val,$query); - if(isset($query['_logic']) && strtolower($query['_logic']) == 'or' ) { - unset($query['_logic']); - $query['$or'] = $query; - } - break; - case '_complex': // 子查询模式查询条件 - $__logic = strtolower($val['_logic']); - if(isset($val['_logic']) && in_array($__logic, $_logic) ) { - unset($val['_logic']); - $query['$'.$__logic] = $val; - } - break; - case '_string':// MongoCode查询 - $query['$where'] = new \MongoCode($val); - break; - } - //兼容 MongoClient OR条件查询方法 - if(isset($query['$or']) && !is_array(current($query['$or']))) { - $val = array(); - foreach ($query['$or'] as $k=>$v) - $val[] = array($k=>$v); - $query['$or'] = $val; - } - return $query; - } - - /** - * where子单元分析 - * @access protected - * @param string $key - * @param mixed $val - * @return array - */ - protected function parseWhereItem($key,$val) { - $query = array(); - if(is_array($val)) { - if(is_string($val[0])) { - $con = strtolower($val[0]); - if(in_array($con,array('neq','ne','gt','egt','gte','lt','lte','elt'))) { // 比较运算 - $k = '$'.$this->comparison[$con]; - $query[$key] = array($k=>$val[1]); - }elseif('like'== $con){ // 模糊查询 采用正则方式 - $query[$key] = new \MongoRegex("/".$val[1]."/"); - }elseif('mod'==$con){ // mod 查询 - $query[$key] = array('$mod'=>$val[1]); - }elseif('regex'==$con){ // 正则查询 - $query[$key] = new \MongoRegex($val[1]); - }elseif(in_array($con,array('in','nin','not in'))){ // IN NIN 运算 - $data = is_string($val[1])? explode(',',$val[1]):$val[1]; - $k = '$'.$this->comparison[$con]; - $query[$key] = array($k=>$data); - }elseif('all'==$con){ // 满足所有指定条件 - $data = is_string($val[1])? explode(',',$val[1]):$val[1]; - $query[$key] = array('$all'=>$data); - }elseif('between'==$con){ // BETWEEN运算 - $data = is_string($val[1])? explode(',',$val[1]):$val[1]; - $query[$key] = array('$gte'=>$data[0],'$lte'=>$data[1]); - }elseif('not between'==$con){ - $data = is_string($val[1])? explode(',',$val[1]):$val[1]; - $query[$key] = array('$lt'=>$data[0],'$gt'=>$data[1]); - }elseif('exp'==$con){ // 表达式查询 - $query['$where'] = new \MongoCode($val[1]); - }elseif('exists'==$con){ // 字段是否存在 - $query[$key] = array('$exists'=>(bool)$val[1]); - }elseif('size'==$con){ // 限制属性大小 - $query[$key] = array('$size'=>intval($val[1])); - }elseif('type'==$con){ // 限制字段类型 1 浮点型 2 字符型 3 对象或者MongoDBRef 5 MongoBinData 7 MongoId 8 布尔型 9 MongoDate 10 NULL 15 MongoCode 16 32位整型 17 MongoTimestamp 18 MongoInt64 如果是数组的话判断元素的类型 - $query[$key] = array('$type'=>intval($val[1])); - }else{ - $query[$key] = $val; - } - return $query; - } - } - $query[$key] = $val; - return $query; - } -} diff --git a/ThinkPHP/Library/Think/Db/Driver/Mysql.class.php b/ThinkPHP/Library/Think/Db/Driver/Mysql.class.php deleted file mode 100644 index ee0a338..0000000 --- a/ThinkPHP/Library/Think/Db/Driver/Mysql.class.php +++ /dev/null @@ -1,235 +0,0 @@ - -// +---------------------------------------------------------------------- - -namespace Think\Db\Driver; -use Think\Db\Driver; - -/** - * mysql数据库驱动 - */ -class Mysql extends Driver{ - - /** - * 解析pdo连接的dsn信息 - * @access public - * @param array $config 连接信息 - * @return string - */ - protected function parseDsn($config){ - $dsn = 'mysql:dbname='.$config['database'].';host='.$config['hostname']; - if(!empty($config['hostport'])) { - $dsn .= ';port='.$config['hostport']; - }elseif(!empty($config['socket'])){ - $dsn .= ';unix_socket='.$config['socket']; - } - - if(!empty($config['charset'])){ - //为兼容各版本PHP,用两种方式设置编码 - $this->options[\PDO::MYSQL_ATTR_INIT_COMMAND] = 'SET NAMES '.$config['charset']; - $dsn .= ';charset='.$config['charset']; - } - return $dsn; - } - - /** - * 取得数据表的字段信息 - * @access public - */ - public function getFields($tableName) { - $this->initConnect(true); - list($tableName) = explode(' ', $tableName); - if(strpos($tableName,'.')){ - list($dbName,$tableName) = explode('.',$tableName); - $sql = 'SHOW COLUMNS FROM `'.$dbName.'`.`'.$tableName.'`'; - }else{ - $sql = 'SHOW COLUMNS FROM `'.$tableName.'`'; - } - - $result = $this->query($sql); - $info = array(); - if($result) { - foreach ($result as $key => $val) { - if(\PDO::CASE_LOWER != $this->_linkID->getAttribute(\PDO::ATTR_CASE)){ - $val = array_change_key_case ( $val , CASE_LOWER ); - } - $info[$val['field']] = array( - 'name' => $val['field'], - 'type' => $val['type'], - 'notnull' => (bool) ($val['null'] === ''), // not null is empty, null is yes - 'default' => $val['default'], - 'primary' => (strtolower($val['key']) == 'pri'), - 'autoinc' => (strtolower($val['extra']) == 'auto_increment'), - ); - } - } - return $info; - } - - /** - * 取得数据库的表信息 - * @access public - */ - public function getTables($dbName='') { - $sql = !empty($dbName)?'SHOW TABLES FROM '.$dbName:'SHOW TABLES '; - $result = $this->query($sql); - $info = array(); - foreach ($result as $key => $val) { - $info[$key] = current($val); - } - return $info; - } - - /** - * 字段和表名处理 - * @access protected - * @param string $key - * @return string - */ - protected function parseKey(&$key) { - $key = trim($key); - if(!is_numeric($key) && !preg_match('/[,\'\"\*\(\)`.\s]/',$key)) { - $key = '`'.$key.'`'; - } - return $key; - } - - /** - * 批量插入记录 - * @access public - * @param mixed $dataSet 数据集 - * @param array $options 参数表达式 - * @param boolean $replace 是否replace - * @return false | integer - */ - public function insertAll($dataSet,$options=array(),$replace=false) { - $values = array(); - $this->model = $options['model']; - if(!is_array($dataSet[0])) return false; - $this->parseBind(!empty($options['bind'])?$options['bind']:array()); - $fields = array_map(array($this,'parseKey'),array_keys($dataSet[0])); - foreach ($dataSet as $data){ - $value = array(); - foreach ($data as $key=>$val){ - if(is_array($val) && 'exp' == $val[0]){ - $value[] = $val[1]; - }elseif(is_null($val)){ - $value[] = 'NULL'; - }elseif(is_scalar($val)){ - if(0===strpos($val,':') && in_array($val,array_keys($this->bind))){ - $value[] = $this->parseValue($val); - }else{ - $name = count($this->bind); - $value[] = ':'.$name; - $this->bindParam($name,$val); - } - } - } - $values[] = '('.implode(',', $value).')'; - } - // 兼容数字传入方式 - $replace= (is_numeric($replace) && $replace>0)?true:$replace; - $sql = (true===$replace?'REPLACE':'INSERT').' INTO '.$this->parseTable($options['table']).' ('.implode(',', $fields).') VALUES '.implode(',',$values).$this->parseDuplicate($replace); - $sql .= $this->parseComment(!empty($options['comment'])?$options['comment']:''); - return $this->execute($sql,!empty($options['fetch_sql']) ? true : false); - } - - /** - * ON DUPLICATE KEY UPDATE 分析 - * @access protected - * @param mixed $duplicate - * @return string - */ - protected function parseDuplicate($duplicate){ - // 布尔值或空则返回空字符串 - if(is_bool($duplicate) || empty($duplicate)) return ''; - - if(is_string($duplicate)){ - // field1,field2 转数组 - $duplicate = explode(',', $duplicate); - }elseif(is_object($duplicate)){ - // 对象转数组 - $duplicate = get_class_vars($duplicate); - } - $updates = array(); - foreach((array) $duplicate as $key=>$val){ - if(is_numeric($key)){ // array('field1', 'field2', 'field3') 解析为 ON DUPLICATE KEY UPDATE field1=VALUES(field1), field2=VALUES(field2), field3=VALUES(field3) - $updates[] = $this->parseKey($val)."=VALUES(".$this->parseKey($val).")"; - }else{ - if(is_scalar($val)) // 兼容标量传值方式 - $val = array('value', $val); - if(!isset($val[1])) continue; - switch($val[0]){ - case 'exp': // 表达式 - $updates[] = $this->parseKey($key)."=($val[1])"; - break; - case 'value': // 值 - default: - $name = count($this->bind); - $updates[] = $this->parseKey($key)."=:".$name; - $this->bindParam($name, $val[1]); - break; - } - } - } - if(empty($updates)) return ''; - return " ON DUPLICATE KEY UPDATE ".join(', ', $updates); - } - - - - /** - * 执行存储过程查询 返回多个数据集 - * @access public - * @param string $str sql指令 - * @param boolean $fetchSql 不执行只是获取SQL - * @return mixed - */ - public function procedure($str,$fetchSql=false) { - $this->initConnect(false); - $this->_linkID->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_WARNING); - if ( !$this->_linkID ) return false; - $this->queryStr = $str; - if($fetchSql){ - return $this->queryStr; - } - //释放前次的查询结果 - if ( !empty($this->PDOStatement) ) $this->free(); - $this->queryTimes++; - N('db_query',1); // 兼容代码 - // 调试开始 - $this->debug(true); - $this->PDOStatement = $this->_linkID->prepare($str); - if(false === $this->PDOStatement){ - $this->error(); - return false; - } - try{ - $result = $this->PDOStatement->execute(); - // 调试结束 - $this->debug(false); - do - { - $result = $this->PDOStatement->fetchAll(\PDO::FETCH_ASSOC); - if ($result) - { - $resultArr[] = $result; - } - } - while ($this->PDOStatement->nextRowset()); - $this->_linkID->setAttribute(\PDO::ATTR_ERRMODE, $this->options[\PDO::ATTR_ERRMODE]); - return $resultArr; - }catch (\PDOException $e) { - $this->error(); - $this->_linkID->setAttribute(\PDO::ATTR_ERRMODE, $this->options[\PDO::ATTR_ERRMODE]); - return false; - } - } -} diff --git a/ThinkPHP/Library/Think/Db/Driver/Oracle.class.php b/ThinkPHP/Library/Think/Db/Driver/Oracle.class.php deleted file mode 100644 index 6bf5477..0000000 --- a/ThinkPHP/Library/Think/Db/Driver/Oracle.class.php +++ /dev/null @@ -1,168 +0,0 @@ - -// +---------------------------------------------------------------------- - -namespace Think\Db\Driver; -use Think\Db\Driver; - -/** - * Oracle数据库驱动 - */ -class Oracle extends Driver{ - - private $table = ''; - protected $selectSql = 'SELECT * FROM (SELECT thinkphp.*, rownum AS numrow FROM (SELECT %DISTINCT% %FIELD% FROM %TABLE%%JOIN%%WHERE%%GROUP%%HAVING%%ORDER%) thinkphp ) %LIMIT%%COMMENT%'; - - /** - * 解析pdo连接的dsn信息 - * @access public - * @param array $config 连接信息 - * @return string - */ - protected function parseDsn($config){ - $dsn = 'oci:dbname=//'.$config['hostname'].($config['hostport']?':'.$config['hostport']:'').'/'.$config['database']; - if(!empty($config['charset'])) { - $dsn .= ';charset='.$config['charset']; - } - return $dsn; - } - - /** - * 执行语句 - * @access public - * @param string $str sql指令 - * @param boolean $fetchSql 不执行只是获取SQL - * @return integer - */ - public function execute($str,$fetchSql=false) { - $this->initConnect(true); - if ( !$this->_linkID ) return false; - $this->queryStr = $str; - if(!empty($this->bind)){ - $that = $this; - $this->queryStr = strtr($this->queryStr,array_map(function($val) use($that){ return '\''.$that->escapeString($val).'\''; },$this->bind)); - } - if($fetchSql){ - return $this->queryStr; - } - $flag = false; - if(preg_match("/^\s*(INSERT\s+INTO)\s+(\w+)\s+/i", $str, $match)) { - $this->table = C("DB_SEQUENCE_PREFIX").str_ireplace(C("DB_PREFIX"), "", $match[2]); - $flag = (boolean)$this->query("SELECT * FROM user_sequences WHERE sequence_name='" . strtoupper($this->table) . "'"); - } - //释放前次的查询结果 - if ( !empty($this->PDOStatement) ) $this->free(); - $this->executeTimes++; - N('db_write',1); // 兼容代码 - // 记录开始执行时间 - $this->debug(true); - $this->PDOStatement = $this->_linkID->prepare($str); - if(false === $this->PDOStatement) { - $this->error(); - return false; - } - foreach ($this->bind as $key => $val) { - if(is_array($val)){ - $this->PDOStatement->bindValue($key, $val[0], $val[1]); - }else{ - $this->PDOStatement->bindValue($key, $val); - } - } - $this->bind = array(); - $result = $this->PDOStatement->execute(); - $this->debug(false); - if ( false === $result) { - $this->error(); - return false; - } else { - $this->numRows = $this->PDOStatement->rowCount(); - if($flag || preg_match("/^\s*(INSERT\s+INTO|REPLACE\s+INTO)\s+/i", $str)) { - $this->lastInsID = $this->_linkID->lastInsertId(); - } - return $this->numRows; - } - } - - /** - * 取得数据表的字段信息 - * @access public - */ - public function getFields($tableName) { - list($tableName) = explode(' ', $tableName); - $result = $this->query("select a.column_name,data_type,decode(nullable,'Y',0,1) notnull,data_default,decode(a.column_name,b.column_name,1,0) pk " - ."from user_tab_columns a,(select column_name from user_constraints c,user_cons_columns col " - ."where c.constraint_name=col.constraint_name and c.constraint_type='P'and c.table_name='".strtoupper($tableName) - ."') b where table_name='".strtoupper($tableName)."' and a.column_name=b.column_name(+)"); - $info = array(); - if($result) { - foreach ($result as $key => $val) { - $info[strtolower($val['column_name'])] = array( - 'name' => strtolower($val['column_name']), - 'type' => strtolower($val['data_type']), - 'notnull' => $val['notnull'], - 'default' => $val['data_default'], - 'primary' => $val['pk'], - 'autoinc' => $val['pk'], - ); - } - } - return $info; - } - - /** - * 取得数据库的表信息(暂时实现取得用户表信息) - * @access public - */ - public function getTables($dbName='') { - $result = $this->query("select table_name from user_tables"); - $info = array(); - foreach ($result as $key => $val) { - $info[$key] = current($val); - } - return $info; - } - - /** - * SQL指令安全过滤 - * @access public - * @param string $str SQL指令 - * @return string - */ - public function escapeString($str) { - return str_ireplace("'", "''", $str); - } - - /** - * limit - * @access public - * @return string - */ - public function parseLimit($limit) { - $limitStr = ''; - if(!empty($limit)) { - $limit = explode(',',$limit); - if(count($limit)>1) - $limitStr = "(numrow>" . $limit[0] . ") AND (numrow<=" . ($limit[0]+$limit[1]) . ")"; - else - $limitStr = "(numrow>0 AND numrow<=".$limit[0].")"; - } - return $limitStr?' WHERE '.$limitStr:''; - } - - /** - * 设置锁机制 - * @access protected - * @return string - */ - protected function parseLock($lock=false) { - if(!$lock) return ''; - return ' FOR UPDATE NOWAIT '; - } -} diff --git a/ThinkPHP/Library/Think/Db/Driver/Pgsql.class.php b/ThinkPHP/Library/Think/Db/Driver/Pgsql.class.php deleted file mode 100644 index e1223a4..0000000 --- a/ThinkPHP/Library/Think/Db/Driver/Pgsql.class.php +++ /dev/null @@ -1,91 +0,0 @@ - -// +---------------------------------------------------------------------- - -namespace Think\Db\Driver; -use Think\Db\Driver; - -/** - * Pgsql数据库驱动 - */ -class Pgsql extends Driver{ - - /** - * 解析pdo连接的dsn信息 - * @access public - * @param array $config 连接信息 - * @return string - */ - protected function parseDsn($config){ - $dsn = 'pgsql:dbname='.$config['database'].';host='.$config['hostname']; - if(!empty($config['hostport'])) { - $dsn .= ';port='.$config['hostport']; - } - return $dsn; - } - - /** - * 取得数据表的字段信息 - * @access public - * @return array - */ - public function getFields($tableName) { - list($tableName) = explode(' ', $tableName); - $result = $this->query('select fields_name as "field",fields_type as "type",fields_not_null as "null",fields_key_name as "key",fields_default as "default",fields_default as "extra" from table_msg('.$tableName.');'); - $info = array(); - if($result){ - foreach ($result as $key => $val) { - $info[$val['field']] = array( - 'name' => $val['field'], - 'type' => $val['type'], - 'notnull' => (bool) ($val['null'] === ''), // not null is empty, null is yes - 'default' => $val['default'], - 'primary' => (strtolower($val['key']) == 'pri'), - 'autoinc' => (strtolower($val['extra']) == 'auto_increment'), - ); - } - } - return $info; - } - - /** - * 取得数据库的表信息 - * @access public - * @return array - */ - public function getTables($dbName='') { - $result = $this->query("select tablename as Tables_in_test from pg_tables where schemaname ='public'"); - $info = array(); - foreach ($result as $key => $val) { - $info[$key] = current($val); - } - return $info; - } - - /** - * limit分析 - * @access protected - * @param mixed $lmit - * @return string - */ - public function parseLimit($limit) { - $limitStr = ''; - if(!empty($limit)) { - $limit = explode(',',$limit); - if(count($limit)>1) { - $limitStr .= ' LIMIT '.$limit[1].' OFFSET '.$limit[0].' '; - }else{ - $limitStr .= ' LIMIT '.$limit[0].' '; - } - } - return $limitStr; - } - -} diff --git a/ThinkPHP/Library/Think/Db/Driver/Sqlite.class.php b/ThinkPHP/Library/Think/Db/Driver/Sqlite.class.php deleted file mode 100644 index d7fd641..0000000 --- a/ThinkPHP/Library/Think/Db/Driver/Sqlite.class.php +++ /dev/null @@ -1,98 +0,0 @@ - -// +---------------------------------------------------------------------- - -namespace Think\Db\Driver; -use Think\Db\Driver; - -/** - * Sqlite数据库驱动 - */ -class Sqlite extends Driver { - - /** - * 解析pdo连接的dsn信息 - * @access public - * @param array $config 连接信息 - * @return string - */ - protected function parseDsn($config){ - $dsn = 'sqlite:'.$config['database']; - return $dsn; - } - - /** - * 取得数据表的字段信息 - * @access public - * @return array - */ - public function getFields($tableName) { - list($tableName) = explode(' ', $tableName); - $result = $this->query('PRAGMA table_info( '.$tableName.' )'); - $info = array(); - if($result){ - foreach ($result as $key => $val) { - $info[$val['field']] = array( - 'name' => $val['field'], - 'type' => $val['type'], - 'notnull' => (bool) ($val['null'] === ''), // not null is empty, null is yes - 'default' => $val['default'], - 'primary' => (strtolower($val['dey']) == 'pri'), - 'autoinc' => (strtolower($val['extra']) == 'auto_increment'), - ); - } - } - return $info; - } - - /** - * 取得数据库的表信息 - * @access public - * @return array - */ - public function getTables($dbName='') { - $result = $this->query("SELECT name FROM sqlite_master WHERE type='table' " - . "UNION ALL SELECT name FROM sqlite_temp_master " - . "WHERE type='table' ORDER BY name"); - $info = array(); - foreach ($result as $key => $val) { - $info[$key] = current($val); - } - return $info; - } - - /** - * SQL指令安全过滤 - * @access public - * @param string $str SQL指令 - * @return string - */ - public function escapeString($str) { - return str_ireplace("'", "''", $str); - } - - /** - * limit - * @access public - * @return string - */ - public function parseLimit($limit) { - $limitStr = ''; - if(!empty($limit)) { - $limit = explode(',',$limit); - if(count($limit)>1) { - $limitStr .= ' LIMIT '.$limit[1].' OFFSET '.$limit[0].' '; - }else{ - $limitStr .= ' LIMIT '.$limit[0].' '; - } - } - return $limitStr; - } -} diff --git a/ThinkPHP/Library/Think/Db/Driver/Sqlsrv.class.php b/ThinkPHP/Library/Think/Db/Driver/Sqlsrv.class.php deleted file mode 100644 index 9df1c92..0000000 --- a/ThinkPHP/Library/Think/Db/Driver/Sqlsrv.class.php +++ /dev/null @@ -1,166 +0,0 @@ - -// +---------------------------------------------------------------------- - -namespace Think\Db\Driver; -use Think\Db\Driver; -use PDO; - -/** - * Sqlsrv数据库驱动 - */ -class Sqlsrv extends Driver{ - protected $selectSql = 'SELECT T1.* FROM (SELECT thinkphp.*, ROW_NUMBER() OVER (%ORDER%) AS ROW_NUMBER FROM (SELECT %DISTINCT% %FIELD% FROM %TABLE%%JOIN%%WHERE%%GROUP%%HAVING% %UNION%) AS thinkphp) AS T1 %LIMIT%%COMMENT%'; - // PDO连接参数 - protected $options = array( - PDO::ATTR_CASE => PDO::CASE_LOWER, - PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, - PDO::ATTR_STRINGIFY_FETCHES => false, - PDO::SQLSRV_ATTR_ENCODING => PDO::SQLSRV_ENCODING_UTF8, - ); - - /** - * 解析pdo连接的dsn信息 - * @access public - * @param array $config 连接信息 - * @return string - */ - protected function parseDsn($config){ - $dsn = 'sqlsrv:Database='.$config['database'].';Server='.$config['hostname']; - if(!empty($config['hostport'])) { - $dsn .= ','.$config['hostport']; - } - return $dsn; - } - - /** - * 取得数据表的字段信息 - * @access public - * @return array - */ - public function getFields($tableName) { - list($tableName) = explode(' ', $tableName); - $result = $this->query("SELECT column_name, data_type, column_default, is_nullable - FROM information_schema.tables AS t - JOIN information_schema.columns AS c - ON t.table_catalog = c.table_catalog - AND t.table_schema = c.table_schema - AND t.table_name = c.table_name - WHERE t.table_name = '$tableName'"); - $info = array(); - if($result) { - foreach ($result as $key => $val) { - $info[$val['column_name']] = array( - 'name' => $val['column_name'], - 'type' => $val['data_type'], - 'notnull' => (bool) ($val['is_nullable'] === ''), // not null is empty, null is yes - 'default' => $val['column_default'], - 'primary' => false, - 'autoinc' => false, - ); - } - } - return $info; - } - - /** - * 取得数据表的字段信息 - * @access public - * @return array - */ - public function getTables($dbName='') { - $result = $this->query("SELECT TABLE_NAME - FROM INFORMATION_SCHEMA.TABLES - WHERE TABLE_TYPE = 'BASE TABLE' - "); - $info = array(); - foreach ($result as $key => $val) { - $info[$key] = current($val); - } - return $info; - } - - /** - * order分析 - * @access protected - * @param mixed $order - * @return string - */ - protected function parseOrder($order) { - return !empty($order)? ' ORDER BY '.$order:' ORDER BY rand()'; - } - - /** - * 字段名分析 - * @access protected - * @param string $key - * @return string - */ - protected function parseKey(&$key) { - $key = trim($key); - if(!is_numeric($key) && !preg_match('/[,\'\"\*\(\)\[.\s]/',$key)) { - $key = '['.$key.']'; - } - return $key; - } - - /** - * limit - * @access public - * @param mixed $limit - * @return string - */ - public function parseLimit($limit) { - if(empty($limit)) return ''; - $limit = explode(',',$limit); - if(count($limit)>1) - $limitStr = '(T1.ROW_NUMBER BETWEEN '.$limit[0].' + 1 AND '.$limit[0].' + '.$limit[1].')'; - else - $limitStr = '(T1.ROW_NUMBER BETWEEN 1 AND '.$limit[0].")"; - return 'WHERE '.$limitStr; - } - - /** - * 更新记录 - * @access public - * @param mixed $data 数据 - * @param array $options 表达式 - * @return false | integer - */ - public function update($data,$options) { - $this->model = $options['model']; - $this->parseBind(!empty($options['bind'])?$options['bind']:array()); - $sql = 'UPDATE ' - .$this->parseTable($options['table']) - .$this->parseSet($data) - .$this->parseWhere(!empty($options['where'])?$options['where']:'') - .$this->parseLock(isset($options['lock'])?$options['lock']:false) - .$this->parseComment(!empty($options['comment'])?$options['comment']:''); - return $this->execute($sql,!empty($options['fetch_sql']) ? true : false); - } - - /** - * 删除记录 - * @access public - * @param array $options 表达式 - * @return false | integer - */ - public function delete($options=array()) { - $this->model = $options['model']; - $this->parseBind(!empty($options['bind'])?$options['bind']:array()); - $sql = 'DELETE FROM ' - .$this->parseTable($options['table']) - .$this->parseWhere(!empty($options['where'])?$options['where']:'') - .$this->parseLock(isset($options['lock'])?$options['lock']:false) - .$this->parseComment(!empty($options['comment'])?$options['comment']:''); - return $this->execute($sql,!empty($options['fetch_sql']) ? true : false); - } - -} \ No newline at end of file diff --git a/ThinkPHP/Library/Think/Db/Lite.class.php b/ThinkPHP/Library/Think/Db/Lite.class.php deleted file mode 100644 index 577c44b..0000000 --- a/ThinkPHP/Library/Think/Db/Lite.class.php +++ /dev/null @@ -1,466 +0,0 @@ - -// +---------------------------------------------------------------------- - -namespace Think\Db; -use Think\Config; -use Think\Debug; -use Think\Log; -use PDO; - -class Lite { - // PDO操作实例 - protected $PDOStatement = null; - // 当前操作所属的模型名 - protected $model = '_think_'; - // 当前SQL指令 - protected $queryStr = ''; - protected $modelSql = array(); - // 最后插入ID - protected $lastInsID = null; - // 返回或者影响记录数 - protected $numRows = 0; - // 事务指令数 - protected $transTimes = 0; - // 错误信息 - protected $error = ''; - // 数据库连接ID 支持多个连接 - protected $linkID = array(); - // 当前连接ID - protected $_linkID = null; - // 数据库连接参数配置 - protected $config = array( - 'type' => '', // 数据库类型 - 'hostname' => '127.0.0.1', // 服务器地址 - 'database' => '', // 数据库名 - 'username' => '', // 用户名 - 'password' => '', // 密码 - 'hostport' => '', // 端口 - 'dsn' => '', // - 'params' => array(), // 数据库连接参数 - 'charset' => 'utf8', // 数据库编码默认采用utf8 - 'prefix' => '', // 数据库表前缀 - 'debug' => false, // 数据库调试模式 - 'deploy' => 0, // 数据库部署方式:0 集中式(单一服务器),1 分布式(主从服务器) - 'rw_separate' => false, // 数据库读写是否分离 主从式有效 - 'master_num' => 1, // 读写分离后 主服务器数量 - 'slave_no' => '', // 指定从服务器序号 - ); - // 数据库表达式 - protected $comparison = array('eq'=>'=','neq'=>'<>','gt'=>'>','egt'=>'>=','lt'=>'<','elt'=>'<=','notlike'=>'NOT LIKE','like'=>'LIKE','in'=>'IN','notin'=>'NOT IN'); - // 查询表达式 - protected $selectSql = 'SELECT%DISTINCT% %FIELD% FROM %TABLE%%JOIN%%WHERE%%GROUP%%HAVING%%ORDER%%LIMIT% %UNION%%COMMENT%'; - // 查询次数 - protected $queryTimes = 0; - // 执行次数 - protected $executeTimes = 0; - // PDO连接参数 - protected $options = array( - PDO::ATTR_CASE => PDO::CASE_LOWER, - PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, - PDO::ATTR_ORACLE_NULLS => PDO::NULL_NATURAL, - PDO::ATTR_STRINGIFY_FETCHES => false, - ); - - /** - * 架构函数 读取数据库配置信息 - * @access public - * @param array $config 数据库配置数组 - */ - public function __construct($config=''){ - if(!empty($config)) { - $this->config = array_merge($this->config,$config); - if(is_array($this->config['params'])){ - $this->options += $this->config['params']; - } - } - } - - /** - * 连接数据库方法 - * @access public - */ - public function connect($config='',$linkNum=0) { - if ( !isset($this->linkID[$linkNum]) ) { - if(empty($config)) $config = $this->config; - try{ - if(empty($config['dsn'])) { - $config['dsn'] = $this->parseDsn($config); - } - if(version_compare(PHP_VERSION,'5.3.6','<=')){ //禁用模拟预处理语句 - $this->options[PDO::ATTR_EMULATE_PREPARES] = false; - } - $this->linkID[$linkNum] = new PDO( $config['dsn'], $config['username'], $config['password'],$this->options); - }catch (\PDOException $e) { - E($e->getMessage()); - } - } - return $this->linkID[$linkNum]; - } - - /** - * 解析pdo连接的dsn信息 - * @access public - * @param array $config 连接信息 - * @return string - */ - protected function parseDsn($config){} - - /** - * 释放查询结果 - * @access public - */ - public function free() { - $this->PDOStatement = null; - } - - /** - * 执行查询 返回数据集 - * @access public - * @param string $str sql指令 - * @param array $bind 参数绑定 - * @return mixed - */ - public function query($str,$bind=array()) { - $this->initConnect(false); - if ( !$this->_linkID ) return false; - $this->queryStr = $str; - if(!empty($bind)){ - $that = $this; - $this->queryStr = strtr($this->queryStr,array_map(function($val) use($that){ return '\''.$that->escapeString($val).'\''; },$bind)); - } - //释放前次的查询结果 - if ( !empty($this->PDOStatement) ) $this->free(); - $this->queryTimes++; - N('db_query',1); // 兼容代码 - // 调试开始 - $this->debug(true); - $this->PDOStatement = $this->_linkID->prepare($str); - if(false === $this->PDOStatement) - E($this->error()); - foreach ($bind as $key => $val) { - if(is_array($val)){ - $this->PDOStatement->bindValue($key, $val[0], $val[1]); - }else{ - $this->PDOStatement->bindValue($key, $val); - } - } - $result = $this->PDOStatement->execute(); - // 调试结束 - $this->debug(false); - if ( false === $result ) { - $this->error(); - return false; - } else { - return $this->getResult(); - } - } - - /** - * 执行语句 - * @access public - * @param string $str sql指令 - * @param array $bind 参数绑定 - * @return integer - */ - public function execute($str,$bind=array()) { - $this->initConnect(true); - if ( !$this->_linkID ) return false; - $this->queryStr = $str; - if(!empty($bind)){ - $that = $this; - $this->queryStr = strtr($this->queryStr,array_map(function($val) use($that){ return '\''.$that->escapeString($val).'\''; },$bind)); - } - //释放前次的查询结果 - if ( !empty($this->PDOStatement) ) $this->free(); - $this->executeTimes++; - N('db_write',1); // 兼容代码 - // 记录开始执行时间 - $this->debug(true); - $this->PDOStatement = $this->_linkID->prepare($str); - if(false === $this->PDOStatement) { - E($this->error()); - } - foreach ($bind as $key => $val) { - if(is_array($val)){ - $this->PDOStatement->bindValue($key, $val[0], $val[1]); - }else{ - $this->PDOStatement->bindValue($key, $val); - } - } - $result = $this->PDOStatement->execute(); - $this->debug(false); - if ( false === $result) { - $this->error(); - return false; - } else { - $this->numRows = $this->PDOStatement->rowCount(); - if(preg_match("/^\s*(INSERT\s+INTO|REPLACE\s+INTO)\s+/i", $str)) { - $this->lastInsID = $this->_linkID->lastInsertId(); - } - return $this->numRows; - } - } - - /** - * 启动事务 - * @access public - * @return void - */ - public function startTrans() { - $this->initConnect(true); - if ( !$this->_linkID ) return false; - //数据rollback 支持 - if ($this->transTimes == 0) { - $this->_linkID->beginTransaction(); - } - $this->transTimes++; - return ; - } - - /** - * 用于非自动提交状态下面的查询提交 - * @access public - * @return boolean - */ - public function commit() { - if ($this->transTimes > 0) { - $result = $this->_linkID->commit(); - $this->transTimes = 0; - if(!$result){ - $this->error(); - return false; - } - } - return true; - } - - /** - * 事务回滚 - * @access public - * @return boolean - */ - public function rollback() { - if ($this->transTimes > 0) { - $result = $this->_linkID->rollback(); - $this->transTimes = 0; - if(!$result){ - $this->error(); - return false; - } - } - return true; - } - - /** - * 获得所有的查询数据 - * @access private - * @return array - */ - private function getResult() { - //返回数据集 - $result = $this->PDOStatement->fetchAll(PDO::FETCH_ASSOC); - $this->numRows = count( $result ); - return $result; - } - - /** - * 获得查询次数 - * @access public - * @param boolean $execute 是否包含所有查询 - * @return integer - */ - public function getQueryTimes($execute=false){ - return $execute?$this->queryTimes+$this->executeTimes:$this->queryTimes; - } - - /** - * 获得执行次数 - * @access public - * @return integer - */ - public function getExecuteTimes(){ - return $this->executeTimes; - } - - /** - * 关闭数据库 - * @access public - */ - public function close() { - $this->_linkID = null; - } - - /** - * 数据库错误信息 - * 并显示当前的SQL语句 - * @access public - * @return string - */ - public function error() { - if($this->PDOStatement) { - $error = $this->PDOStatement->errorInfo(); - $this->error = $error[1].':'.$error[2]; - }else{ - $this->error = ''; - } - if('' != $this->queryStr){ - $this->error .= "\n [ SQL语句 ] : ".$this->queryStr; - } - // 记录错误日志 - trace($this->error,'','ERR'); - if($this->config['debug']) {// 开启数据库调试模式 - E($this->error); - }else{ - return $this->error; - } - } - - /** - * 获取最近一次查询的sql语句 - * @param string $model 模型名 - * @access public - * @return string - */ - public function getLastSql($model='') { - return $model?$this->modelSql[$model]:$this->queryStr; - } - - /** - * 获取最近插入的ID - * @access public - * @return string - */ - public function getLastInsID() { - return $this->lastInsID; - } - - /** - * 获取最近的错误信息 - * @access public - * @return string - */ - public function getError() { - return $this->error; - } - - /** - * SQL指令安全过滤 - * @access public - * @param string $str SQL字符串 - * @return string - */ - public function escapeString($str) { - return addslashes($str); - } - - /** - * 设置当前操作模型 - * @access public - * @param string $model 模型名 - * @return void - */ - public function setModel($model){ - $this->model = $model; - } - - /** - * 数据库调试 记录当前SQL - * @access protected - * @param boolean $start 调试开始标记 true 开始 false 结束 - */ - protected function debug($start) { - if($this->config['debug']) {// 开启数据库调试模式 - if($start) { - G('queryStartTime'); - }else{ - $this->modelSql[$this->model] = $this->queryStr; - //$this->model = '_think_'; - // 记录操作结束时间 - G('queryEndTime'); - trace($this->queryStr.' [ RunTime:'.G('queryStartTime','queryEndTime').'s ]','','SQL'); - } - } - } - - /** - * 初始化数据库连接 - * @access protected - * @param boolean $master 主服务器 - * @return void - */ - protected function initConnect($master=true) { - if(!empty($this->config['deploy'])) - // 采用分布式数据库 - $this->_linkID = $this->multiConnect($master); - else - // 默认单数据库 - if ( !$this->_linkID ) $this->_linkID = $this->connect(); - } - - /** - * 连接分布式服务器 - * @access protected - * @param boolean $master 主服务器 - * @return void - */ - protected function multiConnect($master=false) { - // 分布式数据库配置解析 - $_config['username'] = explode(',',$this->config['username']); - $_config['password'] = explode(',',$this->config['password']); - $_config['hostname'] = explode(',',$this->config['hostname']); - $_config['hostport'] = explode(',',$this->config['hostport']); - $_config['database'] = explode(',',$this->config['database']); - $_config['dsn'] = explode(',',$this->config['dsn']); - $_config['charset'] = explode(',',$this->config['charset']); - - // 数据库读写是否分离 - if($this->config['rw_separate']){ - // 主从式采用读写分离 - if($master) - // 主服务器写入 - $r = floor(mt_rand(0,$this->config['master_num']-1)); - else{ - if(is_numeric($this->config['slave_no'])) {// 指定服务器读 - $r = $this->config['slave_no']; - }else{ - // 读操作连接从服务器 - $r = floor(mt_rand($this->config['master_num'],count($_config['hostname'])-1)); // 每次随机连接的数据库 - } - } - }else{ - // 读写操作不区分服务器 - $r = floor(mt_rand(0,count($_config['hostname'])-1)); // 每次随机连接的数据库 - } - $db_config = array( - 'username' => isset($_config['username'][$r])?$_config['username'][$r]:$_config['username'][0], - 'password' => isset($_config['password'][$r])?$_config['password'][$r]:$_config['password'][0], - 'hostname' => isset($_config['hostname'][$r])?$_config['hostname'][$r]:$_config['hostname'][0], - 'hostport' => isset($_config['hostport'][$r])?$_config['hostport'][$r]:$_config['hostport'][0], - 'database' => isset($_config['database'][$r])?$_config['database'][$r]:$_config['database'][0], - 'dsn' => isset($_config['dsn'][$r])?$_config['dsn'][$r]:$_config['dsn'][0], - 'charset' => isset($_config['charset'][$r])?$_config['charset'][$r]:$_config['charset'][0], - ); - return $this->connect($db_config,$r); - } - - /** - * 析构方法 - * @access public - */ - public function __destruct() { - // 释放查询 - if ($this->PDOStatement){ - $this->free(); - } - // 关闭连接 - $this->close(); - } -} \ No newline at end of file diff --git a/ThinkPHP/Library/Think/Dispatcher.class.php b/ThinkPHP/Library/Think/Dispatcher.class.php deleted file mode 100644 index 0065cfb..0000000 --- a/ThinkPHP/Library/Think/Dispatcher.class.php +++ /dev/null @@ -1,339 +0,0 @@ - -// +---------------------------------------------------------------------- -namespace Think; -/** - * ThinkPHP内置的Dispatcher类 - * 完成URL解析、路由和调度 - */ -class Dispatcher { - - /** - * URL映射到控制器 - * @access public - * @return void - */ - static public function dispatch() { - $varPath = C('VAR_PATHINFO'); - $varAddon = C('VAR_ADDON'); - $varModule = C('VAR_MODULE'); - $varController = C('VAR_CONTROLLER'); - $varAction = C('VAR_ACTION'); - $urlCase = C('URL_CASE_INSENSITIVE'); - if(isset($_GET[$varPath])) { // 判断URL里面是否有兼容模式参数 - $_SERVER['PATH_INFO'] = $_GET[$varPath]; - unset($_GET[$varPath]); - }elseif(IS_CLI){ // CLI模式下 index.php module/controller/action/params/... - $_SERVER['PATH_INFO'] = isset($_SERVER['argv'][1]) ? $_SERVER['argv'][1] : ''; - } - - // 开启子域名部署 - if(C('APP_SUB_DOMAIN_DEPLOY')) { - $rules = C('APP_SUB_DOMAIN_RULES'); - if(isset($rules[$_SERVER['HTTP_HOST']])) { // 完整域名或者IP配置 - define('APP_DOMAIN',$_SERVER['HTTP_HOST']); // 当前完整域名 - $rule = $rules[APP_DOMAIN]; - }else{ - if(strpos(C('APP_DOMAIN_SUFFIX'),'.')){ // com.cn net.cn - $domain = array_slice(explode('.', $_SERVER['HTTP_HOST']), 0, -3); - }else{ - $domain = array_slice(explode('.', $_SERVER['HTTP_HOST']), 0, -2); - } - if(!empty($domain)) { - $subDomain = implode('.', $domain); - define('SUB_DOMAIN',$subDomain); // 当前完整子域名 - $domain2 = array_pop($domain); // 二级域名 - if($domain) { // 存在三级域名 - $domain3 = array_pop($domain); - } - if(isset($rules[$subDomain])) { // 子域名 - $rule = $rules[$subDomain]; - }elseif(isset($rules['*.' . $domain2]) && !empty($domain3)){ // 泛三级域名 - $rule = $rules['*.' . $domain2]; - $panDomain = $domain3; - }elseif(isset($rules['*']) && !empty($domain2) && 'www' != $domain2 ){ // 泛二级域名 - $rule = $rules['*']; - $panDomain = $domain2; - } - } - } - - if(!empty($rule)) { - // 子域名部署规则 '子域名'=>array('模块名[/控制器名]','var1=a&var2=b'); - if(is_array($rule)){ - list($rule,$vars) = $rule; - } - $array = explode('/',$rule); - // 模块绑定 - define('BIND_MODULE',array_shift($array)); - // 控制器绑定 - if(!empty($array)) { - $controller = array_shift($array); - if($controller){ - define('BIND_CONTROLLER',$controller); - } - } - if(isset($vars)) { // 传入参数 - parse_str($vars,$parms); - if(isset($panDomain)){ - $pos = array_search('*', $parms); - if(false !== $pos) { - // 泛域名作为参数 - $parms[$pos] = $panDomain; - } - } - $_GET = array_merge($_GET,$parms); - } - } - } - // 分析PATHINFO信息 - if(!isset($_SERVER['PATH_INFO'])) { - $types = explode(',',C('URL_PATHINFO_FETCH')); - foreach ($types as $type){ - if(0===strpos($type,':')) {// 支持函数判断 - $_SERVER['PATH_INFO'] = call_user_func(substr($type,1)); - break; - }elseif(!empty($_SERVER[$type])) { - $_SERVER['PATH_INFO'] = (0 === strpos($_SERVER[$type],$_SERVER['SCRIPT_NAME']))? - substr($_SERVER[$type], strlen($_SERVER['SCRIPT_NAME'])) : $_SERVER[$type]; - break; - } - } - } - - $depr = C('URL_PATHINFO_DEPR'); - define('MODULE_PATHINFO_DEPR', $depr); - - if(empty($_SERVER['PATH_INFO'])) { - $_SERVER['PATH_INFO'] = ''; - define('__INFO__',''); - define('__EXT__',''); - }else{ - define('__INFO__',trim($_SERVER['PATH_INFO'],'/')); - // URL后缀 - define('__EXT__', strtolower(pathinfo($_SERVER['PATH_INFO'],PATHINFO_EXTENSION))); - $_SERVER['PATH_INFO'] = __INFO__; - if(!defined('BIND_MODULE') && (!C('URL_ROUTER_ON') || !Route::check())){ - if (__INFO__ && C('MULTI_MODULE')){ // 获取模块名 - $paths = explode($depr,__INFO__,2); - $allowList = C('MODULE_ALLOW_LIST'); // 允许的模块列表 - $module = preg_replace('/\.' . __EXT__ . '$/i', '',$paths[0]); - if( empty($allowList) || (is_array($allowList) && in_array_case($module, $allowList))){ - $_GET[$varModule] = $module; - $_SERVER['PATH_INFO'] = isset($paths[1])?$paths[1]:''; - } - } - } - } - - // URL常量 - define('__SELF__',strip_tags($_SERVER[C('URL_REQUEST_URI')])); - - // 获取模块名称 - define('MODULE_NAME', defined('BIND_MODULE')? BIND_MODULE : self::getModule($varModule)); - - // 检测模块是否存在 - if( MODULE_NAME && (defined('BIND_MODULE') || !in_array_case(MODULE_NAME,C('MODULE_DENY_LIST')) ) && is_dir(APP_PATH.MODULE_NAME)){ - // 定义当前模块路径 - define('MODULE_PATH', APP_PATH.MODULE_NAME.'/'); - // 定义当前模块的模版缓存路径 - C('CACHE_PATH',CACHE_PATH.MODULE_NAME.'/'); - // 定义当前模块的日志目录 - C('LOG_PATH', realpath(LOG_PATH).'/'.MODULE_NAME.'/'); - - // 模块检测 - Hook::listen('module_check'); - - // 加载模块配置文件 - if(is_file(MODULE_PATH.'Conf/config'.CONF_EXT)) - C(load_config(MODULE_PATH.'Conf/config'.CONF_EXT)); - // 加载应用模式对应的配置文件 - if('common' != APP_MODE && is_file(MODULE_PATH.'Conf/config_'.APP_MODE.CONF_EXT)) - C(load_config(MODULE_PATH.'Conf/config_'.APP_MODE.CONF_EXT)); - // 当前应用状态对应的配置文件 - if(APP_STATUS && is_file(MODULE_PATH.'Conf/'.APP_STATUS.CONF_EXT)) - C(load_config(MODULE_PATH.'Conf/'.APP_STATUS.CONF_EXT)); - - // 加载模块别名定义 - if(is_file(MODULE_PATH.'Conf/alias.php')) - Think::addMap(include MODULE_PATH.'Conf/alias.php'); - // 加载模块tags文件定义 - if(is_file(MODULE_PATH.'Conf/tags.php')) - Hook::import(include MODULE_PATH.'Conf/tags.php'); - // 加载模块函数文件 - if(is_file(MODULE_PATH.'Common/function.php')) - include MODULE_PATH.'Common/function.php'; - - $urlCase = C('URL_CASE_INSENSITIVE'); - // 加载模块的扩展配置文件 - load_ext_file(MODULE_PATH); - }else{ - E(L('_MODULE_NOT_EXIST_').':'.MODULE_NAME); - } - - if(!defined('__APP__')){ - $urlMode = C('URL_MODEL'); - if($urlMode == URL_COMPAT ){// 兼容模式判断 - define('PHP_FILE',_PHP_FILE_.'?'.$varPath.'='); - }elseif($urlMode == URL_REWRITE ) { - $url = dirname(_PHP_FILE_); - if($url == '/' || $url == '\\') - $url = ''; - define('PHP_FILE',$url); - }else { - define('PHP_FILE',_PHP_FILE_); - } - // 当前应用地址 - define('__APP__',strip_tags(PHP_FILE)); - } - // 模块URL地址 - $moduleName = defined('MODULE_ALIAS')? MODULE_ALIAS : MODULE_NAME; - define('__MODULE__',(defined('BIND_MODULE') || !C('MULTI_MODULE'))? __APP__ : __APP__.'/'.($urlCase ? strtolower($moduleName) : $moduleName)); - - if('' != $_SERVER['PATH_INFO'] && (!C('URL_ROUTER_ON') || !Route::check()) ){ // 检测路由规则 如果没有则按默认规则调度URL - Hook::listen('path_info'); - // 检查禁止访问的URL后缀 - if(C('URL_DENY_SUFFIX') && preg_match('/\.('.trim(C('URL_DENY_SUFFIX'),'.').')$/i', $_SERVER['PATH_INFO'])){ - send_http_status(404); - exit; - } - - // 去除URL后缀 - $_SERVER['PATH_INFO'] = preg_replace(C('URL_HTML_SUFFIX')? '/\.('.trim(C('URL_HTML_SUFFIX'),'.').')$/i' : '/\.'.__EXT__.'$/i', '', $_SERVER['PATH_INFO']); - - $depr = C('URL_PATHINFO_DEPR'); - $paths = explode($depr,trim($_SERVER['PATH_INFO'],$depr)); - - if(!defined('BIND_CONTROLLER')) {// 获取控制器 - if(C('CONTROLLER_LEVEL')>1){// 控制器层次 - $_GET[$varController] = implode('/',array_slice($paths,0,C('CONTROLLER_LEVEL'))); - $paths = array_slice($paths, C('CONTROLLER_LEVEL')); - }else{ - $_GET[$varController] = array_shift($paths); - } - } - // 获取操作 - if(!defined('BIND_ACTION')){ - $_GET[$varAction] = array_shift($paths); - } - // 解析剩余的URL参数 - $var = array(); - if(C('URL_PARAMS_BIND') && 1 == C('URL_PARAMS_BIND_TYPE')){ - // URL参数按顺序绑定变量 - $var = $paths; - }else{ - preg_replace_callback('/(\w+)\/([^\/]+)/', function($match) use(&$var){$var[$match[1]]=strip_tags($match[2]);}, implode('/',$paths)); - } - $_GET = array_merge($var,$_GET); - } - // 获取控制器的命名空间(路径) - define('CONTROLLER_PATH', self::getSpace($varAddon,$urlCase)); - // 获取控制器和操作名 - define('CONTROLLER_NAME', defined('BIND_CONTROLLER')? BIND_CONTROLLER : self::getController($varController,$urlCase)); - define('ACTION_NAME', defined('BIND_ACTION')? BIND_ACTION : self::getAction($varAction,$urlCase)); - - // 当前控制器的UR地址 - $controllerName = defined('CONTROLLER_ALIAS')? CONTROLLER_ALIAS : CONTROLLER_NAME; - define('__CONTROLLER__',__MODULE__.$depr.(defined('BIND_CONTROLLER')? '': ( $urlCase ? parse_name($controllerName) : $controllerName )) ); - - // 当前操作的URL地址 - define('__ACTION__',__CONTROLLER__.$depr.(defined('ACTION_ALIAS')?ACTION_ALIAS:ACTION_NAME)); - - //保证$_REQUEST正常取值 - $_REQUEST = array_merge($_POST,$_GET,$_COOKIE); // -- 加了$_COOKIE. 保证哦.. - } - - /** - * 获得控制器的命名空间路径 便于插件机制访问 - */ - static private function getSpace($var,$urlCase) { - $space = !empty($_GET[$var])?strip_tags($_GET[$var]):''; - unset($_GET[$var]); - return $space; - } - - /** - * 获得实际的控制器名称 - */ - static private function getController($var,$urlCase) { - $controller = (!empty($_GET[$var])? $_GET[$var]:C('DEFAULT_CONTROLLER')); - unset($_GET[$var]); - if($maps = C('URL_CONTROLLER_MAP')) { - if(isset($maps[strtolower($controller)])) { - // 记录当前别名 - define('CONTROLLER_ALIAS',strtolower($controller)); - // 获取实际的控制器名 - return ucfirst($maps[CONTROLLER_ALIAS]); - }elseif(array_search(strtolower($controller),$maps)){ - // 禁止访问原始控制器 - return ''; - } - } - if($urlCase) { - // URL地址不区分大小写 - // 智能识别方式 user_type 识别到 UserTypeController 控制器 - $controller = parse_name($controller,1); - } - return strip_tags(ucfirst($controller)); - } - - /** - * 获得实际的操作名称 - */ - static private function getAction($var,$urlCase) { - $action = !empty($_POST[$var]) ? - $_POST[$var] : - (!empty($_GET[$var])?$_GET[$var]:C('DEFAULT_ACTION')); - unset($_POST[$var],$_GET[$var]); - if($maps = C('URL_ACTION_MAP')) { - if(isset($maps[strtolower(CONTROLLER_NAME)])) { - $maps = $maps[strtolower(CONTROLLER_NAME)]; - if(isset($maps[strtolower($action)])) { - // 记录当前别名 - define('ACTION_ALIAS',strtolower($action)); - // 获取实际的操作名 - if(is_array($maps[ACTION_ALIAS])){ - parse_str($maps[ACTION_ALIAS][1],$vars); - $_GET = array_merge($_GET,$vars); - return $maps[ACTION_ALIAS][0]; - }else{ - return $maps[ACTION_ALIAS]; - } - - }elseif(array_search(strtolower($action),$maps)){ - // 禁止访问原始操作 - return ''; - } - } - } - return strip_tags( $urlCase? strtolower($action) : $action ); - } - - /** - * 获得实际的模块名称 - */ - static private function getModule($var) { - $module = (!empty($_GET[$var])?$_GET[$var]:C('DEFAULT_MODULE')); - unset($_GET[$var]); - if($maps = C('URL_MODULE_MAP')) { - if(isset($maps[strtolower($module)])) { - // 记录当前别名 - define('MODULE_ALIAS',strtolower($module)); - // 获取实际的模块名 - return ucfirst($maps[MODULE_ALIAS]); - }elseif(array_search(strtolower($module),$maps)){ - // 禁止访问原始模块 - return ''; - } - } - return strip_tags(ucfirst($module)); - } - -} diff --git a/ThinkPHP/Library/Think/Exception.class.php b/ThinkPHP/Library/Think/Exception.class.php deleted file mode 100644 index 7b4a918..0000000 --- a/ThinkPHP/Library/Think/Exception.class.php +++ /dev/null @@ -1,16 +0,0 @@ - -// +---------------------------------------------------------------------- -namespace Think; -/** - * ThinkPHP系统异常基类 - */ -class Exception extends \Exception { -} \ No newline at end of file diff --git a/ThinkPHP/Library/Think/Hook.class.php b/ThinkPHP/Library/Think/Hook.class.php deleted file mode 100644 index 51176c7..0000000 --- a/ThinkPHP/Library/Think/Hook.class.php +++ /dev/null @@ -1,121 +0,0 @@ - -// +---------------------------------------------------------------------- -namespace Think; -/** - * ThinkPHP系统钩子实现 - */ -class Hook { - - static private $tags = array(); - - /** - * 动态添加插件到某个标签 - * @param string $tag 标签名称 - * @param mixed $name 插件名称 - * @return void - */ - static public function add($tag,$name) { - if(!isset(self::$tags[$tag])){ - self::$tags[$tag] = array(); - } - if(is_array($name)){ - self::$tags[$tag] = array_merge(self::$tags[$tag],$name); - }else{ - self::$tags[$tag][] = $name; - } - } - - /** - * 批量导入插件 - * @param array $data 插件信息 - * @param boolean $recursive 是否递归合并 - * @return void - */ - static public function import($data,$recursive=true) { - if(!$recursive){ // 覆盖导入 - self::$tags = array_merge(self::$tags,$data); - }else{ // 合并导入 - foreach ($data as $tag=>$val){ - if(!isset(self::$tags[$tag])) - self::$tags[$tag] = array(); - if(!empty($val['_overlay'])){ - // 可以针对某个标签指定覆盖模式 - unset($val['_overlay']); - self::$tags[$tag] = $val; - }else{ - // 合并模式 - self::$tags[$tag] = array_merge(self::$tags[$tag],$val); - } - } - } - } - - /** - * 获取插件信息 - * @param string $tag 插件位置 留空获取全部 - * @return array - */ - static public function get($tag='') { - if(empty($tag)){ - // 获取全部的插件信息 - return self::$tags; - }else{ - return self::$tags[$tag]; - } - } - - /** - * 监听标签的插件 - * @param string $tag 标签名称 - * @param mixed $params 传入参数 - * @return void - */ - static public function listen($tag, &$params=NULL) { - if(isset(self::$tags[$tag])) { - if(APP_DEBUG) { - G($tag.'Start'); - trace('[ '.$tag.' ] --START--','','INFO'); - } - foreach (self::$tags[$tag] as $name) { - APP_DEBUG && G($name.'_start'); - $result = self::exec($name, $tag,$params); - if(APP_DEBUG){ - G($name.'_end'); - trace('Run '.$name.' [ RunTime:'.G($name.'_start',$name.'_end',6).'s ]','','INFO'); - } - if(false === $result) { - // 如果返回false 则中断插件执行 - return ; - } - } - if(APP_DEBUG) { // 记录行为的执行日志 - trace('[ '.$tag.' ] --END-- [ RunTime:'.G($tag.'Start',$tag.'End',6).'s ]','','INFO'); - } - } - return; - } - - /** - * 执行某个插件 - * @param string $name 插件名称 - * @param string $tag 方法名(标签名) - * @param Mixed $params 传入的参数 - * @return void - */ - static public function exec($name, $tag,&$params=NULL) { - if('Behavior' == substr($name,-8) ){ - // 行为扩展必须用run入口方法 - $tag = 'run'; - } - $addon = new $name(); - return $addon->$tag($params); - } -} diff --git a/ThinkPHP/Library/Think/Log.class.php b/ThinkPHP/Library/Think/Log.class.php deleted file mode 100644 index 09b1155..0000000 --- a/ThinkPHP/Library/Think/Log.class.php +++ /dev/null @@ -1,104 +0,0 @@ - -// +---------------------------------------------------------------------- -namespace Think; -/** - * 日志处理类 - */ -class Log { - - // 日志级别 从上到下,由低到高 - const EMERG = 'EMERG'; // 严重错误: 导致系统崩溃无法使用 - const ALERT = 'ALERT'; // 警戒性错误: 必须被立即修改的错误 - const CRIT = 'CRIT'; // 临界值错误: 超过临界值的错误,例如一天24小时,而输入的是25小时这样 - const ERR = 'ERR'; // 一般错误: 一般性错误 - const WARN = 'WARN'; // 警告性错误: 需要发出警告的错误 - const NOTICE = 'NOTIC'; // 通知: 程序可以运行但是还不够完美的错误 - const INFO = 'INFO'; // 信息: 程序输出信息 - const DEBUG = 'DEBUG'; // 调试: 调试信息 - const SQL = 'SQL'; // SQL:SQL语句 注意只在调试模式开启时有效 - - // 日志信息 - static protected $log = array(); - - // 日志存储 - static protected $storage = null; - - // 日志初始化 - static public function init($config=array()){ - $type = isset($config['type']) ? $config['type'] : 'File'; - $class = strpos($type,'\\')? $type: 'Think\\Log\\Driver\\'. ucwords(strtolower($type)); - unset($config['type']); - self::$storage = new $class($config); - } - - /** - * 记录日志 并且会过滤未经设置的级别 - * @static - * @access public - * @param string $message 日志信息 - * @param string $level 日志级别 - * @param boolean $record 是否强制记录 - * @return void - */ - static function record($message,$level=self::ERR,$record=false) { - if($record || false !== strpos(C('LOG_LEVEL'),$level)) { - self::$log[] = "{$level}: {$message}\r\n"; - } - } - - /** - * 日志保存 - * @static - * @access public - * @param integer $type 日志记录方式 - * @param string $destination 写入目标 - * @return void - */ - static function save($type='',$destination='') { - if(empty(self::$log)) return ; - - if(empty($destination)){ - $destination = C('LOG_PATH').date('y_m_d').'.log'; - } - if(!self::$storage){ - $type = $type ? : C('LOG_TYPE'); - $class = 'Think\\Log\\Driver\\'. ucwords($type); - self::$storage = new $class(); - } - $message = implode('',self::$log); - self::$storage->write($message,$destination); - // 保存后清空日志缓存 - self::$log = array(); - } - - /** - * 日志直接写入 - * @static - * @access public - * @param string $message 日志信息 - * @param string $level 日志级别 - * @param integer $type 日志记录方式 - * @param string $destination 写入目标 - * @return void - */ - static function write($message,$level=self::ERR,$type='',$destination='') { - if(!self::$storage){ - $type = $type ? : C('LOG_TYPE'); - $class = 'Think\\Log\\Driver\\'. ucwords($type); - $config['log_path'] = C('LOG_PATH'); - self::$storage = new $class($config); - } - if(empty($destination)){ - $destination = C('LOG_PATH').date('y_m_d').'.log'; - } - self::$storage->write("{$level}: {$message}", $destination); - } -} \ No newline at end of file diff --git a/ThinkPHP/Library/Think/Log/Driver/File.class.php b/ThinkPHP/Library/Think/Log/Driver/File.class.php deleted file mode 100644 index 290746e..0000000 --- a/ThinkPHP/Library/Think/Log/Driver/File.class.php +++ /dev/null @@ -1,50 +0,0 @@ - -// +---------------------------------------------------------------------- - -namespace Think\Log\Driver; - -class File { - - protected $config = array( - 'log_time_format' => ' c ', - 'log_file_size' => 2097152, - 'log_path' => '', - ); - - // 实例化并传入参数 - public function __construct($config=array()){ - $this->config = array_merge($this->config,$config); - } - - /** - * 日志写入接口 - * @access public - * @param string $log 日志信息 - * @param string $destination 写入目标 - * @return void - */ - public function write($log,$destination='') { - $now = date($this->config['log_time_format']); - if(empty($destination)){ - $destination = $this->config['log_path'].date('y_m_d').'.log'; - } - // 自动创建日志目录 - $log_dir = dirname($destination); - if (!is_dir($log_dir)) { - mkdir($log_dir, 0755, true); - } - //检测日志文件大小,超过配置大小则备份日志文件重新生成 - if(is_file($destination) && floor($this->config['log_file_size']) <= filesize($destination) ){ - rename($destination,dirname($destination).'/'.time().'-'.basename($destination)); - } - error_log("[{$now}] ".$_SERVER['REMOTE_ADDR'].' '.$_SERVER['REQUEST_URI']."\r\n{$log}\r\n", 3,$destination); - } -} diff --git a/ThinkPHP/Library/Think/Log/Driver/Sae.class.php b/ThinkPHP/Library/Think/Log/Driver/Sae.class.php deleted file mode 100644 index accbcae..0000000 --- a/ThinkPHP/Library/Think/Log/Driver/Sae.class.php +++ /dev/null @@ -1,49 +0,0 @@ - -// +---------------------------------------------------------------------- - -namespace Think\Log\Driver; - -class Sae { - - protected $config = array( - 'log_time_format' => ' c ', - ); - - // 实例化并传入参数 - public function __construct($config=array()){ - $this->config = array_merge($this->config,$config); - } - - /** - * 日志写入接口 - * @access public - * @param string $log 日志信息 - * @param string $destination 写入目标 - * @return void - */ - public function write($log,$destination='') { - static $is_debug=null; - $now = date($this->config['log_time_format']); - $logstr="[{$now}] ".$_SERVER['REMOTE_ADDR'].' '.$_SERVER['REQUEST_URI']."\r\n{$log}\r\n"; - if(is_null($is_debug)){ - preg_replace('@(\w+)\=([^;]*)@e', '$appSettings[\'\\1\']="\\2";', $_SERVER['HTTP_APPCOOKIE']); - $is_debug = in_array($_SERVER['HTTP_APPVERSION'], explode(',', $appSettings['debug'])) ? true : false; - } - if($is_debug){ - sae_set_display_errors(false);//记录日志不将日志打印出来 - } - sae_debug($logstr); - if($is_debug){ - sae_set_display_errors(true); - } - - } -} diff --git a/ThinkPHP/Library/Think/Model.class.php b/ThinkPHP/Library/Think/Model.class.php deleted file mode 100644 index e56474b..0000000 --- a/ThinkPHP/Library/Think/Model.class.php +++ /dev/null @@ -1,1910 +0,0 @@ - -// +---------------------------------------------------------------------- -namespace Think; -/** - * ThinkPHP Model模型类 - * 实现了ORM和ActiveRecords模式 - */ -class Model { - // 操作状态 - const MODEL_INSERT = 1; // 插入模型数据 - const MODEL_UPDATE = 2; // 更新模型数据 - const MODEL_BOTH = 3; // 包含上面两种方式 - const MUST_VALIDATE = 1; // 必须验证 - const EXISTS_VALIDATE = 0; // 表单存在字段则验证 - const VALUE_VALIDATE = 2; // 表单值不为空则验证 - - // 当前数据库操作对象 - protected $db = null; - // 数据库对象池 - private $_db = array(); - // 主键名称 - protected $pk = 'id'; - // 主键是否自动增长 - protected $autoinc = false; - // 数据表前缀 - protected $tablePrefix = null; - // 模型名称 - protected $name = ''; - // 数据库名称 - protected $dbName = ''; - //数据库配置 - protected $connection = ''; - // 数据表名(不包含表前缀) - protected $tableName = ''; - // 实际数据表名(包含表前缀) - protected $trueTableName = ''; - // 最近错误信息 - protected $error = ''; - // 字段信息 - protected $fields = array(); - // 数据信息 - protected $data = array(); - // 查询表达式参数 - protected $options = array(); - protected $_validate = array(); // 自动验证定义 - protected $_auto = array(); // 自动完成定义 - protected $_map = array(); // 字段映射定义 - protected $_scope = array(); // 命名范围定义 - // 是否自动检测数据表字段信息 - protected $autoCheckFields = true; - // 是否批处理验证 - protected $patchValidate = false; - // 链操作方法列表 - protected $methods = array('strict','order','alias','having','group','lock','distinct','auto','filter','validate','result','token','index','force'); - - /** - * 架构函数 - * 取得DB类的实例对象 字段检查 - * @access public - * @param string $name 模型名称 - * @param string $tablePrefix 表前缀 - * @param mixed $connection 数据库连接信息 - */ - public function __construct($name='',$tablePrefix='',$connection='') { - // 模型初始化 - $this->_initialize(); - // 获取模型名称 - if(!empty($name)) { - if(strpos($name,'.')) { // 支持 数据库名.模型名的 定义 - list($this->dbName,$this->name) = explode('.',$name); - }else{ - $this->name = $name; - } - }elseif(empty($this->name)){ - $this->name = $this->getModelName(); - } - // 设置表前缀 - if(is_null($tablePrefix)) {// 前缀为Null表示没有前缀 - $this->tablePrefix = ''; - }elseif('' != $tablePrefix) { - $this->tablePrefix = $tablePrefix; - }elseif(!isset($this->tablePrefix)){ - $this->tablePrefix = C('DB_PREFIX'); - } - - // 数据库初始化操作 - // 获取数据库操作对象 - // 当前模型有独立的数据库连接信息 - $this->db(0,empty($this->connection)?$connection:$this->connection,true); - } - - /** - * 自动检测数据表信息 - * @access protected - * @return void - */ - protected function _checkTableInfo() { - // 如果不是Model类 自动记录数据表信息 - // 只在第一次执行记录 - if(empty($this->fields)) { - // 如果数据表字段没有定义则自动获取 - if(C('DB_FIELDS_CACHE')) { - $db = $this->dbName?:C('DB_NAME'); - $fields = F('_fields/'.strtolower($db.'.'.$this->tablePrefix.$this->name)); - if($fields) { - $this->fields = $fields; - if(!empty($fields['_pk'])){ - $this->pk = $fields['_pk']; - } - return ; - } - } - // 每次都会读取数据表信息 - $this->flush(); - } - } - - /** - * 获取字段信息并缓存 - * @access public - * @return void - */ - public function flush() { - // 缓存不存在则查询数据表信息 - $this->db->setModel($this->name); - $fields = $this->db->getFields($this->getTableName()); - if(!$fields) { // 无法获取字段信息 - return false; - } - $this->fields = array_keys($fields); - unset($this->fields['_pk']); - foreach ($fields as $key=>$val){ - // 记录字段类型 - $type[$key] = $val['type']; - if($val['primary']) { - // 增加复合主键支持 - if (isset($this->fields['_pk']) && $this->fields['_pk'] != null) { - if (is_string($this->fields['_pk'])) { - $this->pk = array($this->fields['_pk']); - $this->fields['_pk'] = $this->pk; - } - $this->pk[] = $key; - $this->fields['_pk'][] = $key; - } else { - $this->pk = $key; - $this->fields['_pk'] = $key; - } - if($val['autoinc']) $this->autoinc = true; - } - } - // 记录字段类型信息 - $this->fields['_type'] = $type; - - // 2008-3-7 增加缓存开关控制 - if(C('DB_FIELDS_CACHE')){ - // 永久缓存数据表信息 - $db = $this->dbName?:C('DB_NAME'); - F('_fields/'.strtolower($db.'.'.$this->tablePrefix.$this->name),$this->fields); - } - } - - /** - * 设置数据对象的值 - * @access public - * @param string $name 名称 - * @param mixed $value 值 - * @return void - */ - public function __set($name,$value) { - // 设置数据对象属性 - $this->data[$name] = $value; - } - - /** - * 获取数据对象的值 - * @access public - * @param string $name 名称 - * @return mixed - */ - public function __get($name) { - return isset($this->data[$name])?$this->data[$name]:null; - } - - /** - * 检测数据对象的值 - * @access public - * @param string $name 名称 - * @return boolean - */ - public function __isset($name) { - return isset($this->data[$name]); - } - - /** - * 销毁数据对象的值 - * @access public - * @param string $name 名称 - * @return void - */ - public function __unset($name) { - unset($this->data[$name]); - } - - /** - * 利用__call方法实现一些特殊的Model方法 - * @access public - * @param string $method 方法名称 - * @param array $args 调用参数 - * @return mixed - */ - public function __call($method,$args) { - if(in_array(strtolower($method),$this->methods,true)) { - // 连贯操作的实现 - $this->options[strtolower($method)] = $args[0]; - return $this; - }elseif(in_array(strtolower($method),array('count','sum','min','max','avg'),true)){ - // 统计查询的实现 - $field = isset($args[0])?$args[0]:'*'; - return $this->getField(strtoupper($method).'('.$field.') AS tp_'.$method); - }elseif(strtolower(substr($method,0,5))=='getby') { - // 根据某个字段获取记录 - $field = parse_name(substr($method,5)); - $where[$field] = $args[0]; - return $this->where($where)->find(); - }elseif(strtolower(substr($method,0,10))=='getfieldby') { - // 根据某个字段获取记录的某个值 - $name = parse_name(substr($method,10)); - $where[$name] =$args[0]; - return $this->where($where)->getField($args[1]); - }elseif(isset($this->_scope[$method])){// 命名范围的单独调用支持 - return $this->scope($method,$args[0]); - }else{ - E(__CLASS__.':'.$method.L('_METHOD_NOT_EXIST_')); - return; - } - } - // 回调方法 初始化模型 - protected function _initialize() {} - - /** - * 对保存到数据库的数据进行处理 - * @access protected - * @param mixed $data 要操作的数据 - * @return boolean - */ - protected function _facade($data) { - - // 检查数据字段合法性 - if(!empty($this->fields)) { - if(!empty($this->options['field'])) { - $fields = $this->options['field']; - unset($this->options['field']); - if(is_string($fields)) { - $fields = explode(',',$fields); - } - }else{ - $fields = $this->fields; - } - foreach ($data as $key=>$val){ - if(!in_array($key,$fields,true)){ - if(!empty($this->options['strict'])){ - E(L('_DATA_TYPE_INVALID_').':['.$key.'=>'.$val.']'); - } - unset($data[$key]); - }elseif(is_scalar($val)) { - // 字段类型检查 和 强制转换 - $this->_parseType($data,$key); - } - } - } - - // 安全过滤 - if(!empty($this->options['filter'])) { - $data = array_map($this->options['filter'],$data); - unset($this->options['filter']); - } - $this->_before_write($data); - return $data; - } - - // 写入数据前的回调方法 包括新增和更新 - protected function _before_write(&$data) {} - - /** - * 新增数据 - * @access public - * @param mixed $data 数据 - * @param array $options 表达式 - * @param boolean $replace 是否replace - * @return mixed - */ - public function add($data='',$options=array(),$replace=false) { - if(empty($data)) { - // 没有传递数据,获取当前数据对象的值 - if(!empty($this->data)) { - $data = $this->data; - // 重置数据 - $this->data = array(); - }else{ - $this->error = L('_DATA_TYPE_INVALID_'); - return false; - } - } - // 数据处理 - $data = $this->_facade($data); - // 分析表达式 - $options = $this->_parseOptions($options); - if(false === $this->_before_insert($data,$options)) { - return false; - } - // 写入数据到数据库 - $result = $this->db->insert($data,$options,$replace); - if(false !== $result && is_numeric($result)) { - $pk = $this->getPk(); - // 增加复合主键支持 - if (is_array($pk)) return $result; - $insertId = $this->getLastInsID(); - if($insertId) { - // 自增主键返回插入ID - $data[$pk] = $insertId; - if(false === $this->_after_insert($data,$options)) { - return false; - } - return $insertId; - } - if(false === $this->_after_insert($data,$options)) { - return false; - } - } - return $result; - } - // 插入数据前的回调方法 - protected function _before_insert(&$data,$options) {} - // 插入成功后的回调方法 - protected function _after_insert($data,$options) {} - - public function addAll($dataList,$options=array(),$replace=false){ - if(empty($dataList)) { - $this->error = L('_DATA_TYPE_INVALID_'); - return false; - } - // 数据处理 - foreach ($dataList as $key=>$data){ - $dataList[$key] = $this->_facade($data); - } - // 分析表达式 - $options = $this->_parseOptions($options); - // 写入数据到数据库 - $result = $this->db->insertAll($dataList,$options,$replace); - if(false !== $result ) { - $insertId = $this->getLastInsID(); - if($insertId) { - return $insertId; - } - } - return $result; - } - - /** - * 通过Select方式添加记录 - * @access public - * @param string $fields 要插入的数据表字段名 - * @param string $table 要插入的数据表名 - * @param array $options 表达式 - * @return boolean - */ - public function selectAdd($fields='',$table='',$options=array()) { - // 分析表达式 - $options = $this->_parseOptions($options); - // 写入数据到数据库 - if(false === $result = $this->db->selectInsert($fields?:$options['field'],$table?:$this->getTableName(),$options)){ - // 数据库插入操作失败 - $this->error = L('_OPERATION_WRONG_'); - return false; - }else { - // 插入成功 - return $result; - } - } - - /** - * 保存数据 - * @access public - * @param mixed $data 数据 - * @param array $options 表达式 - * @return boolean - */ - public function save($data='',$options=array()) { - if(empty($data)) { - // 没有传递数据,获取当前数据对象的值 - if(!empty($this->data)) { - $data = $this->data; - // 重置数据 - $this->data = array(); - }else{ - $this->error = L('_DATA_TYPE_INVALID_'); - return false; - } - } - // 数据处理 - $data = $this->_facade($data); - if(empty($data)){ - // 没有数据则不执行 - $this->error = L('_DATA_TYPE_INVALID_'); - return false; - } - // 分析表达式 - $options = $this->_parseOptions($options); - $pk = $this->getPk(); - if(!isset($options['where']) ) { - // 如果存在主键数据 则自动作为更新条件 - if (is_string($pk) && isset($data[$pk])) { - $where[$pk] = $data[$pk]; - unset($data[$pk]); - } elseif (is_array($pk)) { - // 增加复合主键支持 - foreach ($pk as $field) { - if(isset($data[$field])) { - $where[$field] = $data[$field]; - } else { - // 如果缺少复合主键数据则不执行 - $this->error = L('_OPERATION_WRONG_'); - return false; - } - unset($data[$field]); - } - } - if(!isset($where)){ - // 如果没有任何更新条件则不执行 - $this->error = L('_OPERATION_WRONG_'); - return false; - }else{ - $options['where'] = $where; - } - } - - if(is_array($options['where']) && isset($options['where'][$pk])){ - $pkValue = $options['where'][$pk]; - } - if(false === $this->_before_update($data,$options)) { - return false; - } - $result = $this->db->update($data,$options); - if(false !== $result && is_numeric($result)) { - if(isset($pkValue)) $data[$pk] = $pkValue; - $this->_after_update($data,$options); - } - return $result; - } - // 更新数据前的回调方法 - protected function _before_update(&$data,$options) {} - // 更新成功后的回调方法 - protected function _after_update($data,$options) {} - - /** - * 删除数据 - * @access public - * @param mixed $options 表达式 - * @return mixed - */ - public function delete($options=array()) { - $pk = $this->getPk(); - if(empty($options) && empty($this->options['where'])) { - // 如果删除条件为空 则删除当前数据对象所对应的记录 - if(!empty($this->data) && isset($this->data[$pk])) - return $this->delete($this->data[$pk]); - else - return false; - } - if(is_numeric($options) || is_string($options)) { - // 根据主键删除记录 - if(strpos($options,',')) { - $where[$pk] = array('IN', $options); - }else{ - $where[$pk] = $options; - } - $options = array(); - $options['where'] = $where; - } - // 根据复合主键删除记录 - if (is_array($options) && (count($options) > 0) && is_array($pk)) { - $count = 0; - foreach (array_keys($options) as $key) { - if (is_int($key)) $count++; - } - if ($count == count($pk)) { - $i = 0; - foreach ($pk as $field) { - $where[$field] = $options[$i]; - unset($options[$i++]); - } - $options['where'] = $where; - } else { - return false; - } - } - // 分析表达式 - $options = $this->_parseOptions($options); - if(empty($options['where'])){ - // 如果条件为空 不进行删除操作 除非设置 1=1 - return false; - } - if(is_array($options['where']) && isset($options['where'][$pk])){ - $pkValue = $options['where'][$pk]; - } - - if(false === $this->_before_delete($options)) { - return false; - } - $result = $this->db->delete($options); - if(false !== $result && is_numeric($result)) { - $data = array(); - if(isset($pkValue)) $data[$pk] = $pkValue; - $this->_after_delete($data,$options); - } - // 返回删除记录个数 - return $result; - } - // 删除数据前的回调方法 - protected function _before_delete($options) {} - // 删除成功后的回调方法 - protected function _after_delete($data,$options) {} - - /** - * 查询数据集 - * @access public - * @param array $options 表达式参数 - * @return mixed - */ - public function select($options=array()) { - $pk = $this->getPk(); - if(is_string($options) || is_numeric($options)) { - // 根据主键查询 - if(strpos($options,',')) { - $where[$pk] = array('IN',$options); - }else{ - $where[$pk] = $options; - } - $options = array(); - $options['where'] = $where; - }elseif (is_array($options) && (count($options) > 0) && is_array($pk)) { - // 根据复合主键查询 - $count = 0; - foreach (array_keys($options) as $key) { - if (is_int($key)) $count++; - } - if ($count == count($pk)) { - $i = 0; - foreach ($pk as $field) { - $where[$field] = $options[$i]; - unset($options[$i++]); - } - $options['where'] = $where; - } else { - return false; - } - } elseif(false === $options){ // 用于子查询 不查询只返回SQL - $options['fetch_sql'] = true; - } - // 分析表达式 - $options = $this->_parseOptions($options); - // 判断查询缓存 - if(isset($options['cache'])){ - $cache = $options['cache']; - $key = is_string($cache['key'])?$cache['key']:md5(serialize($options)); - $data = S($key,'',$cache); - if(false !== $data){ - return $data; - } - } - $resultSet = $this->db->select($options); - if(false === $resultSet) { - return false; - } - if(!empty($resultSet)) { // 有查询结果 - if(is_string($resultSet)){ - return $resultSet; - } - - $resultSet = array_map(array($this,'_read_data'),$resultSet); - $this->_after_select($resultSet,$options); - if(isset($options['index'])){ // 对数据集进行索引 - $index = explode(',',$options['index']); - foreach ($resultSet as $result){ - $_key = $result[$index[0]]; - if(isset($index[1]) && isset($result[$index[1]])){ - $cols[$_key] = $result[$index[1]]; - }else{ - $cols[$_key] = $result; - } - } - $resultSet = $cols; - } - } - - if(isset($cache)){ - S($key,$resultSet,$cache); - } - return $resultSet; - } - // 查询成功后的回调方法 - protected function _after_select(&$resultSet,$options) {} - - /** - * 生成查询SQL 可用于子查询 - * @access public - * @return string - */ - public function buildSql() { - return '( '.$this->fetchSql(true)->select().' )'; - } - - /** - * 分析表达式 - * @access protected - * @param array $options 表达式参数 - * @return array - */ - protected function _parseOptions($options=array()) { - if(is_array($options)) - $options = array_merge($this->options,$options); - - if(!isset($options['table'])){ - // 自动获取表名 - $options['table'] = $this->getTableName(); - $fields = $this->fields; - }else{ - // 指定数据表 则重新获取字段列表 但不支持类型检测 - $fields = $this->getDbFields(); - } - - // 数据表别名 - if(!empty($options['alias'])) { - $options['table'] .= ' '.$options['alias']; - } - // 记录操作的模型名称 - $options['model'] = $this->name; - - // 字段类型验证 - if(isset($options['where']) && is_array($options['where']) && !empty($fields) && !isset($options['join'])) { - // 对数组查询条件进行字段类型检查 - foreach ($options['where'] as $key=>$val){ - $key = trim($key); - if(in_array($key,$fields,true)){ - if(is_scalar($val)) { - $this->_parseType($options['where'],$key); - } - }elseif(!is_numeric($key) && '_' != substr($key,0,1) && false === strpos($key,'.') && false === strpos($key,'(') && false === strpos($key,'|') && false === strpos($key,'&')){ - if(!empty($this->options['strict'])){ - E(L('_ERROR_QUERY_EXPRESS_').':['.$key.'=>'.$val.']'); - } - unset($options['where'][$key]); - } - } - } - // 查询过后清空sql表达式组装 避免影响下次查询 - $this->options = array(); - // 表达式过滤 - $this->_options_filter($options); - return $options; - } - // 表达式过滤回调方法 - protected function _options_filter(&$options) {} - - /** - * 数据类型检测 - * @access protected - * @param mixed $data 数据 - * @param string $key 字段名 - * @return void - */ - protected function _parseType(&$data,$key) { - if(!isset($this->options['bind'][':'.$key]) && isset($this->fields['_type'][$key])){ - $fieldType = strtolower($this->fields['_type'][$key]); - if(false !== strpos($fieldType,'enum')){ - // 支持ENUM类型优先检测 - }elseif(false === strpos($fieldType,'bigint') && false !== strpos($fieldType,'int')) { - $data[$key] = intval($data[$key]); - }elseif(false !== strpos($fieldType,'float') || false !== strpos($fieldType,'double')){ - $data[$key] = floatval($data[$key]); - }elseif(false !== strpos($fieldType,'bool')){ - $data[$key] = (bool)$data[$key]; - } - } - } - - /** - * 数据读取后的处理 - * @access protected - * @param array $data 当前数据 - * @return array - */ - protected function _read_data($data) { - // 检查字段映射 - if(!empty($this->_map) && C('READ_DATA_MAP')) { - foreach ($this->_map as $key=>$val){ - if(isset($data[$val])) { - $data[$key] = $data[$val]; - unset($data[$val]); - } - } - } - return $data; - } - - /** - * 查询数据 - * @access public - * @param mixed $options 表达式参数 - * @return mixed - */ - public function find($options=array()) { - if(is_numeric($options) || is_string($options)) { - $where[$this->getPk()] = $options; - $options = array(); - $options['where'] = $where; - } - // 根据复合主键查找记录 - $pk = $this->getPk(); - if (is_array($options) && (count($options) > 0) && is_array($pk)) { - // 根据复合主键查询 - $count = 0; - foreach (array_keys($options) as $key) { - if (is_int($key)) $count++; - } - if ($count == count($pk)) { - $i = 0; - foreach ($pk as $field) { - $where[$field] = $options[$i]; - unset($options[$i++]); - } - $options['where'] = $where; - } else { - return false; - } - } - // 总是查找一条记录 - $options['limit'] = 1; - // 分析表达式 - $options = $this->_parseOptions($options); - // 判断查询缓存 - if(isset($options['cache'])){ - $cache = $options['cache']; - $key = is_string($cache['key'])?$cache['key']:md5(serialize($options)); - $data = S($key,'',$cache); - if(false !== $data){ - $this->data = $data; - return $data; - } - } - $resultSet = $this->db->select($options); - if(false === $resultSet) { - return false; - } - if(empty($resultSet)) {// 查询结果为空 - return null; - } - if(is_string($resultSet)){ - return $resultSet; - } - - // 读取数据后的处理 - $data = $this->_read_data($resultSet[0]); - $this->_after_find($data,$options); - if(!empty($this->options['result'])) { - return $this->returnResult($data,$this->options['result']); - } - $this->data = $data; - if(isset($cache)){ - S($key,$data,$cache); - } - return $this->data; - } - // 查询成功的回调方法 - protected function _after_find(&$result,$options) {} - - protected function returnResult($data,$type=''){ - if ($type){ - if(is_callable($type)){ - return call_user_func($type,$data); - } - switch (strtolower($type)){ - case 'json': - return json_encode($data); - case 'xml': - return xml_encode($data); - } - } - return $data; - } - - /** - * 处理字段映射 - * @access public - * @param array $data 当前数据 - * @param integer $type 类型 0 写入 1 读取 - * @return array - */ - public function parseFieldsMap($data,$type=1) { - // 检查字段映射 - if(!empty($this->_map)) { - foreach ($this->_map as $key=>$val){ - if($type==1) { // 读取 - if(isset($data[$val])) { - $data[$key] = $data[$val]; - unset($data[$val]); - } - }else{ - if(isset($data[$key])) { - $data[$val] = $data[$key]; - unset($data[$key]); - } - } - } - } - return $data; - } - - /** - * 设置记录的某个字段值 - * 支持使用数据库字段和方法 - * @access public - * @param string|array $field 字段名 - * @param string $value 字段值 - * @return boolean - */ - public function setField($field,$value='') { - if(is_array($field)) { - $data = $field; - }else{ - $data[$field] = $value; - } - return $this->save($data); - } - - /** - * 字段值增长 - * @access public - * @param string $field 字段名 - * @param integer $step 增长值 - * @param integer $lazyTime 延时时间(s) - * @return boolean - */ - public function setInc($field,$step=1,$lazyTime=0) { - if($lazyTime>0) {// 延迟写入 - $condition = $this->options['where']; - $guid = md5($this->name.'_'.$field.'_'.serialize($condition)); - $step = $this->lazyWrite($guid,$step,$lazyTime); - if(empty($step)) { - return true; // 等待下次写入 - }elseif($step < 0) { - $step = '-'.$step; - } - } - return $this->setField($field,array('exp',$field.'+'.$step)); - } - - /** - * 字段值减少 - * @access public - * @param string $field 字段名 - * @param integer $step 减少值 - * @param integer $lazyTime 延时时间(s) - * @return boolean - */ - public function setDec($field,$step=1,$lazyTime=0) { - if($lazyTime>0) {// 延迟写入 - $condition = $this->options['where']; - $guid = md5($this->name.'_'.$field.'_'.serialize($condition)); - $step = $this->lazyWrite($guid,-$step,$lazyTime); - if(empty($step)) { - return true; // 等待下次写入 - }elseif($step > 0) { - $step = '-'.$step; - } - } - return $this->setField($field,array('exp',$field.'-'.$step)); - } - - /** - * 延时更新检查 返回false表示需要延时 - * 否则返回实际写入的数值 - * @access public - * @param string $guid 写入标识 - * @param integer $step 写入步进值 - * @param integer $lazyTime 延时时间(s) - * @return false|integer - */ - protected function lazyWrite($guid,$step,$lazyTime) { - if(false !== ($value = S($guid))) { // 存在缓存写入数据 - if(NOW_TIME > S($guid.'_time')+$lazyTime) { - // 延时更新时间到了,删除缓存数据 并实际写入数据库 - S($guid,NULL); - S($guid.'_time',NULL); - return $value+$step; - }else{ - // 追加数据到缓存 - S($guid,$value+$step); - return false; - } - }else{ // 没有缓存数据 - S($guid,$step); - // 计时开始 - S($guid.'_time',NOW_TIME); - return false; - } - } - - /** - * 获取一条记录的某个字段值 - * @access public - * @param string $field 字段名 - * @param string $spea 字段数据间隔符号 NULL返回数组 - * @return mixed - */ - public function getField($field,$sepa=null) { - $options['field'] = $field; - $options = $this->_parseOptions($options); - // 判断查询缓存 - if(isset($options['cache'])){ - $cache = $options['cache']; - $key = is_string($cache['key'])?$cache['key']:md5($sepa.serialize($options)); - $data = S($key,'',$cache); - if(false !== $data){ - return $data; - } - } - $field = trim($field); - if(strpos($field,',') && false !== $sepa) { // 多字段 - if(!isset($options['limit'])){ - $options['limit'] = is_numeric($sepa)?$sepa:''; - } - $resultSet = $this->db->select($options); - if(!empty($resultSet)) { - if(is_string($resultSet)){ - return $resultSet; - } - $_field = explode(',', $field); - $field = array_keys($resultSet[0]); - $key1 = array_shift($field); - $key2 = array_shift($field); - $cols = array(); - $count = count($_field); - foreach ($resultSet as $result){ - $name = $result[$key1]; - if(2==$count) { - $cols[$name] = $result[$key2]; - }else{ - $cols[$name] = is_string($sepa)?implode($sepa,array_slice($result,1)):$result; - } - } - if(isset($cache)){ - S($key,$cols,$cache); - } - return $cols; - } - }else{ // 查找一条记录 - // 返回数据个数 - if(true !== $sepa) {// 当sepa指定为true的时候 返回所有数据 - $options['limit'] = is_numeric($sepa)?$sepa:1; - } - $result = $this->db->select($options); - if(!empty($result)) { - if(is_string($result)){ - return $result; - } - if(true !== $sepa && 1==$options['limit']) { - $data = reset($result[0]); - if(isset($cache)){ - S($key,$data,$cache); - } - return $data; - } - foreach ($result as $val){ - $array[] = $val[$field]; - } - if(isset($cache)){ - S($key,$array,$cache); - } - return $array; - } - } - return null; - } - - /** - * 创建数据对象 但不保存到数据库 - * @access public - * @param mixed $data 创建数据 - * @param string $type 状态 - * @return mixed - */ - public function create($data='',$type='') { - // 如果没有传值默认取POST数据 - if(empty($data)) { - $data = I('post.'); - }elseif(is_object($data)){ - $data = get_object_vars($data); - } - // 验证数据 - if(empty($data) || !is_array($data)) { - $this->error = L('_DATA_TYPE_INVALID_'); - return false; - } - - // 状态 - $type = $type?:(!empty($data[$this->getPk()])?self::MODEL_UPDATE:self::MODEL_INSERT); - - // 检查字段映射 - $data = $this->parseFieldsMap($data,0); - - // 检测提交字段的合法性 - if(isset($this->options['field'])) { // $this->field('field1,field2...')->create() - $fields = $this->options['field']; - unset($this->options['field']); - }elseif($type == self::MODEL_INSERT && isset($this->insertFields)) { - $fields = $this->insertFields; - }elseif($type == self::MODEL_UPDATE && isset($this->updateFields)) { - $fields = $this->updateFields; - } - if(isset($fields)) { - if(is_string($fields)) { - $fields = explode(',',$fields); - } - // 判断令牌验证字段 - if(C('TOKEN_ON')) $fields[] = C('TOKEN_NAME', null, '__hash__'); - foreach ($data as $key=>$val){ - if(!in_array($key,$fields)) { - unset($data[$key]); - } - } - } - - // 数据自动验证 - if(!$this->autoValidation($data,$type)) return false; - - // 表单令牌验证 - if(!$this->autoCheckToken($data)) { - $this->error = L('_TOKEN_ERROR_'); - return false; - } - - // 验证完成生成数据对象 - if($this->autoCheckFields) { // 开启字段检测 则过滤非法字段数据 - $fields = $this->getDbFields(); - foreach ($data as $key=>$val){ - if(!in_array($key,$fields)) { - unset($data[$key]); - }elseif(MAGIC_QUOTES_GPC && is_string($val)){ - $data[$key] = stripslashes($val); - } - } - } - - // 创建完成对数据进行自动处理 - $this->autoOperation($data,$type); - // 赋值当前数据对象 - $this->data = $data; - // 返回创建的数据以供其他调用 - return $data; - } - - // 自动表单令牌验证 - // TODO ajax无刷新多次提交暂不能满足 - public function autoCheckToken($data) { - // 支持使用token(false) 关闭令牌验证 - if(isset($this->options['token']) && !$this->options['token']) return true; - if(C('TOKEN_ON')){ - $name = C('TOKEN_NAME', null, '__hash__'); - if(!isset($data[$name]) || !isset($_SESSION[$name])) { // 令牌数据无效 - return false; - } - - // 令牌验证 - list($key,$value) = explode('_',$data[$name]); - if(isset($_SESSION[$name][$key]) && $value && $_SESSION[$name][$key] === $value) { // 防止重复提交 - unset($_SESSION[$name][$key]); // 验证完成销毁session - return true; - } - // 开启TOKEN重置 - if(C('TOKEN_RESET')) unset($_SESSION[$name][$key]); - return false; - } - return true; - } - - /** - * 使用正则验证数据 - * @access public - * @param string $value 要验证的数据 - * @param string $rule 验证规则 - * @return boolean - */ - public function regex($value,$rule) { - $validate = array( - 'require' => '/\S+/', - 'email' => '/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/', - 'url' => '/^http(s?):\/\/(?:[A-za-z0-9-]+\.)+[A-za-z]{2,4}(:\d+)?(?:[\/\?#][\/=\?%\-&~`@[\]\':+!\.#\w]*)?$/', - 'currency' => '/^\d+(\.\d+)?$/', - 'number' => '/^\d+$/', - 'zip' => '/^\d{6}$/', - 'integer' => '/^[-\+]?\d+$/', - 'double' => '/^[-\+]?\d+(\.\d+)?$/', - 'english' => '/^[A-Za-z]+$/', - ); - // 检查是否有内置的正则表达式 - if(isset($validate[strtolower($rule)])) - $rule = $validate[strtolower($rule)]; - return preg_match($rule,$value)===1; - } - - /** - * 自动表单处理 - * @access public - * @param array $data 创建数据 - * @param string $type 创建类型 - * @return mixed - */ - private function autoOperation(&$data,$type) { - if(false === $this->options['auto']){ - // 关闭自动完成 - return $data; - } - if(!empty($this->options['auto'])) { - $_auto = $this->options['auto']; - unset($this->options['auto']); - }elseif(!empty($this->_auto)){ - $_auto = $this->_auto; - } - // 自动填充 - if(isset($_auto)) { - foreach ($_auto as $auto){ - // 填充因子定义格式 - // array('field','填充内容','填充条件','附加规则',[额外参数]) - if(empty($auto[2])) $auto[2] = self::MODEL_INSERT; // 默认为新增的时候自动填充 - if( $type == $auto[2] || $auto[2] == self::MODEL_BOTH) { - if(empty($auto[3])) $auto[3] = 'string'; - switch(trim($auto[3])) { - case 'function': // 使用函数进行填充 字段的值作为参数 - case 'callback': // 使用回调方法 - $args = isset($auto[4])?(array)$auto[4]:array(); - if(isset($data[$auto[0]])) { - array_unshift($args,$data[$auto[0]]); - } - if('function'==$auto[3]) { - $data[$auto[0]] = call_user_func_array($auto[1], $args); - }else{ - $data[$auto[0]] = call_user_func_array(array(&$this,$auto[1]), $args); - } - break; - case 'field': // 用其它字段的值进行填充 - $data[$auto[0]] = $data[$auto[1]]; - break; - case 'ignore': // 为空忽略 - if($auto[1]===$data[$auto[0]]) - unset($data[$auto[0]]); - break; - case 'string': - default: // 默认作为字符串填充 - $data[$auto[0]] = $auto[1]; - } - if(isset($data[$auto[0]]) && false === $data[$auto[0]] ) unset($data[$auto[0]]); - } - } - } - return $data; - } - - /** - * 自动表单验证 - * @access protected - * @param array $data 创建数据 - * @param string $type 创建类型 - * @return boolean - */ - protected function autoValidation($data,$type) { - if(false === $this->options['validate'] ){ - // 关闭自动验证 - return true; - } - if(!empty($this->options['validate'])) { - $_validate = $this->options['validate']; - unset($this->options['validate']); - }elseif(!empty($this->_validate)){ - $_validate = $this->_validate; - } - // 属性验证 - if(isset($_validate)) { // 如果设置了数据自动验证则进行数据验证 - if($this->patchValidate) { // 重置验证错误信息 - $this->error = array(); - } - foreach($_validate as $key=>$val) { - // 验证因子定义格式 - // array(field,rule,message,condition,type,when,params) - // 判断是否需要执行验证 - if(empty($val[5]) || ( $val[5]== self::MODEL_BOTH && $type < 3 ) || $val[5]== $type ) { - if(0==strpos($val[2],'{%') && strpos($val[2],'}')) - // 支持提示信息的多语言 使用 {%语言定义} 方式 - $val[2] = L(substr($val[2],2,-1)); - $val[3] = isset($val[3])?$val[3]:self::EXISTS_VALIDATE; - $val[4] = isset($val[4])?$val[4]:'regex'; - // 判断验证条件 - switch($val[3]) { - case self::MUST_VALIDATE: // 必须验证 不管表单是否有设置该字段 - if(false === $this->_validationField($data,$val)) - return false; - break; - case self::VALUE_VALIDATE: // 值不为空的时候才验证 - if('' != trim($data[$val[0]])) - if(false === $this->_validationField($data,$val)) - return false; - break; - default: // 默认表单存在该字段就验证 - if(isset($data[$val[0]])) - if(false === $this->_validationField($data,$val)) - return false; - } - } - } - // 批量验证的时候最后返回错误 - if(!empty($this->error)) return false; - } - return true; - } - - /** - * 验证表单字段 支持批量验证 - * 如果批量验证返回错误的数组信息 - * @access protected - * @param array $data 创建数据 - * @param array $val 验证因子 - * @return boolean - */ - protected function _validationField($data,$val) { - if($this->patchValidate && isset($this->error[$val[0]])) - return ; //当前字段已经有规则验证没有通过 - if(false === $this->_validationFieldItem($data,$val)){ - if($this->patchValidate) { - $this->error[$val[0]] = $val[2]; - }else{ - $this->error = $val[2]; - return false; - } - } - return ; - } - - /** - * 根据验证因子验证字段 - * @access protected - * @param array $data 创建数据 - * @param array $val 验证因子 - * @return boolean - */ - protected function _validationFieldItem($data,$val) { - switch(strtolower(trim($val[4]))) { - case 'function':// 使用函数进行验证 - case 'callback':// 调用方法进行验证 - $args = isset($val[6])?(array)$val[6]:array(); - if(is_string($val[0]) && strpos($val[0], ',')) - $val[0] = explode(',', $val[0]); - if(is_array($val[0])){ - // 支持多个字段验证 - foreach($val[0] as $field) - $_data[$field] = $data[$field]; - array_unshift($args, $_data); - }else{ - array_unshift($args, $data[$val[0]]); - } - if('function'==$val[4]) { - return call_user_func_array($val[1], $args); - }else{ - return call_user_func_array(array(&$this, $val[1]), $args); - } - case 'confirm': // 验证两个字段是否相同 - return $data[$val[0]] == $data[$val[1]]; - case 'unique': // 验证某个值是否唯一 - if(is_string($val[0]) && strpos($val[0],',')) - $val[0] = explode(',',$val[0]); - $map = array(); - if(is_array($val[0])) { - // 支持多个字段验证 - foreach ($val[0] as $field) - $map[$field] = $data[$field]; - }else{ - $map[$val[0]] = $data[$val[0]]; - } - $pk = $this->getPk(); - if(!empty($data[$pk]) && is_string($pk)) { // 完善编辑的时候验证唯一 - $map[$pk] = array('neq',$data[$pk]); - } - if($this->where($map)->find()) return false; - return true; - default: // 检查附加规则 - return $this->check($data[$val[0]],$val[1],$val[4]); - } - } - - /** - * 验证数据 支持 in between equal length regex expire ip_allow ip_deny - * @access public - * @param string $value 验证数据 - * @param mixed $rule 验证表达式 - * @param string $type 验证方式 默认为正则验证 - * @return boolean - */ - public function check($value,$rule,$type='regex'){ - $type = strtolower(trim($type)); - switch($type) { - case 'in': // 验证是否在某个指定范围之内 逗号分隔字符串或者数组 - case 'notin': - $range = is_array($rule)? $rule : explode(',',$rule); - return $type == 'in' ? in_array($value ,$range) : !in_array($value ,$range); - case 'between': // 验证是否在某个范围 - case 'notbetween': // 验证是否不在某个范围 - if (is_array($rule)){ - $min = $rule[0]; - $max = $rule[1]; - }else{ - list($min,$max) = explode(',',$rule); - } - return $type == 'between' ? $value>=$min && $value<=$max : $value<$min || $value>$max; - case 'equal': // 验证是否等于某个值 - case 'notequal': // 验证是否等于某个值 - return $type == 'equal' ? $value == $rule : $value != $rule; - case 'length': // 验证长度 - $length = mb_strlen($value,'utf-8'); // 当前数据长度 - if(strpos($rule,',')) { // 长度区间 - list($min,$max) = explode(',',$rule); - return $length >= $min && $length <= $max; - }else{// 指定长度 - return $length == $rule; - } - case 'expire': - list($start,$end) = explode(',',$rule); - if(!is_numeric($start)) $start = strtotime($start); - if(!is_numeric($end)) $end = strtotime($end); - return NOW_TIME >= $start && NOW_TIME <= $end; - case 'ip_allow': // IP 操作许可验证 - return in_array(get_client_ip(),explode(',',$rule)); - case 'ip_deny': // IP 操作禁止验证 - return !in_array(get_client_ip(),explode(',',$rule)); - case 'regex': - default: // 默认使用正则验证 可以使用验证类中定义的验证名称 - // 检查附加规则 - return $this->regex($value,$rule); - } - } - - /** - * 存储过程返回多数据集 - * @access public - * @param string $sql SQL指令 - * @param mixed $parse 是否需要解析SQL - * @return array - */ - public function procedure($sql, $parse = false) { - return $this->db->procedure($sql, $parse); - } - - /** - * SQL查询 - * @access public - * @param string $sql SQL指令 - * @param mixed $parse 是否需要解析SQL - * @return mixed - */ - public function query($sql,$parse=false) { - if(!is_bool($parse) && !is_array($parse)) { - $parse = func_get_args(); - array_shift($parse); - } - $sql = $this->parseSql($sql,$parse); - return $this->db->query($sql); - } - - /** - * 执行SQL语句 - * @access public - * @param string $sql SQL指令 - * @param mixed $parse 是否需要解析SQL - * @return false | integer - */ - public function execute($sql,$parse=false) { - if(!is_bool($parse) && !is_array($parse)) { - $parse = func_get_args(); - array_shift($parse); - } - $sql = $this->parseSql($sql,$parse); - return $this->db->execute($sql); - } - - /** - * 解析SQL语句 - * @access public - * @param string $sql SQL指令 - * @param boolean $parse 是否需要解析SQL - * @return string - */ - protected function parseSql($sql,$parse) { - // 分析表达式 - if(true === $parse) { - $options = $this->_parseOptions(); - $sql = $this->db->parseSql($sql,$options); - }elseif(is_array($parse)){ // SQL预处理 - $parse = array_map(array($this->db,'escapeString'),$parse); - $sql = vsprintf($sql,$parse); - }else{ - $sql = strtr($sql,array('__TABLE__'=>$this->getTableName(),'__PREFIX__'=>$this->tablePrefix)); - $prefix = $this->tablePrefix; - $sql = preg_replace_callback("/__([A-Z0-9_-]+)__/sU", function($match) use($prefix){ return $prefix.strtolower($match[1]);}, $sql); - } - $this->db->setModel($this->name); - return $sql; - } - - /** - * 切换当前的数据库连接 - * @access public - * @param integer $linkNum 连接序号 - * @param mixed $config 数据库连接信息 - * @param boolean $force 强制重新连接 - * @return Model - */ - public function db($linkNum='',$config='',$force=false) { - if('' === $linkNum && $this->db) { - return $this->db; - } - - if(!isset($this->_db[$linkNum]) || $force ) { - // 创建一个新的实例 - if(!empty($config) && is_string($config) && false === strpos($config,'/')) { // 支持读取配置参数 - $config = C($config); - } - $this->_db[$linkNum] = Db::getInstance($config); - }elseif(NULL === $config){ - $this->_db[$linkNum]->close(); // 关闭数据库连接 - unset($this->_db[$linkNum]); - return ; - } - - // 切换数据库连接 - $this->db = $this->_db[$linkNum]; - $this->_after_db(); - // 字段检测 - if(!empty($this->name) && $this->autoCheckFields) $this->_checkTableInfo(); - return $this; - } - // 数据库切换后回调方法 - protected function _after_db() {} - - /** - * 得到当前的数据对象名称 - * @access public - * @return string - */ - public function getModelName() { - if(empty($this->name)){ - $name = substr(get_class($this),0,-strlen(C('DEFAULT_M_LAYER'))); - if ( $pos = strrpos($name,'\\') ) {//有命名空间 - $this->name = substr($name,$pos+1); - }else{ - $this->name = $name; - } - } - return $this->name; - } - - /** - * 得到完整的数据表名 - * @access public - * @return string - */ - public function getTableName() { - if(empty($this->trueTableName)) { - $tableName = !empty($this->tablePrefix) ? $this->tablePrefix : ''; - if(!empty($this->tableName)) { - $tableName .= $this->tableName; - }else{ - $tableName .= parse_name($this->name); - } - $this->trueTableName = strtolower($tableName); - } - return (!empty($this->dbName)?$this->dbName.'.':'').$this->trueTableName; - } - - /** - * 启动事务 - * @access public - * @return void - */ - public function startTrans() { - $this->commit(); - $this->db->startTrans(); - return ; - } - - /** - * 提交事务 - * @access public - * @return boolean - */ - public function commit() { - return $this->db->commit(); - } - - /** - * 事务回滚 - * @access public - * @return boolean - */ - public function rollback() { - return $this->db->rollback(); - } - - /** - * 返回模型的错误信息 - * @access public - * @return string - */ - public function getError(){ - return $this->error; - } - - /** - * 返回数据库的错误信息 - * @access public - * @return string - */ - public function getDbError() { - return $this->db->getError(); - } - - /** - * 返回最后插入的ID - * @access public - * @return string - */ - public function getLastInsID() { - return $this->db->getLastInsID(); - } - - /** - * 返回最后执行的sql语句 - * @access public - * @return string - */ - public function getLastSql() { - return $this->db->getLastSql($this->name); - } - // 鉴于getLastSql比较常用 增加_sql 别名 - public function _sql(){ - return $this->getLastSql(); - } - - /** - * 获取主键名称 - * @access public - * @return string - */ - public function getPk() { - return $this->pk; - } - - /** - * 获取数据表字段信息 - * @access public - * @return array - */ - public function getDbFields(){ - if(isset($this->options['table'])) {// 动态指定表名 - if(is_array($this->options['table'])){ - $table = key($this->options['table']); - }else{ - $table = $this->options['table']; - if(strpos($table,')')){ - // 子查询 - return false; - } - } - $fields = $this->db->getFields($table); - return $fields ? array_keys($fields) : false; - } - if($this->fields) { - $fields = $this->fields; - unset($fields['_type'],$fields['_pk']); - return $fields; - } - return false; - } - - /** - * 设置数据对象值 - * @access public - * @param mixed $data 数据 - * @return Model - */ - public function data($data=''){ - if('' === $data && !empty($this->data)) { - return $this->data; - } - if(is_object($data)){ - $data = get_object_vars($data); - }elseif(is_string($data)){ - parse_str($data,$data); - }elseif(!is_array($data)){ - E(L('_DATA_TYPE_INVALID_')); - } - $this->data = $data; - return $this; - } - - /** - * 指定当前的数据表 - * @access public - * @param mixed $table - * @return Model - */ - public function table($table) { - $prefix = $this->tablePrefix; - if(is_array($table)) { - $this->options['table'] = $table; - }elseif(!empty($table)) { - //将__TABLE_NAME__替换成带前缀的表名 - $table = preg_replace_callback("/__([A-Z0-9_-]+)__/sU", function($match) use($prefix){ return $prefix.strtolower($match[1]);}, $table); - $this->options['table'] = $table; - } - return $this; - } - - /** - * USING支持 用于多表删除 - * @access public - * @param mixed $using - * @return Model - */ - public function using($using){ - $prefix = $this->tablePrefix; - if(is_array($using)) { - $this->options['using'] = $using; - }elseif(!empty($using)) { - //将__TABLE_NAME__替换成带前缀的表名 - $using = preg_replace_callback("/__([A-Z0-9_-]+)__/sU", function($match) use($prefix){ return $prefix.strtolower($match[1]);}, $using); - $this->options['using'] = $using; - } - return $this; - } - - /** - * 查询SQL组装 join - * @access public - * @param mixed $join - * @param string $type JOIN类型 - * @return Model - */ - public function join($join,$type='INNER') { - $prefix = $this->tablePrefix; - if(is_array($join)) { - foreach ($join as $key=>&$_join){ - $_join = preg_replace_callback("/__([A-Z0-9_-]+)__/sU", function($match) use($prefix){ return $prefix.strtolower($match[1]);}, $_join); - $_join = false !== stripos($_join,'JOIN')? $_join : $type.' JOIN ' .$_join; - } - $this->options['join'] = $join; - }elseif(!empty($join)) { - //将__TABLE_NAME__字符串替换成带前缀的表名 - $join = preg_replace_callback("/__([A-Z0-9_-]+)__/sU", function($match) use($prefix){ return $prefix.strtolower($match[1]);}, $join); - $this->options['join'][] = false !== stripos($join,'JOIN')? $join : $type.' JOIN '.$join; - } - return $this; - } - - /** - * 查询SQL组装 union - * @access public - * @param mixed $union - * @param boolean $all - * @return Model - */ - public function union($union,$all=false) { - if(empty($union)) return $this; - if($all) { - $this->options['union']['_all'] = true; - } - if(is_object($union)) { - $union = get_object_vars($union); - } - // 转换union表达式 - if(is_string($union) ) { - $prefix = $this->tablePrefix; - //将__TABLE_NAME__字符串替换成带前缀的表名 - $options = preg_replace_callback("/__([A-Z0-9_-]+)__/sU", function($match) use($prefix){ return $prefix.strtolower($match[1]);}, $union); - }elseif(is_array($union)){ - if(isset($union[0])) { - $this->options['union'] = array_merge($this->options['union'],$union); - return $this; - }else{ - $options = $union; - } - }else{ - E(L('_DATA_TYPE_INVALID_')); - } - $this->options['union'][] = $options; - return $this; - } - - /** - * 查询缓存 - * @access public - * @param mixed $key - * @param integer $expire - * @param string $type - * @return Model - */ - public function cache($key=true,$expire=null,$type=''){ - // 增加快捷调用方式 cache(10) 等同于 cache(true, 10) - if(is_numeric($key) && is_null($expire)){ - $expire = $key; - $key = true; - } - if(false !== $key) - $this->options['cache'] = array('key'=>$key,'expire'=>$expire,'type'=>$type); - return $this; - } - - /** - * 指定查询字段 支持字段排除 - * @access public - * @param mixed $field - * @param boolean $except 是否排除 - * @return Model - */ - public function field($field,$except=false){ - if(true === $field) {// 获取全部字段 - $fields = $this->getDbFields(); - $field = $fields?:'*'; - }elseif($except) {// 字段排除 - if(is_string($field)) { - $field = explode(',',$field); - } - $fields = $this->getDbFields(); - $field = $fields?array_diff($fields,$field):$field; - } - $this->options['field'] = $field; - return $this; - } - - /** - * 调用命名范围 - * @access public - * @param mixed $scope 命名范围名称 支持多个 和直接定义 - * @param array $args 参数 - * @return Model - */ - public function scope($scope='',$args=NULL){ - if('' === $scope) { - if(isset($this->_scope['default'])) { - // 默认的命名范围 - $options = $this->_scope['default']; - }else{ - return $this; - } - }elseif(is_string($scope)){ // 支持多个命名范围调用 用逗号分割 - $scopes = explode(',',$scope); - $options = array(); - foreach ($scopes as $name){ - if(!isset($this->_scope[$name])) continue; - $options = array_merge($options,$this->_scope[$name]); - } - if(!empty($args) && is_array($args)) { - $options = array_merge($options,$args); - } - }elseif(is_array($scope)){ // 直接传入命名范围定义 - $options = $scope; - } - - if(is_array($options) && !empty($options)){ - $this->options = array_merge($this->options,array_change_key_case($options)); - } - return $this; - } - - /** - * 指定查询条件 支持安全过滤 - * @access public - * @param mixed $where 条件表达式 - * @param mixed $parse 预处理参数 - * @return Model - */ - public function where($where,$parse=null){ - if(!is_null($parse) && is_string($where)) { - if(!is_array($parse)) { - $parse = func_get_args(); - array_shift($parse); - } - $parse = array_map(array($this->db,'escapeString'),$parse); - $where = vsprintf($where,$parse); - }elseif(is_object($where)){ - $where = get_object_vars($where); - } - if(is_string($where) && '' != $where){ - $map = array(); - $map['_string'] = $where; - $where = $map; - } - if(isset($this->options['where'])){ - $this->options['where'] = array_merge($this->options['where'],$where); - }else{ - $this->options['where'] = $where; - } - - return $this; - } - - /** - * 指定查询数量 - * @access public - * @param mixed $offset 起始位置 - * @param mixed $length 查询数量 - * @return Model - */ - public function limit($offset,$length=null){ - if(is_null($length) && strpos($offset,',')){ - list($offset,$length) = explode(',',$offset); - } - $this->options['limit'] = intval($offset).( $length? ','.intval($length) : '' ); - return $this; - } - - /** - * 指定分页 - * @access public - * @param mixed $page 页数 - * @param mixed $listRows 每页数量 - * @return Model - */ - public function page($page,$listRows=null){ - if(is_null($listRows) && strpos($page,',')){ - list($page,$listRows) = explode(',',$page); - } - $this->options['page'] = array(intval($page),intval($listRows)); - return $this; - } - - /** - * 查询注释 - * @access public - * @param string $comment 注释 - * @return Model - */ - public function comment($comment){ - $this->options['comment'] = $comment; - return $this; - } - - /** - * 获取执行的SQL语句 - * @access public - * @param boolean $fetch 是否返回sql - * @return Model - */ - public function fetchSql($fetch=true){ - $this->options['fetch_sql'] = $fetch; - return $this; - } - - /** - * 参数绑定 - * @access public - * @param string $key 参数名 - * @param mixed $value 绑定的变量及绑定参数 - * @return Model - */ - public function bind($key,$value=false) { - if(is_array($key)){ - $this->options['bind'] = $key; - }else{ - $num = func_num_args(); - if($num>2){ - $params = func_get_args(); - array_shift($params); - $this->options['bind'][$key] = $params; - }else{ - $this->options['bind'][$key] = $value; - } - } - return $this; - } - - /** - * 设置模型的属性值 - * @access public - * @param string $name 名称 - * @param mixed $value 值 - * @return Model - */ - public function setProperty($name,$value) { - if(property_exists($this,$name)) - $this->$name = $value; - return $this; - } - -} diff --git a/ThinkPHP/Library/Think/Route.class.php b/ThinkPHP/Library/Think/Route.class.php deleted file mode 100644 index c1bf8a5..0000000 --- a/ThinkPHP/Library/Think/Route.class.php +++ /dev/null @@ -1,316 +0,0 @@ - -// +---------------------------------------------------------------------- -namespace Think; -/** - * ThinkPHP路由解析类 - */ -class Route { - - // 路由检测 - public static function check(){ - $depr = C('URL_PATHINFO_DEPR'); - $regx = preg_replace('/\.'.__EXT__.'$/i','',trim($_SERVER['PATH_INFO'],$depr)); - // 分隔符替换 确保路由定义使用统一的分隔符 - if('/' != $depr){ - $regx = str_replace($depr,'/',$regx); - } - // URL映射定义(静态路由) - $maps = C('URL_MAP_RULES'); - if(isset($maps[$regx])) { - $var = self::parseUrl($maps[$regx]); - $_GET = array_merge($var, $_GET); - return true; - } - // 动态路由处理 - $routes = C('URL_ROUTE_RULES'); - if(!empty($routes)) { - foreach ($routes as $rule=>$route){ - if(is_numeric($rule)){ - // 支持 array('rule','adddress',...) 定义路由 - $rule = array_shift($route); - } - if(is_array($route) && isset($route[2])){ - // 路由参数 - $options = $route[2]; - if(isset($options['ext']) && __EXT__ != $options['ext']){ - // URL后缀检测 - continue; - } - if(isset($options['method']) && REQUEST_METHOD != strtoupper($options['method'])){ - // 请求类型检测 - continue; - } - // 自定义检测 - if(!empty($options['callback']) && is_callable($options['callback'])) { - if(false === call_user_func($options['callback'])) { - continue; - } - } - } - if(0===strpos($rule,'/') && preg_match($rule,$regx,$matches)) { // 正则路由 - if($route instanceof \Closure) { - // 执行闭包 - $result = self::invokeRegx($route, $matches); - // 如果返回布尔值 则继续执行 - return is_bool($result) ? $result : exit; - }else{ - return self::parseRegex($matches,$route,$regx); - } - }else{ // 规则路由 - $len1 = substr_count($regx,'/'); - $len2 = substr_count($rule,'/'); - if($len1>=$len2 || strpos($rule,'[')) { - if('$' == substr($rule,-1,1)) {// 完整匹配 - if($len1 != $len2) { - continue; - }else{ - $rule = substr($rule,0,-1); - } - } - $match = self::checkUrlMatch($regx,$rule); - if(false !== $match) { - if($route instanceof \Closure) { - // 执行闭包 - $result = self::invokeRule($route, $match); - // 如果返回布尔值 则继续执行 - return is_bool($result) ? $result : exit; - }else{ - return self::parseRule($rule,$route,$regx); - } - } - } - } - } - } - return false; - } - - // 检测URL和规则路由是否匹配 - private static function checkUrlMatch($regx,$rule) { - $m1 = explode('/',$regx); - $m2 = explode('/',$rule); - $var = array(); - foreach ($m2 as $key=>$val){ - if(0 === strpos($val,'[:')){ - $val = substr($val,1,-1); - } - - if(':' == substr($val,0,1)) {// 动态变量 - if($pos = strpos($val,'|')){ - // 使用函数过滤 - $val = substr($val,1,$pos-1); - } - if(strpos($val,'\\')) { - $type = substr($val,-1); - if('d'==$type) { - if(isset($m1[$key]) && !is_numeric($m1[$key])) - return false; - } - $name = substr($val, 1, -2); - }elseif($pos = strpos($val,'^')){ - $array = explode('-',substr(strstr($val,'^'),1)); - if(in_array($m1[$key],$array)) { - return false; - } - $name = substr($val, 1, $pos - 1); - }else{ - $name = substr($val, 1); - } - $var[$name] = isset($m1[$key])?$m1[$key]:''; - }elseif(0 !== strcasecmp($val,$m1[$key])){ - return false; - } - } - // 成功匹配后返回URL中的动态变量数组 - return $var; - } - - // 解析规范的路由地址 - // 地址格式 [控制器/操作?]参数1=值1&参数2=值2... - private static function parseUrl($url) { - $var = array(); - if(false !== strpos($url,'?')) { // [控制器/操作?]参数1=值1&参数2=值2... - $info = parse_url($url); - $path = explode('/',$info['path']); - parse_str($info['query'],$var); - }elseif(strpos($url,'/')){ // [控制器/操作] - $path = explode('/',$url); - }else{ // 参数1=值1&参数2=值2... - parse_str($url,$var); - } - if(isset($path)) { - $var[C('VAR_ACTION')] = array_pop($path); - if(!empty($path)) { - $var[C('VAR_CONTROLLER')] = array_pop($path); - } - if(!empty($path)) { - $var[C('VAR_MODULE')] = array_pop($path); - } - } - return $var; - } - - // 解析规则路由 - // '路由规则'=>'[控制器/操作]?额外参数1=值1&额外参数2=值2...' - // '路由规则'=>array('[控制器/操作]','额外参数1=值1&额外参数2=值2...') - // '路由规则'=>'外部地址' - // '路由规则'=>array('外部地址','重定向代码') - // 路由规则中 :开头 表示动态变量 - // 外部地址中可以用动态变量 采用 :1 :2 的方式 - // 'news/:month/:day/:id'=>array('News/read?cate=1','status=1'), - // 'new/:id'=>array('/new.php?id=:1',301), 重定向 - private static function parseRule($rule,$route,$regx) { - // 获取路由地址规则 - $url = is_array($route)?$route[0]:$route; - // 获取URL地址中的参数 - $paths = explode('/',$regx); - // 解析路由规则 - $matches = array(); - $rule = explode('/',$rule); - foreach ($rule as $item){ - $fun = ''; - if(0 === strpos($item,'[:')){ - $item = substr($item,1,-1); - } - if(0===strpos($item,':')) { // 动态变量获取 - if($pos = strpos($item,'|')){ - // 支持函数过滤 - $fun = substr($item,$pos+1); - $item = substr($item,0,$pos); - } - if($pos = strpos($item,'^') ) { - $var = substr($item,1,$pos-1); - }elseif(strpos($item,'\\')){ - $var = substr($item,1,-2); - }else{ - $var = substr($item,1); - } - $matches[$var] = !empty($fun)? $fun(array_shift($paths)) : array_shift($paths); - }else{ // 过滤URL中的静态变量 - array_shift($paths); - } - } - - if(0=== strpos($url,'/') || 0===strpos($url,'http')) { // 路由重定向跳转 - if(strpos($url,':')) { // 传递动态参数 - $values = array_values($matches); - $url = preg_replace_callback('/:(\d+)/', function($match) use($values){ return $values[$match[1] - 1]; }, $url); - } - header("Location: $url", true,(is_array($route) && isset($route[1]))?$route[1]:301); - exit; - }else{ - // 解析路由地址 - $var = self::parseUrl($url); - // 解析路由地址里面的动态参数 - $values = array_values($matches); - foreach ($var as $key=>$val){ - if(0===strpos($val,':')) { - $var[$key] = $values[substr($val,1)-1]; - } - } - $var = array_merge($matches,$var); - // 解析剩余的URL参数 - if(!empty($paths)) { - preg_replace_callback('/(\w+)\/([^\/]+)/', function($match) use(&$var){ $var[strtolower($match[1])]=strip_tags($match[2]);}, implode('/',$paths)); - } - // 解析路由自动传入参数 - if(is_array($route) && isset($route[1])) { - if(is_array($route[1])){ - $params = $route[1]; - }else{ - parse_str($route[1],$params); - } - $var = array_merge($var,$params); - } - $_GET = array_merge($var,$_GET); - } - return true; - } - - // 解析正则路由 - // '路由正则'=>'[控制器/操作]?参数1=值1&参数2=值2...' - // '路由正则'=>array('[控制器/操作]?参数1=值1&参数2=值2...','额外参数1=值1&额外参数2=值2...') - // '路由正则'=>'外部地址' - // '路由正则'=>array('外部地址','重定向代码') - // 参数值和外部地址中可以用动态变量 采用 :1 :2 的方式 - // '/new\/(\d+)\/(\d+)/'=>array('News/read?id=:1&page=:2&cate=1','status=1'), - // '/new\/(\d+)/'=>array('/new.php?id=:1&page=:2&status=1','301'), 重定向 - private static function parseRegex($matches,$route,$regx) { - // 获取路由地址规则 - $url = is_array($route)?$route[0]:$route; - $url = preg_replace_callback('/:(\d+)/', function($match) use($matches){return $matches[$match[1]];}, $url); - if(0=== strpos($url,'/') || 0===strpos($url,'http')) { // 路由重定向跳转 - header("Location: $url", true,(is_array($route) && isset($route[1]))?$route[1]:301); - exit; - }else{ - // 解析路由地址 - $var = self::parseUrl($url); - // 处理函数 - foreach($var as $key=>$val){ - if(strpos($val,'|')){ - list($val,$fun) = explode('|',$val); - $var[$key] = $fun($val); - } - } - // 解析剩余的URL参数 - $regx = substr_replace($regx,'',0,strlen($matches[0])); - if($regx) { - preg_replace_callback('/(\w+)\/([^\/]+)/', function($match) use(&$var){ - $var[strtolower($match[1])] = strip_tags($match[2]); - }, $regx); - } - // 解析路由自动传入参数 - if(is_array($route) && isset($route[1])) { - if(is_array($route[1])){ - $params = $route[1]; - }else{ - parse_str($route[1],$params); - } - $var = array_merge($var,$params); - } - $_GET = array_merge($var,$_GET); - } - return true; - } - - // 执行正则匹配下的闭包方法 支持参数调用 - static private function invokeRegx($closure, $var = array()) { - $reflect = new \ReflectionFunction($closure); - $params = $reflect->getParameters(); - $args = array(); - array_shift($var); - foreach ($params as $param){ - if(!empty($var)) { - $args[] = array_shift($var); - }elseif($param->isDefaultValueAvailable()){ - $args[] = $param->getDefaultValue(); - } - } - return $reflect->invokeArgs($args); - } - - // 执行规则匹配下的闭包方法 支持参数调用 - static private function invokeRule($closure, $var = array()) { - $reflect = new \ReflectionFunction($closure); - $params = $reflect->getParameters(); - $args = array(); - foreach ($params as $param){ - $name = $param->getName(); - if(isset($var[$name])) { - $args[] = $var[$name]; - }elseif($param->isDefaultValueAvailable()){ - $args[] = $param->getDefaultValue(); - } - } - return $reflect->invokeArgs($args); - } - -} \ No newline at end of file diff --git a/ThinkPHP/Library/Think/Storage.class.php b/ThinkPHP/Library/Think/Storage.class.php deleted file mode 100644 index 653e136..0000000 --- a/ThinkPHP/Library/Think/Storage.class.php +++ /dev/null @@ -1,40 +0,0 @@ - -// +---------------------------------------------------------------------- -namespace Think; -// 分布式文件存储类 -class Storage { - - /** - * 操作句柄 - * @var string - * @access protected - */ - static protected $handler ; - - /** - * 连接分布式文件系统 - * @access public - * @param string $type 文件类型 - * @param array $options 配置数组 - * @return void - */ - static public function connect($type='File',$options=array()) { - $class = 'Think\\Storage\\Driver\\'.ucwords($type); - self::$handler = new $class($options); - } - - static public function __callstatic($method,$args){ - //调用缓存驱动的方法 - if(method_exists(self::$handler, $method)){ - return call_user_func_array(array(self::$handler,$method), $args); - } - } -} diff --git a/ThinkPHP/Library/Think/Storage/Driver/File.class.php b/ThinkPHP/Library/Think/Storage/Driver/File.class.php deleted file mode 100644 index ea9d925..0000000 --- a/ThinkPHP/Library/Think/Storage/Driver/File.class.php +++ /dev/null @@ -1,123 +0,0 @@ - -// +---------------------------------------------------------------------- -namespace Think\Storage\Driver; -use Think\Storage; -// 本地文件写入存储类 -class File extends Storage{ - - private $contents=array(); - - /** - * 架构函数 - * @access public - */ - public function __construct() { - } - - /** - * 文件内容读取 - * @access public - * @param string $filename 文件名 - * @return string - */ - public function read($filename,$type=''){ - return $this->get($filename,'content',$type); - } - - /** - * 文件写入 - * @access public - * @param string $filename 文件名 - * @param string $content 文件内容 - * @return boolean - */ - public function put($filename,$content,$type=''){ - $dir = dirname($filename); - if(!is_dir($dir)){ - mkdir($dir,0777,true); - } - if(false === file_put_contents($filename,$content)){ - E(L('_STORAGE_WRITE_ERROR_').':'.$filename); - }else{ - $this->contents[$filename]=$content; - return true; - } - } - - /** - * 文件追加写入 - * @access public - * @param string $filename 文件名 - * @param string $content 追加的文件内容 - * @return boolean - */ - public function append($filename,$content,$type=''){ - if(is_file($filename)){ - $content = $this->read($filename,$type).$content; - } - return $this->put($filename,$content,$type); - } - - /** - * 加载文件 - * @access public - * @param string $filename 文件名 - * @param array $vars 传入变量 - * @return void - */ - public function load($_filename,$vars=null){ - if(!is_null($vars)){ - extract($vars, EXTR_OVERWRITE); - } - include $_filename; - } - - /** - * 文件是否存在 - * @access public - * @param string $filename 文件名 - * @return boolean - */ - public function has($filename,$type=''){ - return is_file($filename); - } - - /** - * 文件删除 - * @access public - * @param string $filename 文件名 - * @return boolean - */ - public function unlink($filename,$type=''){ - unset($this->contents[$filename]); - return is_file($filename) ? unlink($filename) : false; - } - - /** - * 读取文件信息 - * @access public - * @param string $filename 文件名 - * @param string $name 信息名 mtime或者content - * @return boolean - */ - public function get($filename,$name,$type=''){ - if(!isset($this->contents[$filename])){ - if(!is_file($filename)) return false; - $this->contents[$filename]=file_get_contents($filename); - } - $content=$this->contents[$filename]; - $info = array( - 'mtime' => filemtime($filename), - 'content' => $content - ); - return $info[$name]; - } -} diff --git a/ThinkPHP/Library/Think/Storage/Driver/Sae.class.php b/ThinkPHP/Library/Think/Storage/Driver/Sae.class.php deleted file mode 100644 index 3756115..0000000 --- a/ThinkPHP/Library/Think/Storage/Driver/Sae.class.php +++ /dev/null @@ -1,193 +0,0 @@ - -// +---------------------------------------------------------------------- -namespace Think\Storage\Driver; -use Think\Storage; -// SAE环境文件写入存储类 -class Sae extends Storage{ - - /** - * 架构函数 - * @access public - */ - private $mc; - private $kvs = array(); - private $htmls = array(); - private $contents = array(); - public function __construct() { - if(!function_exists('memcache_init')){ - header('Content-Type:text/html;charset=utf-8'); - exit('请在SAE平台上运行代码。'); - } - $this->mc = @memcache_init(); - if(!$this->mc){ - header('Content-Type:text/html;charset=utf-8'); - exit('您未开通Memcache服务,请在SAE管理平台初始化Memcache服务'); - } - } - - /** - * 获得SaeKv对象 - */ - private function getKv(){ - static $kv; - if(!$kv){ - $kv = new \SaeKV(); - if(!$kv->init()) - E('您没有初始化KVDB,请在SAE管理平台初始化KVDB服务'); - } - return $kv; - } - - - /** - * 文件内容读取 - * @access public - * @param string $filename 文件名 - * @return string - */ - public function read($filename,$type=''){ - switch(strtolower($type)){ - case 'f': - $kv = $this->getKv(); - if(!isset($this->kvs[$filename])){ - $this->kvs[$filename]=$kv->get($filename); - } - return $this->kvs[$filename]; - default: - return $this->get($filename,'content',$type); - } - } - - /** - * 文件写入 - * @access public - * @param string $filename 文件名 - * @param string $content 文件内容 - * @return boolean - */ - public function put($filename,$content,$type=''){ - switch(strtolower($type)){ - case 'f': - $kv = $this->getKv(); - $this->kvs[$filename] = $content; - return $kv->set($filename,$content); - case 'html': - $kv = $this->getKv(); - $content = time().$content; - $this->htmls[$filename] = $content; - return $kv->set($filename,$content); - default: - $content = time().$content; - if(!$this->mc->set($filename,$content,MEMCACHE_COMPRESSED,0)){ - E(L('_STORAGE_WRITE_ERROR_').':'.$filename); - }else{ - $this->contents[$filename] = $content; - return true; - } - } - } - - /** - * 文件追加写入 - * @access public - * @param string $filename 文件名 - * @param string $content 追加的文件内容 - * @return boolean - */ - public function append($filename,$content,$type=''){ - if($old_content = $this->read($filename,$type)){ - $content = $old_content.$content; - } - return $this->put($filename,$content,$type); - } - - /** - * 加载文件 - * @access public - * @param string $_filename 文件名 - * @param array $vars 传入变量 - * @return void - */ - public function load($_filename,$vars=null){ - if(!is_null($vars)) - extract($vars, EXTR_OVERWRITE); - eval('?>'.$this->read($_filename)); - } - - /** - * 文件是否存在 - * @access public - * @param string $filename 文件名 - * @return boolean - */ - public function has($filename,$type=''){ - if($this->read($filename,$type)){ - return true; - }else{ - return false; - } - } - - /** - * 文件删除 - * @access public - * @param string $filename 文件名 - * @return boolean - */ - public function unlink($filename,$type=''){ - switch(strtolower($type)){ - case 'f': - $kv = $this->getKv(); - unset($this->kvs[$filename]); - return $kv->delete($filename); - case 'html': - $kv = $this->getKv(); - unset($this->htmls[$filename]); - return $kv->delete($filename); - default: - unset($this->contents[$filename]); - return $this->mc->delete($filename); - } - } - - /** - * 读取文件信息 - * @access public - * @param string $filename 文件名 - * @param string $name 信息名 mtime或者content - * @return boolean - */ - public function get($filename,$name,$type=''){ - switch(strtolower($type)){ - case 'html': - if(!isset($this->htmls[$filename])){ - $kv = $this->getKv(); - $this->htmls[$filename] = $kv->get($filename); - } - $content = $this->htmls[$filename]; - break; - default: - if(!isset($this->contents[$filename])){ - $this->contents[$filename] = $this->mc->get($filename); - } - $content = $this->contents[$filename]; - } - if(false===$content){ - return false; - } - $info = array( - 'mtime' => substr($content,0,10), - 'content' => substr($content,10) - ); - return $info[$name]; - } - -} \ No newline at end of file diff --git a/ThinkPHP/Library/Think/Template.class.php b/ThinkPHP/Library/Think/Template.class.php deleted file mode 100644 index c43a97a..0000000 --- a/ThinkPHP/Library/Think/Template.class.php +++ /dev/null @@ -1,700 +0,0 @@ - -// +---------------------------------------------------------------------- -namespace Think; -/** - * ThinkPHP内置模板引擎类 - * 支持XML标签和普通标签的模板解析 - * 编译型模板引擎 支持动态缓存 - */ -class Template { - - // 模板页面中引入的标签库列表 - protected $tagLib = array(); - // 当前模板文件 - protected $templateFile = ''; - // 模板变量 - public $tVar = array(); - public $config = array(); - private $literal = array(); - private $block = array(); - - /** - * 架构函数 - * @access public - */ - public function __construct(){ - $this->config['cache_path'] = C('CACHE_PATH'); - $this->config['template_suffix'] = C('TMPL_TEMPLATE_SUFFIX'); - $this->config['cache_suffix'] = C('TMPL_CACHFILE_SUFFIX'); - $this->config['tmpl_cache'] = C('TMPL_CACHE_ON'); - $this->config['cache_time'] = C('TMPL_CACHE_TIME'); - $this->config['taglib_begin'] = $this->stripPreg(C('TAGLIB_BEGIN')); - $this->config['taglib_end'] = $this->stripPreg(C('TAGLIB_END')); - $this->config['tmpl_begin'] = $this->stripPreg(C('TMPL_L_DELIM')); - $this->config['tmpl_end'] = $this->stripPreg(C('TMPL_R_DELIM')); - $this->config['default_tmpl'] = C('TEMPLATE_NAME'); - $this->config['layout_item'] = C('TMPL_LAYOUT_ITEM'); - } - - private function stripPreg($str) { - return str_replace( - array('{','}','(',')','|','[',']','-','+','*','.','^','?'), - array('\{','\}','\(','\)','\|','\[','\]','\-','\+','\*','\.','\^','\?'), - $str); - } - - // 模板变量获取和设置 - public function get($name) { - if(isset($this->tVar[$name])) - return $this->tVar[$name]; - else - return false; - } - - public function set($name,$value) { - $this->tVar[$name]= $value; - } - - /** - * 加载模板 - * @access public - * @param string $templateFile 模板文件 - * @param array $templateVar 模板变量 - * @param string $prefix 模板标识前缀 - * @return void - */ - public function fetch($templateFile,$templateVar,$prefix='') { - $this->tVar = $templateVar; - $templateCacheFile = $this->loadTemplate($templateFile,$prefix); - Storage::load($templateCacheFile,$this->tVar,null,'tpl'); - } - - /** - * 加载主模板并缓存 - * @access public - * @param string $templateFile 模板文件 - * @param string $prefix 模板标识前缀 - * @return string - * @throws ThinkExecption - */ - public function loadTemplate ($templateFile,$prefix='') { - if(is_file($templateFile)) { - $this->templateFile = $templateFile; - // 读取模板文件内容 - $tmplContent = file_get_contents($templateFile); - }else{ - $tmplContent = $templateFile; - } - // 根据模版文件名定位缓存文件 - $tmplCacheFile = $this->config['cache_path'].$prefix.md5($templateFile).$this->config['cache_suffix']; - - // 判断是否启用布局 - if(C('LAYOUT_ON')) { - if(false !== strpos($tmplContent,'{__NOLAYOUT__}')) { // 可以单独定义不使用布局 - $tmplContent = str_replace('{__NOLAYOUT__}','',$tmplContent); - }else{ // 替换布局的主体内容 - $layoutFile = THEME_PATH.C('LAYOUT_NAME').$this->config['template_suffix']; - // 检查布局文件 - if(!is_file($layoutFile)) { - E(L('_TEMPLATE_NOT_EXIST_').':'.$layoutFile); - } - $tmplContent = str_replace($this->config['layout_item'],$tmplContent,file_get_contents($layoutFile)); - } - } - // 编译模板内容 - $tmplContent = $this->compiler($tmplContent); - Storage::put($tmplCacheFile,trim($tmplContent),'tpl'); - return $tmplCacheFile; - } - - /** - * 编译模板文件内容 - * @access protected - * @param mixed $tmplContent 模板内容 - * @return string - */ - protected function compiler($tmplContent) { - //模板解析 - $tmplContent = $this->parse($tmplContent); - // 还原被替换的Literal标签 - $tmplContent = preg_replace_callback('//is', array($this, 'restoreLiteral'), $tmplContent); - // 添加安全代码 - $tmplContent = ''.$tmplContent; - // 优化生成的php代码 - $tmplContent = str_replace('?>config['taglib_begin']; - $end = $this->config['taglib_end']; - // 检查include语法 - $content = $this->parseInclude($content); - // 检查PHP语法 - $content = $this->parsePhp($content); - // 首先替换literal标签内容 - $content = preg_replace_callback('/'.$begin.'literal'.$end.'(.*?)'.$begin.'\/literal'.$end.'/is', array($this, 'parseLiteral'),$content); - - // 获取需要引入的标签库列表 - // 标签库只需要定义一次,允许引入多个一次 - // 一般放在文件的最前面 - // 格式: - // 当TAGLIB_LOAD配置为true时才会进行检测 - if(C('TAGLIB_LOAD')) { - $this->getIncludeTagLib($content); - if(!empty($this->tagLib)) { - // 对导入的TagLib进行解析 - foreach($this->tagLib as $tagLibName) { - $this->parseTagLib($tagLibName,$content); - } - } - } - // 预先加载的标签库 无需在每个模板中使用taglib标签加载 但必须使用标签库XML前缀 - if(C('TAGLIB_PRE_LOAD')) { - $tagLibs = explode(',',C('TAGLIB_PRE_LOAD')); - foreach ($tagLibs as $tag){ - $this->parseTagLib($tag,$content); - } - } - // 内置标签库 无需使用taglib标签导入就可以使用 并且不需使用标签库XML前缀 - $tagLibs = explode(',',C('TAGLIB_BUILD_IN')); - foreach ($tagLibs as $tag){ - $this->parseTagLib($tag,$content,true); - } - //解析普通模板标签 {$tagName} - $content = preg_replace_callback('/('.$this->config['tmpl_begin'].')([^\d\w\s'.$this->config['tmpl_begin'].$this->config['tmpl_end'].'].+?)('.$this->config['tmpl_end'].')/is', array($this, 'parseTag'),$content); - return $content; - } - - // 检查PHP语法 - protected function parsePhp($content) { - if(ini_get('short_open_tag')){ - // 开启短标签的情况要将'."\n", $content ); - } - // PHP语法检查 - if(C('TMPL_DENY_PHP') && false !== strpos($content,'config['taglib_begin'].'layout\s(.+?)\s*?\/'.$this->config['taglib_end'].'/is',$content,$matches); - if($find) { - //替换Layout标签 - $content = str_replace($matches[0],'',$content); - //解析Layout标签 - $array = $this->parseXmlAttrs($matches[1]); - if(!C('LAYOUT_ON') || C('LAYOUT_NAME') !=$array['name'] ) { - // 读取布局模板 - $layoutFile = THEME_PATH.$array['name'].$this->config['template_suffix']; - $replace = isset($array['replace'])?$array['replace']:$this->config['layout_item']; - // 替换布局的主体内容 - $content = str_replace($replace,$content,file_get_contents($layoutFile)); - } - }else{ - $content = str_replace('{__NOLAYOUT__}','',$content); - } - return $content; - } - - // 解析模板中的include标签 - protected function parseInclude($content, $extend = true) { - // 解析继承 - if($extend) - $content = $this->parseExtend($content); - // 解析布局 - $content = $this->parseLayout($content); - // 读取模板中的include标签 - $find = preg_match_all('/'.$this->config['taglib_begin'].'include\s(.+?)\s*?\/'.$this->config['taglib_end'].'/is',$content,$matches); - if($find) { - for($i=0;$i<$find;$i++) { - $include = $matches[1][$i]; - $array = $this->parseXmlAttrs($include); - $file = $array['file']; - unset($array['file']); - $content = str_replace($matches[0][$i],$this->parseIncludeItem($file,$array,$extend),$content); - } - } - return $content; - } - - // 解析模板中的extend标签 - protected function parseExtend($content) { - $begin = $this->config['taglib_begin']; - $end = $this->config['taglib_end']; - // 读取模板中的继承标签 - $find = preg_match('/'.$begin.'extend\s(.+?)\s*?\/'.$end.'/is',$content,$matches); - if($find) { - //替换extend标签 - $content = str_replace($matches[0],'',$content); - // 记录页面中的block标签 - preg_replace_callback('/'.$begin.'block\sname=[\'"](.+?)[\'"]\s*?'.$end.'(.*?)'.$begin.'\/block'.$end.'/is', array($this, 'parseBlock'),$content); - // 读取继承模板 - $array = $this->parseXmlAttrs($matches[1]); - $content = $this->parseTemplateName($array['name']); - $content = $this->parseInclude($content, false); //对继承模板中的include进行分析 - // 替换block标签 - $content = $this->replaceBlock($content); - }else{ - $content = preg_replace_callback('/'.$begin.'block\sname=[\'"](.+?)[\'"]\s*?'.$end.'(.*?)'.$begin.'\/block'.$end.'/is', function($match){return stripslashes($match[2]);}, $content); - } - return $content; - } - - /** - * 分析XML属性 - * @access private - * @param string $attrs XML属性字符串 - * @return array - */ - private function parseXmlAttrs($attrs) { - $xml = ''; - $xml = simplexml_load_string($xml); - if(!$xml) - E(L('_XML_TAG_ERROR_')); - $xml = (array)($xml->tag->attributes()); - $array = array_change_key_case($xml['@attributes']); - return $array; - } - - /** - * 替换页面中的literal标签 - * @access private - * @param string $content 模板内容 - * @return string|false - */ - private function parseLiteral($content) { - if(is_array($content)) $content = $content[1]; - if(trim($content)=='') return ''; - //$content = stripslashes($content); - $i = count($this->literal); - $parseStr = ""; - $this->literal[$i] = $content; - return $parseStr; - } - - /** - * 还原被替换的literal标签 - * @access private - * @param string $tag literal标签序号 - * @return string|false - */ - private function restoreLiteral($tag) { - if(is_array($tag)) $tag = $tag[1]; - // 还原literal标签 - $parseStr = $this->literal[$tag]; - // 销毁literal记录 - unset($this->literal[$tag]); - return $parseStr; - } - - /** - * 记录当前页面中的block标签 - * @access private - * @param string $name block名称 - * @param string $content 模板内容 - * @return string - */ - private function parseBlock($name,$content = '') { - if(is_array($name)){ - $content = $name[2]; - $name = $name[1]; - } - $this->block[$name] = $content; - return ''; - } - - /** - * 替换继承模板中的block标签 - * @access private - * @param string $content 模板内容 - * @return string - */ - private function replaceBlock($content){ - static $parse = 0; - $begin = $this->config['taglib_begin']; - $end = $this->config['taglib_end']; - $reg = '/('.$begin.'block\sname=[\'"](.+?)[\'"]\s*?'.$end.')(.*?)'.$begin.'\/block'.$end.'/is'; - if(is_string($content)){ - do{ - $content = preg_replace_callback($reg, array($this, 'replaceBlock'), $content); - } while ($parse && $parse--); - return $content; - } elseif(is_array($content)){ - if(preg_match('/'.$begin.'block\sname=[\'"](.+?)[\'"]\s*?'.$end.'/is', $content[3])){ //存在嵌套,进一步解析 - $parse = 1; - $content[3] = preg_replace_callback($reg, array($this, 'replaceBlock'), "{$content[3]}{$begin}/block{$end}"); - return $content[1] . $content[3]; - } else { - $name = $content[2]; - $content = $content[3]; - $content = isset($this->block[$name]) ? $this->block[$name] : $content; - return $content; - } - } - } - - /** - * 搜索模板页面中包含的TagLib库 - * 并返回列表 - * @access public - * @param string $content 模板内容 - * @return string|false - */ - public function getIncludeTagLib(& $content) { - //搜索是否有TagLib标签 - $find = preg_match('/'.$this->config['taglib_begin'].'taglib\s(.+?)(\s*?)\/'.$this->config['taglib_end'].'\W/is',$content,$matches); - if($find) { - //替换TagLib标签 - $content = str_replace($matches[0],'',$content); - //解析TagLib标签 - $array = $this->parseXmlAttrs($matches[1]); - $this->tagLib = explode(',',$array['name']); - } - return; - } - - /** - * TagLib库解析 - * @access public - * @param string $tagLib 要解析的标签库 - * @param string $content 要解析的模板内容 - * @param boolean $hide 是否隐藏标签库前缀 - * @return string - */ - public function parseTagLib($tagLib,&$content,$hide=false) { - $begin = $this->config['taglib_begin']; - $end = $this->config['taglib_end']; - if(strpos($tagLib,'\\')){ - // 支持指定标签库的命名空间 - $className = $tagLib; - $tagLib = substr($tagLib,strrpos($tagLib,'\\')+1); - }else{ - $className = 'Think\\Template\TagLib\\'.ucwords($tagLib); - } - $tLib = \Think\Think::instance($className); - $that = $this; - foreach ($tLib->getTags() as $name=>$val){ - $tags = array($name); - if(isset($val['alias'])) {// 别名设置 - $tags = explode(',',$val['alias']); - $tags[] = $name; - } - $level = isset($val['level'])?$val['level']:1; - $closeTag = isset($val['close'])?$val['close']:true; - foreach ($tags as $tag){ - $parseTag = !$hide? $tagLib.':'.$tag: $tag;// 实际要解析的标签名称 - if(!method_exists($tLib,'_'.$tag)) { - // 别名可以无需定义解析方法 - $tag = $name; - } - $n1 = empty($val['attr'])?'(\s*?)':'\s([^'.$end.']*)'; - $this->tempVar = array($tagLib, $tag); - - if (!$closeTag){ - $patterns = '/'.$begin.$parseTag.$n1.'\/(\s*?)'.$end.'/is'; - $content = preg_replace_callback($patterns, function($matches) use($tLib,$tag,$that){ - return $that->parseXmlTag($tLib,$tag,$matches[1],$matches[2]); - },$content); - }else{ - $patterns = '/'.$begin.$parseTag.$n1.$end.'(.*?)'.$begin.'\/'.$parseTag.'(\s*?)'.$end.'/is'; - for($i=0;$i<$level;$i++) { - $content=preg_replace_callback($patterns,function($matches) use($tLib,$tag,$that){ - return $that->parseXmlTag($tLib,$tag,$matches[1],$matches[2]); - },$content); - } - } - } - } - } - - /** - * 解析标签库的标签 - * 需要调用对应的标签库文件解析类 - * @access public - * @param object $tagLib 标签库对象实例 - * @param string $tag 标签名 - * @param string $attr 标签属性 - * @param string $content 标签内容 - * @return string|false - */ - public function parseXmlTag($tagLib,$tag,$attr,$content) { - if(ini_get('magic_quotes_sybase')) - $attr = str_replace('\"','\'',$attr); - $parse = '_'.$tag; - $content = trim($content); - $tags = $tagLib->parseXmlAttr($attr,$tag); - return $tagLib->$parse($tags,$content); - } - - /** - * 模板标签解析 - * 格式: {TagName:args [|content] } - * @access public - * @param string $tagStr 标签内容 - * @return string - */ - public function parseTag($tagStr){ - if(is_array($tagStr)) $tagStr = $tagStr[2]; - //if (MAGIC_QUOTES_GPC) { - $tagStr = stripslashes($tagStr); - //} - $flag = substr($tagStr,0,1); - $flag2 = substr($tagStr,1,1); - $name = substr($tagStr,1); - if('$' == $flag && '.' != $flag2 && '(' != $flag2){ //解析模板变量 格式 {$varName} - return $this->parseVar($name); - }elseif('-' == $flag || '+'== $flag){ // 输出计算 - return ''; - }elseif(':' == $flag){ // 输出某个函数的结果 - return ''; - }elseif('~' == $flag){ // 执行某个函数 - return ''; - }elseif(substr($tagStr,0,2)=='//' || (substr($tagStr,0,2)=='/*' && substr(rtrim($tagStr),-2)=='*/')){ - //注释标签 - return ''; - } - // 未识别的标签直接返回 - return C('TMPL_L_DELIM') . $tagStr .C('TMPL_R_DELIM'); - } - - /** - * 模板变量解析,支持使用函数 - * 格式: {$varname|function1|function2=arg1,arg2} - * @access public - * @param string $varStr 变量数据 - * @return string - */ - public function parseVar($varStr){ - $varStr = trim($varStr); - static $_varParseList = array(); - //如果已经解析过该变量字串,则直接返回变量值 - if(isset($_varParseList[$varStr])) return $_varParseList[$varStr]; - $parseStr = ''; - $varExists = true; - if(!empty($varStr)){ - $varArray = explode('|',$varStr); - //取得变量名称 - $var = array_shift($varArray); - if('Think.' == substr($var,0,6)){ - // 所有以Think.打头的以特殊变量对待 无需模板赋值就可以输出 - $name = $this->parseThinkVar($var); - }elseif( false !== strpos($var,'.')) { - //支持 {$var.property} - $vars = explode('.',$var); - $var = array_shift($vars); - switch(strtolower(C('TMPL_VAR_IDENTIFY'))) { - case 'array': // 识别为数组 - $name = '$'.$var; - foreach ($vars as $key=>$val) - $name .= '["'.$val.'"]'; - break; - case 'obj': // 识别为对象 - $name = '$'.$var; - foreach ($vars as $key=>$val) - $name .= '->'.$val; - break; - default: // 自动判断数组或对象 只支持二维 - $name = 'is_array($'.$var.')?$'.$var.'["'.$vars[0].'"]:$'.$var.'->'.$vars[0]; - } - }elseif(false !== strpos($var,'[')) { - //支持 {$var['key']} 方式输出数组 - $name = "$".$var; - preg_match('/(.+?)\[(.+?)\]/is',$var,$match); - $var = $match[1]; - }elseif(false !==strpos($var,':') && false ===strpos($var,'(') && false ===strpos($var,'::') && false ===strpos($var,'?')){ - //支持 {$var:property} 方式输出对象的属性 - $vars = explode(':',$var); - $var = str_replace(':','->',$var); - $name = "$".$var; - $var = $vars[0]; - }else { - $name = "$$var"; - } - //对变量使用函数 - if(count($varArray)>0) - $name = $this->parseVarFunction($name,$varArray); - $parseStr = ''; - } - $_varParseList[$varStr] = $parseStr; - return $parseStr; - } - - /** - * 对模板变量使用函数 - * 格式 {$varname|function1|function2=arg1,arg2} - * @access public - * @param string $name 变量名 - * @param array $varArray 函数列表 - * @return string - */ - public function parseVarFunction($name,$varArray){ - //对变量使用函数 - $length = count($varArray); - //取得模板禁止使用函数列表 - $template_deny_funs = explode(',',C('TMPL_DENY_FUNC_LIST')); - for($i=0;$i<$length ;$i++ ){ - $args = explode('=',$varArray[$i],2); - //模板函数过滤 - $fun = trim($args[0]); - switch($fun) { - case 'default': // 特殊模板函数 - $name = '(isset('.$name.') && ('.$name.' !== ""))?('.$name.'):'.$args[1]; - break; - default: // 通用模板函数 - if(!in_array($fun,$template_deny_funs)){ - if(isset($args[1])){ - if(strstr($args[1],'###')){ - $args[1] = str_replace('###',$name,$args[1]); - $name = "$fun($args[1])"; - }else{ - $name = "$fun($name,$args[1])"; - } - }else if(!empty($args[0])){ - $name = "$fun($name)"; - } - } - } - } - return $name; - } - - /** - * 特殊模板变量解析 - * 格式 以 $Think. 打头的变量属于特殊模板变量 - * @access public - * @param string $varStr 变量字符串 - * @return string - */ - public function parseThinkVar($varStr){ - $vars = explode('.',$varStr); - $vars[1] = strtoupper(trim($vars[1])); - $parseStr = ''; - if(count($vars)>=3){ - $vars[2] = trim($vars[2]); - switch($vars[1]){ - case 'SERVER': - $parseStr = '$_SERVER[\''.strtoupper($vars[2]).'\']';break; - case 'GET': - $parseStr = '$_GET[\''.$vars[2].'\']';break; - case 'POST': - $parseStr = '$_POST[\''.$vars[2].'\']';break; - case 'COOKIE': - if(isset($vars[3])) { - $parseStr = '$_COOKIE[\''.$vars[2].'\'][\''.$vars[3].'\']'; - }else{ - $parseStr = 'cookie(\''.$vars[2].'\')'; - } - break; - case 'SESSION': - if(isset($vars[3])) { - $parseStr = '$_SESSION[\''.$vars[2].'\'][\''.$vars[3].'\']'; - }else{ - $parseStr = 'session(\''.$vars[2].'\')'; - } - break; - case 'ENV': - $parseStr = '$_ENV[\''.strtoupper($vars[2]).'\']';break; - case 'REQUEST': - $parseStr = '$_REQUEST[\''.$vars[2].'\']';break; - case 'CONST': - $parseStr = strtoupper($vars[2]);break; - case 'LANG': - $parseStr = 'L("'.$vars[2].'")';break; - case 'CONFIG': - if(isset($vars[3])) { - $vars[2] .= '.'.$vars[3]; - } - $parseStr = 'C("'.$vars[2].'")';break; - default:break; - } - }else if(count($vars)==2){ - switch($vars[1]){ - case 'NOW': - $parseStr = "date('Y-m-d g:i a',time())"; - break; - case 'VERSION': - $parseStr = 'THINK_VERSION'; - break; - case 'TEMPLATE': - $parseStr = "'".$this->templateFile."'";//'C("TEMPLATE_NAME")'; - break; - case 'LDELIM': - $parseStr = 'C("TMPL_L_DELIM")'; - break; - case 'RDELIM': - $parseStr = 'C("TMPL_R_DELIM")'; - break; - default: - if(defined($vars[1])) - $parseStr = $vars[1]; - } - } - return $parseStr; - } - - /** - * 加载公共模板并缓存 和当前模板在同一路径,否则使用相对路径 - * @access private - * @param string $tmplPublicName 公共模板文件名 - * @param array $vars 要传递的变量列表 - * @return string - */ - private function parseIncludeItem($tmplPublicName,$vars=array(),$extend){ - // 分析模板文件名并读取内容 - $parseStr = $this->parseTemplateName($tmplPublicName); - // 替换变量 - foreach ($vars as $key=>$val) { - $parseStr = str_replace('['.$key.']',$val,$parseStr); - } - // 再次对包含文件进行模板分析 - return $this->parseInclude($parseStr,$extend); - } - - /** - * 分析加载的模板文件并读取内容 支持多个模板文件读取 - * @access private - * @param string $tmplPublicName 模板文件名 - * @return string - */ - private function parseTemplateName($templateName){ - if(substr($templateName,0,1)=='$') - //支持加载变量文件名 - $templateName = $this->get(substr($templateName,1)); - $array = explode(',',$templateName); - $parseStr = ''; - foreach ($array as $templateName){ - if(empty($templateName)) continue; - if(false === strpos($templateName,$this->config['template_suffix'])) { - // 解析规则为 模块@主题/控制器/操作 - $templateName = T($templateName); - } - // 获取模板文件内容 - $parseStr .= file_get_contents($templateName); - } - return $parseStr; - } -} diff --git a/ThinkPHP/Library/Think/Template/Driver/Ease.class.php b/ThinkPHP/Library/Think/Template/Driver/Ease.class.php deleted file mode 100644 index 192bde0..0000000 --- a/ThinkPHP/Library/Think/Template/Driver/Ease.class.php +++ /dev/null @@ -1,41 +0,0 @@ - -// +---------------------------------------------------------------------- -namespace Think\Template\Driver; -/** - * EaseTemplate模板引擎驱动 - */ -class Ease { - /** - * 渲染模板输出 - * @access public - * @param string $templateFile 模板文件名 - * @param array $var 模板变量 - * @return void - */ - public function fetch($templateFile,$var) { - $templateFile = substr($templateFile,strlen(THEME_PATH),-5); - $CacheDir = substr(CACHE_PATH,0,-1); - $TemplateDir = substr(THEME_PATH,0,-1); - vendor('EaseTemplate.template#ease'); - $config = array( - 'CacheDir' => $CacheDir, - 'TemplateDir' => $TemplateDir, - 'TplType' => 'html' - ); - if(C('TMPL_ENGINE_CONFIG')) { - $config = array_merge($config,C('TMPL_ENGINE_CONFIG')); - } - $tpl = new \EaseTemplate($config); - $tpl->set_var($var); - $tpl->set_file($templateFile); - $tpl->p(); - } -} \ No newline at end of file diff --git a/ThinkPHP/Library/Think/Template/Driver/Lite.class.php b/ThinkPHP/Library/Think/Template/Driver/Lite.class.php deleted file mode 100644 index 5f73a02..0000000 --- a/ThinkPHP/Library/Think/Template/Driver/Lite.class.php +++ /dev/null @@ -1,39 +0,0 @@ - -// +---------------------------------------------------------------------- -namespace Think\Template\Driver; -/** - * TemplateLite模板引擎驱动 - */ -class Lite { - /** - * 渲染模板输出 - * @access public - * @param string $templateFile 模板文件名 - * @param array $var 模板变量 - * @return void - */ - public function fetch($templateFile,$var) { - vendor("TemplateLite.class#template"); - $templateFile = substr($templateFile,strlen(THEME_PATH)); - $tpl = new \Template_Lite(); - $tpl->template_dir = THEME_PATH; - $tpl->compile_dir = CACHE_PATH ; - $tpl->cache_dir = TEMP_PATH ; - if(C('TMPL_ENGINE_CONFIG')) { - $config = C('TMPL_ENGINE_CONFIG'); - foreach ($config as $key=>$val){ - $tpl->{$key} = $val; - } - } - $tpl->assign($var); - $tpl->display($templateFile); - } -} \ No newline at end of file diff --git a/ThinkPHP/Library/Think/Template/Driver/Mobile.class.php b/ThinkPHP/Library/Think/Template/Driver/Mobile.class.php deleted file mode 100644 index db39e7f..0000000 --- a/ThinkPHP/Library/Think/Template/Driver/Mobile.class.php +++ /dev/null @@ -1,28 +0,0 @@ - -// +---------------------------------------------------------------------- -namespace Think\Template\Driver; -/** - * MobileTemplate模板引擎驱动 - */ -class Mobile { - /** - * 渲染模板输出 - * @access public - * @param string $templateFile 模板文件名 - * @param array $var 模板变量 - * @return void - */ - public function fetch($templateFile,$var) { - $templateFile=substr($templateFile,strlen(THEME_PATH)); - $var['_think_template_path']=$templateFile; - exit(json_encode($var)); - } -} diff --git a/ThinkPHP/Library/Think/Template/Driver/Smart.class.php b/ThinkPHP/Library/Think/Template/Driver/Smart.class.php deleted file mode 100644 index 5a2eb1c..0000000 --- a/ThinkPHP/Library/Think/Template/Driver/Smart.class.php +++ /dev/null @@ -1,40 +0,0 @@ - -// +---------------------------------------------------------------------- -namespace Think\Template\Driver; -/** - * Smart模板引擎驱动 - */ -class Smart { - /** - * 渲染模板输出 - * @access public - * @param string $templateFile 模板文件名 - * @param array $var 模板变量 - * @return void - */ - public function fetch($templateFile,$var) { - $templateFile = substr($templateFile,strlen(THEME_PATH)); - vendor('SmartTemplate.class#smarttemplate'); - $tpl = new \SmartTemplate($templateFile); - $tpl->caching = C('TMPL_CACHE_ON'); - $tpl->template_dir = THEME_PATH; - $tpl->compile_dir = CACHE_PATH ; - $tpl->cache_dir = TEMP_PATH ; - if(C('TMPL_ENGINE_CONFIG')) { - $config = C('TMPL_ENGINE_CONFIG'); - foreach ($config as $key=>$val){ - $tpl->{$key} = $val; - } - } - $tpl->assign($var); - $tpl->output(); - } -} \ No newline at end of file diff --git a/ThinkPHP/Library/Think/Template/Driver/Smarty.class.php b/ThinkPHP/Library/Think/Template/Driver/Smarty.class.php deleted file mode 100644 index aecdc10..0000000 --- a/ThinkPHP/Library/Think/Template/Driver/Smarty.class.php +++ /dev/null @@ -1,41 +0,0 @@ - -// +---------------------------------------------------------------------- -namespace Think\Template\Driver; -/** - * Smarty模板引擎驱动 - */ -class Smarty { - - /** - * 渲染模板输出 - * @access public - * @param string $templateFile 模板文件名 - * @param array $var 模板变量 - * @return void - */ - public function fetch($templateFile,$var) { - $templateFile = substr($templateFile,strlen(THEME_PATH)); - vendor('Smarty.Smarty#class'); - $tpl = new \Smarty(); - $tpl->caching = C('TMPL_CACHE_ON'); - $tpl->template_dir = THEME_PATH; - $tpl->compile_dir = CACHE_PATH ; - $tpl->cache_dir = TEMP_PATH ; - if(C('TMPL_ENGINE_CONFIG')) { - $config = C('TMPL_ENGINE_CONFIG'); - foreach ($config as $key=>$val){ - $tpl->{$key} = $val; - } - } - $tpl->assign($var); - $tpl->display($templateFile); - } -} \ No newline at end of file diff --git a/ThinkPHP/Library/Think/Template/TagLib.class.php b/ThinkPHP/Library/Think/Template/TagLib.class.php deleted file mode 100644 index 18e3be8..0000000 --- a/ThinkPHP/Library/Think/Template/TagLib.class.php +++ /dev/null @@ -1,246 +0,0 @@ - -// +---------------------------------------------------------------------- -namespace Think\Template; -/** - * ThinkPHP标签库TagLib解析基类 - */ -class TagLib { - - /** - * 标签库定义XML文件 - * @var string - * @access protected - */ - protected $xml = ''; - protected $tags = array();// 标签定义 - /** - * 标签库名称 - * @var string - * @access protected - */ - protected $tagLib =''; - - /** - * 标签库标签列表 - * @var string - * @access protected - */ - protected $tagList = array(); - - /** - * 标签库分析数组 - * @var string - * @access protected - */ - protected $parse = array(); - - /** - * 标签库是否有效 - * @var string - * @access protected - */ - protected $valid = false; - - /** - * 当前模板对象 - * @var object - * @access protected - */ - protected $tpl; - - protected $comparison = array(' nheq '=>' !== ',' heq '=>' === ',' neq '=>' != ',' eq '=>' == ',' egt '=>' >= ',' gt '=>' > ',' elt '=>' <= ',' lt '=>' < '); - - /** - * 架构函数 - * @access public - */ - public function __construct() { - $this->tagLib = strtolower(substr(get_class($this),6)); - $this->tpl = \Think\Think::instance('Think\\Template'); - } - - /** - * TagLib标签属性分析 返回标签属性数组 - * @access public - * @param string $tagStr 标签内容 - * @return array - */ - public function parseXmlAttr($attr,$tag) { - //XML解析安全过滤 - $attr = str_replace('&','___', $attr); - $xml = ''; - $xml = simplexml_load_string($xml); - if(!$xml) { - E(L('_XML_TAG_ERROR_').' : '.$attr); - } - $xml = (array)($xml->tag->attributes()); - if(isset($xml['@attributes'])){ - $array = array_change_key_case($xml['@attributes']); - if($array) { - $tag = strtolower($tag); - if(!isset($this->tags[$tag])){ - // 检测是否存在别名定义 - foreach($this->tags as $key=>$val){ - if(isset($val['alias']) && in_array($tag,explode(',',$val['alias']))){ - $item = $val; - break; - } - } - }else{ - $item = $this->tags[$tag]; - } - $attrs = explode(',',$item['attr']); - if(isset($item['must'])){ - $must = explode(',',$item['must']); - }else{ - $must = array(); - } - foreach($attrs as $name) { - if( isset($array[$name])) { - $array[$name] = str_replace('___','&',$array[$name]); - }elseif(false !== array_search($name,$must)){ - E(L('_PARAM_ERROR_').':'.$name); - } - } - return $array; - } - }else{ - return array(); - } - } - - /** - * 解析条件表达式 - * @access public - * @param string $condition 表达式标签内容 - * @return array - */ - public function parseCondition($condition) { - $condition = str_ireplace(array_keys($this->comparison),array_values($this->comparison),$condition); - $condition = preg_replace('/\$(\w+):(\w+)\s/is','$\\1->\\2 ',$condition); - switch(strtolower(C('TMPL_VAR_IDENTIFY'))) { - case 'array': // 识别为数组 - $condition = preg_replace('/\$(\w+)\.(\w+)\s/is','$\\1["\\2"] ',$condition); - break; - case 'obj': // 识别为对象 - $condition = preg_replace('/\$(\w+)\.(\w+)\s/is','$\\1->\\2 ',$condition); - break; - default: // 自动判断数组或对象 只支持二维 - $condition = preg_replace('/\$(\w+)\.(\w+)\s/is','(is_array($\\1)?$\\1["\\2"]:$\\1->\\2) ',$condition); - } - if(false !== strpos($condition, '$Think')) - $condition = preg_replace_callback('/(\$Think.*?)\s/is', array($this, 'parseThinkVar'), $condition); - return $condition; - } - - /** - * 自动识别构建变量 - * @access public - * @param string $name 变量描述 - * @return string - */ - public function autoBuildVar($name) { - if('Think.' == substr($name,0,6)){ - // 特殊变量 - return $this->parseThinkVar($name); - }elseif(strpos($name,'.')) { - $vars = explode('.',$name); - $var = array_shift($vars); - switch(strtolower(C('TMPL_VAR_IDENTIFY'))) { - case 'array': // 识别为数组 - $name = '$'.$var; - foreach ($vars as $key=>$val){ - if(0===strpos($val,'$')) { - $name .= '["{'.$val.'}"]'; - }else{ - $name .= '["'.$val.'"]'; - } - } - break; - case 'obj': // 识别为对象 - $name = '$'.$var; - foreach ($vars as $key=>$val) - $name .= '->'.$val; - break; - default: // 自动判断数组或对象 只支持二维 - $name = 'is_array($'.$var.')?$'.$var.'["'.$vars[0].'"]:$'.$var.'->'.$vars[0]; - } - }elseif(strpos($name,':')){ - // 额外的对象方式支持 - $name = '$'.str_replace(':','->',$name); - }elseif(!defined($name)) { - $name = '$'.$name; - } - return $name; - } - - /** - * 用于标签属性里面的特殊模板变量解析 - * 格式 以 Think. 打头的变量属于特殊模板变量 - * @access public - * @param string $varStr 变量字符串 - * @return string - */ - public function parseThinkVar($varStr){ - if(is_array($varStr)){//用于正则替换回调函数 - $varStr = $varStr[1]; - } - $vars = explode('.',$varStr); - $vars[1] = strtoupper(trim($vars[1])); - $parseStr = ''; - if(count($vars)>=3){ - $vars[2] = trim($vars[2]); - switch($vars[1]){ - case 'SERVER': $parseStr = '$_SERVER[\''.$vars[2].'\']';break; - case 'GET': $parseStr = '$_GET[\''.$vars[2].'\']';break; - case 'POST': $parseStr = '$_POST[\''.$vars[2].'\']';break; - case 'COOKIE': - if(isset($vars[3])) { - $parseStr = '$_COOKIE[\''.$vars[2].'\'][\''.$vars[3].'\']'; - }elseif(C('COOKIE_PREFIX')){ - $parseStr = '$_COOKIE[\''.C('COOKIE_PREFIX').$vars[2].'\']'; - }else{ - $parseStr = '$_COOKIE[\''.$vars[2].'\']'; - } - break; - case 'SESSION': - if(isset($vars[3])) { - $parseStr = '$_SESSION[\''.$vars[2].'\'][\''.$vars[3].'\']'; - }elseif(C('SESSION_PREFIX')){ - $parseStr = '$_SESSION[\''.C('SESSION_PREFIX').'\'][\''.$vars[2].'\']'; - }else{ - $parseStr = '$_SESSION[\''.$vars[2].'\']'; - } - break; - case 'ENV': $parseStr = '$_ENV[\''.$vars[2].'\']';break; - case 'REQUEST': $parseStr = '$_REQUEST[\''.$vars[2].'\']';break; - case 'CONST': $parseStr = strtoupper($vars[2]);break; - case 'LANG': $parseStr = 'L("'.$vars[2].'")';break; - case 'CONFIG': $parseStr = 'C("'.$vars[2].'")';break; - } - }else if(count($vars)==2){ - switch($vars[1]){ - case 'NOW': $parseStr = "date('Y-m-d g:i a',time())";break; - case 'VERSION': $parseStr = 'THINK_VERSION';break; - case 'TEMPLATE':$parseStr = 'C("TEMPLATE_NAME")';break; - case 'LDELIM': $parseStr = 'C("TMPL_L_DELIM")';break; - case 'RDELIM': $parseStr = 'C("TMPL_R_DELIM")';break; - default: if(defined($vars[1])) $parseStr = $vars[1]; - } - } - return $parseStr; - } - - // 获取标签定义 - public function getTags(){ - return $this->tags; - } -} \ No newline at end of file diff --git a/ThinkPHP/Library/Think/Template/TagLib/Cx.class.php b/ThinkPHP/Library/Think/Template/TagLib/Cx.class.php deleted file mode 100644 index 67b5dd4..0000000 --- a/ThinkPHP/Library/Think/Template/TagLib/Cx.class.php +++ /dev/null @@ -1,614 +0,0 @@ - -// +---------------------------------------------------------------------- -namespace Think\Template\TagLib; -use Think\Template\TagLib; -/** - * CX标签库解析类 - */ -class Cx extends TagLib { - - // 标签定义 - protected $tags = array( - // 标签定义: attr 属性列表 close 是否闭合(0 或者1 默认1) alias 标签别名 level 嵌套层次 - 'php' => array(), - 'volist' => array('attr'=>'name,id,offset,length,key,mod','level'=>3,'alias'=>'iterate'), - 'foreach' => array('attr'=>'name,item,key','level'=>3), - 'if' => array('attr'=>'condition','level'=>2), - 'elseif' => array('attr'=>'condition','close'=>0), - 'else' => array('attr'=>'','close'=>0), - 'switch' => array('attr'=>'name','level'=>2), - 'case' => array('attr'=>'value,break'), - 'default' => array('attr'=>'','close'=>0), - 'compare' => array('attr'=>'name,value,type','level'=>3,'alias'=>'eq,equal,notequal,neq,gt,lt,egt,elt,heq,nheq'), - 'range' => array('attr'=>'name,value,type','level'=>3,'alias'=>'in,notin,between,notbetween'), - 'empty' => array('attr'=>'name','level'=>3), - 'notempty' => array('attr'=>'name','level'=>3), - 'present' => array('attr'=>'name','level'=>3), - 'notpresent'=> array('attr'=>'name','level'=>3), - 'defined' => array('attr'=>'name','level'=>3), - 'notdefined'=> array('attr'=>'name','level'=>3), - 'import' => array('attr'=>'file,href,type,value,basepath','close'=>0,'alias'=>'load,css,js'), - 'assign' => array('attr'=>'name,value','close'=>0), - 'define' => array('attr'=>'name,value','close'=>0), - 'for' => array('attr'=>'start,end,name,comparison,step', 'level'=>3), - ); - - /** - * php标签解析 - * @access public - * @param array $tag 标签属性 - * @param string $content 标签内容 - * @return string - */ - public function _php($tag,$content) { - $parseStr = ''; - return $parseStr; - } - - /** - * volist标签解析 循环输出数据集 - * 格式: - * - * {user.username} - * {user.email} - * - * @access public - * @param array $tag 标签属性 - * @param string $content 标签内容 - * @return string|void - */ - public function _volist($tag,$content) { - $name = $tag['name']; - $id = $tag['id']; - $empty = isset($tag['empty'])?$tag['empty']:''; - $key = !empty($tag['key'])?$tag['key']:'i'; - $mod = isset($tag['mod'])?$tag['mod']:'2'; - // 允许使用函数设定数据集 {$vo.name} - $parseStr = 'autoBuildVar($name); - } - $parseStr .= 'if(is_array('.$name.')): $'.$key.' = 0;'; - if(isset($tag['length']) && '' !=$tag['length'] ) { - $parseStr .= ' $__LIST__ = array_slice('.$name.','.$tag['offset'].','.$tag['length'].',true);'; - }elseif(isset($tag['offset']) && '' !=$tag['offset']){ - $parseStr .= ' $__LIST__ = array_slice('.$name.','.$tag['offset'].',null,true);'; - }else{ - $parseStr .= ' $__LIST__ = '.$name.';'; - } - $parseStr .= 'if( count($__LIST__)==0 ) : echo "'.$empty.'" ;'; - $parseStr .= 'else: '; - $parseStr .= 'foreach($__LIST__ as $key=>$'.$id.'): '; - $parseStr .= '$mod = ($'.$key.' % '.$mod.' );'; - $parseStr .= '++$'.$key.';?>'; - $parseStr .= $this->tpl->parse($content); - $parseStr .= ''; - - if(!empty($parseStr)) { - return $parseStr; - } - return ; - } - - /** - * foreach标签解析 循环输出数据集 - * @access public - * @param array $tag 标签属性 - * @param string $content 标签内容 - * @return string|void - */ - public function _foreach($tag,$content) { - $name = $tag['name']; - $item = $tag['item']; - $key = !empty($tag['key'])?$tag['key']:'key'; - $name = $this->autoBuildVar($name); - $parseStr = '$'.$item.'): ?>'; - $parseStr .= $this->tpl->parse($content); - $parseStr .= ''; - - if(!empty($parseStr)) { - return $parseStr; - } - return ; - } - - /** - * if标签解析 - * 格式: - * - * - * - * - * 表达式支持 eq neq gt egt lt elt == > >= < <= or and || && - * @access public - * @param array $tag 标签属性 - * @param string $content 标签内容 - * @return string - */ - public function _if($tag,$content) { - $condition = $this->parseCondition($tag['condition']); - $parseStr = ''.$content.''; - return $parseStr; - } - - /** - * else标签解析 - * 格式:见if标签 - * @access public - * @param array $tag 标签属性 - * @param string $content 标签内容 - * @return string - */ - public function _elseif($tag,$content) { - $condition = $this->parseCondition($tag['condition']); - $parseStr = ''; - return $parseStr; - } - - /** - * else标签解析 - * @access public - * @param array $tag 标签属性 - * @return string - */ - public function _else($tag) { - $parseStr = ''; - return $parseStr; - } - - /** - * switch标签解析 - * 格式: - * - * 1 - * 2 - * other - * - * @access public - * @param array $tag 标签属性 - * @param string $content 标签内容 - * @return string - */ - public function _switch($tag,$content) { - $name = $tag['name']; - $varArray = explode('|',$name); - $name = array_shift($varArray); - $name = $this->autoBuildVar($name); - if(count($varArray)>0) - $name = $this->tpl->parseVarFunction($name,$varArray); - $parseStr = ''.$content.''; - return $parseStr; - } - - /** - * case标签解析 需要配合switch才有效 - * @access public - * @param array $tag 标签属性 - * @param string $content 标签内容 - * @return string - */ - public function _case($tag,$content) { - $value = $tag['value']; - if('$' == substr($value,0,1)) { - $varArray = explode('|',$value); - $value = array_shift($varArray); - $value = $this->autoBuildVar(substr($value,1)); - if(count($varArray)>0) - $value = $this->tpl->parseVarFunction($value,$varArray); - $value = 'case '.$value.': '; - }elseif(strpos($value,'|')){ - $values = explode('|',$value); - $value = ''; - foreach ($values as $val){ - $value .= 'case "'.addslashes($val).'": '; - } - }else{ - $value = 'case "'.$value.'": '; - } - $parseStr = ''.$content; - $isBreak = isset($tag['break']) ? $tag['break'] : ''; - if('' ==$isBreak || $isBreak) { - $parseStr .= ''; - } - return $parseStr; - } - - /** - * default标签解析 需要配合switch才有效 - * 使用: ddfdf - * @access public - * @param array $tag 标签属性 - * @param string $content 标签内容 - * @return string - */ - public function _default($tag) { - $parseStr = ''; - return $parseStr; - } - - /** - * compare标签解析 - * 用于值的比较 支持 eq neq gt lt egt elt heq nheq 默认是eq - * 格式: content - * @access public - * @param array $tag 标签属性 - * @param string $content 标签内容 - * @return string - */ - public function _compare($tag,$content,$type='eq') { - $name = $tag['name']; - $value = $tag['value']; - $type = isset($tag['type'])?$tag['type']:$type; - $type = $this->parseCondition(' '.$type.' '); - $varArray = explode('|',$name); - $name = array_shift($varArray); - $name = $this->autoBuildVar($name); - if(count($varArray)>0) - $name = $this->tpl->parseVarFunction($name,$varArray); - if('$' == substr($value,0,1)) { - $value = $this->autoBuildVar(substr($value,1)); - }else { - $value = '"'.$value.'"'; - } - $parseStr = ''.$content.''; - return $parseStr; - } - - public function _eq($tag,$content) { - return $this->_compare($tag,$content,'eq'); - } - - public function _equal($tag,$content) { - return $this->_compare($tag,$content,'eq'); - } - - public function _neq($tag,$content) { - return $this->_compare($tag,$content,'neq'); - } - - public function _notequal($tag,$content) { - return $this->_compare($tag,$content,'neq'); - } - - public function _gt($tag,$content) { - return $this->_compare($tag,$content,'gt'); - } - - public function _lt($tag,$content) { - return $this->_compare($tag,$content,'lt'); - } - - public function _egt($tag,$content) { - return $this->_compare($tag,$content,'egt'); - } - - public function _elt($tag,$content) { - return $this->_compare($tag,$content,'elt'); - } - - public function _heq($tag,$content) { - return $this->_compare($tag,$content,'heq'); - } - - public function _nheq($tag,$content) { - return $this->_compare($tag,$content,'nheq'); - } - - /** - * range标签解析 - * 如果某个变量存在于某个范围 则输出内容 type= in 表示在范围内 否则表示在范围外 - * 格式: content - * example: content - * @access public - * @param array $tag 标签属性 - * @param string $content 标签内容 - * @param string $type 比较类型 - * @return string - */ - public function _range($tag,$content,$type='in') { - $name = $tag['name']; - $value = $tag['value']; - $varArray = explode('|',$name); - $name = array_shift($varArray); - $name = $this->autoBuildVar($name); - if(count($varArray)>0) - $name = $this->tpl->parseVarFunction($name,$varArray); - - $type = isset($tag['type'])?$tag['type']:$type; - - if('$' == substr($value,0,1)) { - $value = $this->autoBuildVar(substr($value,1)); - $str = 'is_array('.$value.')?'.$value.':explode(\',\','.$value.')'; - }else{ - $value = '"'.$value.'"'; - $str = 'explode(\',\','.$value.')'; - } - if($type=='between') { - $parseStr = '= $_RANGE_VAR_[0] && '.$name.'<= $_RANGE_VAR_[1]):?>'.$content.''; - }elseif($type=='notbetween'){ - $parseStr = '$_RANGE_VAR_[1]):?>'.$content.''; - }else{ - $fun = ($type == 'in')? 'in_array' : '!in_array'; - $parseStr = ''.$content.''; - } - return $parseStr; - } - - // range标签的别名 用于in判断 - public function _in($tag,$content) { - return $this->_range($tag,$content,'in'); - } - - // range标签的别名 用于notin判断 - public function _notin($tag,$content) { - return $this->_range($tag,$content,'notin'); - } - - public function _between($tag,$content){ - return $this->_range($tag,$content,'between'); - } - - public function _notbetween($tag,$content){ - return $this->_range($tag,$content,'notbetween'); - } - - /** - * present标签解析 - * 如果某个变量已经设置 则输出内容 - * 格式: content - * @access public - * @param array $tag 标签属性 - * @param string $content 标签内容 - * @return string - */ - public function _present($tag,$content) { - $name = $tag['name']; - $name = $this->autoBuildVar($name); - $parseStr = ''.$content.''; - return $parseStr; - } - - /** - * notpresent标签解析 - * 如果某个变量没有设置,则输出内容 - * 格式: content - * @access public - * @param array $tag 标签属性 - * @param string $content 标签内容 - * @return string - */ - public function _notpresent($tag,$content) { - $name = $tag['name']; - $name = $this->autoBuildVar($name); - $parseStr = ''.$content.''; - return $parseStr; - } - - /** - * empty标签解析 - * 如果某个变量为empty 则输出内容 - * 格式: content - * @access public - * @param array $tag 标签属性 - * @param string $content 标签内容 - * @return string - */ - public function _empty($tag,$content) { - $name = $tag['name']; - $name = $this->autoBuildVar($name); - $parseStr = ''.$content.''; - return $parseStr; - } - - public function _notempty($tag,$content) { - $name = $tag['name']; - $name = $this->autoBuildVar($name); - $parseStr = ''.$content.''; - return $parseStr; - } - - /** - * 判断是否已经定义了该常量 - * 已定义 - * @param $attr - * @param $content - * @return string - */ - public function _defined($tag,$content) { - $name = $tag['name']; - $parseStr = ''.$content.''; - return $parseStr; - } - - public function _notdefined($tag,$content) { - $name = $tag['name']; - $parseStr = ''.$content.''; - return $parseStr; - } - - /** - * import 标签解析 - * - * @access public - * @param array $tag 标签属性 - * @param string $content 标签内容 - * @param boolean $isFile 是否文件方式 - * @param string $type 类型 - * @return string - */ - public function _import($tag,$content,$isFile=false,$type='') { - $file = isset($tag['file'])?$tag['file']:$tag['href']; - $parseStr = ''; - $endStr = ''; - // 判断是否存在加载条件 允许使用函数判断(默认为isset) - if (isset($tag['value'])) { - $varArray = explode('|',$tag['value']); - $name = array_shift($varArray); - $name = $this->autoBuildVar($name); - if (!empty($varArray)) - $name = $this->tpl->parseVarFunction($name,$varArray); - else - $name = 'isset('.$name.')'; - $parseStr .= ''; - $endStr = ''; - } - if($isFile) { - // 根据文件名后缀自动识别 - $type = $type?$type:(!empty($tag['type'])?strtolower($tag['type']):null); - // 文件方式导入 - $array = explode(',',$file); - foreach ($array as $val){ - if (!$type || isset($reset)) { - $type = $reset = strtolower(substr(strrchr($val, '.'),1)); - } - switch($type) { - case 'js': - $parseStr .= ''; - break; - case 'css': - $parseStr .= ''; - break; - case 'php': - $parseStr .= ''; - break; - } - } - }else{ - // 命名空间导入模式 默认是js - $type = $type?$type:(!empty($tag['type'])?strtolower($tag['type']):'js'); - $basepath = !empty($tag['basepath'])?$tag['basepath']:__ROOT__.'/Public'; - // 命名空间方式导入外部文件 - $array = explode(',',$file); - foreach ($array as $val){ - if(strpos ($val, '?')) { - list($val,$version) = explode('?',$val); - } else { - $version = ''; - } - switch($type) { - case 'js': - $parseStr .= ''; - break; - case 'css': - $parseStr .= ''; - break; - case 'php': - $parseStr .= ''; - break; - } - } - } - return $parseStr.$endStr; - } - - // import别名 采用文件方式加载(要使用命名空间必须用import) 例如 - public function _load($tag,$content) { - return $this->_import($tag,$content,true); - } - - // import别名使用 导入css文件 - public function _css($tag,$content) { - return $this->_import($tag,$content,true,'css'); - } - - // import别名使用 导入js文件 - public function _js($tag,$content) { - return $this->_import($tag,$content,true,'js'); - } - - /** - * assign标签解析 - * 在模板中给某个变量赋值 支持变量赋值 - * 格式: - * @access public - * @param array $tag 标签属性 - * @param string $content 标签内容 - * @return string - */ - public function _assign($tag,$content) { - $name = $this->autoBuildVar($tag['name']); - if('$'==substr($tag['value'],0,1)) { - $value = $this->autoBuildVar(substr($tag['value'],1)); - }else{ - $value = '\''.$tag['value']. '\''; - } - $parseStr = ''; - return $parseStr; - } - - /** - * define标签解析 - * 在模板中定义常量 支持变量赋值 - * 格式: - * @access public - * @param array $tag 标签属性 - * @param string $content 标签内容 - * @return string - */ - public function _define($tag,$content) { - $name = '\''.$tag['name']. '\''; - if('$'==substr($tag['value'],0,1)) { - $value = $this->autoBuildVar(substr($tag['value'],1)); - }else{ - $value = '\''.$tag['value']. '\''; - } - $parseStr = ''; - return $parseStr; - } - - /** - * for标签解析 - * 格式: - * @access public - * @param array $tag 标签属性 - * @param string $content 标签内容 - * @return string - */ - public function _for($tag, $content){ - //设置默认值 - $start = 0; - $end = 0; - $step = 1; - $comparison = 'lt'; - $name = 'i'; - $rand = rand(); //添加随机数,防止嵌套变量冲突 - //获取属性 - foreach ($tag as $key => $value){ - $value = trim($value); - if(':'==substr($value,0,1)) - $value = substr($value,1); - elseif('$'==substr($value,0,1)) - $value = $this->autoBuildVar(substr($value,1)); - switch ($key){ - case 'start': - $start = $value; break; - case 'end' : - $end = $value; break; - case 'step': - $step = $value; break; - case 'comparison': - $comparison = $value; break; - case 'name': - $name = $value; break; - } - } - - $parseStr = 'parseCondition('$'.$name.' '.$comparison.' $__FOR_END_'.$rand.'__').';$'.$name.'+='.$step.'){ ?>'; - $parseStr .= $content; - $parseStr .= ''; - return $parseStr; - } - -} diff --git a/ThinkPHP/Library/Think/Template/TagLib/Html.class.php b/ThinkPHP/Library/Think/Template/TagLib/Html.class.php deleted file mode 100644 index 4b39499..0000000 --- a/ThinkPHP/Library/Think/Template/TagLib/Html.class.php +++ /dev/null @@ -1,523 +0,0 @@ - -// +---------------------------------------------------------------------- -namespace Think\Template\TagLib; -use Think\Template\TagLib; -/** - * Html标签库驱动 - */ -class Html extends TagLib{ - // 标签定义 - protected $tags = array( - // 标签定义: attr 属性列表 close 是否闭合(0 或者1 默认1) alias 标签别名 level 嵌套层次 - 'editor' => array('attr'=>'id,name,style,width,height,type','close'=>1), - 'select' => array('attr'=>'name,options,values,output,multiple,id,size,first,change,selected,dblclick','close'=>0), - 'grid' => array('attr'=>'id,pk,style,action,actionlist,show,datasource','close'=>0), - 'list' => array('attr'=>'id,pk,style,action,actionlist,show,datasource,checkbox','close'=>0), - 'imagebtn' => array('attr'=>'id,name,value,type,style,click','close'=>0), - 'checkbox' => array('attr'=>'name,checkboxes,checked,separator','close'=>0), - 'radio' => array('attr'=>'name,radios,checked,separator','close'=>0) - ); - - /** - * editor标签解析 插入可视化编辑器 - * 格式: {$vo.remark} - * @access public - * @param array $tag 标签属性 - * @return string|void - */ - public function _editor($tag,$content) { - $id = !empty($tag['id'])?$tag['id']: '_editor'; - $name = $tag['name']; - $style = !empty($tag['style'])?$tag['style']:''; - $width = !empty($tag['width'])?$tag['width']: '100%'; - $height = !empty($tag['height'])?$tag['height'] :'320px'; - // $content = $tag['content']; - $type = $tag['type'] ; - switch(strtoupper($type)) { - case 'FCKEDITOR': - $parseStr = ' '; - break; - case 'FCKMINI': - $parseStr = ' '; - break; - case 'EWEBEDITOR': - $parseStr = ""; - break; - case 'NETEASE': - $parseStr = ''; - break; - case 'UBB': - $parseStr = '
          '; - break; - case 'KINDEDITOR': - $parseStr = ''; - break; - default : - $parseStr = ''; - } - - return $parseStr; - } - - /** - * imageBtn标签解析 - * 格式: - * @access public - * @param array $tag 标签属性 - * @return string|void - */ - public function _imageBtn($tag) { - $name = $tag['name']; //名称 - $value = $tag['value']; //文字 - $id = isset($tag['id'])?$tag['id']:''; //ID - $style = isset($tag['style'])?$tag['style']:''; //样式名 - $click = isset($tag['click'])?$tag['click']:''; //点击 - $type = empty($tag['type'])?'button':$tag['type']; //按钮类型 - - if(!empty($name)) { - $parseStr = '
          '; - }else { - $parseStr = '
          '; - } - - return $parseStr; - } - - /** - * imageLink标签解析 - * 格式: - * @access public - * @param array $tag 标签属性 - * @return string|void - */ - public function _imgLink($tag) { - $name = $tag['name']; //名称 - $alt = $tag['alt']; //文字 - $id = $tag['id']; //ID - $style = $tag['style']; //样式名 - $click = $tag['click']; //点击 - $type = $tag['type']; //点击 - if(empty($type)) { - $type = 'button'; - } - $parseStr = ''; - - return $parseStr; - } - - /** - * select标签解析 - * 格式: - * @access public - * @param array $tag 标签属性 - * @return string|void - */ - public function _select($tag) { - $name = $tag['name']; - $options = $tag['options']; - $values = $tag['values']; - $output = $tag['output']; - $multiple = $tag['multiple']; - $id = $tag['id']; - $size = $tag['size']; - $first = $tag['first']; - $selected = $tag['selected']; - $style = $tag['style']; - $ondblclick = $tag['dblclick']; - $onchange = $tag['change']; - - if(!empty($multiple)) { - $parseStr = ''; - } - if(!empty($first)) { - $parseStr .= ''; - } - if(!empty($options)) { - $parseStr .= '$val) { ?>'; - if(!empty($selected)) { - $parseStr .= ''; - $parseStr .= ''; - $parseStr .= ''; - $parseStr .= ''; - }else { - $parseStr .= ''; - } - $parseStr .= ''; - }else if(!empty($values)) { - $parseStr .= ''; - if(!empty($selected)) { - $parseStr .= ''; - $parseStr .= ''; - $parseStr .= ''; - $parseStr .= ''; - }else { - $parseStr .= ''; - } - $parseStr .= ''; - } - $parseStr .= ''; - return $parseStr; - } - - /** - * checkbox标签解析 - * 格式: - * @access public - * @param array $tag 标签属性 - * @return string|void - */ - public function _checkbox($tag) { - $name = $tag['name']; - $checkboxes = $tag['checkboxes']; - $checked = $tag['checked']; - $separator = $tag['separator']; - $checkboxes = $this->tpl->get($checkboxes); - $checked = $this->tpl->get($checked)?$this->tpl->get($checked):$checked; - $parseStr = ''; - foreach($checkboxes as $key=>$val) { - if($checked == $key || in_array($key,$checked) ) { - $parseStr .= ''.$val.$separator; - }else { - $parseStr .= ''.$val.$separator; - } - } - return $parseStr; - } - - /** - * radio标签解析 - * 格式: - * @access public - * @param array $tag 标签属性 - * @return string|void - */ - public function _radio($tag) { - $name = $tag['name']; - $radios = $tag['radios']; - $checked = $tag['checked']; - $separator = $tag['separator']; - $radios = $this->tpl->get($radios); - $checked = $this->tpl->get($checked)?$this->tpl->get($checked):$checked; - $parseStr = ''; - foreach($radios as $key=>$val) { - if($checked == $key ) { - $parseStr .= ''.$val.$separator; - }else { - $parseStr .= ''.$val.$separator; - } - - } - return $parseStr; - } - - /** - * list标签解析 - * 格式: - * @access public - * @param array $tag 标签属性 - * @return string - */ - public function _grid($tag) { - $id = $tag['id']; //表格ID - $datasource = $tag['datasource']; //列表显示的数据源VoList名称 - $pk = empty($tag['pk'])?'id':$tag['pk'];//主键名,默认为id - $style = $tag['style']; //样式名 - $name = !empty($tag['name'])?$tag['name']:'vo'; //Vo对象名 - $action = !empty($tag['action'])?$tag['action']:false; //是否显示功能操作 - $key = !empty($tag['key'])?true:false; - if(isset($tag['actionlist'])) { - $actionlist = explode(',',trim($tag['actionlist'])); //指定功能列表 - } - - if(substr($tag['show'],0,1)=='$') { - $show = $this->tpl->get(substr($tag['show'],1)); - }else { - $show = $tag['show']; - } - $show = explode(',',$show); //列表显示字段列表 - - //计算表格的列数 - $colNum = count($show); - if(!empty($action)) $colNum++; - if(!empty($key)) $colNum++; - - //显示开始 - $parseStr = "\n"; - $parseStr .= ''; - $parseStr .= ''; - $parseStr .= ''; - //列表需要显示的字段 - $fields = array(); - foreach($show as $val) { - $fields[] = explode(':',$val); - } - - if(!empty($key)) { - $parseStr .= ''; - } - foreach($fields as $field) {//显示指定的字段 - $property = explode('|',$field[0]); - $showname = explode('|',$field[1]); - if(isset($showname[1])) { - $parseStr .= ''; - } - if(!empty($action)) {//如果指定显示操作功能列 - $parseStr .= ''; - } - $parseStr .= ''; - $parseStr .= ''; //支持鼠标移动单元行颜色变化 具体方法在js中定义 - - if(!empty($key)) { - $parseStr .= ''; - } - foreach($fields as $field) { - //显示定义的列表字段 - $parseStr .= ''; - - } - if(!empty($action)) {//显示功能操作 - if(!empty($actionlist[0])) {//显示指定的功能项 - $parseStr .= ''; - } - } - $parseStr .= '
          No'; - }else { - $parseStr .= ''; - } - $parseStr .= $showname[0].'操作
          {$i}'; - if(!empty($field[2])) { - // 支持列表字段链接功能 具体方法由JS函数实现 - $href = explode('|',$field[2]); - if(count($href)>1) { - //指定链接传的字段值 - // 支持多个字段传递 - $array = explode('^',$href[1]); - if(count($array)>1) { - foreach ($array as $a){ - $temp[] = '\'{$'.$name.'.'.$a.'|addslashes}\''; - } - $parseStr .= ''; - }else{ - $parseStr .= ''; - } - }else { - //如果没有指定默认传编号值 - $parseStr .= ''; - } - } - if(strpos($field[0],'^')) { - $property = explode('^',$field[0]); - foreach ($property as $p){ - $unit = explode('|',$p); - if(count($unit)>1) { - $parseStr .= '{$'.$name.'.'.$unit[0].'|'.$unit[1].'} '; - }else { - $parseStr .= '{$'.$name.'.'.$p.'} '; - } - } - }else{ - $property = explode('|',$field[0]); - if(count($property)>1) { - $parseStr .= '{$'.$name.'.'.$property[0].'|'.$property[1].'}'; - }else { - $parseStr .= '{$'.$name.'.'.$field[0].'}'; - } - } - if(!empty($field[2])) { - $parseStr .= ''; - } - $parseStr .= ''; - foreach($actionlist as $val) { - if(strpos($val,':')) { - $a = explode(':',$val); - if(count($a)>2) { - $parseStr .= ''.$a[1].' '; - }else { - $parseStr .= ''.$a[1].' '; - } - }else{ - $array = explode('|',$val); - if(count($array)>2) { - $parseStr .= ' '.$array[2].' '; - }else{ - $parseStr .= ' {$'.$name.'.'.$val.'} '; - } - } - } - $parseStr .= '
          '; - $parseStr .= "\n\n"; - return $parseStr; - } - - /** - * list标签解析 - * 格式: - * @access public - * @param array $tag 标签属性 - * @return string - */ - public function _list($tag) { - $id = $tag['id']; //表格ID - $datasource = $tag['datasource']; //列表显示的数据源VoList名称 - $pk = empty($tag['pk'])?'id':$tag['pk'];//主键名,默认为id - $style = $tag['style']; //样式名 - $name = !empty($tag['name'])?$tag['name']:'vo'; //Vo对象名 - $action = $tag['action']=='true'?true:false; //是否显示功能操作 - $key = !empty($tag['key'])?true:false; - $sort = $tag['sort']=='false'?false:true; - $checkbox = $tag['checkbox']; //是否显示Checkbox - if(isset($tag['actionlist'])) { - if(substr($tag['actionlist'],0,1)=='$') { - $actionlist = $this->tpl->get(substr($tag['actionlist'],1)); - }else { - $actionlist = $tag['actionlist']; - } - $actionlist = explode(',',trim($actionlist)); //指定功能列表 - } - - if(substr($tag['show'],0,1)=='$') { - $show = $this->tpl->get(substr($tag['show'],1)); - }else { - $show = $tag['show']; - } - $show = explode(',',$show); //列表显示字段列表 - - //计算表格的列数 - $colNum = count($show); - if(!empty($checkbox)) $colNum++; - if(!empty($action)) $colNum++; - if(!empty($key)) $colNum++; - - //显示开始 - $parseStr = "\n"; - $parseStr .= ''; - $parseStr .= ''; - $parseStr .= ''; - //列表需要显示的字段 - $fields = array(); - foreach($show as $val) { - $fields[] = explode(':',$val); - } - if(!empty($checkbox) && 'true'==strtolower($checkbox)) {//如果指定需要显示checkbox列 - $parseStr .=''; - } - if(!empty($key)) { - $parseStr .= ''; - } - foreach($fields as $field) {//显示指定的字段 - $property = explode('|',$field[0]); - $showname = explode('|',$field[1]); - if(isset($showname[1])) { - $parseStr .= ''; - }else{ - $parseStr .= $showname[0].''; - } - - } - if(!empty($action)) {//如果指定显示操作功能列 - $parseStr .= ''; - } - - $parseStr .= ''; - $parseStr .= ''; - } - if(!empty($key)) { - $parseStr .= ''; - } - foreach($fields as $field) { - //显示定义的列表字段 - $parseStr .= ''; - - } - if(!empty($action)) {//显示功能操作 - if(!empty($actionlist[0])) {//显示指定的功能项 - $parseStr .= ''; - } - } - $parseStr .= '
          No'; - }else { - $parseStr .= ''; - } - $showname[2] = isset($showname[2])?$showname[2]:$showname[0]; - if($sort) { - $parseStr .= ''.$showname[0].'操作
          {$i}'; - if(!empty($field[2])) { - // 支持列表字段链接功能 具体方法由JS函数实现 - $href = explode('|',$field[2]); - if(count($href)>1) { - //指定链接传的字段值 - // 支持多个字段传递 - $array = explode('^',$href[1]); - if(count($array)>1) { - foreach ($array as $a){ - $temp[] = '\'{$'.$name.'.'.$a.'|addslashes}\''; - } - $parseStr .= ''; - }else{ - $parseStr .= ''; - } - }else { - //如果没有指定默认传编号值 - $parseStr .= ''; - } - } - if(strpos($field[0],'^')) { - $property = explode('^',$field[0]); - foreach ($property as $p){ - $unit = explode('|',$p); - if(count($unit)>1) { - $parseStr .= '{$'.$name.'.'.$unit[0].'|'.$unit[1].'} '; - }else { - $parseStr .= '{$'.$name.'.'.$p.'} '; - } - } - }else{ - $property = explode('|',$field[0]); - if(count($property)>1) { - $parseStr .= '{$'.$name.'.'.$property[0].'|'.$property[1].'}'; - }else { - $parseStr .= '{$'.$name.'.'.$field[0].'}'; - } - } - if(!empty($field[2])) { - $parseStr .= ''; - } - $parseStr .= ''; - foreach($actionlist as $val) { - if(strpos($val,':')) { - $a = explode(':',$val); - if(count($a)>2) { - $parseStr .= ''.$a[1].' '; - }else { - $parseStr .= ''.$a[1].' '; - } - }else{ - $array = explode('|',$val); - if(count($array)>2) { - $parseStr .= ' '.$array[2].' '; - }else{ - $parseStr .= ' {$'.$name.'.'.$val.'} '; - } - } - } - $parseStr .= '
          '; - $parseStr .= "\n\n"; - return $parseStr; - } -} \ No newline at end of file diff --git a/ThinkPHP/Library/Think/Think.class.php b/ThinkPHP/Library/Think/Think.class.php deleted file mode 100644 index 3bd1864..0000000 --- a/ThinkPHP/Library/Think/Think.class.php +++ /dev/null @@ -1,344 +0,0 @@ - -// +---------------------------------------------------------------------- - -namespace Think; -/** - * ThinkPHP 引导类 - */ -class Think { - - // 类映射 - private static $_map = array(); - - // 实例化对象 - private static $_instance = array(); - - /** - * 应用程序初始化 - * @access public - * @return void - */ - static public function start() { - // 注册AUTOLOAD方法 - spl_autoload_register('Think\Think::autoload'); - // 设定错误和异常处理 - register_shutdown_function('Think\Think::fatalError'); - set_error_handler('Think\Think::appError'); - set_exception_handler('Think\Think::appException'); - - // 初始化文件存储方式 - Storage::connect(STORAGE_TYPE); - - $runtimefile = RUNTIME_PATH.APP_MODE.'~runtime.php'; - if(!APP_DEBUG && Storage::has($runtimefile)){ - Storage::load($runtimefile); - }else{ - if(Storage::has($runtimefile)) - Storage::unlink($runtimefile); - $content = ''; - // 读取应用模式 - $mode = include is_file(CONF_PATH.'core.php')?CONF_PATH.'core.php':MODE_PATH.APP_MODE.'.php'; - // 加载核心文件 - foreach ($mode['core'] as $file){ - if(is_file($file)) { - include $file; - if(!APP_DEBUG) $content .= compile($file); - } - } - - // 加载应用模式配置文件 - foreach ($mode['config'] as $key=>$file){ - is_numeric($key)?C(load_config($file)):C($key,load_config($file)); - } - - // 读取当前应用模式对应的配置文件 - if('common' != APP_MODE && is_file(CONF_PATH.'config_'.APP_MODE.CONF_EXT)) - C(load_config(CONF_PATH.'config_'.APP_MODE.CONF_EXT)); - - // 加载模式别名定义 - if(isset($mode['alias'])){ - self::addMap(is_array($mode['alias'])?$mode['alias']:include $mode['alias']); - } - - // 加载应用别名定义文件 - if(is_file(CONF_PATH.'alias.php')) - self::addMap(include CONF_PATH.'alias.php'); - - // 加载模式行为定义 - if(isset($mode['tags'])) { - Hook::import(is_array($mode['tags'])?$mode['tags']:include $mode['tags']); - } - - // 加载应用行为定义 - if(is_file(CONF_PATH.'tags.php')) - // 允许应用增加开发模式配置定义 - Hook::import(include CONF_PATH.'tags.php'); - - // 加载框架底层语言包 - L(include THINK_PATH.'Lang/'.strtolower(C('DEFAULT_LANG')).'.php'); - - if(!APP_DEBUG){ - $content .= "\nnamespace { Think\\Think::addMap(".var_export(self::$_map,true).");"; - $content .= "\nL(".var_export(L(),true).");\nC(".var_export(C(),true).');Think\Hook::import('.var_export(Hook::get(),true).');}'; - Storage::put($runtimefile,strip_whitespace('getMessage(); - $trace = $e->getTrace(); - if('E'==$trace[0]['function']) { - $error['file'] = $trace[0]['file']; - $error['line'] = $trace[0]['line']; - }else{ - $error['file'] = $e->getFile(); - $error['line'] = $e->getLine(); - } - $error['trace'] = $e->getTraceAsString(); - Log::record($error['message'],Log::ERR); - // 发送404信息 - header('HTTP/1.1 404 Not Found'); - header('Status:404 Not Found'); - self::halt($error); - } - - /** - * 自定义错误处理 - * @access public - * @param int $errno 错误类型 - * @param string $errstr 错误信息 - * @param string $errfile 错误文件 - * @param int $errline 错误行数 - * @return void - */ - static public function appError($errno, $errstr, $errfile, $errline) { - switch ($errno) { - case E_ERROR: - case E_PARSE: - case E_CORE_ERROR: - case E_COMPILE_ERROR: - case E_USER_ERROR: - ob_end_clean(); - $errorStr = "$errstr ".$errfile." 第 $errline 行."; - if(C('LOG_RECORD')) Log::write("[$errno] ".$errorStr,Log::ERR); - self::halt($errorStr); - break; - default: - $errorStr = "[$errno] $errstr ".$errfile." 第 $errline 行."; - self::trace($errorStr,'','NOTIC'); - break; - } - } - - // 致命错误捕获 - static public function fatalError() { - Log::save(); - if ($e = error_get_last()) { - switch($e['type']){ - case E_ERROR: - case E_PARSE: - case E_CORE_ERROR: - case E_COMPILE_ERROR: - case E_USER_ERROR: - ob_end_clean(); - self::halt($e); - break; - } - } - } - - /** - * 错误输出 - * @param mixed $error 错误 - * @return void - */ - static public function halt($error) { - $e = array(); - if (APP_DEBUG || IS_CLI) { - //调试模式下输出错误信息 - if (!is_array($error)) { - $trace = debug_backtrace(); - $e['message'] = $error; - $e['file'] = $trace[0]['file']; - $e['line'] = $trace[0]['line']; - ob_start(); - debug_print_backtrace(); - $e['trace'] = ob_get_clean(); - } else { - $e = $error; - } - if(IS_CLI){ - exit(iconv('UTF-8','gbk',$e['message']).PHP_EOL.'FILE: '.$e['file'].'('.$e['line'].')'.PHP_EOL.$e['trace']); - } - } else { - //否则定向到错误页面 - $error_page = C('ERROR_PAGE'); - if (!empty($error_page)) { - redirect($error_page); - } else { - $message = is_array($error) ? $error['message'] : $error; - $e['message'] = C('SHOW_ERROR_MSG')? $message : C('ERROR_MESSAGE'); - } - } - // 包含异常页面模板 - $exceptionFile = C('TMPL_EXCEPTION_FILE',null,THINK_PATH.'Tpl/think_exception.tpl'); - include $exceptionFile; - exit; - } - - /** - * 添加和获取页面Trace记录 - * @param string $value 变量 - * @param string $label 标签 - * @param string $level 日志级别(或者页面Trace的选项卡) - * @param boolean $record 是否记录日志 - * @return void|array - */ - static public function trace($value='[think]',$label='',$level='DEBUG',$record=false) { - static $_trace = array(); - if('[think]' === $value){ // 获取trace信息 - return $_trace; - }else{ - $info = ($label?$label.':':'').print_r($value,true); - $level = strtoupper($level); - - if((defined('IS_AJAX') && IS_AJAX) || !C('SHOW_PAGE_TRACE') || $record) { - Log::record($info,$level,$record); - }else{ - if(!isset($_trace[$level]) || count($_trace[$level])>C('TRACE_MAX_RECORD')) { - $_trace[$level] = array(); - } - $_trace[$level][] = $info; - } - } - } -} diff --git a/ThinkPHP/Library/Think/View.class.php b/ThinkPHP/Library/Think/View.class.php deleted file mode 100644 index cbd6aaf..0000000 --- a/ThinkPHP/Library/Think/View.class.php +++ /dev/null @@ -1,229 +0,0 @@ - -// +---------------------------------------------------------------------- -namespace Think; -/** - * ThinkPHP 视图类 - */ -class View { - /** - * 模板输出变量 - * @var tVar - * @access protected - */ - protected $tVar = array(); - - /** - * 模板主题 - * @var theme - * @access protected - */ - protected $theme = ''; - - /** - * 模板变量赋值 - * @access public - * @param mixed $name - * @param mixed $value - */ - public function assign($name,$value=''){ - if(is_array($name)) { - $this->tVar = array_merge($this->tVar,$name); - }else { - $this->tVar[$name] = $value; - } - } - - /** - * 取得模板变量的值 - * @access public - * @param string $name - * @return mixed - */ - public function get($name=''){ - if('' === $name) { - return $this->tVar; - } - return isset($this->tVar[$name])?$this->tVar[$name]:false; - } - - /** - * 加载模板和页面输出 可以返回输出内容 - * @access public - * @param string $templateFile 模板文件名 - * @param string $charset 模板输出字符集 - * @param string $contentType 输出类型 - * @param string $content 模板输出内容 - * @param string $prefix 模板缓存前缀 - * @return mixed - */ - public function display($templateFile='',$charset='',$contentType='',$content='',$prefix='') { - G('viewStartTime'); - // 视图开始标签 - Hook::listen('view_begin',$templateFile); - // 解析并获取模板内容 - $content = $this->fetch($templateFile,$content,$prefix); - // 输出模板内容 - $this->render($content,$charset,$contentType); - // 视图结束标签 - Hook::listen('view_end'); - } - - /** - * 输出内容文本可以包括Html - * @access private - * @param string $content 输出内容 - * @param string $charset 模板输出字符集 - * @param string $contentType 输出类型 - * @return mixed - */ - private function render($content,$charset='',$contentType=''){ - if(empty($charset)) $charset = C('DEFAULT_CHARSET'); - if(empty($contentType)) $contentType = C('TMPL_CONTENT_TYPE'); - // 网页字符编码 - header('Content-Type:'.$contentType.'; charset='.$charset); - header('Cache-control: '.C('HTTP_CACHE_CONTROL')); // 页面缓存控制 - header('X-Powered-By:ThinkPHP'); - // 输出模板文件 - echo $content; - } - - /** - * 解析和获取模板内容 用于输出 - * @access public - * @param string $templateFile 模板文件名 - * @param string $content 模板输出内容 - * @param string $prefix 模板缓存前缀 - * @return string - */ - public function fetch($templateFile='',$content='',$prefix='') { - if(empty($content)) { - $templateFile = $this->parseTemplate($templateFile); - // 模板文件不存在直接返回 - if(!is_file($templateFile)) E(L('_TEMPLATE_NOT_EXIST_').':'.$templateFile); - }else{ - defined('THEME_PATH') or define('THEME_PATH', $this->getThemePath()); - } - // 页面缓存 - ob_start(); - ob_implicit_flush(0); - if('php' == strtolower(C('TMPL_ENGINE_TYPE'))) { // 使用PHP原生模板 - $_content = $content; - // 模板阵列变量分解成为独立变量 - extract($this->tVar, EXTR_OVERWRITE); - // 直接载入PHP模板 - empty($_content)?include $templateFile:eval('?>'.$_content); - }else{ - // 视图解析标签 - $params = array('var'=>$this->tVar,'file'=>$templateFile,'content'=>$content,'prefix'=>$prefix); - Hook::listen('view_parse',$params); - } - // 获取并清空缓存 - $content = ob_get_clean(); - // 内容过滤标签 - Hook::listen('view_filter',$content); - // 输出模板文件 - return $content; - } - - /** - * 自动定位模板文件 - * @access protected - * @param string $template 模板文件规则 - * @return string - */ - public function parseTemplate($template='') { - if(is_file($template)) { - return $template; - } - $depr = C('TMPL_FILE_DEPR'); - $template = str_replace(':', $depr, $template); - - // 获取当前模块 - $module = MODULE_NAME; - if(strpos($template,'@')){ // 跨模块调用模版文件 - list($module,$template) = explode('@',$template); - } - // 获取当前主题的模版路径 - defined('THEME_PATH') or define('THEME_PATH', $this->getThemePath($module)); - - // 分析模板文件规则 - if('' == $template) { - // 如果模板文件名为空 按照默认规则定位 - $template = CONTROLLER_NAME . $depr . ACTION_NAME; - }elseif(false === strpos($template, $depr)){ - $template = CONTROLLER_NAME . $depr . $template; - } - $file = THEME_PATH.$template.C('TMPL_TEMPLATE_SUFFIX'); - if(C('TMPL_LOAD_DEFAULTTHEME') && THEME_NAME != C('DEFAULT_THEME') && !is_file($file)){ - // 找不到当前主题模板的时候定位默认主题中的模板 - $file = dirname(THEME_PATH).'/'.C('DEFAULT_THEME').'/'.$template.C('TMPL_TEMPLATE_SUFFIX'); - } - return $file; - } - - /** - * 获取当前的模板路径 - * @access protected - * @param string $module 模块名 - * @return string - */ - protected function getThemePath($module=MODULE_NAME){ - // 获取当前主题名称 - $theme = $this->getTemplateTheme(); - // 获取当前主题的模版路径 - $tmplPath = C('VIEW_PATH'); // 模块设置独立的视图目录 - if(!$tmplPath){ - // 定义TMPL_PATH 则改变全局的视图目录到模块之外 - $tmplPath = defined('TMPL_PATH')? TMPL_PATH.$module.'/' : APP_PATH.$module.'/'.C('DEFAULT_V_LAYER').'/'; - } - return $tmplPath.$theme; - } - - /** - * 设置当前输出的模板主题 - * @access public - * @param mixed $theme 主题名称 - * @return View - */ - public function theme($theme){ - $this->theme = $theme; - return $this; - } - - /** - * 获取当前的模板主题 - * @access private - * @return string - */ - private function getTemplateTheme() { - if($this->theme) { // 指定模板主题 - $theme = $this->theme; - }else{ - /* 获取模板主题名称 */ - $theme = C('DEFAULT_THEME'); - if(C('TMPL_DETECT_THEME')) {// 自动侦测模板主题 - $t = C('VAR_TEMPLATE'); - if (isset($_GET[$t])){ - $theme = $_GET[$t]; - }elseif(cookie('think_template')){ - $theme = cookie('think_template'); - } - if(!in_array($theme,explode(',',C('THEME_LIST')))){ - $theme = C('DEFAULT_THEME'); - } - cookie('think_template',$theme,864000); - } - } - defined('THEME_NAME') || define('THEME_NAME', $theme); // 当前模板主题名称 - return $theme?$theme . '/':''; - } - -} \ No newline at end of file diff --git a/ThinkPHP/Library/Vendor/README.txt b/ThinkPHP/Library/Vendor/README.txt deleted file mode 100644 index 88cafc0..0000000 --- a/ThinkPHP/Library/Vendor/README.txt +++ /dev/null @@ -1 +0,0 @@ -第三方类库包目录 \ No newline at end of file diff --git a/ThinkPHP/Mode/common.php b/ThinkPHP/Mode/common.php deleted file mode 100644 index 5513773..0000000 --- a/ThinkPHP/Mode/common.php +++ /dev/null @@ -1,71 +0,0 @@ - -// +---------------------------------------------------------------------- - -/** - * ThinkPHP 普通模式定义 - */ -return array( - // 配置文件 - 'config' => array( - THINK_PATH.'Conf/convention.php', // 系统惯例配置 - CONF_PATH.'config'.CONF_EXT, // 应用公共配置 - ), - - // 别名定义 - 'alias' => array( - 'Think\Log' => CORE_PATH . 'Log'.EXT, - 'Think\Log\Driver\File' => CORE_PATH . 'Log/Driver/File'.EXT, - 'Think\Exception' => CORE_PATH . 'Exception'.EXT, - 'Think\Model' => CORE_PATH . 'Model'.EXT, - 'Think\Db' => CORE_PATH . 'Db'.EXT, - 'Think\Template' => CORE_PATH . 'Template'.EXT, - 'Think\Cache' => CORE_PATH . 'Cache'.EXT, - 'Think\Cache\Driver\File' => CORE_PATH . 'Cache/Driver/File'.EXT, - 'Think\Storage' => CORE_PATH . 'Storage'.EXT, - ), - - // 函数和类文件 - 'core' => array( - THINK_PATH.'Common/functions.php', - COMMON_PATH.'Common/function.php', - CORE_PATH . 'Hook'.EXT, - CORE_PATH . 'App'.EXT, - CORE_PATH . 'Dispatcher'.EXT, - //CORE_PATH . 'Log'.EXT, - CORE_PATH . 'Route'.EXT, - CORE_PATH . 'Controller'.EXT, - CORE_PATH . 'View'.EXT, - BEHAVIOR_PATH . 'BuildLiteBehavior'.EXT, - BEHAVIOR_PATH . 'ParseTemplateBehavior'.EXT, - BEHAVIOR_PATH . 'ContentReplaceBehavior'.EXT, - ), - // 行为扩展定义 - 'tags' => array( - 'app_init' => array( - 'Behavior\BuildLiteBehavior', // 生成运行Lite文件 - ), - 'app_begin' => array( - 'Behavior\ReadHtmlCacheBehavior', // 读取静态缓存 - ), - 'app_end' => array( - 'Behavior\ShowPageTraceBehavior', // 页面Trace显示 - ), - 'view_parse' => array( - 'Behavior\ParseTemplateBehavior', // 模板解析 支持PHP、内置模板引擎和第三方模板引擎 - ), - 'template_filter'=> array( - 'Behavior\ContentReplaceBehavior', // 模板输出替换 - ), - 'view_filter' => array( - 'Behavior\WriteHtmlCacheBehavior', // 写入静态缓存 - ), - ), -); diff --git a/ThinkPHP/ThinkPHP.php b/ThinkPHP/ThinkPHP.php deleted file mode 100644 index 16970a7..0000000 --- a/ThinkPHP/ThinkPHP.php +++ /dev/null @@ -1,97 +0,0 @@ - -// +---------------------------------------------------------------------- - -//---------------------------------- -// ThinkPHP公共入口文件 -//---------------------------------- - -// 记录开始运行时间 -$GLOBALS['_beginTime'] = microtime(TRUE); -// 记录内存初始使用 -define('MEMORY_LIMIT_ON',function_exists('memory_get_usage')); -if(MEMORY_LIMIT_ON) $GLOBALS['_startUseMems'] = memory_get_usage(); - -// 版本信息 -const THINK_VERSION = '3.2.3'; - -// URL 模式定义 -const URL_COMMON = 0; //普通模式 -const URL_PATHINFO = 1; //PATHINFO模式 -const URL_REWRITE = 2; //REWRITE模式 -const URL_COMPAT = 3; // 兼容模式 - -// 类文件后缀 -const EXT = '.class.php'; - -// 系统常量定义 -defined('THINK_PATH') or define('THINK_PATH', __DIR__.'/'); -defined('APP_PATH') or define('APP_PATH', dirname($_SERVER['SCRIPT_FILENAME']).'/'); -defined('APP_STATUS') or define('APP_STATUS', ''); // 应用状态 加载对应的配置文件 -defined('APP_DEBUG') or define('APP_DEBUG', false); // 是否调试模式 - -if(function_exists('saeAutoLoader')){// 自动识别SAE环境 - defined('APP_MODE') or define('APP_MODE', 'sae'); - defined('STORAGE_TYPE') or define('STORAGE_TYPE', 'Sae'); -}else{ - defined('APP_MODE') or define('APP_MODE', 'common'); // 应用模式 默认为普通模式 - defined('STORAGE_TYPE') or define('STORAGE_TYPE', 'File'); // 存储类型 默认为File -} - -defined('RUNTIME_PATH') or define('RUNTIME_PATH', APP_PATH.'Runtime/'); // 系统运行时目录 -defined('LIB_PATH') or define('LIB_PATH', realpath(THINK_PATH.'Library').'/'); // 系统核心类库目录 -defined('CORE_PATH') or define('CORE_PATH', LIB_PATH.'Think/'); // Think类库目录 -defined('BEHAVIOR_PATH')or define('BEHAVIOR_PATH', LIB_PATH.'Behavior/'); // 行为类库目录 -defined('MODE_PATH') or define('MODE_PATH', THINK_PATH.'Mode/'); // 系统应用模式目录 -defined('VENDOR_PATH') or define('VENDOR_PATH', LIB_PATH.'Vendor/'); // 第三方类库目录 -defined('COMMON_PATH') or define('COMMON_PATH', APP_PATH.'Common/'); // 应用公共目录 -defined('CONF_PATH') or define('CONF_PATH', COMMON_PATH.'Conf/'); // 应用配置目录 -defined('LANG_PATH') or define('LANG_PATH', COMMON_PATH.'Lang/'); // 应用语言目录 -defined('HTML_PATH') or define('HTML_PATH', APP_PATH.'Html/'); // 应用静态目录 -defined('LOG_PATH') or define('LOG_PATH', RUNTIME_PATH.'Logs/'); // 应用日志目录 -defined('TEMP_PATH') or define('TEMP_PATH', RUNTIME_PATH.'Temp/'); // 应用缓存目录 -defined('DATA_PATH') or define('DATA_PATH', RUNTIME_PATH.'Data/'); // 应用数据目录 -defined('CACHE_PATH') or define('CACHE_PATH', RUNTIME_PATH.'Cache/'); // 应用模板缓存目录 -defined('CONF_EXT') or define('CONF_EXT', '.php'); // 配置文件后缀 -defined('CONF_PARSE') or define('CONF_PARSE', ''); // 配置文件解析方法 -defined('ADDON_PATH') or define('ADDON_PATH', APP_PATH.'Addon'); - -// 系统信息 -if(version_compare(PHP_VERSION,'5.4.0','<')) { - ini_set('magic_quotes_runtime',0); - define('MAGIC_QUOTES_GPC',get_magic_quotes_gpc()? true : false); -}else{ - define('MAGIC_QUOTES_GPC',false); -} -define('IS_CGI',(0 === strpos(PHP_SAPI,'cgi') || false !== strpos(PHP_SAPI,'fcgi')) ? 1 : 0 ); -define('IS_WIN',strstr(PHP_OS, 'WIN') ? 1 : 0 ); -define('IS_CLI',PHP_SAPI=='cli'? 1 : 0); - -if(!IS_CLI) { - // 当前文件名 - if(!defined('_PHP_FILE_')) { - if(IS_CGI) { - //CGI/FASTCGI模式下 - $_temp = explode('.php',$_SERVER['PHP_SELF']); - define('_PHP_FILE_', rtrim(str_replace($_SERVER['HTTP_HOST'],'',$_temp[0].'.php'),'/')); - }else { - define('_PHP_FILE_', rtrim($_SERVER['SCRIPT_NAME'],'/')); - } - } - if(!defined('__ROOT__')) { - $_root = rtrim(dirname(_PHP_FILE_),'/'); - define('__ROOT__', (($_root=='/' || $_root=='\\')?'':$_root)); - } -} - -// 加载核心Think类 -require CORE_PATH.'Think'.EXT; -// 应用初始化 -Think\Think::start(); \ No newline at end of file diff --git a/ThinkPHP/Tpl/dispatch_jump.tpl b/ThinkPHP/Tpl/dispatch_jump.tpl deleted file mode 100644 index 25d4e4e..0000000 --- a/ThinkPHP/Tpl/dispatch_jump.tpl +++ /dev/null @@ -1,49 +0,0 @@ - - - - - -跳转提示 - - - -
          - -

          :)

          -

          - -

          :(

          -

          - -

          -

          -页面自动 跳转 等待时间: -

          -
          - - - diff --git a/ThinkPHP/Tpl/page_trace.tpl b/ThinkPHP/Tpl/page_trace.tpl deleted file mode 100644 index 8bd3703..0000000 --- a/ThinkPHP/Tpl/page_trace.tpl +++ /dev/null @@ -1,67 +0,0 @@ -
          - - -
          -
          - diff --git a/ThinkPHP/Tpl/think_exception.tpl b/ThinkPHP/Tpl/think_exception.tpl deleted file mode 100644 index 61fd007..0000000 --- a/ThinkPHP/Tpl/think_exception.tpl +++ /dev/null @@ -1,58 +0,0 @@ - - - - -系统发生错误 - - - -
          -

          :(

          -

          -
          - -
          -
          -

          错误位置

          -
          -
          -

          FILE:  LINE:

          -
          -
          - - -
          -
          -

          TRACE

          -
          -
          -

          -
          -
          - -
          -
          - - - diff --git a/ThinkPHP/logo.png b/ThinkPHP/logo.png deleted file mode 100644 index e0b195d..0000000 Binary files a/ThinkPHP/logo.png and /dev/null differ diff --git a/index.php b/index.php deleted file mode 100644 index 10d1083..0000000 --- a/index.php +++ /dev/null @@ -1,26 +0,0 @@ - -// +---------------------------------------------------------------------- - -// 应用入口文件 - -// 检测PHP环境 -if(version_compare(PHP_VERSION,'5.3.0','<')) die('require PHP > 5.3.0 !'); - -// 开启调试模式 建议开发阶段开启 部署阶段注释或者设为false -define('APP_DEBUG',True); - -// 定义应用目录 -define('APP_PATH','./Application/'); - -// 引入ThinkPHP入口文件 -require './ThinkPHP/ThinkPHP.php'; - -// 亲^_^ 后面不需要任何代码了 就是如此简单 \ No newline at end of file