diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 4cea788..0000000 --- a/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/.idea/ -/runtime/ \ No newline at end of file diff --git a/.htaccess b/.htaccess deleted file mode 100644 index 73c58fe..0000000 --- a/.htaccess +++ /dev/null @@ -1,8 +0,0 @@ - -RewriteEngine on -RewriteRule ^.git - [F,L] -RewriteRule ^.svn - [F,L] -RewriteCond %{REQUEST_FILENAME} !-d -RewriteCond %{REQUEST_FILENAME} !-f -RewriteRule (.*) index.php?s=$1 [QSA,PT,L] - diff --git a/404.html b/404.html deleted file mode 100644 index c7a1fb3..0000000 --- a/404.html +++ /dev/null @@ -1,26 +0,0 @@ - - - - - {$sitename} - Power By Ptcms - - - -

404页面未找到

-

很抱歉!这个页面已经找不到了.

-

你可以返回首页 {$siteurl}

-
- - \ No newline at end of file diff --git a/README.md b/README.md index 2809795..c3bba37 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,7 @@ +//模版设置 +增加pc设置与wap模版设置 +增加wap模版配置 + #PTFrameWork 开源,不只是一种行为,更是一种信仰! diff --git a/application/ad/controller/manage.php b/application/ad/controller/manage.php deleted file mode 100644 index caa0b50..0000000 --- a/application/ad/controller/manage.php +++ /dev/null @@ -1,107 +0,0 @@ -tableName='ad'; - parent::init(); - } - - public function indexAction() { - $this->list=$this->model->getlist(); - $this->display(); - } - - public function addAction() { - if (IS_POST){ - $param['name']=I('name','str',''); - if (!$param['name']){ - $this->error('请输入链接名称'); - } - $param['key']=I('key','en',''); - if (!$param['key']){ - $this->error('请输入链接地址'); - } - $param['width']=I('width','int',0); - $param['height']=I('height','int',0); - $param['code']=I('code','str',''); - $param['intro']=I('intro','str',''); - $param['status']=I('status','int',1); - $param['type']=I('isblod','int',1); - $param['create_user_id']=$_SESSION['admin']['userid']; - $param['create_time']=NOW_TIME; - if($this->model->add($param)){ - $this->success('添加成功',U('index')); - }else{ - $this->error('添加失败'); - } - } - $this->display(); - } - - public function editAction() { - $id=I('request.id','int',0); - $info=$this->model->where(array('id'=>$id))->find(); - if (IS_POST){ - $param['name']=I('name','str',''); - if (!$param['name']){ - $this->error('请输入链接名称'); - } - $param['width']=I('width','int',0); - $param['height']=I('height','int',0); - $param['code']=I('code','str',''); - $param['intro']=I('intro','str',''); - $param['status']=I('status','int',1); - $param['type']=I('isblod','int',1); - $param['update_user_id']=$_SESSION['admin']['userid']; - $param['update_time']=NOW_TIME; - $param['id']=$id; - if ($this->model->edit($param)){ - $this->success('修改成功',U('index')); - }else{ - $this->error('修改失败'); - } - } - $this->info=$info; - $this->display(); - } - - public function ajaxAction() { - $id=I('request.id','int',0); - $value=I('param','username',''); - if ($value){ - if ($passport_id=M('passport')->where(array('name'=>$value))->getfield('id')){ - $oid=$this->model->where(array('passport_id'=>$passport_id))->getfield('id'); - if ($oid && $oid!=$id){ - $data=array('status'=>'n','info'=>'您输入的用户名已经使用了'); - }else{ - $data=array('status'=>'y','info'=>'帐号可以使用'); - } - }else{ - $data=array('status'=>'n','info'=>'您输入的用户名不存在'); - } - }else{ - $data=array('status'=>'n','info'=>'输入的用户名有误'); - } - $this->ajax($data); - } - - public function multiAction() { - $param['update_user_id']=$_SESSION['admin']['userid']; - $param['update_time']=NOW_TIME; - if (isset($_POST['changestatus'])){ - foreach($_POST['id'] as $k=>$v){ - $param['id']=$v; - $param['status']=$_POST['value'][$k]; - $this->model->edit($param); - } - $this->success('修改状态成功'); - }elseif(isset($_POST['reorder'])){ - foreach($_POST['ordernum'] as $k=>$v){ - $param['id']=$k; - $param['ordernum']=$v; - $this->model->edit($param); - } - $this->success('排序成功'); - }else{ - } - } -} \ No newline at end of file diff --git a/application/ad/view/manage_add.html b/application/ad/view/manage_add.html deleted file mode 100644 index 085655f..0000000 --- a/application/ad/view/manage_add.html +++ /dev/null @@ -1,76 +0,0 @@ -
-

添加广告

-
-
-
-
-
- 广告名称: - -
-
-
-
- 广告标识: - -
-
-
-
- 广告代码: - -
-
-
-
- 广告宽: - -
-
-
-
- 广告高: - -
-
-
-
- 广告描述: - -
-
-
-
广告类型: - - -
-
- -
-
广告状态: - - -
-
-
-
-
-
- -     -
-
-
-
-
-
- - diff --git a/application/ad/view/manage_edit.html b/application/ad/view/manage_edit.html deleted file mode 100644 index 742a70d..0000000 --- a/application/ad/view/manage_edit.html +++ /dev/null @@ -1,83 +0,0 @@ -
-

修改广告

-
-
-
-
-
- 广告名称: - -
-
-
-
- 广告标识: - -
-
-
-
- 广告代码: - -
-
-
-
- 广告宽: - -
-
-
-
- 广告高: - -
-
-
-
- 广告描述: - -
-
-
-
广告类型: - - -
-
- -
-
广告状态: - - -
-
-
-
-
-
- - -     -
-
-
-
-
-
- - - \ No newline at end of file diff --git a/application/ad/view/manage_index.html b/application/ad/view/manage_index.html deleted file mode 100644 index 303b1d9..0000000 --- a/application/ad/view/manage_index.html +++ /dev/null @@ -1,106 +0,0 @@ -
-

{$menuinfo.menu.name}

-
-
-
-
- 添加 -
-
- - -
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
广告名称创建人创建时间修改人修改时间状态操作
{{loop.name}}({{loop.key}}){{loop.width}}{{loop.height}}{{loop.create_username}}{{loop.create_time}}{{loop.update_username}}{{loop.update_time}} - 禁用 - 正常 - - 预览 - 调用 - 编辑 - 删除 -
- -
-
-
-
-
-
-
调用代码: - -
-
-
-
- - 复制代码 -
-
-
-
-{include file="/application/admin/view/public_angular.html"} - - \ No newline at end of file diff --git a/application/admin/controller/config.php b/application/admin/controller/config.php deleted file mode 100644 index 05cce1f..0000000 --- a/application/admin/controller/config.php +++ /dev/null @@ -1,70 +0,0 @@ -tableName='admin_user'; - parent::init(); - } - - public function indexAction() { - $this->list=$this->model->getlist(); - $this->pagestr=''; - $this->display(); - } - - public function addAction() { - if (IS_POST){ - var_dump($_POST);exit;; - $param['create_user_id']=$_SESSION['admin']['userid']; - $param['create_time']=NOW_TIME; - if($this->model->add($param)){ - $this->success('添加成功',U('index')); - }else{ - $this->error('添加失败'); - } - } - $this->display(); - } - - public function editAction() { - $id=I('request.id','int',0); - $info=$this->model->field('id,passport_id,group_id,intro,status')->where(array('id'=>$id))->find(); - if (IS_POST){ - $param['intro']=I('intro','str'); - $param['group_id']=I('groupid','int',0); - $param['status']=I('status','int',0); - $param['update_user_id']=$_SESSION['admin']['userid']; - $param['update_time']=NOW_TIME; - $param['id']=$id; - if ($this->model->edit($param)){ - $this->success('修改成功',U('index')); - }else{ - $this->error('修改失败'); - } - } - $this->grouplist=M('admin_group')->field('id,name')->select(); - $info['name']=dc::get('passport',$info['passport_id'],'name'); - $this->info=$info; - $this->display(); - } - - public function ajaxAction() { - $id=I('request.id','int',0); - $value=I('param','username',''); - if ($value){ - if ($passport_id=M('passport')->where(array('name'=>$value))->getfield('id')){ - $oid=$this->model->where(array('passport_id'=>$passport_id))->getfield('id'); - if ($oid && $oid!=$id){ - $data=array('status'=>'n','info'=>'您输入的用户名已经使用了'); - }else{ - $data=array('status'=>'y','info'=>'帐号可以使用'); - } - }else{ - $data=array('status'=>'n','info'=>'您输入的用户名不存在'); - } - }else{ - $data=array('status'=>'n','info'=>'输入的用户名有误'); - } - $this->ajax($data); - } -} \ No newline at end of file diff --git a/application/admin/controller/group.php b/application/admin/controller/group.php deleted file mode 100644 index db6fcfa..0000000 --- a/application/admin/controller/group.php +++ /dev/null @@ -1,55 +0,0 @@ -tableName='admin_group'; - parent::init(); - } - - public function indexAction() { - $this->list=$this->model->order('id asc')->getlist(); - $this->display(); - } - - public function addAction() { - if (IS_POST){ - $param['name']=I('name','str'); - $param['intro']=I('intro','str'); - $param['node']=implode(',',M('admin_node')->toNodeAuth(I('node','arr',array()))); - $param['create_user_id']=$_SESSION['admin']['userid']; - $param['create_time']=NOW_TIME; - if($this->model->add($param)){ - $this->success('添加成功',U('index')); - }else{ - $this->error('添加失败'); - } - } - $tree=new Tree(M('admin_node')); - $this->menu=$tree->getAuthList(0,'id,name'); - $this->display(); - } - - public function editAction() { - $id=I('request.id','int',0); - $info=$this->model->field('id,name,node,intro')->where(array('id'=>$id))->find(); - if (IS_POST){ - $param['name']=I('name','str'); - $param['intro']=I('intro','str'); - $param['node']=implode(',',M('admin_node')->toNodeAuth(I('node','arr',array()))); - $param['update_user_id']=$_SESSION['admin']['userid']; - $param['update_time']=NOW_TIME; - $param['id']=$id; - if ($this->model->edit($param)){ - $this->success('修改成功',U('index')); - }else{ - $this->error('修改失败'); - } - } - $info['node']=explode(',',$info['node']); - $tree=new Tree(M('admin_node')); - $this->menu=$tree->getAuthList(0,'id,name'); - $this->info=$info; - $this->display(); - } - -} \ No newline at end of file diff --git a/application/admin/controller/index.php b/application/admin/controller/index.php deleted file mode 100644 index 2a2b3e5..0000000 --- a/application/admin/controller/index.php +++ /dev/null @@ -1,47 +0,0 @@ -menu=$tree->getSonList(0,'id,name,module,controller,action',array('status'=>1)); - }else{ - //其他 - $this->menu=$tree->getSonList(0,'id,name,module,controller,action',array('status'=>1,'id'=>array('in',dc::get('admin_group',$_SESSION['admin']['groupid'],'node')))); - } - $this->display(); - } - - //欢迎页 - public function welcomeAction() { - $tips = array(); - // success info warning danger - if (C('appid') == 'test') { - $tips[] = array('type' => 'danger', 'content' => '您当前使用的APPID为test,请抓紧时间申请正式APPID,否则您可能会无法使用我们的API服务!点击这里更换'); - } - if (C('adminpath') == 'admin') { - $tips[] = array('type' => 'warning', 'content' => '您后台目录为默认的admin,为安全考虑,请您更改目录地址!点击这里更换'); - } - $usernum = M('passport')->count(); - $this->sitenum = 1; - $this->usernum = $usernum; - $this->adnum = 1; - $this->friendlinknum = count(C('friendlink')); - $this->tips = $tips; - $this->display(); - } -} \ No newline at end of file diff --git a/application/admin/controller/node.php b/application/admin/controller/node.php deleted file mode 100644 index e107008..0000000 --- a/application/admin/controller/node.php +++ /dev/null @@ -1,93 +0,0 @@ -tableName='admin_node'; - parent::init(); - } - - public function indexAction() { - $tree=new Tree($this->model); - $list=$tree->getIconList($tree->getList(0,'id,name,module,controller,action,ordernum,status'),2); - foreach($list as &$v){ - $v['url_edit']=U('admin.node.edit',array('id'=>$v['id'])); - $v['url_son']=U('admin.node.add',array('pid'=>$v['id'])); - } - $this->list=$list; - $this->assign('totalnum', count($this->list)); - $this->display(); - } - - public function addAction() { - if(IS_POST){ - $param['name']=I('name','str',''); - $param['pid']=I('pid','int',0); - $param['module']=I('module','str',''); - $param['controller']=I('controller','str',''); - $param['action']=I('action','str',''); - $param['status']=I('status','int',1); - $param['ordernum']=I('ordernum','int',1); - $param['create_user_id']=$_SESSION['admin']['userid']; - $param['create_time']=NOW_TIME; - if($this->model->add($param)){ - $this->success('添加成功'); - }else{ - $this->error('添加失败'); - } - } - $tree=new Tree($this->model); - $this->parentlist=$tree->getIconList($tree->getList(0,'id,name')); - $this->display(); - } - - public function editAction() { - $id=I('request.id','int',0); - $info=$this->model->field('id,name,pid,module,controller,action,status,ordernum')->where(array('id'=>$id))->find(); - if (IS_POST){ - if ($info['id']==$_POST['pid']){ - $this->error('不能设置自己为上级节点'); - } - $param['name']=I('name','str',''); - $param['pid']=I('pid','int',0); - $param['module']=I('module','str',''); - $param['controller']=I('controller','str',''); - $param['action']=I('action','str',''); - $param['status']=I('status','int',1); - $param['ordernum']=I('ordernum','int',1); - $param['update_user_id']=$_SESSION['admin']['userid']; - $param['update_time']=NOW_TIME; - $param['id']=$id; - if ($this->model->edit($param)){ - $this->success('修改成功'); - }else{ - $this->error('修改失败'); - } - } - $tree=new Tree($this->model); - $this->parentlist=$tree->getIconList($tree->getList(0,'id,name')); - $this->info=$info; - $this->display(); - } - - public function multiAction() { - $param['update_user_id']=$_SESSION['admin']['userid']; - $param['update_time']=NOW_TIME; - if (isset($_POST['changestatus'])){ - foreach($_POST['id'] as $k=>$v){ - $param['id']=$v; - $param['status']=$_POST['value'][$k]; - $this->model->edit($param); - } - $this->success('修改状态成功'); - }elseif(isset($_POST['reorder'])){ - foreach($_POST['ordernum'] as $k=>$v){ - $param['id']=$k; - $param['ordernum']=$v; - $this->model->edit($param); - } - $this->success('排序成功'); - }else{ - } - } -} \ No newline at end of file diff --git a/application/admin/controller/public.php b/application/admin/controller/public.php deleted file mode 100644 index fd935e6..0000000 --- a/application/admin/controller/public.php +++ /dev/null @@ -1,46 +0,0 @@ -checkInfo($username, $password)) { - if (M('admin_user')->checkUserStatus($userid)) { - M('admin_user')->setLoginStatus($userid); - $this->success('登录成功',U('admin.index.index')); - } else { - $this->error('您没有权限进入后台!'); - } - } else { - $this->error('帐号和密码输入错误'); - } - } else { - $this->error('验证码输入错误'); - } - } - $this->display(); - } - - // 退出操作 - public function logoutAction() { - M('admin_user')->delLoginStatus(); - $this->success('已经成功退出系统',U('Admin.Index.index')); - } - - /** - * 验证码 - */ - public function verifyAction() { - verify::buildImageVerify(6, 1, 'png', 70, 30); - } -} \ No newline at end of file diff --git a/application/admin/controller/theme.php b/application/admin/controller/theme.php deleted file mode 100644 index a8c1ccd..0000000 --- a/application/admin/controller/theme.php +++ /dev/null @@ -1,58 +0,0 @@ -defaulttpl = $config['tpl_theme']; - $this->list = M('theme')->getlist(); - $this->display(); - } - - public function setAction() { - $key = I('get.tpl', 'str', ''); - cookie('THEME_' . MODULE_NAME, null); - $this->saveconfig(array('tpl_theme' => $key)); - $this->success('设置默认模版成功'); - } - - public function configAction() { - $key = I('get.tpl', 'str', ''); - $file = TPL_PATH . '/' . $key . '/config.php'; - if (!$this->config = pt::import($file)) { - $this->config = array(); - } - if (IS_POST) { - $data = array(); - foreach ($_POST as $k => $v) { - if ($v['name'] && $v['key']) { - $data[$v['key']] = array( - 'name' => $v['name'], - 'value' => $v['value'], - ); - } - } - F($file, $data); - $this->success('修改成功'); - } - $this->tpl = I('get.tpl', 'str'); - $this->display(); - } - - public function delAction() { - $key = I('get.tpl', 'str', ''); - $id = I('get.id', 'str', ''); - $file = TPL_PATH . '/' . $key . '/config.php'; - $data = pt::import($file); - if (isset($data[$id])) { - unset($data[$id]); - F($file, $data); - $this->success('删除成功'); - } - $this->error('没有找到对应的配置项'); - } -} \ No newline at end of file diff --git a/application/admin/controller/user.php b/application/admin/controller/user.php deleted file mode 100644 index 627fa29..0000000 --- a/application/admin/controller/user.php +++ /dev/null @@ -1,87 +0,0 @@ -tableName='admin_user'; - parent::init(); - } - - public function indexAction() { - $this->list=$this->model->getlist(); - $this->display(); - } - - public function addAction() { - if (IS_POST){ - $param['passport_id']=M('passport')->where(array('name'=>I('name','username','')))->getfield('id'); - $param['intro']=I('intro','str'); - $param['group_id']=I('groupid','int',0); - $param['status']=I('status','int',0); - $param['create_user_id']=$_SESSION['admin']['userid']; - $param['create_time']=NOW_TIME; - $param['login_num']=0; - if($this->model->add($param)){ - $this->success('添加成功',U('index')); - }else{ - $this->error('添加失败'); - } - } - $this->grouplist=M('admin_group')->field('id,name')->select(); - $this->display(); - } - - public function editAction() { - $id=I('request.id','int',0); - $info=$this->model->field('id,passport_id,group_id,intro,status')->where(array('id'=>$id))->find(); - if (IS_POST){ - $param['intro']=I('intro','str'); - $param['group_id']=I('groupid','int',0); - $param['status']=I('status','int',0); - $param['update_user_id']=$_SESSION['admin']['userid']; - $param['update_time']=NOW_TIME; - $param['id']=$id; - if ($this->model->edit($param)){ - $this->success('修改成功',U('index')); - }else{ - $this->error('修改失败'); - } - } - $this->grouplist=M('admin_group')->field('id,name')->select(); - $info['name']=dc::get('passport',$info['passport_id'],'name'); - $this->info=$info; - $this->display(); - } - - public function multiAction() { - $param['update_user_id']=$_SESSION['admin']['userid']; - $param['update_time']=NOW_TIME; - if (isset($_POST['changestatus'])){ - foreach($_POST['id'] as $k=>$v){ - $param['id']=$v; - $param['status']=$_POST['value'][$k]; - $this->model->edit($param); - } - $this->success('修改状态成功'); - } - } - - public function ajaxAction() { - $id=I('request.id','int',0); - $value=I('param','username',''); - if ($value){ - if ($passport_id=M('passport')->where(array('name'=>$value))->getfield('id')){ - $oid=$this->model->where(array('passport_id'=>$passport_id))->getfield('id'); - if ($oid && $oid!=$id){ - $data=array('status'=>'n','info'=>'您输入的用户名已经使用了'); - }else{ - $data=array('status'=>'y','info'=>'帐号可以使用'); - } - }else{ - $data=array('status'=>'n','info'=>'您输入的用户名不存在'); - } - }else{ - $data=array('status'=>'n','info'=>'输入的用户名有误'); - } - $this->ajax($data); - } -} \ No newline at end of file diff --git a/application/admin/model/theme.php b/application/admin/model/theme.php deleted file mode 100644 index e4bc1ad..0000000 --- a/application/admin/model/theme.php +++ /dev/null @@ -1,21 +0,0 @@ - -

添加配置项

-
-
-
-
-
- 配置名称: - -
-
-
-
- 配置Key: - -
-
-
-
- 配置说明: - -
-
-
-
- 配置值: - -
-
-
-
- 配置类型: - -
-
-
-
- 配置分组: - -
-
-
-
- 配置选项: - -
-
-
-
- 排序序号: - -
-
-
-
配置级别: - - - - 核心配置生成在主配置文件,扩展配置生成在扩展文件,辅助配置不生成到文件 -
-
- -
-
配置状态: - - -
-
-
-
-
-
- -     -
-
-
-
-
- - - - \ No newline at end of file diff --git a/application/admin/view/config_index.html b/application/admin/view/config_index.html deleted file mode 100644 index 9c14935..0000000 --- a/application/admin/view/config_index.html +++ /dev/null @@ -1,66 +0,0 @@ -
-

{$menuinfo.menu.name}

-
-
-
-
- 添加 -
-
- - - -
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
用户名用户组创建人创建时间修改人修改时间登录数登录时间状态操作
{{loop.username}}{{loop.groupname}}{{loop.create_username}}{{loop.create_time}}{{loop.update_username}}{{loop.update_time}}{{loop.login_num}}{{loop.login_time}} - 禁用 - 正常 - - 编辑 - 删除 -
- -
-
-
-{include file="public_angular"} \ No newline at end of file diff --git a/application/admin/view/css/admin.css b/application/admin/view/css/admin.css deleted file mode 100644 index fedbbff..0000000 --- a/application/admin/view/css/admin.css +++ /dev/null @@ -1,2155 +0,0 @@ -/* reset*/ -html, body, h1, h2, h3, h4, h5, h6, div, dl, dt, dd, ul, ol, li, p, blockquote, pre, hr, figure, table, caption, th, td, form, fieldset, legend, input, button, textarea, menu { margin: 0; padding: 0; } -header, footer, section, article, aside, nav, hgroup, address, figure, figcaption, menu, details { display: block; } -table { border-collapse: collapse; border-spacing: 0; } -caption, th { text-align: left; font-weight: normal; } -html, body, fieldset, img, iframe, abbr { border: 0; } -i, cite, em, var, address, dfn { font-style: normal; } -[hidefocus], summary { outline: 0; } -li { list-style: none; } -h1, h2, h3, h4, h5, h6, small { font-size: 100%; } -sup, sub { font-size: 83%; } -pre, code, kbd, samp { font-family: inherit; } -q:before, q:after { content: none; } -textarea { overflow: auto; resize: none; } -label, summary { cursor: default; } -a, button { cursor: pointer; } -h1, h2, h3, h4, h5, h6, em, strong, b { font-weight: bold; } -del, ins, u, s, a, a:hover { text-decoration: none; } -body, textarea, input, button, select, keygen, legend { font: 14px/20px 'microsoft Yahei', Tahoma, Geneva, sans-serif; color: #333; outline: 0; } -a:link { color: #0082cb; text-decoration: none; } -a:visited { color: #0082cb; text-decoration: none; } -a:hover { color: #0082cb; text-decoration: underline; } -a:active { color: #0082cb; text-decoration: none; } -/* function */ -.f-cb:after, .f-cbli li:after { display: block; clear: both; visibility: hidden; height: 0; overflow: hidden; content: "."; } -.f-cb, .f-cbli li { zoom: 1; } -.f-ib { display: inline-block; *display: inline; *zoom: 1; } -.f-dn { display: none; } -.f-db { display: block; } -.f-fl { float: left; } -.f-fr { float: right; } -.f-pr { position: relative; } -.f-prz { position: relative; zoom: 1; } -.f-oh { overflow: hidden; } -.f-fwn { font-weight: normal; } -.f-fwb { font-weight: bold; } -.f-tal { text-align: left; } -.f-tac { text-align: center; } -.f-tar { text-align: right; } -.f-taj { text-align: justify; text-justify: inter-ideograph; } -.f-vam, .f-vama * { vertical-align: middle; } -.f-wsn { word-wrap: normal; white-space: nowrap; } -.f-pre { overflow: hidden; text-align: left; white-space: pre-wrap; word-wrap: break-word; word-break: break-all; } -.f-wwb { white-space: normal; word-wrap: break-word; word-break: break-all; } -.f-ti { overflow: hidden; text-indent: -30000px; } -.f-ti2 { text-indent: 2em; } -.f-lhn { line-height: normal; } -.f-tdu, .f-tdu:hover { text-decoration: underline; } -.f-tdn, .f-tdn:hover { text-decoration: none; } -.f-toe { overflow: hidden; word-wrap: normal; white-space: nowrap; text-overflow: ellipsis; } -.f-csp { cursor: pointer; } -.f-csd { cursor: default; } -.f-csh { cursor: help; } -.f-csm { cursor: move; } -.f-usn { -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; -o-user-select: none; user-select: none; } -.f-clear { clear: both } -/* 颜色 */ -.c-red { color: red } -.w160 { width: 160px } -.w320 { width: 320px; } -.w450 { width: 450px; !important; } -.w640 { width: 640px; } -label { cursor: pointer } -/* 公共 */ -.input-text { - padding: 3px; - font-size: 14px; - vertical-align: middle; - height: 22px; - color: #555; - vertical-align: middle; - border: 1px solid #ccc; - border-radius: 4px; - -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); - box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); - -webkit-transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s; - transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s; -} -.input-box { - padding: 3px; - font-size: 14px; - line-height: 25px; - vertical-align: middle; - border: 1px solid #ccc; - border-radius: 4px; - -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); - box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); - -webkit-transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s; - transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s; -} -.input-box:focus, .input-text:focus { - border-color: #66afe9; - outline: 0; - -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(102, 175, 233, 0.6); - box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(102, 175, 233, 0.6); -} -.input-box:-moz-placeholder, .input-text:-moz-placeholder { - color: #999999; -} -.input-box:-moz-placeholder, .input-text:-moz-placeholder { - color: #999999; - opacity: 1; -} -.input-box:-ms-input-placeholder, .input-text:-ms-input-placeholder { - color: #999999; -} -.input-box:-webkit-input-placeholder, .input-text:-webkit-input-placeholder { - color: #999999; -} -.input-text[disabled], .input-text[readonly] { - cursor: not-allowed; - background-color: #eeeeee; -} -.pt-set-wrap input[type=radio], .pt-set-wrap input[type=checkbox] { - margin-right: 5px; - vertical-align: -2px; -} -a.box { - display: inline-block; - margin-left: 6px; - margin-bottom: 1px; - width: 70px; - height: 23px; - line-height: 23px; - border-width: 1px; - border-style: solid; - border-color: #ccc; - -moz-border-radius: 3px; - -webkit-border-radius: 3px; - border-radius: 3px; - background: #F9FBFD; - text-align: center; - vertical-align: middle; -} -a.box:hover { - background: #f6f6f6; - color: #333; - text-decoration: none; -} -/*登录用户*/ -#pt-login .pt-login-wrap { - margin: 80px auto 0; - padding: 20px; - width: 650px; - height: 350px; - background: url(../image/login_bg.png) no-repeat; -} -#pt-login .pt-login-wrap .pt-login-title { - position: relative; - height: 60px; - background: url(../image/login_t.png) repeat-x; -} -#pt-login .pt-login-wrap .pt-login-title .pt-title-logo { - background: url(../image/login_logo.png) no-repeat; - position: absolute; - top: 14px; - left: 35px; - width: 137px; - height: 32px; -} -#pt-login .pt-login-wrap .pt-login-content { - padding: 40px 0 0 156px; - line-height: 28px; -} -#pt-login .pt-login-wrap .pt-login-content .pt-login-form-line { - margin-bottom: 25px; -} -#pt-login .pt-login-wrap .pt-login-content .pt-login-form-btn { - margin-left: 72px; -} -#pt-login .pt-login-wrap .pt-login-content label { - display: block; - float: left; - width: 74px; - font-size: 14px; - text-align: right; -} -#pt-login .pt-login-wrap .pt-login-content .verify-input { - width: 80px; -} -#pt-login .pt-login-wrap .pt-login-content .verify { - margin-left: 5px; - margin-right: 5px; - vertical-align: bottom; cursor: pointer; -} -/*头部菜单*/ -#pt-header { - position: relative; - border-bottom: #ccc 1px solid; - height: 89px; - min-width: 990px; - background: #f5f5f5; - background: -webkit-linear-gradient(top, #fff 0%, #f1f1f1 100%); - background: -moz-linear-gradient(top, #fff 0%, #f1f1f1 100%); - background: linear-gradient(top, #fff 0%, #f1f1f1 100%); -} -#pt-header .logo { - position: absolute; - left: 20px; - top: 20px; - width: 240px; - height: 36px; - background: url(../image/logo.png) no-repeat; -} -#pt-header .menu { - position: absolute; - left: 300px; - bottom: -1px; - _bottom: -2px; -} -#pt-header .menu a { - float: left; - height: 35px; - margin-left: 7px; - text-decoration: none; - font-size: 15px; - line-height: 35px; - text-align: center; - font-weight: bold; - letter-spacing: 0.6em; - padding-left: 1.5em; - padding-right: 0.9em; -} -#pt-header .menu .current { - color: #000000; -} -#pt-header .menu .link { - color: #333; - border: #ccc 1px solid; - border-radius: 6px 6px 0 0; - -moz-border-radius: 6px 6px 0 0; - -webkit-border-radius: 6px 6px 0 0; - background: #eee; - background: -webkit-linear-gradient(top, #fafafa 0%, #e0e0e0 100%); - background: -moz-linear-gradient(top, #fafafa 0%, #e0e0e0 100%); - background: linear-gradient(top, #fafafa 0%, #e0e0e0 100%); -} -#pt-header .menu .link:hover { - background: #f3f3f3; - cursor: pointer; -} -#pt-header .menu .link.current { - background: #fff; - background: -webkit-linear-gradient(top, #fafafa 0%, #fff 100%); - background: -moz-linear-gradient(top, #fafafa 0%, #fff 100%); - background: linear-gradient(top, #fafafa 0%, #fff 100%); - border-bottom-color: #fff; -} -#pt-header .menu .link.current:hover { - background: #f9f9f9; - background: #fff; - background: -webkit-linear-gradient(top, #eee 0%, #fff 100%); - background: -moz-linear-gradient(top, #eee 0%, #fff 100%); - background: linear-gradient(top, #eee 0%, #fff 100%); - cursor: pointer; -} -#pt-header .login-info { - position: absolute; - top: 15px; - right: 20px; - color: #7a7a7a; -} -#pt-header .login-info a { - color: #7a7a7a; -} -#pt-header .login-info em { - margin: 0 5px; -} -/** 主体**/ -#container { - padding: 10px 10px 0; - overflow: hidden; - min-width: 820px; -} -.pt-sidebar { - float: left; - width: 171px; - border: 1px solid #ccc; - background: #FFF; - overflow: hidden; -} -.pt-sidebar .pt-sidebar-menu li i { - width: 40px; - height: 40px; - text-align: center; - position: relative; - float: right; - display: inline-block; - top: 1px; - font-family: 'Glyphicons Halflings'; - -webkit-font-smoothing: antialiased; - font-style: normal; - font-weight: normal; - border-bottom: 0px; -} -.pt-sidebar .pt-sidebar-menu li i:before { - content: "\2b"; - before: "\2b"; -} -.pt-sidebar .pt-sidebar-menu li div { - display: none; -} -.pt-sidebar .pt-sidebar-menu li.open { - border-bottom: 1px #ccc solid; -} -.pt-sidebar .pt-sidebar-menu li.open h3 { - cursor: default; -} -.pt-sidebar .pt-sidebar-menu li.open i:before { - content: "\2212"; - before: "\2212"; -} -.pt-sidebar .pt-sidebar-menu li h3 { - padding-left: 15px; - border-bottom: 1px #ccc solid; - line-height: 39px; - font-size: 15px; - cursor: pointer; - background: #fafafa; - background: -webkit-linear-gradient(top, #fafafa 0%, #eee 100%); - background: -moz-linear-gradient(top, #fafafa 0%, #eee 100%); - background: linear-gradient(top, #fafafa 0%, #eee 100%); -} -.pt-sidebar .pt-sidebar-menu-info a { - display: block; - margin: 10px; - height: 25px; - line-height: 25px; - color: #0082cb; - font-size: 14px; - text-indent: 25px; -} -.pt-sidebar .pt-sidebar-menu-info a:hover { - background: #d4e5ff; - text-decoration: none; - -moz-border-radius: 3px; - -webkit-border-radius: 3px; - border-radius: 3px; -} -.pt-sidebar .pt-sidebar-menu-info a.current { - background-color: #0082cb; - color: #FFF; - -moz-border-radius: 3px; - -webkit-border-radius: 3px; - border-radius: 3px; -} -.pt-sidebar .pt-sidebar-menu-info a.current:hover { - background-color: #0082cb; - color: #FFF; - -moz-border-radius: 3px; - -webkit-border-radius: 3px; - border-radius: 3px; -} -/* 右侧主内容 */ -.pt-main { - margin-left: 181px; - border-width: 1px; - border-style: solid; - border-color: #ccc; - min-width: 800px; - _zoom: 1; -} -#mainframe { - overflow-x: hidden; - overflow-y: auto; -} -/*弹出层*/ -.pt-pop { - padding: 20px 20px 0; - width: 460px; -} -/* 内容 */ -.pt-main-wrap .pt-set-wrap, .pt-main-wrap .pt-table-wrap, .pt-main-wrap .pt-wrap { - position: relative; - padding: 20px 20px 20px; - background: #fff; - _zoom: 1; -} -.pt-main-wrap .pt-set-wrap .pt-set-box { - margin: 20px 0; -} -.pt-main-wrap .pt-path { - background: #fafafa; - background: -webkit-linear-gradient(top, #fafafa 0%, #eee 100%); - background: -moz-linear-gradient(top, #fafafa 0%, #eee 100%); - background: linear-gradient(top, #fafafa 0%, #eee 100%); - height: 40px; - line-height: 40px; - color: #444; - position: relative; - padding-left: 20px; - font-size: 15px; - border-bottom: 1px #ccc solid; -} -.pt-main-wrap .pt-path .pt-path-icon { - width: 25px; - height: 40px; - top: 2px; - text-align: left; - position: relative; - display: inline-block; - font-family: 'Glyphicons Halflings'; - -webkit-font-smoothing: antialiased; - font-style: normal; - font-weight: normal; -} -.pt-main-wrap .pt-msg-title { - padding-left: 10px; - -moz-border-radius: 10px; - -webkit-border-radius: 10px; - border-radius: 10px; - background: #eaf3fa; - -moz-border-radius: 3px; - -webkit-border-radius: 3px; - height: 38px; - line-height: 38px; - font-size: 15px; - color: #333; -} -.pt-msg-title span { - float: right; -} -.pt-msg-title span a.btn { - color: #fff; - margin: 4px 10px 4px; - font-size: 14px; - height: 18px; - line-height: 18px; -} -.pt-main-wrap .pt-msg-box { - margin: 15px 20px; -} -.pt-msg-box .tips { - margin-bottom: 5px; - color: #555; - text-indent: 2em; -} -.pt-msg-box .tipsbottom { - margin-top: 15px; - color: #555; -} -.pt-msg-box .quote { - padding: 10px; - border: #F6EAD2 1px solid; - color: #666; - background: #FFFCF4; - line-height: 24px; - margin-top: 10px; -} -.pt-main-wrap .pt-set-content { - /*padding: 15px 20px 0;*/ - _zoom: 1; - position: relative -} -.pt-set-content .pt-set-info { - margin-bottom: 15px; - padding-bottom: 15px; - border-bottom: 1px #ccc dashed; -} -.pt-set-content .pt-set-info:last-child { - border-bottom: none; -} -.pt-set-info .name { - width: 6em; - text-align: right; - display: inline-block -} -.pt-set-info .title { - padding-bottom: 8px; -} -.pt-set-info .line { -} -.pt-set-info .line b { - width: 10em; - text-align: right; - display: inline-block -} -.pt-set-info .auth b { - width: 8em; - text-align: right; - display: inline-block -} -.pt-set-info .auth label { - width: 100px; -} -.pt-set-info p { -} -.pt-set-info label { - display: inline-block; -} -.pt-set-info p span { - color: #666; - margin-left: 15px; -} -.pt-set-info .tips { - margin-top: 10px; - margin-left: 15px; - color: #666; -} -/*选项卡*/ -.pt-tab { - margin: 20px 0; -} -.pt-tab-nav { - font-weight: bold; -} -.pt-tab-nav a { - position: relative; - top: 1px; - cursor: pointer; - font-size: 15px; - height: 38px; - line-height: 38px; - margin-right: 5px; - color: #222; - border: #ccc 1px solid; - border-radius: 8px 8px 0 0; - -moz-border-radius: 8px 8px 0 0; - -webkit-border-radius: 8px 8px 0 0; - background: #f1f1f1; - text-decoration: none; - display: inline-block; - padding: 0 15px; -} -.pt-tab-nav .current { - border: #ccc 1px solid; - border-radius: 8px 8px 0 0; - -moz-border-radius: 8px 8px 0 0; - -webkit-border-radius: 8px 8px 0 0; - border-bottom-color: #fff; - background: #fff; -} -.pt-tab-content { - padding: 15px 10px 10px; - border: 1px solid #ccc; - clear: both; -} -.pt-tab-item { - display: none; -} -.pt-tab-button { - padding-left: 20px -} -/*列表展示*/ -.pt-table-wrap .pt-search-area, .pt-table-wrap .pt-list { - margin: 15px 0; -} -.pt-table-wrap .tips { - font-size: 15px; - line-height: 2em; - margin-bottom: 10px; -} -.pt-search-area .pt-search-box { - padding: 10px 10px 0; - border: #d9e7f4 1px solid; - height: 40px; - background: #f4f8fc; - overflow: hidden; - zoom: 1; - _zoom: 1; -} -.pt-search-box strong { - font-size: 15px; -} -.pt-list-title { - height: 30px; - line-height: 30px; -} -.pt-list-table { - width: 100%; - border-spacing: 0; - border: 1px #ccc solid; -} -.pt-list-table td { - padding: 5px 10px; - overflow: hidden; -} -.pt-list-table thead th { - background: #f9f9f9; - text-transform: uppercase; - font-size: 16px; - font-weight: 600; - border-bottom: 1px solid #ccc; - text-shadow: -1px -1px #fff; - padding: 5px 10px; - text-align: left; - height: 30px; - border-right: #CCC 1px solid; - text-align: center; -} -.pt-list-table thead th.f-tal, .pt-list-table tbody td.f-tal { - text-align: left; -} -.pt-list-table thead th.f-tar, .pt-list-table tbody td.f-tar { - text-align: right; -} -.pt-list-table thead th:hover { - cursor: pointer; -} -.pt-list-table tbody { - border-top: 1px solid #fff; - background: #fff; -} -.pt-list-table tbody tr:hover.odd td, .pt-list-table tr:hover td { - background: #eaeaea; -} -.pt-list-table tbody tr:nth-child(2n) { - background: #f4f4f4; -} -.pt-list-table tbody td { - font-size: 11px; - vertical-align: middle; - height: 25px; - border-right: #CCC 1px solid; - font-size: 14px; - text-align: center; - white-space: nowrap; - text-overflow: ellipsis; - overflow: hidden; -} -.pt-list-table .operate a { - margin-right: 5px; - color: #333; -} -.pt-list-table .operate a:hover { - color: #000; -} -.pt-list-table .operate a:last-child, .pt-list-table .operate a.last { - margin-right: 0; -} -.pt-list-table .operate .icon { - margin-right: 2px; -} -.pt-list-table .w-checkbox { width: 10px; } -.pt-list-table .w-id { width: 50px; } -.pt-list-table .w-fulltime { width: 134px; } -.pt-list-table .w-time { width: 96px; } -.pt-list-table .w-smalltime { width: 77px; } -.pt-list-table .w-word4 { width: 68px; } -.pt-list-table .w-word5 { width: 85px; } -.pt-list-table .w-word4td { width: 56px; } -.pt-list-table .w-word5 { width: 85px; } -.pt-list-table .w-word4 { width: 68px; } -.pt-list-table .w-word3 { width: 51px; } -.pt-list-table .w-word2 { width: 34px; } -.pt-list-table .w-operate1 { width: 45px; } -.pt-list-table .w-operate2 { width: 100px; } -.pt-list-table .w-operate3 { width: 150px; } -.pt-list-table .w-operate4 { width: 200px; } -.pt-list-table .w-operate5 { width: 256px; } -.pt-list-footer { - margin-top: 10px; line-height: 35px; -} -.pt-list-header { - margin-bottom: 10px; line-height: 35px; -} -.pt-list-operate a { - color: #fff; - margin-right: 3px; -} -.pt-list-operate input { - margin-right: 3px; -} -/* 分页 */ -/* 普通翻页器-默认居中 */ -.pt-page { margin: 1px; text-align: center; height: 30px; line-height: 28px; font-size: 0; letter-spacing: -0.307em; word-wrap: normal; white-space: nowrap; color: #999; } -.pt-page a, .pt-page i { display: inline-block; vertical-align: text-bottom; margin: 0 3px; border-radius: 5px; padding: 0 10px; border: 1px solid #ddd; font-size: 14px; letter-spacing: normal; text-shadow: 0 1px #fff; background: #fff; -webkit-transition: background-color 0.3s; -moz-transition: background-color 0.3s; -ms-transition: background-color 0.3s; transition: background-color 0.3s; } -.pt-page i { border: 0; } -.pt-page a, .pt-page a:hover { text-decoration: none; color: #39c; } -.pt-page a:first-child { margin-left: 0; border-radius: 5px; } -.pt-page a:last-child { margin-right: 0; border-radius: 5px; } -.pt-page a:hover { background: #f5f5f5; } -.pt-page a:active { background: #f0f0f0; } -.pt-page a.current, .pt-page a.current:hover, .pt-page a.current:active { cursor: default; color: #999; background: #f5f5f5; } -.pt-page a.disable, .pt-page a.disable:hover, .pt-page a.disable:active { cursor: default; color: #ccc; background: #fff; } -/* 分栏 */ -.pt-col { - margin-top: 20px; - padding: 0 20px; -} -.pt-col-2 { width: 49.5% } -.pt-col-3 { width: 32.65% } -.pt-col-4 { width: 24.25% } -.pt-col-5 { width: 19.2% } -.pt-col-item { - float: left; - min-height: 50px; - margin-right: 1%; -} -.pt-col-item-last { - margin-right: 0; - float: right -} -/* widget */ -.pt-widget { - border: 1px solid #CDCDCD; - width: 100%; -} -.pt-widget a { - color: #333; -} -.pt-widget-title { - background-color: #f4f4f4; - border-bottom: 1px solid #CDCDCD; - height: 35px; - line-height: 35px; -} -.pt-widget-title span { - width: 35px; - border-right: 1px solid #CDCDCD; - float: left; - text-align: center; -} -.pt-widget-title h5 { - float: left; - margin-left: 10px; -} -.pt-widget-content { - min-height: 50px; - background: #FaFaFa; -} -.pt-wcon-text, .pt-wcon-list, .pt-wcon-piclist { - padding: 10px; -} -.pt-wcon-text p { - text-indent: 2em; - line-height: 1.5em; -} -.pt-wcon-list ul { - line-height: 30px; - padding: 0 10px; -} -.pt-wcon-list li { border-bottom: 1px #cecece dotted; height: 30px } -.pt-wcon-list li:first-child { border-top: 1px #cecece dotted; } -.pt-wcon-list i { width: 30px; text-align: center } -.pt-wcon-list strong { width: 150px; display: inline-block; } -.pt-wcon-list li a { display: inline-block } -.pt-wcon-piclist li { - height: 60px; - border-bottom: 1px #cecece dotted; -} -.pt-wcon-piclist li:last-child { - border-bottom-width: 0px; -} -.pt-wcon-piclist .picbox { - background: none repeat scroll 0 0 #FFFFFF; - float: left; - height: 40px; - margin-right: 10px; - margin-top: 5px; - padding: 2px; - width: 40px; -} -.pt-wcon-piclist .textbox { - margin: 5px 0; - position: relative; - font-size: 12px; -} -.pt-wcon-piclist .textbox .info { - color: #999; - line-height: 18px; - height: 18px; - overflow: hidden; -} -.pt-wcon-piclist .textbox .content { - height: 38px; - line-height: 19px; - overflow: hidden; -} -.pt-wcon-infobox { -} -.pt-wcon-infobox .iconbox { - border-right: 1px solid #CDCDCD; - width: 60px; - height: 60px; - line-height: 60px; - font-size: 40px; - padding: 10px; - float: left; -} -.pt-wcon-infobox .infobox { - padding: 10px; -} -.pt-wcon-infobox .infobox strong { - height: 35px; - line-height: 35px; - display: block; - font-size: 20px; - overflow: hidden; -} -.pt-wcon-infobox .infobox span { - height: 25px; - line-height: 25px; -} -.pt-wcon-chart { - margin-top: 20px; - padding: 0 20px; - height: 300px; -} -.pt-wcon-chart .chartbox { - float: left; - width: 74%; -} -.pt-wcon-chart .infobox { - float: right; - width: 24%; -} -.pt-wcon-chart .chartbox .chart { - height: 300px; - width: 100%; -} -.pt-wcon-chart .site-stats { - margin: 0; - padding: 0; text-align: center; - list-style: none; -} -.pt-wcon-chart .site-stats li { - cursor: pointer; - display: inline-block; - margin: 0 5px 10px; - text-align: center; - width: 42%; - height: 65px; - padding: 10px 0; - color: #fff; - position: relative; - background: #b6b3b3; - float: left; -} -.pt-wcon-chart .site-stats li i { - font-size: 24px; - clear: both -} -.pt-wcon-chart .site-stats li:hover { - background: #2E363F; -} -.pt-wcon-chart .site-stats li i { - vertical-align: baseline; -} -.pt-wcon-chart .site-stats li strong { - font-weight: bold; - font-size: 20px; width: 100%; float: left; - margin-left: 0px; -} -.pt-wcon-chart .site-stats li small { - margin-left: 0px; - font-size: 11px; - width: 100%; float: left; -} -/* bootstrap */ - -.label { - padding: 5px 8px 5px; - -webkit-border-radius: 3px; - -moz-border-radius: 3px; - border-radius: 3px; - font-size: 12px; - line-height: 14px; - color: #333333; - vertical-align: baseline; - white-space: nowrap; - background-color: #ffffff; - border: 1px solid transparent; - cursor: pointer; - border-color: #cccccc; -} -.label:hover { - color: #333333; - background-color: #ebebeb; - border-color: #adadad; -} -.btn { - display: inline-block; - padding: 6px 12px; - margin-bottom: 0; - font-size: 14px; - font-weight: normal; - line-height: 1.428571429; - text-align: center; - white-space: nowrap; - vertical-align: middle; - cursor: pointer; - background-image: none; - border: 1px solid transparent; - border-radius: 4px; - -webkit-user-select: none; - -moz-user-select: none; - -ms-user-select: none; - -o-user-select: none; - user-select: none; -} -.btn:focus { - outline: thin dotted; - outline: 5px auto -webkit-focus-ring-color; - outline-offset: -2px; -} -.btn:hover, .btn:focus { - color: #333333; - text-decoration: none; -} -.btn:active, .btn.active { - background-image: none; - outline: 0; - -webkit-box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.125); - box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.125); -} -.btn.disabled, .btn[disabled], fieldset[disabled] .btn { - pointer-events: none; - cursor: not-allowed; - opacity: 0.65; - filter: alpha(opacity=65); - -webkit-box-shadow: none; - box-shadow: none; -} -.btn-default, .label-default { - color: #333333; - background-color: #ffffff; - border-color: #cccccc; -} -.btn-default:hover, .label-default:hover, .btn-default:focus, .btn-default:active, .btn-default.active, .open .dropdown-toggle.btn-default { - color: #333333; - background-color: #ebebeb; - border-color: #adadad; -} -.btn-default:active, .btn-default.active, .open .dropdown-toggle.btn-default { - background-image: none; -} -.btn-default.disabled, .btn-default[disabled], fieldset[disabled] .btn-default, .btn-default.disabled:hover, .btn-default[disabled]:hover, fieldset[disabled] .btn-default:hover, .btn-default.disabled:focus, .btn-default[disabled]:focus, fieldset[disabled] .btn-default:focus, .btn-default.disabled:active, .btn-default[disabled]:active, fieldset[disabled] .btn-default:active, .btn-default.disabled.active, .btn-default[disabled].active, fieldset[disabled] .btn-default.active { - background-color: #ffffff; - border-color: #cccccc; -} -.btn-default .badge { - color: #ffffff; - background-color: #fff; -} -.btn-primary, .label-primary { - color: #ffffff; - background-color: #428bca; - border-color: #357ebd; -} -.btn-primary:hover, .label-primary:hover, .btn-primary:focus, .btn-primary:active, .btn-primary.active, .open .dropdown-toggle.btn-primary { - color: #ffffff; - background-color: #3276b1; - border-color: #285e8e; -} -.btn-primary:active, .btn-primary.active, .open .dropdown-toggle.btn-primary { - background-image: none; -} -.btn-primary.disabled, .btn-primary[disabled], fieldset[disabled] .btn-primary, .btn-primary.disabled:hover, .btn-primary[disabled]:hover, fieldset[disabled] .btn-primary:hover, .btn-primary.disabled:focus, .btn-primary[disabled]:focus, fieldset[disabled] .btn-primary:focus, .btn-primary.disabled:active, .btn-primary[disabled]:active, fieldset[disabled] .btn-primary:active, .btn-primary.disabled.active, .btn-primary[disabled].active, fieldset[disabled] .btn-primary.active { - background-color: #428bca; - border-color: #357ebd; -} -.btn-primary .badge { - color: #428bca; - background-color: #fff; -} -.btn-warning, .label-warning { - color: #ffffff; - background-color: #f0ad4e; - border-color: #eea236; -} -.btn-warning:hover, .label-warning:hover, .btn-warning:focus, .btn-warning:active, .btn-warning.active, .open .dropdown-toggle.btn-warning { - color: #ffffff; - background-color: #ed9c28; - border-color: #d58512; -} -.btn-warning:active, .btn-warning.active, .open .dropdown-toggle.btn-warning { - background-image: none; -} -.btn-warning.disabled, .btn-warning[disabled], fieldset[disabled] .btn-warning, .btn-warning.disabled:hover, .btn-warning[disabled]:hover, fieldset[disabled] .btn-warning:hover, .btn-warning.disabled:focus, .btn-warning[disabled]:focus, fieldset[disabled] .btn-warning:focus, .btn-warning.disabled:active, .btn-warning[disabled]:active, fieldset[disabled] .btn-warning:active, .btn-warning.disabled.active, .btn-warning[disabled].active, fieldset[disabled] .btn-warning.active { - background-color: #f0ad4e; - border-color: #eea236; -} -.btn-warning .badge { - color: #f0ad4e; - background-color: #fff; -} -.btn-danger, .label-danger { - color: #ffffff; - background-color: #d9534f; - border-color: #d43f3a; -} -.btn-danger:hover, .label-danger:hover, .btn-danger:focus, .btn-danger:active, .btn-danger.active, .open .dropdown-toggle.btn-danger { - color: #ffffff; - background-color: #d2322d; - border-color: #ac2925; -} -.btn-danger:active, .btn-danger.active, .open .dropdown-toggle.btn-danger { - background-image: none; -} -.btn-danger.disabled, .btn-danger[disabled], fieldset[disabled] .btn-danger, .btn-danger.disabled:hover, .btn-danger[disabled]:hover, fieldset[disabled] .btn-danger:hover, .btn-danger.disabled:focus, .btn-danger[disabled]:focus, fieldset[disabled] .btn-danger:focus, .btn-danger.disabled:active, .btn-danger[disabled]:active, fieldset[disabled] .btn-danger:active, .btn-danger.disabled.active, .btn-danger[disabled].active, fieldset[disabled] .btn-danger.active { - background-color: #d9534f; - border-color: #d43f3a; -} -.btn-danger .badge { - color: #d9534f; - background-color: #fff; -} -.btn-success, .label-success { - color: #ffffff; - background-color: #5cb85c; - border-color: #4cae4c; -} -.btn-success:hover, .label-success:hover, .btn-success:focus, .btn-success:active, .btn-success.active, .open .dropdown-toggle.btn-success { - color: #ffffff; - background-color: #47a447; - border-color: #398439; -} -.btn-success:active, .btn-success.active, .open .dropdown-toggle.btn-success { - background-image: none; -} -.btn-success.disabled, .btn-success[disabled], fieldset[disabled] .btn-success, .btn-success.disabled:hover, .btn-success[disabled]:hover, fieldset[disabled] .btn-success:hover, .btn-success.disabled:focus, .btn-success[disabled]:focus, fieldset[disabled] .btn-success:focus, .btn-success.disabled:active, .btn-success[disabled]:active, fieldset[disabled] .btn-success:active, .btn-success.disabled.active, .btn-success[disabled].active, fieldset[disabled] .btn-success.active { - background-color: #5cb85c; - border-color: #4cae4c; -} -.btn-success .badge { - color: #5cb85c; - background-color: #fff; -} -.btn-info, .label-info { - color: #ffffff; - background-color: #5bc0de; - border-color: #46b8da; -} -.btn-info:hover, .label-info:hover, .btn-info:focus, .btn-info:active, .btn-info.active, .open .dropdown-toggle.btn-info { - color: #ffffff; - background-color: #39b3d7; - border-color: #269abc; -} -.btn-info:active, .btn-info.active, .open .dropdown-toggle.btn-info { - background-image: none; -} -.btn-info.disabled, .btn-info[disabled], fieldset[disabled] .btn-info, .btn-info.disabled:hover, .btn-info[disabled]:hover, fieldset[disabled] .btn-info:hover, .btn-info.disabled:focus, .btn-info[disabled]:focus, fieldset[disabled] .btn-info:focus, .btn-info.disabled:active, .btn-info[disabled]:active, fieldset[disabled] .btn-info:active, .btn-info.disabled.active, .btn-info[disabled].active, fieldset[disabled] .btn-info.active { - background-color: #5bc0de; - border-color: #46b8da; -} -.btn-info .badge { - color: #5bc0de; - background-color: #fff; -} -.btn-link { - font-weight: normal; - color: #428bca; - cursor: pointer; - border-radius: 0; -} -.btn-link, .btn-link:active, .btn-link[disabled], fieldset[disabled] .btn-link { - background-color: transparent; - -webkit-box-shadow: none; - box-shadow: none; -} -.btn-link, .btn-link:hover, .btn-link:focus, .btn-link:active { - border-color: transparent; -} -.btn-link:hover, .btn-link:focus { - color: #2a6496; - text-decoration: underline; - background-color: transparent; -} -.btn-link[disabled]:hover, fieldset[disabled] .btn-link:hover, .btn-link[disabled]:focus, fieldset[disabled] .btn-link:focus { - color: #999999; - text-decoration: none; -} -.btn-lg { - padding: 10px 16px; - font-size: 18px; - line-height: 1.33; - border-radius: 6px; -} -.btn-sm { - padding: 5px 10px; - font-size: 12px; - line-height: 1.5; - border-radius: 3px; -} -.btn-xs { - padding: 1px 5px; - font-size: 12px; - line-height: 1.5; - border-radius: 3px; -} -.btn-block { - display: block; - width: 100%; - padding-right: 0; - padding-left: 0; -} -.btn-block + .btn-block { - margin-top: 5px; -} -input[type="submit"].btn-block, input[type="reset"].btn-block, input[type="button"].btn-block { - width: 100%; -} -@font-face { - font-family: 'Glyphicons Halflings'; - src: url('./glyphicons-halflings-regular.eot'); - src: url('./glyphicons-halflings-regular.eot?#iefix') format('embedded-opentype'), url('./glyphicons-halflings-regular.woff') format('woff'), url('./glyphicons-halflings-regular.ttf') format('truetype'), url('./glyphicons-halflings-regular.svg#glyphicons-halflingsregular') format('svg'); -} -.icon { - position: relative; - display: inline-block; - top: 1px; - font-family: 'Glyphicons Halflings'; - -webkit-font-smoothing: antialiased; - font-style: normal; - font-weight: normal; - -moz-osx-font-smoothing: grayscale; -} -.icon-asterisk:before { - content: "\2a"; - before: "\2a"; -} -.icon-plus:before { - content: "\2b"; - before: "\2b"; -} -.icon-euro:before { - content: "\20ac"; - before: "\20ac"; -} -.icon-minus:before { - content: "\2212"; - before: "\2212"; -} -.icon-cloud:before { - content: "\2601"; - before: "\2601"; -} -.icon-envelope:before { - content: "\2709"; - before: "\2709"; -} -.icon-pencil:before { - content: "\270f"; - before: "\270f"; -} -.icon-glass:before { - content: "\e001"; - before: "\e001"; -} -.icon-music:before { - content: "\e002"; - before: "\e002"; -} -.icon-search:before { - content: "\e003"; - before: "\e003"; -} -.icon-heart:before { - content: "\e005"; - before: "\e005"; -} -.icon-star:before { - content: "\e006"; - before: "\e006"; -} -.icon-star-empty:before { - content: "\e007"; - before: "\e007"; -} -.icon-user:before { - content: "\e008"; - before: "\e008"; -} -.icon-film:before { - content: "\e009"; - before: "\e009"; -} -.icon-th-large:before { - content: "\e010"; - before: "\e010"; -} -.icon-th:before { - content: "\e011"; - before: "\e011"; -} -.icon-th-list:before { - content: "\e012"; - before: "\e012"; -} -.icon-ok:before { - content: "\e013"; - before: "\e013"; -} -.icon-remove:before { - content: "\e014"; - before: "\e014"; -} -.icon-zoom-in:before { - content: "\e015"; - before: "\e015"; -} -.icon-zoom-out:before { - content: "\e016"; - before: "\e016"; -} -.icon-off:before { - content: "\e017"; - before: "\e017"; -} -.icon-signal:before { - content: "\e018"; - before: "\e018"; -} -.icon-cog:before { - content: "\e019"; - before: "\e019"; -} -.icon-trash:before { - content: "\e020"; - before: "\e020"; -} -.icon-home:before { - content: "\e021"; - before: "\e021"; -} -.icon-file:before { - content: "\e022"; - before: "\e022"; -} -.icon-time:before { - content: "\e023"; - before: "\e023"; -} -.icon-road:before { - content: "\e024"; - before: "\e024"; -} -.icon-download-alt:before { - content: "\e025"; - before: "\e025"; -} -.icon-download:before { - content: "\e026"; - before: "\e026"; -} -.icon-upload:before { - content: "\e027"; - before: "\e027"; -} -.icon-inbox:before { - content: "\e028"; - before: "\e028"; -} -.icon-play-circle:before { - content: "\e029"; - before: "\e029"; -} -.icon-repeat:before { - content: "\e030"; - before: "\e030"; -} -.icon-refresh:before { - content: "\e031"; - before: "\e031"; -} -.icon-list-alt:before { - content: "\e032"; - before: "\e032"; -} -.icon-lock:before { - content: "\e033"; - before: "\e033"; -} -.icon-flag:before { - content: "\e034"; - before: "\e034"; -} -.icon-headphones:before { - content: "\e035"; - before: "\e035"; -} -.icon-volume-off:before { - content: "\e036"; - before: "\e036"; -} -.icon-volume-down:before { - content: "\e037"; - before: "\e037"; -} -.icon-volume-up:before { - content: "\e038"; - before: "\e038"; -} -.icon-qrcode:before { - content: "\e039"; - before: "\e039"; -} -.icon-barcode:before { - content: "\e040"; - before: "\e040"; -} -.icon-tag:before { - content: "\e041"; - before: "\e041"; -} -.icon-tags:before { - content: "\e042"; - before: "\e042"; -} -.icon-book:before { - content: "\e043"; - before: "\e043"; -} -.icon-bookmark:before { - content: "\e044"; - before: "\e044"; -} -.icon-print:before { - content: "\e045"; - before: "\e045"; -} -.icon-camera:before { - content: "\e046"; - before: "\e046"; -} -.icon-font:before { - content: "\e047"; - before: "\e047"; -} -.icon-bold:before { - content: "\e048"; - before: "\e048"; -} -.icon-italic:before { - content: "\e049"; - before: "\e049"; -} -.icon-text-height:before { - content: "\e050"; - before: "\e050"; -} -.icon-text-width:before { - content: "\e051"; - before: "\e051"; -} -.icon-align-left:before { - content: "\e052"; - before: "\e052"; -} -.icon-align-center:before { - content: "\e053"; - before: "\e053"; -} -.icon-align-right:before { - content: "\e054"; - before: "\e054"; -} -.icon-align-justify:before { - content: "\e055"; - before: "\e055"; -} -.icon-list:before { - content: "\e056"; - before: "\e056"; -} -.icon-indent-left:before { - content: "\e057"; - before: "\e057"; -} -.icon-indent-right:before { - content: "\e058"; - before: "\e058"; -} -.icon-facetime-video:before { - content: "\e059"; - before: "\e059"; -} -.icon-picture:before { - content: "\e060"; - before: "\e060"; -} -.icon-map-marker:before { - content: "\e062"; - before: "\e062"; -} -.icon-adjust:before { - content: "\e063"; - before: "\e063"; -} -.icon-tint:before { - content: "\e064"; - before: "\e064"; -} -.icon-edit:before { - content: "\e065"; - before: "\e065"; -} -.icon-share:before { - content: "\e066"; - before: "\e066"; -} -.icon-check:before { - content: "\e067"; - before: "\e067"; -} -.icon-move:before { - content: "\e068"; - before: "\e068"; -} -.icon-step-backward:before { - content: "\e069"; - before: "\e069"; -} -.icon-fast-backward:before { - content: "\e070"; - before: "\e070"; -} -.icon-backward:before { - content: "\e071"; - before: "\e071"; -} -.icon-play:before { - content: "\e072"; - before: "\e072"; -} -.icon-pause:before { - content: "\e073"; - before: "\e073"; -} -.icon-stop:before { - content: "\e074"; - before: "\e074"; -} -.icon-forward:before { - content: "\e075"; - before: "\e075"; -} -.icon-fast-forward:before { - content: "\e076"; - before: "\e076"; -} -.icon-step-forward:before { - content: "\e077"; - before: "\e077"; -} -.icon-eject:before { - content: "\e078"; - before: "\e078"; -} -.icon-chevron-left:before { - content: "\e079"; - before: "\e079"; -} -.icon-chevron-right:before { - content: "\e080"; - before: "\e080"; -} -.icon-plus-sign:before { - content: "\e081"; - before: "\e081"; -} -.icon-minus-sign:before { - content: "\e082"; - before: "\e082"; -} -.icon-remove-sign:before { - content: "\e083"; - before: "\e083"; -} -.icon-ok-sign:before { - content: "\e084"; - before: "\e084"; -} -.icon-question-sign:before { - content: "\e085"; - before: "\e085"; -} -.icon-info-sign:before { - content: "\e086"; - before: "\e086"; -} -.icon-screenshot:before { - content: "\e087"; - before: "\e087"; -} -.icon-remove-circle:before { - content: "\e088"; - before: "\e088"; -} -.icon-ok-circle:before { - content: "\e089"; - before: "\e089"; -} -.icon-ban-circle:before { - content: "\e090"; - before: "\e090"; -} -.icon-arrow-left:before { - content: "\e091"; - before: "\e091"; -} -.icon-arrow-right:before { - content: "\e092"; - before: "\e092"; -} -.icon-arrow-up:before { - content: "\e093"; - before: "\e093"; -} -.icon-arrow-down:before { - content: "\e094"; - before: "\e094"; -} -.icon-share-alt:before { - content: "\e095"; - before: "\e095"; -} -.icon-resize-full:before { - content: "\e096"; - before: "\e096"; -} -.icon-resize-small:before { - content: "\e097"; - before: "\e097"; -} -.icon-exclamation-sign:before { - content: "\e101"; - before: "\e101"; -} -.icon-gift:before { - content: "\e102"; - before: "\e102"; -} -.icon-leaf:before { - content: "\e103"; - before: "\e103"; -} -.icon-fire:before { - content: "\e104"; - before: "\e104"; -} -.icon-eye-open:before { - content: "\e105"; - before: "\e105"; -} -.icon-eye-close:before { - content: "\e106"; - before: "\e106"; -} -.icon-warning-sign:before { - content: "\e107"; - before: "\e107"; -} -.icon-plane:before { - content: "\e108"; - before: "\e108"; -} -.icon-calendar:before { - content: "\e109"; - before: "\e109"; -} -.icon-random:before { - content: "\e110"; - before: "\e110"; -} -.icon-comment:before { - content: "\e111"; - before: "\e111"; -} -.icon-magnet:before { - content: "\e112"; - before: "\e112"; -} -.icon-chevron-up:before { - content: "\e113"; - before: "\e113"; -} -.icon-chevron-down:before { - content: "\e114"; - before: "\e114"; -} -.icon-retweet:before { - content: "\e115"; - before: "\e115"; -} -.icon-shopping-cart:before { - content: "\e116"; - before: "\e116"; -} -.icon-folder-close:before { - content: "\e117"; - before: "\e117"; -} -.icon-folder-open:before { - content: "\e118"; - before: "\e118"; -} -.icon-resize-vertical:before { - content: "\e119"; - before: "\e119"; -} -.icon-resize-horizontal:before { - content: "\e120"; - before: "\e120"; -} -.icon-hdd:before { - content: "\e121"; - before: "\e121"; -} -.icon-bullhorn:before { - content: "\e122"; - before: "\e122"; -} -.icon-bell:before { - content: "\e123"; - before: "\e123"; -} -.icon-certificate:before { - content: "\e124"; - before: "\e124"; -} -.icon-thumbs-up:before { - content: "\e125"; - before: "\e125"; -} -.icon-thumbs-down:before { - content: "\e126"; - before: "\e126"; -} -.icon-hand-right:before { - content: "\e127"; - before: "\e127"; -} -.icon-hand-left:before { - content: "\e128"; - before: "\e128"; -} -.icon-hand-up:before { - content: "\e129"; - before: "\e129"; -} -.icon-hand-down:before { - content: "\e130"; - before: "\e130"; -} -.icon-circle-arrow-right:before { - content: "\e131"; - before: "\e131"; -} -.icon-circle-arrow-left:before { - content: "\e132"; - before: "\e132"; -} -.icon-circle-arrow-up:before { - content: "\e133"; - before: "\e133"; -} -.icon-circle-arrow-down:before { - content: "\e134"; - before: "\e134"; -} -.icon-globe:before { - content: "\e135"; - before: "\e135"; -} -.icon-wrench:before { - content: "\e136"; - before: "\e136"; -} -.icon-tasks:before { - content: "\e137"; - before: "\e137"; -} -.icon-filter:before { - content: "\e138"; - before: "\e138"; -} -.icon-briefcase:before { - content: "\e139"; - before: "\e139"; -} -.icon-fullscreen:before { - content: "\e140"; - before: "\e140"; -} -.icon-dashboard:before { - content: "\e141"; - before: "\e141"; -} -.icon-paperclip:before { - content: "\e142"; - before: "\e142"; -} -.icon-heart-empty:before { - content: "\e143"; - before: "\e143"; -} -.icon-link:before { - content: "\e144"; - before: "\e144"; -} -.icon-phone:before { - content: "\e145"; - before: "\e145"; -} -.icon-pushpin:before { - content: "\e146"; - before: "\e146"; -} -.icon-usd:before { - content: "\e148"; - before: "\e148"; -} -.icon-gbp:before { - content: "\e149"; - before: "\e149"; -} -.icon-sort:before { - content: "\e150"; - before: "\e150"; -} -.icon-sort-by-alphabet:before { - content: "\e151"; - before: "\e151"; -} -.icon-sort-by-alphabet-alt:before { - content: "\e152"; - before: "\e152"; -} -.icon-sort-by-order:before { - content: "\e153"; - before: "\e153"; -} -.icon-sort-by-order-alt:before { - content: "\e154"; - before: "\e154"; -} -.icon-sort-by-attributes:before { - content: "\e155"; - before: "\e155"; -} -.icon-sort-by-attributes-alt:before { - content: "\e156"; - before: "\e156"; -} -.icon-unchecked:before { - content: "\e157"; - before: "\e157"; -} -.icon-expand:before { - content: "\e158"; - before: "\e158"; -} -.icon-collapse-down:before { - content: "\e159"; - before: "\e159"; -} -.icon-collapse-up:before { - content: "\e160"; - before: "\e160"; -} -.icon-log-in:before { - content: "\e161"; - before: "\e161"; -} -.icon-flash:before { - content: "\e162"; - before: "\e162"; -} -.icon-log-out:before { - content: "\e163"; - before: "\e163"; -} -.icon-new-window:before { - content: "\e164"; - before: "\e164"; -} -.icon-record:before { - content: "\e165"; - before: "\e165"; -} -.icon-save:before { - content: "\e166"; - before: "\e166"; -} -.icon-open:before { - content: "\e167"; - before: "\e167"; -} -.icon-saved:before { - content: "\e168"; - before: "\e168"; -} -.icon-import:before { - content: "\e169"; - before: "\e169"; -} -.icon-export:before { - content: "\e170"; - before: "\e170"; -} -.icon-send:before { - content: "\e171"; - before: "\e171"; -} -.icon-floppy-disk:before { - content: "\e172"; - before: "\e172"; -} -.icon-floppy-saved:before { - content: "\e173"; - before: "\e173"; -} -.icon-floppy-remove:before { - content: "\e174"; - before: "\e174"; -} -.icon-floppy-save:before { - content: "\e175"; - before: "\e175"; -} -.icon-floppy-open:before { - content: "\e176"; - before: "\e176"; -} -.icon-credit-card:before { - content: "\e177"; - before: "\e177"; -} -.icon-transfer:before { - content: "\e178"; - before: "\e178"; -} -.icon-cutlery:before { - content: "\e179"; - before: "\e179"; -} -.icon-header:before { - content: "\e180"; - before: "\e180"; -} -.icon-compressed:before { - content: "\e181"; - before: "\e181"; -} -.icon-earphone:before { - content: "\e182"; - before: "\e182"; -} -.icon-phone-alt:before { - content: "\e183"; - before: "\e183"; -} -.icon-tower:before { - content: "\e184"; - before: "\e184"; -} -.icon-stats:before { - content: "\e185"; - before: "\e185"; -} -.icon-sd-video:before { - content: "\e186"; - before: "\e186"; -} -.icon-hd-video:before { - content: "\e187"; - before: "\e187"; -} -.icon-subtitles:before { - content: "\e188"; - before: "\e188"; -} -.icon-sound-stereo:before { - content: "\e189"; - before: "\e189"; -} -.icon-sound-dolby:before { - content: "\e190"; - before: "\e190"; -} -.icon-sound-5-1:before { - content: "\e191"; - before: "\e191"; -} -.icon-sound-6-1:before { - content: "\e192"; - before: "\e192"; -} -.icon-sound-7-1:before { - content: "\e193"; - before: "\e193"; -} -.icon-copyright-mark:before { - content: "\e194"; - before: "\e194"; -} -.icon-registration-mark:before { - content: "\e195"; - before: "\e195"; -} -.icon-cloud-download:before { - content: "\e197"; - before: "\e197"; -} -.icon-cloud-upload:before { - content: "\e198"; - before: "\e198"; -} -.icon-tree-conifer:before { - content: "\e199"; - before: "\e199"; -} -.icon-tree-deciduous:before { - content: "\e200"; - before: "\e200"; -} -#tooltip { - position: absolute; - display: none; - border: none; - padding: 3px 8px; - border-radius: 3px; - font-size: 10px; - background-color: #222222; - color: #ffffff; - z-index: 25; -} -/*验证*/ -.n-invalid { - border-color: #a94442; - -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); - box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); -} -.n-valid { - border-color: #3c763d; - -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); - box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); -} -.n-warning { - border-color: #8a6d3b; - -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); - box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); -} -.msg-box { - display: inline-block; position: relative; *zoom: 1; margin-left: 5px; -} -.n-tip { - color: grey; -} -.n-error { - color: #a94442 -} -.n-ok { - color: #3c763d -} -.n-icon { - width: 17px; - top: 2px; - position: relative; - display: inline-block; - font-family: 'Glyphicons Halflings'; - -webkit-font-smoothing: antialiased; - font-style: normal; - font-weight: normal; - -moz-osx-font-smoothing: grayscale; -} -.n-ok .n-icon:before { - content: "\e013"; - before: "\e013"; -} -.n-error .n-icon:before { - content: "\e014"; - before: "\e014"; -} -.n-tip .n-icon:before { - content: "\e101"; - before: "\e101"; -} -.alert { - padding: 15px; - margin-top: 20px; - border: 1px solid transparent; - border-radius: 4px; -} -.alert p { - line-height: 1.6; -} -.alert h4 { - margin-top: 0; - color: inherit; -} -.alert .alert-link { - font-weight: bold; -} -.alert-dismissable { - padding-right: 35px; -} -.alert-dismissable .close { - position: relative; - top: -2px; - right: -21px; - float: right; - font-size: 21px; - font-weight: bold; - line-height: 1; - color: #000; - text-shadow: 0 1px 0 #fff; - opacity: .2; -} -button.close { - padding: 0; - cursor: pointer; - background: transparent; - border: 0; - -webkit-appearance: none; -} -.alert-success { - color: #3c763d; - background-color: #dff0d8; - border-color: #d6e9c6; -} -.alert-success .alert-link { - color: #2b542c; -} -.alert-info { - color: #31708f; - background-color: #d9edf7; - border-color: #bce8f1; -} -.alert-info .alert-link { - color: #245269; -} -.alert-warning { - color: #8a6d3b; - background-color: #faebcc; - border-color: orange; -} -.alert-warning .alert-link { - color: #66512c; -} -.alert-danger { - color: #a94442; - background-color: #f2dede; - border-color: #ebccd1; -} -.alert-danger .alert-link { - color: #843534; -} -.ke-container { - margin-left: 15px; -} -@-webkit-keyframes progress-bar-stripes { - from { - background-position: 40px 0; - } - to { - background-position: 0 0; - } -} -@keyframes progress-bar-stripes { - from { - background-position: 40px 0; - } - to { - background-position: 0 0; - } -} -.progress { - height: 20px; - margin-bottom: 20px; - overflow: hidden; - background-color: #f5f5f5; - border-radius: 4px; - -webkit-box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1); - box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1); -} -.progress-bar { - float: left; - width: 0; - height: 100%; - font-size: 12px; - line-height: 20px; - color: #ffffff; - text-align: center; - background-color: #428bca; - -webkit-box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.15); - box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.15); - -webkit-transition: width 0.6s ease; - transition: width 0.6s ease; -} -.progress-striped .progress-bar { - background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); - background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); - background-size: 40px 40px; -} -.progress.active .progress-bar { - -webkit-animation: progress-bar-stripes 2s linear infinite; - animation: progress-bar-stripes 2s linear infinite; -} -.progress-bar-success { - background-color: #5cb85c; -} -.progress-striped .progress-bar-success { - background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); - background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); -} -.progress-bar-info { - background-color: #5bc0de; -} -.progress-striped .progress-bar-info { - background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); - background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); -} -.progress-bar-warning { - background-color: #f0ad4e; -} -.progress-striped .progress-bar-warning { - background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); - background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); -} -.progress-bar-danger { - background-color: #d9534f; -} -.progress-striped .progress-bar-danger { - background-image: -webkit-linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); - background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent); -} -.pt-time-list li span { float: right } -/*==========以下部分是Validform必须的===========*/ -.Validform_checktip { - margin-left: 8px; - line-height: 20px; - height: 20px; - overflow: hidden; - color: #999; - font-size: 14px; -} -.Validform_right { - color: #71b83d; - padding-left: 20px; - background: url(../image/right.png?1) no-repeat left center; -} -.Validform_wrong { - color: red; - padding-left: 20px; - white-space: nowrap; - background: url(../image/error.png?1) no-repeat left center; -} -.Validform_loading { - padding-left: 20px; - background: url(../image/onLoad.gif) no-repeat left center; -} -.Validform_error { - background-color: #ffe7e7; -} -.footinfo{ - text-align: center; - margin-top: 20px; - border-top: 1px #ccc dashed; - line-height: 40px; - height: 40px; - color: #666; -} \ No newline at end of file diff --git a/application/admin/view/css/glyphicons-halflings-regular.eot b/application/admin/view/css/glyphicons-halflings-regular.eot deleted file mode 100644 index 423bd5d..0000000 Binary files a/application/admin/view/css/glyphicons-halflings-regular.eot and /dev/null differ diff --git a/application/admin/view/css/glyphicons-halflings-regular.svg b/application/admin/view/css/glyphicons-halflings-regular.svg deleted file mode 100644 index 4469488..0000000 --- a/application/admin/view/css/glyphicons-halflings-regular.svg +++ /dev/null @@ -1,229 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/application/admin/view/css/glyphicons-halflings-regular.ttf b/application/admin/view/css/glyphicons-halflings-regular.ttf deleted file mode 100644 index a498ef4..0000000 Binary files a/application/admin/view/css/glyphicons-halflings-regular.ttf and /dev/null differ diff --git a/application/admin/view/css/glyphicons-halflings-regular.woff b/application/admin/view/css/glyphicons-halflings-regular.woff deleted file mode 100644 index d83c539..0000000 Binary files a/application/admin/view/css/glyphicons-halflings-regular.woff and /dev/null differ diff --git a/application/admin/view/group_add.html b/application/admin/view/group_add.html deleted file mode 100644 index b5fd86d..0000000 --- a/application/admin/view/group_add.html +++ /dev/null @@ -1,65 +0,0 @@ -
-

添加用户组

-
-
-
- -
-
-
-
-
- 用户组名称: - -
-
-
-
- 用户组备注: - -
-
-
-
-
-
- - {section loop=menu} -

{$loop.name}

- {section loop=loop.sons item=submenu} -
-
- {$submenu.name}: -
- {section loop=submenu.sons item=submenulist name=k} - {if !$k.first && $submenulist.level==3}
{/if} - - {/section} -
-
-
-
- {/section} - {/section} -
-
-
-
-
- -     -
-
-
-
-
-
-
-
- - \ No newline at end of file diff --git a/application/admin/view/group_edit.html b/application/admin/view/group_edit.html deleted file mode 100644 index a85b16d..0000000 --- a/application/admin/view/group_edit.html +++ /dev/null @@ -1,73 +0,0 @@ -
-

修改用户组

-
-
-
- -
-
-
-
-
- 用户组名称: - -
-
-
-
- 用户组备注: - -
-
-
-
-
-
- - {section loop=menu} -

{$loop.name}

- {section loop=loop.sons item=submenu} -
-
- {$submenu.name}: -
- {section loop=submenu.sons item=submenulist name=k} - {if !$k.first && $submenulist.level==3}
{/if} - - {/section} -
-
-
-
- {/section} - {/section} -
-
-
-
-
- - -     -
-
-
-
-
-
-
-
- - - \ No newline at end of file diff --git a/application/admin/view/group_index.html b/application/admin/view/group_index.html deleted file mode 100644 index 80f14c3..0000000 --- a/application/admin/view/group_index.html +++ /dev/null @@ -1,51 +0,0 @@ -
-

{$menuinfo.menu.name}

-
-
-
-
- 添加 -
-
- - -
-
-
- - - - - - - - - - - - - - - - - - - - - - - -
用户组名称备注信息创建人创建时间修改人修改时间操作
{{loop.name}}{{loop.intro}}{{loop.create_username}}{{loop.create_time}}{{loop.update_username}}{{loop.update_time}} - 编辑 - 删除 -
- -
-
-
-{include file="public_angular"} \ No newline at end of file diff --git a/application/admin/view/image/bg-button-green.gif b/application/admin/view/image/bg-button-green.gif deleted file mode 100644 index c58a9bc..0000000 Binary files a/application/admin/view/image/bg-button-green.gif and /dev/null differ diff --git a/application/admin/view/image/container_bg.gif b/application/admin/view/image/container_bg.gif deleted file mode 100644 index 9647740..0000000 Binary files a/application/admin/view/image/container_bg.gif and /dev/null differ diff --git a/application/admin/view/image/error.png b/application/admin/view/image/error.png deleted file mode 100644 index 044ba76..0000000 Binary files a/application/admin/view/image/error.png and /dev/null differ diff --git a/application/admin/view/image/jia.png b/application/admin/view/image/jia.png deleted file mode 100644 index 88cb694..0000000 Binary files a/application/admin/view/image/jia.png and /dev/null differ diff --git a/application/admin/view/image/jian.png b/application/admin/view/image/jian.png deleted file mode 100644 index 91e10b9..0000000 Binary files a/application/admin/view/image/jian.png and /dev/null differ diff --git a/application/admin/view/image/left_bg.gif b/application/admin/view/image/left_bg.gif deleted file mode 100644 index f627001..0000000 Binary files a/application/admin/view/image/left_bg.gif and /dev/null differ diff --git a/application/admin/view/image/line_x.gif b/application/admin/view/image/line_x.gif deleted file mode 100644 index f9cc015..0000000 Binary files a/application/admin/view/image/line_x.gif and /dev/null differ diff --git a/application/admin/view/image/loading.gif b/application/admin/view/image/loading.gif deleted file mode 100644 index 085ccae..0000000 Binary files a/application/admin/view/image/loading.gif and /dev/null differ diff --git a/application/admin/view/image/login_bg.png b/application/admin/view/image/login_bg.png deleted file mode 100644 index b8ece1a..0000000 Binary files a/application/admin/view/image/login_bg.png and /dev/null differ diff --git a/application/admin/view/image/login_logo.png b/application/admin/view/image/login_logo.png deleted file mode 100644 index fc8babe..0000000 Binary files a/application/admin/view/image/login_logo.png and /dev/null differ diff --git a/application/admin/view/image/login_t.png b/application/admin/view/image/login_t.png deleted file mode 100644 index 78f65b2..0000000 Binary files a/application/admin/view/image/login_t.png and /dev/null differ diff --git a/application/admin/view/image/logo.png b/application/admin/view/image/logo.png deleted file mode 100644 index 3151eca..0000000 Binary files a/application/admin/view/image/logo.png and /dev/null differ diff --git a/application/admin/view/image/message_bg.gif b/application/admin/view/image/message_bg.gif deleted file mode 100644 index 874fe75..0000000 Binary files a/application/admin/view/image/message_bg.gif and /dev/null differ diff --git a/application/admin/view/image/nav_bg.png b/application/admin/view/image/nav_bg.png deleted file mode 100644 index 0798cd0..0000000 Binary files a/application/admin/view/image/nav_bg.png and /dev/null differ diff --git a/application/admin/view/image/onLoad.gif b/application/admin/view/image/onLoad.gif deleted file mode 100644 index 5e28c95..0000000 Binary files a/application/admin/view/image/onLoad.gif and /dev/null differ diff --git a/application/admin/view/image/order_bg.gif b/application/admin/view/image/order_bg.gif deleted file mode 100644 index 97d0401..0000000 Binary files a/application/admin/view/image/order_bg.gif and /dev/null differ diff --git a/application/admin/view/image/range-line.gif b/application/admin/view/image/range-line.gif deleted file mode 100644 index f71de0a..0000000 Binary files a/application/admin/view/image/range-line.gif and /dev/null differ diff --git a/application/admin/view/image/right.png b/application/admin/view/image/right.png deleted file mode 100644 index 4cd446b..0000000 Binary files a/application/admin/view/image/right.png and /dev/null differ diff --git a/application/admin/view/image/sidebar_title_bg.gif b/application/admin/view/image/sidebar_title_bg.gif deleted file mode 100644 index 70d19e9..0000000 Binary files a/application/admin/view/image/sidebar_title_bg.gif and /dev/null differ diff --git a/application/admin/view/image/skin_list_bg.gif b/application/admin/view/image/skin_list_bg.gif deleted file mode 100644 index 1e890a4..0000000 Binary files a/application/admin/view/image/skin_list_bg.gif and /dev/null differ diff --git a/application/admin/view/image/skin_list_urrent.gif b/application/admin/view/image/skin_list_urrent.gif deleted file mode 100644 index 15e8b15..0000000 Binary files a/application/admin/view/image/skin_list_urrent.gif and /dev/null differ diff --git a/application/admin/view/image/skin_tab_bg.gif b/application/admin/view/image/skin_tab_bg.gif deleted file mode 100644 index 7bf92d2..0000000 Binary files a/application/admin/view/image/skin_tab_bg.gif and /dev/null differ diff --git a/application/admin/view/image/td_title_bg.gif b/application/admin/view/image/td_title_bg.gif deleted file mode 100644 index 169a1d9..0000000 Binary files a/application/admin/view/image/td_title_bg.gif and /dev/null differ diff --git a/application/admin/view/image/validator_default.png b/application/admin/view/image/validator_default.png deleted file mode 100644 index 5a95640..0000000 Binary files a/application/admin/view/image/validator_default.png and /dev/null differ diff --git a/application/admin/view/image/white.gif b/application/admin/view/image/white.gif deleted file mode 100644 index e75322c..0000000 Binary files a/application/admin/view/image/white.gif and /dev/null differ diff --git a/application/admin/view/image/win_bg.png b/application/admin/view/image/win_bg.png deleted file mode 100644 index e771494..0000000 Binary files a/application/admin/view/image/win_bg.png and /dev/null differ diff --git a/application/admin/view/image/x_bg.png b/application/admin/view/image/x_bg.png deleted file mode 100644 index ec9d6d9..0000000 Binary files a/application/admin/view/image/x_bg.png and /dev/null differ diff --git a/application/admin/view/image/y_bg.png b/application/admin/view/image/y_bg.png deleted file mode 100644 index 0bd9479..0000000 Binary files a/application/admin/view/image/y_bg.png and /dev/null differ diff --git a/application/admin/view/index_index.html b/application/admin/view/index_index.html deleted file mode 100644 index 04f1af8..0000000 --- a/application/admin/view/index_index.html +++ /dev/null @@ -1,59 +0,0 @@ - - - - - 管理中心 - {$pt.PRONAME} - - - - - -
-
- - - -
-
-
- {section loop=menu} -
    - {section loop=loop.sons item=submenu} -
  • -

    {$submenu.name}

    -
    - {section loop=submenu.sons item=submenulist} - {$submenulist.name} - {/section} -
    -
  • - {/section} -
- {/section} -
-
- -
-
-
- - - -
- -
- - \ 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 daa52e7..0000000 --- a/application/admin/view/index_welcome.html +++ /dev/null @@ -1,205 +0,0 @@ - - - - - 管理中心 - {$pt.PRONAME} - - - - - -
-
您好 {$username},您是{$groupname},欢迎进入{$pt.PRONAME} 控制台!
-
- {loop=$tips} -
-

{$loop.content}

-
- {/loop} - -
-
-
-
-
- -
程序介绍
-
-
-

{$pt.PRONAME},定位于中小型站长,基于“同源”技术,可以对同一本小说在不同站点进行匹配,也可以进行章节在不同站点的匹配,进行换源阅读,获取更好的阅读体验。

-

{$pt.PRONAME}继承PT产品一惯依赖的智能化、傻瓜化、草根化的技术特点,30秒安装,3分钟建站,在极短的时间内即可以完成建站,同时复制程序重新安装即可以进行批量快速建站,更内置签到程序,签到后当天即可以可以无广告阅读。

-

在程序开发的过程中,非常感谢开发组同学的提供协助,还有非常多的内测人员为我们提出个宝贵的意见,再次一并感谢。

-
-
-
-
-
-
- -
最新新闻
-
-
-
-
-
-
-
-
-
-

服务器信息

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
当前程序名称:当前程序更新时间:
当前程序版本:最新程序版本:Loading......
服务器操作系通服务器解译引擎
服务器PHP版本服务器GD库版本
服务器磁盘空间M服务器附件上传
当前程序路径:服务器日期时间
MySQL数据库程序未使用使用curl远程采集:√ 支持';}else{echo '× 不支持';}?> curl
使用URL远程采集:√ 支持';}else{echo '× 不支持';}?> allow_url_fopen使用GET远程采集:√ 支持';}else{echo '× 不支持';}?> file_get_contents
-

版权信息

-
-

一旦您使用本程序,即代表您同意了下面的条款:

-
-

一、{$pt.PRONAME}PTCMS工作室开发组独立开发,严禁使用任何非法手段破解本程序,进行修改发布等行为;

-

二、不得使用本程序进行违反我国现行法律法规的任何行为,如传播病毒木马、恶意软件、淫秽色情、等;

-

三、严禁使用本程序进行刷流量、刷联盟等行为,如经发现,我们有权在不告知用户的情况下追回程序使用权;

-

四、本程序仅仅是一个建站程序,如果使用者用于非法用途或者侵犯版权,与本程序无关;

-

五、如因用户违反程序使用条例,本站有权终止对该用户的技术支持、更新升级、数据采集等服务并保留追究其相应的法律责任;

-

六、特殊说明(针对本程序):

-

  1、{$pt.PRONAME}为小说搜索程序,严禁使用本程序做任何违反我国现行法律法规的任何行为;

-

  2、{$pt.PRONAME}提供基本的采集功能,可以将其他站点的内容进行采集,用户对此功能进行使用需付完全责任;

-

  3、{$pt.PRONAME}仅为一个程序,如何使用完全为用户的个人行为,本公司对此不承担任何责任;

-
-
-
-
-
-
-
-
-

程序已经发布新版本,请点击下面链接下载更新!

-

-
-
-
- - - - -
- -
- - \ No newline at end of file diff --git a/application/admin/view/node_add.html b/application/admin/view/node_add.html deleted file mode 100644 index f3d4abf..0000000 --- a/application/admin/view/node_add.html +++ /dev/null @@ -1,70 +0,0 @@ -
-

添加{$menuinfo.menu.name}

-
-
-
-
-
- 节点名称: - -
-
-
-
- 上级节点: - -
-
-
-
- 所属模块: - -
-
-
-
- 所属控制器: - -
-
-
-
- 所属方法: - -
-
-
-
- 排序序号: - -
-
-
-
是否显示: - - -
-
-
-
-
-
- -     -
-
-
-
-
-
- - \ No newline at end of file diff --git a/application/admin/view/node_edit.html b/application/admin/view/node_edit.html deleted file mode 100644 index 0bd75bd..0000000 --- a/application/admin/view/node_edit.html +++ /dev/null @@ -1,76 +0,0 @@ -
-

修改{$menuinfo.menu.name}

-
-
-
-
-
- 节点名称: - -
-
-
-
- 上级节点: - -
-
-
-
- 所属模块: - -
-
-
-
- 所属控制器: - -
-
-
-
- 所属方法: - -
-
-
-
- 排序序号: - -
-
-
-
是否显示: - - -
-
-
-
-
-
- - -     -
-
-
-
-
-
- - - \ No newline at end of file diff --git a/application/admin/view/node_index.html b/application/admin/view/node_index.html deleted file mode 100644 index 84ba4df..0000000 --- a/application/admin/view/node_index.html +++ /dev/null @@ -1,59 +0,0 @@ -
-

{$menuinfo.menu.name}管理

-
-
-
-
- 添加 - -
-
- - -
-
-
- - - - - - - - - - - - - - - - - - - - - - - -
节点名称模块控制器方法排序状态操作
{{loop.showname}}{{loop.module}}{{loop.controller}}{{loop.action}} - - - 隐藏 - 显示 - - 子类 - 编辑 - 删除 -
- -
-
-
-{include file="public_angular"} \ No newline at end of file diff --git a/application/admin/view/public_angular.html b/application/admin/view/public_angular.html deleted file mode 100644 index 7abf049..0000000 --- a/application/admin/view/public_angular.html +++ /dev/null @@ -1,34 +0,0 @@ - - - \ No newline at end of file diff --git a/application/admin/view/public_layout.html b/application/admin/view/public_layout.html deleted file mode 100644 index acf2508..0000000 --- a/application/admin/view/public_layout.html +++ /dev/null @@ -1,46 +0,0 @@ - - - - - 管理中心 - {$pt.PRONAME} - - - - - - - - - - - - -
-
- 当前位置: - {$pt.PRONAME} - > {$menuinfo.menu.name} - {if isset($menuinfo.submenu.name)} - > {$menuinfo.submenu.name} - {/if} -
- __CONTENT__ -
-
-
__RUNINFO__
-
- -
- - - diff --git a/application/admin/view/public_login.html b/application/admin/view/public_login.html deleted file mode 100644 index 4d71890..0000000 --- a/application/admin/view/public_login.html +++ /dev/null @@ -1,70 +0,0 @@ - - - - - 管理登录 - {$pt.PRONAME} - - - - - - - -
-
- - -
-
Copyright © 2009-2014 PTcms Studio 。 All Rights Reserved 。 Design By Pakey
-
- - - -
- -
- - diff --git a/application/admin/view/script/admin.js b/application/admin/view/script/admin.js deleted file mode 100644 index 1287ccf..0000000 --- a/application/admin/view/script/admin.js +++ /dev/null @@ -1,255 +0,0 @@ -$.admin = $.admin || {}; -$.extend($.admin, { - 'init': function () { - $.admin.iframe.init(); - $.admin.sidebarmenu.init() - }, 'iframe': { - 'init': function () { - $('#pt-mainframe').bind('load', $.admin.iframe.reheight()); - $(window).bind('resize', $.admin.iframe.reheight()) - }, 'reheight': function () { - var height = $(document).height(); - if (height > 94) { - setTimeout(function () { - $('#pt-mainframe').height(height - 110); - $('.pt-sidebar').height(height - 110); - $('.pt-main').height(height - 110) - }, 0) - } - } - }, 'sidebarmenu': { - 'init': function () { - var n = $.admin.sidebarmenu.getposition(); - $.admin.sidebarmenu.select(n[0], n[1]); - $.admin.sidebarmenu.titleclick(); - $.admin.sidebarmenu.menuclick(); - $.admin.sidebarmenu.linkclick() - }, 'getposition': function () { - var n = [], hash = window.location.hash; - if (hash.length > 1) { - n = hash.substr(1).split(',', 2); - return [parseInt(n[0]), parseInt(n[1])] - } else { - return [0, 0] - } - }, 'select': function (n, m) { - $('.pt-sidebar li').removeClass('open'); - $('.pt-sidebar li a').removeClass('current'); - $('.pt-sidebar .pt-sidebar-menu-info').hide(); - $('.pt-sidebar .pt-sidebar-menu').hide().eq(n).show().find('li a').eq(m).addClass('current').parents('li').addClass('open').find('.pt-sidebar-menu-info').show(); - window.location.hash = '#' + n + ',' + m; - $('#pt-mainframe').attr('src', $('.pt-sidebar-menu').eq(n).find('li a').eq(m).attr('href')) - }, 'titleclick': function () { - $('#pt-header .menu a').bind('click', function () { - m = $('#pt-header .menu a').index(this); - $.admin.sidebarmenu.select(m, 0); - $(this).addClass('current').siblings().removeClass('current'); - return false - }) - }, 'menuclick': function () { - $('.pt-sidebar h3').bind('click', function () { - $(this).siblings('div').show(200).parent().addClass('open').siblings().removeClass('open').find('.pt-sidebar-menu-info').hide(200) - }) - }, 'linkclick': function () { - $('.pt-sidebar a').bind('click', function () { - n = $.admin.sidebarmenu.getposition(); - m = $(this).parents('.pt-sidebar-menu').find('a').index(this); - $.admin.sidebarmenu.select(n[0], m); - return false - }) - } - }, 'tab': { - 'init': function () { - $('.pt-tab').each(function () { - var tab = this, id = $(tab).find('.pt-tab-nav a').index($(tab).find('.pt-tab-nav a.current')); - $(tab).find('.pt-tab-item').eq(id).show().siblings('.pt-tab-item').hide(); - $(tab).find('.pt-tab-nav a').bind('click', function () { - var aid = $(tab).find('.pt-tab-nav a').index($(this)); - $(this).addClass('current').siblings().removeClass('current'); - $(tab).find('.pt-tab-item').eq(aid).show().siblings('.pt-tab-item').hide(); - return false - }) - }) - } - }, 'tool': { - 'checkAll': function () { - $('.checkall').each(function () { - $(this).bind('change', function () { - var name = $(this).attr('data'); - if ($(this).is(':checked')) { - $('input[name="' + name + '"]').attr('checked', true) - } else { - $('input[name="' + name + '"]').attr('checked', false) - } - }) - }) - }, 'selectJump': function () { - $('select').each(function () { - var field = $(this).attr('data'); - if (field != undefined) { - $(this).change(function () { - var arr = SELF.split('/'), param = [], url = '/' + arr[1] + '/' + arr[2] + '/' + arr[3]; - for (i = 4; i < arr.length; i += 2) { - if (arr[i] != '') param[arr[i]] = arr[i + 1] - } - param[field] = $(this).find('option:selected').val(); - for (var key in param) { - if (param[key] != '') { - url += '/' + key + '/' + param[key] - } - } - window.location.href = url - }) - } - }) - }, 'tooltips': function () { - }, 'successtip': function (html, obj, url, t) { - t = t || 1; - layer.tips(html, obj, {style: ['background-color:#3c763d;color:#fff;font-size:14px;line-height:30px;font-weight:bold', '#3c763d'], maxWidth: 185, guide: 1, time: t, closeBtn: false}, function () { - if (url != undefined) { - window.location.href = url - } - }) - }, 'errortip': function (html, obj, t) { - t = t || 3; - layer.tips(html, obj, {style: ['background-color:darkred;color:#fff;font-size:14px;line-height:30px;font-weight:bold', 'darkred'], maxWidth: 185, guide: 1, time: t, closeBtn: false}) - }, 'tipbox': function (id, boxtitle, callback) { - $.layer({ - type: 1, title: boxtitle, closeBtn: [0, true], border: [5, 0.3, '#666', true], offset: ['50px', ''], shadeClose: true, area: ['500px', 'auto'], page: {dom: id}, success: function () { - if ($.isFunction(callback)) callback(); - layer.shift('top', 500) - } - }) - } - } -}); -$.fn.extend({ - 'alert': function (type, text, url) { - var h = ''; - $('body,html').animate({scrollTop: 0}, 500); - $('.alert').remove(); - h += '
'; - h += ' '; - h += ' ' + text; - h += '
'; - $(this).before(h); - $('.alert').fadeIn(300).delay(2000).fadeOut(500, function () { - if (url != undefined) { - window.location.href = url - } - }); - if (url != undefined) { - setTimeout(function () { - window.location.href = url - }, 5000) - } - } -}); -function del(id) { - layer.confirm('确认删除么', function () { - $.ajax({ - 'url': URL + '/multi/', 'type': 'POST', 'data': {'dooperate': 'del', 'id[]': id}, 'dataType': 'json', success: function (data) { - if (data.status) { - layer.msg('操作成功', 2, 1, function () { - window.location.href = SELF - }) - } else { - layer.msg(data.info, 2, 3) - } - } - }) - layer.closeAll() - }, '删除提示', function () { - layer.closeAll() - }) -} -$(function () { - if ($('.pt-tab').length > 0) { - $.admin.tab.init() - } - $('select').width($('select').width() + 8) - $.admin.tool.checkAll(); - $.admin.tool.selectJump(); - $('.alert .close').live('click', function () { - $(this).parent().fadeOut(500) - }); - $('input.date').live('click', function () { - WdatePicker({skin: 'ext', dateFmt: 'yyyy-MM-dd', el: this}) - }); - $('input.datetime').live('click', function () { - WdatePicker({skin: 'ext', dateFmt: 'yyyy-MM-dd HH:mm:ss', el: this}) - }); - $('.additem').click(function () { - $.layer({ - type: 1, title: '添加' + TYPENAME, closeBtn: [0, true], border: [5, 0.3, '#666', true], offset: ['50px', ''], shadeClose: true, area: ['500px', 'auto'], page: {dom: '#addbox'}, - success: function () { - if ($.isFunction(addfunc)) addfunc(); - layer.shift('top', 500) - } - }) - }); - $('.edititem').click(function () { - $.get(URL + '/getinfo/id/' + $(this).data('id'), function (d) { - if (d.status) { - $.layer({ - type: 1, title: '修改' + TYPENAME, closeBtn: [0, true], border: [5, 0.3, '#666', true], offset: ['50px', ''], shadeClose: true, area: ['500px', 'auto'], page: {dom: '#editbox'}, success: function () { - if ($.isFunction(editfunc)) editfunc(d); - layer.shift('top', 500) - } - }) - } else { - $.layer.msg(d.info, 2, 3) - } - }, 'json') - }); - if ($('.vform').length > 0) { - $('.vform').Validform({ - tiptype: 3 - }); - } -}); -function checkselt(name, form) { - si = 0; - var ss = $("input[name='" + name + "']"); - for (var i = 0; i < ss.length; i++) { - if (ss[i].checked) { - si++ - } - } - if (si == 0) { - layer.alert('请选择您要操作的记录!', 8); - return false - } - if ($("select[name='dooperate']").val() == 0) { - layer.alert('请选择您要进行的操作!', 8); - return false - } - layer.confirm('请注意提交后操作就不能再恢复,您确定提交吗?', function () { - $(form).submit() - }); - return false -} -/*before after的支持*/ -var patterns = {text: /^['"]?(.+?)["']?$/, url: /^url\(["']?(.+?)['"]?\)$/}; -function clean(content) { - if (content && content.length) { - var text = content.match(patterns.text)[1], url = text.match(patterns.url); - return url ? '' : text - } -} -function inject(prop, elem, content) { - if (prop != 'after') prop = 'before'; - if (content = clean(elem.currentStyle[prop])) { - $(elem)[prop == 'before' ? 'prepend' : 'append']($(document.createElement('span')).addClass(prop).html(content)) - } -} -$.pseudo = function (elem) { - inject('before', elem); - inject('after', elem); - elem.runtimeStyle.behavior = null -}; -if (document.createStyleSheet) { - var o = document.createStyleSheet(null, 0); - o.addRule('.dummy', 'display:static;'); - o.cssText = 'html, head, head *, body, *.before, *.after, *.before *, *.after *{behavior:none}*{behavior:expression($.pseudo(this))}' -} \ No newline at end of file diff --git a/application/admin/view/script/tongji.js b/application/admin/view/script/tongji.js deleted file mode 100644 index e69de29..0000000 diff --git a/application/admin/view/theme_config.html b/application/admin/view/theme_config.html deleted file mode 100644 index f10a0f3..0000000 --- a/application/admin/view/theme_config.html +++ /dev/null @@ -1,53 +0,0 @@ -
-

模版参数设置

-
-

- 设置的参数您可以在程序中通过 C('tplconfig.参数KEY') 调用,在模版中通过 {$pt.config.tplconfig.参数KEY} 调用;
-

-
-
-
-
-

- 当前共有 {$config|count} 个参数 -

-
-
-
- - - - - - - - - - - {loop="config"} - - - - - - - {/loop} - - - - - - - -
操作参数名称参数key参数值
删除
新参数
- -
-
-
-
-
\ No newline at end of file diff --git a/application/admin/view/theme_index.html b/application/admin/view/theme_index.html deleted file mode 100644 index 1db286b..0000000 --- a/application/admin/view/theme_index.html +++ /dev/null @@ -1,47 +0,0 @@ -
-

模版列表

-
-
-
-

- 当前共有 {$list|count} 个模版 -

-
-
- - - - - - - - - - - - {loop="list"} - - - - - - - - {/loop} - -
模版预览模版信息版本状态操作
- {$loop.name}
- 作者:{$loop.author}
- 邮箱:{$loop.email}
- 网址:{$loop.url}
- 版本:{$loop.version}
- 简介:{$loop.description}
-
{$loop.version}{if $defaulttpl==$key} 默认{/if} - 预览 - 使用 - 参数 -
-
-
-
-
\ 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 5542b3e..0000000 --- a/application/admin/view/user_add.html +++ /dev/null @@ -1,53 +0,0 @@ -
-

添加用户

-
-
-
-
-
- 用户帐号: - -
-
-
-
- 用户组: - -
-
-
-
- 用户备注: - -
-
-
-
帐号状态: - - -
-
-
-
-
-
- -     -
-
-
-
-
-
- - \ No newline at end of file diff --git a/application/admin/view/user_edit.html b/application/admin/view/user_edit.html deleted file mode 100644 index 53f4fc3..0000000 --- a/application/admin/view/user_edit.html +++ /dev/null @@ -1,58 +0,0 @@ -
-

修改用户

-
-
-
-
-
- 用户帐号: - -
-
-
-
- 用户组: - -
-
-
-
- 用户备注: - -
-
-
-
帐号状态: - - -
-
-
-
-
-
- -     -
-
-
-
-
-
- - - \ 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 b3f920e..0000000 --- a/application/admin/view/user_index.html +++ /dev/null @@ -1,60 +0,0 @@ -
-

{$menuinfo.menu.name}

-
-
-
-
- 添加 -
-
- - -
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
用户名用户组创建人创建时间修改人修改时间登录数登录时间状态操作
{{loop.username}}{{loop.groupname}}{{loop.create_username}}{{loop.create_time}}{{loop.update_username}}{{loop.update_time}}{{loop.login_num}}{{loop.login_time}} - 禁用 - 正常 - - 编辑 - 删除 -
- -
-
-
-{include file="public_angular"} \ No newline at end of file diff --git a/application/common/block/friendlink.php b/application/common/block/friendlink.php deleted file mode 100644 index 667b685..0000000 --- a/application/common/block/friendlink.php +++ /dev/null @@ -1,9 +0,0 @@ -where(array('status'=>1))->field('name,url,description,logo,isbold,color')->order('ordernum asc')->limit($num)->getlist(); - return $list; - - } -} \ No newline at end of file diff --git a/application/common/block/pagelist.php b/application/common/block/pagelist.php deleted file mode 100644 index ad9d4ff..0000000 --- a/application/common/block/pagelist.php +++ /dev/null @@ -1,53 +0,0 @@ - 1, 'status' => 1); - $list['prev'] = array('num' => 1, 'status' => 1); - } else { - $list['first'] = array('num' => 1, 'status' => 0); - $list['prev'] = array('num' => $param['page'] - 1, 'status' => 0); - } - if ($param['page'] == $param['maxpage']) { - $list['last'] = array('num' => $param['maxpage'], 'status' => 1); - $list['next'] = array('num' => $param['maxpage'], 'status' => 1); - } else { - $list['last'] = array('num' => $param['maxpage'], 'status' => 0); - $list['next'] = array('num' => $param['page'] + 1, 'status' => 0); - } - $start = $param['page'] - $param['section']; - if ($start >= $param['minpage']) { - $end = $param['page'] + $param['section']; - if ($end > $param['maxpage']) { - $end = $param['maxpage']; - $start = $param['maxpage'] - 2 * $param['section']; - $start = ($start < $param['minpage']) ? $param['minpage'] : $start; - } - } else { - $start = $param['minpage']; - $end = $param['minpage'] + 2 * $param['section']; - $end = ($end > $param['maxpage']) ? $param['maxpage'] : $end; - } - for ($i = $start; $i <= $end; $i++) { - $list['num'][] = array( - 'num' => $i, - 'status' => ($i == $param['page']) ? 1 : 0, - ); - } - $list['totalnum'] = $param['totalnum']; - $list['page'] = $param['page']; - $list['pagenum'] = $param['pagenum']; - $list['pagesize'] = $param['pagesize']; - return $list; - } -} \ No newline at end of file diff --git a/application/common/config.php b/application/common/config.php deleted file mode 100644 index 691d8c8..0000000 --- a/application/common/config.php +++ /dev/null @@ -1,31 +0,0 @@ -'default', - 'runinfo'=>'Processed in {time}(s), Memory: {mem}MB, Sqls: {sql}, cacheread: {cacheread}, cachewrite: {cachewrite}, net:{net}.', - 'DB_MYSQL' => array( - 'DRIVER' => 'Pdo', - 'PREFIX' => 'ptcms_', - 'CHARSET' => 'utf8', - 'MASTER' => array( - array( - 'HOST' => '127.0.0.1', - 'PORT' => '3306', - 'NAME' => 'ptcms', - 'USER' => 'root', - 'PWD' => 'root' - ) - ), - 'SLAVE' => array( - ), - ), - - - 'URL_RULES' => array( - 'index.article.list' => '/{dir}[/{key}][/{page}]', - ), - - 'URL_ROUTER' => array( - '^(news|course)$' => 'index/article/list?module', - ), - -); \ No newline at end of file diff --git a/application/common/controller/admin.php b/application/common/controller/admin.php deleted file mode 100644 index fa42421..0000000 --- a/application/common/controller/admin.php +++ /dev/null @@ -1,56 +0,0 @@ -skipnode=array('admin.index.index'); - } - - public function init() { - session_start(); - // 登录状态判断 - if (empty($_SESSION['admin'])) { - //未登录 - $this->redirect(U('admin.public.login')); - } else { - $this->username = $_SESSION['admin']['username']; - $this->groupname=$_SESSION['admin']['groupname']; - session_write_close(); - } - // 设置了表名则自动初始化model - if ($this->tableName){ - $this->model=M($this->tableName); - } - // 当前页面信息 - $this->menuinfo=M('admin_node')->getMenuInfo(); - //判断是否有权限访问当前页面 创始人 访问权限 免验节点 ajax - if ($_SESSION['admin']['userid']!='1' - && !in_array($this->menuinfo['nodeid'],explode(',',dc::get('admin_group',$_SESSION['admin']['groupid'],'node'))) - && !in_array(MODULE_NAME.'.'.CONTROLLER_NAME.'.'.ACTION_NAME,$this->skipnode) - && ACTION_NAME!='ajax'){ - $this->error('您没有权限访问这个页面!',0,0); - } - // 其他初始化 - } - - // 防止进入空控制器 - public function addAction() {} - public function editAction() {} - public function delAction() { - $id=I('request.id','int',0); - $this->model->del(array('id'=>$id)); - $this->success('删除成功'); - } - public function multiAction() {} - public function ajaxAction() {} -} \ No newline at end of file diff --git a/application/common/controller/common.php b/application/common/controller/common.php deleted file mode 100644 index dfaf591..0000000 --- a/application/common/controller/common.php +++ /dev/null @@ -1,8 +0,0 @@ -/', '', $text); - //完全过滤动态代码 - $text = preg_replace('/<\?|\?' . '>/', '', $text); - //完全过滤js - $text = preg_replace('//', '', $text); - - $text = str_replace('[', '[', $text); - $text = str_replace(']', ']', $text); - $text = str_replace('|', '|', $text); - //br - $text = preg_replace('//i', '[br]', $text); - $text = preg_replace('//i', '[br]', $text); - $text = preg_replace('/(\[br\]\s*){10,}/i', '[br]', $text); - //过滤危险的属性,如:过滤on事件lang js - while (preg_match('/(<[^><]+)( lang|on|action|background|codebase|dynsrc|lowsrc)[^><]+/i', $text, $mat)) { - $text = str_replace($mat[0], $mat[1], $text); - } - while (preg_match('/(<[^><]+)(window\.|javascript:|js:|about:|file:|document\.|vbs:|cookie)([^><]*)/i', $text, $mat)) { - $text = str_replace($mat[0], $mat[1] . $mat[3], $text); - } - if (empty($tags)) { - $tags = 'br'; - } - //允许的HTML标签 - $text = preg_replace('/<(' . $tags . ')( [^><\[\]]*)>/i', '[\1\2]', $text); - $text = preg_replace('/<\/(' . $tags . ')>/Ui', '[/\1]', $text); - //过滤多余html - $text = preg_replace('/<\/?(html|head|meta|link|base|basefont|body|bgsound|title|style|script|form|iframe|frame|frameset|applet|id|ilayer|layer|name|script|style|xml|table|td|th|tr|i|u|strong|img|p|br|div|strong|em|ul|ol|li|dl|dd|dt|a)[^><]*>/i', '', $text); - //过滤合法的html标签 - while (preg_match('/<([a-z]+)[^><\[\]]*>[^><]*<\/\1>/i', $text, $mat)) { - $text = str_replace($mat[0], str_replace('>', ']', str_replace('<', '[', $mat[0])), $text); - } - //转换引号 - while (preg_match('/(\[[^\[\]]*=\s*)(\"|\')([^\2=\[\]]+)\2([^\[\]]*\])/i', $text, $mat)) { - $text = str_replace($mat[0], $mat[1] . '|' . $mat[3] . '|' . $mat[4], $text); - } - //过滤错误的单个引号 - while (preg_match('/\[[^\[\]]*(\"|\')[^\[\]]*\]/i', $text, $mat)) { - $text = str_replace($mat[0], str_replace($mat[1], '', $mat[0]), $text); - } - //转换其它所有不合法的 < > - $text = str_replace('<', '<', $text); - $text = str_replace('>', '>', $text); - $text = str_replace('"', '"', $text); - //反转换 - $text = str_replace('[', '<', $text); - $text = str_replace(']', '>', $text); - $text = str_replace('|', '"', $text); - //过滤多余空格 - $text = str_replace(' ', ' ', $text); - return $text; -} - -function formattext($content) { - // 去除
- $content = str_ireplace(array('
', '
', '
', ' '), "\n", $content); - $content = str_replace("\r", "\n", $content); - do { - $content = str_replace("\n\n", "\n", $content); - } while (strpos($content, "\n\n") !== false); - // 去除空格 - $content = trim(str_replace(array(' ', ' '), ' ', $content)); - // 去除其他html - $content = strip_tags(safetext($content)); - // 加换行及空格 - $content = str_replace("\n", "\r\n", trim($content)); - return $content; -} \ No newline at end of file diff --git a/application/common/library/tree.php b/application/common/library/tree.php deleted file mode 100644 index 87af3f8..0000000 --- a/application/common/library/tree.php +++ /dev/null @@ -1,101 +0,0 @@ -model = $model; - $this->pidkey = $pidkey; - } - - public function getList($pid = 0, $field = '*', $where = array(), $order = 'ordernum asc', $level = 1) { - $where[$this->pidkey] = $pid; - $data = $this->model->field($field)->where($where)->order($order)->select(); - if ($data === null) return array(); - $list = array(); - foreach ($data as $v) { - $v['level'] = $level; - $list[] = $v; - $sons = $this->getlist($v[$this->model->getPk()], $field, $where, $order, $level + 1); - $list = array_merge($list, $sons); - } - return $list; - } - - public function getIconList($list, $startlevel = 1) { - if ($startlevel > 1) { - $preicon[] = array_fill(0, $startlevel - 1, $this->icon['3']); - } else { - $preicon = array(); - } - - foreach ($list as $k => &$v) { - $v['showname'] = $v['name']; - if ($v['level'] >= $startlevel) { - $icon = $this->icon['2']; - $preicon[$v['level'] - $startlevel] = $this->icon['3']; - foreach (array_slice($list, $k + 1) as $n) { - if ($n['level'] < $v['level']) { - //后面没有同级的 - $preicon[$v['level'] - $startlevel] = $this->icon['3']; - break; - } elseif ($n['level'] == $v['level']) { - //后面没有同级的 - $icon = $this->icon['1']; - $preicon[$v['level'] - $startlevel] = $this->icon['0']; - break; - } - } - $v['showname'] = implode('', array_slice($preicon, 0, $v['level'] - $startlevel)) . $icon . $v['name']; - } - } - return $list; - } - - public function getSonList($pid = 0, $field = '*', $where = array(), $limitlevel = 3, $order = 'ordernum asc', $level = 1) { - $where[$this->pidkey] = $pid; - $data = $this->model->field($field)->where($where)->order($order)->select(); - if ($data === null) return array(); - $list = array(); - foreach ($data as $v) { - $v['level'] = $level; - if (isset($v['module'])) { - $v['url'] = ($v['module'] == '') ? '' : U($v['module'] . '.' . $v['controller'] . '.' . $v['action']); - unset($v['module'], $v['controller'], $v['action']); - } - if ($level < $limitlevel) { - $v['sons'] = $this->getSonList($v[$this->model->getPk()], $field, $where, $limitlevel, $order, $level + 1); - } - $list[] = $v; - } - return $list; - } - - public function getAuthList($pid = 0, $field = '*', $where = array(), $order = 'ordernum asc', $level = 1) { - $where[$this->pidkey] = $pid; - $data = $this->model->field($field)->where($where)->order($order)->select(); - if ($data === null) return array(); - $list = array(); - foreach ($data as $v) { - $v['level'] = $level; - if ($level < 4) { - $son=$this->getAuthList($v[$this->model->getPk()], $field, $where, $order, $level + 1); - if ($level == 3) { - $list = array_merge($list, array($v), $son); - } else { - $v['sons'] = $son; - $list[] = $v; - } - }else{ - $list[] = $v; - } - } - return $list; - } -} \ No newline at end of file diff --git a/application/common/model/ad.php b/application/common/model/ad.php deleted file mode 100644 index 53fe149..0000000 --- a/application/common/model/ad.php +++ /dev/null @@ -1,46 +0,0 @@ -insert($param); - } - - /** - * 修改 - * @param $param - * @return mixed - */ - public function edit($param) { - //更新缓存 - return $this->update($param); - } - - /** - * 删除数据 - * @param $where - */ - public function del($where) { - $this->where($where)->delete(); - } - - //获取列表 - public function getlist() { - $list=(array)$this->select(); - foreach($list as &$v){ - if (isset($v['create_user_id'])){ - //后台 - $v['create_username']=dc::get('passport',$v['create_user_id'],'name'); - $v['update_username']=dc::get('passport',$v['update_user_id'],'name'); - $v['url_edit']=U('ad.manage.edit',array('id'=>$v['id'])); - $v['url_show']=U('ad.manage.show',array('id'=>$v['id'])); - $v['create_time']=$v['create_time']?date('Y-m-d H:i',$v['create_time']):''; - $v['update_time']=$v['update_time']?date('Y-m-d H:i',$v['update_time']):''; - } - } - return $list; - } -} \ No newline at end of file diff --git a/application/common/model/admin_group.php b/application/common/model/admin_group.php deleted file mode 100644 index cd381cb..0000000 --- a/application/common/model/admin_group.php +++ /dev/null @@ -1,43 +0,0 @@ -insert($param); - } - - /** - * 修改 - * @param $param - * @return mixed - */ - public function edit($param) { - //更新缓存 - dc::refresh('admin_group',$param['id']); - return $this->update($param); - } - - /** - * 删除数据 - * @param $where - */ - public function del($where) { - $this->where($where)->delete(); - } - - // 获取列表 - public function getlist() { - $list=(array)$this->select(); - foreach($list as &$v){ - $v['create_username']=dc::get('passport',$v['create_user_id'],'name'); - $v['update_username']=dc::get('passport',$v['update_user_id'],'name'); - $v['url_edit']=U('admin.group.edit',array('id'=>$v['id'])); - $v['create_time']=$v['create_time']?date('Y-m-d H:i',$v['create_time']):''; - $v['update_time']=$v['update_time']?date('Y-m-d H:i',$v['update_time']):''; - } - return $list; - } -} \ No newline at end of file diff --git a/application/common/model/admin_node.php b/application/common/model/admin_node.php deleted file mode 100644 index 61f442e..0000000 --- a/application/common/model/admin_node.php +++ /dev/null @@ -1,69 +0,0 @@ -insert($param); - } - - /** - * 修改 - * @param $param - * @return mixed - */ - public function edit($param) { - return $this->update($param); - } - - /** - * 删除数据 - * @param $where - */ - public function del($where) { - $this->where($where)->delete(); - } - - /** - * 获取当前节点及父节点的信息 - * @return mixed - */ - public function getMenuInfo() { - $info=$this->field('id,name,pid')->where(array('module'=>MODULE_NAME,'controller'=>CONTROLLER_NAME,'action'=>ACTION_NAME))->find(); - $parentinfo=$this->field('name,pid,module,controller,action')->where(array('id'=>$info['pid']))->find(); - if (empty($parentinfo['module'])){ - $res['menu']['name']=$info['name']; - $res['menu']['url']=U(MODULE_NAME.'.'.CONTROLLER_NAME.'.'.ACTION_NAME); - $res['submenu']['name']=''; - $res['submenu']['url']=''; - }else{ - $res['menu']['name']=$parentinfo['name']; - $res['menu']['url']=U($parentinfo['module'].'.'.$parentinfo['controller'].'.'.$parentinfo['action']); - $res['submenu']['name']=$info['name']; - $res['submenu']['url']=U(MODULE_NAME.'.'.CONTROLLER_NAME.'.'.ACTION_NAME); - } - $res['nodeid']=$info['id']; - return $res; - } - - public function getParentList($id) { - $info=$this->where(array('id'=>$id))->field('id,pid')->find(); - if ($info['pid']==0) return array(); - $res[]=$info['pid']; - $res=array_merge($res,$this->getParentList($info['pid'])); - return $res; - } - - public function toNodeAuth($arr) { - foreach($arr as $v){ - $plist=$this->getParentList($v); - foreach($plist as $id){ - if (!in_array($id,$arr)) $arr[]=$id; - } - } - return $arr; - } -} \ No newline at end of file diff --git a/application/common/model/admin_user.php b/application/common/model/admin_user.php deleted file mode 100644 index a8ff966..0000000 --- a/application/common/model/admin_user.php +++ /dev/null @@ -1,71 +0,0 @@ -where(array('passport_id'=>$userid))->getfield('status'); - } - - // 设置用户登录状态 - public function setLoginStatus($userid) { - //设置登录信息 - $_SESSION['admin']['userid']=$userid; - $_SESSION['admin']['username']=M('passport')->where(array('id'=>$userid))->getField('name'); - $_SESSION['admin']['groupid']=$this->where(array('passport_id'=>$userid))->getField('group_id'); - $_SESSION['admin']['groupname']=dc::get('admin_group',$_SESSION['admin']['groupid'],'name'); - // 更新通行证登录时间 - $data['login_ip']=get_ip(); - $data['login_time']=NOW_TIME; - M('passport')->where(array('id'=>$userid))->update($data); - // 更新后台表信息 - $data['login_num']=array('exp','`login_num`+1'); - $this->where(array('passport_id'=>$userid))->update($data); - } - - // 删除用户登录信息 - public function delLoginStatus() { - $_SESSION['admin']=null; - } - - // 获取列表 - public function getlist() { - $list=$this->select(); - foreach($list as &$v){ - $v['username']=dc::get('passport',$v['passport_id'],'name'); - $v['groupname']=dc::get('admin_group',$v['group_id'],'name'); - $v['create_username']=dc::get('passport',$v['create_user_id'],'name'); - $v['update_username']=dc::get('passport',$v['update_user_id'],'name'); - $v['url_edit']=U('admin.user.edit',array('id'=>$v['id'])); - $v['create_time']=$v['create_time']?date('Y-m-d H:i',$v['create_time']):''; - $v['update_time']=$v['update_time']?date('Y-m-d H:i',$v['update_time']):''; - $v['login_time']=$v['login_time']?date('Y-m-d H:i',$v['login_time']):''; - } - return $list; - } - - /** - * 插入数据 - * @param $param - * @return mixed - */ - public function add($param) { - return $this->insert($param); - } - - /** - * 修改 - * @param $param - * @return mixed - */ - public function edit($param) { - return $this->update($param); - } - - /** - * 删除数据 - * @param $where - */ - public function del($where) { - $this->where($where)->delete(); - } -} \ No newline at end of file diff --git a/application/common/model/friendlink.php b/application/common/model/friendlink.php deleted file mode 100644 index f718f19..0000000 --- a/application/common/model/friendlink.php +++ /dev/null @@ -1,58 +0,0 @@ -insert($param); - } - - /** - * 修改 - * @param $param - * @return mixed - */ - public function edit($param) { - //更新缓存 - return $this->update($param); - } - - /** - * 删除数据 - * @param $where - */ - public function del($where) { - $this->where($where)->delete(); - } - - //获取列表 - public function getlist() { - $list=(array)$this->select(); - foreach($list as &$v){ - $v['showname']=$this->getshowname($v); - if (isset($v['create_user_id'])){ - //后台 - $v['create_username']=dc::get('passport',$v['create_user_id'],'name'); - $v['update_username']=dc::get('passport',$v['update_user_id'],'name'); - $v['url_edit']=U('friendlink.manage.edit',array('id'=>$v['id'])); - $v['create_time']=$v['create_time']?date('Y-m-d H:i',$v['create_time']):''; - $v['update_time']=$v['update_time']?date('Y-m-d H:i',$v['update_time']):''; - } - } - return $list; - } - - //获取展示的链接名 - public function getshowname($v) { - $v['showname']=$v['name']; - if ($v['isbold']){ - $v['showname']=''.$v['showname'].''; - } - if ($v['color']!==''){ - $v['showname']="{$v['showname']}"; - } - return $v['showname']; - } -} \ No newline at end of file diff --git a/application/common/model/passport.php b/application/common/model/passport.php deleted file mode 100644 index f69ffc4..0000000 --- a/application/common/model/passport.php +++ /dev/null @@ -1,12 +0,0 @@ -where(array('name'=>$username))->field('id,password,salt')->find()){ - if ($info['password']==md5(md5($password).$info['salt'])){ - return $info['id']; - } - } - return false; - } -} \ No newline at end of file diff --git a/application/common/ptf.coding.io.config.php b/application/common/ptf.coding.io.config.php deleted file mode 100644 index a0e1dff..0000000 --- a/application/common/ptf.coding.io.config.php +++ /dev/null @@ -1,19 +0,0 @@ - array( - 'DRIVER' => 'Pdo', - 'PREFIX' => 'ptcms_', - 'CHARSET' => 'utf8', - 'MASTER' => array( - array( - 'HOST' => '10.9.1.188', - 'PORT' => '3306', - 'NAME' => 'cf_92aa4934_9075_4c43_8bc6_8c4a304f58b9', - 'USER' => 'C5M1OJxpIKbQVNlY', - 'PWD' => 'k31GzgvccXk5GITk' - ) - ), - 'SLAVE' => array( - ), - ), -); \ No newline at end of file diff --git a/application/friendlink/controller/manage.php b/application/friendlink/controller/manage.php deleted file mode 100644 index faded5e..0000000 --- a/application/friendlink/controller/manage.php +++ /dev/null @@ -1,111 +0,0 @@ -tableName='friendlink'; - parent::init(); - } - - public function indexAction() { - $this->list=$this->model->getlist(); - $this->display(); - } - - public function addAction() { - if (IS_POST){ - $param['name']=I('name','str',''); - if (!$param['name']){ - $this->error('请输入链接名称'); - } - $param['url']=I('url','url',''); - if (!$param['url']){ - $this->error('请输入链接地址'); - } - $param['logo']=I('logo','str',''); - $param['description']=I('description','str',''); - $param['color']=I('color','str',''); - $param['ordernum']=I('ordernum','int',50); - $param['status']=I('status','int',1); - $param['isblod']=I('isblod','int',0); - $param['create_user_id']=$_SESSION['admin']['userid']; - $param['create_time']=NOW_TIME; - if($this->model->add($param)){ - $this->success('添加成功',U('index')); - }else{ - $this->error('添加失败'); - } - } - $this->display(); - } - - public function editAction() { - $id=I('request.id','int',0); - $info=$this->model->where(array('id'=>$id))->find(); - if (IS_POST){ - $param['name']=I('name','str',''); - if (!$param['name']){ - $this->error('请输入链接名称'); - } - $param['url']=I('url','url',''); - if (!$param['url']){ - $this->error('请输入链接地址'); - } - $param['logo']=I('logo','str',''); - $param['description']=I('description','str',''); - $param['color']=I('color','str',''); - $param['ordernum']=I('ordernum','int',50); - $param['status']=I('status','int',50); - $param['isblod']=I('isblod','int',50); - $param['update_user_id']=$_SESSION['admin']['userid']; - $param['update_time']=NOW_TIME; - $param['id']=$id; - if ($this->model->edit($param)){ - $this->success('修改成功',U('index')); - }else{ - $this->error('修改失败'); - } - } - $this->info=$info; - $this->display(); - } - - public function ajaxAction() { - $id=I('request.id','int',0); - $value=I('param','username',''); - if ($value){ - if ($passport_id=M('passport')->where(array('name'=>$value))->getfield('id')){ - $oid=$this->model->where(array('passport_id'=>$passport_id))->getfield('id'); - if ($oid && $oid!=$id){ - $data=array('status'=>'n','info'=>'您输入的用户名已经使用了'); - }else{ - $data=array('status'=>'y','info'=>'帐号可以使用'); - } - }else{ - $data=array('status'=>'n','info'=>'您输入的用户名不存在'); - } - }else{ - $data=array('status'=>'n','info'=>'输入的用户名有误'); - } - $this->ajax($data); - } - - public function multiAction() { - $param['update_user_id']=$_SESSION['admin']['userid']; - $param['update_time']=NOW_TIME; - if (isset($_POST['changestatus'])){ - foreach($_POST['id'] as $k=>$v){ - $param['id']=$v; - $param['status']=$_POST['value'][$k]; - $this->model->edit($param); - } - $this->success('修改状态成功'); - }elseif(isset($_POST['reorder'])){ - foreach($_POST['ordernum'] as $k=>$v){ - $param['id']=$k; - $param['ordernum']=$v; - $this->model->edit($param); - } - $this->success('排序成功'); - }else{ - } - } -} \ No newline at end of file diff --git a/application/friendlink/view/manage_add.html b/application/friendlink/view/manage_add.html deleted file mode 100644 index 6ebe5d4..0000000 --- a/application/friendlink/view/manage_add.html +++ /dev/null @@ -1,76 +0,0 @@ -
-

添加链接

-
-
-
-
-
- 链接名称: - -
-
-
-
- 链接地址: - -
-
-
-
- 链接描述: - -
-
-
-
- 链接logo: - -
-
-
-
- 排序序号: - -
-
-
-
- 链接颜色: - -
-
-
-
链接字体: - - -
-
- -
-
链接状态: - - -
-
-
-
-
-
- -     -
-
-
-
-
-
- - diff --git a/application/friendlink/view/manage_edit.html b/application/friendlink/view/manage_edit.html deleted file mode 100644 index a4aa2dd..0000000 --- a/application/friendlink/view/manage_edit.html +++ /dev/null @@ -1,83 +0,0 @@ -
-

修改链接

-
-
-
-
-
- 链接名称: - -
-
-
-
- 链接地址: - -
-
-
-
- 链接描述: - -
-
-
-
- 链接logo: - -
-
-
-
- 排序序号: - -
-
-
-
- 链接颜色: - -
-
-
-
链接字体: - - -
-
- -
-
链接状态: - - -
-
-
-
-
-
- - -     -
-
-
-
-
-
- - - \ No newline at end of file diff --git a/application/friendlink/view/manage_index.html b/application/friendlink/view/manage_index.html deleted file mode 100644 index 9860a59..0000000 --- a/application/friendlink/view/manage_index.html +++ /dev/null @@ -1,62 +0,0 @@ -
-

{$menuinfo.menu.name}

-
-
-
-
- 添加 - -
-
- - -
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
链接名称链接地址排序创建人创建时间修改人修改时间状态操作
{{loop.url}} - - {{loop.create_username}}{{loop.create_time}}{{loop.update_username}}{{loop.update_time}} - 禁用 - 正常 - - 编辑 - 删除 -
- -
-
-
-{include file="/application/admin/view/public_angular.html"} \ No newline at end of file diff --git a/application/index/controller/index.php b/application/index/controller/index.php deleted file mode 100644 index 8e27701..0000000 --- a/application/index/controller/index.php +++ /dev/null @@ -1,13 +0,0 @@ -display(); - } -} \ No newline at end of file diff --git a/index.php b/index.php deleted file mode 100644 index fa75a77..0000000 --- a/index.php +++ /dev/null @@ -1,10 +0,0 @@ -array( - 'user'=>array( - 模块1=>地址1 - 模块2=>地址2 - ) - ) - 'block'=>array() - ) -根据这个map来做自动加载 - -2、 -模块必须设置了才允许访问 - - -##官网 -社区管理员标识 置顶 删除 屏蔽 \ No newline at end of file diff --git a/ptcms.sql b/ptcms.sql deleted file mode 100644 index 9fc45ca..0000000 --- a/ptcms.sql +++ /dev/null @@ -1,157 +0,0 @@ -# Host: localhost (Version: 5.5.38) -# Date: 2014-10-09 08:55:17 -# Generator: MySQL-Front 5.3 (Build 4.120) - -/*!40101 SET NAMES utf8 */; - -# -# Structure for table "ptcms_admin_group" -# - -DROP TABLE IF EXISTS `ptcms_admin_group`; -CREATE TABLE `ptcms_admin_group` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `name` varchar(10) NOT NULL DEFAULT '', - `intro` varchar(255) NOT NULL DEFAULT '', - `node` text NOT NULL, - `create_user_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '创建人', - `update_user_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '修改人', - `create_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间', - `update_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '修改时间', - PRIMARY KEY (`id`) -) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COMMENT='用户组信息表'; - -# -# Data for table "ptcms_admin_group" -# - -/*!40000 ALTER TABLE `ptcms_admin_group` DISABLE KEYS */; -INSERT INTO `ptcms_admin_group` VALUES (1,'超级管理员','拥有所有权限','4,5,15,8,9,10,11,12,14,17,19,20,21,18,22,23,24,25,3,1,6,7,13,2,16',1,1,1412777739,1412778653); -/*!40000 ALTER TABLE `ptcms_admin_group` ENABLE KEYS */; - -# -# Structure for table "ptcms_admin_node" -# - -DROP TABLE IF EXISTS `ptcms_admin_node`; -CREATE TABLE `ptcms_admin_node` ( - `id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '文档ID', - `name` varchar(50) NOT NULL DEFAULT '' COMMENT '标题', - `pid` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '上级分类ID', - `module` varchar(20) DEFAULT NULL, - `controller` varchar(50) DEFAULT NULL, - `action` varchar(50) DEFAULT NULL, - `ordernum` smallint(10) unsigned NOT NULL DEFAULT '0' COMMENT '排序(同级有效)', - `status` tinyint(1) NOT NULL DEFAULT '0' COMMENT '状态', - `create_user_id` int(11) unsigned DEFAULT '0' COMMENT '创建人', - `update_user_id` int(11) unsigned DEFAULT '0' COMMENT '修改人', - `create_time` int(11) unsigned DEFAULT '0' COMMENT '创建时间', - `update_time` int(11) unsigned DEFAULT '0' COMMENT '修改时间', - PRIMARY KEY (`id`), - KEY `pid` (`pid`), - KEY `status` (`status`) -) ENGINE=MyISAM AUTO_INCREMENT=26 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC; - -# -# Data for table "ptcms_admin_node" -# - -/*!40000 ALTER TABLE `ptcms_admin_node` DISABLE KEYS */; -INSERT INTO `ptcms_admin_node` VALUES (1,'常用',0,'','','',1,1,1,1,1412696793,1412757936),(2,'系统',0,'','','',1,1,1,1,1412696797,1412757936),(3,'系统概况',1,'','','',50,1,1,1,1412699544,1412757936),(4,'欢迎界面',3,'admin','index','welcome',10,1,1,1,1412699598,1412757936),(5,'系统探针',3,'admin','index','system',20,1,1,1,1412699662,1412757936),(6,'常用功能',1,'','','',50,1,1,1,1412699681,1412757936),(7,'开发功能',1,'','','',50,1,1,1,1412699705,1412757936),(8,'权限节点',7,'admin','node','index',50,1,1,1,1412699737,1412757936),(9,'添加节点',8,'admin','node','add',50,1,1,1,1412699752,1412757936),(10,'修改节点',8,'admin','node','edit',50,1,1,1,1412699787,1412757936),(11,'删除节点',8,'admin','node','del',50,1,1,1,1412699817,1412757936),(12,'批量操作',8,'admin','node','multi',50,1,1,1,1412700038,1412757936),(13,'系统设置',2,'','','',50,1,1,1,1412701712,1412757936),(14,'基本参数',13,'','','',50,1,1,1,1412701727,1412757936),(15,'添加菜单',6,'','','',50,1,1,1,1412701869,1412757936),(16,'管理员设置',2,'','','',50,1,1,1,1412749506,1412757936),(17,'用户管理',16,'admin','user','index',50,1,1,1,1412749542,1412757936),(18,'用户组管理',16,'admin','group','index',50,1,1,1,1412749571,1412757936),(19,'添加用户',17,'admin','user','add',50,1,1,1,1412749589,1412757936),(20,'修改用户',17,'admin','user','edit',50,1,1,1,1412749624,1412757936),(21,'删除用户',17,'admin','user','del',50,1,1,1,1412749640,1412757936),(22,'添加用户组',18,'admin','group','add',50,1,1,1,1412749659,1412757936),(23,'修改用户组',18,'admin','group','edit',50,1,1,1,1412749668,1412757936),(24,'删除用户组',18,'admin','group','del',50,1,1,1,1412749694,1412757936),(25,'批量操作',18,'admin','group','multi',50,1,1,1,1412749710,1412757936); -/*!40000 ALTER TABLE `ptcms_admin_node` ENABLE KEYS */; - -# -# Structure for table "ptcms_admin_user" -# - -DROP TABLE IF EXISTS `ptcms_admin_user`; -CREATE TABLE `ptcms_admin_user` ( - `id` smallint(5) unsigned NOT NULL AUTO_INCREMENT, - `passport_id` int(11) NOT NULL DEFAULT '0', - `group_id` smallint(5) DEFAULT '0' COMMENT '用户组', - `intro` varchar(255) NOT NULL DEFAULT '', - `create_user_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '创建人', - `update_user_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '修改人', - `create_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间', - `update_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '修改时间', - `login_num` int(11) unsigned DEFAULT '0' COMMENT '登录次数', - `login_ip` varchar(15) DEFAULT NULL, - `login_time` int(11) unsigned DEFAULT '0' COMMENT '最后登录时间', - `status` tinyint(3) unsigned DEFAULT '1' COMMENT '用户状态 1正常 0未审核', - PRIMARY KEY (`id`), - UNIQUE KEY `passport_id` (`passport_id`), - KEY `group_id` (`group_id`) -) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='用户信息表'; - -# -# Data for table "ptcms_admin_user" -# - -/*!40000 ALTER TABLE `ptcms_admin_user` DISABLE KEYS */; -INSERT INTO `ptcms_admin_user` VALUES (1,1,1,'默认管理员帐号',1,1,1411978787,1412813064,12,'127.0.0.1',1412778449,1),(3,2,1,'haha',1,0,1412815173,0,0,NULL,0,1); -/*!40000 ALTER TABLE `ptcms_admin_user` ENABLE KEYS */; - -# -# Structure for table "ptcms_caption" -# - -DROP TABLE IF EXISTS `ptcms_caption`; -CREATE TABLE `ptcms_caption` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `key` varchar(50) DEFAULT NULL, - `name` varchar(100) DEFAULT NULL COMMENT '名称', - `description` varchar(255) DEFAULT NULL COMMENT '描述信息', - PRIMARY KEY (`id`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='key中文解释'; - -# -# Data for table "ptcms_caption" -# - -/*!40000 ALTER TABLE `ptcms_caption` DISABLE KEYS */; -/*!40000 ALTER TABLE `ptcms_caption` ENABLE KEYS */; - -# -# Structure for table "ptcms_passport" -# - -DROP TABLE IF EXISTS `ptcms_passport`; -CREATE TABLE `ptcms_passport` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `name` varchar(50) DEFAULT NULL, - `password` char(32) DEFAULT NULL, - `salt` char(6) DEFAULT NULL, - `reg_ip` varchar(15) DEFAULT NULL, - `reg_time` int(11) unsigned DEFAULT '0', - `login_ip` varchar(15) DEFAULT NULL, - `login_time` int(11) unsigned DEFAULT '0', - PRIMARY KEY (`id`), - KEY `name` (`name`(5)) -) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COMMENT='用户信息主表'; - -# -# Data for table "ptcms_passport" -# - -/*!40000 ALTER TABLE `ptcms_passport` DISABLE KEYS */; -INSERT INTO `ptcms_passport` VALUES (1,'admin','db4dfadff18f7145ca4f6a2a15ff6303','565795','127.0.0.1',1411978787,'127.0.0.1',1412778449),(2,'test1',NULL,NULL,NULL,0,NULL,0),(3,'test2',NULL,NULL,NULL,0,NULL,0),(4,'test3',NULL,NULL,NULL,0,NULL,0); -/*!40000 ALTER TABLE `ptcms_passport` ENABLE KEYS */; - -# -# Structure for table "ptcms_user" -# - -DROP TABLE IF EXISTS `ptcms_user`; -CREATE TABLE `ptcms_user` ( - `user_id` int(11) NOT NULL DEFAULT '0', - `group_id` smallint(6) DEFAULT NULL, - `status` tinyint(3) unsigned DEFAULT '1' COMMENT '用户状态 1正常 0未审核', - PRIMARY KEY (`user_id`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='用户信息表'; - -# -# Data for table "ptcms_user" -# - -/*!40000 ALTER TABLE `ptcms_user` DISABLE KEYS */; -/*!40000 ALTER TABLE `ptcms_user` ENABLE KEYS */; diff --git a/ptcms/core/api.php b/ptcms/core/api.php new file mode 100644 index 0000000..1c30ad9 --- /dev/null +++ b/ptcms/core/api.php @@ -0,0 +1,70 @@ +apiurl = $this->config->get('apiserver'); + $driverclass = 'Driver_Api_' . $this->config->get('driver_api', 'ptcms'); + $this->handle = new $driverclass; + } + + public function __call($method, $param = array()) { + $param = ($param == array()) ? array() : $param['0']; + return $this->call($method, $param); + } + + public function method($var) { + $this->name = $var; + return $this; + } + + public function param($var) { + $this->param = $var; + return $this; + } + + public function header($var) { + $this->header = $var; + return $this; + } + + public function get() { + return $this->call($this->name, $this->param, 'GET', $this->header); + } + + public function post() { + return $this->call($this->name, $this->param, 'POST', $this->header); + } + + public function put() { + return $this->call($this->name, $this->param, 'PUT', $this->header); + } + + public function delete() { + return $this->call($this->name, $this->param, 'DELETE', $this->header); + } + + // 调用API + public function call($name, $param = array(), $method = 'GET', $header = array()) { + + if (strpos($name, 'http') === 0) { + $url = $name; + } else { + $url = $this->apiurl . '/' . $name; + } + //get方式则把参数加到url里面 + if ($method == 'GET' && $header != array()) { + $param = array_merge($param, $header); + } + return $this->handle->call($url, $param, $method, $header); + } +} \ No newline at end of file diff --git a/ptcms/core/block.php b/ptcms/core/block.php index c135847..f1f1748 100644 --- a/ptcms/core/block.php +++ b/ptcms/core/block.php @@ -5,19 +5,43 @@ * @Email : admin@ptcms.com * @File : block.php */ -abstract class block extends Controller { +class PT_Block{ + protected $pt; + public function __construct() { + $this->pt=PT_Base::getInstance(); + } + + public function getInstance($class) { + static $_class; + $class = $class . 'Block'; + if (empty($_class[$class])) { + if (class_exists($class)) { + $_class[$class] = new $class(); + }else{ + $_class[$class] = null; + } + } + return $_class[$class]; + } - public function run($param) { - $key = $this->getKey($param); - $cachetime = empty($param['cachetime']) ? C('CACHE_TIME', null, 600) : intval($param['cachetime']); - $data = $this->checkCache($key, $cachetime); - if (APP_DEBUG || $data === false) { - $data = $this->exec($param); + public function getData($name,$param) { + $key = $this->getKey($name,$param); + $cachetime = $this->pt->input->param('cachetime','int',$this->pt->config->get('cachetime', 600),$param); + $data = $this->pt->cache->get($key); + $hander=$this->getInstance($name); + if ($hander && (APP_DEBUG || $data === null)) { + $data = $hander->run($param); if (!empty($param['template'])) { - $this->assign('block', $data); - $data = $this->render($param['template'], 'common'); + $this->pt->view->set($param); + if ($layout=$this->pt->config->get('layout')){ + $this->pt->config->get('layout',false); + $data = $this->pt->view->fetch($param['template']); + $this->pt->config->get('layout',$layout); + }else{ + $data = $this->pt->view->fetch($param['template']); + } } - if (!APP_DEBUG) Cache::set($key, array('time' => NOW_TIME, 'data' => $data), $cachetime); + $this->pt->cache->set($key, $data, $cachetime); } return $data; } @@ -30,23 +54,15 @@ public function run($param) { * @return bool */ public function checkCache($key, $cachetime) { - $data = Cache::get($key); + $data = $this->pt->cache->get($key); if (!isset($data['time']) || ($cachetime <> 0 && $data['time'] + $cachetime < NOW_TIME)) { return false; } return $data['data']; } - public function getKey($param) { - return md5(get_class($this) . serialize($param)); + public function getKey($name,$param) { + return md5($name . serialize($param)); } - /** - * 需要实现的方法 - * - * @param $param - * @return mixed - */ - abstract public function exec($param); - } \ No newline at end of file diff --git a/ptcms/core/cache.php b/ptcms/core/cache.php index 5ec21f7..5e4559f 100644 --- a/ptcms/core/cache.php +++ b/ptcms/core/cache.php @@ -5,37 +5,43 @@ * @Email : admin@ptcms.com * @File : Cache.php */ -class Cache { +class PT_Cache{ protected static $handler = null; + protected $pt; + + public function __construct() { + $this->pt=PT_Base::getInstance(); + } /** + * @param string $type; * @return Driver_Cache_File */ - public static function getInstance() { - $key = C('cache_type', null, 'file'); - if (empty(self::$handler[$key])) { - $class = 'Driver_Cache_' . C('cache_type'); - self::$handler[$key] = new $class(C('cache_option', null, array())); + public function getInstance($type = '') { + $type = $type ? $type : $this->pt->config->get('cache_driver', 'file'); + if (empty(self::$handler[$type])) { + $class = 'Driver_Cache_' . $this->pt->config->get('cache_driver'); + self::$handler[$type] = new $class($this->pt->config->get('cache_option', array())); } - return self::$handler[$key]; + return self::$handler[$type]; } - public static function set($key, $value, $time = 0) { + public function set($key, $value, $time = 0) { $GLOBALS['_cacheWrite']++; - return self::getInstance()->set($key, $value, $time); + return $this->getInstance()->set($key, $value, $time); } - public static function get($key) { + public function get($key) { $GLOBALS['_cacheRead']++; - return self::getInstance()->get($key); + return $this->getInstance()->get($key); } - public static function rm($key) { - return self::getInstance()->rm($key); + public function rm($key) { + return $this->getInstance()->rm($key); } - public static function clear() { - self::getInstance()->clear(); + public function clear() { + $this->getInstance()->clear(); } } \ No newline at end of file diff --git a/ptcms/core/config.php b/ptcms/core/config.php new file mode 100644 index 0000000..6f0192d --- /dev/null +++ b/ptcms/core/config.php @@ -0,0 +1,82 @@ +register($key); + //多级模式 + $c = self::$_config; + $k = &$c; + $fields = explode('.', $key); + foreach ($fields as $field) { + $k = &$k[$field]; + } + $k = $var; + self::$_config=$c; + return true; + } + + /* + * 注册配置 + */ + public function register($config){ + if (!is_array($config)) return false; + self::$_config = array_merge(self::$_config, array_change_key_case($config)); + return true; + } + + // save 只可以写入公共配置文件的 支持数组 + public function save($key, $value='') { + $file=APP_PATH . '/common/config.php'; + $config = include $file; + if (is_array($key)){ + $config=array_merge($config, $key); + }elseif(isset($config[$key])){ + $config[$key]=$value; + }else{ + return; + } + if (!F($file, $config)){ + $this->response->error('修改失败,请检查'.$file . '文件权限',0,0); + }; + } +} diff --git a/ptcms/core/controller.php b/ptcms/core/controller.php index 6f36bcd..8b5e4a4 100644 --- a/ptcms/core/controller.php +++ b/ptcms/core/controller.php @@ -5,25 +5,20 @@ * @Email : admin@ptcms.com * @File : controller.php */ -class Controller { - protected function getView() { +class PT_Controller extends PT_Base { + public function getView() { static $view; if (!isset($view)) { - plugin::call('view_start'); + $this->plugin->call('view_start'); //实例化view - $view = new View(); + $view = new PT_View(); //初始化模版 $view->getTheme(); } return $view; } - public function assign($name, $value = null) { - $this->getView()->assign($name, $value); - return $this; //支持连贯操作 - } - /** * 显示当前页面的视图内容 * @@ -33,8 +28,8 @@ public function assign($name, $value = null) { * @param string $theme 所属模版 * @return void */ - protected function display($tpl = null, $module = null, $theme = null) { - $content = $this->render($tpl, $module, $theme); + public function display($tpl = null, $module = null, $theme = null) { + $content = $this->fetch($tpl, $module, $theme); $this->show($content); } @@ -47,123 +42,96 @@ protected function display($tpl = null, $module = null, $theme = null) { * @return void */ protected function show($content, $mimeType = 'text/html') { - pt::show($content, $mimeType); - } - - protected function render($tpl = null, $module = null, $theme = null) { - if (C('html', null, false)) { - $rules = C('URL_RULES'); - $key = $_GET['m'] . '.' . $_GET['c'] . '.' . $_GET['a']; - if (isset($rules[$key])) { - $param = $_GET; - unset($param['m'], $param['c'], $param['a'], $param['s'], $param['t']); - C('is_gen_html', true); - $content = $this->getView()->render($tpl, $module, $theme); - $url = empty($this->htmlurl) ? U($key, $param, C('link_ignore', null, array())) : $this->htmlurl; - html::create($url, $content); - return $content; - } - } - return $this->getView()->render($tpl, $module, $theme); + $this->response->setBody($content, $mimeType); } - // 实现 $this->name=value 的赋值方法 - public function __set($name, $value) { - $this->getView()->assign($name, $value); + protected function fetch($tpl = null, $module = null, $theme = null) { + return $this->view->fetch($tpl, $module, $theme); } - // 获取 $this->name 的值 - public function __get($name) { - return $this->getView()->getassign($name); + protected function render($var){ + if ($var===true){ + $this->response->enableRender(); + }elseif($var===false){ + $this->response->disableRender(); + }else{ + $this->view->setFile($var); + } } - protected function success($info, $jumpUrl = '', $second = 1) { + public function success($info, $jumpUrl = '', $second = 1) { $this->dispatchJump($info, 1, $jumpUrl, $second); } - protected function error($info, $jumpUrl = '', $second = 3) { + public function error($info, $jumpUrl = '', $second = 3) { $this->dispatchJump($info, 0, $jumpUrl, $second); } protected function dispatchJump($message, $status = 1, $jumpurl = '', $second = 1) { - C('LAYOUT', false); - if (IS_AJAX or $second === true) { + $this->config->set('layout', false); + if ($this->request->isAjax() or $second === true) { $data['status'] = $status; - $data['info'] = $message; - $data['url'] = $jumpurl; + $data['info'] = $message; + $data['url'] = $jumpurl; $this->ajax($data); } else { - defined('PT_SITENAME') ? $this->assign('msgname', PT_SITENAME) : $this->assign('msgname', C('SITENAME', null, 'PTFrameWork')); + defined('PT_SITENAME') ? $this->view->set('msgname', PT_SITENAME) : $this->view->set('msgname', $this->config->get('sitename', null, 'PTFrameWork')); //如果设置了关闭窗口,则提示完毕后自动关闭窗口 - $this->assign('status', $status); // 状态 - $this->assign('waitsecond', $second); - $this->assign('message', $message); // 提示信息 - $this->assign('msgtitle', $status ? '成功' : '失败'); + $this->view->set('status', $status); // 状态 + $this->view->set('waitsecond', $second); + $this->view->set('message', $message); // 提示信息 + $this->view->set('msgtitle', $status ? '成功' : '失败'); if ($status) { //发送成功信息 - $this->assign('msgtype', 'success'); // 提示类型 + $this->view->set('msgtype', 'success'); // 提示类型 // 默认操作成功自动返回操作前页面 if ($jumpurl) { - $this->assign("jumpurl", $jumpurl); + $this->view->set("jumpurl", $jumpurl); } elseif (!empty($_SERVER['HTTP_REFERER'])) { - $this->assign("jumpurl", $_SERVER["HTTP_REFERER"]); + $this->view->set("jumpurl", $_SERVER["HTTP_REFERER"]); } else { - $this->assign('jumpurl', $_SERVER['REQUEST_URI']); + $this->view->set('jumpurl', $_SERVER['REQUEST_URI']); } } else { - $this->assign('msgtype', 'error'); // 提示类型 + $this->view->set('msgtype', 'error'); // 提示类型 // 默认发生错误的话自动返回上页 if ($jumpurl) { - $this->assign("jumpurl", $jumpurl); + $this->view->set("jumpurl", $jumpurl); } elseif (!empty($_SERVER['HTTP_REFERER'])) { - $this->assign("jumpurl", '#back#'); + $this->view->set("jumpurl", '#back#'); } else { - $this->assign('jumpurl', $_SERVER['REQUEST_URI']); + $this->view->set('jumpurl', $_SERVER['REQUEST_URI']); } } - $this->display('message', 'common', C('tpl_theme') ? C('tpl_theme') : 'default'); + $this->display('message', 'common', $this->config->get('tpl_theme') ? $this->config->get('tpl_theme') : 'default'); exit; } } - protected function ajax($data, $type = 'json') { + public function ajax($data, $type = 'json') { + // 跨域 + header('Access-Control-Allow-Origin:*'); + header('Access-Control-Allow-Headers:accept, content-type'); + switch (strtoupper($type)) { case 'JSON' : // 返回JSON数据格式到客户端 包含状态信息 - pt::show(json_encode($data), 'application/json'); + $data=$this->response->jsonEncode($data); break; case 'JSONP': - // 返回JSON数据格式到客户端 包含状态信息 - $handler = isset($_GET[C('VAR_JSONP_HANDLER')]) ? $_GET[C('VAR_JSONP_HANDLER')] : 'ptcms_jsonp'; - pt::show($handler . '(' . json_encode($data) . ');', 'application/json'); + // 返回JSONP数据格式到客户端 包含状态信息 + $data=$this->response->jsonpEncode($data); break; case 'EVAL' : // 返回可执行的js脚本 - pt::show($data); break; default : - // 用于扩展其他返回格式数据 } + $this->response->setBody($data, 'application/json'); exit; } public function redirect($url, $type = 302) { - if ($type == 302) { - header('HTTP/1.1 302 Moved Temporarily'); - header('Status:302 Moved Temporarily'); // 确保FastCGI模式下正常 - } else { - header('HTTP/1.1 301 Moved Permanently'); - header('Status:301 Moved Permanently'); - } - header('Location: ' . $url); - exit; - } - - public function _empty($msg) { - if (APP_DEBUG) { - $this->error($msg, '', 0); - } else { - halt($msg); - } + $this->response->redirect($url, $type); } } \ No newline at end of file diff --git a/ptcms/core/cookie.php b/ptcms/core/cookie.php new file mode 100644 index 0000000..cdeac18 --- /dev/null +++ b/ptcms/core/cookie.php @@ -0,0 +1,60 @@ +option = array( + 'prefix' => $this->config->get('cookie_prefix', 'PTCMS_'), + // cookie 保存时间 + 'expire' => intval($this->config->get('cookie_expire', 2592000)), + // cookie 保存路径 + 'path' => $this->config->get('cookie_path', '/'), + // cookie 有效域名 + 'domain' => $this->config->get('cookie_domain'), + ); + } + + public function get($name, $default=null) { + $name = $this->option['prefix'] . $name; + if (isset($_COOKIE[$name])) { + return $_COOKIE[$name]; + } else { + return $default; + } + } + + public function set($name, $value = '', $option = null) { + if (!is_null($option)) { + if (is_numeric($option)) + $option = array('expire' => $option); + elseif (is_string($option)) + parse_str($option, $option); + $config = array_merge($this->option, array_change_key_case($option)); + } else { + $config = $this->option; + } + $name = $this->option['prefix'] . $name; + $expire = !empty($config['expire']) ? time() + $config['expire'] : 0; + setcookie($name, $value, $expire, $config['path'], $config['domain']); + $_COOKIE[$name] = $value; + } + + public function del($name) { + $name = $this->option['prefix'] . $name; + setcookie($name, '', time() - 3600, $this->option['path'], $this->option['domain']); + // 删除指定cookie + unset($_COOKIE[$name]); + } + + public function clear() { + foreach ($_COOKIE as $key => $val) { + if (0 === stripos($key, $this->option['prefix'])) { + setcookie($key, '', time() - 3600, $this->option['prefix']['path'], $this->option['prefix']['domain']); + unset($_COOKIE[$key]); + } + } + return true; + } +} \ No newline at end of file diff --git a/ptcms/core/db.php b/ptcms/core/db.php new file mode 100644 index 0000000..8b31561 --- /dev/null +++ b/ptcms/core/db.php @@ -0,0 +1,77 @@ +pt=PT_Base::getInstance(); + } + + /** + * @param string $name + * @return Driver_Db_Dao + */ + public function getInstance($name='') { + if (self::$_config == array()) { + self::$_config = $this->parseConfig(); + } + $name=($name=='')?'__empty__':$name; + if (empty(self::$_class[$name])){ + $class='Driver_Db_'.self::$_config['type'].'_dao'; + self::$_class[$name]=new $class(self::$_config,$name); + } + return self::$_class[$name]; + } + + /** + * @param $name + * @return mixed + */ + public function table($name='') { + return $this->getInstance($name); + } + + public function parseConfig() { + $config_params['type']=$this->pt->config->get('db_type', 'mysql'); + switch($config_params['type']){ + case 'mysql': + $config_params['master'] = array( + array( + 'host' => $this->pt->config->get('db_mysql_master_host', 'localhost'), + 'port' => $this->pt->config->get('db_mysql_master_port', '3306'), + 'name' => $this->pt->config->get('db_mysql_master_name', 'ptcms'), + 'user' => $this->pt->config->get('db_mysql_master_user', 'root'), + 'pwd' => $this->pt->config->get('db_mysql_master_pwd', ''), + ) + ); + if ($this->pt->config->get('db_mysql_salve_host')){ + $config_params['singleton']=false; + $config_params['slave'] = array( + array( + 'host' => $this->pt->config->get('db_mysql_salve_host', 'localhost'), + 'port' => $this->pt->config->get('db_mysql_salve_port', '3306'), + 'name' => $this->pt->config->get('db_mysql_salve_name', 'ptcms'), + 'user' => $this->pt->config->get('db_mysql_salve_user', 'root'), + 'pwd' => $this->pt->config->get('db_mysql_salve_pwd', ''), + ) + ); + }else{ + $config_params['singleton']=true; + $config_params['slave'] = $config_params['master']; + } + $config_params['driver']=$this->pt->config->get('db_mysql_driver', 'pdo'); + $config_params['prefix']=$this->pt->config->get('db_mysql_prefix', 'ptcms_'); + $config_params['charset']=$this->pt->config->get('db_mysql_charset', 'utf8'); + break; + } + return $config_params; + } +} + diff --git a/ptcms/core/dispatcher.php b/ptcms/core/dispatcher.php index 4102677..6e2dffa 100644 --- a/ptcms/core/dispatcher.php +++ b/ptcms/core/dispatcher.php @@ -5,41 +5,53 @@ * @Email : admin@ptcms.com * @File : dispatcher.php */ -class dispatcher { +class PT_Dispatcher extends PT_Base { // 入口文件 - public static function run() { - if (!empty($_POST['s'])) $_GET['s'] = $_POST['s']; - if (!empty($_POST['m'])) $_GET['m'] = $_POST['m']; - if (!empty($_POST['c'])) $_GET['c'] = $_POST['c']; - if (!empty($_POST['a'])) $_GET['a'] = $_POST['a']; + public function run() { + // 暂时去掉post设置参数 + //if (!empty($_POST['s'])) $_GET['s'] = $_POST['s']; + //if (!empty($_POST['m'])) $_GET['m'] = $_POST['m']; + //if (!empty($_POST['c'])) $_GET['c'] = $_POST['c']; + //if (!empty($_POST['a'])) $_GET['a'] = $_POST['a']; if (empty($_GET['s'])) { //设置默认值 - $_GET['m']=empty($_GET['m'])?C('default_module', null, 'index'):$_GET['m']; - $_GET['c']=empty($_GET['c'])?C('default_controller', null, 'index'):$_GET['c']; - $_GET['a']=empty($_GET['a'])?C('default_action', null, 'index'):$_GET['a']; + $_GET['m'] = empty($_GET['m']) ? $this->config->get('default_module', 'index') : $_GET['m']; + $_GET['c'] = empty($_GET['c']) ? $this->config->get('default_controller', 'index') : $_GET['c']; + $_GET['a'] = empty($_GET['a']) ? $this->config->get('default_action', 'index') : $_GET['a']; } else { $_GET['s'] = trim($_GET['s'], '/');//去除左右的/防止干扰 - self::router();//路由校验 - self::parseSuperVar();//解析超级变量 + $this->router();//路由校验 + $this->parseSuperVar();//解析超级变量 } + $_GET['f'] = empty($_GET['f']) ? $this->config->get('default_format', 'html') : $_GET['f']; //module映射 - $mapModule = C('map_module', null, array()); + $mapModule = $this->config->get('map_module', array()); if (isset($mapModule[$_GET['m']])) { halt('当前模块已经改名', __FILE__, __LINE__ - 1); } elseif (in_array($_GET['m'], $mapModule)) { $_GET['_m'] = $_GET['m']; $_GET['m'] = array_search($_GET['m'], $mapModule); } + //过滤xss及参数前后空白 + foreach($_GET as &$v){ + $v=trim(strip_tags($v)); + } $_REQUEST = array_merge($_GET, $_POST); } // 解析超级变量 - public static function parseSuperVar() { - $param = explode('/', $_GET['s']); - $var['m'] = isset($param['0']) ? array_shift($param) : C('default_module', null, 'index'); - $var['c'] = isset($param['0']) ? array_shift($param) : C('default_controller', null, 'index'); - $var['a'] = isset($param['0']) ? array_shift($param) : C('default_action', null, 'index'); + public function parseSuperVar() { + if (strpos($_GET['s'], '.')) { + $param = explode('.', $_GET['s'], 2); + $_GET['f'] = $param['1']; + $param = explode('/', $param['0']); + } else { + $param = explode('/', $_GET['s']); + } + $var['m'] = isset($param['0']) ? array_shift($param) : $this->config->get('default_module', 'index'); + $var['c'] = isset($param['0']) ? array_shift($param) : $this->config->get('default_controller', 'index'); + $var['a'] = isset($param['0']) ? array_shift($param) : $this->config->get('default_action', 'index'); while ($k = each($param)) { $var[$k['value']] = current($param); next($param); @@ -48,8 +60,8 @@ public static function parseSuperVar() { } // 解析路由 - public static function router() { - if ($router = C('url_router')) { + public function router() { + if ($router = $this->config->get('url_router')) { foreach ($router as $rule => $url) { if (preg_match('{' . $rule . '}isU', $_GET['s'], $match)) { unset($match['0']); diff --git a/ptcms/core/filter.php b/ptcms/core/filter.php new file mode 100644 index 0000000..4a8e226 --- /dev/null +++ b/ptcms/core/filter.php @@ -0,0 +1,135 @@ +regex($value, $filter) ? $value : $default); + } + } + + public function regex($value, $rule) { + $validate = array( + //必填 + 'require' => '/.+/', + //邮箱 + 'email' => '/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/', + //链接 + 'url' => '/^http:\/\/[a-zA-Z0-9]+\.[a-zA-Z0-9]+[\/=\?%\-&_~`@\[\]\':+!]*([^<>\"\"])*$/', + //货币 + 'currency' => '/^\d+(\.\d+)?$/', + //数字 + 'number' => '/^\d+$/', + //邮编 + 'zip' => '/^[0-9]\d{5}$/', + //电话 + 'tel' => '/^1[\d]{10}$/', + //整型 + 'integer' => '/^[-\+]?\d+$/', + //带小数点 + 'double' => '/^[-\+]?\d+(\.\d+)?$/', + //英文字母 + 'english' => '/^[a-zA-Z]+$/', + //中文汉字 + 'chinese' => '/^[\x{4e00}-\x{9fa5}]+$/u', + //拼音 + 'pinyin' => '/^[a-zA-Z0-9\-\_]+$/', + //用户名 + 'username' => '/^(?!_)(?!.*?_$)[a-zA-Z0-9_\x{4e00}-\x{9fa5}]{3,15}$/u', + //英文字符 + 'en' => '/^[a-zA-Z0-9_\s\-\.]+$/', + //中文字符 + 'cn' => '/^[\w\s\-\x{4e00}-\x{9fa5}]+$/u', + //安全字符串 + 'safestring' => '/^[^\$\?]+$/' + ); + // 检查是否有内置的正则表达式 + if (isset($validate[ strtolower($rule) ])) $rule = $validate[ strtolower($rule) ]; + return preg_match($rule, strval($value)) === 1; + } + + //安全的剔除字符 单行等 用于搜索 链接等地方 + public function safeStrip($kw) { + if (strlen($kw) == 0) return ''; + $kw=strip_tags($kw); + $badString = '~!@#$%^&*()+|=\\{}[];\'"/<>?'; + $length = strlen($badString); + $pos = 0; + while ($pos < $length) { + $kw = str_replace($badString{$pos}, '', $kw); + $pos++; + } + return preg_replace('/([\r\n\t]+)/', '', $kw); + } + + /** + * 过滤掉html字符 + * @param string $text + * @param string $tags 允许的html标签 + * @return mixed|string + */ + public function safetext($text,$tags='br') { + $text = trim($text); + //完全过滤注释 + $text = preg_replace('//', '', $text); + //完全过滤动态代码 + $text = preg_replace('/<\?|\?' . '>/', '', $text); + //完全过滤js + $text = preg_replace('//', '', $text); + + $text = str_replace('[', '[', $text); + $text = str_replace(']', ']', $text); + $text = str_replace('|', '|', $text); + //br + $text = preg_replace('//i', '[br]', $text); + $text = preg_replace('//i', '[br]', $text); + $text = preg_replace('/(\[br\]\s*){10,}/i', '[br]', $text); + //过滤危险的属性,如:过滤on事件lang js + while (preg_match('/(<[^><]+)( lang|on|action|background|codebase|dynsrc|lowsrc)[^><]+/i', $text, $mat)) { + $text = str_replace($mat[0], $mat[1], $text); + } + while (preg_match('/(<[^><]+)(window\.|javascript:|js:|about:|file:|document\.|vbs:|cookie)([^><]*)/i', $text, $mat)) { + $text = str_replace($mat[0], $mat[1] . $mat[3], $text); + } + //允许的HTML标签 + $text = preg_replace('/<(' . $tags . ')( [^><\[\]]*)>/i', '[\1\2]', $text); + $text = preg_replace('/<\/(' . $tags . ')>/Ui', '[/\1]', $text); + //过滤多余html + $text = preg_replace('/<\/?(html|head|meta|link|base|basefont|body|bgsound|title|style|script|form|iframe|frame|frameset|applet|id|ilayer|layer|name|script|style|xml|table|td|th|tr|i|u|strong|img|p|br|div|strong|em|ul|ol|li|dl|dd|dt|a)[^><]*>/i', '', $text); + //过滤合法的html标签 + while (preg_match('/<([a-z]+)[^><\[\]]*>[^><]*<\/\1>/i', $text, $mat)) { + $text = str_replace($mat[0], str_replace('>', ']', str_replace('<', '[', $mat[0])), $text); + } + //转换引号 + while (preg_match('/(\[[^\[\]]*=\s*)(\"|\')([^\2=\[\]]+)\2([^\[\]]*\])/i', $text, $mat)) { + $text = str_replace($mat[0], $mat[1] . '|' . $mat[3] . '|' . $mat[4], $text); + } + //过滤错误的单个引号 + while (preg_match('/\[[^\[\]]*(\"|\')[^\[\]]*\]/i', $text, $mat)) { + $text = str_replace($mat[0], str_replace($mat[1], '', $mat[0]), $text); + } + //转换其它所有不合法的 < > + $text = str_replace('<', '<', $text); + $text = str_replace('>', '>', $text); + $text = str_replace('"', '"', $text); + //反转换 + $text = str_replace('[', '<', $text); + $text = str_replace(']', '>', $text); + $text = str_replace('|', '"', $text); + //过滤多余空格 + $text = str_replace(' ', ' ', $text); + return $text; + } +} \ No newline at end of file diff --git a/ptcms/core/input.php b/ptcms/core/input.php new file mode 100644 index 0000000..8931a1a --- /dev/null +++ b/ptcms/core/input.php @@ -0,0 +1,53 @@ +param($name, $type, $default, $_GET); + } + + public function post($name, $type = 'int', $default = null) { + return $this->param($name, $type, $default, $_POST); + } + + public function request($name, $type = 'int', $default = null) { + return $this->param($name, $type, $default, $_REQUEST); + } + + public function put($name, $type = 'int', $default = null) { + static $input = null; + if ($input === null) parse_str(file_get_contents('php://input'), $input); + return $this->param($name, $type, $default, $input); + } + + public function server($name, $type = 'int', $default = null) { + return $this->param($name, $type, $default, $_SERVER); + } + + public function globals($name, $type = 'int', $default = null) { + return $this->param($name, $type, $default, $GLOBALS); + } + + public function cookie($name, $type = 'int', $default = null) { + return $this->param($this->config->get('cookie_prefix', '') . $name, $type, $default, $_COOKIE); + } + + public function session($name, $type = 'int', $default = null) { + return $this->param($name, $type, $default, $GLOBALS); + } + + public function files($name, $type = 'int', $default = null) { + return $this->param($name, $type, $default, $_FILES); + } + + public function has($name, $type = 'request') { + + } + + public function param($name, $filter = 'int', $default = null, $param = array()) { + $value = isset($param[ $name ]) ? $param[ $name ] : null; + return $this->filter->filter($value, $filter, $default); + } + + +} \ No newline at end of file diff --git a/ptcms/core/log.php b/ptcms/core/log.php index a32b017..7601702 100644 --- a/ptcms/core/log.php +++ b/ptcms/core/log.php @@ -1,7 +1,7 @@ $log) { - $file = CACHE_PATH . '/log/' . $type . '_' . date('Ymd') . '.log'; + $file = CACHE_PATH . '/log/' . $type . '_' . date('Ymd') . '.txt'; if (is_array($log)) { foreach ($log as $v) { F($file, $v, FILE_APPEND); diff --git a/ptcms/core/model.php b/ptcms/core/model.php index 2cedd17..50eb0fe 100644 --- a/ptcms/core/model.php +++ b/ptcms/core/model.php @@ -1,681 +1,133 @@ config->get('db_type')) $this->hasdb = true; + } /** - * 相关数据存储 + * __call魔法方法 用于调用db相关的方法 * - * @var array + * @param $method + * @param $args + * @return mixed */ - protected $data = array(); - - - public function __construct($tablename = '') { - //定义model字段缓存文件目录 - $this->cachePath = CACHE_PATH . '/fields'; - //获取数据库连接参数 - self::$config = $this->parseConfig(); - - if ($tablename) { - $this->setTable($tablename); - } - return true; - } - - public function __set($key, $value) { - $this->data[strtolower($key)] = $value; - } - - public function __get($key) { - return $this->data[strtolower($key)]; - } - - public function __isset($key) { - return isset($this->data[strtolower($key)]); - } - - public function __unset($key) { - unset($this->data[strtolower($key)]); - } - public function __call($method, $args) { - $method = strtolower($method); - //todo join union - if (in_array($method, array('field', 'order', 'limit', 'page', 'group', 'having', 'table', 'distinct'))) { - $this->parts[$method] = isset($args['0']) ? $args['0'] : ''; - } elseif ($method == 'where') { - foreach ($args as $v) { - if (is_string($v)) { - $this->parts['where'][] = array('_string' => $v); - } elseif (is_array($v)) { - foreach ($v as $field => $var) { - $this->parts['where'][] = array($field => $var); + if (!$this->dbhand) { + //设置table则用table实例化db 否则是按照类名来实例化db + $name = $this->table ? $this->table : substr(get_class($this), 0, -5); + $this->dbhand = $this->db($name); + } + if (method_exists($this->dbhand, $method)) { + $res=call_user_func_array(array($this->dbhand, $method), $args); + if (is_subclass_of($res,'Driver_Db_Dao')) return $this; + return $res; + } + $this->response->error('未定义的model操作', $method, 'f'); + return false; + } + + public function get($table, $id, $field = '') { + $db = $this->db($table); + if ($id == 0) return null; + if (!isset(self::$_data[$table][$id])) { + // 检索memCache,不存在则读取数据库 + self::$_data[$table][$id] = $this->cache->get($table . '.' . $id); + if (self::$_data[$table][$id] === null) { + self::$_data[$table][$id] = $db->find($id); + if (self::$_data[$table][$id]) { + //其他处理 如小说的链接 + $modelclass = strtr($table, '_', '') . 'model'; + if ($this->$modelclass && method_exists($this->$modelclass, 'dataAppend')) { + self::$_data[$table][$id] = $this->$modelclass->dataAppend(self::$_data[$table][$id]); } } - } - } elseif (in_array($method, array('count', 'max', 'min', 'avg', 'sum'))) { - $this->parts['field'] = empty($args['0']) ? '*' : $args['0']; - return $this->parseCount($method); - } elseif ($method == 'data') { - $this->data = $args['0']; - } else { - halt('不具备的Model操作' . $method); - } - return $this; - } - - public function setTable($tablename) { - $this->tableName = $this->prefix . $tablename; - $this->getTableField(); - } - - // 配置解析 - public function parseConfig() { - $params = C('DB_MYSQL', null, array()); - - //分析,检测配置文件内容 - if (!is_array($params)) { - halt('数据库配置文件必须为数组'); - } - $params = array_change_key_case($params); - - //获取数据表前缀,默认为空 - $this->prefix = (isset($params['prefix']) && $params['prefix']) ? trim($params['prefix']) : ''; - - - // 指定数据库链接引擎 - $this->driver = (isset($params['driver']) && $params['driver']) ? trim($params['driver']) : 'Pdo'; - - //分析主数据库连接参数 - $config_params = array(); - if (isset($params['master']) && is_array($params['master'])) { - $config_params['master'] = $params['master']; - } else { - halt('主库数据库配置不存在'); - } - - //分析从数据库连接参数 - if (isset($params['slave']) && $params['slave']) { - $config_params['slave'] = $params['slave']; - } else { - //当没有从库连接参数时,开启单例模式 - $this->singleton = true; - $config_params['slave'] = $config_params['master']; - } - //将数据库的用户名及密码及时从内存中注销,提高程序安全性 - unset($params); - - return $config_params; - } - - /** - * @param string $id - * @return mixed - */ - public function master($id = null) { - if (self::$master) { - return self::$master[array_rand(self::$master)]; - } - $driverclass = 'Driver_Model_' . $this->driver; - foreach (self::$config['master'] as $k => $v) { - $v = array_change_key_case($v); - self::$master[$k] = new $driverclass($v); - } - if ($this->singleton) - self::$slave = self::$master; - if ($id === null) - return self::$master[array_rand(self::$master)]; - else - return self::$master[$id]; - } - - /** - * @return mixed - */ - public function slave() { - if (self::$slave) { - return self::$slave[array_rand(self::$slave)]; - } - $driverclass = 'Driver_Model_' . $this->driver; - foreach (self::$config['slave'] as $k => $v) { - $v = array_change_key_case($v); - self::$slave[$k] = new $driverclass($v); - } - if ($this->singleton) - self::$master = self::$slave; - return self::$slave[array_rand(self::$slave)]; - } - - public function getTableField($tablename = '') { - $tablename = empty($tablename) ? $this->tableName : $tablename; - if (!$tablename) { - halt('您必须设置表名后才可以使用该方法'); - } - $cachefile = $this->cachePath . '/' . $tablename . '.php'; - if (!APP_DEBUG && is_file($cachefile)) - list($this->pk, $this->fields) = include $cachefile; - else { - $pks = $fields = array(); - if ($tableInfo = (array)$this->slave()->fetchAll("SHOW FIELDS FROM {$tablename}")) { - foreach ($tableInfo as $v) { - if ($v['Key'] == 'PRI') $pks[] = strtolower($v['Field']); - $fields[] = strtolower($v['Field']); - } - $this->pk = empty($pks) ? '' : $pks['0']; - $this->fields = $fields; - if (!APP_DEBUG) { - $cacheData = array($this->pk, $this->fields); - F($cachefile, $cacheData); - } - } else { - halt('获取表' . $tablename . '信息发送错误 ' . $this->slave()->error()); - } - } - return $this->fields; - } - - public function getPk() { - if ($this->pk === null) - $this->getTableField(); - return $this->pk; - } - - /** - * @param array $data - * @param bool $replace - * @return mixed - */ - public function insert($data = array(), $replace = false) { - if (!empty($data)) $this->data = array_merge($this->data, array_change_key_case($data)); - if ($this->tableName || $this->parts['table']) { - foreach ($this->data as $k => $v) { // 过滤参数 - if (in_array($k, $this->fields)) - $this->data[$k] = $this->parseValue($v); - else - unset($this->data[$k]); - } - $fields = array_map(array($this, 'parseKey'), array_keys($this->data)); - $this->sql = ($replace ? 'REPLACE' : 'INSERT') . ' INTO ' . $this->parseTable() . '(' . implode(',', $fields) . ') VALUES (' . implode(',', $this->data) . ');'; - $this->data = $this->parts = array(); - $this->errorinfo = ''; //清空存储 - if ($this->master()->execute($this->sql)) { - return $this->master()->insertId(); - } else { - $this->errorinfo = $this->master()->errno() . ':' . $this->master()->error(); - return false; - } - } else { - halt('insert操作必须设置要操作的表'); - } - } - - /** - * @param array $data - * @return mixed - */ - public function update($data = array()) { - if (!empty($data)) $this->data = array_merge($this->data, array_change_key_case($data)); - if ($this->tableName || $this->parts['table']) { - $sets = array(); - if (!empty($this->data[$this->pk])) { //主键不允许更改 当作where条件 - $this->parts['where'][] = array($this->pk => $this->data[$this->pk]); - unset($this->data[$this->pk]); - } - if (empty($this->parts['field'])) { //通过field连贯操作限制更新的字段 - $fields = $this->fields; - } else { - $fields = is_string($this->parts['field']) ? explode(',', $this->parts['field']) : $this->parts['field']; - } - foreach ($this->data as $k => $v) { // 数据解析 - if (in_array($k, $fields)) { - $sets[] = $this->parseKey($k) . '=' . $this->parseValue($v); + $this->cache->set($table . '.' . $id, self::$_data[$table][$id], $this->config->get('cache_time', 900)); + } + } + if ($field !== '') { + if (strpos($field, '.')) { + $name = explode('.', $field); + $value = self::$_data[$table][$id]; + foreach ($name as $n) { + if (isset($value[$n])) { + $value = $value[$n]; + } else { + return null; + } } - } - $this->sql = 'UPDATE ' . $this->parseTable() . ' SET ' . implode(',', $sets) - . $this->parseWhere() - . $this->parseOrder() - . $this->parseLimit(); - $this->data = $this->parts = array(); - $this->errorinfo = ''; //清空存储 - $affectRow = $this->master()->execute($this->sql); - if ($this->master()->error()) { - $this->errorinfo = $this->master()->errno() . ':' . $this->master()->error(); - return false; - } else { - return $affectRow; - } - } else { - halt('update操作必须设置要操作的表'); - } - } - - public function delete() { - if (!empty($data)) $this->data = array_merge($this->data, array_change_key_case($data)); - if ($this->tableName || $this->parts['table']) { - $this->sql = 'DELETE FROM' . $this->parseTable() - . $this->parseWhere() - . $this->parseOrder() - . $this->parseLimit(); - $this->data = $this->parts = array(); - $this->errorinfo = ''; //清空存储 - if ($affectRow = $this->master()->execute($this->sql)) { - return $affectRow; - } else { - $this->errorinfo = $this->master()->errno() . ':' . $this->master()->error(); - return false; - } - } else { - halt('update操作必须设置要操作的表'); - } - } - - public function find($id = null) { - if (is_scalar($id)) $this->parts['where'][] = array($this->pk => $id); - $this->parts['limit'] = 1; - $this->sql = "SELECT " - . $this->parseField() . ' FROM ' - . $this->parseTable() - . $this->parseJoin() - . $this->parseWhere() - . $this->parseGroup() - . $this->parseHaving() - . $this->parseOrder() - . $this->parseLimit() - . $this->parseUnion(); - $this->data = $this->parts = array(); - $this->errorinfo = ''; //清空存储 - $row = $this->slave()->fetch($this->sql); - if (!$this->slave()->error()) { - if ($row) { - return $row; + return $value; + } elseif (strpos($field, ',')) { + //多字段获取 如"novelid,novelname" + return array_intersect_key(self::$_data[$table][$id], array_flip(explode(',', $field))); } else { - return null; - } - } else { - $this->errorinfo = $this->slave()->errno() . ':' . $this->slave()->error(); - return false; - } - } - - public function select() { - $this->sql = "SELECT " - . $this->parseField() . ' FROM ' - . $this->parseTable() - . $this->parseJoin() - . $this->parseWhere() - . $this->parseGroup() - . $this->parseHaving() - . $this->parseOrder() - . $this->parseLimit() - . $this->parseUnion(); - $this->data = $this->parts = array(); - $this->errorinfo = ''; //清空存储 - $row = $this->slave()->fetchAll($this->sql); - if (!$this->slave()->error()) { - if ($row) { - return $row; - } else { - return null; - } - } else { - $this->errorinfo = $this->slave()->errno() . ':' . $this->slave()->error(); - return false; - } - } - - public function getField($field, $isArr = false) { - if (empty($this->parts['field'])) $this->parts['field'] = $field; - if ($isArr) { - $row = $this->select(); - if ($row === false || $row === null) - return $row; - else { - $res = array(); - if ($field !== true && strpos($field, ',') === false) { - foreach ($row as $v) { - $res[] = $v[$field]; - } + //单字段 + if (isset(self::$_data[$table][$id][$field])) { + return self::$_data[$table][$id][$field]; } else { - foreach ($row as $v) { - $res[current($v)] = (count($v) == 1) ? current($v) : $v; - } + return null; } - return $res; } - } else { - $row = $this->find(); - if ($row === false || $row === null) - return $row; - elseif ($field === true) - return current($row); - elseif (isset($row[$field])) - return $row[$field]; - else - return ''; - } - } - - public function setField($field, $data) { - if (is_array($field)) { - $this->data = $field; - } elseif (is_string($field)) { - $this->data[$field] = $data; - } - $this->update(); - } - - public function setInc($field, $step = 1) { - $this->setField($field, array('exp', "{$field}+{$step}")); - } - - public function setDec($field, $step = 1) { - $this->setField($field, array('exp', "{$field}-{$step}")); - } - - /** - * 字段和表名处理添加` - * - * @access protected - * @param string $key - * @return string - */ - protected function parseKey(&$key) { - $key = trim($key); - if (!preg_match('/[,\'\"\*\(\)`.\s]/', $key)) { - $key = '`' . $key . '`'; } - return $key; + return self::$_data[$table][$id]; } - /** - * value分析 - * - * @access protected - * @param mixed $value - * @return string - */ - protected function parseValue($value) { - if (is_string($value)) { - $value = '\'' . $this->master()->escapeString($value) . '\''; - } elseif (isset($value[0]) && is_string($value[0]) && strtolower($value[0]) == 'exp') { - $value = $this->master()->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; - } - - public function getLastSql() { - return $this->sql; - } - - public function getError() { - return $this->errorinfo; - } - - protected function parseWhere() { - if (empty($this->parts['where'])) return ' WHERE 1'; - return ' WHERE ' . $this->parseWhereCondition($this->parts['where']); - } - - protected function parseWhereCondition($condition) { - $logic = ' AND '; - $wheres = array(); - foreach ($condition as $var) { - $k = key($var); - $v = current($var); - if (in_array($k, $this->fields)) { - $wheres[] = '(' . $this->parseWhereItem($this->parseKey($k), $v) . ')'; - } elseif ($k == '_logic' && in_array(strtolower($v), array('or', 'and', 'xor'))) { - $logic = ' ' . strtoupper($v) . ' '; - } elseif ($k == '_string') { - $wheres[] = '(' . $v . ')'; - } else { - } - } - return implode($logic, $wheres); - } - - /** - * @param $field - * @param $var - * @return mixed - */ - protected function parseWhereItem($field, $var) { - if (is_array($var)) { - switch (strtolower($var['0'])) { - case '>': - case '<': - case '>=': - case '<=': - case '=': - case '<>': - case 'like': - case 'not like': - return $field . ' ' . $var['0'] . ' ' . $this->parseValue($var['1']); - case 'in': - case 'not in': - if (is_array($var['1'])) - $var['1'] = implode(',', $var['1']); - return "{$field} {$var['0']} ( {$var['1']} )"; - case 'between': - case 'not between': - if (is_string($var['1'])) - $var['1'] = explode(',', $var['1']); - return "{$field} {$var['0']} {$var['1']['0']} and {$var['1']['1']}"; - case 'exp': - return "{$field} {$var['1']}"; - default: - return ''; - } - } else { - return $field . ' = ' . $this->parseValue($var); - } - } - - protected function parseOrder() { - if (!empty($this->parts['order'])) { - if (is_string($this->parts['order'])) { - return ' ORDER BY ' . $this->parts['order']; - } - } - return ''; - } - - protected function parseGroup() { - if (!empty($this->parts['group'])) { - if (is_string($this->parts['group'])) { - return ' GROUP BY ' . $this->parseKey($this->parts['group']); - } elseif (is_array($this->parts['group'])) { - array_walk($this->parts['group'], array($this, 'parseKey')); - return ' GROUP BY ' . implode(',', $this->parts['group']); - } - } - return ''; - } - - protected function parseHaving() { - if (empty($this->parts['having'])) return ''; - return ' HAVING ' . $this->parseWhereCondition($this->parts['having']); - } - - protected function parseLimit() { - if (isset($this->parts['page'])) { - // 根据页数计算limit - if (strpos($this->parts['page'], ',')) { - list($page, $listRows) = explode(',', $this->parts['page']); - } else { - $page = $this->parts['page']; - } - $page = $page ? $page : 1; - $listRows = isset($listRows) ? $listRows : (is_numeric($this->parts['limit']) ? $this->parts['limit'] : 20); - $offset = $listRows * ((int)$page - 1); - return ' LIMIT ' . $offset . ',' . $listRows; - } elseif (!empty($this->parts['limit'])) { - return ' LIMIT ' . $this->parts['limit']; + public function set($table, $id, $data) { + $db = $this->db($table); + if ($db->where(array($db->getPk() => $id))->update($data)) { + return $this->rm($table, $id); } else { - return ''; - } - } - - protected function parseUnion() { - - } - - protected function parseJoin() { - - } - - protected function parseField() { - if (empty($this->parts['field'])) { - return '*'; - } else { - if (is_string($this->parts['field'])) { - $this->parts['field'] = explode(',', $this->parts['field']); - } - array_walk($this->parts['field'], array($this, 'parseKey')); - return implode(',', $this->parts['field']); - } - } - - protected function parseTable() { - if (empty($this->parts['table'])) { - if ($this->tableName) - return $this->parseKey($this->tableName); - else - halt('必须设置表才可以进行此操作'); - } else { - return str_replace('!@#_', self::$config['prefix'], $this->parts['table']); + return false; } } - protected function parseDistinct() { - return $this->parts['distinct'] ? ' DISTINCT ' : ''; - } - - public function parseCount($method) { - $this->parts['field'] = "{$method}({$this->parts['field']}) as pt_num"; - return $this->getField('pt_num'); - } - - public function start() { - $this->master(0)->startTrans(); - } - - public function commit() { - $this->master(0)->commit(); - } - - public function rollback() { - $this->master(0)->rollback(); - } - - public function fetch($sql) { - return $this->slave()->fetch($sql); - } - - public function fetchall($sql) { - return $this->slave()->fetchall($sql); + public function rm($table, $id) { + $this->cache->rm($table . '.' . $id); + unset(self::$_data[$table][$id]); + return true; } - -} - +} \ No newline at end of file diff --git a/ptcms/core/plugin.php b/ptcms/core/plugin.php index f91f88c..9b6c8c9 100644 --- a/ptcms/core/plugin.php +++ b/ptcms/core/plugin.php @@ -5,11 +5,15 @@ * @Email : admin@ptcms.com * @File : plugin.php */ -class plugin { +class PT_Plugin extends PT_Base { - public $tag = ''; + protected $pt; + //子类hook点 public static $_tags = array(); + public function __construct() { + $this->pt=PT_Base::getInstance(); + } /** * 调用插件 * @@ -83,6 +87,10 @@ public static function get($tag = '') { } } + /** + * 获取开启的所有的插件 + * @return array + */ public static function getlist() { $list = array(); foreach (self::$_tags as $v) { @@ -91,50 +99,19 @@ public static function getlist() { return array_unique($list); } - /** - * 安装插件 - */ - public function install() { - $name = substr(get_class($this), 0, -6); - if ($this->checkstatus($name)) { - return 0; - } elseif ($this->tag == '') { - return -1; - } - self::add($this->tag, $name); - $config = include APP_PATH . '/common/config.php'; - $config['plugin'] = self::$_tags; - F(APP_PATH . '/common/config.php', $config); - return 1; - } - - // 卸载插件 - public function uninstall() { - $name = substr(get_class($this), 0, -6); - if (!$this->checkstatus($name)) { - return 0; - } elseif ($this->tag == '') { - return -1; - } - self::del($this->tag, substr(get_class($this), 0, -6)); - $config = include APP_PATH . '/common/config.php'; - $config['plugin'] = self::$_tags; - F(APP_PATH . '/common/config.php', $config); - return 1; - } - - // 检查插件是否被安装 - public function checkstatus($plugin) { - if (substr($plugin, -4) == '.php') $plugin = substr($plugin, 0, -4); - foreach (self::$_tags as $tag) { - if (in_array($plugin, $tag)) return true; - } - return false; - } // 返回插件的配置项 - public function getconfig($key) { + public function loadconfig() { $name = substr(get_class($this), 0, -6); - return C('plugin_config.' . $name . '.' . $key); + $list=pt::import(APP_PATH.'/common/plugin/'.$name.'/config.php'); + if ($list){ + $config=array(); + foreach($list as $v){ + $config[$v['key']]=$v['value']; + } + $this->pt->config->set(array('pluginconfig'=>$config)); + return $config; + } + return array(); } } \ No newline at end of file diff --git a/ptcms/core/request.php b/ptcms/core/request.php new file mode 100644 index 0000000..ed00354 --- /dev/null +++ b/ptcms/core/request.php @@ -0,0 +1,109 @@ + 15 && $i[1] < 32) || ($i[0] == 192 && $i[1] == 168)) { + //如果是内网ip重新获取 + $keys = array('HTTP_X_FORWARDED_FOR', 'HTTP_CLIENT_IP'); + foreach ($keys as $key) { + if (empty($_SERVER[ $key ])) continue; + $ips = explode(',', $_SERVER[ $key ], 1); + $ip = $ips[0]; + break; + } + } + $l = ip2long($ip); + if ((false !== $l) && ($ip === long2ip($l))) return $ip; + return $default; + } + + /** + * 获取host + * @param null $domain + * @return mixed|null|string + */ + public static function getSiteCode($domain = null) { + $domain = ($domain!==null) ? parse_url($domain,PHP_URL_HOST) : $_SERVER['HTTP_HOST']; + // 替换域名中的-为_ + $domain = str_replace('-', '_', $domain); + // 去掉端口 + if (strpos($domain, ':') !== false) $domain = substr($domain, 0, strpos($domain, ':')); + // 去掉开始的www. + if (stripos($domain, 'www.') === 0) $domain = substr($domain, 4); + return $domain; + } +} \ No newline at end of file diff --git a/ptcms/core/response.php b/ptcms/core/response.php new file mode 100644 index 0000000..9d9696f --- /dev/null +++ b/ptcms/core/response.php @@ -0,0 +1,215 @@ +config->get('gzip_encode', false)) { + $zlib = ini_get('zlib.output_compression'); + if (empty($zlib)) ob_start('ob_gzhandler'); + } + if (!headers_sent()) { + //设置系统的输出字符为utf-8 + header("Content-Type: $mimeType; charset=utf-8"); + //支持页面回跳 + header("Cache-control: private"); + //版权标识 + header("X-Powered-By: PTcms Studio (www.ptcms.com)"); + } + } + + public function setBody($content = '', $mimeType = 'text/html') { + if (!headers_sent()) { + $this->setHeader($mimeType); + } + echo $content; + } + + public function disableRender() { + $this->autoRender = false; + } + + public function enableRender() { + $this->autoRender = true; + } + + public function isAutoRender() { + return $this->autoRender; + } + + + public function jsonEncode($data, $format = 0) { + if (APP_DEBUG && $format == 0) { + $format = JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE; + } + return json_encode($data, $format); + } + + public function jsonpEncode($data, $format = 0) { + if (APP_DEBUG && $format == 0) { + $format = JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE; + } + $callback = $this->input->get($this->config->get('jsonp_callback'), 'en', 'ptcms_jsonp'); + return $callback . '(' . json_encode($data, $format) . ');'; + } + + /** + * XML编码 + * + * @param mixed $data 数据 + * @param string $root 根节点名 + * @param string $attr 根节点属性 + * @param string $encoding 数据编码 + * @return string + */ + public function xmlEncode($data, $root = 'ptcms', $attr = '', $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 .= $this->dataToXml($data); + $xml .= ""; + return preg_replace('/[\x00-\x1f]/', '', $xml); + } + + public function error($msg = '找不到指定的页面', $level = 'f') { + if (APP_DEBUG) { + halt($msg); + } else { + if ($level != 'f') { + $this->controller->error($msg, 0, 0); + } else { + $this->error($msg, '', 0); + $file = PT_ROOT . '/' . $this->config->get('404file', '404.html'); + $this->log->write($msg); + if (is_file($file)) { + $content = F($file); + $content = str_replace(array('{$sitename}', '{$siteurl}', '{$msg}'), array($this->config->get('sitename', 'PTCMS FrameWork'), $this->config->get('siteurl', PT_URL), $msg), $content); + exit($content); + } else { + exit($msg . ' 页面出现错误,如需自定义此错误,请创建文件:' . $file); + } + } + } + exit; + } + + public function _empty($msg) { + if (APP_DEBUG) { + $this->error($msg, '', 0); + } else { + halt($msg); + } + } + + public function redirect($url, $type = 302) { + if ($type == 302) { + header('HTTP/1.1 302 Moved Temporarily'); + header('Status:302 Moved Temporarily'); // 确保FastCGI模式下正常 + } else { + header('HTTP/1.1 301 Moved Permanently'); + header('Status:301 Moved Permanently'); + } + header('Location: ' . $url); + exit; + } + + public function runinfo() { + if ($this->config->get('is_gen_html')) return ''; + $tpl = $this->config->get('runinfo', 'Power by PTCMS, Processed in {time}(s), Memory usage: {mem}MB.'); + $from[] = '{time}'; + $to[] = number_format(microtime(true) - $GLOBALS['_startTime'], 3); + $from[] = '{mem}'; + $to[] = number_format((memory_get_usage() - $GLOBALS['_startUseMems']) / 1024 / 1024, 3); + if (strpos($tpl, '{net}')) { + $from[] = '{net}'; + $to[] = $GLOBALS['_apinum']; + } + if (strpos($tpl, '{file}')) { + $from[] = '{file}'; + $to[] = count(get_included_files()); + } + if (strpos($tpl, '{sql}')) { + $from[] = '{sql}'; + $to[] = $GLOBALS['_sqlnum']; + } + if (strpos($tpl, '{cacheread}')) { + $from[] = '{cacheread}'; + $to[] = $GLOBALS['_cacheRead']; + } + if (strpos($tpl, '{cachewrite}')) { + $from[] = '{cachewrite}'; + $to[] = $GLOBALS['_cacheWrite']; + } + $runtimeinfo = str_replace($from, $to, $tpl); + return $runtimeinfo; + } + + + /** + * 数据XML编码 + * + * @param mixed $data 数据 + * @param string $parentkey + * @return string + */ + protected function dataToXml($data, $parentkey = '') { + $xml = ''; + foreach ($data as $key => $val) { + if (is_numeric($key)) { + $key = $parentkey; + } + $xml .= "<{$key}>"; + if (is_array($val) || is_object($val)) { + $len = strlen("<{$key}>"); + $con = $this->dataToXml($val, $key); + if (strpos($con, "<{$key}>") === 0) { + $con = substr($con, $len, -($len + 1)); + } + $xml .= $con; + } elseif (strlen($val) > 150 || preg_match('{[<>&\'|"]+}', $val)) { + $xml .= ''; + } else { + $xml .= $val; + } + $xml .= ""; + } + return $xml; + } + + /** + * 下载文件 + * @param $con + * @param $name + * @param string $type + */ + public function download($con, $name, $type = 'file') { + $length = ($type == 'file') ? filesize($con) : strlen($con); + header("Content-type: application/octet-stream"); + header("Accept-Ranges: bytes"); + header("Content-Length: " . $length); + header('Pragma: cache'); + header('Cache-Control: public, must-revalidate, max-age=0'); + header('Content-Disposition: attachment; filename="' . urlencode($name) . '.txt"; charset=utf-8'); //下载显示的名字,注意格式 + header("Content-Transfer-Encoding: binary "); + if ($type == 'file') { + readfile($con); + } else { + echo $con; + } + } + + +} \ No newline at end of file diff --git a/ptcms/core/session.php b/ptcms/core/session.php new file mode 100644 index 0000000..153c593 --- /dev/null +++ b/ptcms/core/session.php @@ -0,0 +1,123 @@ +pt=PT_Base::getInstance(); + } + + public function start($name=array()) { + $name=array_merge($this->pt->config->get('session',array()),$name); + if ($this->pt->config->get('var_session_id') && isset($_REQUEST[$this->pt->config->get('var_session_id')])) { + session_id($_REQUEST[$this->pt->config->get('var_session_id')]); + } elseif (isset($name['id'])) { + session_id($name['id']); + } + if (empty($name['type']) && $this->pt->config->get('driver_session')){ + $name['type']=$this->pt->config->get('driver_session'); + } + 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']); + 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'])){ + $type = $name['type']; + $class = 'Driver_Session_'.$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_start(); + } + + public function __set($name,$value) { + return $this->set($name,$value); + } + + public function __get($name) { + return $this->get($name); + } + + public function get($name='', $default = null) { + if ($name=='') return $_SESSION; + //数组模式 找到返回 + if (strpos($name,'.')){ + //数组模式 找到返回 + $c = $_SESSION; + $fields = explode('.', $name); + foreach($fields as $field){ + if(!isset($c[$field])) return $default; + $c = $c[$field]; + } + return $c; + }elseif (isset($_SESSION[$name])) { + return $_SESSION[$name]; + } else { + return $default; + } + } + + public function set($key, $value = '') { + $_SESSION[$key] = $value; + return true; + } + + public function rm($key) { + if (!isset($_SESSION[$key])) { + return false; + } + + unset($_SESSION[$key]); + + return true; + } + + /** + * 清空session值 + * + * @access public + * @return void + */ + public static function clear() { + + $_SESSION = array(); + } + + /** + * 注销session + * + * @access public + * @return void + */ + public static function destory() { + + if (session_id()) { + unset($_SESSION); + session_destroy(); + } + } + + /** + * 当浏览器关闭时,session将停止写入 + * + * @access public + * @return void + */ + public static function close() { + + if (session_id()) { + session_write_close(); + } + } +} \ No newline at end of file diff --git a/ptcms/core/storage.php b/ptcms/core/storage.php index 0cd5177..a9f43f2 100644 --- a/ptcms/core/storage.php +++ b/ptcms/core/storage.php @@ -5,20 +5,21 @@ * @Email : admin@ptcms.com * @File : Storage.php */ -class Storage { +class PT_Storage extends PT_Base { protected static $handler = null; /** + * @param string $type * @return Driver_Storage_File */ - static public function getInstance() { - $key = C('storage_type', null, 'file') . '_' . C('storage_path', null, 'storage'); - if (empty(self::$handler[$key])) { - $class = 'Driver_Storage_' . C('storage_type'); - self::$handler[$key] = new $class(C('storage_option', null, array())); + static public function getInstance($type = '') { + $type = $type ? $type : PT_Base::getInstance()->config->get('storage_type', 'file') . '_' . PT_Base::getInstance()->config->get('storage_path', 'storage'); + if (empty(self::$handler[$type])) { + $class = 'Driver_Storage_' . PT_Base::getInstance()->config->get('storage_type'); + self::$handler[$type] = new $class(PT_Base::getInstance()->config->get('storage_option', array())); } - return self::$handler[$key]; + return self::$handler[$type]; } public static function exist($file) { @@ -49,6 +50,10 @@ public static function getUrl($file) { return self::getInstance()->getUrl($file); } + public static function getPath($file) { + return self::getInstance()->getPath($file); + } + public static function error() { return self::getInstance()->error(); } diff --git a/ptcms/core/view.php b/ptcms/core/view.php index 2fffabb..6682998 100644 --- a/ptcms/core/view.php +++ b/ptcms/core/view.php @@ -5,44 +5,63 @@ * @Email : admin@ptcms.com * @File : view.php */ -class View { +class PT_View { // 模板存储变量 protected $_tpl_vars = array(); // 模版基地址 - protected $tplpath; - // 模版路径 - protected $tplFile; + protected $tplpath = TPL_PATH; + // 模版文件名 + protected $tplfile = ''; + // 模版全路径 + protected $tplfilepath = ''; // 模版 protected $theme = ''; + protected $pt; public function __construct() { - $this->tplpath = TPL_PATH; + $this->pt=PT_Base::getInstance(); + PT_Plugin::call('view_start'); + //初始化模版 + $this->getTheme(); } + public function setFile($file) { + $this->tplfile = $file; + } + + public function setPath($path) { + $this->tplpath = $path; + } + + /** + * 获取风格 + * + * @return mixed|string + */ public function getTheme() { //设置了默认模版名 - $this->theme = C('tpl_theme', null, 'default'); + $this->theme = $this->pt->config->get('tpl_theme', 'default'); if ($this->theme) { //值不为空 则为自动侦测目录 if (isset($_GET['t'])) { $auto = $_GET['t']; - cookie('THEME_' . MODULE_NAME, $auto, 25920000); - } elseif (cookie('THEME_' . MODULE_NAME)) { - $auto = cookie('THEME_' . MODULE_NAME); + $this->pt->cookie->set('THEME_' . MODULE_NAME, $auto, 25920000); + } elseif ($this->pt->cookie->get('THEME_' . MODULE_NAME)) { + $auto = $this->pt->cookie->get('THEME_' . MODULE_NAME); } if (isset($auto)) { if (is_dir($this->tplpath . '/' . $auto)) { $this->theme = $auto; - C('tpl_theme', $this->theme); + $this->pt->config->set('tpl_theme', $this->theme); } else { - cookie('THEME_' . MODULE_NAME, null); + $this->pt->cookie->del('THEME_' . MODULE_NAME); } } //读取模版配置文件 if ($tplconfig = pt::import($this->tplpath . '/' . $this->theme . '/config.php')) { foreach ($tplconfig as $k => $v) { - C("tplconfig.{$k}", $v['value']); + $this->pt->config->set("tplconfig.{$k}", $v['value']); } } } @@ -50,31 +69,33 @@ public function getTheme() { } /** - * 模板变量赋值 + * 模板变量赋值,支持连贯操作 * * @access public * @param mixed $var * @param mixed $value - * @return void + * @return PT_View */ - public function assign($var, $value = null) { + public function set($var, $value = null) { if (is_array($var)) { $this->_tpl_vars = array_merge($this->_tpl_vars, $var); } else { $this->_tpl_vars[$var] = $value; } + return $this; } /* * 获取模板变量值 */ - public function getassign($var) { + public function get($var = '') { + if ($var == '') return $this->_tpl_vars; if (isset($this->_tpl_vars[$var])) return $this->_tpl_vars[$var]; if (strpos($var, '.') !== false) { $arr = explode('.', $var); $tmp = $this->_tpl_vars; foreach ($arr as $v) { - if (substr($v, 0, 1) === '$') $v = $this->getassign($v); + if (substr($v, 0, 1) === '$') $v = $this->get($v); $tmp = $tmp[$v]; } if (!empty($tmp)) { @@ -84,6 +105,18 @@ public function getassign($var) { return null; } + public function __set($name, $var) { + if (!is_object($var)) return $this->set($name, $var); + return false; + } + + public function __get($name) { + if (isset($this->_tpl_vars[$name])){ + return $this->_tpl_vars[$name]; + } + return null; + } + /** * 加载并视图片段文件内容 * @@ -93,8 +126,8 @@ public function getassign($var) { * @param string $theme 所属模版 * @return string */ - public function render($tpl = null, $module = null, $theme = null) { - $this->tplFile = $this->getTplFile($tpl, $module, $theme); + public function fetch($tpl = null, $module = null, $theme = null) { + $this->tplfilepath = $this->getTplFile($tpl, $module, $theme); extract($this->_tpl_vars, EXTR_OVERWRITE); ob_start(); include $this->checkCompile(); @@ -112,358 +145,100 @@ public function render($tpl = null, $module = null, $theme = null) { * @return string */ protected function getTplFile($tpl, $module = null, $theme = null) { - $theme = ($theme === null) ? $this->theme : $theme; + $tpl = ($tpl === null) ? $this->tplfile : $tpl; + $theme = ($theme === null) ? $this->theme : $theme; $module = ($module === null) ? MODULE_NAME : $module; if (substr($tpl, 0, 1) === '/') { //绝对目录 可以设置模版 $tplfile = PT_ROOT . $tpl; - $tmpl = $this->tplpath . "/{$theme}/" . C("tpl_public", null, 'public'); + $tmpl = $this->tplpath . "/{$theme}/" . $this->pt->config->get("tpl_public", 'public'); } else { - if ($tpl == '') { + if (!$tpl) { $tpl = CONTROLLER_NAME . '_' . ACTION_NAME; } //判断模版目录 - $protect = C('tpl_protect', null, ''); - $suffix = C('tpl_suffix', null, 'html'); + $protect = $this->pt->config->get('tpl_protect', ''); + $suffix = $this->pt->config->get('tpl_suffix', 'html'); if ($theme) { // 设置了模版 模版目录为template下对应的设置的模版目录 - $tplfile = $this->tplpath . "/{$theme}/{$module}/{$protect}/{$tpl}.{$suffix}"; + $tplfile = rtrim($this->tplpath . "/{$theme}/{$module}/{$protect}", '/') . "/{$tpl}.{$suffix}"; if (!is_file($tplfile)) { //没有找到的模版默认使用default匹配一次 if (is_file($this->tplpath . "/{$theme}/{$module}/{$tpl}.{$suffix}")) { //去掉保护目录 $tplfile = $this->tplpath . "/{$theme}/{$module}/{$tpl}.{$suffix}"; - log::record('指定的模版(' . $tplfile . ')不存在,尝试使用' . $tplfile . '模版成功'); + $this->log->record('指定的模版(' . $tplfile . ')不存在,尝试使用' . $tplfile . '模版成功'); } elseif ($theme !== 'default' && is_file($this->tplpath . "/default/{$module}/{$tpl}.{$suffix}")) { //使用默认模版 - log::record('指定的模版(' . $tplfile . ')不存在,尝试使用默认模版成功'); + $this->log->record('指定的模版(' . $tplfile . ')不存在,尝试使用默认模版成功'); $tplfile = $this->tplpath . "/default/{$module}/{$tpl}.{$suffix}"; - $theme = 'default'; + $theme = 'default'; } } - $tmpl = $this->tplpath . "/{$theme}/" . C("tpl_public", null, 'public'); + $tmpl = $this->tplpath . "/{$theme}/" . $this->pt->config->get("tpl_public", 'public'); } else { //未设置模版 模版目录为对应模块的view目录 - if ($module == 'plugin') { - $tplfile = APP_PATH . "/common/plugin/" . CONTROLLER_NAME . "/view/" . ACTION_NAME . ".{$suffix}"; - } else { - $tplfile = APP_PATH . "/{$module}/view/{$tpl}.{$suffix}"; - } - $tmpl = APP_PATH . "/{$module}/view/"; + $tplfile = APP_PATH . "/{$module}/view/{$tpl}.{$suffix}"; + $tmpl = APP_PATH . "/{$module}/view/"; } } $realtpl = str_replace('\\', '/', realpath($tplfile)); if (!$realtpl) { - halt("模版{$tpl}不存在:" . $tplfile); + if (APP_DEBUG){ + halt("模版{$tpl}不存在:" . $tplfile); + }else{ + $this->pt->response->error("模版{$tpl}不存在"); + } } defined('__TMPL__') || define('__TMPL__', rtrim(PT_DIR . str_replace(PT_ROOT, '', $tmpl), '/')); return $realtpl; } - // 校验编译模板 + /** + * @return string + */ protected function checkCompile() { - $tplfile = ltrim(str_replace(array(PT_ROOT, '/application/', '/template/'), '/', $this->tplFile), '/'); + $tplfile = ltrim(str_replace(array(PT_ROOT, '/application/', '/template/'), '/', $this->tplfilepath), '/'); $compiledFile = CACHE_PATH . '/template/' . substr(str_replace('/', ',', $tplfile), 0, -5) . '.php'; - if (APP_DEBUG || !is_file($compiledFile) || filemtime($compiledFile) < filemtime($this->tplFile)) { + if (APP_DEBUG || !is_file($compiledFile) || filemtime($compiledFile) < filemtime($this->tplfilepath)) { // 获取模版内容 - $content = F($this->tplFile); - plugin::call('template_compile_start', $content); + $content = F($this->tplfilepath); + $this->pt->plugin->call('template_compile_start', $content); + $driverclass = 'Driver_View_' . $this->pt->config->get('view_driver', 'Mc'); + /* @var $driver Driver_view_MC */ + $driver = new $driverclass(); // 解析模版 - $content = $this->compile($content); + $content = $driver->compile($content); //判断是否开启layout - if (C('LAYOUT', null, false)) { - $includeFile = $this->getTplFile(C('LAYOUT_NAME', null, 'layout')); - $layout = $this->compile(F($includeFile)); - $content = str_replace('__CONTENT__', $content, $layout); + if ($this->pt->config->get('layout', false)) { + $includeFile = $this->getTplFile($this->pt->config->get('layout_name', 'layout')); + $layout = $driver->compile(F($includeFile)); + $content = str_replace('__CONTENT__', $content, $layout); } $content = '' . $this->replace($content); - plugin::call('template_compile_end', $content); + $this->pt->plugin->call('template_compile_end', $content); F($compiledFile, $content); } return $compiledFile; } - // css压缩 - public function compressCss($match) { - return ''; - } - - // js压缩 - public function compressJs($march) { - return str_replace($march['1'], compressJs($march['1']), $march['0']); - } - // 模版输出替换 protected function replace($content) { $replace = array( - '__TMPL__' => '', // 项目模板目录 - '__ROOT__' => '', // 当前网站地址 - '__APP__' => '', // 当前项目地址 - '__MODULE__' => '', - '__ACTION__' => '', // 当前操作地址 - '__SELF__' => '', // 当前页面地址 - '__URL__' => '', // 当前控制器地址 - '__PUBLIC__' => '' . '/public', // 站点公共目录 - '__RUNINFO__' => '', // 站点公共目录 + '__TMPL__' => '', // 项目模板目录 + '__ROOT__' => '', // 当前网站地址 + '__APP__' => '', // 当前项目地址 + '__MODULE__' => '', + '__ACTION__' => '', // 当前操作地址 + '__SELF__' => '', // 当前页面地址 + '__URL__' => '', // 当前控制器地址 + '__PUBLIC__' => '' . '/public', // 站点公共目录 + '__RUNINFO__' => 'pt->response->runinfo();?>', // 站点公共目录 ); - // 允许用户自定义模板的字符串替换 - $content = str_replace(array_keys($replace), array_values($replace), $content); - // 特定替换 + $content = strtr($content, $replace); // 判断是否显示runtime info 信息 return $content; } - // 编译解析 - public function compile($content) { - $left = preg_quote('{', '/'); - $right = preg_quote('}', '/'); - if (!preg_match('/' . $left . '.*?' . $right . '/s', $content)) return $content; - // 解析载入 - $content = preg_replace_callback('/' . $left . 'include\s+file\s*\=\s*(\'|\")([^\}]*?)\1\s*' . $right . '/i', array('self', 'parseInlcude'), $content); - // 解析代码 - $content = preg_replace_callback('/' . $left . '(code|php)' . $right . '(.*?)' . $left . '\/\1' . $right . '/is', array('self', 'parseEncode'), $content); - // 模板注释 - $content = preg_replace('/' . $left . '\/\*.*?\*\/' . $right . '/s', '', $content); - $content = preg_replace('/' . $left . '\/\/.*?' . $right . '/', '', $content); - // 解析变量 - $content = preg_replace_callback('/' . $left . '(\$\w+(?:(?:\[(?:[^\[\]]+|(?R))*\])*|(?:\.[\w\-]+)*))((?:\s*\|\s*[\w\:]+(?:\s*=\s*(?:@|"[^"]*"|\'[^\']*\'|#[\w\-]+|\$[\w\-]+(?:(?:\[(?:[^\[\]]+|(?R))*\])*|(?:\.[\w\-]+)*)|[^\|\:,"\'\s]*?)(?:\s*,\s*(?:@|"[^"]*"|\'[^\']*\'|#[\w\-]+|\$[\w\-]+(?:(?:\[(?:[^\[\]]+|(?R))*\])*|(?:\.[\w\-]+)*)|[^\|\:,"\'\s]*?))*)?)*)\s*' . $right . '/', array('self', 'parseVariable'), $content); - // 解析函数 - $content = preg_replace_callback('/' . $left . '(\=|~)\s*(.+?)\s*' . $right . '/', array('self', 'parseFunction'), $content); - // 解析判断 - $content = preg_replace_callback('/' . $left . '(if|else\s*if)\s+(.+?)\s*' . $right . '/', array('self', 'parseJudgment'), $content); - $content = preg_replace('/' . $left . 'else\s*' . $right . '/i', '', $content); - $content = preg_replace('/' . $left . 'sectionelse\s*' . $right . '/i', '', $content); - $content = preg_replace('/' . $left . '\/if\s*' . $right . '/i', '', $content); - // 解析链接 - $content = preg_replace_callback('/' . $left . 'link\=((?:"[^"]*"|\'[^\']*\'|#\w+|\$\w+(?:(?:\[(?:[^\[\]]+|(?R))*\])*|(?:\.\w+)*)|[^"\'\s]+?)(?:(?:\s+\w+\s*\=\s*(?:"[^"]*"|\'[^\']*\'|#\w+|\$\w+(?:(?:\[(?:[^\[\]]+|(?R))*\])*|(?:\.\w+)*)|[^"\'\s]+?))*?))\s*' . $right . '/i', array('self', 'parseLink'), $content); - // 解析微件 - $content = preg_replace_callback('/' . $left . 'block((?:\s+\w+\s*\=\s*(?:"[^"]*"|\'[^\']*\'|#\w+|\$\w+(?:(?:\[(?:[^\[\]]+|(?R))*\])*|(?:\.\w+)*)|[^"\'\s]+?))+)\s*' . $right . '/i', array('self', 'parseBlock'), $content); - // 解析循环 - $content = preg_replace_callback('/' . $left . 'loop\s*=([\'|"]?)(\$?\w+(?:(?:\[(?:[^\[\]]+|(?R))*\])*|(?:\.\w+)*))\1\s*' . $right . '/i', array('self', 'parseLoop'), $content); - $content = preg_replace_callback('/' . $left . 'loop' . $right . '/i', array('self', 'parseLoop'), $content); - $content = preg_replace_callback('/' . $left . 'section((?:\s+\w+\s*\=\s*(?:"[^"]*"|\'[^\']*\'|#\w+|\$\w+(?:(?:\[(?:[^\[\]]+|(?R))*\])*|(?:\.\w+)*)|[^"\'\s]+?))+)\s*' . $right . '/i', array('self', 'parseSection'), $content); - $content = preg_replace('/' . $left . '\/(?:loop|section)\s*' . $right . '/i', '', $content); - // 解析标题 - $content = preg_replace('/(]*>.*?]*>.*?]*>.+?)(?=<\/title[^>]*>.*?<\/head[^>]*>)/is', '\1 - ' . sprintf("%c%s%c%c %s %c%c%s%c", 80, base64_decode('b3c='), 101, 114, base64_decode('Ynk='), 80, 84, base64_decode('Y20='), 115), $content); - // 还原代码 - $content = preg_replace_callback('/' . chr(2) . '(.*?)' . chr(3) . '/', array('self', 'parseDecode'), $content); - // 内容后续处理 - - if (!APP_DEBUG) { -// $content = preg_replace_callback('/]*>([^<]*)<\/style>/isU', array('self', 'compressCss'), $content); -// $content = preg_replace_callback('/]*>([^<]+?)<\/script>/isU', array('self', 'compressJs'), $content); -// $content = preg_replace(array("/>\s+ <'), $content); - $content = preg_replace('/\?>\s*<\?php/', '', $content); -// $content = str_replace(array("\r\n", "\r", "\n", "\t", ' ', ' '), ' ', $content); - $content = strip_whitespace($content); - } - // 返回内容 - return $content; - } - - // 解析变量名 - private function parseVar($var) { - $var = strtolower(is_array($var) ? reset($var) : trim($var)); - if (substr($var, 0, 1) !== '$') $var = '$' . $var; - if (preg_match('/^\$\w+(\.[\w\-]+)+$/', $var)) { - if (substr($var, 0, 4) === '$pt.') { - $vars = array_pad(explode('.', $var, 3), 3, ''); - switch ($vars[1]) { - case 'server': - $var = '$_SERVER[\'' . strtoupper($vars[2]) . '\']'; - break; - case 'const': - $var = strtoupper($vars[2]); - break; - case 'config': - $var = 'C("' . $vars[2] . '")'; - break; - case 'get': - $var = '$_GET[\'' . $vars[2] . '\']'; - break; - case 'post': - $var = '$_POST[\'' . $vars[2] . '\']'; - break; - case 'request': - $var = '$_REQUEST[\'' . $vars[2] . '\']'; - break; - case 'cookie': - $var = 'Cookie("' . $vars[2] . '")'; - break; - case 'getad': - // 当广告js存在时才会解析出来 否则不会解析 - if (is_file(PT_ROOT . "/public/" . C('addir') . "/" . $vars[2] . ".js")) { - $var = "''"; - } else { - $var = '""'; - } - break; - default: - $var = strtoupper($vars[1]); - break; - } - } else { - $var = preg_replace('/\.(\w+)/', '[\'\1\']', $var); - } - } - return $var; - } - - /** - * @param $string - * @param $format - * @return array - * $format中值true则按照变量解析 其他为默认值 - */ - private function parseAttribute($string, $format) { - $attribute = array('_etc' => array()); - preg_match_all('/(?:^|\s+)(\w+)\s*\=\s*(?|(")([^"]*)"|(\')([^\']*)\'|(#)(\w+)|(\$)(\w+(?:(?:\[(?:[^\[\]]+|(?R))*\])*|(?:\.\w+)*))|()([^"\'\s]+?))(?=\s+\w+\s*\=|$)/', $string, $match); - foreach ($match[0] as $key => $value) { - $name = strtolower($match[1][$key]); - $value = trim($match[3][$key]); - if (isset($format[$name]) && is_bool($format[$name])) { - $attribute[$name] = $format[$name] ? self::parseVar($value) : $value; - } else { - switch ($match[2][$key]) { - case '#': - $value = strtoupper($value); - break; - case '$': - $value = self::parseVar($value); - break; - case '"': - case '\'': - $value = $match[2][$key] . $value . $match[2][$key]; - break; - default: - $value = is_numeric($value) ? $value : var_export($value, true); - } - if (isset($format[$name])) { - $attribute[$name] = $value; - } else { - $attribute['_etc'][$name] = $value; - } - } - } - return array_merge($format, $attribute); - } - - // 解析变量 - private function parseVariable($matches) { - $variable = self::parseVar($matches[1]); - if ($matches[2]) { - preg_match_all('/\s*\|\s*([\w\:]+)(\s*=\s*(?:@|"[^"]*"|\'[^\']*\'|#\w+|\$\w+(?:(?:\[(?:[^\[\]]+|(?R))*\])*|(?:\.\w+)*)|[^\|\:,"\'\s]*?)(?:\s*,\s*(?:@|"[^"]*"|\'[^\']*\'|#\w+|\$\w+(?:(?:\[(?:[^\[\]]+|(?R))*\])*|(?:\.\w+)*)|[^\|\:,"\'\s]*?))*)?(?=\||$)/', $matches[2], $match); - foreach ($match[0] as $key => $value) { - $function = $match[1][$key]; - if (strtolower($function) == 'parsetpl') { - return ""; - } elseif (in_array($function, array('date', 'default'))) { - $function .= 'var'; - } - $param = array($variable); - preg_match_all('/(?:=|,)\s*(?|(@)|(")([^"]*)"|(\')([^\']*)\'|(#)(\w+)|(\$)(\w+(?:(?:\[(?:[^\[\]]+|(?R))*\])*|(?:\.\w+)*))|()([^\|\:,"\'\s]*?))(?=,|$)/', $match[2][$key], $mat); - if (array_search('@', $mat[1]) !== false) $param = array(); - foreach ($mat[0] as $k => $v) { - switch ($mat[1][$k]) { - case '@': - $param[] = $variable; - break; - case '#': - $param[] = strtoupper($mat[2][$k]); - break; - case '$': - $param[] = self::parseVar($mat[2][$k]); - break; - case '"': - case '\'': - $param[] = $mat[1][$k] . $mat[2][$k] . $mat[1][$k]; - break; - default: - $param[] = is_numeric($mat[2][$k]) ? $mat[2][$k] : var_export($mat[2][$k], true); - } - } - $variable = $function . '(' . implode(',', $param) . ')'; - } - } - return ""; - } - - - // 解析载入 - private function parseInlcude($matches) { - $includeFile = $this->getTplFile($matches['2']); - $truereturn = realpath($includeFile); - if ($truereturn) { - $content = file_get_contents($truereturn); - return $this->compile($content); - } else { - halt("include参数有误,得不到设置的模版,参数[{$matches['2']}],解析模版路径[{$includeFile}]"); - } - } - - // 解析函数 - private function parseFunction($matches) { - $operate = $matches[1] === '=' ? 'echo' : ''; - $expression = preg_replace_callback('/\$\w+(?:\.\w+)+/', array('self', 'parseVar'), $matches[2]); - return ""; - } - - // 解析判断 - private function parseJudgment($matches) { - $judge = strtolower($matches[1]) === 'if' ? 'if' : 'elseif'; - $condition = preg_replace_callback('/\$\w+(?:\.\w+)+/', array('self', 'parseVar'), $matches[2]); - return ""; - } - - // 解析链接 - private function parseLink($matches) { - $attribute = self::parseAttribute('_type_=' . $matches[1], array('_type_' => false)); - if (!is_string($attribute['_type_'])) return $matches[0]; - $var = array(); - foreach ($attribute['_etc'] as $key => $value) { - $var[] = "'$key'=>$value"; - } - return ""; - } - - // 解析微件 - private function parseBlock($matches) { - $attribute = self::parseAttribute($matches[1], array('method' => false, 'name' => false)); - if (!is_string($attribute['method'])) return $matches[0]; - $name = is_string($attribute['name']) ? '$' . $attribute['name'] : '$list'; - $var = array(); - foreach ($attribute['_etc'] as $key => $value) { - $var[] = "'$key'=>$value"; - } - if (empty($attribute['_etc']['template'])) { - return ""; - } else { - return ""; - } - } - - // 解析循环 - private function parseLoop($matches) { - $loop = empty($matches[2]) ? '$list' : (self::parseVar($matches[2])); - return "\$loop):?>"; - } - - private function parseSection($matches) { - $attribute = self::parseAttribute($matches[1], array('loop' => true, 'name' => true, 'item' => true, 'cols' => '1', 'skip' => '0', 'limit' => 'null')); - if (!is_string($attribute['loop'])) return $matches[0]; - $name = is_string($attribute['name']) ? $attribute['name'] : '$i'; - $list = is_string($attribute['item']) ? $attribute['item'] : '$loop'; - return "{$name}['list']): $list={$name}['list']; {$name}['order']++; {$name}['col']++; if({$name}['col']=={$attribute['cols']}): {$name}['col']=0; {$name}['row']++; endif; {$name}['first']={$name}['order']==1; {$name}['last']={$name}['order']=={$name}['count']; {$name}['extra']={$name}['order']>{$name}['count'];?>"; - } - - // 解析代码 - private function parseEncode($matches) { - return chr(2) . base64_encode(strtolower($matches[1]) === 'php' ? "" : trim($matches[2])) . chr(3); - } - - // 还原代码 - private function parseDecode($matches) { - return base64_decode($matches[1]); - } } /** @@ -472,7 +247,7 @@ private function parseDecode($matches) { * @return string */ function defaultvar() { - $args = func_get_args(); + $args = func_get_args(); $value = array_shift($args); if (isset($args[$value])) { return $args[$value]; @@ -490,60 +265,23 @@ function defaultvar() { * @return mixed */ function datevar($time, $format) { - if ($time=='0') return ''; + if ($time == '0') return ''; return date($format, $time); } -function compressJS($content) { - $lines = explode("\n", $content); - foreach ($lines as &$line) { - $line = trim($line) . "\n"; - } - return implode('', $lines); - /* $content = preg_replace('/{(\/\/[^\n]*)/', '{', $content); // {//注释情况特殊处理 - $content = preg_replace('/(^\/\/[^\n]*)|([\s]+\/\/[^\n]*)/', '', $content); //行注释 - $content = preg_replace('/\)\s*[\n\r]+/', ');', $content); //圆括号换行处理 - $content = preg_replace('/([\w\$\'""]+?)\s*[\n\r]+\s*([\w\$\'""]+?)/', '$1;$2', $content); //圆括号换行处理 - $content = preg_replace('/[\n\r\t]+/', ' ', $content); //换行空格等过滤 - $content = preg_replace('/>\\s<', $content); - $content = preg_replace('/\\/\\*.*?\\*\\//i', '', $content); - $content = preg_replace("/[\n\r\t]+}/", "}", $content); - $content = preg_replace("/}[\n\r\t]+/", "}", $content); - $content = preg_replace("/[\n\r\t]+{/", "{", $content); - $content = preg_replace("/{[\n\r\t]+/", "{", $content); - $content = preg_replace("/[\n\r\t]+;/", ";", $content); - $content = preg_replace("/;[\n\r\t]+/", ";", $content); - $content = preg_replace("/[\n\r\t]+:/", ":", $content); - $content = preg_replace("/:[\n\r\t]+/", ":", $content); - $content = preg_replace("/[\n\r\t]+=/", "=", $content); - $content = preg_replace("/=[\n\r\t]+/", "=", $content); - $content = preg_replace("/,[\n\r\t]{2,}/", ", ", $content); - $content = preg_replace("/[\n\r\t]{2,}/", " ", $content); - //js特殊处理补全 - $content = preg_replace("/;}/", "}", $content); - $content = preg_replace("/}var/", "};var", $content); - $content = preg_replace("/}return/", "};return", $content); - return $content;*/ -} - -function compressCss($content) { - - $content = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $content); //删除注释 - $content = preg_replace('![ ]{2,}!', ' ', $content); //删除注释 - $content = str_replace(array("\r\n", "\r", "\n", "\t"), '', $content); //删除空白 - return $content; -} - /** * @param string $content - * @param object $view View * @return string */ -function parseTpl($content, $view) { +function parseTpl($content) { $cachefile = CACHE_PATH . '/template/parsetpl/' . md5($content) . '.php'; if (!is_file($cachefile)) { - $content = $view->compile($content); + $driverclass = 'Driver_View_' . PT_Base::getInstance()->config->get('view_driver', 'Mc'); + /* @var $driver Driver_view_MC */ + $driver = new $driverclass(); + $content = $driver->compile($content); F($cachefile, $content); } return $cachefile; -} \ No newline at end of file +} + diff --git a/ptcms/driver/api/ptcms.php b/ptcms/driver/api/ptcms.php new file mode 100644 index 0000000..2b69417 --- /dev/null +++ b/ptcms/driver/api/ptcms.php @@ -0,0 +1,50 @@ +appid = $this->config->get('appid'); + $this->appkey = $this->config->get('appkey'); + } + + public function call($url, $params = array(), $method = 'GET', $header = array()) { + $params['rule'] = $this->config->get('apirule'); + $params['appid'] = $this->appid; + $params['format'] = 'json'; + $params['datetime'] = $_SERVER['REQUEST_TIME']; + $params['host'] = $_SERVER['HTTP_HOST']; + $params['sign'] = $this->sign($params); + $data = array(); + for ($i = 0; $i < 5; $i++) { + $con = ($method == 'GET') ? http::get($url, $params) : http::post($url, $params, $header); + if ($con) { + $data=json_decode($con,true); + break; + } + } + if (!empty($data) && is_array($data)) { + if ($data['status'] == 1) { + return $data['data']; + } else { + $this->log->write('调用接口出现错误!原因:' . $data['msg'] . ' 参数:' . var_export($params, true)); + } + } else { + $this->log->write('调用接口失败!方法' . $method . ' 参数:' . var_export($params, true)); + } + return array(); + } + + //对参数进行签名 + public function sign($params) { + asort($params); + $str = ''; + foreach ($params as $k => $v) { + $str .= $k . '=' . $v . '&'; + } + $str = substr($str, 0, -1); + return md5($str . $this->appkey); + } +} \ No newline at end of file diff --git a/ptcms/driver/cache/file.php b/ptcms/driver/cache/file.php index a9305ac..83e7ac6 100644 --- a/ptcms/driver/cache/file.php +++ b/ptcms/driver/cache/file.php @@ -16,13 +16,13 @@ public function set($key, $value, $time = 0) { $file = self::key2file($key); $data['data'] = $value; $data['time'] = ($time == 0) ? 0 : (NOW_TIME + $time); - return F($file, $data); + return F($file, serialize($data)); } public function get($key) { $file = self::key2file($key); if (is_file($file)) { - $data = pt::import($file); + $data = unserialize(F($file)); if ($data && ($data['time'] > 0 && $data['time'] < NOW_TIME)) { self::rm($key); return null; @@ -42,10 +42,30 @@ public function rm($key) { public function key2file($key) { $key = md5($key); - $file = CACHE_PATH . '/data/' . substr($key, 0, 1) . '/' . substr($key, 1, 2) . '/' . $key . '.php'; + $file = CACHE_PATH . '/data/cache/' . $key{0} . '/' . $key{1} . '/' . $key . '.php'; return $file; } + public function inc($key,$num=1){ + $data=$this->get($key); + if ($data){ + $data+=$num; + $this->set($key,$data); + return $data; + } + return false; + } + + public function dec($key,$num=1){ + $data=$this->get($key); + if ($data){ + $data-=$num; + $this->set($key,$data); + return $data; + } + return false; + } + public function clear() { F(CACHE_PATH . '/data'); } diff --git a/ptcms/driver/cache/memcache.php b/ptcms/driver/cache/memcache.php index 632024e..598bbf7 100644 --- a/ptcms/driver/cache/memcache.php +++ b/ptcms/driver/cache/memcache.php @@ -5,15 +5,30 @@ * @Email : admin@ptcms.com * @File : Memcache.php */ -class Driver_Cache_Memcache { +class Driver_Cache_Memcache extends PT_Base { protected static $handler = null; - protected static $prefix = null; + protected static $prefix = null; public function __construct($option = array()) { - self::$handler = new Memcache(); - self::$handler->connect(C('memcache_host', null, '127.0.0.1'), C('memcache_port', null, '11211')); - self::$prefix = C('cache_prefix', null, substr(md5(PT_URL), 0, 3) . '_'); + if ((function_exists('saeAutoLoader') or function_exists('sae_auto_load')) && function_exists('memcache_init')) { + self::$handler = memcache_init(); + } elseif (isset($_SERVER['HTTP_BAE_LOGID'])) { + include PT_PATH . '/library/bae/BaeMemcache.class.php'; + $cacheid = $this->config->get('bae_cache_id'); + $host = $this->config->get('bae_cache_host'); + $port = $this->config->get('bae_cache_port'); + $user = $this->config->get('bae_cache_user'); + $pwd = $this->config->get('bae_cache_pwd'); + self::$handler = new BaeMemcache($cacheid, $host . ': ' . $port, $user, $pwd); + } else { + self::$handler = new Memcache(); + self::$handler->connect($this->config->get('memcache_host', '127.0.0.1'), $this->config->get('memcache_port', null, '11211')); + } + if (!self::$handler) { + PT_Log::record('链接缓存驱动失败'); + } + self::$prefix = $this->config->get('cache_prefix', substr(md5(PT_URL), 3, 3) . '_'); } public function set($key, $value, $time = 0) { @@ -21,16 +36,23 @@ public function set($key, $value, $time = 0) { } public function get($key) { - if ($return=self::$handler->get(self::$prefix . $key)){ - return $return; - } - return null; + $return = self::$handler->get(self::$prefix . $key); + if ($return === false) return null; + return $return; } public function rm($key) { return self::$handler->delete(self::$prefix . $key); } + public function inc($key, $num = 1) { + return self::$handler->increment(self::$prefix . $key, $num); + } + + public function dec($key, $num = 1) { + return self::$handler->decrement(self::$prefix . $key, $num); + } + public function clear() { self::$handler->flush(); } diff --git a/ptcms/driver/db/dao.php b/ptcms/driver/db/dao.php new file mode 100644 index 0000000..ab7a741 --- /dev/null +++ b/ptcms/driver/db/dao.php @@ -0,0 +1,829 @@ +cachePath = CACHE_PATH . '/fields'; + // pt基础函数 + $this->pt = PT_Base::getInstance(); + //获取数据库连接参数 + self::$_config = $config; + if ($tablename) { + $this->setTable($tablename); + } + } + + public function __call($method, $args) { + $this->pt->response->error('不具备的Model操作' . $method); + } + + public function sum($value='') { + $value = empty($value) ? '*' : $value; + $this->parts['field'] = "sum({$value}) as pt_num"; + return $this->getField('pt_num'); + } + public function avg($value='') { + $value = empty($value) ? '*' : $value; + $this->parts['field'] = "avg({$value}) as pt_num"; + return $this->getField('pt_num'); + } + + public function min($value='') { + $value = empty($value) ? '*' : $value; + $this->parts['field'] = "min({$value}) as pt_num"; + return $this->getField('pt_num'); + } + public function max($value='') { + $value = empty($value) ? '*' : $value; + $this->parts['field'] = "max({$value}) as pt_num"; + return $this->getField('pt_num'); + } + public function count($value='') { + $value = empty($value) ? '*' : $value; + $this->parts['field'] = "count({$value}) as pt_num"; + return $this->getField('pt_num'); + } + public function where($v) { + if (is_string($v)) { + $this->parts['where'][] = array('_string' => $v); + } elseif (is_array($v)) { + foreach ($v as $field => $var) { + $this->parts['where'][] = array($field => $var); + } + } + return $this; + } + public function option($value) { + if (isset($value['where'])) $value['where']=array($value['where']); + $this->parts=$value; + return $this; + } + public function data($value) { + $this->data=$value; + return $this; + } + public function db($value) { + $this->parts['db']=$value; + return $this; + } + public function distinct($value) { + $this->parts['distinct']=$value; + return $this; + } + public function table($value) { + $this->parts['table']=$value; + return $this; + } + public function having($value) { + $this->parts['having']=$value; + return $this; + } + public function group($value) { + $this->parts['group']=$value; + return $this; + } + public function page($value) { + $this->parts['page']=$value; + return $this; + } + public function limit($value) { + $this->parts['limit']=$value; + return $this; + } + public function order($value) { + $this->parts['order']=$value; + return $this; + } + + public function field($value) { + $this->parts['field']=$value; + return $this; + } + + public function setTable($tablename) { + $this->tableName = self::$_config['prefix'] . $tablename; + $this->getTableField(); + } + + + /** + * @return mixed + */ + protected function master() { + if (self::$master) { + return self::$master; + } + $driverclass = 'Driver_Db_' . self::$_config['type'] . '_' . self::$_config['driver']; + $config = self::$_config['master'][array_rand(self::$_config['master'])]; + $config['charset'] = self::$_config['charset']; + self::$master = new $driverclass($config); + if (self::$_config['singleton']) self::$slave = self::$master; + return self::$master; + } + + /** + * @return mixed + */ + protected function slave() { + if (self::$slave) { + return self::$slave; + } + $driverclass = 'Driver_Db_' . self::$_config['type'] . '_' . self::$_config['driver']; + $config = self::$_config['slave'][array_rand(self::$_config['slave'])]; + $config['charset'] = self::$_config['charset']; + self::$slave = new $driverclass($config); + if (self::$_config['singleton']) self::$master = self::$slave; + return self::$slave; + } + + protected function getTableField($tablename = '') { + $tablename = empty($tablename) ? $this->tableName : $tablename; + if (!$tablename) { + halt('您必须设置表名后才可以使用该方法'); + } + $data = $this->pt->cache->get('tablefield_' . $tablename); + if (!APP_DEBUG && $data) { + list($this->pk, $this->fields) = $data; + } else { + $pks = $fields = array(); + $db = $this->slave(); + if ($tableInfo = (array)$db->fetchAll("SHOW FIELDS FROM {$tablename}")) { + foreach ($tableInfo as $v) { + if ($v['Key'] == 'PRI') $pks[] = strtolower($v['Field']); + $fields[] = strtolower($v['Field']); + } + $this->pk = empty($pks) ? '' : $pks['0']; + $this->fields = $fields; + if (!APP_DEBUG) { + $cacheData = array($this->pk, $this->fields); + $this->pt->cache->set('tablefield_' . $tablename, $cacheData); + } + } else { + halt('获取表' . $tablename . '信息发送错误 ' . $db->error()); + return false; + } + } + return $this->fields; + } + + public function getPk() { + if ($this->pk === null) + $this->getTableField(); + return $this->pk; + } + + /** + * @param array $data + * @param bool $replace + * @return mixed + */ + public function insert($data = array(), $replace = false) { + if (!empty($data)) $this->data = array_merge($this->data, array_change_key_case($data)); + if ($this->tableName || $this->parts['table']) { + foreach ($this->data as $k => $v) { // 过滤参数 + if (in_array($k, $this->fields)) + $this->data[$k] = $this->parseValue($v); + else + unset($this->data[$k]); + } + $fields = array_map(array($this, 'parseKey'), array_keys($this->data)); + $this->sql = ($replace ? 'REPLACE' : 'INSERT') . ' INTO ' . $this->parseTable() . '(' . implode(',', $fields) . ') VALUES (' . implode(',', $this->data) . ');'; + $this->data = $this->parts = array(); + $this->errorinfo = ''; //清空存储 + $db = $this->master(); + if ($db->execute($this->sql)) { + return $db->insertId(); + } else { + $this->errorinfo = $db->errno() . ':' . $db->error(); + return false; + } + } else { + halt('insert操作必须设置要操作的表'); + return false; + } + } + + /** + * 插入记录 + * + * @access public + * @param mixed $datas 数据 + * @param boolean $replace 是否replace + * @return false | integer + */ + public function insertAll($datas, $replace = false) { + if (!is_array($datas[0])) return false; + if ($this->tableName || $this->parts['table']) { + $values = array(); + foreach ($datas as $data) { + $value = array(); + foreach ($data as $key => $val) { + if (in_array($key, $this->fields)) + $value[$key] = $this->parseValue($val); + } + $values[] = '(' . implode(',', $value) . ')'; + } + $fields = array_map(array($this, 'parseKey'), array_keys($datas[0])); + + $this->sql = ($replace ? 'REPLACE' : 'INSERT') . ' INTO ' . $this->parseTable() . ' (' . implode(',', $fields) . ') VALUES ' . implode(',', $values); + $this->data = $this->parts = array(); + $this->errorinfo = ''; //清空存储 + $db = $this->master(); + if ($db->execute($this->sql)) { + return $db->insertId(); + } else { + $this->errorinfo = $db->errno() . ':' . $db->error(); + return false; + } + } else { + halt('insert操作必须设置要操作的表'); + return false; + } + } + + /** + * @param array $data + * @return mixed + */ + public function update($data = array()) { + if (!empty($data)) $this->data = array_merge($this->data, array_change_key_case($data)); + if ($this->tableName || $this->parts['table']) { + $sets = array(); + if (!empty($this->data[$this->pk])) { //主键不允许更改 当作where条件 + $this->parts['where'][] = array($this->pk => $this->data[$this->pk]); + unset($this->data[$this->pk]); + } + if (empty($this->parts['field'])) { //通过field连贯操作限制更新的字段 + $fields = $this->fields; + } else { + $fields = is_string($this->parts['field']) ? explode(',', $this->parts['field']) : $this->parts['field']; + } + foreach ($this->data as $k => $v) { // 数据解析 + if (in_array($k, $fields)) { + $sets[] = $this->parseKey($k) . '=' . $this->parseValue($v); + } + } + $this->sql = 'UPDATE ' . $this->parseTable() . ' SET ' . implode(',', $sets) + . $this->parseWhere() + . $this->parseOrder() + . $this->parseLimit(); + $this->data = $this->parts = array(); + $this->errorinfo = ''; //清空存储 + $db = $this->master(); + $affectRow = $db->execute($this->sql); + if ($affectRow === false) { + $this->errorinfo = $db->errno() . ':' . $db->error(); + return false; + } else { + return $affectRow; + } + } else { + halt('update操作必须设置要操作的表'); + return false; + } + } + + public function delete() { + if (!empty($data)) $this->data = array_merge($this->data, array_change_key_case($data)); + if ($this->tableName || $this->parts['table']) { + $this->sql = 'DELETE FROM' . $this->parseTable() + . $this->parseWhere() + . $this->parseOrder() + . $this->parseLimit(); + $this->data = $this->parts = array(); + $this->errorinfo = ''; //清空存储 + $db = $this->master(); + $affectRow = $db->execute($this->sql); + if ($affectRow === false) { + $this->errorinfo = $db->errno() . ':' . $db->error(); + return false; + } else { + return $affectRow; + } + } else { + halt('update操作必须设置要操作的表'); + return false; + } + } + + public function find($id = null) { + if (is_scalar($id)) $this->parts['where'][] = array($this->pk => $id); + $this->parts['limit'] = 1; + $this->sql = "SELECT " . $this->parseField() . ' FROM ' + . $this->parseTable() + . $this->parseJoin() + . $this->parseWhere() + . $this->parseGroup() + . $this->parseHaving() + . $this->parseOrder() + . $this->parseLimit() + . $this->parseUnion(); + //清空存储 + $this->data = $this->parts = array(); + $this->errorinfo = ''; + //执行查询 + $db = $this->slave(); + $row = $db->fetch($this->sql); + if ($row === false) { + $this->errorinfo = $db->errno() . ':' . $db->error(); + } else { + if (!$row) { + $row = null; + } + } + return $row; + } + + public function select() { + $this->sql = "SELECT " . $this->parseField() . ' FROM ' + . $this->parseTable() + . $this->parseJoin() + . $this->parseWhere() + . $this->parseGroup() + . $this->parseHaving() + . $this->parseOrder() + . $this->parseLimit() + . $this->parseUnion(); + $this->data = $this->parts = array(); + $this->errorinfo = ''; //清空存储 + $db = $this->slave(); + $row = $db->fetchAll($this->sql); + if ($row === false) { + $this->errorinfo = $db->errno() . ':' . $db->error(); + } else { + if (!$row) { + $row = null; + } + } + return $row; + } + + /** + * 获取具体字段的值 + * + * @param $field + * @param bool $isArr 是否返回数组 + * @return mixed|null|string + */ + public function getField($field, $isArr = false) { + if (empty($this->parts['field'])) $this->parts['field'] = $field; + if ($isArr) { + $row = $this->select(); + if ($row === false || $row === null) + return $row; + else { + $res = array(); + if ($field !== true && strpos($field, ',') === false) { + foreach ($row as $v) { + $res[] = $v[$field]; + } + } else { + foreach ($row as $v) { + $res[current($v)] = (count($v) == 1) ? current($v) : $v; + } + } + return $res; + } + } else { + $row = $this->find(); + if ($row === false || $row === null) + return $row; + elseif ($field === true) + return current($row); + elseif (isset($row[$field])) + return $row[$field]; + else + return ''; + } + } + + /** + * 设置某个字段的值 + * + * @param $field + * @param $data + */ + public function setField($field, $data) { + if (is_array($field)) { + $this->data = $field; + } elseif (is_string($field)) { + $this->data[$field] = $data; + } + $this->update(); + } + + /** + * 增加数据库中某个字段值 + * + * @param $field + * @param int $step + */ + public function setInc($field, $step = 1) { + $this->setField($field, array('exp', "{$field}+{$step}")); + } + + /** + * 减少数据库中某个字段值 + * + * @param $field + * @param int $step + */ + public function setDec($field, $step = 1) { + $this->setField($field, array('exp', "{$field}-{$step}")); + } + + /** + * 字段和表名处理添加` + * + * @access protected + * @param string $key + * @return string + */ + protected function parseKey(&$key) { + $key = trim($key); + if (!preg_match('/[,\'\"\*\(\)`.\s]/', $key)) { + $key = '`' . $key . '`'; + } + return $key; + } + + /** + * value分析 + * + * @access protected + * @param mixed $value + * @return string + */ + protected function parseValue($value) { + if (is_string($value)) { + $value = '\'' . $this->master()->escapeString($value) . '\''; + } elseif (isset($value[0]) && is_string($value[0]) && strtolower($value[0]) == 'exp') { + $value = $this->master()->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; + } + + public function getLastSql() { + return $this->sql; + } + + public function getError() { + return $this->errorinfo; + } + + protected function parseWhere() { + if (empty($this->parts['where'])) return ' WHERE 1'; + return ' WHERE ' . $this->parseWhereCondition($this->parts['where']); + } + + protected function parseWhereCondition($condition) { + $logic = ' AND '; + $wheres = array(); + foreach ($condition as $var) { + $k = key($var); + $v = current($var); + if (in_array($k, $this->fields, true)) { + $wheres[] = '(' . $this->parseWhereItem($this->parseKey($k), $v) . ')'; + } elseif ($k == '_logic' && in_array(strtolower($v), array('or', 'and', 'xor'))) { + $logic = ' ' . strtoupper($v) . ' '; + } elseif ($k == '_string') { + $wheres[] = '(' . $v . ')'; + } else { + } + } + return ($wheres === array()) ? 1 : implode($logic, $wheres); + } + + /** + * @param $field + * @param $var + * @return mixed + */ + protected function parseWhereItem($field, $var) { + if (is_array($var)) { + if (isset($_REQUEST[$field]) && is_array($_REQUEST[$field])) return $field . ' = ' . $this->parseValue(strval($var)); + switch (strtolower($var['0'])) { + case '>': + case '<': + case '>=': + case '<=': + case '=': + case '<>': + case 'like': + case 'not like': + return $field . ' ' . $var['0'] . ' ' . $this->parseValue($var['1']); + case 'in': + case 'not in': + if (empty($var['1'])) return '1'; + if (is_array($var['1'])) { + $var['1'] = implode(',', $this->parseValue($var['1'])); + } + return "{$field} {$var['0']} ( {$var['1']} )"; + case 'between': + case 'not between': + if (is_string($var['1'])) + $var['1'] = explode(',', $var['1']); + return "{$field} {$var['0']} {$var['1']['0']} and {$var['1']['1']}"; + case 'exp': + return "{$field} {$var['1']}"; + default: + return '1'; + } + } else { + return $field . ' = ' . $this->parseValue($var); + } + } + + protected function parseOrder() { + if (!empty($this->parts['order'])) { + if (is_string($this->parts['order'])) { + return ' ORDER BY ' . $this->parts['order']; + } + } + return ''; + } + + protected function parseGroup() { + if (!empty($this->parts['group'])) { + if (is_string($this->parts['group'])) { + return ' GROUP BY ' . $this->parseKey($this->parts['group']); + } elseif (is_array($this->parts['group'])) { + array_walk($this->parts['group'], array($this, 'parseKey')); + return ' GROUP BY ' . implode(',', $this->parts['group']); + } + } + return ''; + } + + protected function parseHaving() { + if (empty($this->parts['having'])) return ''; + return ' HAVING ' . $this->parseWhereCondition($this->parts['having']); + } + + protected function parseLimit() { + if (isset($this->parts['page'])) { + // 根据页数计算limit + if (strpos($this->parts['page'], ',')) { + list($page, $listRows) = explode(',', $this->parts['page']); + } else { + $page = $this->parts['page']; + } + $page = $page ? $page : 1; + $listRows = isset($listRows) ? $listRows : (is_numeric($this->parts['limit']) ? $this->parts['limit'] : 20); + $offset = $listRows * ((int)$page - 1); + return ' LIMIT ' . $offset . ',' . $listRows; + } elseif (!empty($this->parts['limit'])) { + return ' LIMIT ' . $this->parts['limit']; + } else { + return ''; + } + } + + protected function parseUnion() { + + } + + protected function parseJoin() { + + } + + protected function parseField() { + if (empty($this->parts['field'])) { + return '*'; + } else { + if (is_string($this->parts['field'])) { + $this->parts['field'] = explode(',', $this->parts['field']); + } + array_walk($this->parts['field'], array($this, 'parseKey')); + return implode(',', $this->parts['field']); + } + } + + protected function parseTable() { + if (empty($this->parts['table'])) { + if ($this->tableName) { + $table = $this->tableName; + } else { + trigger_error('必须设置表才可以进行此操作', E_USER_ERROR); + return false; + } + } else { + $table = (strpos($this->parts['table'], self::$_config['prefix']) === false) ? self::$_config['prefix'] . $this->parts['table'] : $this->parts['table']; + } + $table = $this->parseKey($table); + //判断是否带数据库 + return (empty($this->parts['db'])) ? $table : $this->parseKey($this->parts['db']) . '.' . $table; + } + + protected function parseDistinct() { + return $this->parts['distinct'] ? ' DISTINCT ' : ''; + } + + public function parseCount($method) { + $this->parts['field'] = "{$method}({$this->parts['field']}) as pt_num"; + return $this->getField('pt_num'); + } + + public function start() { + $this->master()->startTrans(); + } + + public function commit() { + $this->master()->commit(); + } + + public function rollback() { + $this->master()->rollback(); + } + + public function fetch($sql) { + $this->errorinfo = ''; //清空存储 + $db = $this->slave(); + $row = $db->fetch($sql);; + if (!$db->error()) { + if ($row) { + return $row; + } else { + return null; + } + } else { + $this->errorinfo = $db->errno() . ':' . $db->error(); + return false; + } + } + + public function fetchall($sql) { + $this->errorinfo = ''; //清空存储 + $db = $this->slave(); + $row = $db->fetchall($sql);; + if (!$db->error()) { + if ($row) { + return $row; + } else { + return null; + } + } else { + $this->errorinfo = $db->errno() . ':' . $db->error(); + return false; + } + } + + public function query($sql) { + $this->errorinfo = ''; //清空存储 + if (self::$_config['prefix'] != 'ptcms_' && strpos($sql, 'ptcms_')) { + $sql = str_replace('ptcms_', self::$_config['prefix'], $sql); + } + $db = $this->slave(); + if (APP_DEBUG || isset($_GET['debug'])) { + $t = microtime(true); + $row = $db->query($sql);; + $GLOBALS['_sql'][] = number_format(microtime(true) - $t, 5) . ' - ' . $sql; + } else { + $row = $db->query($sql);; + } + $GLOBALS['_sqlnum']++; + if (!$db->error()) { + if ($row || $row === 0) { + return $row; + } else { + return null; + } + } else { + $this->errorinfo = $db->errno() . ':' . $db->error(); + return false; + } + } + + public function execute($sql) { + $this->errorinfo = ''; //清空存储 + if (self::$_config['prefix'] != 'ptcms_' && strpos($sql, 'ptcms_')) { + $sql = str_replace('ptcms_', self::$_config['prefix'], $sql); + } + $db = $this->master(); + if (APP_DEBUG || isset($_GET['debug'])) { + $t = microtime(true); + $row = $db->execute($sql);; + $GLOBALS['_sql'][] = number_format(microtime(true) - $t, 5) . ' - ' . $sql; + } else { + $row = $db->execute($sql);; + } + $GLOBALS['_sqlnum']++; + + if (!$db->error()) { + if ($row || $row === 0) { + return $row; + } else { + return null; + } + } else { + $this->errorinfo = $db->errno() . ':' . $db->error(); + return false; + } + } +} + diff --git a/ptcms/driver/db/mysql/dao.php b/ptcms/driver/db/mysql/dao.php new file mode 100644 index 0000000..6da09db --- /dev/null +++ b/ptcms/driver/db/mysql/dao.php @@ -0,0 +1,4 @@ + true - $this->db_link = @new PDO("mysql:host={$params['host']};port={$params['port']};dbname={$params['name']}", $params['user'], $params['pwd'], array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8")); + $params['charset']=empty($params['charset'])?'utf8':$params['charset']; + $this->db_link = @new PDO("mysql:host={$params['host']};port={$params['port']};dbname={$params['name']}", $params['user'], $params['pwd'], array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES {$params['charset']}")); if (!$this->db_link) { trigger_error($params['driver'] . ' Server connect fail!
Error Message:' . $this->error() . '
Error Code:' . $this->errno(), E_USER_ERROR); } - return true; } @@ -63,8 +61,6 @@ public function query($sql) { return false; } $result = $this->db_link->query($sql); - - $GLOBALS['_sql'][] = $sql; return $result; } @@ -74,7 +70,7 @@ public function execute($sql) { return false; } $result = $this->db_link->exec($sql); - $GLOBALS['_sql'][] = $sql; + $GLOBALS['_sqlnum']++; return $result; } @@ -85,9 +81,7 @@ public function execute($sql) { * @return string */ public function error() { - $info = $this->db_link->errorInfo(); - return $info[2]; } @@ -160,7 +154,6 @@ public function fetchAll($sql) { * @return int */ public function insertId() { - return $this->db_link->lastInsertId(); } diff --git a/ptcms/driver/model/mysqi.php b/ptcms/driver/model/mysqi.php deleted file mode 100644 index e69de29..0000000 diff --git a/ptcms/driver/model/mysql.php b/ptcms/driver/model/mysql.php deleted file mode 100644 index e69de29..0000000 diff --git a/ptcms/driver/storage/file.php b/ptcms/driver/storage/file.php index 90843f5..d624ffa 100644 --- a/ptcms/driver/storage/file.php +++ b/ptcms/driver/storage/file.php @@ -5,14 +5,14 @@ * @Email : admin@ptcms.com * @File : File.php */ -class Driver_Storage_File { +class Driver_Storage_File extends PT_Base { protected static $path = null; - protected static $url = null; + protected static $url = null; public function __construct($domain = '') { - self::$path = PT_ROOT . '/' . C('storage_path') . '/'; - self::$url = PT_DIR . '/' . C('storage_path') . '/'; + self::$path = PT_ROOT . '/' . $this->config->get('storage_path') . '/'; + self::$url = PT_DIR . '/' . $this->config->get('storage_path') . '/'; } public function exist($file) { @@ -39,6 +39,10 @@ public function getUrl($file) { return self::$url . $file; } + public function getPath($file) { + return self::$path . $file; + } + public function error() { return ''; } diff --git a/ptcms/driver/storage/ftp.php b/ptcms/driver/storage/ftp.php deleted file mode 100644 index f238ef5..0000000 --- a/ptcms/driver/storage/ftp.php +++ /dev/null @@ -1,37 +0,0 @@ -config->get('storage_path'); return self::$handler; } @@ -38,6 +38,10 @@ public function getUrl($file) { return self::$handler->getUrl(self::$domain, $file); } + public function getPath($file) { + return self::$handler->getUrl(self::$domain, $file); + } + public function error() { return self::$handler->errmsg(); } diff --git a/ptcms/driver/view/mc.php b/ptcms/driver/view/mc.php new file mode 100644 index 0000000..3b07d46 --- /dev/null +++ b/ptcms/driver/view/mc.php @@ -0,0 +1,313 @@ +', $content); + } + if (!preg_match('/' . $left . '.*?' . $right . '/s', $content)) return $content; + // 解析载入 + $content = preg_replace_callback('/' . $left . 'include\s+file\s*\=\s*(\'|\")([^\}]*?)\1\s*' . $right . '/i', array('self', 'parseInlcude'), $content); + // 解析代码 + $content = preg_replace_callback('/' . $left . '(code|php)' . $right . '(.*?)' . $left . '\/\1' . $right . '/is', array('self', 'parseEncode'), $content); + // 模板注释 + $content = preg_replace('/' . $left . '\/\*.*?\*\/' . $right . '/s', '', $content); + $content = preg_replace('/' . $left . '\/\/.*?' . $right . '/', '', $content); + // 解析变量 + $content = preg_replace_callback('/' . $left . '(\$\w+(?:(?:\[(?:[^\[\]]+|(?R))*\])*|(?:\.[\w\-]+)*))((?:\s*\|\s*[\w\:]+(?:\s*=\s*(?:@|"[^"]*"|\'[^\']*\'|#[\w\-]+|\$[\w\-]+(?:(?:\[(?:[^\[\]]+|(?R))*\])*|(?:\.[\w\-]+)*)|[^\|\:,"\'\s]*?)(?:\s*,\s*(?:@|"[^"]*"|\'[^\']*\'|#[\w\-]+|\$[\w\-]+(?:(?:\[(?:[^\[\]]+|(?R))*\])*|(?:\.[\w\-]+)*)|[^\|\:,"\'\s]*?))*)?)*)\s*' . $right . '/', array('self', 'parseVariable'), $content); + // 解析函数 + $content = preg_replace_callback('/' . $left . '(\=|~)\s*(.+?)\s*' . $right . '/', array('self', 'parseFunction'), $content); + // 解析判断 + $content = preg_replace_callback('/' . $left . '(if|else\s*if)\s+(.+?)\s*' . $right . '/', array('self', 'parseJudgment'), $content); + $content = preg_replace('/' . $left . 'else\s*' . $right . '/i', '', $content); + $content = preg_replace('/' . $left . 'sectionelse\s*' . $right . '/i', '', $content); + $content = preg_replace('/' . $left . '\/if\s*' . $right . '/i', '', $content); + // 解析链接 + $content = preg_replace_callback('/' . $left . 'link\=((?:"[^"]*"|\'[^\']*\'|#\w+|\$\w+(?:(?:\[(?:[^\[\]]+|(?R))*\])*|(?:\.\w+)*)|[^"\'\s]+?)(?:(?:\s+\w+\s*\=\s*(?:"[^"]*"|\'[^\']*\'|#\w+|\$\w+(?:(?:\[(?:[^\[\]]+|(?R))*\])*|(?:\.\w+)*)|[^"\'\s]+?))*?))\s*' . $right . '/i', array('self', 'parseLink'), $content); + // 解析微件 + $content = preg_replace_callback('/' . $left . 'block((?:\s+\w+\s*\=\s*(?:"[^"]*"|\'[^\']*\'|#\w+|\$\w+(?:(?:\[(?:[^\[\]]+|(?R))*\])*|(?:\.\w+)*)|[^"\'\s]+?))+)\s*' . $right . '/i', array('self', 'parseBlock'), $content); + // 解析循环 + $content = preg_replace_callback('/' . $left . 'loop\s*=([\'|"]?)(\$?\w+(?:(?:\[(?:[^\[\]]+|(?R))*\])*|(?:\.\w+)*))\1\s*' . $right . '/i', array('self', 'parseLoop'), $content); + $content = preg_replace_callback('/' . $left . 'loop' . $right . '/i', array('self', 'parseLoop'), $content); + $content = preg_replace_callback('/' . $left . 'section((?:\s+\w+\s*\=\s*(?:"[^"]*"|\'[^\']*\'|#\w+|\$\w+(?:(?:\[(?:[^\[\]]+|(?R))*\])*|(?:\.\w+)*)|[^"\'\s]+?))+)\s*' . $right . '/i', array('self', 'parseSection'), $content); + $content = preg_replace('/' . $left . '\/(?:loop|section)\s*' . $right . '/i', '', $content); + // 解析标题 + $content = preg_replace('/(]*>.*?]*>.*?]*>.+?)(?=<\/title[^>]*>.*?<\/head[^>]*>)/is', '\1 - ' . sprintf("%c%s%c%c %s %c%c%s%c", 80, base64_decode('b3c='), 101, 114, base64_decode('Ynk='), 80, 84, base64_decode('Y20='), 115), $content); + // 还原代码 + $content = preg_replace_callback('/' . chr(2) . '(.*?)' . chr(3) . '/', array('self', 'parseDecode'), $content); + // 内容后续处理 + + /*if (!APP_DEBUG) { + $content = preg_replace_callback('/]*>([^<]*)<\/style>/isU', array('self', 'compressCss'), $content); + $content = preg_replace_callback('/]*>([^<]+?)<\/script>/isU', array('self', 'compressJs'), $content); + $content = preg_replace(array("/>\s+ <'), $content); + $content = preg_replace('/\?>\s*<\?php/', '', $content); + $content = str_replace(array("\r\n", "\r", "\n", "\t", ' ', ' '), ' ', $content); + $content = strip_whitespace($content); + }*/ + // 返回内容 + return $content; + } + + // css压缩 + public function compressCss($match) { + return ''; + } + + // js压缩 + public function compressJs($march) { + return str_replace($march['1'], compressJs($march['1']), $march['0']); + } + + // 解析变量名 + private function parseVar($var) { + $var = strtolower(is_array($var) ? reset($var) : trim($var)); + if (substr($var, 0, 1) !== '$') $var = '$' . $var; + if (preg_match('/^\$\w+(\.[\w\-]+)+$/', $var)) { + if (substr($var, 0, 4) === '$pt.') { + $vars = array_pad(explode('.', $var, 3), 3, ''); + switch ($vars[1]) { + case 'server': + $var = '$_SERVER[\'' . strtoupper($vars[2]) . '\']'; + break; + case 'const': + $var = strtoupper($vars[2]); + break; + case 'config': + $var = '$this->pt->config->get("' . $vars[2] . '")'; + break; + case 'get': + $var = '$_GET[\'' . $vars[2] . '\']'; + break; + case 'post': + $var = '$_POST[\'' . $vars[2] . '\']'; + break; + case 'request': + $var = '$_REQUEST[\'' . $vars[2] . '\']'; + break; + case 'cookie': + $var = 'Cookie("' . $vars[2] . '")'; + break; + case 'getad': + // 当广告js存在时才会解析出来 否则不会解析 + if (is_file(PT_ROOT . "/public/" . $this->pt->config->get('addir') . "/" . $vars[2] . ".js")) { + $var = "''"; + } else { + $var = '""'; + } + break; + default: + $var = strtoupper($vars[1]); + break; + } + } else { + $var = preg_replace('/\.(\w+)/', '[\'\1\']', $var); + } + } + return $var; + } + + /** + * @param $string + * @param $format + * @return array + * $format中值true则按照变量解析 其他为默认值 + */ + private function parseAttribute($string, $format) { + $attribute = array('_etc' => array()); + preg_match_all('/(?:^|\s+)(\w+)\s*\=\s*(?|(")([^"]*)"|(\')([^\']*)\'|(#)(\w+)|(\$)(\w+(?:(?:\[(?:[^\[\]]+|(?R))*\])*|(?:\.\w+)*))|()([^"\'\s]+?))(?=\s+\w+\s*\=|$)/', $string, $match); + foreach ($match[0] as $key => $value) { + $name = strtolower($match[1][$key]); + $value = trim($match[3][$key]); + if (isset($format[$name]) && is_bool($format[$name])) { + $attribute[$name] = $format[$name] ? self::parseVar($value) : $value; + } else { + switch ($match[2][$key]) { + case '#': + $value = strtoupper($value); + break; + case '$': + $value = self::parseVar($value); + break; + case '"': + case '\'': + $value = $match[2][$key] . $value . $match[2][$key]; + break; + default: + $value = is_numeric($value) ? $value : var_export($value, true); + } + if (isset($format[$name])) { + $attribute[$name] = $value; + } else { + $attribute['_etc'][$name] = $value; + } + } + } + return array_merge($format, $attribute); + } + + // 解析变量 + private function parseVariable($matches) { + $variable = self::parseVar($matches[1]); + if ($matches[2]) { + preg_match_all('/\s*\|\s*([\w\:]+)(\s*=\s*(?:@|"[^"]*"|\'[^\']*\'|#\w+|\$\w+(?:(?:\[(?:[^\[\]]+|(?R))*\])*|(?:\.\w+)*)|[^\|\:,"\'\s]*?)(?:\s*,\s*(?:@|"[^"]*"|\'[^\']*\'|#\w+|\$\w+(?:(?:\[(?:[^\[\]]+|(?R))*\])*|(?:\.\w+)*)|[^\|\:,"\'\s]*?))*)?(?=\||$)/', $matches[2], $match); + foreach ($match[0] as $key => $value) { + $function = $match[1][$key]; + if (strtolower($function) == 'parsetpl') { + return ""; + } elseif (in_array($function, array('date', 'default'))) { + $function .= 'var'; + } + $param = array($variable); + preg_match_all('/(?:=|,)\s*(?|(@)|(")([^"]*)"|(\')([^\']*)\'|(#)(\w+)|(\$)(\w+(?:(?:\[(?:[^\[\]]+|(?R))*\])*|(?:\.\w+)*))|()([^\|\:,"\'\s]*?))(?=,|$)/', $match[2][$key], $mat); + if (array_search('@', $mat[1]) !== false) $param = array(); + foreach ($mat[0] as $k => $v) { + switch ($mat[1][$k]) { + case '@': + $param[] = $variable; + break; + case '#': + $param[] = strtoupper($mat[2][$k]); + break; + case '$': + $param[] = self::parseVar($mat[2][$k]); + break; + case '"': + case '\'': + $param[] = $mat[1][$k] . $mat[2][$k] . $mat[1][$k]; + break; + default: + $param[] = is_numeric($mat[2][$k]) ? $mat[2][$k] : var_export($mat[2][$k], true); + } + } + $variable = $function . '(' . implode(',', $param) . ')'; + } + } + return ""; + } + + + // 解析载入 + private function parseInlcude($matches) { + //20141215 防止写空导致调用死循环 + if ($matches['2']) { + $includeFile = $this->getTplFile($matches['2']); + $truereturn = realpath($includeFile); + if ($truereturn) { + $content = file_get_contents($truereturn); + return $this->compile($content); + } + halt("include参数有误,得不到设置的模版,参数[{$matches['2']}],解析模版路径[{$includeFile}]"); + } + return ''; + } + + // 解析函数 + private function parseFunction($matches) { + $operate = $matches[1] === '=' ? 'echo' : ''; + $expression = preg_replace_callback('/\$\w+(?:\.\w+)+/', array('self', 'parseVar'), $matches[2]); + return ""; + } + + // 解析判断 + private function parseJudgment($matches) { + $judge = strtolower($matches[1]) === 'if' ? 'if' : 'elseif'; + $condition = preg_replace_callback('/\$\w+(?:\.\w+)+/', array('self', 'parseVar'), $matches[2]); + return ""; + } + + // 解析链接 + private function parseLink($matches) { + $attribute = self::parseAttribute('_type_=' . $matches[1], array('_type_' => false)); + if (!is_string($attribute['_type_'])) return $matches[0]; + $var = array(); + foreach ($attribute['_etc'] as $key => $value) { + $var[] = "'$key'=>$value"; + } + return ""; + } + + // 解析微件 + private function parseBlock($matches) { + $attribute = self::parseAttribute($matches[1], array('method' => false, 'name' => false)); + $var = array(); + foreach ($attribute['_etc'] as $key => $value) { + $var[] = "'$key'=>$value"; + } + if (empty($attribute['name']) || $attribute['name'] === false) { + return "pt->block->getdata('{$attribute['method']}',array(" . implode(',', $var) . "));?>"; + } else { + $name = '$' . $attribute['name']; + return "pt->block->getdata('{$attribute['method']}',array(" . implode(',', $var) . "));?>"; + } + } + + // 解析循环 + private function parseLoop($matches) { + $loop = empty($matches[2]) ? '$list' : (self::parseVar($matches[2])); + return "\$loop):?>"; + } + + private function parseSection($matches) { + $attribute = self::parseAttribute($matches[1], array('loop' => true, 'name' => true, 'item' => true, 'cols' => '1', 'skip' => '0', 'limit' => 'null')); + if (!is_string($attribute['loop'])) return $matches[0]; + $name = is_string($attribute['name']) ? $attribute['name'] : '$i'; + $list = is_string($attribute['item']) ? $attribute['item'] : '$loop'; + return "{$name}['list']): $list={$name}['list']; {$name}['order']++; {$name}['col']++; if({$name}['col']=={$attribute['cols']}): {$name}['col']=0; {$name}['row']++; endif; {$name}['first']={$name}['order']==1; {$name}['last']={$name}['order']=={$name}['count']; {$name}['extra']={$name}['order']>{$name}['count'];?>"; + } + + // 解析代码 + private function parseEncode($matches) { + return chr(2) . base64_encode(strtolower($matches[1]) === 'php' ? "" : trim($matches[2])) . chr(3); + } + + // 还原代码 + private function parseDecode($matches) { + return base64_decode($matches[1]); + } +} + + +function compressJS($content) { + $lines = explode("\n", $content); + foreach ($lines as &$line) { + $line = trim($line) . "\n"; + } + return implode('', $lines); + /* $content = preg_replace('/{(\/\/[^\n]*)/', '{', $content); // {//注释情况特殊处理 + $content = preg_replace('/(^\/\/[^\n]*)|([\s]+\/\/[^\n]*)/', '', $content); //行注释 + $content = preg_replace('/\)\s*[\n\r]+/', ');', $content); //圆括号换行处理 + $content = preg_replace('/([\w\$\'""]+?)\s*[\n\r]+\s*([\w\$\'""]+?)/', '$1;$2', $content); //圆括号换行处理 + $content = preg_replace('/[\n\r\t]+/', ' ', $content); //换行空格等过滤 + $content = preg_replace('/>\\s<', $content); + $content = preg_replace('/\\/\\*.*?\\*\\//i', '', $content); + $content = preg_replace("/[\n\r\t]+}/", "}", $content); + $content = preg_replace("/}[\n\r\t]+/", "}", $content); + $content = preg_replace("/[\n\r\t]+{/", "{", $content); + $content = preg_replace("/{[\n\r\t]+/", "{", $content); + $content = preg_replace("/[\n\r\t]+;/", ";", $content); + $content = preg_replace("/;[\n\r\t]+/", ";", $content); + $content = preg_replace("/[\n\r\t]+:/", ":", $content); + $content = preg_replace("/:[\n\r\t]+/", ":", $content); + $content = preg_replace("/[\n\r\t]+=/", "=", $content); + $content = preg_replace("/=[\n\r\t]+/", "=", $content); + $content = preg_replace("/,[\n\r\t]{2,}/", ", ", $content); + $content = preg_replace("/[\n\r\t]{2,}/", " ", $content); + //js特殊处理补全 + $content = preg_replace("/;}/", "}", $content); + $content = preg_replace("/}var/", "};var", $content); + $content = preg_replace("/}return/", "};return", $content); + return $content;*/ +} + +function compressCss($content) { + + $content = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $content); //删除注释 + $content = preg_replace('![ ]{2,}!', ' ', $content); //删除注释 + $content = str_replace(array("\r\n", "\r", "\n", "\t"), '', $content); //删除空白 + return $content; +} diff --git a/ptcms/library/apiclient.php b/ptcms/library/apiclient.php index 4f68d7d..94ac449 100644 --- a/ptcms/library/apiclient.php +++ b/ptcms/library/apiclient.php @@ -15,18 +15,30 @@ public function __construct($apiuri, $apiid, $apikey) { $this->apiurl = $apiuri; } - // 调用API public function __call($method, $params = array()) { - $params = ($params == array()) ? array() : $params['0']; + $params=($params == array()) ? array() : $params['0']; + return $this->call($method,$params); + } + + // 调用API + public function call($method, $params = array()) { + $url=$this->apiurl; + if (strpos($method,'/')){ + $tmp=explode('/',$method,2); + $url.='/'.$tmp['0']; + $method=$tmp['1']; + } $params['action'] = $method; $params['appid'] = $this->appid; $params['format'] = 'json'; $params['datetime'] = $_SERVER['REQUEST_TIME']; $params['sign'] = $this->sign($params); //自动重试5次 防止失败! + $data = array(); for ($i = 0; $i < 5; $i++) { - $data = json_decode(http::get($this->apiurl, $params), true); - if (is_array($data)) { + $con = http::get($url, $params); + if ($con) { + $data = json_decode($con, true); break; } } @@ -34,10 +46,10 @@ public function __call($method, $params = array()) { if ($data['status'] == 1) { return $data['data']; } else { - log::write('调用接口失败!原因:' . $data['msg'] . ' 参数:' . var_export($params, true)); + PT_Log::write('调用接口出现错误!原因:' . $data['msg'] . ' 参数:' . var_export($params, true)); } } else { - log::write('调用接口失败!方法' . $method . ' 参数:' . var_export($params, true)); + PT_Log::write('调用接口失败!方法' . $method . ' 参数:' . var_export($params, true)); } return array(); } diff --git a/ptcms/library/bae/BaeImageService.class.php b/ptcms/library/bae/BaeImageService.class.php new file mode 100644 index 0000000..0ee1139 --- /dev/null +++ b/ptcms/library/bae/BaeImageService.class.php @@ -0,0 +1,1399 @@ + 'php sdk error', + BaeImageConstant::BAE_IMAGEUI_SDK_SYS => 'php sdk error', + BaeImageConstant::BAE_IMAGEUI_SDK_INIT_FAIL => 'php sdk init error', + BaeImageConstant::BAE_IMAGEUI_SDK_PARAM => 'param invalid', + BaeImageConstant::BAE_IMAGEUI_SDK_HTTP_STATUS_ERROR_AND_RESULT_ERROR + => 'http status is error, and the body returned is not a json string', + BaeImageConstant::BAE_IMAGEUI_SDK_HTTP_STATUS_OK_BUT_RESULT_ERROR + => 'http status is ok, but the body returned is not a json string', + ); + + + public function getRequestId() + { + return $this->_requestId; + } + + public function __construct($accessKey, $secretKey, $host) + { + $this->paramArr = array(); + + if (is_null($accessKey) || $this->_checkString($accessKey, 1, 64)) { + $this->_clientId = $accessKey; + } else { + throw new BaeException("invalid param - access key[${accessKey}], which must be a 1 - 64 length string", + BaeImageConstant::BAE_IMAGEUI_SDK_INIT_FAIL); + } + + if (is_null($secretKey) || $this->_checkString($secretKey, 1, 64)) { + $this->_clientSecret = $secretKey; + } else { + throw new BaeException("invalid param - secret key[${secretKey}], which must be a 1 - 64 length string", + BaeImageConstant::BAE_IMAGEUI_SDK_INIT_FAIL); + } + + if (is_null($host) || $this->_checkString($host, 1, 1024)) { + if (!is_null($host)) { + $this->_host = $host; + } + } else { + throw new BaeException("invalid param - host[${host}], which must be a 1 - 1024 length string", + BaeImageConstant::BAE_IMAGEUI_SDK_INIT_FAIL); + } + $this->_resetErrorStatus(); + + } + + private function _get_ak_sk_host(&$opt, $opt_key, $member, $g_key, $env_key, $min, $max) + { + $dis = array( + 'client_id' => 'access_key', + 'client_secret' => 'secret_key', + 'host' => 'host' + ); + + global $$g_key; + + if (isset($opt[$opt_key])) { + if (!$this->_checkString($opt[$opt_key], $min, $max)) { + throw new BaeException('invalid ' . $dis[$opt_key] . ' in $optinal(' + . $opt[$opt_key] . '), which must be a ' . $min . ' - ' . $max . ' length string', + BaeImageConstant::BAE_IMAGEUI_SDK_PARAM); + } + return; + } + if ($this->_checkString($member, $min, $max)) { + $opt[$opt_key]= $member; + return; + } + if (isset($$g_key)) { + if (!$this->_checkString($$g_key, $min, $max)) { + throw new BaeException('invalid ' . $g_key . ' in global area(' + . $$g_key . '), which must be a ' . $min . ' - ' . $max . ' length string', + BaeImageConstant::BAE_IMAGEUI_SDK_PARAM); + } + $opt[$opt_key]= $$g_key; + return; + } + if (false !== getenv($env_key)) { + if (! $this->_checkString(getenv($env_key), $min, $max)) { + throw new BaeException('invalid ' . $env_key . ' in environment variable(' + . getenv($env_key). '), which must be a ' . $min . ' - ' . $max . ' length string', + BaeImageConstant::BAE_IMAGEUI_SDK_PARAM); + } + $opt[$opt_key]= getenv($env_key); + return; + } + if ($opt_key === self::HOST) { + $opt[$opt_key]= self::DEFAULT_HOST; + return; + } + + throw new BaeException('no param(' . $dis[$opt_key] . ')was found', BaeImageConstant::BAE_IMAGEUI_SDK_PARAM); + } + + private function _adjustOpt(&$opt) + { + if (! isset($opt) || empty($opt) || !is_array($opt)) { + throw new BaeException('no params are set', BaeImageConstant::BAE_IMAGEUI_SDK_PARAM); + } + if (!isset($opt[self::TIMESTAMP])) { + $opt[self::TIMESTAMP]= time(); + } + + $this->_get_ak_sk_host($opt, self::ACCESS_KEY, $this->_clientId, + 'g_accessKey', 'HTTP_BAE_ENV_AK', 1, 64); + $this->_get_ak_sk_host($opt, self::SECRET_KEY, $this->_clientSecret, + 'g_secretKey', 'HTTP_BAE_ENV_SK', 1, 64); + $this->_get_ak_sk_host($opt, self::HOST, $this->_host, + 'g_host', 'HTTP_BAE_ENV_ADDR_BUS', 1, 1024); + } + + private function _getSign(&$opt, &$arrContent, $arrNeed = array()) + { + $arrData = array(); + $arrContent = array(); + $arrNeed[] = self::TIMESTAMP; + $arrNeed[] = self::METHOD; + $arrNeed[] = self::ACCESS_KEY; + if (isset($opt[self::EXPIRES])) { + $arrNeed[] = self::EXPIRES; + } + if (isset($opt[self::VERSION])) { + $arrNeed[] = self::VERSION; + } + + $arrExclude = array(self::HOST, self::SECRET_KEY); + foreach ($arrNeed as $key) { + if (!isset($opt[$key]) || (!is_integer($opt[$key]) && empty($opt[$key]))) { + throw new BaeException("lack param(${key})", BaeImageConstant::BAE_IMAGEUI_SDK_PARAM); + } + if (in_array($key, $arrExclude)) { + continue; + } + $arrData[$key] = $opt[$key]; + $arrContent[$key] = $opt[$key]; + } + foreach ($opt as $key => $value) { + if (!in_array($key, $arrNeed) && !in_array($key, $arrExclude)) { + $arrData[$key]= $value; + $arrContent[$key]= $value; + } + } + ksort($arrData); + $url = 'http://' . $opt[self::HOST] . '/rest/2.0/' . self::PRODUCT . '/'; + if (isset($opt[self::RESOURCE]) && !is_null($opt[self::RESOURCE])){ + $url .= $opt[self::RESOURCE]; + $arrContent[self::RESOURCE]= $opt[self::RESOURCE]; + }else { + $url .= self::RESOURCE; + } + $basicString = 'POST' . $url; + foreach ($arrData as $key => $value) { + $basicString .= $key . '=' . $value; + } + $basicString .= $opt[self::SECRET_KEY]; + + $sign = md5(urlencode($basicString)); + $arrContent[self::SIGN] = $sign; + $arrContent[self::HOST] = $opt[self::HOST]; + } + + private function _baseControl($opt) + { + $content = ''; + $resource = self::RESOURCE; + if (isset($opt[self::RESOURCE]) && !is_null($opt[self::RESOURCE])) { + $resource = $opt[self::RESOURCE]; + } + + $host = $opt[self::HOST]; + unset($opt[self::HOST]); + + foreach ($opt as $k => $v) { + if (is_string($v)) { + $v = urlencode($v); + } + $content .= $k . '=' . $v . '&'; + } + $content = substr($content, 0, strlen($content)- 1); + $url = 'http://' . $host . '/rest/2.0/' . self::PRODUCT . '/'; + $url .= $resource; + + $request = new RequestCore($url); + $headers['Content-Type'] = 'application/x-www-form-urlencoded'; + $headers['User-Agent'] = 'Baidu ImageUi Phpsdk Client'; + foreach ($headers as $headerKey => $headerValue) { + $headerValue = str_replace(array("\r", "\n"), '', $headerValue); + if ($headerValue !== '') { + $request->add_header($headerKey, $headerValue); + } + } + $request->set_method('POST'); + $request->set_body($content); + $request->send_request(); + return new ResponseCore($request->get_response_header(), + $request->get_response_body(), + $request->get_response_code()); + } + + + private function _commonProcess($paramOpt = NULL, $arrNeed = array()) + { + $this->_adjustOpt($paramOpt); + $arrContent = array(); + $this->_getSign($paramOpt, $arrContent, $arrNeed); + /****************************debug**********************/ + //var_dump($arrContent); + $ret = $this->_baseControl($arrContent); + if (empty($ret)) { + throw new BaeException('base control returned empty object', BaeImageConstant::BAE_IMAGEUI_SDK_SYS); + } + if ($ret->isOK()) { + $result = json_decode($ret->body, true); + if (is_null($result)) { + throw new BaeException($ret->body, + BaeImageConstant::BAE_IMAGEUI_SDK_HTTP_STATUS_OK_BUT_RESULT_ERROR); + } + $this->_requestId = $result['request_id']; + + return $result; + } + $result = json_decode($ret->body, true); + if (is_null($result)) { + throw new BaeException('ret body: ' . $ret->body, + BaeImageConstant::BAE_IMAGEUI_SDK_HTTP_STATUS_ERROR_AND_RESULT_ERROR); + } + $this->_requestId = $result['request_id']; + + trigger_error("request_id : " . $this->_requestId . ", fail . error_msg: " + . $result['error_msg'].", error_code: " . $result['error_code'], + E_USER_WARNING); + throw new BaeException($result['error_msg'], $result['error_code']); + } + + /** + * Apply transforms into an image + * @param baeImageSource array

image source, + * contains image source or image url

+ * @param baeImageTransform BaeImageTransform,

contains variety transforms

+ * @param isURL bool

true for image source is URL, false for image + * byte string

+ * @return Image-relevant data,if success, otherwise return false + */ + public function applyTransformByObject($baeImageSource, $baeImageTransform) + { + $isURL=true; + $URL = ''; + $this->_resetErrorStatus(); + try { + if(empty($baeImageTransform) || !($baeImageTransform instanceof BaeImageTransform)){ + throw new BaeException('input source is not an instance of BaeImageTransform', BaeImageConstant::BAE_IMAGEUI_SDK_PARAM); + } + if($baeImageTransform->errcode !== 0){ + $this->errcode = $baeImageTransform->errcode; + $this->errmsg = $baeImageTransform->errmsg; + return false; + + } + if(empty($baeImageSource)){ + throw new BaeException('no bae image source', BaeImageConstant::BAE_IMAGEUI_SDK_PARAM); + } + + /********************examming url pattern*******************************/ + if($isURL === true){ + $this->_examURL($baeImageSource); + $URL = $baeImageSource; + }else{ + //restrict image into 2M + if(!$this->_checkString($baeImageSource, 0, 2*1024*1024)){ + throw new BaeException('image must be less than 2M', BaeImageConstant::BAE_IMAGEUI_SDK_PARAM); + } + } + + $paramArr = $baeImageTransform->getOperations();// obtain the operations setting on the image + $paramArr['src'] = $URL; + $arrArgs = array( + self::METHOD => 'process',/*'appid'=>"appid7avderfd05",'dev_uid'=>'12345','secret_key'=>'pNceSAlS4HB8fToDilmXQvwSc6nHInHW',*/ + ); + $arrArgs = array_merge($arrArgs, $paramArr); + return $this->_commonProcess($arrArgs,array('src',)); + + } catch (Exception $ex) { + $this->_exceptionHandler($ex); + return false; + } + + } + + /** + * Apply transforms into an image + * @param image string

image source, + * contains image source or image url

+ * @param params array

options operating into an image

+ * @param isURL bool

true for image source is URL, false for image + * byte string

+ * @return Image-relevant data,if success, otherwise return false + * + */ + public function applyTransform($baeImageSource, $params=array()) + { + $isURL=true; + $URL = ''; + $baeImageTransform = new BaeImageTransform(); + $this->_resetErrorStatus(); + try{ + if(!is_array($params)){ + throw new BaeException(sprintf('invalid parameters, [%s] should be array', $params), + BaeImageConstant::BAE_IMAGEUI_SDK_PARAM); + } + + if (!empty($params)){ + foreach ($params as $key => $value){ + if(!is_string($key)){ + throw new BaeException(sprintf('invalid key [%s]', $key), + BaeImageConstant::BAE_IMAGEUI_SDK_PARAM); + } + switch($key){ + case BaeImageConstant::TRANSFORM_ZOOMING: + if(!is_array($value) || count($value) < 2 || count($value) > 3){ + throw new BaeException('invalid zooming param', BaeImageConstant::BAE_IMAGEUI_SDK_PARAM); + } + if(count($value) == 3){ + $baeImageTransform->setZooming($value[0], $value[1],$value[2]); + }else{ + $baeImageTransform->setZooming($value[0], $value[1]); + } + break; + case BaeImageConstant::TRANSFORM_CROPPING: + if(!is_array($value) || count($value) != 4){ + throw new BaeException('invalid cropping param', BaeImageConstant::BAE_IMAGEUI_SDK_PARAM); + } + $baeImageTransform->setCropping($value[0], $value[1], $value[2], $value[3]); + break; + case BaeImageConstant::TRANSFORM_ROTATE: + $baeImageTransform->setRotation($value); + break; + case BaeImageConstant::TRANSFORM_HUE: + $baeImageTransform->setHue($value); + break; + case BaeImageConstant::TRANSFORM_LIGHTNESS: + $baeImageTransform->setLightness($value); + break; + case BaeImageConstant::TRANSFORM_CONTRAST: + $baeImageTransform->setContrast($value); + break; + case BaeImageConstant::TRANSFORM_SHARPNESS: + $baeImageTransform->setSharpness($value); + break; + case BaeImageConstant::TRANSFORM_SATURATION: + $baeImageTransform->setSaturation($value); + break; + case BaeImageConstant::TRANSFORM_TRANSCODE: + if(!is_array($value) || count($value) > 2 || count($value) == 0){ + throw new BaeException('invalid transcode param', BaeImageConstant::BAE_IMAGEUI_SDK_PARAM); + } + if(count($value) == 2){ + $baeImageTransform->setTranscoding($value[0], $value[1]); + }else{ + $baeImageTransform->setTranscoding($value[0]); + } + break; + case BaeImageConstant::TRANSFORM_QUALITY: + $baeImageTransform->setQuality($value); + break; + case BaeImageConstant::TRANSFORM_GETGIFFIRSTFRAME: + $baeImageTransform->setGetGifFirstFrame(); + break; + case BaeImageConstant::TRANSFORM_HORIZONTALFLIP: + $baeImageTransform->horizontalFlip(); + break; + case BaeImageConstant::TRANSFORM_VERTICALFLIP: + $baeImageTransform->verticalFlip(); + break; + case BaeImageConstant::TRANSFORM_AUTOROTATE: + $baeImageTransform->setAutorotate(); + break; + case BaeImageConstant::TRANSFORM_CLEAROPERATIONS: + $baeImageTransform->clearOperations(); + break; + default: + throw new BaeException(sprintf('invalid key [%s]', $key), + BaeImageConstant::BAE_IMAGEUI_SDK_PARAM); + } + } + } + if($baeImageTransform->errcode !== 0){ + $this->errcode = $baeImageTransform->errcode; + $this->errmsg = $baeImageTransform->errmsg; + return false; + } + if(empty($baeImageSource)){ + throw new BaeException('no bae image source', BaeImageConstant::BAE_IMAGEUI_SDK_PARAM); + } + // handle the baeImageSource + if($isURL === true){ + $this->_examURL($baeImageSource); + $URL = $baeImageSource; + }else{ + //restrict image into 2M + if(!$this->_checkString($baeImageSource, 0, 2*1024*1024)){ + throw new BaeException('image must be less than 2M', BaeImageConstant::BAE_IMAGEUI_SDK_PARAM); + } + } + + unset($params); + $params = $baeImageTransform->getOperations(); + $params['src'] = $URL; + $arrArgs = array( + self::METHOD => 'process',); + $arrArgs = array_merge($arrArgs, $params); + return $this->_commonProcess($arrArgs,array('src',)); + + } catch (Exception $ex) { + $this->_exceptionHandler($ex); + return false; + } + } + + + /** + * Apply an annotation into an image + * @param baeImageSource string,

image source or image url

+ * @param isURL bool,

true for $image field + * is URL, false for image byte string

+ * @param baeImageAnnotate BaeImageAnnotate, contains variety of + * operations about annotation. + * @return Image-relevant data,if success, otherwise return false + */ + public function applyAnnotateByObject($baeImageSource, $baeImageAnnotate) + { + $isURL=true; + $URL = ''; + $this->_resetErrorStatus(); + try { + if(empty($baeImageAnnotate) || !($baeImageAnnotate instanceof BaeImageAnnotate)){ + throw new BaeException('input source is not an instance of BaeImageAnnotate', BaeImageConstant::BAE_IMAGEUI_SDK_PARAM); + } + if($baeImageAnnotate->errcode !== 0){ + $this->errcode = $baeImageAnnotate->errcode; + $this->errmsg = $baeImageAnnotate->errmsg; + return false; + } + if(empty($baeImageSource)){ + throw new BaeException('no bae image source', BaeImageConstant::BAE_IMAGEUI_SDK_PARAM); + } + /********************examming url pattern*******************************/ + if($isURL === true){ + $this->_examURL($baeImageSource); + $URL = $baeImageSource; + }else{ + if(!$this->_checkString($baeImageSource, 0, 2*1024*1024)){ + throw new BaeException('image must be less than 2M', BaeImageConstant::BAE_IMAGEUI_SDK_PARAM); + } + } + + $operations = $baeImageAnnotate->getOperations(); + + // $operations must contain text + if (empty($operations['text'])) { + throw new BaeException('no text script', BaeImageConstant::BAE_IMAGEUI_SDK_PARAM); + } + $jsonParams = $this->_formJsonParams($URL, $operations, $this->ProcType_Annotate, true); + $paramArr = array('strudata'=>$jsonParams); + $arrArgs = array( + self::METHOD => 'processExt',/*'appid'=>"appid7avderfd05",'dev_uid'=>'12345','secret_key'=>'pNceSAlS4HB8fToDilmXQvwSc6nHInHW',*/ + ); + $arrArgs = array_merge($arrArgs, $paramArr); + return $this->_commonProcess($arrArgs); + + }catch (Exception $ex) { + //echo "exception:". $ex->getMessage(); + $this->_exceptionHandler($ex); + return false; + } + } + + /** + * Apply an annotation into an image + * @param image string,

image source or image url

+ * @param isURL bool,

true for $image field + * is URL, false for image data source

+ * @param params array,

contains variety of + * operations about annotation

+ * @return Image-relevant data,if success, otherwise return false + */ + public function applyAnnotate($baeImageSource, $text, $params=array()) + { + $isURL=true; + $URL = ''; + $baeImageAnnotate = new BaeImageAnnotate(); + $this->_resetErrorStatus(); + try{ + if(!is_array($params)){ + throw new BaeException(sprintf('invalid parameters, [%s] should be array', $params), + BaeImageConstant::BAE_IMAGEUI_SDK_PARAM); + } + if (!empty($params)) { + foreach ($params as $key => $value){ + if(!is_string($key)){ + throw new BaeException(sprintf('invalid key [%s]', $key), + BaeImageConstant::BAE_IMAGEUI_SDK_PARAM); + } + switch($key){ + case BaeImageConstant::ANNOTATE_OPACITY: + $baeImageAnnotate->setOpacity($value); + break; + case BaeImageConstant::ANNOTATE_OUTPUTCODE: + $baeImageAnnotate->setOutputCode($value); + break; + case BaeImageConstant::ANNOTATE_QUALITY: + $baeImageAnnotate->setQuality($value); + break; + case BaeImageConstant::ANNOTATE_FONT: + if(!is_array($value) || count($value) != 3){ + throw new BaeException('invalid font param', BaeImageConstant::BAE_IMAGEUI_SDK_PARAM); + } + $baeImageAnnotate->setFont($value[0],$value[1],$value[2]); + break; + case BaeImageConstant::ANNOTATE_POS: + if(!is_array($value) || count($value) != 2){ + throw new BaeException('invalid pos param', BaeImageConstant::BAE_IMAGEUI_SDK_PARAM); + } + $baeImageAnnotate->setPos($value[0],$value[1]); + break; + case BaeImageConstant::ANNOTATE_CLEAROPERATIONS: + $baeImageAnnotate->clearOperations(); + break; + default: + throw new BaeException(sprintf('invalid key [%s]', $key), + BaeImageConstant::BAE_IMAGEUI_SDK_PARAM); + } + } + } + if(empty($baeImageSource)){ + throw new BaeException('no bae image source', BaeImageConstant::BAE_IMAGEUI_SDK_PARAM); + } + if(empty($text)){ + throw new BaeException('no text script', BaeImageConstant::BAE_IMAGEUI_SDK_PARAM); + } + $baeImageAnnotate->setText($text); // check $text + if($baeImageAnnotate->errcode !== 0){ + $this->errcode = $baeImageAnnotate->errcode; + $this->errmsg = $baeImageAnnotate->errmsg; + return false; + } + /********************examming url pattern*******************************/ + if($isURL == true){ + $this->_examURL($baeImageSource); + $URL = $baeImageSource; + }else{ + //restrict image into 2M + if(!$this->_checkString($baeImageSource, 0, 2*1024*1024)){ + throw new BaeException('image must be less than 2M', BaeImageConstant::BAE_IMAGEUI_SDK_PARAM); + } + } + unset($params); + + $operations = $baeImageAnnotate->getOperations(); + $jsonParams = $this->_formJsonParams($URL, $operations, $this->ProcType_Annotate, true); + $paramArr = array('strudata'=>$jsonParams); + $arrArgs = array( + self::METHOD => 'processExt',); + $arrArgs = array_merge($arrArgs, $paramArr); + return $this->_commonProcess($arrArgs); + + } catch (Exception $ex) { + //echo "exception:". $ex->getMessage(); + $this->_exceptionHandler($ex); + return false; + } + } + + /** + * Generate a QR Code image about a text script. + * @param baeImageQRCode BaeImageQRCode,

contains variety of + * operations about QR Code

+ * @return Image-relevant data,if success, otherwise return false + */ + public function applyQRCodeByObject($baeImageQRCode) + { + $this->_resetErrorStatus(); + try { + if(empty($baeImageQRCode) || !($baeImageQRCode instanceof BaeImageQRCode)){ + throw new BaeException('input source is not an instance of BaeImageQRCode', BaeImageConstant::BAE_IMAGEUI_SDK_PARAM); + } + if($baeImageQRCode->errcode !== 0){ + $this->errcode = $baeImageQRCode->errcode; + $this->errmsg = $baeImageQRCode->errmsg; + return false; + } + $operations = $baeImageQRCode->getOperations(); + // $operations must contain text + if (empty($operations['text'])) { + throw new BaeException('no text script', BaeImageConstant::BAE_IMAGEUI_SDK_PARAM); + } + $jsonParams = $this->_formJsonParams(null, $operations, $this->ProcType_QRCode, false); + $paramArr = array('strudata'=>$jsonParams); + $arrArgs = array( + self::METHOD => 'processExt', + ); + $arrArgs = array_merge($arrArgs, $paramArr); + return $this->_commonProcess($arrArgs); + + }catch (Exception $ex) { + $this->_exceptionHandler($ex); + return false; + } + } + + /** + * Generate a QR Code image about a text script. + * @param text string,

text script for processing

+ * @param params array,

contains variety of + * operations about QR Code

+ * @return Image-relevant data,if success, otherwise return false + */ + public function applyQRCode($text, $params=array()) + { + $baeImageQRCode = new BaeImageQRCode(); + $this->_resetErrorStatus(); + try{ + if(empty($text)){ + throw new BaeException('no text script', BaeImageConstant::BAE_IMAGEUI_SDK_PARAM); + } + if(!is_array($params)){ + throw new BaeException(sprintf('invalid parameters, [%s] should be array', $params), + BaeImageConstant::BAE_IMAGEUI_SDK_PARAM); + } + if (!empty($params)){ + foreach ($params as $key => $value){ + if(!is_string($key)){ + throw new BaeException(sprintf('invalid key [%s]', $key), + BaeImageConstant::BAE_IMAGEUI_SDK_PARAM); + } + switch($key){ + case BaeImageConstant::QRCODE_SIZE: + $baeImageQRCode->setSize($value); + break; + case BaeImageConstant::QRCODE_LEVEL: + $baeImageQRCode->setLevel($value); + break; + case BaeImageConstant::QRCODE_VERSION: + $baeImageQRCode->setVersion($value);; + break; + case BaeImageConstant::QRCODE_MARGIN: + $baeImageQRCode->setMargin($value); + break; + case BaeImageConstant::QRCODE_FOREGROUND: + $baeImageQRCode->setForeground($value); + break; + case BaeImageConstant::QRCODE_BACKGROUND: + $baeImageQRCode->setBackground($value); + break; + case BaeImageConstant::QRCODE_CLEAROPERATIONS: + $baeImageQRCode->clearOperations(); + break; + default: + throw new BaeException(sprintf('invalid key [%s]', $key), + BaeImageConstant::BAE_IMAGEUI_SDK_PARAM); + } + } + } + unset($params); + if($baeImageQRCode->errcode !== 0){ + $this->errcode = $baeImageQRCode->errcode; + $this->errmsg = $baeImageQRCode->errmsg; + return false; + } + $operations = $baeImageQRCode->getOperations(); + // GBK ENCODE + $this->_checkString2($text,'text', 1,500); + $text = mb_convert_encoding($text, 'GBK', 'UTF-8'); + $operations['text'] = $text; + $jsonParams = $this->_formJsonParams(null, $operations, $this->ProcType_QRCode, false); + $paramArr = array('strudata'=>$jsonParams); + $arrArgs = array( + self::METHOD => 'processExt',); + $arrArgs = array_merge($arrArgs, $paramArr); + return $this->_commonProcess($arrArgs); + + } catch (Exception $ex) { + $this->_exceptionHandler($ex); + return false; + } + } + + /** + * Apply composition + * @param composites array,

a set of BaeImageComposite object

+ * @param canvas_width[optional] int,

canvas width

+ * @param canvas_height[optional] int,

canvas height

+ * @param outputcode[optional] BaeImageConstant,

output image type

+ * @param quality[optional] int,

output image quality

+ * @return Image-relevant data,if success, otherwise return false + */ + public function applyCompositeByObject($composites, $canvas_width = 1000, $canvas_height = 1000, + $outputcode = BaeImageConstant::JPG, $quality = 80) + { + + $this->_resetErrorStatus(); + try { + if(empty($composites) || ! is_array($composites)){ + throw new BaeException('input source is not a BaeImageComposite array', BaeImageConstant::BAE_IMAGEUI_SDK_PARAM); + } + //common params + $this->_checkInt($canvas_width, 'canvas width', 0, 10000); + $this->_checkInt($canvas_height, 'canvas height', 0, 10000); + $this->_checkInt($outputcode, 'outputcode', 0, 3); + $this->_checkInt($quality, 'quality', 0, 100); + $commParams = array('desttype'=> $outputcode, 'canvas_width'=> $canvas_width, + 'canvas_height'=>$canvas_height, 'quality'=>$quality); + $len = count($composites); + if($len < 2){ + throw new BaeException('short of images, at least two elements', BaeImageConstant::BAE_IMAGEUI_SDK_PARAM); + } + if($len > 2){ + throw new BaeException('too many images, at most two elements', BaeImageConstant::BAE_IMAGEUI_SDK_PARAM); + } + /*construct parameter array of _formJsonParmas()*/ + $operations = array(); + $isURL = array(); + $imageSource = array(); + if(!($composites[0] instanceof BaeImageComposite)){ + throw new BaeException('input source is not an instance of BaeImageComposite', BaeImageConstant::BAE_IMAGEUI_SDK_PARAM); + } + if($composites[0]->errcode !== 0){ + $this->errcode = $composites[0]->errcode; + $this->errmsg = $composites[0]->errmsg; + return false; + } + $operations[0] = $composites[0]->getOperations(); + // merge common params + $operations = array_merge($operations, $commParams); + $baeImageSource = $composites[0]->getBaeImageSource(); + if (empty($baeImageSource['data'])) { + throw new BaeException('no commosite image parameters', BaeImageConstant::BAE_IMAGEUI_SDK_PARAM); + } + $imageSource[0] = $baeImageSource['data']; + $isURL[0] = $baeImageSource['isURL']; + + for($i=1;$i<$len;$i++){ + if(!($composites[$i] instanceof BaeImageComposite)){ + throw new BaeException('input source is not an instance of BaeImageComposite', BaeImageConstant::BAE_IMAGEUI_SDK_PARAM); + } + if($composites[$i]->errcode !== 0){ + $this->errcode = $composites[$i]->errcode; + $this->errmsg = $composites[$i]->errmsg; + return false; + } + $operations[1] = $composites[$i]->getOperations(); + $baeImageSource = $composites[$i]->getBaeImageSource(); + if (empty($baeImageSource['data'])) { + throw new BaeException('no commosite image parameters', BaeImageConstant::BAE_IMAGEUI_SDK_PARAM); + } + $imageSource[1] = $baeImageSource['data']; + $isURL[1] = $baeImageSource['isURL']; + $jsonParams = $this->_formJsonParams($imageSource, $operations,$this->ProcType_Composite, $isURL); + $paramArr = array('strudata'=>$jsonParams); + $arrArgs = array( + self::METHOD => 'processExt',); + $arrArgs = array_merge($arrArgs, $paramArr); + $retImage = $this->_commonProcess($arrArgs); + } + return $retImage; + + }catch (Exception $ex) { + $this->_exceptionHandler($ex); + return false; + } + } + + /** + * Apply composition + * @param params array,

contains variety of operaitons about composite

+ * @param canvas_width[optional] int,

canvas width

+ * @param canvas_height[optional] int,

canvas height

+ * @param outputcode[optional] BaeImageConstant,

output image type

+ * @param quality[optional] int,

output image quality

+ * @return Image-relevant data,if success, otherwise return false + */ + public function applyComposite($params,$canvas_width = 1000, $canvas_height = 1000, + $outputcode = BaeImageConstant::JPG, $quality = 80) + { + $baeImageComposite = new BaeImageComposite(); + $this->_resetErrorStatus(); + try{/*check common paramters*/ + $this->_checkInt($canvas_width, 'canvas width', 0, 10000); + $this->_checkInt($canvas_height, 'canvas height', 0, 10000); + $this->_checkInt($outputcode, 'outputcode', 0, 3); + $this->_checkInt($quality, 'quality', 0, 100); + $commParams = array('desttype'=> $outputcode, 'canvas_width'=> $canvas_width, + 'canvas_height'=>$canvas_height, 'quality'=>$quality); + + if (empty($params) || !is_array($params)) {//// + throw new BaeException(sprintf('invalid parameters, [%s] should be array', $params), + BaeImageConstant::BAE_IMAGEUI_SDK_PARAM); + } + if(count($params) < 2){ + throw new BaeException('short of images, at least two elements', BaeImageConstant::BAE_IMAGEUI_SDK_PARAM); + } + if(count($params) > 2){ + throw new BaeException('too many images, at most two elements', BaeImageConstant::BAE_IMAGEUI_SDK_PARAM); + } + + $operations = array(); + $isURL = array(); + $imageSource = array(); + $paramElement = $params[0]; + foreach ($paramElement as $key => $value){ + if(!is_string($key)){ + throw new BaeException(sprintf('invalid key [%s]', $key), + BaeImageConstant::BAE_IMAGEUI_SDK_PARAM); + } + switch($key){ + case BaeImageConstant::COMPOSITE_BAEIMAGESOURCE: + //if(!is_array($value) || count($value) != 2){ + if(!is_array($value)){ + throw new BaeException('invalid bae image source parameter', BaeImageConstant::BAE_IMAGEUI_SDK_PARAM); + } + if (empty($value[0])) { + throw new BaeException('no image source parameters', BaeImageConstant::BAE_IMAGEUI_SDK_PARAM); + } + if(count($value) === 2){ + $baeImageComposite->setBaeImageSource($value[0], $value[1]); + }else{ + $baeImageComposite->setBaeImageSource($value[0]); + } + break; + case BaeImageConstant::COMPOSITE_OPACITY: + $baeImageComposite->setOpacity($value); + break; + case BaeImageConstant::COMPOSITE_ANCHOR: + $baeImageComposite->setAnchor($value); + break; + case BaeImageConstant::COMPOSITE_POS: + if(!is_array($value) || count($value) != 2){ + throw new BaeException('invalid position parameter', BaeImageConstant::BAE_IMAGEUI_SDK_PARAM); + } + $baeImageComposite->setPos($value[0],$value[1]); + break; + case BaeImageConstant::COMPOSITE_CLEAROPERATIONS: + $baeImageComposite->clearOperations(); + break; + default: + throw new BaeException(sprintf('invalid key [%s]', $key), + BaeImageConstant::BAE_IMAGEUI_SDK_PARAM); + } + } + if($baeImageComposite->errcode !== 0){ + $this->errcode = $baeImageComposite->errcode; + $this->errmsg = $baeImageComposite->errmsg; + return false; + } + $operations[0] = $baeImageComposite->getOperations(); + $operations = array_merge($operations, $commParams); + $baeImageSource = $baeImageComposite->getBaeImageSource(); + $imageSource[0] = $baeImageSource['data']; + $isURL[0] = $baeImageSource['isURL']; + + for($i=1,$len=count($params);$i<$len;$i++){ + $baeImageComposite->clearOperations(); + $paramElement = $params[$i]; + foreach ($paramElement as $key => $value){ + if(!is_string($key)){ + throw new BaeException(sprintf('invalid key [%s]', $key), + BaeImageConstant::BAE_IMAGEUI_SDK_PARAM); + } + switch($key){ + case BaeImageConstant::COMPOSITE_BAEIMAGESOURCE: + if(!is_array($value)){ + throw new BaeException('invalid bae image source parameter', BaeImageConstant::BAE_IMAGEUI_SDK_PARAM); + } + if (empty($value[0])) { + throw new BaeException('no image source parameters', BaeImageConstant::BAE_IMAGEUI_SDK_PARAM); + } + if(count($value) === 2){ + $baeImageComposite->setBaeImageSource($value[0], $value[1]); + }else{ + $baeImageComposite->setBaeImageSource($value[0]); + } + break; + case BaeImageConstant::COMPOSITE_OPACITY: + $baeImageComposite->setOpacity($value); + break; + case BaeImageConstant::COMPOSITE_ANCHOR: + $baeImageComposite->setAnchor($value); + break; + case BaeImageConstant::COMPOSITE_POS: + if(!is_array($value) || count($value) != 2){ + throw new BaeException('invalid position parameter', BaeImageConstant::BAE_IMAGEUI_SDK_PARAM); + } + $baeImageComposite->setPos($value[0],$value[1]); + break; + case BaeImageConstant::COMPOSITE_CLEAROPERATIONS: + $baeImageComposite->clearOperations(); + break; + default: + throw new BaeException(sprintf('invalid key [%s]', $key), + BaeImageConstant::BAE_IMAGEUI_SDK_PARAM); + } + } + if($baeImageComposite->errcode !== 0){ + $this->errcode = $baeImageComposite->errcode; + $this->errmsg = $baeImageComposite->errmsg; + return false; + + } + $operations[1] = $baeImageComposite->getOperations(); + $baeImageSource = $baeImageComposite->getBaeImageSource(); + $imageSource[1] = $baeImageSource['data']; + $isURL[1] = $baeImageSource['isURL']; + + $jsonParams = $this->_formJsonParams($imageSource, $operations, + $this->ProcType_Composite, $isURL); + $paramArr = array('strudata'=>$jsonParams); + $arrArgs = array( + self::METHOD => 'processExt',); + $arrArgs = array_merge($arrArgs, $paramArr); + $retImage = $this->_commonProcess($arrArgs); + } + return $retImage; + } catch (Exception $ex) { + //echo "exception:" . $ex->getMessage(); + $this->_exceptionHandler($ex); + return false; + } + } + + /** + * Generate verificaion code + * @param baeImageVCode BaeImageVCode,

contains variety of setting about vcdoe

+ * @return image url of vcode,if success, otherwise return false + */ + public function generateVCode($params=array()) + { + $this->_resetErrorStatus(); + $baeImageVCode = new BaeImageVCode(); + try { + if(!is_array($params)){ + throw new BaeException(sprintf('invalid parameters, [%s] should be array', $params), + BaeImageConstant::BAE_IMAGEUI_SDK_PARAM); + } + + if (!empty($params)) { + foreach ($params as $key => $value){ + if(!is_string($key)){ + throw new BaeException(sprintf('invalid key [%s]', $key), + BaeImageConstant::BAE_IMAGEUI_SDK_PARAM); + } + switch ($key){ + case BaeImageConstant::VCODE_LEN: + $baeImageVCode->setLen($value); + break; + case BaeImageConstant::VCODE_PATTERN: + $baeImageVCode->setPattern($value); + break; + case BaeImageConstant::VCODE_CLEAROPERATIONS: + $baeImageVCode->clearOperations(); + break; + default: + throw new BaeException(sprintf('invalid key [%s]', $key), + BaeImageConstant::BAE_IMAGEUI_SDK_PARAM); + } + } + } + unset($params); + if($baeImageVCode->errcode !== 0){ + $this->errcode = $baeImageVCode->errcode; + $this->errmsg = $baeImageVCode->errmsg; + return false; + } + + $paramArr = $baeImageVCode->getOperations();// obtain the operations setting on the vcode + $paramArr['vcservice'] = 0;//generate vcode + $arrArgs = array( + self::METHOD => 'process', + ); + $arrArgs = array_merge($arrArgs, $paramArr); + $retArr = $this->_commonProcess($arrArgs); + $retStatus = $retArr['response_params']['status']; + if($retStatus !== 0){ + throw new BaeException('failed to get verification code', BaeImageConstant::BAE_IMAGEUI_SDK_HTTP_STATUS_OK_BUT_RESULT_ERROR); + } + return $retArr; + } catch (Exception $ex) { + $this->_exceptionHandler($ex); + return false; + } + + } + + /** + * Verify vcode + * @param baeImageVCode BaeImageVCode,

contains variety of setting about vcdoe

+ * @return result of vcode,if success, otherwise return false + */ + public function verifyVCode($params) + { + $this->_resetErrorStatus(); + $baeImageVCode = new BaeImageVCode(); + try { + if(empty($params)){ + throw new BaeException(sprintf('invalid parameters, [%s] is empty', $params), + BaeImageConstant::BAE_IMAGEUI_SDK_PARAM); + } + if(!is_array($params)){ + throw new BaeException(sprintf('invalid parameters, [%s] should be array', $params), + BaeImageConstant::BAE_IMAGEUI_SDK_PARAM); + } + if(empty($params['input'])){ + throw new BaeException(sprintf('invalid parameters, [%s] input field is empty ', $params), + BaeImageConstant::BAE_IMAGEUI_SDK_PARAM); + } + if(empty($params['secret'])){ + throw new BaeException(sprintf('invalid parameters, [%s] secret field is empty ', $params), + BaeImageConstant::BAE_IMAGEUI_SDK_PARAM); + } + foreach ($params as $key => $value){ + if(!is_string($key)){ + throw new BaeException(sprintf('invalid key [%s]', $key), + BaeImageConstant::BAE_IMAGEUI_SDK_PARAM); + } + switch ($key){ + case BaeImageConstant::VCODE_INPUT: + $baeImageVCode->setInput($value); + break; + case BaeImageConstant::VCODE_SECRET: + $baeImageVCode->setSecret($value); + break; + case BaeImageConstant::VCODE_CLEAROPERATIONS: + $baeImageVCode->clearOperations(); + break; + default: + throw new BaeException(sprintf('invalid key [%s]', $key), + BaeImageConstant::BAE_IMAGEUI_SDK_PARAM); + } + } + + unset($params); + if($baeImageVCode->errcode !== 0){ + $this->errcode = $baeImageVCode->errcode; + $this->errmsg = $baeImageVCode->errmsg; + return false; + } + $paramArr = $baeImageVCode->getOperations();// obtain the operations setting on the vcode + $paramArr['vcservice'] = 1;//verify vcode + $arrArgs = array( + self::METHOD => 'process', + ); + $arrArgs = array_merge($arrArgs, $paramArr); + return $this->_commonProcess($arrArgs); + + } catch (Exception $ex) { + $this->_exceptionHandler($ex); + return false; + } + } + + /* + * + * formed json type params using the given input + * @param type mixed $imageSource, image source data or url + * @param type array $operations + * @param int $procType + * @param bool $isURL + * + * @return the json-formed params + */ + private function _formJsonParams($imageSource, $operations, $procType, $isURL) + { + $jsonParamArr = array(); + switch ($procType) { + /****************************QR Code*******************************/ + case 0: + $jsonParamArr['process_type'] = $procType . '';// value = '0' + $jsonParamArr['req_data_num'] = '1'; // fixed value; + $jsonParamArr['req_data_source'] = array(); + $jsonParamArr['source_data'] = array(); + $text = $this->_getOperation($operations, 'text'); //get text in qr code + $jsonParamArr['source_data']['data1'] = base64_encode($text); + $jsonParamArr['req_data_source'][0] = array('sourcemethod' => 'BODY'); + $jsonParamArr['req_data_source'][0]['source_data_type'] = 0; //0-text script, 1-image + $jsonParamArr['req_data_source'][0]['operations'] = array(); + $jsonParamArr['req_data_source'][0]['http_reqpack'] = array(); //reserve + + if(!is_null($this->_getOperation($operations, 'size'))){ + $jsonParamArr['req_data_source'][0]['operations']['size'] = $this->_getOperation($operations, 'size'); + }else{ + $jsonParamArr['req_data_source'][0]['operations']['size'] = 3; + } + + if(!is_null($this->_getOperation($operations, 'version'))){ + $jsonParamArr['req_data_source'][0]['operations']['version'] = $this->_getOperation($operations, 'version'); + }else{ + $jsonParamArr['req_data_source'][0]['operations']['version'] = 0; + } + + if(!is_null($this->_getOperation($operations,'margin'))){ + $jsonParamArr['req_data_source'][0]['operations']['margin'] = $this->_getOperation($operations,'margin'); + }else{ + $jsonParamArr['req_data_source'][0]['operations']['margin'] = 4; + } + if(!is_null($this->_getOperation($operations,'level'))){ + $jsonParamArr['req_data_source'][0]['operations']['level'] = $this->_getOperation($operations,'level'); + }else{ + $jsonParamArr['req_data_source'][0]['operations']['level'] = 2; + } + + if(!is_null($this->_getOperation($operations,'foreground'))){ + $jsonParamArr['req_data_source'][0]['operations']['foreground'] = $this->_getOperation($operations,'foreground'); + }else{ + $jsonParamArr['req_data_source'][0]['operations']['foreground'] = '000000'; + } + if(!is_null($this->_getOperation($operations,'background'))){ + $jsonParamArr['req_data_source'][0]['operations']['background'] = $this->_getOperation($operations,'background'); + }else{ + $jsonParamArr['req_data_source'][0]['operations']['background'] = 'FFFFFF'; + } + break; + /****************Annotate*********************/ + case 1: + $jsonParamArr['process_type'] = $procType . '';// value = '1' + $jsonParamArr['req_data_num'] = '2'; // fixed value; + $jsonParamArr['req_data_source'] = array(); + $jsonParamArr['source_data'] = array(); + $text = $this->_getOperation($operations, 'text'); //get text in annotate + if($isURL === true){ + $jsonParamArr['req_data_source'][0] = array('sourcemethod' => 'GET'); + $jsonParamArr['req_data_source'][0]['source_url'] = $imageSource; + $jsonParamArr['source_data']['data1'] = base64_encode($text); + }else{ + $jsonParamArr['req_data_source'][0] = array('sourcemethod' => 'BODY'); + // image source must be filled in 'data1',if exist. followed by text in data2 + $jsonParamArr['source_data']['data1'] = base64_encode($imageSource); + $jsonParamArr['source_data']['data2'] = base64_encode($text); + + } + $jsonParamArr['req_data_source'][0]['source_data_type'] = 1; + $jsonParamArr['req_data_source'][0]['operations'] = array(); + $jsonParamArr['req_data_source'][0]['http_reqpack'] = array(); + + $jsonParamArr['req_data_source'][1] = array('sourcemethod' => 'BODY'); + $jsonParamArr['req_data_source'][1]['source_data_type'] = 0; + $jsonParamArr['req_data_source'][1]['operations'] = array(); + $jsonParamArr['req_data_source'][1]['http_reqpack'] = array(); + // operations cant be empty in req_data_source[0][operations] + if(!is_null($this->_getOperation($operations, 'x_offset'))){ + $jsonParamArr['req_data_source'][0]['operations']['x_offset'] = $this->_getOperation($operations, 'x_offset'); + }else{ + $jsonParamArr['req_data_source'][0]['operations']['x_offset'] = 0; + } + + if(!is_null($this->_getOperation($operations, 'y_offset'))){ + $jsonParamArr['req_data_source'][0]['operations']['y_offset'] = $this->_getOperation($operations, 'y_offset'); + }else{ + $jsonParamArr['req_data_source'][0]['operations']['y_offset'] = 0; + } + + if(!is_null($this->_getOperation($operations, 'opacity'))){ + $opacity = $this->_getOperation($operations, 'opacity'); + $strOpacity = strtoupper(dechex(ceil(255-$opacity*255)). ''); + if(strlen($strOpacity) === 1){ + $strOpacity = '0'. $strOpacity; + } + }else{ + $strOpacity = "FF"; + } + + if(!is_null($this->_getOperation($operations,'font_name'))){ + $jsonParamArr['req_data_source'][0]['operations']['font_name'] = $this->_getOperation($operations,'font_name'); + }else{ + $jsonParamArr['req_data_source'][0]['operations']['font_name'] = BaeImageConstant::SUN; + } + if(!is_null($this->_getOperation($operations,'font_color'))){ + $jsonParamArr['req_data_source'][0]['operations']['font_color'] = '#'. $this->_getOperation($operations,'font_color'). $strOpacity; + //echo "color" . $jsonParamArr['req_data_source'][0]['operations']['font_color']; + }else{ + $jsonParamArr['req_data_source'][0]['operations']['font_color'] = '#000000'. $strOpacity; + } + + if(!is_null($this->_getOperation($operations,'font_size'))){ + $jsonParamArr['req_data_source'][0]['operations']['font_size'] = $this->_getOperation($operations,'font_size'); + }else{ + $jsonParamArr['req_data_source'][0]['operations']['font_size'] = 25; + } + if(!is_null($this->_getOperation($operations,'desttype'))){ + $jsonParamArr['req_data_source'][0]['operations']['desttype'] = $this->_getOperation($operations,'desttype'); + }else{ + $jsonParamArr['req_data_source'][0]['operations']['desttype'] = 0; + } + if(!is_null($this->_getOperation($operations,'quality'))){ + $jsonParamArr['req_data_source'][0]['operations']['quality'] = $this->_getOperation($operations,'quality'); + }else{ + $jsonParamArr['req_data_source'][0]['operations']['quality'] = 80; + } + + break; + /********************Composite**********************/ + case 2: + $jsonParamArr['process_type'] = $procType . '';// value = '2' + $jsonParamArr['req_data_source'] = array(); + $jsonParamArr['source_data'] = array(); + + $num = count($imageSource); + $jsonParamArr['req_data_num'] = 2 .''; // fixed value; + $count = 0; + $isEmpty = true; + while($count < $num){ + if($isURL[$count] === true){ + $jsonParamArr['req_data_source'][$count] = array('sourcemethod' => 'GET'); + $jsonParamArr['req_data_source'][$count]['source_url'] = $imageSource[$count]; + }else{ + $jsonParamArr['req_data_source'][$count] = array('sourcemethod' => 'BODY'); + if($isEmpty === true){ + $jsonParamArr['source_data']['data1'] = base64_encode($imageSource[$count]); + $isEmpty = false; + }else{ + $jsonParamArr['source_data']['data2'] = base64_encode($imageSource[$count]); + } + + } + $jsonParamArr['req_data_source'][$count]['source_data_type'] = 1; + $jsonParamArr['req_data_source'][$count]['operations'] = array(); + $jsonParamArr['req_data_source'][$count]['http_reqpack'] = array(); + if(!is_null($this->_getOperation($operations[$count], 'x_offset'))){ + $jsonParamArr['req_data_source'][$count]['operations']['x_offset'] = $this->_getOperation($operations[$count], 'x_offset'); + }else{ + $jsonParamArr['req_data_source'][$count]['operations']['x_offset'] = 0; + } + + if(!is_null($this->_getOperation($operations[$count], 'y_offset'))){ + $jsonParamArr['req_data_source'][$count]['operations']['y_offset'] = $this->_getOperation($operations[$count], 'y_offset'); + }else{ + $jsonParamArr['req_data_source'][$count]['operations']['y_offset'] = 0; + } + + if(!is_null($this->_getOperation($operations[$count], 'opacity'))){ + $jsonParamArr['req_data_source'][$count]['operations']['opacity'] = $this->_getOperation($operations[$count], 'opacity'); + }else{ + $jsonParamArr['req_data_source'][$count]['operations']['opacity'] = 0.0; + } + + if(!is_null($this->_getOperation($operations[$count],'anchor_point'))){ + $jsonParamArr['req_data_source'][$count]['operations']['anchor_point'] = $this->_getOperation($operations[$count],'anchor_point'); + }else{ + $jsonParamArr['req_data_source'][$count]['operations']['anchor_point'] = BaeImageConstant::TOP_LEFT; + } + /*********************Common params********************************/ + if(!is_null($this->_getOperation($operations,'canvas_width'))){ + $jsonParamArr['req_data_source'][$count]['operations']['canvas_width'] = $this->_getOperation($operations,'canvas_width'); + }else{ + $jsonParamArr['req_data_source'][$count]['operations']['canvas_width'] = 0; + } + if(!is_null($this->_getOperation($operations,'canvas_height'))){ + $jsonParamArr['req_data_source'][$count]['operations']['canvas_height'] = $this->_getOperation($operations,'canvas_height'); + }else{ + $jsonParamArr['req_data_source'][$count]['operations']['canvas_height'] = 0; + } + if(!is_null($this->_getOperation($operations,'desttype'))){ + $jsonParamArr['req_data_source'][$count]['operations']['desttype'] = $this->_getOperation($operations,'desttype'); + }else{ + $jsonParamArr['req_data_source'][$count]['operations']['desttype'] = 0; + } + if(!is_null($this->_getOperation($operations,'quality'))){ + $jsonParamArr['req_data_source'][$count]['operations']['quality'] = $this->_getOperation($operations,'quality'); + }else{ + $jsonParamArr['req_data_source'][$count]['operations']['quality'] = 80; + } + $count++; + + } + break; + + } + return json_encode($jsonParamArr); + } + + private function _getOperation($arrParams, $strOperation){ + if(!empty($arrParams[$strOperation])){ + return $arrParams[$strOperation]; + } + return null; + + } + /* + * Examming url pattern + * */ + private function _examURL($url) + { + $this->_checkString2($url, 'url', 0, 2048); + $pattern = "/^(http[s]?:\/\/){1}[.]*/"; + // regular match + if(!preg_match($pattern, $url)){ + throw new BaeException(sprintf('invalid image source url[%s]', $url), + BaeImageConstant::BAE_IMAGEUI_SDK_PARAM);// + } + return true; + } + + private function _resetErrorStatus() + { + $this->errcode = 0; + $this->errmsg = $this->_arrayErrorMap[$this->errcode]; + $this->_requestId = 0; + } + + private function _exceptionHandler($ex) + { + $tmpCode = $ex->getCode(); + if (0 === $tmpCode) { + $tmpCode = BaeImageConstant::BAE_IMAGEUI_SDK_SYS; + } + + $this->errcode = $tmpCode; + if ($this->errcode >= 30000) { + $this->errmsg = $ex->getMessage(); + } else { + $this->errmsg = $this->_arrayErrorMap[$this->errcode] + . ', detail info[' . $ex->getMessage() + . ', break point: ' . $ex->getFile(). ':' . $ex->getLine() . '].' + . "\n" + . $ex->getTraceAsString(); + } + } + + private function _checkInt($num, $prompt, $intMin = -1, $intMax = -1) + { + if (!is_integer($num)) { + throw new BaeException(sprintf('[%s] parameter not an integer', $prompt), BaeImageConstant::BAE_IMAGEUI_SDK_PARAM); + } + if ($intMin !== -1 && $num < $intMin) { + throw new BaeException(sprintf('[%s] parameter less than minimum', $prompt), BaeImageConstant::BAE_IMAGEUI_SDK_PARAM); + } + if ($intMax !== -1 && $intMax < $num) { + throw new BaeException(sprintf('[%s] parameter greater than maximum', $prompt), BaeImageConstant::BAE_IMAGEUI_SDK_PARAM); + } + } + + private function _checkString($str, $min, $max) + { + if (is_string($str) && strlen($str) >= $min && strlen($str) <= $max) { + return true; + } + return false; + } + private function _checkString2($str, $prompt, $min=null, $max=null) + { + if (!is_string($str)){ + throw new BaeException(sprintf('[%s] parameter not a string', $prompt), BaeImageConstant::BAE_IMAGEUI_SDK_PARAM); + } + if($min !== null && strlen($str) < $min){ + throw new BaeException(sprintf('[%s] parameter less than minimum', $prompt), BaeImageConstant::BAE_IMAGEUI_SDK_PARAM); + } + if($max !== null && strlen($str) > $max) { + throw new BaeException(sprintf('[%s] parameter greater than maximum', $prompt), BaeImageConstant::BAE_IMAGEUI_SDK_PARAM); + } + } +} diff --git a/ptcms/library/bae/BaeMemcache.class.php b/ptcms/library/bae/BaeMemcache.class.php new file mode 100644 index 0000000..c69c824 --- /dev/null +++ b/ptcms/library/bae/BaeMemcache.class.php @@ -0,0 +1,256 @@ +_handle= $memcache; + } + return; + } + + /** + * Retrieve previously stored data if an item with such key exists on the server + * at this moment. You can pass array of keys to get array of values. The result + * array will contain only found key-value pairs. + * + * @param string|array $mixedKey The key or array of keys to fetch + * @param int|array $flag If present, flags fetched along with + * the values will be written to this parameter + * @return string|array + * @see http://cn.php.net/manual/zh/memcache.get.php + */ + public function get($key, $flag= null) + { + if(empty($key)) + { + return null; + } + $res= $this->_handle->getExt($key); + if(false === $res) + { + $this->errcode = $this->_handle->_last_errno; + $this->errmsg= $this->_handle->_convertErrmsg($this->errcode); + } + else + { + $this->errcode = 0; + $this->errmsg= "RES_SUCCESS"; + } + return $res; + } + + /** + * Store data at the memcache cluster + * + * @param string $key The key that will be associated with the item + * @param mixed $var The variable to store + * @param int $flag Use MEMCACHE_COMPRESSED to store the item compressed (uses zlib) + * @param int $expire Expiration time of the item. If it's equal to zero, the item will never expire + * @return bool + * @see http://cn.php.net/manual/zh/memcache.set.php + */ + public function set($key, $var, $flag=0, $expire=0) + { + $res= $this->_handle->set($key, $var, $expire); + if(!$res) + { + $this->errcode = $this->_handle->_last_errno; + $this->errmsg= $this->_handle->_convertErrmsg($this->errcode); + } + else + { + $this->errcode = 0; + $this->errmsg= "RES_SUCCESS"; + } + return $res; + } + + /** + * Add an item to the memcache cluster + * + * @param string $key The key that will be associated with the item + * @param mix $var The variable to store + * @param int $flag Use MEMCACHE_COMPRESSED to store the item compressed (uses zlib) + * @param int $expire Expiration time of the item. If it's equal to zero, the item will never expire + * @return bool + * @see http://cn.php.net/manual/zh/memcache.add.php + */ + public function add($key, $var, $flag= 0, $expire= 0) + { + $res= $this->_handle->add($key, $var, $expire); + if(!$res) + { + $this->errcode = $this->_handle->_last_errno; + $this->errmsg= $this->_handle->_convertErrmsg($this->errcode); + } + else + { + $this->errcode = 0; + $this->errmsg= "RES_SUCCESS"; + } + return $res; + } + + /** + * Replace value of the existing item in memcache cluster + * + * @param string $key The key that will be associated with the item + * @param mixed $var The variable to store + * @param int $flag Use MEMCACHE_COMPRESSED to store the item compressed (uses zlib) + * @param int $expire Expiration time of the item. If it's equal to zero, the item will never expire + * @return bool + * @see http://cn.php.net/manual/zh/memcache.replace.php + */ + public function replace($key, $var, $flag= 0, $expire= 0) + { + $res= $this->_handle->replace($key, $var, $expire); + if(!$res) + { + $this->errcode = $this->_handle->_last_errno; + $this->errmsg= $this->_handle->_convertErrmsg($this->errcode); + } + else + { + $this->errcode = 0; + $this->errmsg= "RES_SUCCESS"; + } + return $res; + } + + /** + * Increment cache item's value at the memcache cluster + * + * @param string $key Key of the item to increment + * @param int $value Increment the item by value + * @return int + * @see http://cn.php.net/manual/zh/memcache.increment.php + */ + public function increment($key, $value= 1) + { + $res= $this->_handle->increment($key, $value); + if(!$res) + { + $this->errcode = $this->_handle->_last_errno; + $this->errmsg= $this->_handle->_convertErrmsg($this->errcode); + } + else + { + $this->errcode = 0; + $this->errmsg= "RES_SUCCESS"; + } + return $res; + } + + /** + * Decrement cache item's value at the memcache cluster + * + * @param string $key Key of the item to decrement + * @param int $value Dncrement the item by value + * @return int + * @see http://cn.php.net/manual/zh/memcache.decrement.php + */ + public function decrement($key, $value= 1) + { + $res= $this->_handle->decrement($key, $value); + if(!$res) + { + $this->errcode = $this->_handle->_last_errno; + $this->errmsg= $this->_handle->_convertErrmsg($this->errcode); + } + else + { + $this->errcode = 0; + $this->errmsg= "RES_SUCCESS"; + } + return $res; + } + + /** + * Delete item from the memcache cluster + * + * @param string $key The key associated with the item to delete + * @param int $time The value will be deleted whithin $time seconds. + * @return bool + * @see http://cn.php.net/manual/zh/function.memcache-delete.php + */ + public function delete($key, $time = 0) + { + $res= $this->_handle->delete($key, $time); + if(!$res) + { + $this->errcode = $this->_handle->_last_errno; + $this->errmsg= $this->_handle->_convertErrmsg($this->errcode); + } + else + { + $this->errcode = 0; + $this->errmsg= "RES_SUCCESS"; + } + return $res; + } + + /** + * Close memcached connection + * + */ + public function close() + { + if($this->_handle) + { + //return $this->_handle->close(); + return true; + } + else + { + return false; + } + } + + public function set_shareAppid($appid) + { + if(!is_string($appid)) return false; + + $ret = $this->_handle->set_shareAppid($appid); + if($ret === false) return false; + + $this->appid = $appid; + return true; + } + + public function __destruct() + { + $this->close(); + } + +} + +/* vim: set ts=4 sw=4 sts=4 tw=100 noet: */ diff --git a/ptcms/library/bae/images/BaeImageAnnotate.class.php b/ptcms/library/bae/images/BaeImageAnnotate.class.php new file mode 100644 index 0000000..3950740 --- /dev/null +++ b/ptcms/library/bae/images/BaeImageAnnotate.class.php @@ -0,0 +1,254 @@ + 'php sdk error', + BaeImageConstant::BAE_IMAGEUI_SDK_SYS => 'php sdk error', + BaeImageConstant::BAE_IMAGEUI_SDK_INIT_FAIL => 'php sdk init error', + BaeImageConstant::BAE_IMAGEUI_SDK_PARAM => 'param invalid', + BaeImageConstant::BAE_IMAGEUI_SDK_HTTP_STATUS_ERROR_AND_RESULT_ERROR + => 'http status is error, and the body returned is not a json string', + BaeImageConstant::BAE_IMAGEUI_SDK_HTTP_STATUS_OK_BUT_RESULT_ERROR + => 'http status is ok, but the body returned is not a json string', + ); + + public function __construct($text = NULL) + { + $this->_resetErrorStatus(); + $this->paramArr = array(); + if(!is_null($text)){ + $this->setText($text); + } + + } + /** + * The text script of annotation + * @param text string,

range:1-500 characters

+ */ + public function setText($text) + { + try { + $this->_checkString($text, 1, 500); + $this->text = $text; + $this->paramArr['text'] = $text; + }catch (Exception $ex) { + $this->_exceptionHandler($ex); + return false; + } + return true; + } + + public function getText() + { + return $this->text; + + } + + public function getOperations() + { + return $this->paramArr; + } + + private function setParam($key, $value) + { + $this->paramArr[$key] = $value; + } + /** + * The opacity of an image + * @param floatOpacity float,

range:0-1

+ */ + public function setOpacity($floatOpacity) + { + //$this->_resetErrorStatus(); + try { + $this->_checkFloat($floatOpacity, 'opacity', 0.0, 1.0); + $this->setParam('opacity', $floatOpacity); + } catch (Exception $ex) { + $this->_exceptionHandler($ex); + return false; + } + return true; + + } + /** + * Font options + * @param name BaeImageConstant + * @param size int,

range:0-1000,default 5

+ * @param color string,

range:6 bits RGB,default '000000'

+ */ + public function setFont($name, $size, $color) + { + //$this->_resetErrorStatus(); + try { + $this->_checkInt($name,'font name', 0, 4); + $this->_checkInt($size, 'font size' ,0, 1000); + $this->_checkRGB($color); + $this->setParam('font_name', $name); + $this->setParam('font_color', $color); + $this->setParam('font_size', $size); + } catch (Exception $ex) { + $this->_exceptionHandler($ex); + return false; + } + return true; + + } + /** + * Position of the text script + * @param x_offset int,

range:0-width of the image

+ * @param y_offset int,

range:0-height of the image

+ */ + public function setPos($x_offset, $y_offset) + { + //$this->_resetErrorStatus(); + try { + $this->_checkInt($x_offset, 'x_offset', 0);//without restriction + $this->_checkInt($y_offset, 'y_offset', 0);//without restriction + $this->setParam('x_offset', $x_offset); + $this->setParam('y_offset', $y_offset); + } catch (Exception $ex) { + $this->_exceptionHandler($ex); + return false; + } + return true; + + } + /** + * The output image type + * @param outputcode BaeImageConstant,

support by JPG,GIF,BMP,PNG,WEBP + */ + public function setOutputCode($outputcode) + { + //$this->_resetErrorStatus(); + try { + $this->_checkInt($outputcode, 'outputcode', 0, 4); + $this->setParam('desttype', $outputcode); + } catch (Exception $ex) { + $this->_exceptionHandler($ex); + return false; + } + return true; + + } + /** + * The quality of output image + * @param intQuality int,

range:0-100,default 80

+ */ + public function setQuality($intQuality) + { + //$this->_resetErrorStatus(); + try { + $this->_checkInt($intQuality, 'quality', 0, 100); + $this->setParam('quality', $intQuality); + } catch (Exception $ex) { + $this->_exceptionHandler($ex); + return false; + } + return true; + + } + + public function clearOperations() + { + $this->paramArr = array(); + return true; + } + + private function _checkRGB($strRGB){ + $this->_checkString($strRGB, 6, 6); + $pattern = "/[AaBbCcDdEeFf0123456789]{6}/"; + // regular match + if(!preg_match($pattern, $strRGB)){ + throw new BaeException(sprintf('invalid RGB color[%s]', $strRGB), + BaeImageConstant::BAE_IMAGEUI_SDK_PARAM);// + } + } + + private function _checkFloat($num, $prompt, $floatMin = null, $floatMax = null) + { + if(is_integer($num)){ + $num = floatval($num); + } + if(!is_float($num)){ + throw new BaeException(sprintf('[%s] parameter not a float', $prompt), BaeImageConstant::BAE_IMAGEUI_SDK_PARAM); + } + if($floatMin !== null && $num < $floatMin){ + throw new BaeException(sprintf('[%s] parameter less than minimum', $prompt), BaeImageConstant::BAE_IMAGEUI_SDK_PARAM); + } + if($floatMax !== null && $num > $floatMax){ + throw new BaeException(sprintf('[%s] parameter greater than maximum', $prompt), BaeImageConstant::BAE_IMAGEUI_SDK_PARAM); + } + } + + private function _checkEnum($value, $arrEnum = array(0,1,2),$name) + { + if(!in_array($value, $arrEnum)) { + throw new Exception(sprintf('Param % is incorrect',$name)); + } + } + + private function _checkInt($num, $prompt, $intMin = -1, $intMax = -1) + { + if (!is_integer($num)) { + throw new BaeException(sprintf('[%s] parameter not an integer', $prompt), BaeImageConstant::BAE_IMAGEUI_SDK_PARAM); + } + if ($intMin !== -1 && $num < $intMin) { + throw new BaeException(sprintf('[%s] parameter less than minimum', $prompt), BaeImageConstant::BAE_IMAGEUI_SDK_PARAM); + } + if ($intMax !== -1 && $intMax < $num) { + throw new BaeException(sprintf('[%s] parameter greater than maximum', $prompt), BaeImageConstant::BAE_IMAGEUI_SDK_PARAM); + } + } + + private function _checkString($str, $min=null, $max=null) + { + if (!is_string($str)){ + throw new BaeException(sprintf('[%s] parameter not a string', $str), BaeImageConstant::BAE_IMAGEUI_SDK_PARAM); + } + if($min !== null && strlen($str) < $min){ + throw new BaeException(sprintf('[%s] parameter less than minimum', $str), BaeImageConstant::BAE_IMAGEUI_SDK_PARAM); + } + if($max !== null && strlen($str) > $max) { + throw new BaeException(sprintf('[%s] parameter greater than maximum', $str), BaeImageConstant::BAE_IMAGEUI_SDK_PARAM); + } + } + + private function _resetErrorStatus() + { + $this->errcode = 0; + $this->errmsg = $this->_arrayErrorMap[$this->errcode]; + $this->_requestId = 0; + } + + private function _exceptionHandler($ex) + { + $tmpCode = $ex->getCode(); + if (0 === $tmpCode) { + $tmpCode = BaeImageConstant::BAE_IMAGEUI_SDK_SYS; + } + + $this->errcode = $tmpCode; + if ($this->errcode >= 30000) { + $this->errmsg = $ex->getMessage(); + } else { + $this->errmsg = $this->_arrayErrorMap[$this->errcode] + . ', detail info[' . $ex->getMessage() + . ', break point: ' . $ex->getFile(). ':' . $ex->getLine() . '].' + . "\n" + . $ex->getTraceAsString(); + } + } +} \ No newline at end of file diff --git a/ptcms/library/bae/images/BaeImageComposite.class.php b/ptcms/library/bae/images/BaeImageComposite.class.php new file mode 100644 index 0000000..a3e6f09 --- /dev/null +++ b/ptcms/library/bae/images/BaeImageComposite.class.php @@ -0,0 +1,246 @@ + 'php sdk error', + BaeImageConstant::BAE_IMAGEUI_SDK_SYS => 'php sdk error', + BaeImageConstant::BAE_IMAGEUI_SDK_INIT_FAIL => 'php sdk init error', + BaeImageConstant::BAE_IMAGEUI_SDK_PARAM => 'param invalid', + BaeImageConstant::BAE_IMAGEUI_SDK_HTTP_STATUS_ERROR_AND_RESULT_ERROR + => 'http status is error, and the body returned is not a json string', + BaeImageConstant::BAE_IMAGEUI_SDK_HTTP_STATUS_OK_BUT_RESULT_ERROR + => 'http status is ok, but the body returned is not a json string', + ); + + public function __construct($baeImageSource = NULL) + { + $isURL = true; + $this->_resetErrorStatus(); + try{ + if(!is_null($baeImageSource)){ + if($isURL === true){ + $this->_examURL($baeImageSource); + $this->baeImageSource = $baeImageSource; + } + else{ + if(!$this->_checkString($baeImageSource, 0, 2*1024*1024)){ + throw new BaeException('image must be less than 2M', BaeImageConstant::BAE_IMAGEUI_SDK_PARAM); + } + } + $this->isURL = true; + } + }catch (Exception $ex) { + $this->_exceptionHandler($ex); + return false; + } + } + /** + * Setting the image source + * @param baeImageSource string,

image source url or byte string

+ * @param isURL bool,

true for $baeImageSource is url pattern, false for byte string

+ */ + public function setBaeImageSource($baeImageSource) + { + $isURL=true; + try{ + if(empty($baeImageSource)){ + throw new BaeException('no bae image source', BaeImageConstant::BAE_IMAGEUI_SDK_PARAM); + } + if($isURL === true){ + $this->_examURL($baeImageSource); + $this->baeImageSource = $baeImageSource; + } + else{ + if(!$this->_checkString($baeImageSource, 0, 2*1024*1024)){ + throw new BaeException('image must be less than 2M', BaeImageConstant::BAE_IMAGEUI_SDK_PARAM); + } + } + $this->isURL = true; + }catch (Exception $ex) { + $this->_exceptionHandler($ex); + return false; + } + return true; + } + + public function getBaeImageSource() + { + return array('data'=>$this->baeImageSource, 'isURL'=>$this->isURL); + } + + public function getOperations() + { + return $this->paramArr; + } + + private function setParam($key, $value) + { + $this->paramArr[$key] = $value; + } + /** + * Position of the image apart from anchor point + * @param x_offset int + * @param y_offset int + */ + public function setPos($x_offset, $y_offset) + { + //$this->_resetErrorStatus(); + try { + $this->_checkInt($x_offset, 'x_offset');//without restriction + $this->_checkInt($y_offset, 'y_offset');//without restriction + $this->setParam('x_offset', $x_offset); + $this->setParam('y_offset', $y_offset); + } catch (Exception $ex) { + $this->_exceptionHandler($ex); + return false; + } + return true; + + } + /** + * Opacity of the image + * @param floatOpacity float,

range:0-1

+ */ + public function setOpacity($floatOpacity) + { + //$this->_resetErrorStatus(); + try { + $this->_checkFloat($floatOpacity, 'opacity', 0.0, 1.0); + $this->setParam('opacity', $floatOpacity); + } catch (Exception $ex) { + $this->_exceptionHandler($ex); + return false; + } + return true; + + } + /** + * Anchor point of the image + * @param anchor BaeImageConstant,

range:0-8,default 0

+ */ + public function setAnchor($anchor) + { + //$this->_resetErrorStatus(); + try { + $this->_checkInt($anchor, 'anchor', 0, 8); + $this->setParam('anchor_point', $anchor); + } catch (Exception $ex) { + $this->_exceptionHandler($ex); + return false; + } + return true; + + } + + public function clearOperations() + { + $this->paramArr = array(); + return true; + } + + + + private function _checkFloat($num, $prompt, $floatMin = null, $floatMax = null) + { + if(is_integer($num)){ + $num = floatval($num); + } + if(!is_float($num)){ + throw new BaeException(sprintf('[%s] parameter not a float', $prompt), BaeImageConstant::BAE_IMAGEUI_SDK_PARAM); + } + if($floatMin !== null && $num < $floatMin){ + throw new BaeException(sprintf('[%s] parameter less than minimum', $prompt), BaeImageConstant::BAE_IMAGEUI_SDK_PARAM); + } + if($floatMax !== null && $num > $floatMax){ + throw new BaeException(sprintf('[%s] parameter greater than maximum', $prompt), BaeImageConstant::BAE_IMAGEUI_SDK_PARAM); + } + } + + private function _checkInt($num, $prompt, $intMin = -1, $intMax = -1) + { + if (!is_integer($num)) { + throw new BaeException(sprintf('[%s] parameter not an integer', $prompt), BaeImageConstant::BAE_IMAGEUI_SDK_PARAM); + } + if ($intMin !== -1 && $num < $intMin) { + throw new BaeException(sprintf('[%s] parameter less than minimum', $prompt), BaeImageConstant::BAE_IMAGEUI_SDK_PARAM); + } + if ($intMax !== -1 && $intMax < $num) { + throw new BaeException(sprintf('[%s] parameter greater than maximum', $prompt), BaeImageConstant::BAE_IMAGEUI_SDK_PARAM); + } + } + + private function _checkString($str, $min, $max) + { + if (is_string($str) && strlen($str) >= $min && strlen($str) <= $max) { + return true; + } + return false; + } + private function _checkString2($str, $prompt, $min=null, $max=null) + { + if (!is_string($str)){ + throw new BaeException(sprintf('[%s] parameter not a string', $prompt), BaeImageConstant::BAE_IMAGEUI_SDK_PARAM); + } + if($min !== null && strlen($str) < $min){ + throw new BaeException(sprintf('[%s] parameter less than minimum', $prompt), BaeImageConstant::BAE_IMAGEUI_SDK_PARAM); + } + if($max !== null && strlen($str) > $max) { + throw new BaeException(sprintf('[%s] parameter greater than maximum', $prompt), BaeImageConstant::BAE_IMAGEUI_SDK_PARAM); + } + } + + /* + * Examming url pattern + * */ + private function _examURL($url) + { + $this->_checkString2($url, 'url', 0, 2048); + $pattern = "/^(http[s]?:\/\/){1}[.]*/"; + // regular match + if(!preg_match($pattern, $url)){ + throw new BaeException(sprintf('invalid image source url[%s]', $url), + BaeImageConstant::BAE_IMAGEUI_SDK_PARAM);// + } + return true; + } + + private function _resetErrorStatus() + { + $this->errcode = 0; + $this->errmsg = $this->_arrayErrorMap[$this->errcode]; + $this->_requestId = 0; + } + + private function _exceptionHandler($ex) + { + $tmpCode = $ex->getCode(); + if (0 === $tmpCode) { + $tmpCode = BaeImageConstant::BAE_IMAGEUI_SDK_SYS; + } + + $this->errcode = $tmpCode; + if ($this->errcode >= 30000) { + $this->errmsg = $ex->getMessage(); + } else { + $this->errmsg = $this->_arrayErrorMap[$this->errcode] + . ', detail info[' . $ex->getMessage() + . ', break point: ' . $ex->getFile(). ':' . $ex->getLine() . '].' + . "\n" + . $ex->getTraceAsString(); + } + } + +} diff --git a/ptcms/library/bae/images/BaeImageConstant.class.php b/ptcms/library/bae/images/BaeImageConstant.class.php new file mode 100644 index 0000000..700e587 --- /dev/null +++ b/ptcms/library/bae/images/BaeImageConstant.class.php @@ -0,0 +1,99 @@ + \ No newline at end of file diff --git a/ptcms/library/bae/images/BaeImageQRCode.class.php b/ptcms/library/bae/images/BaeImageQRCode.class.php new file mode 100644 index 0000000..23a5e4e --- /dev/null +++ b/ptcms/library/bae/images/BaeImageQRCode.class.php @@ -0,0 +1,235 @@ + 'php sdk error', + BaeImageConstant::BAE_IMAGEUI_SDK_SYS => 'php sdk error', + BaeImageConstant::BAE_IMAGEUI_SDK_INIT_FAIL => 'php sdk init error', + BaeImageConstant::BAE_IMAGEUI_SDK_PARAM => 'param invalid', + BaeImageConstant::BAE_IMAGEUI_SDK_HTTP_STATUS_ERROR_AND_RESULT_ERROR + => 'http status is error, and the body returned is not a json string', + BaeImageConstant::BAE_IMAGEUI_SDK_HTTP_STATUS_OK_BUT_RESULT_ERROR + => 'http status is ok, but the body returned is not a json string', + ); + + public function __construct($text = NULL) + { + $this->_resetErrorStatus(); + $this->paramArr = array(); + if(!is_null($text)){ + $this->setText($text); + } + + } + /** + * Setting the text script + * @param text string,

the text script to generate QR coderange:1-500 characters

+ */ + public function setText($text) + { + try { + $this->_checkString($text);//check if it is not a string + $text = mb_convert_encoding($text, 'GBK', 'UTF-8'); + //echo "---------:". $text." len:". strlen($text); + $this->_checkString($text, 1, 500); + $this->text = $text; + $this->paramArr['text'] = $text; + }catch (Exception $ex) { + $this->_exceptionHandler($ex); + return false; + } + return true; + } + + public function getText() + { + return $this->text; + } + + public function getOperations() + { + return $this->paramArr; + } + + private function setParam($key, $value) + { + $this->paramArr[$key] = $value; + } + /** + * The version of the QR code + * @param intVersion int,

range:0-30

+ */ + public function setVersion($intVersion) + { + //$this->_resetErrorStatus(); + try { + $this->_checkInt($intVersion, 'version', 0, 30); + $this->setParam('version', $intVersion); + } catch (Exception $ex) { + $this->_exceptionHandler($ex); + return false; + } + return true; + } + /** + * The size of the QR code + * @param intSize int,

range:1-100

+ */ + public function setSize($intSize) + { + //$this->_resetErrorStatus(); + try { + $this->_checkInt($intSize, 'size', 1, 100); + $this->setParam('size', $intSize); + } catch (Exception $ex) { + $this->_exceptionHandler($ex); + return false; + } + return true; + } + /** + * The error correction level of an QR code + * @param intLevel int,

range:1-4

+ */ + public function setLevel($intLevel) + { + //$this->_resetErrorStatus(); + try { + $this->_checkInt($intLevel, 'level', 1, 4); + $this->setParam('level', $intLevel); + } catch (Exception $ex) { + $this->_exceptionHandler($ex); + return false; + } + return true; + } + /** + * The margin of a QR code + * @param intMargin int,

range:1-100

+ */ + public function setMargin($intMargin) + { + //$this->_resetErrorStatus(); + try { + $this->_checkInt($intMargin, 'margin', 1, 100); + $this->setParam('margin', $intMargin); + } catch (Exception $ex) { + $this->_exceptionHandler($ex); + return false; + } + return true; + } + /** + * Foreground color of QR code + * @param strForeground string,

range:6 bits RGB,default '000000'

+ */ + public function setForeground($strForeground) + { + //$this->_resetErrorStatus(); + try { + $this->_checkRGB($strForeground); + $this->setParam('foreground', $strForeground); + } catch (Exception $ex) { + $this->_exceptionHandler($ex); + return false; + } + return true; + } + /** + * Background color of QR code + * @param strBackground string,

range:6 bits RGB,default 'FFFFFF'

+ */ + public function setBackground($strBackground) + { + //$this->_resetErrorStatus(); + try { + $this->_checkRGB($strBackground); + $this->setParam('background', $strBackground); + } catch (Exception $ex) { + $this->_exceptionHandler($ex); + return false; + } + return true; + } + + public function clearOperations(){ + $this->paramArr = array(); + return true; + } + + + private function _checkInt($num, $prompt, $intMin = -1, $intMax = -1) + { + if (!is_integer($num)) { + throw new BaeException(sprintf('[%s] parameter not an integer', $prompt), BaeImageConstant::BAE_IMAGEUI_SDK_PARAM); + } + if ($intMin !== -1 && $num < $intMin) { + throw new BaeException(sprintf('[%s] parameter less than minimum', $prompt), BaeImageConstant::BAE_IMAGEUI_SDK_PARAM); + } + if ($intMax !== -1 && $intMax < $num) { + throw new BaeException(sprintf('[%s] parameter greater than maximum', $prompt), BaeImageConstant::BAE_IMAGEUI_SDK_PARAM); + } + } + + private function _checkString($str, $min=null, $max=null) + { + if (!is_string($str)){ + throw new BaeException(sprintf('[%s] parameter not a string', $str), BaeImageConstant::BAE_IMAGEUI_SDK_PARAM); + } + if($min !== null && strlen($str) < $min){ + throw new BaeException(sprintf('[%s] parameter less than minimum', $str), BaeImageConstant::BAE_IMAGEUI_SDK_PARAM); + } + if($max !== null && strlen($str) > $max) { + throw new BaeException(sprintf('[%s] parameter greater than maximum', $str), BaeImageConstant::BAE_IMAGEUI_SDK_PARAM); + } + } + + private function _checkRGB($strRGB){ + $this->_checkString($strRGB, 6, 6); + $pattern = "/[AaBbCcDdEeFf0123456789]{6}/"; + // regular match + if(!preg_match($pattern, $strRGB)){ + throw new BaeException(sprintf('invalid RGB color[%s]', $strRGB), + BaeImageConstant::BAE_IMAGEUI_SDK_PARAM);// + } + } + + private function _resetErrorStatus() + { + $this->errcode = 0; + $this->errmsg = $this->_arrayErrorMap[$this->errcode]; + $this->_requestId = 0; + } + + private function _exceptionHandler($ex) + { + $tmpCode = $ex->getCode(); + if (0 === $tmpCode) { + $tmpCode = BaeImageConstant::BAE_IMAGEUI_SDK_SYS; + } + + $this->errcode = $tmpCode; + if ($this->errcode >= 30000) { + $this->errmsg = $ex->getMessage(); + } else { + $this->errmsg = $this->_arrayErrorMap[$this->errcode] + . ', detail info[' . $ex->getMessage() + . ', break point: ' . $ex->getFile(). ':' . $ex->getLine() . '].' + . "\n" + . $ex->getTraceAsString(); + } + } + +} +?> \ No newline at end of file diff --git a/ptcms/library/bae/images/BaeImageTransform.class.php b/ptcms/library/bae/images/BaeImageTransform.class.php new file mode 100644 index 0000000..69a3190 --- /dev/null +++ b/ptcms/library/bae/images/BaeImageTransform.class.php @@ -0,0 +1,355 @@ + + * such as cropping,rotation,transcode and adjusting lightness an image.
+ * You can consider each operation or simultaneously combine some operations
+ * at one request. + * + */ +class BaeImageTransform extends BaeBase{ + + + private $_arrayErrorMap = array( + '0' => 'php sdk error', + BaeImageConstant::BAE_IMAGEUI_SDK_SYS => 'php sdk error', + BaeImageConstant::BAE_IMAGEUI_SDK_INIT_FAIL => 'php sdk init error', + BaeImageConstant::BAE_IMAGEUI_SDK_PARAM => 'param invalid', + BaeImageConstant::BAE_IMAGEUI_SDK_HTTP_STATUS_ERROR_AND_RESULT_ERROR + => 'http status is error, and the body returned is not a json string', + BaeImageConstant::BAE_IMAGEUI_SDK_HTTP_STATUS_OK_BUT_RESULT_ERROR + => 'http status is ok, but the body returned is not a json string', + ); + + private $paramArr; + + private $_requestId; + + public function __construct(){ + $this->paramArr = array(); + $this->_resetErrorStatus(); + } + + public function getRequestId() + { + return $this->_requestId; + } + + private function setParam($key, $value) + { + $this->paramArr[$key] = $value; + } + + public function getOperations() + { + + return $this->paramArr; + } + + /** + * + * @param intZoomingType int,

the zooming type,including height,width and pixel

+ * @param intValue int,

the zooming value,width:0-1000 height:0-1000 + * pixel:0-1000000

+ * @param heightIntValue[optional],

+ * @throws BaeException + */ + public function setZooming($intZoomingType, $intValue, $heightIntValue = 0) + { + //$this->_resetErrorStatus(); + try { + switch ($intZoomingType) { + case BaeImageConstant::TRANSFORM_ZOOMING_TYPE_HEIGHT: + $this->_checkInt($intValue, 'zooming height' , 0, 10000); + $this->setParam('size', 'b0_' . $intValue); + break; + case BaeImageConstant::TRANSFORM_ZOOMING_TYPE_WIDTH: + $this->_checkInt($intValue, 'zooming width' ,0, 10000); + $this->setParam('size', 'b' . $intValue . '_0'); + break; + case BaeImageConstant::TRANSFORM_ZOOMING_TYPE_PIXELS: + $this->_checkInt($intValue, 'zooming pixels' ,0, 100000000); + $this->setParam('size','p' . $intValue); + break; + case BaeImageConstant::TRANSFORM_ZOOMING_TYPE_UNRATIO: + $this->_checkInt($intValue, 'zooming unratio' , 0, 10000); + $this->_checkInt($heightIntValue, 'zooming height(unratio)' , 0, 10000); + $this->setParam('size','u' . $intValue . '_' .$heightIntValue); + break; + default: + throw new BaeException('invalid zooming type parameters', BaeImageConstant::BAE_IMAGEUI_SDK_PARAM); + } + } catch (Exception $ex) { + $this->_exceptionHandler($ex); + return false; + } + return true; + } + /** + * Cropping an image + * @param intX int,

start with x coordinates,range:0-10000

+ * @param intY int,

start with y coordinates,range:0-10000

+ * @param intWidth,

end with x+width,range:0-10000

+ * @param intHeight,

end with y+height,range:0-10000

+ */ + public function setCropping($intX, $intY, $intWidth, $intHeight) + { + //$this->_resetErrorStatus(); + try { + $this->_checkInt($intX, 'cut_x' , 0, 10000); + $this->_checkInt($intY, 'cut_y' , 0, 10000); + $this->_checkInt($intHeight, 'cut_h' , 0, 10000); + $this->_checkInt($intWidth, 'cut_w' , 0, 10000); + + $this->setParam('cut_x', $intX); + $this->setParam('cut_y', $intY); + $this->setParam('cut_h', $intHeight); + $this->setParam('cut_w', $intWidth); + } catch (Exception $ex) { + $this->_exceptionHandler($ex); + return false; + } + return true; + } + /** + * Rotating an image with any degree + * @param intDegree int,

the rotating value,range:0-360

+ */ + public function setRotation($intDegree) + { + //$this->_resetErrorStatus(); + try { + $this->_checkInt($intDegree, 'rotate' , 0, 360); + $this->setParam('rotate', $intDegree); + } catch (Exception $ex) { + $this->_exceptionHandler($ex); + return false; + } + return true; + } + /** + * Setting the hue of an image + * @param intHue int,

the hue value,range:1-100

+ */ + public function setHue($intHue) + { + //$this->_resetErrorStatus(); + try { + $this->_checkInt($intHue, 'hue' ,1, 100); + $this->setParam('hue', $intHue); + } catch (Exception $ex) { + $this->_exceptionHandler($ex); + return false; + } + return true; + } + /** + * Setting the lightness of an image + * @param intLightness int,

the lightness value range: bigger than 1

+ */ + public function setLightness($intLightness) + { + //$this->_resetErrorStatus(); + try { + $this->_checkInt($intLightness, 'lightness' , 1); + $this->setParam('lightness', $intLightness); + } catch (Exception $ex) { + $this->_exceptionHandler($ex); + return false; + } + return true; + } + /** + * Setting the contrast of an image + * @param intContrast int,

0 for degenerate,1 for enhance.

+ */ + public function setContrast($intContrast) + { + //$this->_resetErrorStatus(); + try { + $this->_checkInt($intContrast, 'contrast' , 0, 1); + $this->setParam('contrast', $intContrast); + } catch (Exception $ex) { + $this->_exceptionHandler($ex); + return false; + } + return true; + } + /** + * Setting the sharpness of an image + * @param intSharpness int,

the sharpness value,1-100 for sharpen, 101-200 for vague.

+ */ + public function setSharpness($intSharpness) + { + //$this->_resetErrorStatus(); + try { + $this->_checkInt($intSharpness, 'sharpness' , 1, 200); + $this->setParam('sharpen', $intSharpness); + } catch (Exception $ex) { + $this->_exceptionHandler($ex); + return false; + } + return true; + } + /** + * Setting the saturation of an image + * @param intSaturation int,

the saturation value,range:1-100

+ */ + public function setSaturation($intSaturation) + { + //$this->_resetErrorStatus(); + try { + $this->_checkInt($intSaturation, 'saturation', 1, 100); + $this->setParam('saturation',$intSaturation); + } catch (Exception $ex) { + $this->_exceptionHandler($ex); + return false; + } + return true; + } + /** + * Transcoding the output image with a given type + * @param imageType BaeImageConstant,

support by GIF,JPG,WEBP,BMP,PNG

intQuality + * @param intQuality[optional] int,

the quality of an image.range:0-100

+ * @throws BaeException + */ + public function setTranscoding($imageType, $intQuality = 60) + { + //$this->_resetErrorStatus(); + try { + if(!is_integer($imageType)){ + throw new BaeException(sprintf('invalid image type[%s]', $imageType), + BaeImageConstant::BAE_IMAGEUI_SDK_PARAM); + } + switch ($imageType) { + case BaeImageConstant::GIF: + $this->_checkInt($intQuality, 'quality' , 0, 100); + $this->setParam('quality', $intQuality); + $this->setParam('imgtype', 2); + break; + case BaeImageConstant::JPG: + $this->_checkInt($intQuality, 'quality' , 0, 100); + $this->setParam('quality', $intQuality); + $this->setParam('imgtype', 1); + break; + case BaeImageConstant::PNG: + $this->setParam('imgtype', 3); + break; + case BaeImageConstant::WEBP: + $this->setParam('imgtype', 4); + break; + default: + throw new BaeException(sprintf('invalid image type[%s]', $imageType), + BaeImageConstant::BAE_IMAGEUI_SDK_PARAM); + } + } catch (Exception $ex) { + $this->_exceptionHandler($ex); + return false; + } + return true; + } + /** + * Setting the quality of an image + * @param intQuality int,

the quality value, range:0-100

+ */ + public function setQuality($intQuality = 60) + { + //$this->_resetErrorStatus(); + try { + $this->_checkInt($intQuality, 'quality', 0, 100); + $this->setParam('quality', $intQuality); + } catch (Exception $ex) { + $this->_exceptionHandler($ex); + return false; + } + return true; + } + + public function setGetGifFirstFrame() + { + $this->setParam('tieba', 1); + return true; + } + + public function setAutorotate() + { + $this->setParam('autorotate', 1); + return true; + } + /** + * Flipping the image horizontally + */ + public function horizontalFlip() + { + $this->setParam('flop', 1); + return true; + } + /** + * Flipping the image vertically + */ + public function verticalFlip() + { + $this->setParam('flip', 1); + return true; + } + /** + * Clear operations + */ + public function clearOperations(){ + $this->paramArr = array(); + return true; + } + + private function _resetErrorStatus() + { + $this->errcode = 0; + $this->errmsg = $this->_arrayErrorMap[$this->errcode]; + $this->_requestId = 0; + } + + private function _exceptionHandler($ex) + { + $tmpCode = $ex->getCode(); + if (0 === $tmpCode) { + $tmpCode = BaeImageConstant::BAE_IMAGEUI_SDK_SYS; + } + + $this->errcode = $tmpCode; + if ($this->errcode >= 30000) { + $this->errmsg = $ex->getMessage(); + } else { + $this->errmsg = $this->_arrayErrorMap[$this->errcode] + . ', detail info[' . $ex->getMessage() + . ', break point: ' . $ex->getFile(). ':' . $ex->getLine() . '].' + . "\n" + . $ex->getTraceAsString(); + } + } + + private function _checkInt($num, $prompt, $intMin = -1, $intMax = -1) + { + if (!is_integer($num)) { + throw new BaeException(sprintf('[%s] parameter not an integer', $prompt), BaeImageConstant::BAE_IMAGEUI_SDK_PARAM); + } + if ($intMin !== -1 && $num < $intMin) { + throw new BaeException(sprintf('[%s] parameter less than minimum', $prompt), BaeImageConstant::BAE_IMAGEUI_SDK_PARAM); + } + if ($intMax !== -1 && $intMax < $num) { + throw new BaeException(sprintf('[%s] parameter greater than maximum', $prompt), BaeImageConstant::BAE_IMAGEUI_SDK_PARAM); + } + } + + private function _checkString($str, $min, $max) + { + if (is_string($str) && strlen($str) >= $min && strlen($str) <= $max) { + return true; + } + return false; + } +} diff --git a/ptcms/library/bae/images/BaeImageVCode.class.php b/ptcms/library/bae/images/BaeImageVCode.class.php new file mode 100644 index 0000000..6f5ccf7 --- /dev/null +++ b/ptcms/library/bae/images/BaeImageVCode.class.php @@ -0,0 +1,173 @@ + 'php sdk error', + BaeImageConstant::BAE_IMAGEUI_SDK_SYS => 'php sdk error', + BaeImageConstant::BAE_IMAGEUI_SDK_INIT_FAIL => 'php sdk init error', + BaeImageConstant::BAE_IMAGEUI_SDK_PARAM => 'param invalid', + BaeImageConstant::BAE_IMAGEUI_SDK_HTTP_STATUS_ERROR_AND_RESULT_ERROR + => 'http status is error, and the body returned is not a json string', + BaeImageConstant::BAE_IMAGEUI_SDK_HTTP_STATUS_OK_BUT_RESULT_ERROR + => 'http status is ok, but the body returned is not a json string', + ); + + public function __construct() + { + $this->_resetErrorStatus(); + $this->paramArr = array('len'=>4,'setno'=>0); + } + public function getOperations() + { + return $this->paramArr; + } + + private function setParam($key, $value) + { + $this->paramArr[$key] = $value; + } + /** + * The bits of the verification code + * @param intLen integer,

range:4-5

+ */ + public function setLen($intLen) + { + try { + $this->_checkInt($intLen, 'verification code len', 4, 5); + $this->setParam('len', $intLen); + }catch (Exception $ex) { + $this->_exceptionHandler($ex); + return false; + } + return true; + } + + /** + * The pattern of the verification code + * @param pattern integer,

range:0-3

+ */ + public function setPattern($pattern) + { + try { + $this->_checkInt($pattern, 'verification code pattern', 0, 3); + $this->setParam('setno', $pattern); + }catch (Exception $ex) { + $this->_exceptionHandler($ex); + return false; + } + return true; + } + + /** + * The input to verify + * @param strInput string,

range:4-5

+ */ + public function setInput($strInput) + { + try { + $this->_checkString($strInput, 'vcode.input' ,4, 5); + $this->setParam('input', $strInput); + $this->input = $strInput; + }catch (Exception $ex) { + $this->_exceptionHandler($ex); + return false; + } + return true; + } + + public function getInput(){ + return $this->input; + } + + /** + * The secret text of the verification code + * @param strSecret string,

range:without restriction

+ */ + public function setSecret($strSecret) + { + try { + $this->_checkString($strSecret,'vcode.secret', 368, 368);//without restriction + $this->setParam('vcode', $strSecret); + $this->strSecret = $strSecret; + }catch (Exception $ex) { + $this->_exceptionHandler($ex); + return false; + } + return true; + } + public function getSecret(){ + return $this->strSecret; + } + + public function clearOperations() + { + $this->paramArr = array(); + return true; + } + + private function _checkInt($num, $prompt, $intMin = -1, $intMax = -1) + { + if (!is_integer($num)) { + throw new BaeException(sprintf('[%s] parameter not an integer', $prompt), BaeImageConstant::BAE_IMAGEUI_SDK_PARAM); + } + if ($intMin !== -1 && $num < $intMin) { + throw new BaeException(sprintf('[%s] parameter less than minimum', $prompt), BaeImageConstant::BAE_IMAGEUI_SDK_PARAM); + } + if ($intMax !== -1 && $intMax < $num) { + throw new BaeException(sprintf('[%s] parameter greater than maximum', $prompt), BaeImageConstant::BAE_IMAGEUI_SDK_PARAM); + } + } + + private function _checkString($str, $prompt, $min=null, $max=null) + { + if (!is_string($str)){ + throw new BaeException(sprintf('[%s] parameter not a string', $prompt), BaeImageConstant::BAE_IMAGEUI_SDK_PARAM); + } + if($min !== null && strlen($str) < $min){ + throw new BaeException(sprintf('[%s] parameter less than minimum', $prompt), BaeImageConstant::BAE_IMAGEUI_SDK_PARAM); + } + if($max !== null && strlen($str) > $max) { + throw new BaeException(sprintf('[%s] parameter greater than maximum', $prompt), BaeImageConstant::BAE_IMAGEUI_SDK_PARAM); + } + } + + private function _resetErrorStatus() + { + $this->errcode = 0; + $this->errmsg = $this->_arrayErrorMap[$this->errcode]; + $this->_requestId = 0; + } + + private function _exceptionHandler($ex) + { + $tmpCode = $ex->getCode(); + if (0 === $tmpCode) { + $tmpCode = BaeImageConstant::BAE_IMAGEUI_SDK_SYS; + } + + $this->errcode = $tmpCode; + if ($this->errcode >= 30000) { + $this->errmsg = $ex->getMessage(); + } else { + $this->errmsg = $this->_arrayErrorMap[$this->errcode] + . ', detail info[' . $ex->getMessage() + . ', break point: ' . $ex->getFile(). ':' . $ex->getLine() . '].' + . "\n" + . $ex->getTraceAsString(); + } + } +} \ No newline at end of file diff --git a/ptcms/library/bae/lib/BaeBase.class.php b/ptcms/library/bae/lib/BaeBase.class.php new file mode 100644 index 0000000..7fd1a22 --- /dev/null +++ b/ptcms/library/bae/lib/BaeBase.class.php @@ -0,0 +1,78 @@ +'; + debug_print_backtrace(); + echo ''; + trigger_error($error_msg, $error_type); + } + + /** + * @brief return the handle + * + */ + public function getHandle() + { + return $this->_handle; + } + + /** + * @brief return the error message + * + */ + public function errmsg() + { + return $this->errmsg; + } + + /** + * @brief return the error code + * + */ + public function errno() + { + return $this->errcode; + } + +} + +/* vim: set ts=4 sw=4 sts=4 tw=100 noet: */ +?> \ No newline at end of file diff --git a/ptcms/library/bae/lib/BaeException.class.php b/ptcms/library/bae/lib/BaeException.class.php new file mode 100644 index 0000000..39686ad --- /dev/null +++ b/ptcms/library/bae/lib/BaeException.class.php @@ -0,0 +1,21 @@ + \ No newline at end of file diff --git a/ptcms/library/bae/lib/BaeTaskQueueException.class.php b/ptcms/library/bae/lib/BaeTaskQueueException.class.php new file mode 100644 index 0000000..2ffb584 --- /dev/null +++ b/ptcms/library/bae/lib/BaeTaskQueueException.class.php @@ -0,0 +1,6 @@ + diff --git a/ptcms/library/bae/lib/BccsServerException.class.php b/ptcms/library/bae/lib/BccsServerException.class.php new file mode 100644 index 0000000..4987923 --- /dev/null +++ b/ptcms/library/bae/lib/BccsServerException.class.php @@ -0,0 +1,6 @@ + diff --git a/ptcms/library/bae/lib/BcmsException.class.php b/ptcms/library/bae/lib/BcmsException.class.php new file mode 100644 index 0000000..cacd6c3 --- /dev/null +++ b/ptcms/library/bae/lib/BcmsException.class.php @@ -0,0 +1,6 @@ + \ No newline at end of file diff --git a/ptcms/library/bae/lib/ChannelException.class.php b/ptcms/library/bae/lib/ChannelException.class.php new file mode 100644 index 0000000..ef7d02e --- /dev/null +++ b/ptcms/library/bae/lib/ChannelException.class.php @@ -0,0 +1,6 @@ + diff --git a/ptcms/library/bae/lib/CronException.class.php b/ptcms/library/bae/lib/CronException.class.php new file mode 100644 index 0000000..175f223 --- /dev/null +++ b/ptcms/library/bae/lib/CronException.class.php @@ -0,0 +1,6 @@ + diff --git a/ptcms/library/bae/lib/RequestCore.class.php b/ptcms/library/bae/lib/RequestCore.class.php new file mode 100644 index 0000000..8b6c85e --- /dev/null +++ b/ptcms/library/bae/lib/RequestCore.class.php @@ -0,0 +1,773 @@ +). + */ + public $request_class = 'RequestCore'; + /** + * The default class to use for HTTP Responses (defaults to ). + */ + public $response_class = 'ResponseCore'; + /** + * Default useragent string to use. + */ + public $useragent = 'RequestCore/1.4.2'; + /** + * File to read from while streaming up. + */ + public $read_file = null; + /** + * The resource to read from while streaming up. + */ + public $read_stream = null; + /** + * The size of the stream to read from. + */ + public $read_stream_size = null; + /** + * The length already read from the stream. + */ + public $read_stream_read = 0; + /** + * File to write to while streaming down. + */ + public $write_file = null; + /** + * The resource to write to while streaming down. + */ + public $write_stream = null; + /** + * Stores the intended starting seek position. + */ + public $seek_position = null; + /** + * The user-defined callback function to call when a stream is read from. + */ + public $registered_streaming_read_callback = null; + /** + * The user-defined callback function to call when a stream is written to. + */ + public $registered_streaming_write_callback = null; + /*%******************************************************************************************%*/ + // CONSTANTS + /** + * GET HTTP Method + */ + const HTTP_GET = 'GET'; + /** + * POST HTTP Method + */ + const HTTP_POST = 'POST'; + /** + * PUT HTTP Method + */ + const HTTP_PUT = 'PUT'; + /** + * DELETE HTTP Method + */ + const HTTP_DELETE = 'DELETE'; + /** + * HEAD HTTP Method + */ + const HTTP_HEAD = 'HEAD'; + /*%******************************************************************************************%*/ + // CONSTRUCTOR/DESTRUCTOR + /** + * Constructs a new instance of this class. + * + * @param string $url (Optional) The URL to request or service endpoint to query. + * @param string $proxy (Optional) The faux-url to use for proxy settings. Takes the following format: `proxy://user:pass@hostname:port` + * @param array $helpers (Optional) An associative array of classnames to use for request, and response functionality. Gets passed in automatically by the calling class. + * @return $this A reference to the current instance. + */ + public function __construct($url = null, $proxy = null, $helpers = null) { + // Set some default values. + $this->request_url = $url; + $this->method = self::HTTP_GET; + $this->request_headers = array (); + $this->request_body = ''; + // Set a new Request class if one was set. + if (isset ( $helpers ['request'] ) && ! empty ( $helpers ['request'] )) { + $this->request_class = $helpers ['request']; + } + // Set a new Request class if one was set. + if (isset ( $helpers ['response'] ) && ! empty ( $helpers ['response'] )) { + $this->response_class = $helpers ['response']; + } + if ($proxy) { + $this->set_proxy ( $proxy ); + } + return $this; + } + /** + * Destructs the instance. Closes opened file handles. + * + * @return $this A reference to the current instance. + */ + public function __destruct() { + if (isset ( $this->read_file ) && isset ( $this->read_stream )) { + fclose ( $this->read_stream ); + } + if (isset ( $this->write_file ) && isset ( $this->write_stream )) { + fclose ( $this->write_stream ); + } + return $this; + } + /*%******************************************************************************************%*/ + // REQUEST METHODS + /** + * Sets the credentials to use for authentication. + * + * @param string $user (Required) The username to authenticate with. + * @param string $pass (Required) The password to authenticate with. + * @return $this A reference to the current instance. + */ + public function set_credentials($user, $pass) { + $this->username = $user; + $this->password = $pass; + return $this; + } + /** + * Adds a custom HTTP header to the cURL request. + * + * @param string $key (Required) The custom HTTP header to set. + * @param mixed $value (Required) The value to assign to the custom HTTP header. + * @return $this A reference to the current instance. + */ + public function add_header($key, $value) { + $this->request_headers [$key] = $value; + return $this; + } + /** + * Removes an HTTP header from the cURL request. + * + * @param string $key (Required) The custom HTTP header to set. + * @return $this A reference to the current instance. + */ + public function remove_header($key) { + if (isset ( $this->request_headers [$key] )) { + unset ( $this->request_headers [$key] ); + } + return $this; + } + /** + * Set the method type for the request. + * + * @param string $method (Required) One of the following constants: , , , , . + * @return $this A reference to the current instance. + */ + public function set_method($method) { + $this->method = strtoupper ( $method ); + return $this; + } + /** + * Sets a custom useragent string for the class. + * + * @param string $ua (Required) The useragent string to use. + * @return $this A reference to the current instance. + */ + public function set_useragent($ua) { + $this->useragent = $ua; + return $this; + } + /** + * Set the body to send in the request. + * + * @param string $body (Required) The textual content to send along in the body of the request. + * @return $this A reference to the current instance. + */ + public function set_body($body) { + $this->request_body = $body; + return $this; + } + /** + * Set the URL to make the request to. + * + * @param string $url (Required) The URL to make the request to. + * @return $this A reference to the current instance. + */ + public function set_request_url($url) { + $this->request_url = $url; + return $this; + } + /** + * Set additional CURLOPT settings. These will merge with the default settings, and override if + * there is a duplicate. + * + * @param array $curlopts (Optional) A set of key-value pairs that set `CURLOPT` options. These will merge with the existing CURLOPTs, and ones passed here will override the defaults. Keys should be the `CURLOPT_*` constants, not strings. + * @return $this A reference to the current instance. + */ + public function set_curlopts($curlopts) { + $this->curlopts = $curlopts; + return $this; + } + /** + * Sets the length in bytes to read from the stream while streaming up. + * + * @param integer $size (Required) The length in bytes to read from the stream. + * @return $this A reference to the current instance. + */ + public function set_read_stream_size($size) { + $this->read_stream_size = $size; + return $this; + } + /** + * Sets the resource to read from while streaming up. Reads the stream from its current position until + * EOF or `$size` bytes have been read. If `$size` is not given it will be determined by and + * . + * + * @param resource $resource (Required) The readable resource to read from. + * @param integer $size (Optional) The size of the stream to read. + * @return $this A reference to the current instance. + */ + public function set_read_stream($resource, $size = null) { + if (! isset ( $size ) || $size < 0) { + $stats = fstat ( $resource ); + if ($stats && $stats ['size'] >= 0) { + $position = ftell ( $resource ); + if ($position !== false && $position >= 0) { + $size = $stats ['size'] - $position; + } + } + } + $this->read_stream = $resource; + return $this->set_read_stream_size ( $size ); + } + /** + * Sets the file to read from while streaming up. + * + * @param string $location (Required) The readable location to read from. + * @return $this A reference to the current instance. + */ + public function set_read_file($location) { + $this->read_file = $location; + $read_file_handle = fopen ( $location, 'r' ); + return $this->set_read_stream ( $read_file_handle ); + } + /** + * Sets the resource to write to while streaming down. + * + * @param resource $resource (Required) The writeable resource to write to. + * @return $this A reference to the current instance. + */ + public function set_write_stream($resource) { + $this->write_stream = $resource; + return $this; + } + /** + * Sets the file to write to while streaming down. + * + * @param string $location (Required) The writeable location to write to. + * @return $this A reference to the current instance. + */ + public function set_write_file($location) { + $this->write_file = $location; + $write_file_handle = fopen ( $location, 'w' ); + return $this->set_write_stream ( $write_file_handle ); + } + /** + * Set the proxy to use for making requests. + * + * @param string $proxy (Required) The faux-url to use for proxy settings. Takes the following format: `proxy://user:pass@hostname:port` + * @return $this A reference to the current instance. + */ + public function set_proxy($proxy) { + $proxy = parse_url ( $proxy ); + $proxy ['user'] = isset ( $proxy ['user'] ) ? $proxy ['user'] : null; + $proxy ['pass'] = isset ( $proxy ['pass'] ) ? $proxy ['pass'] : null; + $proxy ['port'] = isset ( $proxy ['port'] ) ? $proxy ['port'] : null; + $this->proxy = $proxy; + return $this; + } + /** + * Set the intended starting seek position. + * + * @param integer $position (Required) The byte-position of the stream to begin reading from. + * @return $this A reference to the current instance. + */ + public function set_seek_position($position) { + $this->seek_position = isset ( $position ) ? ( integer ) $position : null; + return $this; + } + /** + * Register a callback function to execute whenever a data stream is read from using + * . + * + * The user-defined callback function should accept three arguments: + * + *
    + *
  • $curl_handle - resource - Required - The cURL handle resource that represents the in-progress transfer.
  • + *
  • $file_handle - resource - Required - The file handle resource that represents the file on the local file system.
  • + *
  • $length - integer - Required - The length in kilobytes of the data chunk that was transferred.
  • + *
+ * + * @param string|array|function $callback (Required) The callback function is called by , so you can pass the following values:
    + *
  • The name of a global function to execute, passed as a string.
  • + *
  • A method to execute, passed as array('ClassName', 'MethodName').
  • + *
  • An anonymous function (PHP 5.3+).
+ * @return $this A reference to the current instance. + */ + public function register_streaming_read_callback($callback) { + $this->registered_streaming_read_callback = $callback; + return $this; + } + /** + * Register a callback function to execute whenever a data stream is written to using + * . + * + * The user-defined callback function should accept two arguments: + * + *
    + *
  • $curl_handle - resource - Required - The cURL handle resource that represents the in-progress transfer.
  • + *
  • $length - integer - Required - The length in kilobytes of the data chunk that was transferred.
  • + *
+ * + * @param string|array|function $callback (Required) The callback function is called by , so you can pass the following values:
    + *
  • The name of a global function to execute, passed as a string.
  • + *
  • A method to execute, passed as array('ClassName', 'MethodName').
  • + *
  • An anonymous function (PHP 5.3+).
+ * @return $this A reference to the current instance. + */ + public function register_streaming_write_callback($callback) { + $this->registered_streaming_write_callback = $callback; + return $this; + } + /*%******************************************************************************************%*/ + // PREPARE, SEND, AND PROCESS REQUEST + /** + * A callback function that is invoked by cURL for streaming up. + * + * @param resource $curl_handle (Required) The cURL handle for the request. + * @param resource $file_handle (Required) The open file handle resource. + * @param integer $length (Required) The maximum number of bytes to read. + * @return binary Binary data from a stream. + */ + public function streaming_read_callback($curl_handle, $file_handle, $length) { + // Once we've sent as much as we're supposed to send... + if ($this->read_stream_read >= $this->read_stream_size) { + // Send EOF + return ''; + } + // If we're at the beginning of an upload and need to seek... + if ($this->read_stream_read == 0 && isset ( $this->seek_position ) && $this->seek_position !== ftell ( $this->read_stream )) { + if (fseek ( $this->read_stream, $this->seek_position ) !== 0) { + throw new RequestCore_Exception ( 'The stream does not support seeking and is either not at the requested position or the position is unknown.' ); + } + } + $read = fread ( $this->read_stream, min ( $this->read_stream_size - $this->read_stream_read, $length ) ); // Remaining upload data or cURL's requested chunk size + $this->read_stream_read += strlen ( $read ); + $out = $read === false ? '' : $read; + // Execute callback function + if ($this->registered_streaming_read_callback) { + call_user_func ( $this->registered_streaming_read_callback, $curl_handle, $file_handle, $out ); + } + return $out; + } + /** + * A callback function that is invoked by cURL for streaming down. + * + * @param resource $curl_handle (Required) The cURL handle for the request. + * @param binary $data (Required) The data to write. + * @return integer The number of bytes written. + */ + public function streaming_write_callback($curl_handle, $data) { + $length = strlen ( $data ); + $written_total = 0; + $written_last = 0; + while ( $written_total < $length ) { + $written_last = fwrite ( $this->write_stream, substr ( $data, $written_total ) ); + if ($written_last === false) { + return $written_total; + } + $written_total += $written_last; + } + // Execute callback function + if ($this->registered_streaming_write_callback) { + call_user_func ( $this->registered_streaming_write_callback, $curl_handle, $written_total ); + } + return $written_total; + } + /** + * Prepares and adds the details of the cURL request. This can be passed along to a + * function. + * + * @return resource The handle for the cURL object. + */ + public function prep_request() { + $curl_handle = curl_init (); + // Set default options. + curl_setopt ( $curl_handle, CURLOPT_URL, $this->request_url ); + curl_setopt ( $curl_handle, CURLOPT_FILETIME, true ); + curl_setopt ( $curl_handle, CURLOPT_FRESH_CONNECT, false ); + curl_setopt ( $curl_handle, CURLOPT_SSL_VERIFYPEER, false ); + @ curl_setopt ( $curl_handle, CURLOPT_SSL_VERIFYHOST, true ); + curl_setopt ( $curl_handle, CURLOPT_CLOSEPOLICY, CURLCLOSEPOLICY_LEAST_RECENTLY_USED ); + curl_setopt ( $curl_handle, CURLOPT_MAXREDIRS, 5 ); + curl_setopt ( $curl_handle, CURLOPT_HEADER, true ); + curl_setopt ( $curl_handle, CURLOPT_RETURNTRANSFER, true ); + curl_setopt ( $curl_handle, CURLOPT_TIMEOUT, 5184000 ); + curl_setopt ( $curl_handle, CURLOPT_CONNECTTIMEOUT, 120 ); + curl_setopt ( $curl_handle, CURLOPT_NOSIGNAL, true ); + curl_setopt ( $curl_handle, CURLOPT_REFERER, $this->request_url ); + curl_setopt ( $curl_handle, CURLOPT_USERAGENT, $this->useragent ); + curl_setopt ( $curl_handle, CURLOPT_READFUNCTION, array ( + $this, 'streaming_read_callback' ) ); + if ($this->debug_mode) { + curl_setopt ( $curl_handle, CURLOPT_VERBOSE, true ); + } + if (! ini_get ( 'safe_mode' )) { + //modify by zhengkan + //curl_setopt($curl_handle, CURLOPT_FOLLOWLOCATION, true); + } + // Enable a proxy connection if requested. + if ($this->proxy) { + curl_setopt ( $curl_handle, CURLOPT_HTTPPROXYTUNNEL, true ); + $host = $this->proxy ['host']; + $host .= ($this->proxy ['port']) ? ':' . $this->proxy ['port'] : ''; + curl_setopt ( $curl_handle, CURLOPT_PROXY, $host ); + if (isset ( $this->proxy ['user'] ) && isset ( $this->proxy ['pass'] )) { + curl_setopt ( $curl_handle, CURLOPT_PROXYUSERPWD, $this->proxy ['user'] . ':' . $this->proxy ['pass'] ); + } + } + // Set credentials for HTTP Basic/Digest Authentication. + if ($this->username && $this->password) { + curl_setopt ( $curl_handle, CURLOPT_HTTPAUTH, CURLAUTH_ANY ); + curl_setopt ( $curl_handle, CURLOPT_USERPWD, $this->username . ':' . $this->password ); + } + // Handle the encoding if we can. + if (extension_loaded ( 'zlib' )) { + curl_setopt ( $curl_handle, CURLOPT_ENCODING, '' ); + } + // Process custom headers + if (isset ( $this->request_headers ) && count ( $this->request_headers )) { + $temp_headers = array (); + foreach ( $this->request_headers as $k => $v ) { + $temp_headers [] = $k . ': ' . $v; + } + curl_setopt ( $curl_handle, CURLOPT_HTTPHEADER, $temp_headers ); + } + switch ($this->method) { + case self::HTTP_PUT : + curl_setopt ( $curl_handle, CURLOPT_CUSTOMREQUEST, 'PUT' ); + if (isset ( $this->read_stream )) { + if (! isset ( $this->read_stream_size ) || $this->read_stream_size < 0) { + throw new RequestCore_Exception ( 'The stream size for the streaming upload cannot be determined.' ); + } + curl_setopt ( $curl_handle, CURLOPT_INFILESIZE, $this->read_stream_size ); + curl_setopt ( $curl_handle, CURLOPT_UPLOAD, true ); + } else { + curl_setopt ( $curl_handle, CURLOPT_POSTFIELDS, $this->request_body ); + } + break; + case self::HTTP_POST : + curl_setopt ( $curl_handle, CURLOPT_POST, true ); + curl_setopt ( $curl_handle, CURLOPT_POSTFIELDS, $this->request_body ); + break; + case self::HTTP_HEAD : + curl_setopt ( $curl_handle, CURLOPT_CUSTOMREQUEST, self::HTTP_HEAD ); + curl_setopt ( $curl_handle, CURLOPT_NOBODY, 1 ); + break; + default : // Assumed GET + curl_setopt ( $curl_handle, CURLOPT_CUSTOMREQUEST, $this->method ); + if (isset ( $this->write_stream )) { + curl_setopt ( $curl_handle, CURLOPT_WRITEFUNCTION, array ( + $this, 'streaming_write_callback' ) ); + curl_setopt ( $curl_handle, CURLOPT_HEADER, false ); + } else { + curl_setopt ( $curl_handle, CURLOPT_POSTFIELDS, $this->request_body ); + } + break; + } + // Merge in the CURLOPTs + if (isset ( $this->curlopts ) && sizeof ( $this->curlopts ) > 0) { + foreach ( $this->curlopts as $k => $v ) { + curl_setopt ( $curl_handle, $k, $v ); + } + } + return $curl_handle; + } + /** + * Take the post-processed cURL data and break it down into useful header/body/info chunks. Uses the + * data stored in the `curl_handle` and `response` properties unless replacement data is passed in via + * parameters. + * + * @param resource $curl_handle (Optional) The reference to the already executed cURL request. + * @param string $response (Optional) The actual response content itself that needs to be parsed. + * @return ResponseCore A object containing a parsed HTTP response. + */ + public function process_response($curl_handle = null, $response = null) { + // Accept a custom one if it's passed. + if ($curl_handle && $response) { + $this->curl_handle = $curl_handle; + $this->response = $response; + } + // As long as this came back as a valid resource... + if (is_resource ( $this->curl_handle )) { + // Determine what's what. + $header_size = curl_getinfo ( $this->curl_handle, CURLINFO_HEADER_SIZE ); + $this->response_headers = substr ( $this->response, 0, $header_size ); + $this->response_body = substr ( $this->response, $header_size ); + $this->response_code = curl_getinfo ( $this->curl_handle, CURLINFO_HTTP_CODE ); + $this->response_info = curl_getinfo ( $this->curl_handle ); + // Parse out the headers + $this->response_headers = explode ( "\r\n\r\n", trim ( $this->response_headers ) ); + $this->response_headers = array_pop ( $this->response_headers ); + $this->response_headers = explode ( "\r\n", $this->response_headers ); + array_shift ( $this->response_headers ); + // Loop through and split up the headers. + $header_assoc = array (); + foreach ( $this->response_headers as $header ) { + $kv = explode ( ': ', $header ); + //$header_assoc [strtolower ( $kv [0] )] = $kv [1]; + $header_assoc [$kv [0]] = $kv [1]; + } + // Reset the headers to the appropriate property. + $this->response_headers = $header_assoc; + $this->response_headers ['_info'] = $this->response_info; + $this->response_headers ['_info'] ['method'] = $this->method; + if ($curl_handle && $response) { + return new $this->response_class ( $this->response_headers, $this->response_body, $this->response_code, $this->curl_handle ); + } + } + // Return false + return false; + } + /** + * Sends the request, calling necessary utility functions to update built-in properties. + * + * @param boolean $parse (Optional) Whether to parse the response with ResponseCore or not. + * @return string The resulting unparsed data from the request. + */ + public function send_request($parse = false) { + $curl_handle = $this->prep_request (); + $this->response = curl_exec ( $curl_handle ); + if ($this->response === false) { + throw new RequestCore_Exception ( 'cURL resource: ' . ( string ) $curl_handle . '; cURL error: ' . curl_error ( $curl_handle ) . ' (' . curl_errno ( $curl_handle ) . ')' ); + } + $parsed_response = $this->process_response ( $curl_handle, $this->response ); + curl_close ( $curl_handle ); + if ($parse) { + return $parsed_response; + } + return $this->response; + } + /** + * Sends the request using , enabling parallel requests. Uses the "rolling" method. + * + * @param array $handles (Required) An indexed array of cURL handles to process simultaneously. + * @param array $opt (Optional) An associative array of parameters that can have the following keys:
    + *
  • callback - string|array - Optional - The string name of a function to pass the response data to. If this is a method, pass an array where the [0] index is the class and the [1] index is the method name.
  • + *
  • limit - integer - Optional - The number of simultaneous requests to make. This can be useful for scaling around slow server responses. Defaults to trusting cURLs judgement as to how many to use.
+ * @return array Post-processed cURL responses. + */ + public function send_multi_request($handles, $opt = null) { + // Skip everything if there are no handles to process. + if (count ( $handles ) === 0) + return array (); + if (! $opt) + $opt = array (); + + // Initialize any missing options + $limit = isset ( $opt ['limit'] ) ? $opt ['limit'] : - 1; + // Initialize + $handle_list = $handles; + $http = new $this->request_class (); + $multi_handle = curl_multi_init (); + $handles_post = array (); + $added = count ( $handles ); + $last_handle = null; + $count = 0; + $i = 0; + // Loop through the cURL handles and add as many as it set by the limit parameter. + while ( $i < $added ) { + if ($limit > 0 && $i >= $limit) + break; + curl_multi_add_handle ( $multi_handle, array_shift ( $handles ) ); + $i ++; + } + do { + $active = false; + // Start executing and wait for a response. + while ( ($status = curl_multi_exec ( $multi_handle, $active )) === CURLM_CALL_MULTI_PERFORM ) { + // Start looking for possible responses immediately when we have to add more handles + if (count ( $handles ) > 0) + break; + } + // Figure out which requests finished. + $to_process = array (); + while ( $done = curl_multi_info_read ( $multi_handle ) ) { + // Since curl_errno() isn't reliable for handles that were in multirequests, we check the 'result' of the info read, which contains the curl error number, (listed here http://curl.haxx.se/libcurl/c/libcurl-errors.html ) + if ($done ['result'] > 0) { + throw new RequestCore_Exception ( 'cURL resource: ' . ( string ) $done ['handle'] . '; cURL error: ' . curl_error ( $done ['handle'] ) . ' (' . $done ['result'] . ')' ); + } // Because curl_multi_info_read() might return more than one message about a request, we check to see if this request is already in our array of completed requests +elseif (! isset ( $to_process [( int ) $done ['handle']] )) { + $to_process [( int ) $done ['handle']] = $done; + } + } + // Actually deal with the request + foreach ( $to_process as $pkey => $done ) { + $response = $http->process_response ( $done ['handle'], curl_multi_getcontent ( $done ['handle'] ) ); + $key = array_search ( $done ['handle'], $handle_list, true ); + $handles_post [$key] = $response; + if (count ( $handles ) > 0) { + curl_multi_add_handle ( $multi_handle, array_shift ( $handles ) ); + } + curl_multi_remove_handle ( $multi_handle, $done ['handle'] ); + curl_close ( $done ['handle'] ); + } + } while ( $active || count ( $handles_post ) < $added ); + curl_multi_close ( $multi_handle ); + ksort ( $handles_post, SORT_NUMERIC ); + return $handles_post; + } + /*%******************************************************************************************%*/ + // RESPONSE METHODS + /** + * Get the HTTP response headers from the request. + * + * @param string $header (Optional) A specific header value to return. Defaults to all headers. + * @return string|array All or selected header values. + */ + public function get_response_header($header = null) { + if ($header) { + // return $this->response_headers [strtolower ( $header )]; + return $this->response_headers [$header]; + } + return $this->response_headers; + } + /** + * Get the HTTP response body from the request. + * + * @return string The response body. + */ + public function get_response_body() { + return $this->response_body; + } + /** + * Get the HTTP response code from the request. + * + * @return string The HTTP response code. + */ + public function get_response_code() { + return $this->response_code; + } +} +/** + * Container for all response-related methods. + */ +class ResponseCore { + /** + * Stores the HTTP header information. + */ + public $header; + /** + * Stores the SimpleXML response. + */ + public $body; + /** + * Stores the HTTP response code. + */ + public $status; + /** + * Constructs a new instance of this class. + * + * @param array $header (Required) Associative array of HTTP headers (typically returned by ). + * @param string $body (Required) XML-formatted response from AWS. + * @param integer $status (Optional) HTTP response status code from the request. + * @return object Contains an `header` property (HTTP headers as an associative array), a or `body` property, and an `status` code. + */ + public function __construct($header, $body, $status = null) { + $this->header = $header; + $this->body = $body; + $this->status = $status; + return $this; + } + /** + * Did we receive the status code we expected? + * + * @param integer|array $codes (Optional) The status code(s) to expect. Pass an for a single acceptable value, or an of integers for multiple acceptable values. + * @return boolean Whether we received the expected status code or not. + */ + public function isOK($codes = array(200, 201, 204, 206)) { + if (is_array ( $codes )) { + return in_array ( $this->status, $codes ); + } + return $this->status === $codes; + } +} +/** + * Default RequestCore Exception. + */ +class RequestCore_Exception extends Exception { +} diff --git a/ptcms/library/bae/zcache/memcache_errno.php b/ptcms/library/bae/zcache/memcache_errno.php new file mode 100644 index 0000000..96eede5 --- /dev/null +++ b/ptcms/library/bae/zcache/memcache_errno.php @@ -0,0 +1,26 @@ + "RES_PAYLOAD_FAILURE", + "0" => "RES_SUCCESS", + "1" => "RES_FAILURE", + "2" => "RES_USER_AUTH_FAILURE", + "7" => "RES_UNKNOWN_READ_FAILURE", + "8" => "RES_PROTOCOL_ERROR", + "9" => "RES_CLIENT_ERROR", + "10" => "RES_SERVER_ERROR", + "5" => "RES_WRITE_FAILURE", + "12" => "RES_DATA_EXISTS", + "14" => "RES_NOTSTORED", + "16" => "RES_NOTFOUND", + "18" => "RES_PARTIAL_READ", + "19" => "RES_SOME_ERRORS", + "20" => "RES_NO_SERVERS", + "21" => "RES_SERVER_BUSY", + "26" => "RES_ERRNO", + "32" => "RES_BUFFERED", + "31" => "RES_TIMEOUT", + "33" => "RES_BAD_KEY_PROVIDED", + "11" => "RES_CONNECTION_SOCKET_CREATE_FAILURE", + + ); + + private $errnomap = array ( + + ZCACHE_AGENT_ERR_PARAM => RES_CLIENT_ERROR, + ZCACHE_AGENT_ERR_MCPACK => RES_PROTOCOL_ERROR, + ZCACHE_AGENT_ERR_MEM => RES_SERVER_ERROR, + ZCACHE_AGENT_ERR_MCPACK_OP => RES_PROTOCOL_ERROR, + + ZCACHE_OK => RES_SUCCESS, + ZCACHE_ERR_PARAM => RES_CLIENT_ERROR, + ZCACHE_ERR_NOT_AUTH => RES_HOST_LOOKUP_FAILURE, + ZCACHE_ERR_BUF_NOT_ENOUGH => RES_BUFFERED, + ZCACHE_ERR_EXIST => RES_DATA_EXISTS, + ZCACHE_ERR_NOT_EXIST => RES_NOTFOUND, + ZCACHE_ERR_BLOCK_NOT_EXIST => RES_SERVER_ERROR, + ZCACHE_ERR_PRODUCT_NOT_EXIST => RES_SERVER_ERROR, + ZCACHE_ERR_BUSY => RES_END, + ZCACHE_ERR_FROZEN_DELETE => RES_SERVER_ERROR, + ZCACHE_ERR_BLOCK_UPDATED => RES_SERVER_ERROR, + ZCACHE_ERR_TIMEOUT => RES_TIMEOUT, + ZCACHE_ERR_NET => RES_SERVER_ERROR, + ZCACHE_ERR_MEM => RES_SERVER_ERROR, + ZCACHE_ERR_DISK => RES_SERVER_ERROR, + ZCACHE_ERR_METASERVER => RES_SERVER_ERROR, + ZCACHE_ERR_CACHESERVER => RES_SERVER_ERROR, + ZCACHE_ERR_LIB => RES_SERVER_ERROR, + ZCACHE_ERR_PART_SUC => RES_SERVER_ERROR, + ZCACHE_ERR_BLOCK_WRONG_STATE => RES_SERVER_ERROR, + ZCACHE_APIPLUS_INIT_FAIL => RES_SERVER_ERROR, + ZCACHE_ERR_CREATE_PRDT_FILE => RES_SERVER_ERROR, + ZCACHE_ERR_PRODUCT_ALREADY_EXIST => RES_SERVER_ERROR, + + ZCACHE_CLIENT_ERR_PARAM => RES_CLIENT_ERROR, + ZCACHE_CLIENT_ERR_CONNECT => RES_CONNECTION_SOCKET_CREATE_FAILURE, + ZCACHE_CLIENT_ERR_READ => RES_UNKNOWN_READ_FAILURE, + ZCACHE_CLIENT_ERR_WRITE => RES_WRITE_FAILURE, + ZCACHE_CLIENT_ERR_NSHEAD => RES_PROTOCOL_ERROR, + ZCACHE_CLIENT_ERR_MCPACK => RES_PROTOCOL_ERROR, + + ); + + private $_adapter; + private $_pname_str; + private $_token_str; + private $_logid_int; + private $_appid; + public $_last_errno; + + private function _convertErrno($errcode) { + if (array_key_exists($errcode, $this->errnomap)) { + return $this->errnomap[$errcode]; + } + return RES_SOME_ERRORS; + } + + private function _log($output) { + if(ENABLE_DEBUG !== 0) { + echo "--memcached: $output"; + } + } + + public function _convertErrmsg($errcode) { + if (array_key_exists(strval($errcode), $this->errmsgmap)) { + return $this->errmsgmap[strval($errcode)]; + } + return "RES_SOME_ERRORS"; + } + + public function __construct($cache_id, $memcache_addr, $user, $password) { + $cnfobj = new ZCacheConf(); + //$cnfobj->PERSISTENT = 0; + $cnfobj->CONNTIMEOUT = 1; + $cnfobj->MCPACK_VERSION = PHP_MC_PACK_V2; + + //retry time + $cnfobj->RETRYTIME = 3; + + $zcache_addrs = $memcache_addr; + + if($zcache_addrs === false) { + throw new MemcachedMeException("Missing cache server address"); + } + + $addr_arr = explode(",", $zcache_addrs); + if($addr_arr === false) { + throw new MemcachedMeException("invalid cache server address"); + } + + foreach($addr_arr as $addr) { + $ipport = explode(":", $addr); + if($ipport === false) { + throw new MemcachedMeException("invalid cache server address"); + } + $cnfobj->agent_servers[] = array( + "socket_address" => $ipport[0], + "socket_port" => intval($ipport[1]), + "socket_timeout" => 500 + ); + } + if(!$this->_getInitEnv($cache_id, $user, $password)) { + throw new MemcachedMeException("invalid cache evn"); + } + $this->_adapter = new ZCache($cnfobj); + $this->_adapter->set_shareAppid($this->_appid); + $this->_last_errno = RES_SUCCESS; + } + private function _getInitEnv($cache_id, $user, $password) { + $pname_str = $user; + $token_str = $password; + $logid_int = 1; + + $appid = $cache_id; + + if($pname_str === false || $token_str === false || $logid_int === false || $appid === false) { + $this->_log("Please setup HTTP_BAE_ENV_AK, HTTP_BAE_ENV_SK, HTTP_BAE_ENV_APPID\n"); + return false; + } + $logid_int = intval($logid_int); + $this->_pname_str = $pname_str; + $this->_token_str = $token_str; + $this->_logid_int = $logid_int; + $this->_appid = $appid; + + return true; + } + + private function _getEnv(&$pname_str, &$token_str, &$logid_int) { + $pname_str = $this->_pname_str; + $token_str = $this->_token_str; + $logid_int = $this->_logid_int; + + return true; + } + + private function _checkParamValue($value) { + if(!is_string($value)) + return true; + + $len = strlen($value); + if($len == 0 || $len > ZCACHE_MAX_VALUE_LEN) { + return false; + } + return true; + } + + private function _convertKey($key) { + if(is_numeric($key)) + return strval($key); + return $key; + } + + private function _convertValue($value) { + if(is_int($value)) { + $res = strval($value); + } else if(is_float($value)) { + $res = serialize(strval($value)); + } else if(is_string($value)) { + if(is_numeric($value)) { + if(strstr($value, ".") !== false) { ### float + $res = serialize(strval($value)); + } else + $res = $value; + } + $res = serialize($value); + } else { + $res = serialize($value); + } + + if($this->_checkParamValue($res) === false) return false; + else return $res; + } + + private function _convertOffset($offset) { + if(is_numeric($offset)) + return intval($offset); + return 0; + } + + private function _unconvertResult($result) { + if(!is_numeric($result)) { + return unserialize($result); + } + return $result; + } + + public function addEx($pname_str, $token_str, $logid_int, $key, $value, $expiration = 0) { + if(!is_int($expiration) || $expiration < 0) { + $this->_last_errno = RES_CLIENT_ERROR; + return false; + } + + $key = $this->_convertKey($key); + $value_str = $this->_convertValue($value); + if($value_str === false) { + $this->_last_errno = RES_CLIENT_ERROR; + return false; + } + $ret = $this->_adapter->addOne($pname_str, $token_str, $logid_int, $key, $value_str, $expiration*1000); + $this->_last_errno = $this->_convertErrno($this->_adapter->getLastErrCode()); + return $ret; + } + + public function add($key, $value, $expiration = 0) { + $pname_str = ""; + $token_str = ""; + $logid_int = 0; + if(!$this->_getEnv($pname_str, $token_str, $logid_int)) { + $this->_last_errno = RES_CLIENT_ERROR; + return false; + } + return $this->addEx($pname_str, $token_str, $logid_int, $key, $value, $expiration); + } + + public function setEx($pname_str, $token_str, $logid_int, $key, $value, $expiration = 0) { + if(!is_int($expiration) || $expiration < 0) { + $this->_last_errno = RES_CLIENT_ERROR; + return false; + } + + $key = $this->_convertKey($key); + $value_str = $this->_convertValue($value); + if($value_str === false) { + $this->_last_errno = RES_CLIENT_ERROR; + return false; + } + $ret = $this->_adapter->setOne($pname_str, $token_str, $logid_int, $key, $value_str, $expiration*1000); + $this->_last_errno = $this->_convertErrno($this->_adapter->getLastErrCode()); + return $ret; + } + + public function set($key, $value, $expiration = 0) { + $pname_str = ""; + $token_str = ""; + $logid_int = 0; + if(!$this->_getEnv($pname_str, $token_str, $logid_int)) { + $this->_last_errno = RES_CLIENT_ERROR; + return false; + } + return $this->setEx($pname_str, $token_str, $logid_int, $key, $value, $expiration); + } + + public function replaceEx($pname_str, $token_str, $logid_int, $key, $value, $expiration = 0) { + if(!is_int($expiration) || $expiration < 0) { + $this->_last_errno = RES_CLIENT_ERROR; + return false; + } + + $key = $this->_convertKey($key); + $value_str = $this->_convertValue($value); + if($value_str === false) { + $this->_last_errno = RES_CLIENT_ERROR; + return false; + } + + $ret = $this->_adapter->replaceOne($pname_str, $token_str, $logid_int, $key, $value_str, $expiration*1000); + $this->_last_errno = $this->_convertErrno($this->_adapter->getLastErrCode()); + return $ret; + } + + public function replace($key, $value, $expiration = 0) { + $pname_str = ""; + $token_str = ""; + $logid_int = 0; + if(!$this->_getEnv($pname_str, $token_str, $logid_int)) { + $this->_last_errno = RES_CLIENT_ERROR; + return false; + } + return $this->replaceEx($pname_str, $token_str, $logid_int, $key, $value, $expiration); + } + + public function deleteEx($pname_str, $token_str, $logid_int, $key, $time=0) { + $key = $this->_convertKey($key); + $ret = $this->_adapter->deleteOne($pname_str, $token_str, $logid_int, $key, $time*1000); + $this->_last_errno = $this->_convertErrno($this->_adapter->getLastErrCode()); + + return $ret; + } + + public function delete($key, $time = 0) { + $pname_str = ""; + $token_str = ""; + $logid_int = 0; + if(!$this->_getEnv($pname_str, $token_str, $logid_int)) { + $this->_last_errno = RES_CLIENT_ERROR; + return false; + } + return $this->deleteEx($pname_str, $token_str, $logid_int, $key, $time); + } + + public function incrementEx($pname_str, $token_str, $logid_int, $key, $offset = 1) { + $key = $this->_convertKey($key); + $offset = $this->_convertOffset($offset); + $ret = $this->_adapter->increment($pname_str, $token_str, $logid_int, $key, strval($offset), 0); + $this->_last_errno = $this->_convertErrno($this->_adapter->getLastErrCode()); + if($ret === false) return false; + return intval($ret); + } + + public function increment($key, $offset = 1) { + $pname_str = ""; + $token_str = ""; + $logid_int = 0; + if(!$this->_getEnv($pname_str, $token_str, $logid_int)) { + $this->_last_errno = RES_CLIENT_ERROR; + return false; + } + return $this->incrementEx($pname_str, $token_str, $logid_int, $key, $offset); + } + + public function decrementEx($pname_str, $token_str, $logid_int, $key, $offset = 1) { + $key = $this->_convertKey($key); + $offset = $this->_convertOffset($offset); + $ret = $this->_adapter->decrement($pname_str, $token_str, $logid_int, $key, strval($offset), 0); + $this->_last_errno = $this->_convertErrno($this->_adapter->getLastErrCode()); + if($ret === false) return false; + return intval($ret); + } + + public function decrement($key, $offset = 1) { + $pname_str = ""; + $token_str = ""; + $logid_int = 0; + if(!$this->_getEnv($pname_str, $token_str, $logid_int)) { + $this->_last_errno = RES_CLIENT_ERROR; + return false; + } + return $this->decrementEx($pname_str, $token_str, $logid_int, $key, $offset); + } + + public function getEx($pname_str, $token_str, $logid_int, $key) { + $key = $this->_convertKey($key); + $ret = $this->_adapter->getOne($pname_str, $token_str, $logid_int, $key); + $this->_last_errno = $this->_convertErrno($this->_adapter->getLastErrCode()); + $ret = $this->_unconvertResult($ret); + return $ret; + } + + public function get($key, $cache_cb = null, & $cas_token = null) { + $pname_str = ""; + $token_str = ""; + $logid_int = 0; + if(!$this->_getEnv($pname_str, $token_str, $logid_int)) { + $this->_last_errno = RES_CLIENT_ERROR; + return false; + } + return $this->getEx($pname_str, $token_str, $logid_int, $key); + } + + public function setMultiEx($pname_str, $token_str, $logid_int, array $items, $expiration = 0) { + if(!is_int($expiration) || $expiration < 0) { + $this->_last_errno = RES_CLIENT_ERROR; + return false; + } + $new_items = array(); + foreach($items as $key => $val) { + $key = $this->_convertKey($key); + $value_str = $this->_convertValue($val); + if($value_str === false) { + $this->_last_errno = RES_CLIENT_ERROR; + return false; + } + $new_items[$key] = $value_str; + } + + $ret_arr = $this->_adapter->setMulti($pname_str, $token_str, $logid_int, $new_items, $expiration*1000); + if(!$ret_arr) { + $this->_last_errno = RES_PAYLOAD_FAILURE; + return false; + } + + if(!isset($ret_arr['content']) || !is_array($ret_arr['content']) ) { + $this->_last_errno = RES_PAYLOAD_FAILURE; + return false; + } + + $count = count($ret_arr['content']); + if(count($items) != $count) { + $this->_last_errno = RES_PAYLOAD_FAILURE; + return false; + } + + for($i = 0; $i < $count; $i++) { + $result = $ret_arr['content']['result' . $i]; + if(isset($result['err_no']) && is_int($result['err_no']) && $result['err_no'] == ZCACHE_OK) { + continue; + } else { + $this->_last_errno = RES_PAYLOAD_FAILURE; + return false; + } + } + $this->_last_errno = RES_SUCCESS; + return true; + } + + public function setMulti(array $items, $expiration = 0) { + $pname_str = ""; + $token_str = ""; + $logid_int = 0; + + if(!$this->_getEnv($pname_str, $token_str, $logid_int)) { + $this->_last_errno = RES_CLIENT_ERROR; + return false; + } + return $this->setMultiEx($pname_str, $token_str, $logid_int, $items, $expiration); + } + + public function getMultiEx($pname_str, $token_str, $logid_int, array $keys) { + if(!is_array($keys)) { + $this->_last_errno = RES_CLIENT_ERROR; + return false; + } + + $strkey_arr = array(); + foreach($keys as $k => $v) { + $strkey_arr[] = $this->_convertKey($v); + } + + $ret_arr = $this->_adapter->getMulti($pname_str, $token_str, $logid_int, $strkey_arr); + if(!$ret_arr) { + + $this->_last_errno = RES_PAYLOAD_FAILURE; + return false; + } + + if(!isset($ret_arr['content']) || !is_array($ret_arr['content']) ) { + + $this->_last_errno = RES_PAYLOAD_FAILURE; + return false; + } + + $count = count($ret_arr['content']); + if(count($keys) != $count) { + + $this->_last_errno = RES_PAYLOAD_FAILURE; + return false; + } + + + $ret_values = array(); + for($i = 0; $i < $count; $i++) { + $result = $ret_arr['content']['result' . $i]; + if(isset($result['err_no']) && is_int($result['err_no']) && $result['err_no'] == ZCACHE_OK && + isset($result['value']) && is_string($result['value']) ) { + + $ret_values[$keys[$i]] = $this->_unconvertResult($result['value']); + } + } + $this->_last_errno = RES_SUCCESS; + return $ret_values; + } + + public function getMulti(array $keys, & $cas_tokens = null, $flags = 0) { + $pname_str = ""; + $token_str = ""; + $logid_int = 0; + if(!$this->_getEnv($pname_str, $token_str, $logid_int)) { + $this->_last_errno = RES_CLIENT_ERROR; + return false; + } + return $this->getMultiEx($pname_str, $token_str, $logid_int, $keys); + } +/* + public function getByKey($server_key, $key, $cache_cb = null, & $cas_token = null) { + throw new Exception("NotImplemented"); + } + + public function getMultiByKey($server_key, array $keys, & $cas_tokens = null, $flags = 0) { + throw new Exception("NotImplemented"); + } + + public function getDelayed(array $keys, $with_cas = null, $value_cb = null) { + throw new Exception("NotImplemented"); + } + + public function getDelayedByKey($server_key, array $keys, $with_cas = null, $value_cb = null) { + throw new Exception("NotImplemented"); + } + + public function fetch() { + throw new Exception("NotImplemented"); + } + + public function fetchAll() { + throw new Exception("NotImplemented"); + } + + public function setByKey($server_key, $key, $value, $expiration = 0) { + throw new Exception("NotImplemented"); + } + + public function setMultiByKey($server_key, array $items, $expiration = 0) { + throw new Exception("NotImplemented"); + } + + public function cas($token, $key, $value, $expiration = 0) { + throw new Exception("NotImplemented"); + } + + public function casByKey($token, $server_key, $key, $value, $expiration = 0) { + throw new Exception("NotImplemented"); + } + + public function addByKey($server_key, $key, $value, $expiration = 0) { + throw new Exception("NotImplemented"); + } + + public function append($key, $value, $expiration = 0) { + throw new Exception("NotImplemented"); + } + + public function appendByKey($server_ke, $key, $value, $expiration = 0) { + throw new Exception("NotImplemented"); + } + + public function prepend($key, $value, $expiration = 0) { + throw new Exception("NotImplemented"); + } + + public function prependByKey($server_key, $key, $value, $expiration = 0) { + throw new Exception("NotImplemented"); + } + + public function replaceByKey($serve_key, $key, $value, $expiration = 0) { + throw new Exception("NotImplemented"); + } + + public function deleteByKey($key, $time = 0) { + throw new Exception("NotImplemented"); + } + + public function getOption($option) { + throw new Exception("NotImplemented"); + } + + public function setOption($option, $value) { + throw new Exception("NotImplemented"); + } + + public function addServer($host, $port, $weight = 0) { + throw new Exception("NotImplemented"); + } + + public function addServers(array $servers) { + throw new Exception("NotImplemented"); + } + + public function getServerList() { + throw new Exception("NotImplemented"); + } + + public function getServerByKey($server_key) { + throw new Exception("NotImplemented"); + } + + public function flush($delay = 0) { + throw new Exception("NotImplemented"); + } + + public function getStats() { + throw new Exception("NotImplemented"); + } + + public function getResultMessage() { + throw new Exception("NotImplemented"); + } +*/ + + public function getResultCode() { + return $this->_last_errno; + } + + public function getExtEx($pname_str, $token_str, $logid_int, $key) { + + $key = $this->_convertKey($key); + + if(is_string($key)) { + return $this->getEx($pname_str, $token_str, $logid_int, $key); + } elseif(is_array($key)) { + return $this->getMultiEx($pname_str, $token_str, $logid_int, $key); + } else { + $this->_last_errno = RES_CLIENT_ERROR; + return false; + } + } + + public function getExt($key, $cache_cb = null, & $cas_token = null) { + $pname_str = ""; + $token_str = ""; + $logid_int = 0; + + if(!$this->_getEnv($pname_str, $token_str, $logid_int)) { + $this->_last_errno = RES_CLIENT_ERROR; + return false; + } + return $this->getExtEx($pname_str, $token_str, $logid_int, $key); + } + + public function set_shareAppid($appid) + { + if(!is_string($appid)) return false; + + $ret = $this->_adapter->set_shareAppid($appid); + if($ret === false) return false; + + $this->_appid = $appid; + return true; + } +} + +class MemcachedMeException extends Exception { + function __construct($errmsg = "", $errcode = 0) { + } + +} diff --git a/ptcms/library/bae/zcache/zcache_api.php b/ptcms/library/bae/zcache/zcache_api.php new file mode 100644 index 0000000..11db7e7 --- /dev/null +++ b/ptcms/library/bae/zcache/zcache_api.php @@ -0,0 +1,486 @@ +handlers = array (); + $this->zcfObj = $pZcfObj; + } + + public function __destruct() { + foreach($this->handlers as $k => $handler) { + $handler->close(); + unset ($this->handlers[$k]); + } + } + + private function _log($output) { + #echo "--zcached: $output"; + } + + protected function _getHandler() { + if (isset($this->_cur_handler)) + { + return $this->_cur_handler; + } + $servers = $this->zcfObj->agent_servers; + $num = count($servers); + $retry = $this->zcfObj->RETRYTIME; + + while ($retry-- > 0) { + $idx = rand() % $num; + $server = $servers[$idx]; + $key = $server['socket_address'] . ":" . $server['socket_port']; + $socket = new ZCacheSocket(); + $socket->set_vars_from_array($server); + if ($socket->connect($this->zcfObj->CONNTIMEOUT)) + { + $this->_cur_handler = $socket; + return $socket; + } + /* if (!isset ($this->handlers[$key])) { */ + /* $socket = new ZCacheSocket(); */ + /* $socket->set_vars_from_array($server); */ + + /* if ($socket->connect($this->zcfObj->CONNTIMEOUT)) { */ + /* $this->handlers[$key] = $socket; */ + /* return $socket; */ + /* } */ + /* } else */ + /* return $this->handlers[$key]; */ + } + return null; + } + + protected function _putHandler($handler, $force = 0) { + if (!$this->zcfObj->PERSISTENT || $force != 0) { + /* foreach ($this->handlers as $key => $value) { */ + /* if ($value === $handler) { */ + /* $handler->close(); */ + /* unset ($this->handlers[$key]); */ + /* break; */ + /* } */ + /* } */ + $handler->close(); + unset($this->_cur_handler); + } + } + + protected function _readResponse($handler) { + //ȡnshead + + $headbuf = $handler->read(36); + if (!$headbuf) { + $this->_log("read nshead failed\n"); + $this->_last_errno = ZCACHE_CLIENT_ERR_READ; + $this->_last_errmsg = "net read err"; + return NULL; + } + + //nshead + $head = zcache_split_nshead($headbuf); + if (!isset ($head['body_len'])) { + $this->_log("no body_len in nshead\n"); + $this->_last_errno = ZCACHE_CLIENT_ERR_NSHEAD; + $this->_last_errmsg = "nshead err"; + return NULL; + } + + //ȡݰ + $retbuffer = $handler->read($head['body_len']); + if (!$retbuffer) { + $this->_log("read nsbody " . $head['body_len'] . " failed\n"); + $this->_last_errno = ZCACHE_CLIENT_ERR_READ; + $this->_last_errmsg = "net read err"; + return NULL; + } + if($head['reserverd']) { + $decrypt_data = fcrypt_decode_hmac('key', $retbuffer); + //$this->_log("fcrypt_decode_hmac: " . strlen($retbuffer) . " " . strlen($decrypt_data) ); + return $decrypt_data; + } else { + return $retbuffer; + } + } + + public function getLastErrCode() { + return $this->_last_errno; + } + public function getLastErrMsg() { + return $this->_last_errmsg; + } + + private function _makeNshead($logid_int, $query_pack) { + $nshead = new ZCacheNsHead(); + $nshead_arr['provider'] = "zcacheadapter"; + $nshead_arr['log_id'] = $logid_int; + + $nshead_arr['reserved'] = $this->zcfObj->crypt_flag; + if($this->zcfObj->crypt_flag) { + $crypt_data = fcrypt_encode_hmac('key', $query_pack); + //$this->_log("fcrypt_encode_hmac: " . strlen($query_pack) . " " . strlen($crypt_data) ); + $nshead_arr['body_len'] = strlen($crypt_data); + $buffer = $nshead->build_nshead($nshead_arr) . $crypt_data; + } else { + $nshead_arr['body_len'] = strlen($query_pack); + $buffer = $nshead->build_nshead($nshead_arr) . $query_pack; + } + return $buffer; + } + + private function _makePack($pname_str, $token_str, $logid_int, $cmd_str, $expire_int, $item_arr) { + //fill query pack + $query_arr['cmd'] = $cmd_str; + $query_arr['pname'] = $pname_str; + $query_arr['token'] = $token_str; + $query_arr['logid'] = $logid_int; + $query_arr['appid'] = $this->_appid; + + $query_num = count($item_arr); + $query_arr['content']['query_num'] = $query_num; + + $i = 0; + foreach($item_arr as $value) { + $query_arr['content']['query' . $i]['key'] = $value['key']; + + if (isset($value['value'])) + $query_arr['content']['query' . $i]['value'] = $value['value']; + + if($expire_int >= 0) { + $query_arr['content']['query' . $i]['delay_time'] = $expire_int; + } + $i++; + } + + $query_pack = mc_pack_array2pack($query_arr, $this->zcfObj->MCPACK_VERSION); + return $this->_makeNshead($logid_int, $query_pack); + } + + public function parseResult($ret_arr) { + if(!isset($ret_arr['content']) || !is_array($ret_arr['content']) || + !isset($ret_arr['content']['result0']) || !is_array($ret_arr['content']['result0']) ) { + $this->_last_errno = ZCACHE_CLIENT_ERR_MCPACK; + return false; + } + + $val = $ret_arr['content']['result0']; + if (isset($val['err_no']) && is_int($val['err_no']) ) { + $this->_last_errno = $val['err_no']; + if($this->_last_errno == ZCACHE_OK) + return true; + return false; + } else { + $this->_last_errno = ZCACHE_CLIENT_ERR_MCPACK; + return false; + } + } + + public function parseResult2($ret_arr) { + if(!isset($ret_arr['content']) || !is_array($ret_arr['content']) || + !isset($ret_arr['content']['result0']) || !is_array($ret_arr['content']['result0']) ) { + $this->_last_errno = ZCACHE_CLIENT_ERR_MCPACK; + return false; + } + + $val = $ret_arr['content']['result0']; + if (isset($val['err_no']) && is_int($val['err_no']) && + isset($val['value']) && is_string($val['value']) ) { + $this->_last_errno = $val['err_no']; + return $val['value']; + } + else if(isset($val['err_no']) && is_int($val['err_no'])) { + $this->_last_errno = $val['err_no']; + return false; + } + else { + $this->_last_errno = ZCACHE_CLIENT_ERR_MCPACK; + return false; + } + } + + private function _talkWithServer($handler, $buffer) { + + if (!$handler->write($buffer)) { + $this->_last_errno = ZCACHE_CLIENT_ERR_WRITE; + $this->_last_errmsg = "net write err"; + $this->_putHandler($handler, 1); + return false; + } + + $retbuffer = $this->_readResponse($handler); + if (!$retbuffer) { + $this->_putHandler($handler, 1); + + //print("retry connect\n"); + $handler = $this->_getHandler(); // read error: retry connect , write , read once + if (!$handler) { + $this->_last_errno = ZCACHE_CLIENT_ERR_CONNECT; + $this->_last_errmsg = "retry net connect err"; + return false; + } + + //print("retry write\n"); + if (!$handler->write($buffer)) { + $this->_last_errno = ZCACHE_CLIENT_ERR_WRITE; + $this->_last_errmsg = "retry net write err"; + $this->_putHandler($handler, 1); + return false; + } + + //print("retry read\n"); + $retbuffer = $this->_readResponse($handler); + if (!$retbuffer) { + $this->_last_errno = ZCACHE_CLIENT_ERR_READ; + $this->_last_errmsg = "retry net read err"; + $this->_putHandler($handler, 1); + return false; + } + + } + + //print("query ok\n"); + $this->_putHandler($handler); + $ret_arr = mc_pack_pack2array($retbuffer); + + + + if (isset ($ret_arr['err_no']) && ZCACHE_OK == $ret_arr['err_no'] ) { + $this->_last_errno = ZCACHE_OK; + if(isset($ret_arr['error'])) { + $this->_last_errmsg = $ret_arr['error']; + } + return $ret_arr; + } else { + if (isset ($ret_arr['err_no'])) { + $this->_last_errno = $ret_arr['err_no']; + if(isset($ret_arr['error'])) { + $this->_last_errmsg = $ret_arr['error']; + } + } else { + $this->_last_errno = ZCACHE_CLIENT_ERR_MCPACK; + $this->_last_errmsg = "mcpack err"; + } + return false; + } + } + + private function talkWithServer($pname_str, $token_str, $logid_int, $cmd_str, $expire_int, $item_arr) { + $handler = $this->_getHandler(); + if (!$handler) { + $this->_last_errno = ZCACHE_CLIENT_ERR_CONNECT; + $this->_last_errmsg = "net connect err"; + return false; + } + + $buffer = $this->_makePack($pname_str, $token_str, $logid_int, $cmd_str, $expire_int, $item_arr); + return $this->_talkWithServer($handler, $buffer); + } + + private function talkWithServer2($logid_int, $query_arr) { + $handler = $this->_getHandler(); + if (!$handler) { + $this->_last_errno = ZCACHE_CLIENT_ERR_CONNECT; + $this->_last_errmsg = "net connect err"; + return false; + } + + $query_pack = mc_pack_array2pack($query_arr, $this->zcfObj->MCPACK_VERSION); + $buffer = $this->_makeNshead($logid_int, $query_pack); + return $this->_talkWithServer($handler, $buffer); + } + + private function _addSetReplace($pname_str, $token_str, $logid_int, $cmd_str, $key_str, $value_str, $expire_int) { + //param judge + if (!is_string($pname_str) || !is_string($token_str) || !is_int($logid_int) || + !is_string($key_str) || strlen($key_str) > ZCACHE_MAX_KEY_LEN || strlen($key_str) == 0 || + !is_string($value_str) || + !is_int($expire_int) ) { + $this->_last_errno = ZCACHE_CLIENT_ERR_PARAM; + $this->_last_errmsg = "param err"; + return false; + } + + $query_arr = array( + array( + 'key' => $key_str, + 'value' => $value_str + ) + ); + $ret_arr = $this->talkWithServer($pname_str, $token_str, $logid_int, $cmd_str, $expire_int, $query_arr); + if($ret_arr === false) return false; + return $this->parseResult($ret_arr); + } + + public function addOne($pname_str, $token_str, $logid_int, $key_str, $value_str, $expire_int = 0) { + return $this->_addSetReplace($pname_str, $token_str, $logid_int, "add", $key_str, $value_str, $expire_int); + } + + public function setOne($pname_str, $token_str, $logid_int, $key_str, $value_str, $expire_int = 0) { + return $this->_addSetReplace($pname_str, $token_str, $logid_int, "set", $key_str, $value_str, $expire_int); + } + + public function replaceOne($pname_str, $token_str, $logid_int, $key_str, $value_str, $expire_int = 0) { + return $this->_addSetReplace($pname_str, $token_str, $logid_int, "replace", $key_str, $value_str, $expire_int); + } + + public function deleteOne($pname_str, $token_str, $logid_int, $key_str, $delay_int = 0) { + //param judge + if (!is_string($pname_str) || !is_string($token_str) || !is_int($logid_int) || + !is_string($key_str) || strlen($key_str) > ZCACHE_MAX_KEY_LEN || strlen($key_str) == 0 || + !is_int($delay_int) ) { + $this->_last_errno = ZCACHE_CLIENT_ERR_PARAM; + $this->_last_errmsg = "param err"; + return false; + } + + $query_arr = array( + array( + 'key' => $key_str, + ) + ); + $ret_arr = $this->talkWithServer($pname_str, $token_str, $logid_int, "delete", $delay_int, $query_arr); + if($ret_arr === false) return false; + return $this->parseResult($ret_arr); + } + + public function increment($pname_str, $token_str, $logid_int, $key_str, $value_str, $expire_int = 0) { + //param judge + if (!is_string($pname_str) || !is_string($token_str) || !is_int($logid_int) || + !is_string($key_str) || strlen($key_str) > ZCACHE_MAX_KEY_LEN || strlen($key_str) == 0 || + !is_string($value_str) || + !is_int($expire_int) ) { + $this->_last_errno = ZCACHE_CLIENT_ERR_PARAM; + $this->_last_errmsg = "param err"; + return false; + } + $query_arr = array( + array( + 'key' => $key_str, + 'value' => $value_str + ) + ); + $ret_arr = $this->talkWithServer($pname_str, $token_str, $logid_int, "increment", $expire_int, $query_arr); + if($ret_arr === false) return false; + return $this->parseResult2($ret_arr); + } + + public function decrement($pname_str, $token_str, $logid_int, $key_str, $value_str, $expire_int = 0) { + //param judge + if (!is_string($pname_str) || !is_string($token_str) || !is_int($logid_int) || + !is_string($key_str) || strlen($key_str) > ZCACHE_MAX_KEY_LEN || strlen($key_str) == 0 || + !is_string($value_str) || + !is_int($expire_int) ) { + $this->_last_errno = ZCACHE_CLIENT_ERR_PARAM; + $this->_last_errmsg = "param err"; + return false; + } + + $query_arr = array( + array( + 'key' => $key_str, + 'value' => $value_str + ) + ); + $ret_arr = $this->talkWithServer($pname_str, $token_str, $logid_int, "decrement", $expire_int, $query_arr); + if($ret_arr === false) return false; + return $this->parseResult2($ret_arr); + } + + /* + ** return: value(string) or FALSE + */ + public function getOne($pname_str, $token_str, $logid_int, $key_str) { + //param judge + if (!is_string($pname_str) || !is_string($token_str) || !is_int($logid_int) || + !is_string($key_str) || strlen($key_str) > ZCACHE_MAX_KEY_LEN || strlen($key_str) == 0) { + $this->_last_errno = ZCACHE_CLIENT_ERR_PARAM; + $this->_last_errmsg = "param err"; + return false; + } + + $query_arr = array( + array( + 'key' => $key_str, + ) + ); + $ret_arr = $this->talkWithServer($pname_str, $token_str, $logid_int, "get", -1, $query_arr); + if($ret_arr === false) return false; + return $this->parseResult2($ret_arr); + } + + public function getMulti($pname_str, $token_str, $logid_int, $key_arr) { + //param judge + if (!is_string($pname_str) || !is_string($token_str) || !is_int($logid_int) || + !is_array($key_arr) || count($key_arr) > ZCACHE_MAX_QUERY_NUM) { + $this->_last_errno = ZCACHE_CLIENT_ERR_PARAM; + $this->_last_errmsg = "param err"; + return false; + } + + $query_arr = array(); + foreach ($key_arr as $key) { + if (!is_string($key) || strlen($key) > ZCACHE_MAX_KEY_LEN || strlen($key) == 0) { + $this->_last_errno = ZCACHE_CLIENT_ERR_PARAM; + $this->_last_errmsg = "param err"; + return false; + } + $query_arr[] = array( + 'key' => $key, + ); + } + return $this->talkWithServer($pname_str, $token_str, $logid_int, "get", -1, $query_arr); + } + + public function setMulti($pname_str, $token_str, $logid_int, $item_arr, $expire_int = 0) { + //param judge + if (!is_string($pname_str) || !is_string($token_str) || !is_int($logid_int) || + !is_array($item_arr) || count($item_arr) > ZCACHE_MAX_QUERY_NUM || + !is_int($expire_int) ) { + $this->_last_errno = ZCACHE_CLIENT_ERR_PARAM; + $this->_last_errmsg = "param err"; + return false; + } + + $query_arr = array(); + foreach($item_arr as $key => $val) { + if (!is_string($key) || strlen($key) > ZCACHE_MAX_KEY_LEN || strlen($key) == 0 || + !is_string($val) ) { + $this->_last_errno = ZCACHE_CLIENT_ERR_PARAM; + $this->_last_errmsg = "param err"; + return false; + } + + $query_arr[] = array( + 'key' => $key, + 'value' => $val + ); + } + return $this->talkWithServer($pname_str, $token_str, $logid_int, "set", $expire_int, $query_arr); + } + + public function set_shareAppid($appid) + { + if(!is_string($appid)) return false; + + $this->_appid = $appid; + return true; + } +} diff --git a/ptcms/library/bae/zcache/zcache_conf.php b/ptcms/library/bae/zcache/zcache_conf.php new file mode 100644 index 0000000..0461fc6 --- /dev/null +++ b/ptcms/library/bae/zcache/zcache_conf.php @@ -0,0 +1,20 @@ + 0, + * 'version' => 0, + * 'log_id' => 0, + * 'provider' => "" + * 'magic_num' => 0xfb709394, #ħ, ⲿҪдԶ + * 'reserved' => 0, + * 'body_len' => 0 + * ); + * + * + * + * װһԷ͵nsheadͷݰ,ݣⲿƴװ + * + * @param $vars_arr Ҫnsheadͷݰ, + * @return һԷ͵nsheadͷݰ,ݣⲿƴװ + */ + public function build_nshead($vars_arr) + { + $nshead_arr = array( + 'id' => 0, + 'version' => 0, + 'log_id' => 0, + 'provider' => str_pad("", 16, "\0", STR_PAD_BOTH), + 'magic_num' => 0xfb709394, #ħ + 'reserved' => 0, + 'body_len' => 0 + ); + foreach ($vars_arr as $key => $value) + { + if (isset($nshead_arr[$key])) + { + $nshead_arr[$key] = $value; + } + } + $nshead = ""; + $nshead = pack("L*", (($nshead_arr['version'] << 16) + ($nshead_arr['id'])), $nshead_arr['log_id']); + //ȡ15ֽڵprovider + $nshead .= str_pad(substr($nshead_arr['provider'], 0, 15), 16, "\0"); + $nshead .= pack("L*", $nshead_arr['magic_num'], $nshead_arr['reserved']); + $nshead .= pack("L", $nshead_arr['body_len']); + return $nshead; + } + + /** + * nsheadbuf뷵bufֶ + * һnsheadݰ nshead + buf + * + * һnsheadarray, + * + * array( + * 'id' => + * 'version' => + * 'log_id' => + * 'provider' => + * 'magic_num' => + * 'reserved' => + * 'body_len' => + * 'buf' => + * ); + + * + * 'buf' DZʾʵʵ + * + * @param $head յnshead ݰ + * @param $get_buf Ҫݣget_buf == false, 'buf' + * @param һnsheadarray + */ + public function split_nshead($head, $get_buf = true) + { + $ret_arr = array( + 'id' => 0, + 'version' => 0, + 'log_id' => 0, + 'provider' => "", + 'magic_num' => 0, + 'reserved' => 0, + 'body_len' => 0, + 'buf' => "" + ); + + $ret = unpack("v1id/v1version/I1log_id", substr($head, 0, 8)); + foreach ($ret as $key => $value) + { + $ret_arr[$key] = $value; + } + $ret_arr['provider'] = substr($head, 8, 16); + $ret = unpack("I1magic_num/I1reserverd/I1body_len", substr($head, 24, 12)); + foreach ($ret as $key => $value) + { + $ret_arr[$key] = $value; + } + //36nshead_tṹС + if ($get_buf) { + $ret_arr['buf'] = substr($head, 36, $ret_arr['body_len']); + } + return $ret_arr; + } + + /** + * nshead ͨsocket $msgsocket ͳȥ + * + * @param $msgsocket Ҫдsocket + * @param $vars_arr Ҫ͵nsheadͷ + * @param $buf Ҫ͵ʵ + * @return ͵ʵݳ + */ + public function nshead_write($msgsocket, $vars_arr, $buf) + { + $nshead = $this->build_nshead($vars_arr); + $nshead .= $buf; + return fwrite($msgsocket, $nshead, strlen($nshead)); + } + + /** + * socket $msgsocket ȡnsheadݰ + * + * @param $msgsocket Ҫյsocket + * @param $nshead_check_magicnum ǷMAGICNUM, Ĭϼ + */ + public function nshead_read($msgsocket, $nshead_check_magicnum = true) + { + $temp_out = ""; + $this->socket_read_buf = ""; + //ȶnsheadͷ + $temp_out = fread($msgsocket, 36); + if ($temp_out === false) + { + return false; + } + $nshead = $this->split_nshead($temp_out, false); + // msgic num + if ($nshead_check_magicnum == true + && $nshead['magic_num'] != 0xfb709394 + && $nshead['magic_num'] != -76508268) + //php汾unpackʱbugжһ¸ + { + error_log("magic num mismatch: ret ".$nshead['magic_num']." want 0xfb709394"); + return false; + } + #nshead + $left_bytes = $nshead['body_len']; + while ($left_bytes > 0) { + $recv_data = fread($msgsocket, $left_bytes); + $recv_size = strlen($recv_data); + if ($recv_size > 0 && $recv_size <= $left_bytes) { + $nshead['buf'] .= $recv_data; + $left_bytes -= $recv_size; + } else { + return false; + } + } + return $nshead; + } +} + diff --git a/ptcms/library/bae/zcache/zcache_socket.php b/ptcms/library/bae/zcache/zcache_socket.php new file mode 100644 index 0000000..2832e5a --- /dev/null +++ b/ptcms/library/bae/zcache/zcache_socket.php @@ -0,0 +1,277 @@ +socket_domain = 1; //AF_INET; + $this->socket_type = 1; //SOCK_STREAM; + $this->socket_protocol = 6; //SOL_TCP; + $this->socket_address = "127.0.0.1"; + $this->socket_port = 9120; + $this->socket_read_len = 8192; + $this->socket_read_type = 2; //PHP_BINARY_READ; + $this->socket_timeout = 200; + $this->socket_error = ""; + $this->socket_errno = 0; + } + + function __destruct() + { + if (!empty($this->socket)) + { + if(is_resource($this->socket)) + { + fclose($this->socket); + //socket_close($this->socket); + } + $this->socket = NULL; + } + $this->socket_domain = NULL; + $this->socket_type = NULL; + $this->socket_protocol = NULL; + $this->socket_address = NULL; + $this->socket_port = NULL; + $this->socket_read_len = NULL; + $this->socket_read_type = NULL; + $this->socket_timeout = NULL; + $this->socket_error = NULL; + $this->socket_errno = NULL; + } + + function __set($name, $value) + { + switch ($name) + { + case "socket_domain": + if ($value == 2 /*AF_INET*/ || $value == 10 /*AF_INET6*/ || $value == 1 /*AF_UNIX*/) + { + $this->$name = $value; + } + break; + case "socket_type": + if ($value == 1 /*SOCK_STREAM*/ || $value = 2 /*SOCK_DGRAM*/ || $value == 3 /*SOCK_RAW*/ || + $value == 5 /*SOCK_SEQPACKET*/ || $value == 4 /*SOCK_RDM*/) + { + $this->$name = $value; + } + break; + case "socket_protocol": + if ($value == 6 /*SOL_TCP*/ || $value == 17 /*SOL_UDP*/ || $value == 1 /*SOL_SOCKET*/) + { + $this->$name = $value; + } + break; + case "socket_address": + //preg_match_all("/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/", $value, $match); + //if ($match[0][0] == $value) + //{ + $this->$name = $value; + //} + break; + case "socket_port": + if ($value > 0 && $value <= 65535) + { + $this->$name = $value; + } + break; + case "socket_read_len": + if ($value > 0 && $value <= 8192) + { + $this->$name = $value; + } + break; + case "socket_read_type": + if ($value == 2 /*PHP_BINARY_READ*/ || $value == 1 /*PHP_NORMAL_READ*/) + { + $this->$name = $value; + } + break; + case "socket_timeout": + if ($value >= 0) + { + $this->$name = $value; + } + break; + } + } + + function __get($name) + { + switch ($name) + { + case "socket_domain": + case "socket_type": + case "socket_protocol": + case "socket_address": + case "socket_port": + case "socket_read_len": + case "socket_read_type": + case "socket_timeout": + case "socket_error": + case "socket_errno": + return $this->$name; + break; + default: + return NULL; + break; + } + } + + function set_vars_from_array($vars_arr) + { + foreach ($vars_arr as $key => $value) + { + $this->__set($key, $value); + } + } + + function get_vars_to_array() + { + $vars_arr = array( + 'socket_domain' => $this->socket_domain, + 'socket_type' => $this->socket_type, + 'socket_protocol' => $this->socket_protocol, + 'socket_address' => $this->socket_address, + 'socket_port' => $this->socket_port, + 'socket_read_len' => $this->socket_read_len, + 'socket_read_type' => $this->socket_read_type, + 'socket_timeout' => $this->socket_timeout, + 'socket_error' => $this->socket_error, + 'socket_errno' => $this->socket_errno, + ); + return $vars_arr; + } + + // NOTE: this function may report PHP WARNING + function tcp_connect($address, $port, $ctimeout = NULL) + { + $fp = fsockopen($address, $port, $error, $errstr, $ctimeout); + if(!$fp) { + return false; + } + + /*if(!stream_set_blocking($fp, 0)) { + fclose($fp); + return false; + }*/ + return $fp; + } + + public function connect($timeout) + { + $this->connect_timeout = $timeout; + $this->socket=$this->tcp_connect($this->socket_address, $this->socket_port, $timeout); + if(is_resource($this->socket)) + { + return true; + } + return false; + } + + function close() + { + if ($this->socket !== false || $this->socket !== NULL) + { + if(is_resource($this->socket)) + { + fclose($this->socket); + } + $this->socket = NULL; + } + } + + function write($buffer) + { + $orignbuf = $buffer; + $ret = false; + while (true) + { + $ret = @fwrite($this->socket, $buffer, strlen($buffer)); + if ($ret == false) + { + fclose($this->socket); + $this->socket = NULL; + break; + //return false; + + } + + if ($ret == strlen($buffer)) + break; + + $buffer = substr($buffer, $ret); + } + if ($ret == false)//ʧ + { + $ret = $this->connect($this->connect_timeout); + if ($ret ===false)//ʧ + { + return $ret; + } + $this->socket = $ret; + } + else//ͳɹ + { + return $ret; + } + + $ret = false; + $buffer = $orignbuf; + while (true) + { + $ret = @fwrite($this->socket, $buffer, strlen($buffer)); + if ($ret == false) + { + fclose($this->socket); + $this->socket = NULL; + return false; + + } + + if ($ret == strlen($buffer)) + break; + + $buffer = substr($buffer, $ret); + } + + return true; + } + + function read($len) + { + $buffer = ""; + while ((@ $temp = fread($this->socket, $len)) !== false) + { + if( strlen($temp) == 0 ) + { + //print("read error\n"); + return false; + } + $buffer .= $temp; + $len -= strlen($temp); + if ($len === 0) + break; + } + if ($temp === false) + { + fclose($this->socket); + $this->socket = NULL; + return false; + } + return $buffer; + } + } diff --git a/ptcms/library/bae/zcache/zcache_util.php b/ptcms/library/bae/zcache/zcache_util.php new file mode 100644 index 0000000..8e7ad65 --- /dev/null +++ b/ptcms/library/bae/zcache/zcache_util.php @@ -0,0 +1,95 @@ + 0, + 'version' => 0, + 'log_id' => zcache_build_logid(), + 'provider' => str_pad("", 16, "\0", STR_PAD_BOTH), + 'magic_num' => 0xfb709394, + 'reserved' => 0, + 'body_len' => 0 + ); + foreach ($vars_arr as $key => $value) + { + if (isset($nshead_arr[$key])) + { + $nshead_arr[$key] = $value; + } + } + $nshead = ""; + $nshead = pack("L*", (($nshead_arr['version'] << 16) + ($nshead_arr['id'])), $nshead_arr['log_id']); + $nshead .= $nshead_arr['provider']; + $nshead .= pack("L*", $nshead_arr['magic_num'], $nshead_arr['reserved']); + $nshead .= pack("L", $nshead_arr['body_len']); + return $nshead; + } + + /** + * nsheadbuf뷵bufֶ + * typedef struct _nshead_t + * { + * unsigned short id; + * unsigned short version; + * unsigned int log_id; + * char provider[16]; + * unsigned int magic_num; + * unsigned int reserved; + * unsigned int body_len; + * } nshead_t; + */ + function zcache_split_nshead($buf) + { + #echo "split nshead"; + $ret_arr = array( + 'id' => 0, + 'version' => 0, + 'log_id' => 0, + 'provider' => "", + 'magic_num' => 0, + 'reserved' => 0, + 'body_len' => 0, + 'buf' => "" + ); + $ret = unpack("v1id/v1version/I1log_id", substr($buf, 0, 8)); + foreach ($ret as $key => $value) + { + $ret_arr[$key] = $value; + } + $ret_arr['provider'] = substr($buf, 8, 16); + $ret = unpack("I1magic_num/I1reserverd/I1body_len", substr($buf, 24, 12)); + foreach ($ret as $key => $value) + { + $ret_arr[$key] = $value; + } + $ret_arr['buf'] = substr($buf, 36, $ret_arr['body_len']); + return $ret_arr; + } + + + diff --git a/ptcms/library/collect.php b/ptcms/library/collect.php index d0308d7..95823b6 100644 --- a/ptcms/library/collect.php +++ b/ptcms/library/collect.php @@ -2,6 +2,33 @@ class collect { + public static function getcontent($data) { + if(is_string($data)) $data=array('rule'=>$data,'charset'=>'auto'); + $content=http::get($data['rule']); + if ($content){ + // 处理编码 + if (!in_array($data['charset'], array('auto', 'utf-8', 'gbk'))) { + $data['charset'] = 'auto'; + } + if ($data['charset'] == 'auto') { + if (!mb_check_encoding($content,'UTF-8')) { + $content = mb_convert_encoding ($content,'UTF-8','GBK' ); + } + } elseif ($data['charset'] == 'gbk') { + $content = mb_convert_encoding ($content,'UTF-8','GBK' ); + } + //错误标识 + if (!empty($data['error']) && strpos($content,$data['error'])!==false){ + return ''; + } + if (!empty($data['replace'])) { + $content=collect::replace($content, $data['replace']); + } + return $content; + } + return ''; + } + /** * 根据正则批量获取 * @@ -12,7 +39,7 @@ class collect { */ public static function getMatchAll($pregArr, $code, $needposition = 0) { if (is_string($pregArr)) { - $pregArr = array('rule' => $pregArr); + $pregArr = array('rule' => self::parseMatchRule($pregArr)); } elseif (empty($pregArr['rule'])) { return array(); } @@ -51,7 +78,11 @@ public static function getMatchAll($pregArr, $code, $needposition = 0) { } } } - $matchvar = $match['1']; + if (isset($match['1'])){ + $matchvar = $match['1']; + }else{ + return false; + } } if (!empty($pregArr['replace'])) { foreach ($matchvar as $k => $v) { @@ -72,7 +103,7 @@ public static function getMatchAll($pregArr, $code, $needposition = 0) { */ public static function getMatch($pregArr, $code) { if (is_string($pregArr)) { - $pregArr = array('rule' => $pregArr); + $pregArr = array('rule' => self::parseMatchRule($pregArr)); } elseif (empty($pregArr['rule'])) { return ''; } @@ -111,7 +142,7 @@ public static function replace($con, array $arr) { $replace = isset($tmp['1']) ? $tmp['1'] : ''; $v['option'] = isset($v['option']) ? $v['option'] : ''; if ($v['method'] == 1) { //正则 - $con = preg_replace("{{$rule}}{$v['option']}", $replace, $con); + $con = preg_replace("{".$rule."}{$v['option']}", $replace, $con); } else { if (strpos($v['option'], 'i') === false) { $con = str_replace($rule, $replace, $con); @@ -132,17 +163,21 @@ public static function replace($con, array $arr) { * @return string */ public static function parseUrl($url, $path) { - if (strpos($url, '://') === false) { - if (substr($url, 0, 1) == '/') { - $tmp = parse_url($path); - $url = $tmp['scheme'] . '://' . $tmp['host'] . $url; - } elseif (substr($path, -1) == '/') { - $url = $path . $url; - } else { - $url = dirname($path) . '/' . $url; + if ($url){ + if (strpos($url, '://') === false) { + if (substr($url, 0, 1) == '/') { + $tmp = parse_url($path); + $url = $tmp['scheme'] . '://' . $tmp['host'] . $url; + } elseif (substr($path, -1) == '/') { + $url = $path . $url; + } else { + $url = dirname($path) . '/' . $url; + } } + return $url; + }else{ + return ''; } - return $url; } /** @@ -176,4 +211,20 @@ public static function cut($strings, $argl, $argr, $lt = false, $gt = false) { } return ($args); } + + public static function parseMatchRule($rules) { + $replace_pairs=array( + '{'=>'\{', + '}'=>'\}', + '[内容]'=>'(.*?)', + '[数字]'=>'\d*', + '[空白]'=>'\s*', + '[任意]'=>'.*?', + '[参数]'=>'[^\>\<]*?', + '[属性]'=>'[^\>\<\'"]*?', + ); + return strtr($rules,$replace_pairs); + } + + } \ No newline at end of file diff --git a/ptcms/library/dc.php b/ptcms/library/dc.php deleted file mode 100644 index 6e1d130..0000000 --- a/ptcms/library/dc.php +++ /dev/null @@ -1,103 +0,0 @@ -data($data)->where(array($model->getPk() => $id))->save()) { - return self::refresh($type, $id); - } else { - return false; - } - } - - //删除信息 - static public function delete($type, $id) { - Cache::rm($type . '.' . $id); - unset(self::$_data[$type][$id]); - return true; - } - - //更新信息 - static public function refresh($type, $id) { - $model = M($type); - self::$_data[$type][$id] = $model->find($id); - if (self::$_data[$type][$id]) { - //其他处理 如小说的链接 - if (method_exists($model, 'dataAppend')) { - self::$_data[$type][$id] = $model->dataAppend(self::$_data[$type][$id]); - } - } - // 写入缓存 - Cache::set($type . '.' . $id, self::$_data[$type][$id],C('cache_time',null,900)); - return self::$_data[$type][$id]; - } - - // 获取数据 - static public function get($type, $id, $field = '') { - if ($id == 0) return null; - if (!isset(self::$_data[$type][$id])) { - // 检索memCache,不存在则读取数据库 - self::$_data[$type][$id] = Cache::get($type . '.' . $id); - if (self::$_data[$type][$id] === null) { - $model = M($type); - self::$_data[$type][$id] = $model->find($id); - if (self::$_data[$type][$id]) { - //其他处理 如小说的链接 - if (method_exists($model, 'dataAppend')) { - self::$_data[$type][$id] = $model->dataAppend(self::$_data[$type][$id]); - } - } - Cache::set($type . '.' . $id, self::$_data[$type][$id],C('cache_time',null,900)); - } - } - if ($field !== '') { - if(strpos($field,',')){ - //多字段获取 如"novelid,novelname" - return array_intersect_key(self::$_data[$type][$id],array_flip(explode(',',$field))); - }else{ - //单字段 - if (isset(self::$_data[$type][$id][$field])) { - return self::$_data[$type][$id][$field]; - } else { - return null; - } - } - } - return self::$_data[$type][$id]; - } -} \ No newline at end of file diff --git a/ptcms/library/html.php b/ptcms/library/html.php index 38d2f80..4fdace4 100644 --- a/ptcms/library/html.php +++ b/ptcms/library/html.php @@ -6,7 +6,7 @@ class html { public static function create($url, $content) { $file = self::parseUrl($url); if ($file) { - return F($file, str_replace(C('gen_html_replace'), '', $content)); + return F($file, str_replace(PT_Base::getInstance()->config->get('gen_html_replace'), '', $content)); } else { return false; } @@ -29,16 +29,21 @@ public static function read($url) { // 地址解析 public static function parseUrl($url) { - if (!C('html') || strpos($url, '?') || strpos($url, '#') || strpos($url, '&') || strpos($url, '=')) return false; + if (!PT_Base::getInstance()->config->get('html') || strpos($url, '?') || strpos($url, '#') || strpos($url, '&') || strpos($url, '=')) return false; $path = parse_url($url, PHP_URL_PATH); if (strpos(basename($path), '.') === false) { - $path = trim($path, '/') . '/' . C('HTML_DEFAULTFILE', null, 'index.html'); + $path = trim($path, '/') . '/' . PT_Base::getInstance()->config->get('HTML_DEFAULTFILE', 'index.html'); } else { $path = trim($path, '/'); } - if (PT_DIR && substr($path, 0, strlen(PT_DIR)) == PT_DIR) { - $path = trim(substr($path, strlen(PT_DIR)), '/'); + $dir = trim(PT_DIR, '/'); + if ($dir && substr($path, 0, strlen($dir)) == $dir) { + $path = trim(substr($path, strlen($dir)), '/'); } return PT_ROOT . '/' . $path; } + + public static function trigger($url) { + http::trigger($url); + } } \ No newline at end of file diff --git a/ptcms/library/http.php b/ptcms/library/http.php index fa07715..299e336 100644 --- a/ptcms/library/http.php +++ b/ptcms/library/http.php @@ -2,22 +2,26 @@ class http { - public static function curl($url, $params = array(), $method = 'GET', $header = array()) { + public static function curl($url, $params = array(), $method = 'GET', $header = array(), $option = array()) { $opts = array( - CURLOPT_TIMEOUT => C('timeout', null, 10), - CURLOPT_CONNECTTIMEOUT => C('timeout', null, 10), + CURLOPT_TIMEOUT => PT_Base::getInstance()->config->get('timeout', 10), + CURLOPT_CONNECTTIMEOUT => PT_Base::getInstance()->config->get('timeout', 10), CURLOPT_RETURNTRANSFER => 1, CURLOPT_FOLLOWLOCATION => 1, - CURLOPT_HEADER => false, - CURLOPT_USERAGENT => C('user_agent', null, 'PTSingleNovel'), - CURLOPT_REFERER => $url, - CURLOPT_NOSIGNAL => 1, - CURLOPT_ENCODING => 'gzip, deflate', - CURLOPT_HTTPHEADER => $header, + CURLOPT_HEADER => false, + CURLOPT_USERAGENT => PT_Base::getInstance()->config->get('user_agent', 'PTCMS Spider'), + CURLOPT_REFERER => $url, + CURLOPT_NOSIGNAL => 1, + CURLOPT_ENCODING => 'gzip, deflate', + CURLOPT_HTTPHEADER => $header, CURLOPT_SSL_VERIFYPEER => false, CURLOPT_SSL_VERIFYHOST => false, ); - + //补充配置 + foreach ($option as $k => $v) { + $opts[$k] = $v; + } + //安全模式 if (ini_get("safe_mode") || ini_get('open_basedir')) { unset($opts[CURLOPT_FOLLOWLOCATION]); } @@ -28,8 +32,8 @@ public static function curl($url, $params = array(), $method = 'GET', $header = break; case 'POST': //判断是否传输文件 - $opts[CURLOPT_URL] = $url; - $opts[CURLOPT_POST] = 1; + $opts[CURLOPT_URL] = $url; + $opts[CURLOPT_POST] = 1; $opts[CURLOPT_POSTFIELDS] = $params; break; default: @@ -42,52 +46,58 @@ public static function curl($url, $params = array(), $method = 'GET', $header = $data = curl_exec($ch); //todo safe_mode模式下需要处理的location $error = curl_error($ch); + $errno = curl_errno($ch); curl_close($ch); - if ($error) return false; + if ($error && $errno !== 28) { + PT_Log::record('Curl获取远程内容错误!原因:' . $error . ' 地址:' . $url); + return false; + } return $data; } - public static function filegc($url, $params = array(), $method = 'GET') { - $header = array("Referer: $url", "User-Agent: " . C('user_agent', null, 'PTSingleNovel')); + public static function filegc($url, $params = array(), $method = 'GET', $header = array(), $option = array()) { + $header = array_merge(array("Referer: $url", "User-Agent: " . PT_Base::getInstance()->config->get('user_agent', 'PTCMS Spider', "Accept-Encoding: gzip,deflate")), $header); $context = array( 'http' => array( - 'method' => $method, - 'header' => implode("\r\n", $header), - 'timeout' => C('timeout', null, 10), + 'method' => $method, + 'header' => implode("\r\n", $header), + 'timeout' => PT_Base::getInstance()->config->get('timeout', 10), ) ); + if ($option) $context['http'] = array_merge($context['http'], $option); if ($method == 'POST') { if (is_array($params)) $params = http_build_query($params); - $content_length = strlen($params); - $header[] = "Content-type: application/x-www-form-urlencoded"; - $header[] = "Content-length: $content_length"; - $context['http']['header'] = implode("\r\n", $header); + $content_length = strlen($params); + $header[] = "Content-type: application/x-www-form-urlencoded"; + $header[] = "Content-length: $content_length"; + $context['http']['header'] = implode("\r\n", $header); $context['http']['content'] = $params; } $stream_context = stream_context_create($context); - $data = file_get_contents($url, false, $stream_context); - return $data; + $data = @file_get_contents($url, false, $stream_context); + return self::gzdecode($data); } - public static function fsock($url, $params, $method = 'GET') { + public static function fsock($url, $params = array(), $method = 'GET') { $urlinfo = parse_url($url); - $port = isset($urlinfo["port"]) ? $urlinfo["port"] : 80; - $path = $urlinfo['path'] . (!empty($urlinfo['query']) ? '?' . $urlinfo['query'] : '') . (!empty($urlinfo['fragment']) ? '#' . $urlinfo['fragment'] : ''); + $port = isset($urlinfo["port"]) ? $urlinfo["port"] : 80; + $path = $urlinfo['path'] . (!empty($urlinfo['query']) ? '?' . $urlinfo['query'] : '') . (!empty($urlinfo['fragment']) ? '#' . $urlinfo['fragment'] : ''); $in = "{$method} {$path} HTTP/1.1\r\n"; $in .= "Host: {$urlinfo['host']}\r\n"; $in .= "Content-Type: application/octet-stream\r\n"; $in .= "Connection: Close\r\n"; $in .= "Hostname: {$urlinfo['host']}\r\n"; - $in .= "User-Agent: " . C('user_agent', null, 'PTSingleNovel') . "\r\n"; + $in .= "User-Agent: " . PT_Base::getInstance()->config->get('user_agent', 'PTCMS Spider') . "\r\n"; $in .= "Referer: {$url}\r\n"; + $in .= "Accept-Encoding: gzip,deflate\r\n"; if ($method == 'POST') { $params = is_array($params) ? http_build_query($params) : $params; $in .= "Content-Length: " . strlen($params) . "\r\n\r\n"; } $address = gethostbyname($urlinfo['host']); - $fp = fsockopen($address, $port, $err, $errstr, C('timeout', null, 10)); + $fp = fsockopen($address, $port, $err, $errstr, PT_Base::getInstance()->config->get('timeout', 10)); if (!$fp) { exit ("cannot conncect to {$address} at port {$port} '{$errstr}'"); } @@ -103,7 +113,7 @@ public static function fsock($url, $params, $method = 'GET') { } public static function get($url, $data = array()) { - $func = C('httpmethod', null, 'curl'); + $func = PT_Base::getInstance()->config->get('httpmethod', 'curl'); if (is_array($data)) { $data = http_build_query($data); } @@ -115,17 +125,27 @@ public static function get($url, $data = array()) { } $data = array(); } - $t = microtime(true); - $res = self::$func($url, $data, 'GET'); - $GLOBALS['_api'][] = $func . ' GET ' . number_format(microtime(true) - $t, 5) . ' ' . $url; + if (APP_DEBUG || isset($_GET['debug'])) { + $t = microtime(true); + $res = self::$func($url, $data, 'GET'); + $GLOBALS['_api'][] = $func . ' GET ' . number_format(microtime(true) - $t, 5) . ' ' . strlen($res) . ' ' . $url; + } else { + $res = self::$func($url, $data, 'GET'); + } + $GLOBALS['_apinum']++; return $res; } - public static function post($url, $data = array()) { - $func = C('httpmethod', null, 'curl'); - $t = microtime(true); - $res = self::$func($url, $data, 'POST'); - $GLOBALS['_api'][] = $func . ' POST ' . number_format(microtime(true) - $t, 5) . ' ' . $url . json_encode($data, 256); + public static function post($url, $data = array(), $header = array()) { + $func = PT_Base::getInstance()->config->get('httpmethod', 'curl'); + if (APP_DEBUG || isset($_GET['debug'])) { + $t = microtime(true); + $res = self::$func($url, $data, 'POST'); + $GLOBALS['_api'][] = $func . ' POST ' . number_format(microtime(true) - $t, 5) . ' ' . strlen($res) . ' ' . $url . json_encode($data, 256); + } else { + $res = self::$func($url, $data, 'POST', $header); + } + $GLOBALS['_apinum']++; return $res; } @@ -142,4 +162,43 @@ public static function getMethod() { } return $method; } + + //触发G + public static function trigger($url) { + if (stripos($url, 'http') === 0) { + $func = PT_Base::getInstance()->config->get('httpmethod', 'curl'); + if ($func == 'curl') { + http::curl($url, array(), 'GET', array(), array( + CURLOPT_TIMEOUT_MS => 20, + CURLOPT_CONNECTTIMEOUT_MS => 20, + )); + } else { + http::filegc($url, array(), 'GET', array(), array( + 'timeout' => 0, + )); + } + } + return; + } + + // Gzip解压函数 + public static function gzdecode($data) { + if (strlen($data) < 18) return $data; + $res = unpack('vfile_type', substr($data, 0, 2)); + if ($res['file_type'] <> 35615) return $data; + if (function_exists('gzdecode') && $unpacked = gzdecode($data)) return $unpacked; + $flags = ord(substr($data, 3, 1)); + $headerlen = 10; + if ($flags & 4) { + $extralen = unpack('v', substr($data, 10, 2)); + $extralen = $extralen[1]; + $headerlen += $extralen + 2; + } + if ($flags & 8) $headerlen = strpos($data, chr(0), $headerlen) + 1; + if ($flags & 16) $headerlen = strpos($data, chr(0), $headerlen) + 1; + if ($flags & 2) $headerlen += 2; + $unpacked = gzinflate(substr($data, $headerlen)); + if ($unpacked === false) return $data; + return $unpacked; + } } \ No newline at end of file diff --git a/ptcms/library/image.php b/ptcms/library/image.php index 2203281..c06d81a 100644 --- a/ptcms/library/image.php +++ b/ptcms/library/image.php @@ -286,9 +286,10 @@ public function water($source, $posotion = image::IMAGE_WATER_SOUTHEAST, $alpha */ public function text($text, $font, $size = 20, $color = '#ff0000', $locate = Image::IMAGE_WATER_SOUTHEAST, $margin = '', $offset = 0, $angle = 0) { //资源检测 - if (!is_file($font)) return false; + //if (!is_file($font)) return false; if ($margin === '') $margin = ceil($size / 2); //获取文字信息 + $info = imagettfbbox($size, $angle, $font, $text); $minx = min($info[0], $info[2], $info[4], $info[6]); $maxx = max($info[0], $info[2], $info[4], $info[6]); diff --git a/ptcms/library/oauth.php b/ptcms/library/oauth.php index 8e2d9d7..9e95a77 100644 --- a/ptcms/library/oauth.php +++ b/ptcms/library/oauth.php @@ -108,8 +108,8 @@ public function __construct(array $config, $token = null) { */ public static function getInstance($type, $token = null) { if (empty(self::$_instance[$type])) { - $config['appid'] = C("oauth_{$type}_appid"); - $config['appsecret'] = C("oauth_{$type}_appsecret"); + $config['appid'] = PT_Base::getInstance()->config->get("oauth_{$type}_appid"); + $config['appsecret'] = PT_Base::getInstance()->config->get("oauth_{$type}_appsecret"); $classname = 'Driver_Oauth_' . $type; self::$_instance[$type] = new $classname($config, $token); } diff --git a/ptcms/library/pinyin.php b/ptcms/library/pinyin.php index b77d908..038aeab 100644 --- a/ptcms/library/pinyin.php +++ b/ptcms/library/pinyin.php @@ -7,9 +7,9 @@ */ class pinyin { - static $data = null; + protected static $data = null; - public static function getdata() { + protected static function getdata() { if (self::$data === null) { $fp = fopen(dirname(__FILE__) . '/data/pinyin.dat', 'r') or exit('读取字典失败'); while (!feof($fp)) { @@ -29,7 +29,7 @@ public static function getdata() { * @param string $default 匹配不到默认显示字符 * @return string */ - public static function change($str, $isfirst = false, $default = '-') { + public static function change($str, $isfirst = false, $default = '0') { $str = iconv('UTF-8', 'GBK//ignore', $str); $data = self::getdata(); $restr = ''; diff --git a/ptcms/library/steal.php b/ptcms/library/steal.php deleted file mode 100644 index 55ed5c0..0000000 --- a/ptcms/library/steal.php +++ /dev/null @@ -1,182 +0,0 @@ - $v) { - if ($v == '') { - for ($i = 2; $i < $count; $i++) { - if (!empty($match[$i][$k])) { - $match['1'][$k] = $match[$i][$k]; - break; - } - } - } - } - } - $matchvar = $match['1']; - } - if (!empty($pregArr['replace'])) { - foreach ($matchvar as $k => $v) { - $matchvar[$k] = self::replace($v, $pregArr['replace']); - } - } - return $matchvar; - } - return false; - } - - /** - * 根据正则获取指定数据 单个 - * - * @param string $pregArr 正则 - * @param string $code 源内容 - * @return bool|string - */ - public static function getMatch($pregArr, $code) - { - try { - if (empty($pregArr['rule'])) { - return ''; - } - $pregstr = '{' . $pregArr['rule'] . '}'; - if (!empty($pregArr['option'])) { - $pregstr .= $pregArr['option']; - } - preg_match($pregstr, $code, $match); - if (isset($match['1'])) { - if (empty($pregArr['replace'])) { - return $match['1']; - } else { - return self::replace($match[1], $pregArr['replace']); - } - } - return false; - } catch (Exception $e) { - halt($e->getMessage()); - return ''; - } - } - - /** - * 内容替换 支持正则批量替换 - * - * @param string $con 代替换的内容 - * @param array $arr 替换规则数组 单个元素如下 - * array( - * 'rule'=>'规则1',//♂后面表示要替换的 内容 - * 'option'=>'参数', - * 'method'=>1,//1 正则 0普通 - * ), - * @return mixed - */ - public static function replace($con, array $arr) - { - foreach ($arr as $v) { - if (!empty($v['rule'])) { - $tmp = explode('♂', $v['rule']); - $rule = $tmp['0']; - $replace = isset($tmp['1']) ? $tmp['1'] : ''; - $v['option'] = isset($v['option']) ? $v['option'] : ''; - if ($v['method'] == 1) { //正则 - $con = preg_replace("{{$rule}}{$v['option']}", $replace, $con); - } else { - if (strpos($v['option'], 'i') === false) { - $con = str_replace($rule, $replace, $con); - } else { - $con = str_ireplace($rule, $replace, $con); - } - } - } - } - return $con; - } - - /** - * 处理链接,根据当前页面地址得到完整的链接地址 - * - * @param string $url 当前链接 - * @param string $path 当前页面地址 - * @return string - */ - public static function parseUrl($url, $path) - { - if (strpos($url, '://') === false) { - if (substr($url, 0, 1) == '/') { - $tmp = parse_url($path); - $url = $tmp['scheme'] . '://' . $tmp['host'] . $url; - } elseif (substr($path, -1) == '/') { - $url = $path . $url; - } else { - $url = dirname($path) . '/' . $url; - } - } - return $url; - } - - //内容切割 - public static function cut($argl, $argr, $lt, $gt, $strings) - { - if (!$strings) return (""); - if (strpos($argl, ".+?")) { - $argl = strtr($argl, array("/" => "\/")); - if (@preg_match("/" . $argl . "/", $strings, $match)) $argl = $match[0]; - } - if (strpos($argr, ".+?")) { - $argr = strtr($argr, array("/" => "\/")); - if (@preg_match("/" . $argr . "/", $strings, $match)) $argr = $match[0]; - } - $args = @explode($argl, $strings); - $args = @explode($argr, $args[1]); - $args = $args[0]; - if ($args) { - if ($lt) $args = $argl . $args; - if ($gt) $args .= $argr; - } else { - $args = ""; - } - return ($args); - } -} \ No newline at end of file diff --git a/ptcms/library/upload.php b/ptcms/library/upload.php index 5dc68d3..b45638d 100644 --- a/ptcms/library/upload.php +++ b/ptcms/library/upload.php @@ -16,7 +16,7 @@ class upload { //自定义文件存放完整路径 public $filePath; //自定义允许文件后缀 - public $allowType = "jpg|png|gif|txt|bmp|doc|xls|jpeg|zip|rar"; + public $allowType = "jpg|png|gif|txt|bmp|ico|doc|xls|jpeg|zip|rar"; //自定义允许文件mime public $allowMime = array(); //自定义文件大小 Kb @@ -131,7 +131,7 @@ public function uploadone() { // 上传操作 if ($this->save(F($this->fileinfo['tmp_name']))) { $info['ext'] = $this->get_type(); - $info['fileurl'] = Storage::geturl($this->filePath); + $info['fileurl'] = PT_Base::getInstance()->storage->geturl($this->filePath); $info['filepath'] = $this->filePath; $info['filename'] = $this->fileinfo['name']; $info['hash'] = md5_file($this->fileinfo['tmp_name']); @@ -151,7 +151,7 @@ protected function save($content) { $content = $img->save(); } } - return storage::write($this->filePath, $content); + return PT_Base::getInstance()->storage->write($this->filePath, $content); } protected function geterrorinfo($num) { @@ -184,7 +184,7 @@ public function uploadurl($url, $content = '') { $this->getpath(); if ($this->save($content)) { $info['ext'] = $this->get_type(); - $info['fileurl'] = Storage::geturl($this->filePath); + $info['fileurl'] = PT_Base::getInstance()->storage->geturl($this->filePath); $info['filepath'] = $this->filePath; $info['filename'] = $this->fileinfo['name']; $info['hash'] = md5($content); diff --git a/ptcms/library/verify.php b/ptcms/library/verify.php index c21b425..2bd33b8 100644 --- a/ptcms/library/verify.php +++ b/ptcms/library/verify.php @@ -70,7 +70,7 @@ static public function randString($len = 6, $type = '', $addChars = '') { */ static function buildImageVerify($length = 4, $mode = 1, $type = 'png', $width = 48, $height = 22, $verifyName = 'verify') { $randval = self::randString($length, $mode); - $_SESSION[$verifyName] = strtolower($randval); + PT_Base::getInstance()->session->set($verifyName, strtolower($randval)); $width = ($length * 10 + 10) > $width ? $length * 10 + 10 : $width; if ($type != 'gif' && function_exists('imagecreatetruecolor')) { $im = imagecreatetruecolor($width, $height); diff --git a/ptcms/library/yarclient.php b/ptcms/library/yarclient.php index 68ffd8b..b6c4a72 100644 --- a/ptcms/library/yarclient.php +++ b/ptcms/library/yarclient.php @@ -1,10 +1,6 @@ $name = self::$_class[$name]; } - F($runtimefile, $str); + if ($name == 'pt') { + return $this->pt = self::getInstance(); + } + if (is_file(PT_PATH . "/core/{$name}.php")) { + $classname = 'PT_' . $name; + if (!class_exists($classname, true)) pt::import(PT_PATH . "/core/{$name}.php"); + return $this->$name = self::$_class[$name] = new $classname(); + } + return null; + } + + public function __get($name) { + return $this->$name=$this->getInstanceof($name); + } + + /** + * @param $name + * @return object + */ + public function model($name) { + $class=null; + if (isset(self::$_model[$name])) return self::$_model[$name]; + $classname=$name.'Model'; + if (class_exists($classname)){ + return self::$_model[$name]=new $classname($name); + } + return $class; + } + + /** + * @param $name + * @return Driver_Db_Dao + */ + public function db($name='') { + return $this->getInstanceof('db')->getInstance($name); + } + + /** + * @param $name + * @return PT_model + */ + public function block($name) { + return $this->getInstanceof('block')->getInstance($name); } - include $runtimefile; } -pt::start(); -class pt { +class pt extends PT_Base { + + protected static $base; /** * 框架开始调用 */ - public static function start() { + public function start() { + self::$base = PT_Base::getInstance(); //初始化加载 - self::init(); - plugin::call('app_init_start'); + $this->init(); + $this->plugin->call('app_init_start'); //加载站点配置文件 - C(self::import(APP_PATH . '/common/' . pt::getSiteCode() . '.config.php')); + $this->config->register(self::import(APP_PATH . '/common/' . $this->request->getSiteCode() . '.config.php')); // 路由解析 - plugin::call('dispatcher_start'); + $this->plugin->call('dispatcher_start'); self::dispatcher(); - plugin::call('dispatcher_end'); + $this->plugin->call('dispatcher_end'); if (MODULE_NAME != 'common') { // 加载模块文件 - C(self::import(APP_PATH . '/' . MODULE_NAME . '/config.php')); + $this->config->register(self::import(APP_PATH . '/' . MODULE_NAME . '/config.php')); // 加载函数 self::import(APP_PATH . '/' . MODULE_NAME . '/function.php'); } // 控制器调用 - self::app(); + $this->app(); } /** * 注册autoload等操作 */ - protected static function init() { + protected function init() { // 设定错误和异常处理 register_shutdown_function(array(__CLASS__, 'shutdown')); //set_error_handler(array(__CLASS__, 'error')); @@ -177,32 +203,34 @@ function stripslashes_deep($value) { return $value; } - $_POST = stripslashes_deep($_POST); - $_GET = stripslashes_deep($_GET); + $_POST = stripslashes_deep($_POST); + $_GET = stripslashes_deep($_GET); $_COOKIE = stripslashes_deep($_COOKIE); } } // 注册插件 - Plugin::register(C('plugin', null, array())); + $this->plugin->register($this->config->get('plugin', array())); } - protected static function app() { + protected function app() { //加载控制器启动的插件 - plugin::call('controller_start'); + $this->plugin->call('controller_start'); + //正常模式 + $controllerFile = APP_PATH . '/' . MODULE_NAME . '/controller/' . CONTROLLER_NAME . '.php'; + $classname = CONTROLLER_NAME . 'Controller'; + $actionname = ACTION_NAME . 'Action'; if (MODULE_NAME == 'plugin') { //插件控制器 $controllerFile = APP_PATH . '/common/plugin/' . CONTROLLER_NAME . '/manage.php'; - $classname = 'manageController'; - $actionname = ACTION_NAME . 'Action'; - } else { - //正常模式 - $controllerFile = APP_PATH . '/' . MODULE_NAME . '/controller/' . CONTROLLER_NAME . '.php'; - $classname = CONTROLLER_NAME . 'Controller'; - $actionname = ACTION_NAME . 'Action'; + $classname = 'manageController'; + $actionname = ACTION_NAME . 'Action'; + } elseif (!in_array(MODULE_NAME, explode(',', $this->config->get('allow_module', '')))) { + $this->response->error(MODULE_NAME . '模块不允许访问'); } if (is_file($controllerFile)) { include $controllerFile; if (class_exists($classname, false)) { + /* @var $app PT_Controller */ $app = new $classname(); //加载init方法 if (method_exists($app, 'init')) { @@ -211,17 +239,33 @@ protected static function app() { // 加载action if (method_exists($app, $actionname)) { $app->$actionname(); + if ($this->response->isAutoRender()) { + switch ($_GET['f']) { + case 'json': + $data = $app->view->get(); + $this->response->jsonEncode($data); + break; + case 'jsonp': + $data = $app->view->get(); + $this->response->jsonpEncode($data); + break; + case 'xml': + $data = $app->view->get(); + $this->response->xmlEncode($data); + break; + default: + $app->display(); + } + } } else { - $app->_empty("当前控制器下" . get_class($app) . "找不到指定的方法 {$_GET['a']}Action"); + $this->response->error("当前控制器下" . get_class($app) . "找不到指定的方法 {$_GET['a']}Action"); } - plugin::call('controller_end'); + $this->plugin->call('controller_end'); } else { - $app = new Controller(); - $app->_empty('控制器' . CONTROLLER_NAME . '对应的文件中未找到类' . $classname); + $this->response->error('控制器' . CONTROLLER_NAME . '对应的文件中未找到类' . $classname); } } else { - $app = new Controller(); - $app->_empty(MODULE_NAME . '模块下控制器' . CONTROLLER_NAME . 'Controller对应的文件不存在'); + $this->response->error(MODULE_NAME . '模块下控制器' . CONTROLLER_NAME . 'Controller对应的文件不存在'); } } @@ -239,7 +283,7 @@ public static function import($filename) { protected static function dispatcher() { - dispatcher::run(); + self::$base->dispatcher->run(); // 获取分组 模块和操作名称 define('MODULE_NAME', strtolower($_GET['m'])); define('CONTROLLER_NAME', strtolower($_GET['c'])); @@ -257,9 +301,9 @@ protected static function dispatcher() { // 自动加载 public static function autoload($class) { $classfile = strtolower(str_replace('_', '/', $class)); - if (in_array($classfile, array('controller', 'view', 'dispatcher', 'cache', 'model', 'plugin', 'storage', 'block', 'log'))) { - pt::import(PT_PATH . '/core/' . $classfile . '.php'); - } elseif (substr($classfile, 0, 6) == 'driver') { + //pt_开头的类指定目录到core + if (strpos($classfile, 'pt/') === 0) $classfile = str_replace('pt/', 'core/', $classfile); + if (is_file(PT_PATH . '/' . $classfile . '.php')) { pt::import(PT_PATH . '/' . $classfile . '.php'); } elseif (substr($classfile, -10) == 'controller') { if (!pt::import(APP_PATH . '/' . MODULE_NAME . '/controller/' . substr($classfile, 0, -10) . '.php')) { @@ -268,26 +312,44 @@ public static function autoload($class) { } elseif (substr($classfile, -5) == 'model') { //适配ptcms_a_b这样的表 $classfile = substr(str_replace('/', '_', $classfile), 0, -5); - if (MODULE_NAME == 'plugin') { - $file = APP_PATH . '/common/plugin/' . MODULE_NAME . '/model/' . $classfile . '.php'; - } else { - $file = APP_PATH . '/' . MODULE_NAME . '/model/' . $classfile . '.php'; - } - if (!pt::import($file)) { - pt::import(APP_PATH . '/common/model/' . $classfile . '.php'); + if (isset($GLOBALS['_automap']['model'][$classfile])) { + //存在这个model + if (isset($GLOBALS['_automap']['model'][$classfile][MODULE_NAME])) { + $file = $GLOBALS['_automap']['model'][$classfile][MODULE_NAME]; + } elseif (isset($GLOBALS['_automap']['model'][$classfile]['common'])) { + $file = $GLOBALS['_automap']['model'][$classfile]['common']; + } else { + $file = current(array_slice($GLOBALS['_automap']['model'][$classfile], 0, 1)); + } + pt::import($file); } } elseif (substr($classfile, -5) == 'block') { - if (!pt::import(APP_PATH . '/' . MODULE_NAME . '/block/' . substr($classfile, 0, -5) . '.php')) { - pt::import(APP_PATH . '/common/block/' . substr($classfile, 0, -5) . '.php'); + $classfile = substr($classfile, 0, -5); + if (isset($GLOBALS['_automap']['block'][$classfile])) { + //存在这个block + if (isset($GLOBALS['_automap']['block'][$classfile][MODULE_NAME])) { + $file = $GLOBALS['_automap']['block'][$classfile][MODULE_NAME]; + } elseif (isset($GLOBALS['_automap']['block'][$classfile]['common'])) { + $file = $GLOBALS['_automap']['block'][$classfile]['common']; + } else { + $file = current(array_slice($GLOBALS['_automap']['block'][$classfile], 0, 1)); + } + pt::import($file); } } elseif (substr($classfile, -6) == 'plugin') { $classname = substr($classfile, 0, -6); pt::import(APP_PATH . '/common/plugin/' . $classname . '/' . $classname . '.php'); } else { - (pt::import(PT_PATH . '/library/' . $classfile . '.php')) or - (pt::import(APP_PATH . '/common/library/' . $classfile . '.php')) or - (pt::import(APP_PATH . '/' . MODULE_NAME . '/library/' . $classfile . '.php')) or - (pt::import(APP_PATH . '/common/plugin/' . MODULE_NAME . '/library/' . $classfile . '.php')); + if (!pt::import(PT_PATH . '/library/' . $classfile . '.php') && isset($GLOBALS['_automap']['library'][$classfile])) { + if (isset($GLOBALS['_automap']['library'][$classfile][MODULE_NAME])) { + $file = $GLOBALS['_automap']['library'][$classfile][MODULE_NAME]; + } elseif (isset($GLOBALS['_automap']['library'][$classfile]['common'])) { + $file = $GLOBALS['_automap']['library'][$classfile]['common']; + } else { + $file = current(array_slice($GLOBALS['_automap']['library'][$classfile], 0, 1)); + } + pt::import($file); + } } } @@ -300,7 +362,7 @@ public static function shutdown() { } } //如果开启日志 则记录日志 - if (C('log', null, false)) log::build(); + if (self::$base->config->get('log', false)) self::$base->log->build(); // 如果自定义了close函数 则进行调用 if (function_exists('pt_close')) { pt_close(); @@ -329,180 +391,8 @@ public static function error($errno, $errstr, $errfile, $errline) { break; } } - - public static function err404($msg = '找不到指定的页面') { - $file = PT_ROOT . C('404file', null, '/404.html'); - log::write($msg); - if (is_file($file)) { - $content = F($file); - $content = str_replace(array('{$sitename}', '{$siteurl}', '{$msg}'), array(C('sitename'), C('siteurl'), $msg), $content); - exit($content); - } else { - exit($msg . ' 页面出现错误,如需自定义此错误,请创建文件:' . $file); - } - } - - /** - * 获取host - **/ - public static function getSiteCode() { - // 替换域名中的-为_ - $domain = str_replace('-', '_', $_SERVER['HTTP_HOST']); - // 去掉端口 - if (strpos($domain, ':') !== false) $domain = substr($domain, 0, strpos($domain, ':')); - // 去掉开始的www. - if (stripos($domain, 'www.') === 0) $domain = substr($domain, 4); - return $domain; - } - - /** - * 输出视图内容 - * - * @access public - * @param string $content 输出内容 - * @param string $mimeType MIME类型 - * @return void - */ - public static function show($content = '', $mimeType = 'text/html') { - if (C('gzip_encode', null, false)) { - $zlib = ini_get('zlib.output_compression'); - if (empty($zlib)) ob_start('ob_gzhandler'); - } - if (!headers_sent()) { - //设置系统的输出字符为utf-8 - header("Content-Type: $mimeType; charset=utf-8"); - //支持页面回跳 - header("Cache-control: private"); - //长连接 - header("Connection:Keep-Alive"); - //版权标识 - header("X-Powered-By: PTcms Studio (www.ptcms.com)"); - } - echo $content; - } -} - - -/** - * 获取和设置配置参数 支持批量定义 - * - * @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)) { - $name = strtolower($name); - if (!strpos($name, '.')) { - if (is_null($value)) - return $_config[$name] = isset($_config[$name]) ? $_config[$name] : $default; - $_config[$name] = $value; - return true; - } - // 二维数组设置和获取支持 - $name = explode('.', $name); - if (is_null($value)) { - $value = $_config; - foreach ($name as $n) { - if (isset($value[$n])) { - $value = $value[$n]; - } else { - $value = $default; - break; - } - } - return $value; - } - $_config[$name[0]][$name[1]] = $value; - return true; - } - // 批量设置 - if (is_array($name)) { - $_config = array_merge($_config, array_change_key_case($name)); - return true; - } - // 避免非法参数 - return null; } -/** - * Cookie 设置、获取、删除 - * - * @param string $name cookies名称 - * @param string $value cookie值 - * @param string $option cookie参数 - * @return mixed - */ -function cookie($name, $value = '', $option = null) { - static $_config = null; - if (!$_config) { - // 默认设置 - $_config = array( - // cookie 名称前缀 - 'prefix' => C('cookie_prefix', null, 'PTCMS_'), - // cookie 保存时间 - 'expire' => intval(C('cookie_expire', null, 2592000)), - // cookie 保存路径 - 'path' => C('cookie_path', null, '/'), - // cookie 有效域名 - 'domain' => C('cookie_domain'), - ); - } - // 参数设置(会覆盖黙认设置) - 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)); - } else { - $config = $_config; - } - // 清除指定前缀的所有cookie - if (is_null($name)) { - if (empty($_COOKIE)) - return true; - // 要删除的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']); - unset($_COOKIE[$key]); - } - } - } - return true; - } - $name = $config['prefix'] . $name; - if ('' === $value) { - if (isset($_COOKIE[$name])) { - return $_COOKIE[$name]; - } else { - return null; - } - } else { - if (is_null($value)) { - setcookie($name, '', time() - 3600, $config['path'], $config['domain']); - // 删除指定cookie - unset($_COOKIE[$name]); - } else { - // 设置cookie - $expire = !empty($config['expire']) ? time() + $config['expire'] : 0; - setcookie($name, $value, $expire, $config['path'], $config['domain']); - $_COOKIE[$name] = $value; - } - } - return null; -} /** * 文件函数 @@ -533,11 +423,7 @@ function F($file, $content = false, $mod = '') { mkdir(dirname($file), 0755, true); } if (is_array($content)) { - if (APP_DEBUG) { - $content = str_replace('\\\\', '\\', 'response->setHeader(); $e['message'] = $msg; - $e['file'] = $file; - $e['line'] = $line; + $e['file'] = $file; + $e['line'] = $line; include PT_PATH . '/error.tpl'; exit; } else { - PT::err404($msg); - } -} - -/** - * 获取输入参数 支持过滤和默认值 - * - * @param string $name 变量的名称 支持指定类型 - * @param mixed $default 不存在的时候默认值 - * @param mixed $filter 参数过滤方法 - * @param array $input - * @return mixed - */ -function I($name, $filter = 'int', $default = null, $input = array()) { - // 可以从指定的数组中取值 - if ($input == array()) { - if (strpos($name, '.')) { - // 指定参数来源 - list($method, $name) = explode('.', $name, 2); - } else { - // 默认为post - $method = 'post'; - } - switch (strtolower($method)) { - case 'get' : - $input = $_GET; - break; - case 'post' : - $input = $_POST; - break; - case 'put' : - parse_str(file_get_contents('php://input'), $input); - 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; - default: - return NULL; - } + PT_Base::getInstance()->response->error($msg . ' [' . $file . '(' . $line . ')]'); } - $value = isset($input[$name]) ? $input[$name] : null; - if (is_array($filter)) return in_array($value, $filter) ? $value : $default; - if (!is_string($filter)) return $value; - switch ($filter) { - case 'int': - return is_null($value) ? (is_null($default) ? 0 : $default) : intval($value); - case 'str': - return is_null($value) ? (is_null($default) ? '' : $default) : strval($value); - case 'arr': - return is_array($value) ? $value : (is_array($default) ? $default : array()); - default: - return empty($value) ? $default : (regex($value, $filter) ? $value : $default); - } -} - - -/** - * regex - * 使用正则验证数据 - * - * @param string $value 要验证的数据 - * @param string $rule 验证规则 - * @return mixed - */ -function regex($value, $rule) { - $validate = array( - //必填 - 'require' => '/.+/', - //邮箱 - 'email' => '/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/', - //链接 - 'url' => '/^http:\/\/[a-zA-Z0-9]+\.[a-zA-Z0-9]+[\/=\?%\-&_~`@\[\]\':+!]*([^<>\"\"])*$/', - //货币 - 'currency' => '/^\d+(\.\d+)?$/', - //数字 - 'number' => '/^\d+$/', - //邮编 - 'zip' => '/^[0-9]\d{5}$/', - //电话 - 'tel' => '/^1[\d]{10}$/', - //整型 - 'integer' => '/^[-\+]?\d+$/', - //带小数点 - 'double' => '/^[-\+]?\d+(\.\d+)?$/', - //英文字母 - 'english' => '/^[a-zA-Z]+$/', - //中文汉字 - 'chinese' => '/^[\x{4e00}-\x{9fa5}]+$/u', - //拼音 - 'pinyin' => '/^[a-zA-Z0-9\-\_]+$/', - //用户名 - 'username' => '/^(?!_)(?!.*?_$)[a-zA-Z0-9_\x{4e00}-\x{9fa5}]{3,15}$/u', - //英文字符 - 'en' => '/^[a-zA-Z0-9_\s\-\.]+$/', - //中文字符 - 'cn' => '/^[\w\s\-\x{4e00}-\x{9fa5}]+$/u', - //安全字符串 - 'safestring' => '/^[^\$\?]+$/' - ); - // 检查是否有内置的正则表达式 - if (isset($validate[strtolower($rule)])) $rule = $validate[strtolower($rule)]; - return preg_match($rule, strval($value)) === 1; } /** @@ -716,10 +456,11 @@ function regex($value, $rule) { * @return string */ function U($method = '', $args = array(), $ignores = array()) { - static $rules = null, $_method = array(), $_map = array(); + static $rules = null, $_method = array(), $_map = array(),$power=false; if ($rules === null) { - $rules = C('URL_RULES'); - $_map = C('map_module'); + $rules = PT_Base::getInstance()->config->get('URL_RULES'); + $_map = PT_Base::getInstance()->config->get('map_module'); + $power = PT_Base::getInstance()->config->get('rewritepower',false); } //忽视args中的部分参数 if (!empty($ignores)) { @@ -740,24 +481,39 @@ function U($method = '', $args = array(), $ignores = array()) { $_method[$method] = strtolower($_method[$method]); } $method = $_method[$method]; - if (!empty($rules[$method])) { - $keys = array(); - $rule = $rules[$method]; + if (!empty($rules[$method]) && empty($args['_force']) && count($args) >= substr_count($rules[$method], '{')) { + $keys = array(); + $rule = $rules[$method]; + $oargs = $args; foreach ($args as $key => $arg) { $keys[] = '{' . $key . '}'; + if (strpos($rule, '{' . $key . '}')) unset($oargs[$key]); } $url = clearUrl(str_replace($keys, $args, $rule)); if (strpos($url, ']')) { $url = strtr($url, array('[' => '', ']' => '')); } - return PT_DIR . $url; + if ($oargs) { + return PT_DIR . $url . (strpos($url, '?') ? '&' : '?') . http_build_query($oargs); + } else { + return PT_DIR . $url; + } } else { list($param['m'], $param['c'], $param['a']) = explode('.', $method); + if (isset($_map[$param['m']])) $param['m'] = $_map[$param['m']]; //调整顺序为m c a krsort($param); $param = array_merge($param, $args); - if (isset($_map[$param['m']])) $param['m'] = $_map[$param['m']]; - return __APP__ . '?' . http_build_query($param); + if ($power){ + $url = PT_DIR . '/' . $param['m'] . '/' . $param['c'] . '/' . $param['a'] . '.' . $_GET['f']; + unset($param['m'], $param['c'], $param['a']); + if ($param) { + $url .= '?' . http_build_query($param); + } + }else{ + $url=__APP__.'?'.http_build_query($param); + } + return $url; } } @@ -784,7 +540,7 @@ function clearUrl($url) { function strip_whitespace($content) { $stripStr = ''; //分析php源码 - $tokens = token_get_all($content); + $tokens = token_get_all($content); $last_space = false; for ($i = 0, $j = count($tokens); $i < $j; $i++) { if (is_string($tokens[$i])) { @@ -826,110 +582,101 @@ function strip_whitespace($content) { return $stripStr; } - /** - * block调用函数 + * 获取自动加载的目录文件 * - * @param string $class block名称 - * @param array $param block参数 - * @return mixed + * @return array */ -function B($class, $param) { - static $_class; - $classname = ucfirst(strtolower($class)); - $class = $classname . 'Block'; - if (empty($_class[$class])) { - if (class_exists($class)) { - $_class[$class] = new $class(); - } else { - halt('不存在的block:' . $classname, __FILE__, __LINE__ - 4); +function get_auto_map() { + $map = array(); + $dirs = array_unique(explode(',', trim((PT_Base::getInstance()->config->get('allow_module', null, '') . ',common'), ','))); + foreach ($dirs as $dir) { + $path = APP_PATH . '/' . $dir; + if (!is_dir($path)) continue; + $handle = opendir($path); + while (($dirname = readdir($handle)) !== false) { + if (in_array($dirname, array('model', 'block', 'library'))) { + $handle1 = opendir($path . '/' . $dirname); + while (($filename = readdir($handle1)) !== false) { + if (substr($filename, -4) == '.php') { + $map[$dirname][substr($filename, 0, -4)][$dir] = $path . '/' . $dirname . '/' . $filename; + } + } + closedir($handle1); + } } + closedir($handle); } - return $_class[$class]->run($param); + return $map; } -function runinfo() { - if (C('is_gen_html')) return ''; - $tpl = C('runinfo', null, 'Power by PTCMS, Processed in {time}(s), Memory usage: {mem}MB.'); - $from[] = '{time}'; - $to[] = number_format(microtime(true) - $GLOBALS['_startTime'], 3); - $from[] = '{mem}'; - $to[] = number_format((memory_get_usage() - $GLOBALS['_startUseMems']) / 1024 / 1024, 3); - if (strpos($tpl, '{net}')) { - $from[] = '{net}'; - $to[] = count($GLOBALS['_api']); - } - if (strpos($tpl, '{file}')) { - $from[] = '{file}'; - $to[] = count(get_included_files()); - } - if (strpos($tpl, '{sql}')) { - $from[] = '{sql}'; - $to[] = count($GLOBALS['_sql']); - } - if (strpos($tpl, '{cacheread}')) { - $from[] = '{cacheread}'; - $to[] = $GLOBALS['_cacheRead']; - } - if (strpos($tpl, '{cachewrite}')) { - $from[] = '{cachewrite}'; - $to[] = $GLOBALS['_cacheWrite']; - } - $runtimeinfo = str_replace($from, $to, $tpl); - return $runtimeinfo; +// 判断是否有html缓存 +if ($_SERVER['REQUEST_METHOD'] === 'GET' && strpos($_SERVER['REQUEST_URI'], '.php') === false && is_file(PT_ROOT . $_SERVER['REQUEST_URI'])) { + readfile(PT_ROOT . $_SERVER['REQUEST_URI']); + exit; } - -function is_mobile() { - // 如果有HTTP_X_WAP_PROFILE则一定是移动设备 - if (isset ($_SERVER['HTTP_X_WAP_PROFILE'])) { - return true; - } - // 如果via信息含有wap则一定是移动设备,部分服务商会屏蔽该信息 - if (isset ($_SERVER['HTTP_VIA'])) { - // 找不到为flase,否则为true - return stristr($_SERVER['HTTP_VIA'], "wap") ? true : false; - } - // 脑残法,判断手机发送的客户端标志,兼容性有待提高 - if (isset ($_SERVER['HTTP_USER_AGENT'])) { - $clientkeywords = array('nokia', 'sony', 'ericsson', 'mot', 'samsung', 'htc', 'sgh', 'lg', 'sharp', 'sie-', 'philips', 'panasonic', 'alcatel', 'lenovo', 'iphone', 'ipod', 'blackberry', 'meizu', 'android', 'netfront', 'symbian', 'ucweb', 'windowsce', 'palm', 'operamini', 'operamobi', 'openwave', 'nexusone', 'cldc', 'midp', 'wap', 'mobile', 'UCBrowser'); - // 从HTTP_USER_AGENT中查找手机浏览器的关键字 - if (preg_match("/(" . implode('|', $clientkeywords) . ")/i", strtolower($_SERVER['HTTP_USER_AGENT']))) { - return true; - } - } - // 协议法,因为有可能不准确,放到最后判断 - if (isset ($_SERVER['HTTP_ACCEPT'])) { - // 如果只支持wml并且不支持html那一定是移动设备 - // 如果支持wml和html但是wml在html之前则是移动设备 - if ((strpos($_SERVER['HTTP_ACCEPT'], 'vnd.wap.wml') !== false) && (strpos($_SERVER['HTTP_ACCEPT'], 'text/html') === false || (strpos($_SERVER['HTTP_ACCEPT'], 'vnd.wap.wml') < strpos($_SERVER['HTTP_ACCEPT'], 'text/html')))) { - return true; - } - } - return false; +// 自动识别SAE环境 +if (function_exists('saeAutoLoader') or function_exists('sae_auto_load')) { + // sae + defined('APP_MODE') or define('APP_MODE', 'sae'); +} else { + // 普通模式 + defined('APP_MODE') or define('APP_MODE', 'common'); } -// 判断是否是蜘蛛 -function is_spider($ua = '') { - empty($ua) && $ua = $_SERVER['HTTP_USER_AGENT']; - $ua = strtolower($ua); - $spiders = array('bot', 'crawl', 'spider', 'slurp', 'sohu-search', 'lycos', 'robozilla'); - foreach ($spiders as $spider) { - if (false !== strpos($ua, $spider)) return true; +//后台运行程序 +if (!empty($_GET['backRun'])) { + //生成html + if (function_exists('fastcgi_finish_request')) { + fastcgi_finish_request(); + } else { + ignore_user_abort(true); } - return false; } -//获取客户端ip -function get_ip($default = '0.0.0.0') { - $keys = array('HTTP_X_FORWARDED_FOR', 'HTTP_CLIENT_IP', 'REMOTE_ADDR'); +// 加载公共配置文件 +PT_Base::getInstance()->config->register(pt::import(APP_PATH . '/common/config.php')); +pt::import(APP_PATH . '/common/function.php'); - foreach ($keys as $key) { - if (empty($_SERVER[$key])) continue; - $ips = explode(',', $_SERVER[$key], 1); - $ip = $ips[0]; - $l = ip2long($ip); - if ((false !== $l) && ($ip === long2ip($l))) return $ip; +// 编译模式 +if (APP_DEBUG) { + // 开启错误输出 + ini_set('display_errors', 'on'); + // 设置错误输出级别 + error_reporting(E_ALL); + $GLOBALS['_automap'] = get_auto_map(); +} else { + // 开启错误输出 + ini_set('display_errors', 'off'); + // 设置错误输出级别 + error_reporting(0); + // 合并核心文件 + $runtimefile = CACHE_PATH . '/pt_runtime.php'; + if (!is_file($runtimefile)) { + $files = array( + PT_PATH . '/core/cache.php', + PT_PATH . '/driver/cache/' . strtolower(PT_Base::getInstance()->config->get('cache_driver', 'file')) . '.php', + PT_PATH . '/core/controller.php', + PT_PATH . '/core/dispatcher.php', + PT_PATH . '/core/log.php', + PT_PATH . '/core/plugin.php', + PT_PATH . '/core/view.php', + PT_PATH . '/core/block.php', + ); + if (PT_Base::getInstance()->config->get('mysql_driver')) { + $files[] = PT_PATH . '/core/model.php'; + $files[] = PT_PATH . '/driver/model/' . strtolower(PT_Base::getInstance()->config->get('mysql_driver', null, 'pdo')) . '.php'; + } + $str = "start(); diff --git a/ptcms_ad.sql b/ptcms_ad.sql deleted file mode 100644 index 8ac8afa..0000000 --- a/ptcms_ad.sql +++ /dev/null @@ -1,35 +0,0 @@ -# Host: localhost (Version: 5.5.38) -# Date: 2014-10-10 08:45:08 -# Generator: MySQL-Front 5.3 (Build 4.120) - -/*!40101 SET NAMES utf8 */; - -# -# Structure for table "ptcms_ad" -# - -DROP TABLE IF EXISTS `ptcms_ad`; -CREATE TABLE `ptcms_ad` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `name` varchar(50) NOT NULL DEFAULT '', - `key` varchar(50) NOT NULL DEFAULT '', - `width` smallint(6) DEFAULT '0', - `height` smallint(6) DEFAULT '0', - `code` text, - `intro` varchar(255) NOT NULL DEFAULT '', - `create_user_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '创建人', - `update_user_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '修改人', - `create_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间', - `update_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '修改时间', - `type` tinyint(3) DEFAULT '1' COMMENT '广告类型 1 html 2 js', - `status` tinyint(3) DEFAULT '1', - PRIMARY KEY (`id`) -) ENGINE=MyISAM DEFAULT CHARSET=utf8; - -# -# Data for table "ptcms_ad" -# - -/*!40000 ALTER TABLE `ptcms_ad` DISABLE KEYS */; -INSERT INTO `ptcms_ad` VALUES (1,'ddd333','sss22',12,32,'123123','123',1,1,1412899971,1412900277,1,1),(2,'网站统计','tongji',0,0,'','',1,0,1412900092,0,1,1); -/*!40000 ALTER TABLE `ptcms_ad` ENABLE KEYS */; diff --git a/ptcms_friendlink.sql b/ptcms_friendlink.sql deleted file mode 100644 index 557a85d..0000000 --- a/ptcms_friendlink.sql +++ /dev/null @@ -1,35 +0,0 @@ -# Host: localhost (Version: 5.5.38) -# Date: 2014-10-10 08:45:16 -# Generator: MySQL-Front 5.3 (Build 4.120) - -/*!40101 SET NAMES utf8 */; - -# -# Structure for table "ptcms_friendlink" -# - -DROP TABLE IF EXISTS `ptcms_friendlink`; -CREATE TABLE `ptcms_friendlink` ( - `id` smallint(5) unsigned NOT NULL AUTO_INCREMENT, - `name` varchar(20) NOT NULL DEFAULT '', - `url` varchar(100) NOT NULL DEFAULT '', - `logo` varchar(100) NOT NULL, - `description` varchar(255) NOT NULL COMMENT '描述信息', - `ordernum` smallint(5) unsigned NOT NULL DEFAULT '50', - `color` varchar(20) NOT NULL COMMENT '颜色代码', - `isbold` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '是否加粗', - `create_user_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '创建人', - `update_user_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '修改人', - `create_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间', - `update_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '修改时间', - `status` tinyint(1) NOT NULL DEFAULT '1' COMMENT '状态 1可用 0禁用', - PRIMARY KEY (`id`) -) ENGINE=MyISAM AUTO_INCREMENT=8 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC; - -# -# Data for table "ptcms_friendlink" -# - -/*!40000 ALTER TABLE `ptcms_friendlink` DISABLE KEYS */; -INSERT INTO `ptcms_friendlink` VALUES (6,'PTCMS工作室','http://www.ptcms.com','','PTCMS官方网站',10,'red',1,1,1,1412859114,1412862704,1); -/*!40000 ALTER TABLE `ptcms_friendlink` ENABLE KEYS */; diff --git a/public/image/114.png b/public/image/114.png deleted file mode 100644 index 3d08227..0000000 Binary files a/public/image/114.png and /dev/null differ diff --git a/public/image/144.png b/public/image/144.png deleted file mode 100644 index b6bd36d..0000000 Binary files a/public/image/144.png and /dev/null differ diff --git a/public/image/57.png b/public/image/57.png deleted file mode 100644 index 07835df..0000000 Binary files a/public/image/57.png and /dev/null differ diff --git a/public/image/72.png b/public/image/72.png deleted file mode 100644 index 6107000..0000000 Binary files a/public/image/72.png and /dev/null differ diff --git a/public/image/error.gif b/public/image/error.gif deleted file mode 100644 index e68479b..0000000 Binary files a/public/image/error.gif and /dev/null differ diff --git a/public/image/favicon.ico b/public/image/favicon.ico deleted file mode 100644 index 50d9690..0000000 Binary files a/public/image/favicon.ico and /dev/null differ diff --git a/public/image/loading.gif b/public/image/loading.gif deleted file mode 100644 index ca8d7a2..0000000 Binary files a/public/image/loading.gif and /dev/null differ diff --git a/public/image/loading2.gif b/public/image/loading2.gif deleted file mode 100644 index 5bb90fd..0000000 Binary files a/public/image/loading2.gif and /dev/null differ diff --git a/public/image/logo.png b/public/image/logo.png deleted file mode 100644 index 72a5e5d..0000000 Binary files a/public/image/logo.png and /dev/null differ diff --git a/public/image/success.gif b/public/image/success.gif deleted file mode 100644 index eb5905b..0000000 Binary files a/public/image/success.gif and /dev/null differ diff --git a/public/plugin/datepicker/WdatePicker.js b/public/plugin/datepicker/WdatePicker.js deleted file mode 100644 index 1d95ab3..0000000 --- a/public/plugin/datepicker/WdatePicker.js +++ /dev/null @@ -1,360 +0,0 @@ -/* - * My97 DatePicker 4.8 Beta2 - * License: http://www.my97.net/dp/license.asp - */ -var $dp, WdatePicker; -(function () { - var $ = { - $langList: [{name: "en", charset: "UTF-8"}, {name: "zh-cn", charset: "UTF-8"}, {name: "zh-tw", charset: "UTF-8"}], - $skinList: [ - {name: "default", charset: "gb2312"}, - {name: "whyGreen", charset: "gb2312"}, - {name: "blue", charset: "gb2312"}, - {name: "green", charset: "gb2312"}, - {name: "ext", charset: "gb2312"}, - {name: "blueFresh", charset: "gb2312"} - ], - $wdate: true, - $crossFrame: true, - $preLoad: false, - doubleCalendar: false, - enableKeyboard: true, - enableInputMask: true, - autoUpdateOnChanged: null, - weekMethod: "ISO8601", - position: {}, - lang: "auto", - skin: "ext", - dateFmt: "yyyy-MM-dd HH:mm:ss", -//dateFmt:"yyyy-MM-dd", - realDateFmt: "yyyy-MM-dd", - realTimeFmt: "HH:mm:ss", - realFullFmt: "%Date %Time", - minDate: "1900-01-01 00:00:00", - maxDate: "2099-12-31 23:59:59", - startDate: "", - alwaysUseStartDate: false, - yearOffset: 1911, - firstDayOfWeek: 0, - isShowWeek: false, - highLineWeekDay: true, - isShowClear: true, - isShowToday: true, - isShowOK: true, - isShowOthers: true, - readOnly: false, - errDealMode: 0, - autoPickDate: null, - qsEnabled: true, - autoShowQS: false, - specialDates: null, specialDays: null, disabledDates: null, disabledDays: null, opposite: false, onpicking: null, onpicked: null, onclearing: null, oncleared: null, ychanging: null, ychanged: null, Mchanging: null, Mchanged: null, dchanging: null, dchanged: null, Hchanging: null, Hchanged: null, mchanging: null, mchanged: null, schanging: null, schanged: null, eCont: null, vel: null, elProp: "", errMsg: "", quickSel: [], has: {}, getRealLang: function () { - var _ = $.$langList; - for (var A = 0; A < _.length; A++)if (_[A].name == this.lang)return _[A]; - return _[0] - } - }; - WdatePicker = T; - var X = window, S = {innerHTML: ""}, M = "document", H = "documentElement", C = "getElementsByTagName", U, A, R, G, a, W = navigator.appName; - if (W == "Microsoft Internet Explorer")R = true; else if (W == "Opera")a = true; else G = true; - A = J(); - if ($.$wdate)K(A + "skin/WdatePicker.css"); - U = X; - if ($.$crossFrame) { - try { - while (U.parent && U.parent[M] != U[M] && U.parent[M][C]("frameset").length == 0)U = U.parent - } catch (N) { - } - } - if (!U.$dp)U.$dp = {ff: G, ie: R, opera: a, status: 0, defMinDate: $.minDate, defMaxDate: $.maxDate}; - B(); - if ($.$preLoad && $dp.status == 0)E(X, "onload", function () { - T(null, true) - }); - if (!X[M].docMD) { - E(X[M], "onmousedown", D); - X[M].docMD = true - } - if (!U[M].docMD) { - E(U[M], "onmousedown", D); - U[M].docMD = true - } - E(X, "onunload", function () { - if ($dp.dd)O($dp.dd, "none") - }); - function B() { - U.$dp = U.$dp || {}; - obj = { - $: function ($) { - return (typeof $ == "string") ? X[M].getElementById($) : $ - }, $D: function ($, _) { - return this.$DV(this.$($).value, _) - }, $DV: function (_, $) { - if (_ != "") { - this.dt = $dp.cal.splitDate(_, $dp.cal.dateFmt); - if ($)for (var B in $)if (this.dt[B] === undefined)this.errMsg = "invalid property:" + B; else { - this.dt[B] += $[B]; - if (B == "M") { - var C = $["M"] > 0 ? 1 : 0, A = new Date(this.dt["y"], this.dt["M"], 0).getDate(); - this.dt["d"] = Math.min(A + C, this.dt["d"]) - } - } - if (this.dt.refresh())return this.dt - } - return "" - }, show: function () { - var A = U[M].getElementsByTagName("div"), $ = 100000; - for (var B = 0; B < A.length; B++) { - var _ = parseInt(A[B].style.zIndex); - if (_ > $)$ = _ - } - this.dd.style.zIndex = $ + 2; - O(this.dd, "block") - }, hide: function () { - O(this.dd, "none") - }, attachEvent: E - }; - for (var $ in obj)U.$dp[$] = obj[$]; - $dp = U.$dp - } - - function E(A, $, _) { - if (R)A.attachEvent($, _); else if (_) { - var B = $.replace(/on/, ""); - _._ieEmuEventHandler = function ($) { - return _($) - }; - A.addEventListener(B, _._ieEmuEventHandler, false) - } - } - - function J() { - var _, A, $ = X[M][C]("script"); - for (var B = 0; B < $.length; B++) { - _ = $[B].getAttribute("src") || ""; - _ = _.substr(0, _.toLowerCase().indexOf("wdatepicker.js")); - A = _.lastIndexOf("/"); - if (A > 0)_ = _.substring(0, A + 1); - if (_)break - } - return _ - } - - function K(A, $, B) { - var D = X[M][C]("HEAD").item(0), _ = X[M].createElement("link"); - if (D) { - _.href = A; - _.rel = "stylesheet"; - _.type = "text/css"; - if ($)_.title = $; - if (B)_.charset = B; - D.appendChild(_) - } - } - - function F($) { - $ = $ || U; - var A = 0, _ = 0; - while ($ != U) { - var D = $.parent[M][C]("iframe"); - for (var F = 0; F < D.length; F++) { - try { - if (D[F].contentWindow == $) { - var E = V(D[F]); - A += E.left; - _ += E.top; - break - } - } catch (B) { - } - } - $ = $.parent - } - return {"leftM": A, "topM": _} - } - - function V(G, F) { - if (G.getBoundingClientRect)return G.getBoundingClientRect(); else { - var A = {ROOT_TAG: /^body|html$/i, OP_SCROLL: /^(?:inline|table-row)$/i}, E = false, I = null, _ = G.offsetTop, H = G.offsetLeft, D = G.offsetWidth, B = G.offsetHeight, C = G.offsetParent; - if (C != G)while (C) { - H += C.offsetLeft; - _ += C.offsetTop; - if (Q(C, "position").toLowerCase() == "fixed")E = true; else if (C.tagName.toLowerCase() == "body")I = C.ownerDocument.defaultView; - C = C.offsetParent - } - C = G.parentNode; - while (C.tagName && !A.ROOT_TAG.test(C.tagName)) { - if (C.scrollTop || C.scrollLeft)if (!A.OP_SCROLL.test(O(C)))if (!a || C.style.overflow !== "visible") { - H -= C.scrollLeft; - _ -= C.scrollTop - } - C = C.parentNode - } - if (!E) { - var $ = Z(I); - H -= $.left; - _ -= $.top - } - D += H; - B += _; - return {"left": H, "top": _, "right": D, "bottom": B} - } - } - - function L($) { - $ = $ || U; - var B = $[M], A = ($.innerWidth) ? $.innerWidth : (B[H] && B[H].clientWidth) ? B[H].clientWidth : B.body.offsetWidth, _ = ($.innerHeight) ? $.innerHeight : (B[H] && B[H].clientHeight) ? B[H].clientHeight : B.body.offsetHeight; - return {"width": A, "height": _} - } - - function Z($) { - $ = $ || U; - var B = $[M], A = B[H], _ = B.body; - B = (A && A.scrollTop != null && (A.scrollTop > _.scrollTop || A.scrollLeft > _.scrollLeft)) ? A : _; - return {"top": B.scrollTop, "left": B.scrollLeft} - } - - function D($) { - var _ = $ ? ($.srcElement || $.target) : null; - try { - if ($dp.cal && !$dp.eCont && $dp.dd && _ != $dp.el && $dp.dd.style.display == "block")$dp.cal.close() - } catch ($) { - } - } - - function Y() { - $dp.status = 2 - } - - var P, _; - - function T(N, F) { - $dp.win = X; - B(); - N = N || {}; - for (var K in $)if (K.substring(0, 1) != "$" && N[K] === undefined)N[K] = $[K]; - if (F) { - if (!L()) { - _ = _ || setInterval(function () { - if (U[M].readyState == "complete")clearInterval(_); - T(null, true) - }, 50); - return - } - if ($dp.status == 0) { - $dp.status = 1; - N.el = S; - I(N, true) - } else return - } else if (N.eCont) { - N.eCont = $dp.$(N.eCont); - N.el = S; - N.autoPickDate = true; - N.qsEnabled = false; - I(N) - } else { - if ($.$preLoad && $dp.status != 2)return; - var J = H(); - if (J) { - N.srcEl = J.srcElement || J.target; - J.cancelBubble = true - } - N.el = N.el = $dp.$(N.el || N.srcEl); - if (!N.el || N.el["My97Mark"] === true || N.el.disabled || ($dp.dd && O($dp.dd) != "none" && $dp.dd.style.left != "-970px")) { - try { - N.el["My97Mark"] = false - } catch (C) { - } - return - } - I(N); - if (J && N.el.nodeType == 1 && N.el["My97Mark"] === undefined) { - var A, D; - if (J.type == "focus") { - A = "onclick"; - D = "onfocus" - } else { - A = "onfocus"; - D = "onclick" - } - E(N.el, A, N.el[D]) - } - } - function L() { - if (R && U != X && U[M].readyState != "complete")return false; - return true - } - - function H() { - if (G) { - func = H.caller; - while (func != null) { - var $ = func.arguments[0]; - if ($ && ($ + "").indexOf("Event") >= 0)return $; - func = func.caller - } - return null - } - return event - } - } - - function Q(_, $) { - return _.currentStyle ? _.currentStyle[$] : document.defaultView.getComputedStyle(_, false)[$] - } - - function O(_, $) { - if (_)if ($ != null)_.style.display = $; else return Q(_, "display") - } - - function I(G, _) { - var D = G.el ? G.el.nodeName : "INPUT"; - if (_ || G.eCont || new RegExp(/input|textarea|div|span|p|a/ig).test(D))G.elProp = D == "INPUT" ? "value" : "innerHTML"; else return; - if (G.lang == "auto")G.lang = R ? navigator.browserLanguage.toLowerCase() : navigator.language.toLowerCase(); - if (!G.eCont)for (var C in G)$dp[C] = G[C]; - if (!$dp.dd || G.eCont || ($dp.dd && (G.getRealLang().name != $dp.dd.lang || G.skin != $dp.dd.skin))) { - if (G.eCont)E(G.eCont, G); else { - $dp.dd = U[M].createElement("DIV"); - $dp.dd.style.cssText = "position:absolute"; - U[M].body.appendChild($dp.dd); - E($dp.dd, G); - if (_)$dp.dd.style.left = $dp.dd.style.top = "-970px"; else { - $dp.show(); - B($dp) - } - } - } else if ($dp.cal) { - $dp.show(); - $dp.cal.init(); - if (!$dp.eCont)B($dp) - } - function E(F, E) { - F.innerHTML = ""; - var D = F.lastChild.contentWindow[M], _ = $.$langList, C = $.$skinList, H = E.getRealLang(); - F.lang = H.name; - F.skin = E.skin; - var G = [""]; - for (var I = 0; I < C.length; I++)if (C[I].name == E.skin)G.push(""); - G.push(""); - G.push(""); - G.push(""); - E.setPos = B; - E.onload = Y; - D.write(""); - D.cfg = E; - D.write(G.join("")) - } - - function B(I) { - var G = I.position.left, B = I.position.top, C = I.el; - if (C == S)return; - if (C != I.srcEl && (O(C) == "none" || C.type == "hidden"))C = I.srcEl; - var H = V(C), $ = F(X), D = L(U), A = Z(U), E = $dp.dd.offsetHeight, _ = $dp.dd.offsetWidth; - if (isNaN(B))B = 0; - if (($.topM + H.bottom + E > D.height) && ($.topM + H.top - E > 0))B += A.top + $.topM + H.top - E - 2; else B += A.top + $.topM + Math.min(H.bottom, D.height - E) + 2; - if (isNaN(G))G = 0; - G += A.left + Math.min($.leftM + H.left, D.width - _ - 5) - (R ? 2 : 0); - I.dd.style.top = B + "px"; - I.dd.style.left = G + "px" - } - } -})() \ No newline at end of file diff --git a/public/plugin/datepicker/calendar.js b/public/plugin/datepicker/calendar.js deleted file mode 100644 index 69b42e4..0000000 --- a/public/plugin/datepicker/calendar.js +++ /dev/null @@ -1,22 +0,0 @@ -/* - * My97 DatePicker 4.8 Beta2 - * License: http://www.my97.net/dp/license.asp - */ -eval(function (p, a, c, k, e, d) { - e = function (c) { - return (c < a ? "" : e(parseInt(c / a))) + ((c = c % a) > 35 ? String.fromCharCode(c + 29) : c.toString(36)) - }; - if (!''.replace(/^/, String)) { - while (c--)d[e(c)] = k[c] || e(c); - k = [function (e) { - return d[e] - }]; - e = function () { - return '\\w+' - }; - c = 1; - } - ; - while (c--)if (k[c])p = p.replace(new RegExp('\\b' + e(c) + '\\b', 'g'), k[c]); - return p; -}('k($4j.3X){$f={};19(o p 4i $2l)k(5Z $2l[p]=="6d"){$f[p]={};19(o 4B 4i $2l[p])$f[p][4B]=$2l[p][4B]}q $f[p]=$2l[p]}q $f=$2l;19(p 4i $4j)$f[p]=$4j[p];o $c;k($62){6o.2N.7c("6W",l($){k(!$)h.2h();t $});6o.2N.7b("6N",l(){o $=h.6K;3l($.5f!=1)$=$.7e;t $});7a.2N.2T=l($,b){o A=$.1l(/6C/,"");b.6B=l($){6M.1Q=$;t b()};h.7g(A,b.6B,1n)}}l 5n(){$c=h;h.2F=[];$d=1P.75("x");$d.1d="4r";$d.1I="<1t Y=3Y><1t Y=3Y><1x 2t=0 2r=0 2u=0><1j><18 7V=2><4k 1E=7W>&4A;<1t Y=7u 4g=2><1t 1f=\\":\\" Y=6i 6p><1t Y=6q 4g=2><1t 1f=\\":\\" Y=6i 6p><1t Y=6q 4g=2><18><1N 1E=7s><1j><18><1N 1E=7r><1t Y=4h 1E=7y 3a=1N><1t Y=4h 1E=7C 3a=1N><1t Y=4h 1E=73 3a=1N>";6S($d,l(){3x()});A();h.5o();$f.22=[1P,$d.1K,$d.1v,$d.2B,$d.2Q,$d.2S,$d.2W,$d.2d,$d.1X];19(o B=0;B<$f.22.u;B++){o b=$f.22[B];b.34=B==$f.22.u-1?$f.22[1]:$f.22[B+1];$f.2T(b,"56",4P)}$();4K("y,M,H,m,s");$d.5s.1r=l(){58(1)};$d.5t.1r=l(){58(-1)};$d.4s.1r=l(){k($d.1F.1c.2g!="6t"){$c.4I();3v($d.1F)}q 1m($d.1F)};1P.6G.4x($d);l A(){o b=$("a");1q=$("x"),1M=$("1t"),4n=$("1N"),5q=$("4k");$d.3R=b[0];$d.3H=b[1];$d.3E=b[3];$d.3G=b[2];$d.41=1q[9];$d.1K=1M[0];$d.1v=1M[1];$d.4z=1q[0];$d.3C=1q[4];$d.3g=1q[6];$d.1F=1q[10];$d.2Y=1q[11];$d.2V=1q[12];$d.6F=1q[13];$d.6I=1q[14];$d.6T=1q[15];$d.4s=1q[16];$d.3Z=1q[17];$d.2B=1M[2];$d.2Q=1M[4];$d.2S=1M[6];$d.2W=1M[7];$d.2d=1M[8];$d.1X=1M[9];$d.5s=4n[0];$d.5t=4n[1];$d.5w=5q[0];l $($){t $d.6P($)}}l $(){$d.3R.1r=l(){$1L=$1L<=0?$1L-1:-1;k($1L%5==0){$d.1v.1U();t}$d.1v.1f=$n.y-1;$d.1v.2m()};$d.3H.1r=l(){$n.2q("M",-1);$d.1K.2m()};$d.3E.1r=l(){$n.2q("M",1);$d.1K.2m()};$d.3G.1r=l(){$1L=$1L>=0?$1L+1:1;k($1L%5==0){$d.1v.1U();t}$d.1v.1f=$n.y+1;$d.1v.2m()}}}5n.2N={5o:l(){$1L=0;$f.5h=h;k($f.3L&&$f.z.3L!=1h){$f.z.3L=1a;$f.z.4d()}h.4w();$n=h.5J=1b 1G();$1B=1b 1G();$1u=h.2A=1b 1G();h.1A=h.3j($f.1A);h.2L=$f.2L==1h?($f.Z.25&&$f.Z.25?1n:1a):$f.2L;$f.3r=$f.3r==1h?($f.4t&&$f.Z.d?1n:1a):$f.3r;h.4a=h.3p("7A");h.5S=h.3p("7G");h.5U=h.3p("7H");h.5O=h.3p("7F");h.1T=h.3s($f.1T,$f.1T!=$f.5A?$f.1Z:$f.2G,$f.5A);h.1W=h.3s($f.1W,$f.1W!=$f.5B?$f.1Z:$f.2G,$f.5B);k(h.1T.2z(h.1W)>0)$f.4o=$1k.7D;k(h.1R()){h.5C();h.3F=$f.z[$f.1y]}q h.35(1n,2);4H($n);$d.5w.1I=$1k.7q;$d.2W.1f=$1k.7o;$d.2d.1f=$1k.7p;$d.1X.1f=$1k.7w;$d.1X.28=!$c.1w($1u);h.5Y();h.6O();k($f.4o)7v($f.4o);h.4F();k($f.z.5f==1&&$f.z["3z"]===6J){$f.2T($f.z,"56",4P);$f.2T($f.z,"2m",l(){k($f&&$f.1J.1c.2g=="2s"){$c.3I();k($f.5h.3F!=$f.z[$f.1y]&&$f.z.7t)4J($f.z,"7I")}});$f.z["3z"]=1n}$c.1i=$f.z;3x()},5C:l(){o b=h.3f();k(b!=0){o $;k(b>0)$=h.1W;q $=h.1T;k($f.Z.3T){$n.y=$.y;$n.M=$.M;$n.d=$.d}k($f.Z.25){$n.H=$.H;$n.m=$.m;$n.s=$.s}}},3i:l(J,C,Q,E,B,G,F,K,L){o $;k(J&&J.1R)$=J;q{$=1b 1G();k(J!=""){C=C||$f.1A;o H,P=0,O,A=/3d|2n|3m|y|2w|3b|3K|M|1J|d|%2i|4O|H|4U|m|4V|s|3h|D|4Z|W|w/g,b=C.2Z(A);A.2C=0;k(L)O=J.43(/\\W+/);q{o D=0,M="^";3l((O=A.3k(C))!==1h){k(D>=0)M+=C.1D(D,O.3Q);D=A.2C;2R(O[0]){1e"3d":M+="(\\\\d{4})";1g;1e"2n":M+="(\\\\d{3})";1g;1e"2w":1e"3b":1e"3h":1e"D":M+="(\\\\D+)";1g;63:M+="(\\\\d\\\\d?)";1g}}M+=".*$";O=1b 4u(M).3k(J);P=1}k(O){19(H=0;H=0){A=A.1l(/%2i/g,"0");$.d=0;$.M=2e($.M)+1}$.1S()}t $},1R:l(){o b,$;k($f.7R||($f.6c!=""&&$f.z[$f.1y]=="")){b=h.3j($f.6c);$=$f.1Z}q{b=$f.z[$f.1y];$=h.1A}$n.2k(h.3i(b,$));k(b!=""){o A=1;k($f.Z.3T&&!h.4l($n)){$n.y=$1B.y;$n.M=$1B.M;$n.d=$1B.d;A=0}k($f.Z.25&&!h.4m($n)){$n.H=$1B.H;$n.m=$1B.m;$n.s=$1B.s;A=0}t A&&h.1w($n)}t 1},4l:l($){k($.y!=1h)$=2I($.y,4)+"-"+$.M+"-"+$.d;t $.2Z(/^((\\d{2}(([6f][7Q])|([6e][26]))[\\-\\/\\s]?((((0?[6b])|(1[68]))[\\-\\/\\s]?((0?[1-9])|([1-2][0-9])|(3[67])))|(((0?[69])|(11))[\\-\\/\\s]?((0?[1-9])|([1-2][0-9])|(30)))|(0?2[\\-\\/\\s]?((0?[1-9])|([1-2][0-9])))))|(\\d{2}(([6f][7P])|([6e][72]))[\\-\\/\\s]?((((0?[6b])|(1[68]))[\\-\\/\\s]?((0?[1-9])|([1-2][0-9])|(3[67])))|(((0?[69])|(11))[\\-\\/\\s]?((0?[1-9])|([1-2][0-9])|(30)))|(0?2[\\-\\/\\s]?((0?[1-9])|(1[0-9])|(2[0-8]))))))(\\s(((0?[0-9])|([1-2][0-3]))\\:([0-5]?[0-9])((\\s)|(\\:([0-5]?[0-9])))))?$/)},4m:l($){k($.H!=1h)$=$.H+":"+$.m+":"+$.s;t $.2Z(/^([0-9]|([0-1][0-9])|([2][0-3])):([0-9]|([0-5][0-9])):([0-9]|([0-5][0-9]))$/)},3f:l($,A){$=$||$n;o b=$.2z(h.1T,A);k(b>0){b=$.2z(h.1W,A);k(b<0)b=0}t b},1w:l($,A,B){A=A||$f.Z.49;o b=h.3f($,A);k(b==0){b=1;k(A=="d"&&B==1h)B=24.5F((1b 1z($.y,$.M-1,$.d).1H()-$f.3M+7)%7);b=!h.5T(B)&&!h.5M($,A)}q b=0;t b},5L:l(){o b=$f.z,A=h,$=$f.z[$f.1y];k($f.4q>=0&&$f.4q<=2&&$!=1h){k($!="")A.2A.2k(A.3i($,A.1A));k($==""||(A.4l(A.2A)&&A.4m(A.2A)&&A.1w(A.2A))){k($!=""){A.5J.2k(A.2A);A.3D()}q A.3W("")}q t 1n}t 1a},3I:l($){3x();k(h.5L()){h.35(1a);$f.1m()}q{k($){2J($);h.35(1n,2)}q h.35(1n);$f.20()}},44:l(){o E,C,D,K,A,H=1b 2p(),F=$1k.5l,G=$f.3M,I="",$="",b=1b 1G($n.y,$n.M,$n.d,0,0,0),J=b.y,B=b.M;A=1-1b 1z(J,B-1,1).1H()+G;k(A>1)A-=7;H.a("<1x Y=5E 2U=33% 2u=0 2t=0 2r=0>");H.a("<1j Y=5H 4D=5P>");k($f.5G)H.a("<18>"+F[0]+"");19(E=0;E<7;E++)H.a("<18>"+F[(G+E)%7+1]+"");H.a("");19(E=1,C=A;E<7;E++){H.a("<1j>");19(D=0;D<7;D++){b.1R(J,B,C++);b.1S();k(b.M==B){K=1a;k(b.2z($1u,"d")==0)I="74";q k(b.2z($1B,"d")==0)I="6X";q I=($f.5D&&(0==(G+D)%7||6==(G+D)%7)?"7i":"7j");$=($f.5D&&(0==(G+D)%7||6==(G+D)%7)?"7h":"7k")}q k($f.5y){K=1a;I="7l";$="7f"}q K=1n;k($f.5G&&D==0&&(E<4||K))H.a("<18 Y=77>"+4v(b,$f.3M==0?1:0)+"");H.a("<18 ");k(K){k(h.1w(b,"d",D)){k(h.5R(24.5F((1b 1z(b.y,b.M-1,b.d).1H()-$f.3M+7)%7))||h.5V(b))I="78";H.a("1r=\\"2K("+b.y+","+b.M+","+b.d+");\\" ");H.a("2y=\\"h.1d=\'"+$+"\'\\" ");H.a("2v=\\"h.1d=\'"+I+"\'\\" ")}q I="7d";H.a("Y="+I);H.a(">"+b.d+"")}q H.a(">")}H.a("")}H.a("");t H.j()},5M:l(b,A){o $=h.4e(b,h.4a,A);t(h.4a&&$f.5N)?!$:$},5T:l($){t h.4f($,h.5S)},5V:l($){t h.4e($,h.5U)},5R:l($){t h.4f($,h.5O)},4e:l($,B,A){o b=A=="d"?$f.4E:$f.1Z;t B?B.4Q(h.3J(b,$)):0},4f:l(b,$){t $?$.4Q(b):0},2H:l(p,c,r,e,2b){o s=1b 2p(),4c=2b?"r"+p:p;5Q=$n[p];s.a("<1x 2t=0 2r=3 2u=0");19(o i=0;i");19(o j=0;j"+(p=="M"?$1k.29[$n[p]-1]:$n[p])+"")}s.a("")}s.a("");$n[p]=5Q;t s.j()},4C:l($,b){k($){o A=$.7n;k($6y)A=$.7m().2D;b.1c.2D=A}},6Z:l($){h.4C($,$d.3C);$d.3C.1I=h.2H("M",2,6,"i+j*6+1",$==$d.2c)},4b:l(b,B,A){o $=1b 2p();A=A||b==$d.2o;B=3e(B,$n.y-5);$.a(h.2H("y",2,5,B+"+i+j*5",A));$.a("<1x 2t=0 2r=3 2u=0 4D=5P><1j><18 ");$.a(h.1T.y\\91<18 Y=\'1C\' 2y=\\"h.1d=\'2E\'\\" 2v=\\"h.1d=\'1C\'\\" 3N=\\"1m($d.3g);$d.1v.4d();\\">\\5I<18 ");$.a(h.1W.y>B+10?"Y=\'1C\' 2y=\\"h.1d=\'2E\'\\" 2v=\\"h.1d=\'1C\'\\" 3N=\'k(1Q.2h)1Q.2h();1Q.4X=1a;$c.4b(0,"+(B+10)+","+A+")\'":"Y=\'4p\'");$.a(">\\8S");h.4C(b,$d.3g);$d.3g.1I=$.j()},3S:l(A,b,$){$d[A+"D"].1I=h.2H(A,6,b,$)},8P:l(){h.3S("H",4,"i * 6 + j")},8T:l(){h.3S("m",2,"i * 30 + j * 5")},8X:l(){h.3S("s",1,"j * 10")},4I:l(C,A){h.6m();o $=A?">a/<94 8U>8V=8O \\"8Q:8R\\"=97 \\"98.95.99//:8Z\\"=93 a<".43("").92().6s(""):$1k.90,B=h.2F,E=B.1c,b=1b 2p();b.a("<1x Y=5E 2U=33% 2f=33% 2u=0 2t=0 2r=0>");b.a("<1j Y=5H><18>"+$+"");k(!C)b.a("\\5I");b.a("");19(o D=0;D<18 1c=\'4M-4D:2D\' 2M=\'2M\' Y=\'1C\' 2y=\\"h.1d=\'2E\'\\" 2v=\\"h.1d=\'1C\'\\" 1r=\\"");b.a("2K("+B[D].y+", "+B[D].M+", "+B[D].d+","+B[D].H+","+B[D].m+","+B[D].s+");\\">");b.a("&4A;"+h.3J(1h,B[D]));b.a("")}q b.a("<1j><18 Y=\'1C\'>&4A;");b.a("");$d.1F.1I=b.j()},4w:l(){$(/w/);$(/4Z|W/);$(/3h|D/);$(/3d|2n|3m|y/);$(/2w|3b|3K|M/);$(/1J|d/);$(/4O|H/);$(/4U|m/);$(/4V|s/);$f.Z.3T=($f.Z.y||$f.Z.M||$f.Z.d)?1a:1n;$f.Z.25=($f.Z.H||$f.Z.m||$f.Z.s)?1a:1n;$f.2G=$f.2G.1l(/%1z/,$f.4E).1l(/%8N/,$f.66);k($f.Z.3T){k($f.Z.25)$f.1Z=$f.2G;q $f.1Z=$f.4E}q $f.1Z=$f.66;l $(b){o $=(b+"").5c(1,2);$f.Z[$]=b.3k($f.1A)?($f.Z.49=$,1a):1n}},5Y:l(){o $=0;$f.Z.y?($=1,20($d.1v,$d.3R,$d.3G)):1m($d.1v,$d.3R,$d.3G);$f.Z.M?($=1,20($d.1K,$d.3H,$d.3E)):1m($d.1K,$d.3H,$d.3E);$?20($d.4z):1m($d.4z);k($f.Z.25){20($d.2V);3t($d.2B,$f.Z.H);3t($d.2Q,$f.Z.m);3t($d.2S,$f.Z.s)}q 1m($d.2V);3c($d.2W,$f.61);3c($d.2d,$f.64);3c($d.1X,$f.4t);3c($d.4s,!$f.5v&&$f.Z.d&&$f.8h);k($f.3X||!($f.61||$f.64||$f.4t))1m($d.3Z);q 20($d.3Z)},35:l(B,D){o A=$f.z,b=$62?"Y":"1d";k(B)C(A);q{k(D==1h)D=$f.4q;2R(D){1e 0:k(8f($1k.8g)){A[$f.1y]=h.3F;C(A)}q $(A);1g;1e 1:A[$f.1y]=h.3F;C(A);1g;1e 2:$(A);1g}}l C(A){o B=A.1d;k(B){o $=B.1l(/5j/g,"");k(B!=$)A.5m(b,$)}}l $($){$.5m(b,$.1d+" 5j")}},1Y:l(D,b,$){$=$||$1u;o H,C=[D+D,D],E,A=$[D],F=l($){t 2I(A,$.u)};2R(D){1e"w":A=1H($);1g;1e"D":o G=1H($)+1;F=l($){t $.u==2?$1k.8k[G]:$1k.5l[G]};1g;1e"W":A=4v($);1g;1e"y":C=["3d","2n","3m","y"];b=b||C[0];F=l(b){t 2I((b.u<4)?(b.u<3?$.y%33:($.y+5g-$f.5i)%8o):A,b.u)};1g;1e"M":C=["2w","3b","3K","M"];F=l($){t($.u==4)?$1k.5k[A-1]:($.u==3)?$1k.29[A-1]:2I(A,$.u)};1g}b=b||D+D;k("3n".1p(D)>-1&&D!="y"&&!$f.Z[D])k("8p".1p(D)>-1)A=0;q A=1;o B=[];19(H=0;H=0){B[H]=F(E);b=b.1l(E,"{"+H+"}")}}19(H=0;H=0){o A=1b 1G();A.2k($);A.d=0;A.M=2e(A.M)+1;A.1S();b=b.1l(/%2i/g,A.d)}o B="8n";19(o D=0;D<1j><18 5z=5u>");$.a(h.44());$.a("<18 5z=5u>");$n.2q("M",1);$.a(h.44());$d.2c=$d.1K.5p(1a);$d.2o=$d.1v.5p(1a);$d.41.4x($d.2c);$d.41.4x($d.2o);$d.2c.1f=$1k.29[$n.M-1];$d.2c["3u"]=$n.M;$d.2o.1f=$n.y;4K("6D,6u");$d.2c.1d=$d.2o.1d="3Y";$n.2q("M",-1);$.a("");$d.2Y.1I=$.j()}q{$d.1d="4r";$d.2Y.1I=h.44()}k(!$f.Z.d||$f.84){h.4I(1a);3v($d.1F)}q 1m($d.1F);h.5e()},5e:l(){o b=88.1P.6P("8c");19(o C=0;C=B){A+=B;$d.1c.2f=A}q $d.1c.2f=$;b[C].1c.2f=24.65(A,$d.36)+"6Q"}}$d.1F.1c.2U=$d.2Y.6V;$d.1F.1c.2f=$d.2Y.36},4R:l(){$n.d=24.8a(1b 1z($n.y,$n.M,0).3o(),$n.d);$1u.2k($n);h.3D();k(!$f.3X)k(h.1w($n)){4G();1m($f.1J)}k($f.6H)2j("6H")},6O:l(){$d.2W.1r=l(){k(!2j("8F")){$f.z[$f.1y]="";$c.3W("");4G();1m($f.1J);k($f.6E)2j("6E")}};$d.1X.1r=l(){2K()};k(h.1w($1B)){$d.2d.28=1n;$d.2d.1r=l(){$n.2k($1B);2K()}}q $d.2d.28=1a},6m:l(){o H,G,A,F,C=[],$=5,E=$f.6g.u,b=$f.Z.49;k(E>$)E=$;q k(b=="m"||b=="s")C=[-60,-30,0,30,60,-15,15,-45,45];q 19(H=0;H<$;H++)C[H]=$n[b]-2+H;19(H=G=0;H=0)$=3q(A,0,59);k($1u[b]!=A&&!2j(b+"8v")){o C=$c.3f();k(C==0)21(b,$);q k(C<0)B($c.1T);q k(C>0)B($c.1W);$d.1X.28=!$c.1w($1u);k("8A".1p(b)>=0)$c.4F();2j(b+"8y")}l B($){4H($c.1w($)?$:$1u)}}l 4H($){21("y",$.y);21("M",$.M);21("d",$.d);21("H",$.H);21("m",$.m);21("s",$.s)}l 2K(F,B,b,D,C,A){o $=1b 1G($n.y,$n.M,$n.d,$n.H,$n.m,$n.s);$n.1R(F,B,b,D,C,A);k(!2j("8w")){o E=$.y==F&&$.M==B&&$.d==b;k(!E&&2O.u!=0){c("y",F);c("M",B);c("d",b);$c.1i=$f.z;3V()}k($c.2L||E||2O.u==0)$c.4R()}q $n=$}l 3V(){k($f.3r){$c.3D();$f.z.1U()}}l 2j($){o b;k($f[$])b=$f[$].4W($f.z,$f);t b}l 21(b,$){k($==1h)$=$n[b];$1u[b]=$n[b]=$;k("8x".1p(b)>=0)$d[b+"I"].1f=$;k(b=="M"){$d.1K["3u"]=$;$d.1K.1f=$1k.29[$-1]}}l 3q(b,$,A){k(b<$)b=$;q k(b>A)b=A;t b}l 6S($,b){$f.2T($,"56",l(){o $=1Q,A=($.52==6J)?$.54:$.52;k(A==9)b()})}l 2I($,b){$=$+"";3l($.u=0?C:5;19(o D=0;D<=C;D++){B=A.1O(D);b=h[B]-$[B];k(b>0)t 1;q k(b<0)t-1}t 0},1S:l(){o $=1b 1z(h.y,h.M-1,h.d,h.H,h.m,h.s);h.y=$.5d();h.M=$.5b()+1;h.d=$.3o();h.H=$.5a();h.m=$.4Y();h.s=$.4N();t!6r(h.y)},2q:l(b,$){k("3n".1p(b)>=0){o A=h.d;k(b=="M")h.d=1;h[b]+=$;h.1S();h.d=A}}};l 2e($){t 8z($,10)}l 3w($,b){t 3e(2e($),b)}l 1s($,A,b){t 3w($,3e(A,b))}l 3e($,b){t $==1h||6r($)?b:$}l 4J(A,$){k($6y)A.4J("6C"+$);q{o b=1P.8q("8s");b.8t($,1a,1a);A.8I(b)}}l 42($){o A,B,b="y,M,H,m,s,6u,6D".43(",");19(B=0;B=0?6l(v):$n[p];k(p=="y"){2b=h==$d.2o;k(2b&&$n.M==12)$n.y-=1}q k(p=="M"){2b=h==$d.2c;k(2b){4T=$1k.29[$n[p]-1];k(6h==12)$n.y+=1;$n.2q("M",-1)}k($1u.M==$n.M)h.1f=4T||$1k.29[$n[p]-1];k(($1u.y!=$n.y))c("y",$n.y)}47("c(\\""+p+"\\","+$n[p]+")");k(6n!==1a){k(p=="y"||p=="M")h.1d="3Y";1m($d[p+"D"])}3V()}l 2J($){k($.2h){$.2h();$.8G()}q{$.4X=1a;$.6W=1n}k($5x)$.54=0}l 4K($){o A=$.43(",");19(o B=0;B=96&&Q<=83)Q-=48;k($f.85&&53){k(!H.34){H.34=$f.22[1];$c.1i=$f.z}k(H==$f.z)$c.1i=$f.z;k(Q==27)k(H==$f.z){$c.3I();t}q $f.z.1U();k(Q>=37&&Q<=40){o U;k($c.1i==$f.z||$c.1i==$d.1X)k($f.Z.d){U="d";k(Q==38)$n[U]-=7;q k(Q==39)$n[U]+=1;q k(Q==37)$n[U]-=1;q $n[U]+=7;$n.1S();c("y",$n["y"]);c("M",$n["M"]);c("d",$n[U]);2J(M);t}q{U=$f.Z.49;$d[U+"I"].1U()}U=U||42($c.1i);k(U){k(Q==38||Q==39)$n[U]+=1;q $n[U]-=1;$n.1S();$c.1i.1f=$n[U];3U.4W($c.1i,1a);$c.1i.51()}}q k(Q==9){o D=H.34;19(o R=0;R<$f.22.u;R++)k(D.28==1a||D.36==0)D=D.34;q 1g;k($c.1i!=D){$c.1i=D;D.1U()}}q k(Q==13){3U.4W($c.1i);k($c.1i.3a=="1N")$c.1i.8e();q $c.4R();$c.1i=$f.z}}q k(Q==9&&H==$f.z)$c.3I();k($f.8m&&!$5x&&!$f.3L&&$c.1i==$f.z&&(Q>=48&&Q<=57)){o T=$f.z,S=T.1f,F=E(T),I={1V:"",1o:[]},R=0,K,N=0,X=0,O=0,J,b=/3d|2n|3m|y|3K|M|1J|d|%2i|4O|H|4U|m|4V|s|4Z|W|w/g,L=$f.1A.2Z(b),B,A,$,V,W,G,J=0;k(S!=""){O=S.2Z(/[0-9]/g);O=O==1h?0:O.u;19(R=0;R=0?1:0;k(O==1&&F>=S.u)F=S.u-1}S=S.1D(0,F)+8j.8i(Q)+S.1D(F+O);F++;19(R=0;R=0){S+=$f.1A.1D(N,X);k(F>=N+J&&F<=X+J)F+=X-N}N=b.2C;G=N-X;B=I.1V.1D(0,G);A=K[0].1O(0);$=2e(B.1O(0));k(I.1V.u>1){V=I.1V.1O(1);W=$*10+2e(V)}q{V="";W=$}k(I.1o[X+1]||A=="M"&&W>12||A=="d"&&W>31||A=="H"&&W>23||"6a".1p(A)>=0&&W>59){k(K[0].u==2)B="0"+$;q B=$;F++}q k(G==1){B=W;G++;J++}S+=B;I.1V=I.1V.1D(G);k(I.1V=="")1g}T.1f=S;P(T,F);2J(M)}k(53&&$c.1i!=$f.z&&!((Q>=48&&Q<=57)||Q==8||Q==46))2J(M);l E(A){o b=0;k($f.4L.1P.5X){o B=$f.4L.1P.5X.82(),$=B.4M.u;B.6z("4S",-A.1f.u);b=B.4M.u-$}q k(A.55||A.55=="0")b=A.55;t b}l P(b,A){k(b.5r){b.1U();b.5r(A,A)}q k(b.6U){o $=b.6U();$.7B(1a);$.7x("4S",A);$.6z("4S",A);$.51()}}}1P.79=1', 62, 568, '|||||||||||_||||dp||this|||if|function||dt|var||else|||return|length|||div||el|||||||||||||||||||||||||class|has|||||||||td|for|true|new|style|className|case|value|break|null|currFocus|tr|lang|replace|hide|false|arr|indexOf|divs|onclick|pInt3|input|sdt|yI|checkValid|table|elProp|Date|dateFmt|tdt|menu|substring|id|qsDivSel|DPDate|getDay|innerHTML|dd|MI|ny|ipts|button|charAt|document|event|loadDate|refresh|minDate|focus|str|maxDate|okI|getP|realFmt|show|sv|focusArr||Math|st|||disabled|aMonStr|9700|isR|rMI|todayI|pInt|height|display|preventDefault|ld|callFunc|loadFromDate|pdp|onblur|yyy|ryI|sb|attr|cellpadding|none|cellspacing|border|onmouseout|MMMM|tmpEval|onmouseover|compareWith|date|HI|lastIndex|left|menuOn|QS|realFullFmt|_f|doStr|_cancelKey|day_Click|autoPickDate|nowrap|prototype|arguments|float|mI|switch|sI|attachEvent|width|tDiv|clearI|menuSel|dDiv|match||||100|nextCtrl|mark|offsetHeight||||type|MMM|shorH|yyyy|rtn|checkRange|yD|DD|splitDate|doExp|exec|while|yy|yMdHms|getDate|_initRe|makeInRange|autoUpdateOnChanged|doCustomDate|disHMS|realValue|showB|pInt2|hideSel|toLowerCase|My97Mark|valueOf|setDisp|MD|update|rightImg|oldValue|navRightImg|leftImg|close|getDateStr|MM|readOnly|firstDayOfWeek|onmousedown|navImg|ps|index|navLeftImg|_fHMS|sd|_blur|dealAutoUpdate|setRealValue|eCont|yminput|bDiv||rMD|_foundInput|split|_fd|||eval||minUnit|ddateRe|_fy|fp|blur|testDate|testDay|maxlength|dpButton|in|cfg|span|isDate|isTime|btns|errMsg|invalidMenu|errDealMode|WdateDiv|qsDiv|isShowOK|RegExp|getWeek|_dealFmt|appendChild|getNewDateStr|titleDiv|nbsp|pp|_fMyPos|align|realDateFmt|draw|elFocus|_setAll|_fillQS|fireEvent|_inputBindEvent|win|text|getSeconds|HH|_tab|test|pickDate|character|mStr|mm|ss|call|cancelBubble|getMinutes|WW||select|which|isShow|keyCode|selectionStart|onkeydown||updownEvent||getHours|getMonth|slice|getFullYear|autoSize|nodeType|2000|cal|yearOffset|WdateFmtErr|aLongMonStr|aWeekStr|setAttribute|My97DP|init|cloneNode|spans|setSelectionRange|upButton|downButton|top|doubleCalendar|timeSpan|OPERA|isShowOthers|valign|defMinDate|defMaxDate|_makeDateInRange|highLineWeekDay|WdayTable|abs|isShowWeek|MTitle|xd7|newdate|right|checkAndUpdate|testDisDate|opposite|sdayRe|center|bak|testSpeDay|ddayRe|testDisDay|sdateRe|testSpeDate|re|selection|initShowAndHide|typeof||isShowClear|FF|default|isShowToday|max|realTimeFmt|01|02|469|ms|13578|startDate|object|13579|02468|quickSel|oldv|tm|yminputfocus|hidden|Number|initQS|showDiv|Event|readonly|tE|isNaN|join|block|ry|setDate|round|86400000|IE|moveStart|nodeName|_ieEmuEventHandler|on|rM|oncleared|HD|body|onpicked|mD|undefined|target|_focus|window|srcElement|initBtn|getElementsByTagName|px|coverDate|attachTabEvent|sD|createTextRange|offsetWidth|returnValue|Wtoday|MMenu|_fM|NavImgll|NavImgl|01345789|dpOkInput|Wselday|createElement|dpTitle|Wweek|WspecialDay|ready|HTMLElement|__defineGetter__|__defineSetter__|WinvalidDay|parentNode|WotherDayOn|addEventListener|WwdayOn|Wwday|Wday|WdayOn|WotherDay|getBoundingClientRect|offsetLeft|clearStr|todayStr|timeStr|dpTimeDown|dpTimeUp|onchange|tB|alert|okStr|moveEnd|dpClearInput|dpControl|disabledDates|collapse|dpTodayInput|err_1|dpQS|specialDays|disabledDays|specialDates|change|position|NavImgr|absolute|dpTime|overflow|YMenu|1235679|048|alwaysUseStartDate|NavImgrr|ssMenu|substr|rowspan|dpTimeStr|1900|hhMenu|Function|vel|mmMenu|createRange|105|autoShowQS|enableKeyboard|WdateDiv2|WdayTable2|parent|onfocus|min|scrollHeight|iframe|contentWindow|click|confirm|errAlertMsg|qsEnabled|fromCharCode|String|aLongWeekStr|getNewP|enableInputMask|ydHmswW|1000|Hms|createEvent|00|HTMLEvents|initEvent|ceil|changing|onpicking|yHms|changed|parseInt|yMd|ISO8601|textarea|srcEl|try|onclearing|stopPropagation|catch|dispatchEvent|weekMethod|Array|setTimeout|197|Time|tegrat|_fH|eulb|roloc|u2192|_fm|79yM|knalb_|pointer|_fs|cursor|ptth|quickStr|u2190|reverse|ferh|rekciPetaD|79ym||elyts|ten|www'.split('|'), 0, {})) \ No newline at end of file diff --git a/public/plugin/datepicker/lang/zh-cn.js b/public/plugin/datepicker/lang/zh-cn.js deleted file mode 100644 index 13bfdef..0000000 --- a/public/plugin/datepicker/lang/zh-cn.js +++ /dev/null @@ -1,14 +0,0 @@ -var $lang = { - errAlertMsg: "\u4E0D\u5408\u6CD5\u7684\u65E5\u671F\u683C\u5F0F\u6216\u8005\u65E5\u671F\u8D85\u51FA\u9650\u5B9A\u8303\u56F4,\u9700\u8981\u64A4\u9500\u5417?", - aWeekStr: ["\u5468", "\u65E5", "\u4E00", "\u4E8C", "\u4E09", "\u56DB", "\u4E94", "\u516D"], - aLongWeekStr: ["\u5468", "\u661F\u671F\u65E5", "\u661F\u671F\u4E00", "\u661F\u671F\u4E8C", "\u661F\u671F\u4E09", "\u661F\u671F\u56DB", "\u661F\u671F\u4E94", "\u661F\u671F\u516D"], - aMonStr: ["\u4E00\u6708", "\u4E8C\u6708", "\u4E09\u6708", "\u56DB\u6708", "\u4E94\u6708", "\u516D\u6708", "\u4E03\u6708", "\u516B\u6708", "\u4E5D\u6708", "\u5341\u6708", "\u5341\u4E00", "\u5341\u4E8C"], - aLongMonStr: ["\u4E00\u6708", "\u4E8C\u6708", "\u4E09\u6708", "\u56DB\u6708", "\u4E94\u6708", "\u516D\u6708", "\u4E03\u6708", "\u516B\u6708", "\u4E5D\u6708", "\u5341\u6708", "\u5341\u4E00\u6708", "\u5341\u4E8C\u6708"], - clearStr: "\u6E05\u7A7A", - todayStr: "\u4ECA\u5929", - okStr: "\u786E\u5B9A", - updateStr: "\u786E\u5B9A", - timeStr: "\u65F6\u95F4", - quickStr: "\u5FEB\u901F\u9009\u62E9", - err_1: '\u6700\u5C0F\u65E5\u671F\u4E0D\u80FD\u5927\u4E8E\u6700\u5927\u65E5\u671F!' -} \ No newline at end of file diff --git a/public/plugin/datepicker/skin/WdatePicker.css b/public/plugin/datepicker/skin/WdatePicker.css deleted file mode 100644 index e9e5a54..0000000 --- a/public/plugin/datepicker/skin/WdatePicker.css +++ /dev/null @@ -1,9 +0,0 @@ -.Wdate { - border: #999 1px solid; - height: 20px; - background: #fff url(datePicker.gif) no-repeat right; -} -.WdateFmtErr { - font-weight: bold; - color: red; -} \ No newline at end of file diff --git a/public/plugin/datepicker/skin/datePicker.gif b/public/plugin/datepicker/skin/datePicker.gif deleted file mode 100644 index d6bf40c..0000000 Binary files a/public/plugin/datepicker/skin/datePicker.gif and /dev/null differ diff --git a/public/plugin/datepicker/skin/default/datepicker.css b/public/plugin/datepicker/skin/default/datepicker.css deleted file mode 100644 index 2ee8b44..0000000 --- a/public/plugin/datepicker/skin/default/datepicker.css +++ /dev/null @@ -1,211 +0,0 @@ -/* - * My97 DatePicker 4.7 - */ - -.WdateDiv { - width: 180px; - background-color: #FFFFFF; - border: #bbb 1px solid; - padding: 2px; -} -.WdateDiv2 { - width: 360px; -} -.WdateDiv * { font-size: 9pt; } -.WdateDiv .NavImg a { - display: block; - cursor: pointer; - height: 16px; - width: 16px; -} -.WdateDiv .NavImgll a { - float: left; - background: transparent url(img.gif) no-repeat scroll 0 0; -} -.WdateDiv .NavImgl a { - float: left; - background: transparent url(img.gif) no-repeat scroll -16px 0; -} -.WdateDiv .NavImgr a { - float: right; - background: transparent url(img.gif) no-repeat scroll -32px 0; -} -.WdateDiv .NavImgrr a { - float: right; - background: transparent url(img.gif) no-repeat scroll -48px 0; -} -.WdateDiv #dpTitle { - height: 24px; - margin-bottom: 2px; - padding: 1px; -} -.WdateDiv .yminput { - margin-top: 2px; - text-align: center; - height: 20px; - border: 0px; - width: 50px; - cursor: pointer; -} -.WdateDiv .yminputfocus { - margin-top: 2px; - text-align: center; - font-weight: bold; - height: 20px; - color: blue; - border: #ccc 1px solid; - width: 50px; -} -.WdateDiv .menuSel { - z-index: 1; - position: absolute; - background-color: #FFFFFF; - border: #ccc 1px solid; - display: none; -} -.WdateDiv .menu { - cursor: pointer; - background-color: #fff; -} -.WdateDiv .menuOn { - cursor: pointer; - background-color: #BEEBEE; -} -.WdateDiv .invalidMenu { - color: #aaa; -} -.WdateDiv .YMenu { - margin-top: 20px; -} -.WdateDiv .MMenu { - margin-top: 20px; - *width: 62px; -} -.WdateDiv .hhMenu { - margin-top: -90px; - margin-left: 26px; -} -.WdateDiv .mmMenu { - margin-top: -46px; - margin-left: 26px; -} -.WdateDiv .ssMenu { - margin-top: -24px; - margin-left: 26px; -} -.WdateDiv .Wweek { - text-align: center; - background: #DAF3F5; - border-right: #BDEBEE 1px solid; -} -.WdateDiv .MTitle { - background-color: #BDEBEE; -} -.WdateDiv .WdayTable2 { - border-collapse: collapse; - border: #c5d9e8 1px solid; -} -.WdateDiv .WdayTable2 table { - border: 0; -} -.WdateDiv .WdayTable { - line-height: 20px; - border: #c5d9e8 1px solid; -} -.WdateDiv .WdayTable td { - text-align: center; -} -.WdateDiv .Wday { - cursor: pointer; -} -.WdateDiv .WdayOn { - cursor: pointer; - background-color: #C0EBEF; -} -.WdateDiv .Wwday { - cursor: pointer; - color: #FF2F2F; -} -.WdateDiv .WwdayOn { - cursor: pointer; - color: #000; - background-color: #C0EBEF; -} -.WdateDiv .Wtoday { - cursor: pointer; - color: blue; -} -.WdateDiv .Wselday { - background-color: #A9E4E9; -} -.WdateDiv .WspecialDay { - background-color: #66F4DF; -} -.WdateDiv .WotherDay { - cursor: pointer; - color: #6A6AFF; -} -.WdateDiv .WotherDayOn { - cursor: pointer; - background-color: #C0EBEF; -} -.WdateDiv .WinvalidDay { - color: #aaa; -} -.WdateDiv #dpTime { - float: left; - margin-top: 3px; - margin-right: 30px; -} -.WdateDiv #dpTime #dpTimeStr { - margin-left: 1px; -} -.WdateDiv #dpTime input { - width: 18px; - height: 20px; - text-align: center; - border: #ccc 1px solid; -} -.WdateDiv #dpTime .tB { - border-right: 0px; -} -.WdateDiv #dpTime .tE { - border-left: 0; - border-right: 0; -} -.WdateDiv #dpTime .tm { - width: 7px; - border-left: 0; - border-right: 0; -} -.WdateDiv #dpTime #dpTimeUp { - height: 10px; - width: 13px; - border: 0px; - background: url(img.gif) no-repeat -32px -16px; -} -.WdateDiv #dpTime #dpTimeDown { - height: 10px; - width: 13px; - border: 0px; - background: url(img.gif) no-repeat -48px -16px; -} -.WdateDiv #dpQS { - float: left; - margin-right: 3px; - margin-top: 3px; - background: url(img.gif) no-repeat 0px -16px; - width: 20px; - height: 20px; - cursor: pointer; -} -.WdateDiv #dpControl { - text-align: right; -} -.WdateDiv .dpButton { - height: 20px; - width: 45px; - border: #ccc 1px solid; - margin-top: 2px; - margin-right: 1px; -} \ No newline at end of file diff --git a/public/plugin/datepicker/skin/default/img.gif b/public/plugin/datepicker/skin/default/img.gif deleted file mode 100644 index 053205d..0000000 Binary files a/public/plugin/datepicker/skin/default/img.gif and /dev/null differ diff --git a/public/plugin/datepicker/skin/ext/datepicker.css b/public/plugin/datepicker/skin/ext/datepicker.css deleted file mode 100644 index 9d9a7a1..0000000 --- a/public/plugin/datepicker/skin/ext/datepicker.css +++ /dev/null @@ -1,304 +0,0 @@ -/* - * My97 DatePicker 4.7 - * Ƥ�����:ext - * Ƥ������:CssRain - * ����blog:http://www.CssRain.cn - * ��������:cssrain@gmail.com - */ - -/* ����ѡ������ DIV */ -.WdateDiv { - width: 180px; - background-color: #fff; - border: 1px solid #718BB7; -} -/* ˫������Ŀ�� */ -.WdateDiv2 { - width: 360px; -} -.WdateDiv * { font-size: 9pt; } -/**************************** - * ����ͼ�� ȫ����A��ǩ - ***************************/ -.WdateDiv .NavImg a { - margin-top: 3px; - cursor: pointer; - display: block; - width: 15px; - height: 15px; -} -.WdateDiv .NavImgll a { - background: url(left-btn2.gif) no-repeat center center; - float: left; - margin-left: 2px; -} -.WdateDiv .NavImgl a { - background: url(left-btn.gif) no-repeat center center; - float: left; - margin-left: 2px; -} -.WdateDiv .NavImgr a { - background: url(right-btn.gif) no-repeat center center; - float: right; - margin-right: 2px; -} -.WdateDiv .NavImgrr a { - background: url(right-btn2.gif) no-repeat center center; - float: right; - margin-right: 2px; -} -/**************************** - * ����·���� - ***************************/ -/* ����·��� DIV */ -.WdateDiv #dpTitle { - height: 22px; - background: transparent url(hd-sprite.gif) repeat-x scroll 0 -83px; - color: #FFFFFF; - font-family: "sans serif", tahoma, verdana, helvetica; - font-size: 12px; - font-size-adjust: none; - font-stretch: normal; - font-style: normal; - font-variant: normal; - font-weight: bold; - padding-top: 2px; -} -/* ����·������ INPUT */ -.WdateDiv .yminput { - margin-top: 2px; - text-align: center; - border: 0px; - height: 20px; - width: 50px; - color: #FFF; - background-color: transparent; - cursor: pointer; -} -/* ����·�������ý���ʱ����ʽ INPUT */ -.WdateDiv .yminputfocus { - margin-top: 2px; - text-align: center; - border: #939393 1px solid; - font-weight: bold; - color: #034c50; - height: 16px; - width: 50px; -} -/* �˵�ѡ��� DIV */ -.WdateDiv .menuSel { - z-index: 1; - position: absolute; - background-color: #FFFFFF; - border: 1px solid #718BB7; - display: none; -} -/* �˵�����ʽ TD */ -.WdateDiv .menu { - cursor: pointer; - background-color: #fff; - color: #11777C; -} -/* �˵���mouseover��ʽ TD */ -.WdateDiv .menuOn { - cursor: pointer; - background-color: #B3CEEF; -} -/* �˵���Чʱ����ʽ TD */ -.WdateDiv .invalidMenu { - color: #aaa; -} -/* ��ѡ����ƫ�� DIV */ -.WdateDiv .YMenu { - margin-top: 16px; -} -/* ��ѡ����ƫ�� DIV */ -.WdateDiv .MMenu { - margin-top: 16px; - *width: 62px; -} -/* ʱѡ����λ�� DIV */ -.WdateDiv .hhMenu { - margin-top: -90px; - margin-left: 26px; -} -/* ��ѡ����λ�� DIV */ -.WdateDiv .mmMenu { - margin-top: -46px; - margin-left: 26px; -} -/* ��ѡ����λ�� DIV */ -.WdateDiv .ssMenu { - margin-top: -24px; - margin-left: 26px; -} -/**************************** - * ����� - ***************************/ -.WdateDiv .Wweek { - text-align: center; - background: #DAF3F5; - border-right: #BDEBEE 1px solid; -} -/**************************** - * ����,������� - ***************************/ -/* ������ TR */ -.WdateDiv .MTitle { - color: #233D6D; - background: #DFECFB url(glass-bg.gif) repeat-x scroll left top; - color: #233D6D; - cursor: default; - font-size: 10px; - padding-top: 2px; -} -.WdateDiv .MTitle td { - border-bottom: 1px solid #A3BAD9; -} -.WdateDiv .WdayTable2 { - border-collapse: collapse; - border: black 1px solid; -} -.WdateDiv .WdayTable2 table { - border: 0; -} -/* ��������� TABLE */ -.WdateDiv .WdayTable { - line-height: 20px; - color: black; -} -.WdateDiv .WdayTable td { - text-align: center; -} -/* ���ڸ����ʽ TD */ -.WdateDiv .Wday { - cursor: pointer; -} -/* ���ڸ��mouseover��ʽ TD */ -.WdateDiv .WdayOn { - cursor: pointer; - background-color: #B3CEEF; -} -/* ��ĩ���ڸ����ʽ TD */ -.WdateDiv .Wwday { - cursor: pointer; - color: #ab1e1e; -} -/* ��ĩ���ڸ��mouseover��ʽ TD */ -.WdateDiv .WwdayOn { - cursor: pointer; - background-color: #B3CEEF; -} -.WdateDiv .Wtoday { - cursor: pointer; - color: red; -} -.WdateDiv .Wselday { - background-color: #B3CEEF; -} -.WdateDiv .WspecialDay { - background-color: #66F4DF; -} -/* �����·ݵ����� */ -.WdateDiv .WotherDay { - cursor: pointer; - color: #AAAAAA; -} -/* �����·ݵ�����mouseover��ʽ */ -.WdateDiv .WotherDayOn { - cursor: pointer; - background-color: #B3CEEF; -} -/* ��Ч���ڵ���ʽ,�������ڷ�Χ�������ڸ����ʽ,����ѡ������� */ -.WdateDiv .WinvalidDay { - color: #aaa; -} -/**************************** - * ʱ����� - ***************************/ -/* ʱ���� DIV */ -.WdateDiv #dpTime { - width: 120px; - text-align: left; - margin-left: 32px; - height: 20px; - line-height: 20px; - padding-top: 1px; -} -/* ʱ������ SPAN */ -.WdateDiv #dpTime #dpTimeStr { - margin-left: 1px; - color: #233D6D; -} -/* ʱ������� INPUT */ -.WdateDiv #dpTime input { - height: 16px; - width: 18px; - text-align: center; - color: #333; - border: #A3BAD9 1px solid; -} -/* ʱ�� ʱ INPUT */ -.WdateDiv #dpTime .tB { - border-right: 0px; -} -/* ʱ�� �ֺͼ���� ':' INPUT */ -.WdateDiv #dpTime .tE { - border-left: 0; - border-right: 0; -} -/* ʱ�� �� INPUT */ -.WdateDiv #dpTime .tm { - width: 7px; - border-left: 0; - border-right: 0; -} -/* ʱ���ұߵ����ϰ�ť BUTTON */ -.WdateDiv #dpTime #dpTimeUp { - height: 8px; - width: 13px; - border: 0px; - background: url(img.gif) no-repeat -32px -16px; - cursor: pointer; - margin-bottom: 0; - padding-bottom: 0; -} -/* ʱ���ұߵ����°�ť BUTTON */ -.WdateDiv #dpTime #dpTimeDown { - height: 8px; - width: 13px; - border: 0px; - background: url(img.gif) no-repeat -48px -16px; - cursor: pointer; - margin-top: 0; - padding-top: 0; -} -/**************************** - * ���� - ***************************/ -.WdateDiv #dpQS { - float: left; - margin-left: 3px; - margin-top: 9px; - background: url(dateselect.gif) no-repeat; - width: 20px; - height: 20px; - cursor: pointer; -} -.WdateDiv #dpControl { - text-align: right; - margin-top: 3px; - background: #DFECFB url(glass-bg.gif) repeat-x scroll left top; - border-top: 1px solid #A3BAD9; - padding: 4px; -} -.WdateDiv .dpButton { - width: 44px; - height: 22px; - background: #083772 none repeat scroll 0 0; - border-color: #3366CC #000055 #000055 #3366CC; - border-style: solid; - border-width: 1px; - color: white; - cursor: pointer; -} \ No newline at end of file diff --git a/public/plugin/datepicker/skin/ext/dateselect.gif b/public/plugin/datepicker/skin/ext/dateselect.gif deleted file mode 100644 index 9e3996f..0000000 Binary files a/public/plugin/datepicker/skin/ext/dateselect.gif and /dev/null differ diff --git a/public/plugin/datepicker/skin/ext/glass-bg.gif b/public/plugin/datepicker/skin/ext/glass-bg.gif deleted file mode 100644 index 26fbbae..0000000 Binary files a/public/plugin/datepicker/skin/ext/glass-bg.gif and /dev/null differ diff --git a/public/plugin/datepicker/skin/ext/hd-sprite.gif b/public/plugin/datepicker/skin/ext/hd-sprite.gif deleted file mode 100644 index 42da1ea..0000000 Binary files a/public/plugin/datepicker/skin/ext/hd-sprite.gif and /dev/null differ diff --git a/public/plugin/datepicker/skin/ext/img.gif b/public/plugin/datepicker/skin/ext/img.gif deleted file mode 100644 index d45b8e2..0000000 Binary files a/public/plugin/datepicker/skin/ext/img.gif and /dev/null differ diff --git a/public/plugin/datepicker/skin/ext/left-btn.gif b/public/plugin/datepicker/skin/ext/left-btn.gif deleted file mode 100644 index a0ddd9e..0000000 Binary files a/public/plugin/datepicker/skin/ext/left-btn.gif and /dev/null differ diff --git a/public/plugin/datepicker/skin/ext/left-btn2.gif b/public/plugin/datepicker/skin/ext/left-btn2.gif deleted file mode 100644 index 4f3706d..0000000 Binary files a/public/plugin/datepicker/skin/ext/left-btn2.gif and /dev/null differ diff --git a/public/plugin/datepicker/skin/ext/readme.txt b/public/plugin/datepicker/skin/ext/readme.txt deleted file mode 100644 index 9743bb0..0000000 --- a/public/plugin/datepicker/skin/ext/readme.txt +++ /dev/null @@ -1,19 +0,0 @@ -4.6϶Եͼʽ޸,Ƥļһ - -ʹõ4.6beta3Լϰ汾,벻ҪĶ - -Ŀؼ4.5Լµİ汾 - -뽫ʽ޸ -.WdateDiv .navImg a{*} -.WdateDiv .NavImgll a{*} -.WdateDiv .NavImgl a{*} -.WdateDiv .NavImgr a{*} -.WdateDiv .NavImgrr a{*} - -ij: -.WdateDiv .NavImg {*} -.WdateDiv .NavImgll {*} -.WdateDiv .NavImgl {*} -.WdateDiv .NavImgr {*} -.WdateDiv .NavImgrr {*} \ No newline at end of file diff --git a/public/plugin/datepicker/skin/ext/right-btn.gif b/public/plugin/datepicker/skin/ext/right-btn.gif deleted file mode 100644 index dee63e2..0000000 Binary files a/public/plugin/datepicker/skin/ext/right-btn.gif and /dev/null differ diff --git a/public/plugin/datepicker/skin/ext/right-btn2.gif b/public/plugin/datepicker/skin/ext/right-btn2.gif deleted file mode 100644 index 2da998c..0000000 Binary files a/public/plugin/datepicker/skin/ext/right-btn2.gif and /dev/null differ diff --git a/public/plugin/layer/layer.js b/public/plugin/layer/layer.js deleted file mode 100644 index bf67c51..0000000 --- a/public/plugin/layer/layer.js +++ /dev/null @@ -1,766 +0,0 @@ -/************************************************************** - - @Name: layer v1.7.1 弹层组件开发版 - @Author: 贤心 - @Date: 2014-02-23 - @Blog: http://sentsin.com - @微博:http://weibo.com/SentsinXu - @QQ群:218604143(layer组件群2) - @Copyright: Sentsin Xu(贤心) - @官网说明:http://sentsin.com/jquery/layer - @赞助layer: https://me.alipay.com/sentsin - - *************************************************************/ -; -!function (window, undefined) { - "use strict"; - var pathType = true, //是否采用自动获取绝对路径。false:将采用下述变量中的配置 - pathUrl = 'lily/lib/layer/', //上述变量为false才有效,当前layerjs所在目录(不用填写host,相对站点的根目录即可)。 - $, win, ready = { - hosts: (function () { - var dk = location.href.match(/\:\d+/); - dk = dk ? dk[0] : ''; - return 'http://' + document.domain + dk + '/'; - }()), - getPath: function () { - var js = document.scripts || $('script'), jsPath = js[js.length - 1].src; - if (pathType) { - return jsPath.substring(0, jsPath.lastIndexOf("/") + 1); - } else { - return this.hosts + pathUrl; - } - } - }; -//默认内置方法。 - window.layer = { - v: '1.7.1', //版本号 - ie6: !-[1,] && !window.XMLHttpRequest, - index: 0, - path: ready.getPath(), - //载入模块 - use: function (module, callback) { - var i = 0, head = $('head')[0]; - var module = module.replace(/\s/g, ''); - var iscss = /\.css$/.test(module); - var node = document.createElement(iscss ? 'link' : 'script'); - var id = module.replace(/\.|\//g, ''); - if (iscss) { - node.setAttribute('type', 'text/css'); - node.setAttribute('rel', 'stylesheet'); - } - node.setAttribute((iscss ? 'href' : 'src'), layer.path + module); - node.setAttribute('id', id); - if (!$('#' + id)[0]) { - head.appendChild(node); - } - $(node).ready(function () { - callback && callback(); - }); - }, - ready: function (callback) { - return layer.use('skin/layer.css', callback); - }, - //普通对话框,类似系统默认的alert() - alert: function (alertMsg, alertType, alertTit, alertYes) { - return $.layer({ - dialog: {msg: alertMsg, type: alertType, yes: alertYes}, - title: alertTit, - area: ['auto', 'auto'] - }); - }, - //询问框,类似系统默认的confirm() - confirm: function (conMsg, conYes, conTit, conNo) { - return $.layer({ - dialog: {msg: conMsg, type: 4, btns: 2, yes: conYes, no: conNo}, - title: conTit - }); - }, - //普通消息框,一般用于行为成功后的提醒,默认两秒自动关闭 - msg: function (msgText, msgTime, parme, callback) { - var icon, conf = {title: false, closeBtn: false}; - (msgText == '' || msgText == undefined) && (msgText = ' '); - msgTime === undefined && (msgTime = 2); - if (typeof parme === 'number') { - icon = parme; - } else { - parme = parme || {}; - icon = parme.type; - conf.success = function () { - layer.shift(parme.rate) - }; - conf.shade = parme.shade; - } - conf.time = msgTime; - conf.dialog = {msg: msgText, type: icon}; - conf.end = typeof parme === 'function' ? parme : callback; - return $.layer(conf); - }, - //加载层快捷引用 - load: function (parme, loadIcon) { - if (typeof parme === 'string') { - return this.msg(parme, 0, 16); - } else { - return $.layer({ - time: parme, - loading: {type: loadIcon}, - bgcolor: !loadIcon ? '' : '#fff', - shade: [0.1, '#000', !loadIcon ? false : true], - border: [7, 0.3, '#000', (loadIcon === 3 || !loadIcon) ? false : true], - type: 3, - title: ['', false], - closeBtn: [0, false] - }); - } - }, - //tips层快捷引用 - // pakey 改 后面参数改为end函数回调 - tips: function (html, follow, parme, end) { - var conf = { - type: 4, shade: false, success: function (layerE) { - if (!this.closeBtn) { - layerE.find('.xubox_tips').css({'padding-right': 10}); - } - }, bgcolor: '', tips: {msg: html, follow: follow} - }; - parme = parme || {}; - conf.time = parme.time || parme; - conf.closeBtn = parme.closeBtn || false - conf.maxWidth = parme.maxWidth || maxWidth; - conf.tips.guide = parme.guide || guide; - conf.tips.style = parme.style || style; - if ($.isFunction(end)) { - conf.end = end; - } - return $.layer(conf); - } - }; - var Class = function (setings) { - var config = this.config; - layer.index++; - this.index = layer.index; - this.config = $.extend({}, config, setings); - this.config.dialog = $.extend({}, config.dialog, setings.dialog); - this.config.page = $.extend({}, config.page, setings.page); - this.config.iframe = $.extend({}, config.iframe, setings.iframe); - this.config.loading = $.extend({}, config.loading, setings.loading); - this.config.tips = $.extend({}, config.tips, setings.tips); - this.creat(); - }; - Class.pt = Class.prototype; -//默认配置 - Class.pt.config = { - type: 0, - shade: [0.3, '#000', true], - shadeClose: false, - fix: true, - move: ['.xubox_title', true], - moveOut: false, - title: ['温馨提示', true], - offset: ['200px', '50%'], - area: ['310px', 'auto'], - closeBtn: [0, true], - time: 0, - bgcolor: '#fff', - border: [8, 0.3, '#000', true], - zIndex: 19891014, - maxWidth: 400, - dialog: { - btns: 1, btn: ['确定', '取消'], type: 3, msg: '', yes: function (index) { - layer.close(index); - }, no: function (index) { - layer.close(index); - } - }, - page: {dom: '#xulayer', html: '', url: ''}, - iframe: {src: 'http://sentsin.com'}, - loading: {type: 0}, - tips: {msg: '', follow: '', guide: 0, isGuide: true, style: ['background-color:#FF9900; color:#fff;', '#FF9900']}, - success: function (layer) { - }, //创建成功后的回调 - close: function (index) { - layer.close(index); - }, //右上角关闭回调 - end: function () { - } //终极销毁回调 - }; - Class.pt.type = ['dialog', 'page', 'iframe', 'loading', 'tips']; -//容器 - Class.pt.space = function (html) { - var html = html || '', times = this.index, config = this.config, dialog = config.dialog, dom = this.dom, - ico = dialog.type === -1 ? '' : '', - frame = [ - '
' + ico + '' + dialog.msg + '
', - '
' + html + '
', - '', - '', - '
' + config.tips.msg + '
' - ], - shade = '', border = '', zIndex = config.zIndex + times, - shadeStyle = 'z-index:' + zIndex + '; background-color:' + config.shade[1] + '; opacity:' + config.shade[0] + '; filter:alpha(opacity=' + config.shade[0] * 100 + ');'; - config.shade[2] && (shade = '
'); - config.zIndex = zIndex; - var title = '', closebtn = '', borderStyle = "z-index:" + (zIndex - 1) + "; background-color: " + config.border[2] + "; opacity:" + config.border[1] + "; filter:alpha(opacity=" + config.border[1] * 100 + "); top:-" + config.border[0] + "px; left:-" + config.border[0] + "px;"; - config.border[3] && (border = '
'); - config.closeBtn[1] && (closebtn = ''); - config.title[1] && (title = '

' + config.title[0] + '

') - var boxhtml = '
' - + '
' - + frame[config.type] - + title - + closebtn - + '' - + '
' + border + '
'; - return [shade, boxhtml]; - }; -//缓存字符 - Class.pt.dom = { - lay: 'xubox_layer', - ifr: 'xubox_iframe' - }; -//创建骨架 - Class.pt.creat = function () { - var that = this, space = '', config = this.config, dialog = config.dialog, title = that.config.title, dom = that.dom, times = that.index; - ; - title.constructor === Array || (that.config.title = [title, true]); - title === false && (that.config.title = [title, false]); - var page = config.page, body = $("body"), setSpace = function (html) { - var html = html || '' - space = that.space(html); - body.append(space[0]); - }; - switch (config.type) { - case 1: - if (page.html !== '') { - setSpace('
' + page.html + '
'); - body.append(space[1]); - } else if (page.url !== '') { - setSpace('
' + page.html + '
'); - body.append(space[1]); - $.get(page.url, function (datas) { - $('#xuboxPageHtml' + times).html(datas.toString()); - page.ok && page.ok(datas); - }); - } else { - if ($(page.dom).parents('.xubox_page').length == 0) { - setSpace(); - $(page.dom).show().wrap(space[1]); - } else { - return; - } - } - break; - case 2: - setSpace(); - body.append(space[1]); - break; - case 3: - config.title = ['', false]; - config.area = ['auto', 'auto']; - config.closeBtn = ['', false]; - $('.xubox_loading')[0] && layer.close($('.xubox_loading').parents('.' + dom.lay).attr('times')); - setSpace(); - body.append(space[1]); - break; - case 4: - config.title = ['', false]; - config.area = ['auto', 'auto']; - config.fix = false; - config.border = false; - $('.xubox_tips')[0] && layer.close($('.xubox_tips').parents('.' + dom.lay).attr('times')); - setSpace(); - body.append(space[1]); - $('#' + dom.lay + times).find('.xubox_close').css({top: 6, right: 7}); - break; - default: - config.title[1] || (config.area = ['auto', 'auto']); - $('.xubox_dialog')[0] && layer.close($('.xubox_dialog').parents('.' + dom.lay).attr('times')); - setSpace(); - body.append(space[1]); - break; - } - ; - this.layerS = $('#xubox_shade' + times); - this.layerB = $('#xubox_border' + times); - this.layerE = $('#' + dom.lay + times); - var layerE = this.layerE; - this.layerMian = layerE.find('.xubox_main'); - this.layerTitle = layerE.find('.xubox_title'); - this.layerText = layerE.find('.xubox_text'); - this.layerPage = layerE.find('.xubox_page'); - this.layerBtn = layerE.find('.xubox_botton'); - //设置layer面积坐标等数据 - if (config.offset[1].indexOf("px") != -1) { - var _left = parseInt(config.offset[1]); - } else { - if (config.offset[1] == '50%') { - var _left = config.offset[1]; - } else { - var _left = parseInt(config.offset[1]) / 100 * win.width(); - } - } - ; - layerE.css({left: _left + config.border[0], width: config.area[0], height: config.area[1]}); - config.fix ? layerE.css({top: parseInt(config.offset[0]) + config.border[0]}) : layerE.css({top: parseInt(config.offset[0]) + win.scrollTop() + config.border[0], position: 'absolute'}); - //配置按钮 - if (config.title[1] && (config.type !== 3 || config.type !== 4)) { - var confbtn = config.type === 0 ? dialog : config; - confbtn.btn = config.btn || dialog.btn; - switch (confbtn.btns) { - case 0: - that.layerBtn.html('').hide(); - break; - case 1: - that.layerBtn.html('' + confbtn.btn[0] + ''); - break; - case 2: - that.layerBtn.html('' + confbtn.btn[0] + '' + '' + confbtn.btn[1] + ''); - break; - } - } - if (layerE.css('left') === 'auto') { - layerE.hide(); - setTimeout(function () { - layerE.show(); - that.set(times); - }, 500); - } else { - that.set(times); - } - config.time <= 0 || that.autoclose(); - this.callback(); - }; -//初始化骨架 - Class.pt.set = function (times) { - var that = this, layerE = that.layerE, config = that.config, dialog = config.dialog, page = config.page, loading = config.loading, dom = that.dom; - that.autoArea(times); - if (config.title[1]) { - layer.ie6 && that.layerTitle.css({width: layerE.outerWidth()}); - } else { - config.type != 4 && layerE.find('.xubox_close').addClass('xubox_close1'); - } - ; - layerE.attr({'type': that.type[config.type]}); - switch (config.type) { - case 1: - layerE.find(page.dom).addClass('layer_pageContent'); - config.shade[2] && layerE.css({zIndex: config.zIndex + 1}); - config.title[1] && that.layerPage.css({top: that.layerTitle.outerHeight()}); - break; - case 2: - var iframe = layerE.find('.' + dom.ifr), heg = layerE.height(); - iframe.addClass('xubox_load').css({width: layerE.width()}); - config.title[1] ? iframe.css({top: that.layerTitle.height(), height: heg - that.layerTitle.height()}) : iframe.css({top: 0, height: heg}); - layer.ie6 && iframe.attr('src', config.iframe.src); - break; - case 3: - break; - case 4 : - var layArea = [0, layerE.outerHeight()], fow = $(config.tips.follow), fowo = { - width: fow.outerWidth(), - height: fow.outerHeight(), - top: fow.offset().top, - left: fow.offset().left - }, tipsG = layerE.find('.layerTipsG'); - config.tips.isGuide || tipsG.remove(); - layerE.outerWidth() > config.maxWidth && layerE.width(config.maxWidth); - fowo.tipColor = config.tips.style[1]; - layArea[0] = layerE.outerWidth(); - //辨别tips的方位 - fowo.where = [function () { //上 - fowo.tipLeft = fowo.left; - fowo.tipTop = fowo.top - layArea[1] - 10; - tipsG.removeClass('layerTipsB').addClass('layerTipsT').css({'border-right-color': fowo.tipColor}); - }, function () { //右 - fowo.tipLeft = fowo.left + fowo.width + 10; - fowo.tipTop = fowo.top; - tipsG.removeClass('layerTipsL').addClass('layerTipsR').css({'border-bottom-color': fowo.tipColor}); - }, function () { //下 - fowo.tipLeft = fowo.left; - fowo.tipTop = fowo.top + fowo.height + 10; - tipsG.removeClass('layerTipsT').addClass('layerTipsB').css({'border-right-color': fowo.tipColor}); - }, function () { //左 - fowo.tipLeft = fowo.left - layArea[0] + 10; - fowo.tipTop = fowo.top; - tipsG.removeClass('layerTipsR').addClass('layerTipsL').css({'border-bottom-color': fowo.tipColor}); - }]; - fowo.where[config.tips.guide](); - /* 8*2为小三角形占据的空间 */ - if (config.tips.guide === 0) { - fowo.top - (win.scrollTop() + layArea[1] + 8 * 2) < 0 && fowo.where[2](); - } else if (config.tips.guide === 1) { - win.width() - (fowo.left + fowo.width + layArea[0] + 8 * 2) > 0 || fowo.where[3]() - } else if (config.tips.guide === 2) { - (fowo.top - win.scrollTop() + fowo.height + layArea[1] + 8 * 2) - win.height() > 0 && fowo.where[0](); - } else if (config.tips.guide === 3) { - layArea[0] + 8 * 2 - fowo.left > 0 && fowo.where[1]() - } - layerE.css({left: fowo.tipLeft, top: fowo.tipTop}); - break; - default: - that.layerMian.css({'background-color': '#fff'}); - if (config.title[1]) { - that.layerText.css({paddingTop: 18 + that.layerTitle.outerHeight()}); - } else { - layerE.find('.xubox_msgico').css({top: 8}); - that.layerText.css({marginTop: 11}); - } - break; - } - ; - config.fadeIn && layerE.css({opacity: 0}).animate({opacity: 1}, config.fadeIn); - that.move(); - }; -//自适应宽高 - Class.pt.autoArea = function (times) { - var that = this, layerE = that.layerE, config = that.config, page = config.page, - layerMian = that.layerMian, layerBtn = that.layerBtn, layerText = that.layerText, - layerPage = that.layerPage, layerB = that.layerB, titHeight, outHeight, btnHeight = 0, - load = $(".xubox_loading"); - if (config.area[0] === 'auto' && layerMian.outerWidth() >= config.maxWidth) { - layerE.css({width: config.maxWidth}); - } - config.title[1] ? titHeight = that.layerTitle.innerHeight() : titHeight = 0; - switch (config.type) { - case 0: - var aBtn = layerBtn.find('a'); - outHeight = layerText.outerHeight() + 20; - if (aBtn.length > 0) { - btnHeight = aBtn.outerHeight() + 20; - } - break; - case 1: - outHeight = $(page.dom).outerHeight(); - config.area[0] === 'auto' && layerE.css({width: layerPage.outerWidth()}); - if (page.html !== '' || page.url !== '') { - outHeight = layerPage.outerHeight(); - } - break; - case 3: - outHeight = load.outerHeight(); - layerMian.css({width: load.width()}); - break; - } - ; - (config.area[1] === 'auto') && layerMian.css({height: titHeight + outHeight + btnHeight}); - layerB.css({width: layerE.outerWidth() + 2 * config.border[0], height: layerE.outerHeight() + 2 * config.border[0]}); - (layer.ie6 && config.area[0] != 'auto') && layerMian.css({width: layerE.outerWidth()}); - (config.offset[1] === '50%' || config.offset[1] == '') && (config.type !== 4) ? layerE.css({marginLeft: -layerE.outerWidth() / 2}) : layerE.css({marginLeft: 0}); - }; -//拖拽层 - Class.pt.move = function () { - var that = this, config = this.config, dom = that.dom, conf = { - setY: 0, - moveLayer: function () { - if (parseInt(conf.layerE.css('margin-left')) == 0) { - var lefts = parseInt(conf.move.css('left')); - } else { - var lefts = parseInt(conf.move.css('left')) + (-parseInt(conf.layerE.css('margin-left'))) - } - if (conf.layerE.css('position') !== 'fixed') { - lefts = lefts - conf.layerE.parent().offset().left; - conf.setY = 0 - } - conf.layerE.css({left: lefts, top: parseInt(conf.move.css('top')) - conf.setY}); - } - }; - config.move[1] && that.layerE.find(config.move[0]).attr('move', 'ok'); - config.move[1] ? that.layerE.find(config.move[0]).css({cursor: 'move'}) : that.layerE.find(config.move[0]).css({cursor: 'auto'}); - $(config.move[0]).on('mousedown', function (M) { - M.preventDefault(); - if ($(this).attr('move') === 'ok') { - conf.ismove = true; - conf.layerE = $(this).parents('.' + dom.lay); - var xx = conf.layerE.offset().left, yy = conf.layerE.offset().top, ww = conf.layerE.width() - 6, hh = conf.layerE.height() - 6; - if (!$('#xubox_moves')[0]) { - $('body').append('
'); - } - conf.move = $('#xubox_moves'); - config.moveType && conf.move.css({opacity: 0}); - conf.moveX = M.pageX - conf.move.position().left; - conf.moveY = M.pageY - conf.move.position().top; - conf.layerE.css('position') !== 'fixed' || (conf.setY = win.scrollTop()); - } - }); - $(document).mousemove(function (M) { - if (conf.ismove) { - var offsetX = M.pageX - conf.moveX, offsetY = M.pageY - conf.moveY; - M.preventDefault(); - //控制元素不被拖出窗口外 - if (!config.moveOut) { - conf.setY = win.scrollTop(); - var setRig = win.width() - conf.move.outerWidth() - config.border[0], setTop = config.border[0] + conf.setY; - offsetX < config.border[0] && (offsetX = config.border[0]); - offsetX > setRig && (offsetX = setRig); - offsetY < setTop && (offsetY = setTop); - offsetY > win.height() - conf.move.outerHeight() - config.border[0] + conf.setY && (offsetY = win.height() - conf.move.outerHeight() - config.border[0] + conf.setY); - } - conf.move.css({left: offsetX, top: offsetY}); - config.moveType && conf.moveLayer(); - offsetX = null; - offsetY = null; - setRig = null; - setTop = null - } - }).mouseup(function () { - try { - if (conf.ismove) { - conf.moveLayer(); - conf.move.remove(); - } - conf.ismove = false; - } catch (e) { - conf.ismove = false; - } - config.moveEnd && config.moveEnd(); - }); - }; -//自动关闭layer - Class.pt.autoclose = function () { - var that = this, time = this.config.time, maxLoad = function () { - time--; - if (time === 0) { - layer.close(that.index); - clearInterval(that.autotime); - } - }; - this.autotime = setInterval(maxLoad, 1000); - }; - ready.config = { - end: {} - }; - Class.pt.callback = function () { - var that = this, layerE = that.layerE, config = that.config, dialog = config.dialog; - that.openLayer(); - that.config.success(layerE); - layer.ie6 && that.IE6(); - layerE.find('.xubox_close').off('click').on('click', function (e) { - e.preventDefault(); - config.close(that.index); - }); - layerE.find('.xubox_yes').off('click').on('click', function (e) { - e.preventDefault(); - config.yes ? config.yes(that.index) : dialog.yes(that.index); - }); - layerE.find('.xubox_no').off('click').on('click', function (e) { - e.preventDefault(); - config.no ? config.no(that.index) : dialog.no(that.index); - }); - this.layerS.off('click').on('click', function (e) { - e.preventDefault(); - that.config.shadeClose && layer.close(that.index); - }); - ready.config.end[that.index] = config.end; - }; - Class.pt.IE6 = function () { - var that = this, layerE = that.layerE, select = $('select'), dom = that.dom; - var _ieTop = layerE.offset().top; - //ie6的固定与相对定位 - if (that.config.fix) { - var ie6Fix = function () { - layerE.css({top: $(document).scrollTop() + _ieTop}); - }; - } else { - var ie6Fix = function () { - layerE.css({top: _ieTop}); - }; - } - ie6Fix(); - win.scroll(ie6Fix); - //隐藏select - $.each(select, function (index, value) { - var sthis = $(this); - if (!sthis.parents('.' + dom.lay)[0]) { - sthis.css('display') == 'none' || sthis.attr({'layer': '1'}).hide(); - } - sthis = null; - }); - //恢复select - that.reselect = function () { - $.each(select, function (index, value) { - var sthis = $(this); - if (!sthis.parents('.' + dom.lay)[0]) { - (sthis.attr('layer') == 1 && $('.' + dom.lay).length < 1) && sthis.removeAttr('layer').show(); - } - sthis = null; - }); - }; - }; -//给layer对象拓展方法 - Class.pt.openLayer = function () { - var that = this, dom = that.dom; - //自适应宽高 - layer.autoArea = function (index) { - return that.autoArea(index); - }; - //获取layer当前索引 - layer.getIndex = function (selector) { - return $(selector).parents('.' + dom.lay).attr('times'); - }; - //获取子iframe的DOM - layer.getChildFrame = function (selector, index) { - index = index || $('.' + dom.ifr).parents('.' + dom.lay).attr('times'); - return $('#' + dom.lay + index).find('.' + dom.ifr).contents().find(selector); - }; - //得到当前iframe层的索引,子iframe时使用 - layer.getFrameIndex = function (name) { - return $(name ? '#' + name : '.' + dom.ifr).parents('.' + dom.lay).attr('times'); - }; - //iframe层自适应宽高 - layer.iframeAuto = function (index) { - index = index || $('.' + dom.ifr).parents('.' + dom.lay).attr('times'); - var heg = this.getChildFrame('body', index).outerHeight(), - lbox = $('#' + dom.lay + index), tit = lbox.find('.xubox_title'), titHt = 0; - !tit || (titHt = tit.height()); - lbox.css({height: heg + titHt}); - var bs = -parseInt($('#xubox_border' + index).css('top')); - $('#xubox_border' + index).css({height: heg + 2 * bs + titHt}); - $('#' + dom.ifr + index).css({height: heg}); - }; - //关闭layer - layer.close = function (index) { - var layerNow = $('#' + dom.lay + index), shadeNow = $('#xubox_moves, #xubox_shade' + index); - if (layerNow.attr('type') == that.type[1]) { - if (layerNow.find('.xuboxPageHtml')[0]) { - layerNow.remove(); - } else { - layerNow.find('.xubox_close,.xubox_botton,.xubox_title,.xubox_border').remove(); - for (var i = 0; i < 3; i++) { - layerNow.find('.layer_pageContent').unwrap().hide(); - } - } - } else { - document.all && layerNow.find('#' + dom.ifr + index).remove(); - layerNow.remove(); - } - shadeNow.remove(); - layer.ie6 && that.reselect(); - typeof ready.config.end[index] === 'function' && ready.config.end[index](); - delete ready.config.end[index]; - }; - //关闭加载层 - layer.loadClose = function () { - var parent = $('.xubox_loading').parents('.' + dom.lay), - index = parent.attr('times'); - layer.close(index); - }; - //出场内置动画 - layer.shift = function (type, rate) { - var config = that.config, iE6 = layer.ie6, layerE = that.layerE, cutWth = 0, ww = win.width(), wh = win.height(); - (config.offset[1] == '50%' || config.offset[1] == '') ? cutWth = layerE.outerWidth() / 2 : cutWth = layerE.outerWidth(); - var anim = { - t: {top: 50 + config.border[0]}, - b: {top: wh - layerE.outerHeight() - config.border[0]}, - cl: cutWth + config.border[0], - ct: -layerE.outerHeight(), - cr: ww - cutWth - config.border[0], - fn: function () { - iE6 && that.IE6(); - } - }; - switch (type) { - case 'left-top': - layerE.css({left: anim.cl, top: anim.ct}).animate(anim.t, rate, anim.fn); - break; - case 'top': - layerE.css({top: anim.ct}).animate(anim.t, rate, anim.fn); - break; - case 'right-top': - layerE.css({left: anim.cr, top: anim.ct}).animate(anim.t, rate, anim.fn); - break; - case 'right-bottom': - layerE.css({left: anim.cr, top: wh}).animate(anim.b, rate, anim.fn); - break; - case 'bottom': - layerE.css({top: wh}).animate(anim.b, rate, anim.fn); - break; - case 'left-bottom': - layerE.css({left: anim.cl, top: wh}).animate(anim.b, rate, anim.fn); - break; - case 'left': - layerE.css({left: -layerE.outerWidth(), marginLeft: 0}).animate({left: anim.t.top}, rate, anim.fn); - break; - } - ; - }; - //初始化拖拽元素 - layer.setMove = function () { - return that.move(); - }; - //给指定层重置属性 - layer.area = function (index, options) { - var nowobect = [$('#' + dom.lay + index), $('#xubox_border' + index)], - type = nowobect[0].attr('type'), main = nowobect[0].find('.xubox_main'), - title = nowobect[0].find('.xubox_title'); - if (type === that.type[1] || type === that.type[2]) { - nowobect[0].css(options); - main.css({height: options.height}); - if (type === that.type[2]) { - var iframe = nowobect[0].find('iframe'); - iframe.css({width: options.width, height: title ? options.height - title.outerHeight() : options.height}); - } - if (nowobect[0].css('margin-left') !== '0px') { - options.hasOwnProperty('top') && nowobect[0].css({top: options.top - (nowobect[1][0] && parseInt(nowobect[1].css('top')))}); - options.hasOwnProperty('left') && nowobect[0].css({left: options.left + nowobect[0].outerWidth() / 2 - (nowobect[1][0] && parseInt(nowobect[1].css('left')))}) - nowobect[0].css({marginLeft: -nowobect[0].outerWidth() / 2}); - } - if (nowobect[1][0]) { - nowobect[1].css({ - width: parseFloat(options.width) - 2 * parseInt(nowobect[1].css('left')), - height: parseFloat(options.height) - 2 * parseInt(nowobect[1].css('top')) - }); - } - } - }; - //关闭所有层 - layer.closeAll = function () { - var layerObj = $('.' + dom.lay); - $.each(layerObj, function () { - var i = $(this).attr('times'); - layer.close(i); - }); - }; - //关闭tips层 - layer.closeTips = function () { - var tips = $('.xubox_tips'); - if (tips[0]) { - layer.close(tips.parents('.xubox_layer').attr('times')); - } - }; - //重置iframe url - layer.iframeSrc = function (index, url) { - $('#' + dom.lay + index).find('iframe').attr('src', url); - }; - //置顶当前窗口 - layer.zIndex = that.config.zIndex; - layer.setTop = function (layerNow) { - var setZindex = function () { - layer.zIndex++; - layerNow.css('z-index', layer.zIndex + 1); - }; - layer.zIndex = parseInt(layerNow[0].style.zIndex); - layerNow.on('mousedown', setZindex); - return layer.zIndex; - }; - }; -//主入口 - ready.run = function () { - $ = jQuery; - win = $(window); - layer.use('skin/layer.css'); - $.layer = function (deliver) { - var o = new Class(deliver); - return o.index; - }; - }; -//为支持CMD规范的模块加载器 - var require = '../../init/jquery'; //若采用seajs,需正确配置jquery的相对路径。未用可无视此处。 - if (window.seajs) { - define([require], function (require, exports, module) { - ready.run(); - exports.layer = [window.layer, window['$'].layer]; - }); - } else { - ready.run(); - } -}(window); \ No newline at end of file diff --git a/public/plugin/layer/skin/default/Thumbs.db b/public/plugin/layer/skin/default/Thumbs.db deleted file mode 100644 index 69b55dc..0000000 Binary files a/public/plugin/layer/skin/default/Thumbs.db and /dev/null differ diff --git a/public/plugin/layer/skin/default/textbg.png b/public/plugin/layer/skin/default/textbg.png deleted file mode 100644 index ad1040c..0000000 Binary files a/public/plugin/layer/skin/default/textbg.png and /dev/null differ diff --git a/public/plugin/layer/skin/default/xubox_ico0.png b/public/plugin/layer/skin/default/xubox_ico0.png deleted file mode 100644 index eed069e..0000000 Binary files a/public/plugin/layer/skin/default/xubox_ico0.png and /dev/null differ diff --git a/public/plugin/layer/skin/default/xubox_loading0.gif b/public/plugin/layer/skin/default/xubox_loading0.gif deleted file mode 100644 index 6f3c953..0000000 Binary files a/public/plugin/layer/skin/default/xubox_loading0.gif and /dev/null differ diff --git a/public/plugin/layer/skin/default/xubox_loading1.gif b/public/plugin/layer/skin/default/xubox_loading1.gif deleted file mode 100644 index db3a483..0000000 Binary files a/public/plugin/layer/skin/default/xubox_loading1.gif and /dev/null differ diff --git a/public/plugin/layer/skin/default/xubox_loading2.gif b/public/plugin/layer/skin/default/xubox_loading2.gif deleted file mode 100644 index 5bb90fd..0000000 Binary files a/public/plugin/layer/skin/default/xubox_loading2.gif and /dev/null differ diff --git a/public/plugin/layer/skin/default/xubox_loading3.gif b/public/plugin/layer/skin/default/xubox_loading3.gif deleted file mode 100644 index fbe57be..0000000 Binary files a/public/plugin/layer/skin/default/xubox_loading3.gif and /dev/null differ diff --git a/public/plugin/layer/skin/default/xubox_title0.png b/public/plugin/layer/skin/default/xubox_title0.png deleted file mode 100644 index 4ffbe31..0000000 Binary files a/public/plugin/layer/skin/default/xubox_title0.png and /dev/null differ diff --git a/public/plugin/layer/skin/layer.css b/public/plugin/layer/skin/layer.css deleted file mode 100644 index 478be98..0000000 --- a/public/plugin/layer/skin/layer.css +++ /dev/null @@ -1,58 +0,0 @@ -body, div, dl, dt, dd, ul, ol, li, h1, h2, h3, h4, h5, h6, input, button, textarea, p, blockquote, th, td, form { margin: 0; padding: 0 } -* html { background-image: url(about:blank); background-attachment: fixed } -.xubox_shade, .xubox_layer { position: fixed; _position: absolute } -.xubox_shade { top: 0; left: 0; width: 100%; height: 100%; _height: expression(document.body.offsetHeight+"px") } -.xubox_layer { top: 150px; left: 50%; height: auto; width: 310px; margin-left: -155px } -.xubox_border, .xubox_title, .xubox_title i, .xubox_page, .xubox_iframe, .xubox_title em, .xubox_close, .xubox_msgico, .xubox_moves { position: absolute } -.xubox_border { border-radius: 5px } -.xubox_title { left: 0; top: 0 } -.xubox_main { position: relative; height: 100%; _float: left } -.xubox_page { top: 0; left: 0 } -.xubox_load { background: url(default/xubox_loading0.gif) #fff center center no-repeat } -.xubox_loading { display: block; float: left; text-decoration: none; color: #FFF; _float: none } -.xulayer_png32 { background: url(default/xubox_ico0.png) no-repeat } -.xubox_moves { border: 3px solid #333; cursor: move; opacity: .7; filter: alpha(opacity=70) } -.xubox_msgico { width: 32px; height: 32px; top: 52px; left: 15px; background: url(default/xubox_ico0.png) no-repeat } -.xubox_text { padding-left: 55px; float: left; line-height: 25px; word-break: break-all; padding-right: 20px; overflow: hidden; font-size: 14px } -.xubox_msgtype0 { background-position: -91px -38px } -.xubox_msgtype1 { background-position: -128px -38px } -.xubox_msgtype2 { background-position: -163px -38px } -.xubox_msgtype3 { background-position: -91px -75px } -.xubox_msgtype4 { background-position: -163px -75px } -.xubox_msgtype5 { background-position: -163px -112px } -.xubox_msgtype6 { background-position: -163px -148px } -.xubox_msgtype7 { background-position: -128px -75px } -.xubox_msgtype8 { background-position: -91px -6px } -.xubox_msgtype9 { background-position: -129px -6px } -.xubox_msgtype10 { background-position: -163px -6px } -.xubox_msgtype11 { background-position: -206px -6px } -.xubox_msgtype12 { background-position: -206px -44px } -.xubox_msgtype13 { background-position: -206px -81px } -.xubox_msgtype14 { background-position: -206px -122px } -.xubox_msgtype15 { background-position: -206px -157px } -.xubox_loading_0 { width: 60px; height: 24px; background: url(default/xubox_loading0.gif) no-repeat } -.xubox_loading_1 { width: 37px; height: 37px; background: url(default/xubox_loading1.gif) no-repeat } -.xubox_loading_2, .xubox_msgtype16 { width: 32px; height: 32px; background: url(default/xubox_loading2.gif) no-repeat } -.xubox_loading_3 { width: 126px; height: 22px; background: url(default/xubox_loading3.gif) no-repeat } -.xubox_title { width: 100%; height: 35px; line-height: 35px; border-bottom: 1px solid #d5d5d5; background: url(default/xubox_title0.png) #ebebeb repeat-x; cursor: move; font-size: 14px; color: #333 } -.xubox_title em { display: block; height: 20px; line-height: 20px; width: 80%; top: 9px; left: 10px; font-style: normal; overflow: hidden } -.xubox_close0 { right: 10px; top: 10px; width: 14px; height: 14px; background-position: -31px -7px; cursor: pointer; overflow: hidden } -.xubox_close0:hover { background-position: -51px -7px } -.xubox_close1 { right: -20px; top: -21px; width: 34px; height: 30px; background-position: -5px -252px; cursor: pointer; overflow: hidden; _right: 3px; _top: 3px; _width: 14px; _height: 14px; _background-position: -31px -7px } -.xubox_close1:hover { background-position: -44px -252px; _background-position: -51px -7px } -.xubox_botton a { position: absolute; bottom: 10px; left: 50%; background: url(default/xubox_ico0.png) repeat; text-decoration: none; color: #FFF; font-size: 14px; text-align: center; font-weight: bold; overflow: hidden } -.xubox_botton a:hover { text-decoration: none; color: #FFF } -.xubox_botton .xubox_botton1 { width: 79px; height: 32px; line-height: 32px; margin-left: -39px; background-position: -6px -34px } -.xubox_botton1:hover { background-position: -6px -72px } -.xubox_botton .xubox_botton2 { margin-left: -76px; width: 71px; height: 29px; line-height: 29px; background-position: -5px -114px } -.xubox_botton2:hover { background-position: -5px -146px } -.xubox_botton .xubox_botton3 { width: 71px; height: 29px; line-height: 29px; margin-left: 10px; background-position: -81px -114px } -.xubox_botton3:hover { background-position: -81px -146px } -.xubox_tips { position: relative; line-height: 20px; padding: 3px 30px 3px 10px; font-size: 12px; _float: left; border-radius: 3px; box-shadow: 1px 1px 3px rgba(0, 0, 0, .3) } -.xubox_tips i.layerTipsG { position: absolute; width: 0; height: 0; border-width: 8px; border-color: transparent; border-style: dashed; *overflow: hidden } -.xubox_tips i.layerTipsT, .xubox_tips i.layerTipsB { left: 5px; border-right-style: solid } -.xubox_tips i.layerTipsT { bottom: -8px } -.xubox_tips i.layerTipsB { top: -8px } -.xubox_tips i.layerTipsR, .xubox_tips i.layerTipsL { top: 1px; border-bottom-style: solid } -.xubox_tips i.layerTipsR { left: -8px } -.xubox_tips i.layerTipsL { right: -8px } diff --git a/public/plugin/layer/skin/layer.ext.css b/public/plugin/layer/skin/layer.ext.css deleted file mode 100644 index 9d0dd47..0000000 --- a/public/plugin/layer/skin/layer.ext.css +++ /dev/null @@ -1,22 +0,0 @@ -/** - - @Name: layer拓展样式 - @Date: 2012.12.13 - @Author: 贤心 - @blog: sentsin.com - -**/ - -/* prompt模式 */ -.xubox_layer .xubox_form { width: 240px; line-height: 30px; padding: 0 5px; border: 1px solid #ccc; background: url(default/textbg.png) #fff repeat-x; color: #333; } -.xubox_layer .xubox_formArea { width: 300px; height: 100px; line-height: 20px; } -/* tab模式 */ -.xubox_layer .xubox_tab { position: relative; border: 1px solid #ccc; } -.xubox_layer .xubox_tabmove { position: absolute; width: 600px; height: 30px; top: 0; left: 0; } -.xubox_layer .xubox_tabtit { display: block; height: 30px; border-bottom: 1px solid #ccc; background-color: #eee; } -.xubox_layer .xubox_tabtit span { position: relative; float: left; width: 120px; height: 30px; line-height: 30px; text-align: center; cursor: pointer; } -.xubox_layer .xubox_tabtit span.xubox_tabnow { left: -1px; _top: 1px; height: 31px; border-left: 1px solid #ccc; border-right: 1px solid #ccc; background-color: #fff; z-index: 10; } -.xubox_layer .xubox_tab_main { line-height: 24px; clear: both; } -.xubox_layer .xubox_tab_main .xubox_tabli { display: none; } -.xubox_layer .xubox_tab_main .xubox_tabli.xubox_tab_layer { display: block; } -.xubox_layer .xubox_tabclose { position: absolute; right: 10px; top: 5px; cursor: pointer; } diff --git a/public/plugin/validator/change.txt b/public/plugin/validator/change.txt deleted file mode 100644 index e3881b6..0000000 --- a/public/plugin/validator/change.txt +++ /dev/null @@ -1 +0,0 @@ -remote增加tp ajax返回支持 \ No newline at end of file diff --git a/public/plugin/validator/images/loading.gif b/public/plugin/validator/images/loading.gif deleted file mode 100644 index 6e5bace..0000000 Binary files a/public/plugin/validator/images/loading.gif and /dev/null differ diff --git a/public/plugin/validator/images/validator_default.png b/public/plugin/validator/images/validator_default.png deleted file mode 100644 index 5a95640..0000000 Binary files a/public/plugin/validator/images/validator_default.png and /dev/null differ diff --git a/public/plugin/validator/images/validator_simple.png b/public/plugin/validator/images/validator_simple.png deleted file mode 100644 index 2470db5..0000000 Binary files a/public/plugin/validator/images/validator_simple.png and /dev/null differ diff --git a/public/plugin/validator/jquery.validator.css b/public/plugin/validator/jquery.validator.css deleted file mode 100644 index 82558a8..0000000 --- a/public/plugin/validator/jquery.validator.css +++ /dev/null @@ -1,64 +0,0 @@ -/*! nice Validator 0.7.0 - * (c) 2012-2014 Jony Zhang , MIT Licensed - * http://niceue.com/validator/ - */ -.n-inline-block, .nice-validator input, .nice-validator select, .nice-validator textarea, .msg-wrap, .n-icon, .n-msg { display: inline-block; *display: inline; *zoom: 1 } -.msg-box { position: relative; *zoom: 1 } -.msg-wrap { position: relative; white-space: nowrap } -.msg-wrap, .n-icon, .n-msg { vertical-align: top } -.n-arrow { position: absolute; overflow: hidden; } -.n-arrow b, .n-arrow i { position: absolute; left: 0; top: 0; border: 0; margin: 0; padding: 0; overflow: hidden; font-weight: 400; font-style: normal; font-size: 12px; font-family: serif; line-height: 14px; _line-height: 15px } -.n-arrow i { text-shadow: none } -.n-icon { width: 16px; height: 16px; overflow: hidden; background-repeat: no-repeat } -.n-msg { display: inline-block; line-height: 15px; margin-left: 2px; *margin-top: -1px; _margin-top: 0; font-size: 12px; font-family: simsun } -.n-error { color: #c33 } -.n-ok { color: #390 } -.n-tip, .n-loading { color: #808080 } -.n-error .n-icon { background-position: 0 0 } -.n-ok .n-icon { background-position: -16px 0 } -.n-tip .n-icon { background-position: -32px 0 } -.n-loading .n-icon { background: url("images/loading.gif") 0 center no-repeat !important } -.n-top, .n-right, .n-bottom, .n-left { display: inline-block; line-height: 0; vertical-align: top; outline: 0 } -.n-top .n-arrow, .n-bottom .n-arrow { height: 6px; width: 12px; left: 8px } -.n-left .n-arrow, .n-right .n-arrow { width: 6px; height: 12px; top: 6px } -.n-top { vertical-align: top; } -.n-top .msg-wrap { margin-bottom: 6px } -.n-top .n-arrow { bottom: -6px; } -.n-top .n-arrow b { top: -6px } -.n-top .n-arrow i { top: -7px } -.n-bottom { vertical-align: bottom; } -.n-bottom .msg-wrap { margin-top: 6px } -.n-bottom .n-arrow { top: -6px; } -.n-bottom .n-arrow b { top: -1px } -.n-bottom .n-arrow i { top: 0 } -.n-left .msg-wrap { right: 100%; margin-right: 6px } -.n-left .n-arrow { right: -6px; } -.n-left .n-arrow b { left: -6px } -.n-left .n-arrow i { left: -7px } -.n-right .msg-wrap { margin-left: 6px } -.n-right .n-arrow { left: -6px; } -.n-right .n-arrow b { left: 1px } -.n-right .n-arrow i { left: 2px } -.n-default .n-left, .n-default .n-right { margin-top: 5px } -.n-default .n-top .msg-wrap { bottom: 100% } -.n-default .n-bottom .msg-wrap { top: 100% } -.n-default .msg-wrap { position: absolute; z-index: 1; } -.n-default .msg-wrap .n-icon { background-image: url("images/validator_default.png") } -.n-default .n-tip .n-icon { display: none } -.n-simple .msg-wrap { position: absolute; z-index: 1; } -.n-simple .msg-wrap .n-icon { background-image: url("images/validator_simple.png") } -.n-simple .n-top .msg-wrap { bottom: 100% } -.n-simple .n-bottom .msg-wrap { top: 100% } -.n-simple .n-left, .n-simple .n-right { margin-top: 5px } -.n-simple .n-bottom .msg-wrap { margin-top: 3px } -.n-simple .n-tip .n-icon { display: none } -.n-yellow .msg-wrap { position: absolute; z-index: 1; padding: 4px 6px; font-size: 12px; border: 1px solid transparent; background-color: #fffcef; border-color: #ffbb76; color: #db7c22; box-shadow: 0 1px 3px #ccc; border-radius: 2px; } -.n-yellow .msg-wrap .n-arrow b { color: #ffbb76; text-shadow: 0 0 2px #ccc } -.n-yellow .msg-wrap .n-arrow i { color: #fffcef } -.n-yellow .msg-wrap .n-icon { background-image: url("images/validator_simple.png") } -.n-yellow .n-top .msg-wrap { bottom: 100% } -.n-yellow .n-bottom .msg-wrap { top: 100% } -.n-yellow .n-tip, .n-yellow .n-ok, .n-yellow .n-loading { background-color: #f8fdff; border-color: #ddd; color: #333; box-shadow: 0 1px 3px #ccc; } -.n-yellow .n-tip .n-arrow b, .n-yellow .n-ok .n-arrow b, .n-yellow .n-loading .n-arrow b { color: #ddd; text-shadow: 0 0 2px #ccc } -.n-yellow .n-tip .n-arrow i, .n-yellow .n-ok .n-arrow i, .n-yellow .n-loading .n-arrow i { color: #f8fdff } -.n-yellow .n-tip .n-icon { display: none } diff --git a/public/plugin/validator/jquery.validator.js b/public/plugin/validator/jquery.validator.js deleted file mode 100644 index 510bb11..0000000 --- a/public/plugin/validator/jquery.validator.js +++ /dev/null @@ -1,1526 +0,0 @@ -/*! nice Validator 0.7.0 - * (c) 2012-2014 Jony Zhang , MIT Licensed - * http://niceue.com/validator/ - */ -/*jshint evil:true, expr:true */ -(function ($, undefined) { - "use strict"; - var NS = 'validator', - CLS_NS = '.' + NS, - CLS_NS_RULE = '.rule', - CLS_NS_FIELD = '.field', - CLS_NS_FORM = '.form', - CLS_WRAPPER = 'nice-' + NS, - CLS_MSG_OK = 'n-ok', - CLS_MSG_ERROR = 'n-error', - CLS_MSG_TIP = 'n-tip', - CLS_MSG_LOADING = 'n-loading', - CLS_MSG_BOX = 'msg-box', - ARIA_REQUIRED = 'aria-required', - ARIA_INVALID = 'aria-invalid', - DATA_RULE = 'data-rule', - DATA_MSG = 'data-msg', - DATA_TIP = 'data-tip', - DATA_OK = 'data-ok', - DATA_TARGET = 'data-target', - DATA_INPUT_STATUS = 'data-inputstatus', - NOVALIDATE = 'novalidate', - INPUT_SELECTOR = ':verifiable', - rRules = /(!?)\s?(\w+)(?:\[\s*(.*?\]?)\s*\]|\(\s*(.*?\)?)\s*\))?\s*(;|\||&)?/g, - rRule = /(\w+)(?:\[\s*(.*?\]?)\s*\]|\(\s*(.*?\)?)\s*\))?/, - rDisplay = /(?:([^:;\(\[]*):)?(.*)/, - rDoubleBytes = /[^\x00-\xff]/g, - rPos = /^.*(top|right|bottom|left).*$/, - rAjaxType = /(?:(post|get):)?(.+)/i, - rUnsafe = /<|>/g, - noop = $.noop, - proxy = $.proxy, - isFunction = $.isFunction, - isArray = $.isArray, - isString = function (s) { - return typeof s === 'string'; - }, - isObject = function (o) { - return o && Object.prototype.toString.call(o) === '[object Object]'; - }, - isIE6 = !window.XMLHttpRequest, - attr = function (el, key, value) { - if (value !== undefined) { - if (value === null) el.removeAttribute(key); - else el.setAttribute(key, '' + value); - } else { - return el.getAttribute(key); - } - }, - debug = window.console || { - log: noop, - info: noop - }, - novalidateonce, - defaults = { - debug: 0, - timely: 1, - theme: 'default', - ignore: '', - //stopOnError: false, - //focusCleanup: false, - focusInvalid: true, - beforeSubmit: noop, - //dataFilter: null, - //valid: null, - //invalid: null, - validClass: 'n-valid', - invalidClass: 'n-invalid', - msgWrapper: 'span', - msgMaker: function (opt) { - var html, - cls = { - error: CLS_MSG_ERROR, - ok: CLS_MSG_OK, - tip: CLS_MSG_TIP, - loading: CLS_MSG_LOADING - }[opt.type]; - html = ''; - html += opt.arrow + opt.icon + '' + opt.msg + ''; - html += ''; - return html; - }, - msgIcon: '', - msgArrow: '', - msgClass: '', - //msgStyle: null, - //msgShow: null, - //msgHide: null, - //showOk: true, - defaultMsg: '{0} is not valid.', - loadingMsg: 'Validating...' - }, - themes = { - 'default': { - formClass: 'n-default', - msgClass: 'n-right', - showOk: '' - } - }; - /** jQuery Plugin - * @param {Object} options - debug {Boolean} false Whether to enable debug mode - timely {Boolean} true Whether to enable timely verification - theme {String} 'default' Using which theme - stopOnError {Boolean} false Whether to stop validate when found an error input - focusCleanup {Boolean} false Whether to clean up the field message when focus the field - focusInvalid {Boolean} true Whether to focus the field that is invalid - ignore {jqSelector} '' Ignored fields (Using jQuery selector) - - beforeSubmit {Function} Do something before submitting the form - dataFilter {Function} Conversion ajax results - valid {Function} Triggered when the form is valid - invalid {Function} Triggered when the form is invalid - validClass {String} Add the class name to a valid field - invalidClass {String} Add the class name to a invalid field - - msgShow {Function} null When show a message, will trigger this callback - msgHide {Function} null When hide a message, will trigger this callback - msgWrapper {String} 'span' Message wrapper tag name - msgMaker {Function} Message HTML maker - msgIcon {String} Icon template - msgArrow {String} Small arrow template - msgStyle {String} Custom message style - msgClass {String} Additional added to the message class names - formClass {String} Additional added to the form class names - - defaultMsg {String} Default error message - loadingMsg {String} Tips for asynchronous loading - messages {Object} null Custom messages for the current instance - - rules {Object} null Custom rules for the current instance - - fields {Object} Field set to be verified - {String} key name|#id - {String|Object} value Rule string, or an object is passed more arguments - - fields[key][rule] {String} Rule string - fields[key][tip] {String} Custom friendly message when focus the input - fields[key][ok] {String} Custom success message - fields[key][msg] {Object} Custom error message - fields[key][msgStyle] {String} Custom message style - fields[key][msgClass] {String} Additional added to the message class names - fields[key][msgWrapper] {String} Message wrapper tag name - fields[key][msgMaker] {Function} Custom message HTML maker - fields[key][dataFilter] {Function} Conversion ajax results - fields[key][valid] {Function} Triggered when this field is valid - fields[key][invalid] {Function} Triggered when this field is invalid - fields[key][must] {Boolean} If set true, we always check the field even has remote checking - fields[key][timely] {Boolean} Whether to enable timely verification - fields[key][target] {jqSelector} Verify the current field, but the message can be displayed on target element - */ - $.fn[NS] = function (options) { - var that = this, - args = arguments; - if (that.is(':input')) return that; - !that.is('form') && (that = this.find('form')); - !that.length && (that = this); - that.each(function () { - var cache = $(this).data(NS); - if (cache) { - if (isString(options)) { - if (options.charAt(0) === '_') return; - cache[options].apply(cache, Array.prototype.slice.call(args, 1)); - } else if (options) { - cache._reset(true); - cache._init(this, options); - } - } else { - new Validator(this, options); - } - }); - return this; - }; - // Validate a field, or an area - $.fn.isValid = function (callback, checkOnly) { - var me = getInstance(this[0]), - hasCallback = isFunction(callback), - ret; - if (!me) return true; - // By default only verify without prompt message - me.checkOnly = checkOnly === undefined || checkOnly; - ret = me._multiValidate( - this.is(':input') ? this : this.find(INPUT_SELECTOR), - function (isValid) { - hasCallback && callback.call(null, isValid); - me.checkOnly = false; - } - ); - // If you pass a callback, we maintain the jQuery object chain - return hasCallback ? this : ret; - }; - // A faster selector than ":input:not(:submit,:button,:reset,:image,:disabled,[novalidate])" - $.expr[":"].verifiable = function (elem) { - var name = elem.nodeName.toLowerCase(); - return (name === 'input' && !({submit: 1, button: 1, reset: 1, image: 1})[elem.type] || name === 'select' || name === 'textarea') && - elem.disabled === false && attr(elem, NOVALIDATE) === null; - }; - // Constructor for Validator - function Validator(element, options) { - var me = this; - if (!me instanceof Validator) return new Validator(element, options); - me.$el = $(element); - me._init(element, options); - } - - Validator.prototype = { - _init: function (element, options) { - var me = this, - opt, themeOpt, dataOpt; - // Initialization options - if (isFunction(options)) { - options = { - valid: options - }; - } - options = options || {}; - dataOpt = attr(element, 'data-' + NS + '-option'); - dataOpt = dataOpt && dataOpt.charAt(0) === '{' ? (new Function("return " + dataOpt))() : {}; - themeOpt = themes[options.theme || dataOpt.theme || defaults.theme]; - opt = me.options = $.extend({}, defaults, themeOpt, dataOpt, me.options, options); - me.rules = new Rules(opt.rules, true); - me.messages = new Messages(opt.messages, true); - me.elements = me.elements || {}; - me.deferred = {}; - me.errors = {}; - me.fields = {}; - // Initialization fields - me._initFields(opt.fields); - // Initialization group verification - if (isArray(opt.groups)) { - $.map(opt.groups, function (obj) { - if (!isString(obj.fields) || !isFunction(obj.callback)) return null; - obj.$elems = me.$el.find(keys2selector(obj.fields)); - $.map(obj.fields.split(' '), function (k) { - me.fields[k] = me.fields[k] || {}; - me.fields[k].group = obj; - }); - }); - } - // Initialization message parameters - me.msgOpt = { - type: 'error', - pos: getPos(opt.msgClass), - wrapper: opt.msgWrapper, - cls: opt.msgClass, - style: opt.msgStyle, - icon: opt.msgIcon, - arrow: opt.msgArrow, - show: opt.msgShow, - hide: opt.msgHide - }; - // Guess whether it use ajax submit - me.isAjaxSubmit = false; - if (opt.valid || attr(element, 'action') === null) { - me.isAjaxSubmit = true; - } else { - // if there is a "valid.form" event - var events = $[$._data ? '_data' : 'data'](element, "events"); - if (events && events.valid && - $.map(events.valid, function (e) { - return e.namespace.indexOf('form') !== -1 ? 1 : null; - }).length - ) { - me.isAjaxSubmit = true; - } - } - // Initialization events and make a cache - if (!me.$el.data(NS)) { - me.$el.data(NS, me).addClass(CLS_WRAPPER + ' ' + opt.formClass) - .on('submit' + CLS_NS + ' validate' + CLS_NS, proxy(me, '_submit')) - .on('reset' + CLS_NS, proxy(me, '_reset')) - .on('showtip' + CLS_NS, proxy(me, '_showTip')) - .on('validated' + CLS_NS_FIELD + CLS_NS, INPUT_SELECTOR, proxy(me, '_validatedField')) - .on('validated' + CLS_NS_RULE + CLS_NS, INPUT_SELECTOR, proxy(me, '_validatedRule')) - .on('focusin' + CLS_NS + ' click' + CLS_NS + ' showtip' + CLS_NS, INPUT_SELECTOR, proxy(me, '_focusin')) - .on('focusout' + CLS_NS + ' validate' + CLS_NS, INPUT_SELECTOR, proxy(me, '_focusout')) - .on('click' + CLS_NS, ':radio,:checkbox', proxy(me, '_click')); - if (opt.timely >= 2) { - me.$el.on('keyup' + CLS_NS + ' paste' + CLS_NS, INPUT_SELECTOR, proxy(me, '_focusout')) - .on('change' + CLS_NS, 'select', proxy(me, '_click')); - } - // cache the novalidate attribute value - me._novalidate = attr(element, NOVALIDATE); - // Initialization is complete, stop off default HTML5 form validation, and as a basis has been initialized - // jQuery's "attr('novalidate')" in IE7 will complain: "SCRIPT3: Member not found." - attr(element, NOVALIDATE, NOVALIDATE); - } - }, - _initFields: function (fields) { - var me = this; - // Processing field information - if (isObject(fields)) { - $.each(fields, function (k, v) { - // delete the field from settings - if (v === null) { - var el = me.elements[k]; - if (el) me._resetElement(el, true); - delete me.fields[k]; - } else { - me.fields[k] = isString(v) ? { - rule: v - } : v; - } - }); - } - // Parsing DOM rules - me.$el.find(INPUT_SELECTOR).each(function () { - me._parse(this); - }); - }, - // Parsing a field - _parse: function (el) { - var me = this, - field, - key = el.name, - dataRule = attr(el, DATA_RULE); - dataRule && attr(el, DATA_RULE, null); - // if the field has passed the key as id mode, or it doesn't has a name - if (el.id && ('#' + el.id in me.fields) || !el.name) { - key = '#' + el.id; - } - // doesn't verify a field that has neither id nor name - if (!key) return; - field = me.fields[key] || {}; - field.key = key; - field.old = {}; - field.rule = field.rule || dataRule || ''; - if (!field.rule) return; - if (field.rule.match(/match|checked/)) { - field.must = true; - } - if (field.rule.indexOf('required') !== -1) { - field.required = true; - attr(el, ARIA_REQUIRED, true); - } - if ('timely' in field && !field.timely || !me.options.timely) { - attr(el, 'notimely', true); - } - if (isString(field.target)) { - attr(el, DATA_TARGET, field.target); - } - if (isString(field.tip)) { - attr(el, DATA_TIP, field.tip); - } - me.fields[key] = me._parseRule(field); - }, - // Parsing field rules - _parseRule: function (field) { - var arr = rDisplay.exec(field.rule); - if (!arr) return; - // current rule index - field._v = 0; - if (arr[1]) { - field.display = arr[1]; - } - if (arr[2]) { - field.rules = []; - arr[2].replace(rRules, function () { - var args = arguments; - args[3] = args[3] || args[4]; - field.rules.push({ - not: args[1] === "!", - method: args[2], - params: args[3] ? args[3].split(', ') : undefined, - or: args[5] === "|" - }); - }); - // current rule name - // field._r = field.rules[0].method; - } - return field; - }, - // Verify a zone - _multiValidate: function ($inputs, doneCallbacks) { - var me = this, - opt = me.options; - me._multiValid = true; - if (opt.ignore) $inputs = $inputs.not(opt.ignore); - $inputs.each(function (i, el) { - var field = me.getField(el); - if (field) { - me._validate(el, field); - if (!me._multiValid && opt.stopOnError) { - // stop the verification - return false; - } - } - }); - // Need to wait for the completion of all field validation (especially asynchronous verification) - $.when.apply( - null, - $.map(me.deferred, function (v) { - return v; - }) - ).done(function () { - doneCallbacks.call(me, me._multiValid); - }); - // If the form does not contain asynchronous validation, the return value is correct. - // Otherwise, you should detect whether a form valid through "doneCallbacks". - return !$.isEmptyObject(me.deferred) ? undefined : me._multiValid; - }, - // Verify the whole form - _submit: function (e) { - var me = this, - opt = me.options, - form = e.target, - autoSubmit = e.type === 'submit'; - e.preventDefault(); - if ( - novalidateonce && (novalidateonce = false) || - // Prevent duplicate submission - me.submiting || - // Receive the "validate" event only from the form. - e.type === 'validate' && me.$el[0] !== form || - // trigger the beforeSubmit callback. - opt.beforeSubmit.call(me, form) === false - ) { - return; - } - opt.debug && debug.log("\n" + e.type); - me._reset(); - me.submiting = true; - me.isValid = undefined; - me._multiValidate( - me.$el.find(INPUT_SELECTOR), - function (isValid) { - var ret = (isValid || opt.debug === 2) ? 'valid' : 'invalid', - errors; - if (!isValid) { - if (opt.focusInvalid) { - // navigate to the error element - me.$el.find(':input[' + ARIA_INVALID + '="true"]:first').focus(); - } - errors = $.map(me.errors, function (err) { - return err; - }); - } - // releasing submit - me.submiting = false; - // trigger callback and event - isFunction(opt[ret]) && opt[ret].call(me, form, errors); - me.$el.trigger(ret + CLS_NS_FORM, [form, errors]); - if (isValid && !me.isAjaxSubmit && autoSubmit) { - novalidateonce = true; - form.submit(); - } - } - ); - }, - _reset: function (e) { - var me = this; - me.errors = {}; - if (e) { - me.$el.find(INPUT_SELECTOR).each(function (i, el) { - me._resetElement(el); - }); - } - }, - _resetElement: function (el, all) { - var opt = this.options; - $(el).removeClass(opt.validClass + ' ' + opt.invalidClass); - this.hideMsg(el); - if (all) { - attr(el, ARIA_REQUIRED, null); - } - }, - _focusin: function (e) { - var me = this, - opt = me.options, - el = e.target, - msg; - if (e.type !== 'showtip') { - if (me.submiting) return; - if (attr(el, DATA_INPUT_STATUS) === 'error') { - if (opt.focusCleanup) { - $(el).removeClass(opt.invalidClass); - me.hideMsg(el); - } - } else { - if (el.value !== '') return; - } - } - msg = attr(el, DATA_TIP); - if (!msg) return; - me.showMsg(el, { - type: 'tip', - msg: msg - }); - }, - // Handle focusout/validate/keyup/click/paste events - _focusout: function (e, isClick) { - var me = this, - opt = me.options, - field, - must, - el = e.target, - etype = e.type, - timer = 150; - if (!isClick && etype !== 'paste') { - // must be verified, if it is a manual trigger - if (etype === 'validate') { - must = true; - timer = 0; - } - // or doesn't require real-time verification, exit - else if (attr(el, 'notimely')) return; - // or it isn't a "keyup" event, exit - else if (opt.timely >= 2 && etype !== 'keyup') return; - // if the current field is ignored, exit - if (opt.ignore && $(el).is(opt.ignore)) return; - if (etype === 'keyup') { - var key = e.keyCode, - specialKey = { - 8: 1, // Backspace - 9: 1, // Tab - 16: 1, // Shift - 32: 1, // Space - 46: 1 // Delete - }; - // only gets focus, no verification - if (key === 9 && !el.value) return; - // do not validate, if triggered by these keys - if (key < 48 && !specialKey[key]) return; - // keyboard events, reducing the frequency of verification - timer = opt.timely >= 100 ? opt.timely : 500; - } - } - field = me.getField(el); - if (!field) return; - if (timer) { - if (field._t) clearTimeout(field._t); - field._t = setTimeout(function () { - me._validate(el, field, must); - }, timer); - } else { - // use synchronous verification for "validate" event - me._validate(el, field, must); - } - }, - _click: function (e) { - this._focusout(e, true); - }, - _showTip: function (e) { - var me = this; - if (me.$el[0] !== e.target) return; - me.$el.find(INPUT_SELECTOR + "[" + DATA_TIP + "]").each(function () { - me.showMsg(this, { - msg: attr(this, DATA_TIP), - type: 'tip' - }); - }); - }, - // Validated a field - _validatedField: function (e, field, ret) { - var me = this, - opt = me.options, - el = e.target, - isValid = ret.isValid = field.isValid = !!ret.isValid, - callback = isValid ? 'valid' : 'invalid'; - ret.key = field.key; - ret.rule = field._r; - if (isValid) { - ret.type = 'ok'; - } else { - if (me.submiting) { - me.errors[field.key] = ret.msg; - } - me._multiValid = false; - } - field.old.value = el.value; - field.old.id = el.id; - me.elements[field.key] = el; - me.$el[0].isValid = me.isValid = isValid ? me.isFormValid() : isValid; - if (me.checkOnly) return; - // trigger callback and event - isFunction(field[callback]) && field[callback].call(me, el, ret); - $(el).attr(ARIA_INVALID, isValid ? null : true) - .removeClass(isValid ? opt.invalidClass : opt.validClass) - .addClass(!ret.skip ? isValid ? opt.validClass : opt.invalidClass : "") - .trigger(callback + CLS_NS_FIELD, [ret, me]); - me.$el.triggerHandler('validation', [ret, me]); - // show or hide the message - if (field.msgMaker || opt.msgMaker) { - me[ret.showOk || ret.msg ? 'showMsg' : 'hideMsg'](el, ret, field); - } - }, - // Validated a rule - _validatedRule: function (e, field, ret, msgOpt) { - field = field || me.getField(el); - msgOpt = msgOpt || {}; - var me = this, - opt = me.options, - el = e.target, - msg, - rule, - method = field._r, - transfer, - isValid = false; - // use null to break validation from a field - if (ret === null) { - $(el).trigger('validated' + CLS_NS_FIELD, [field, {isValid: true, skip: true}]); - return; - } - else if (ret === true || ret === undefined || ret === '') { - isValid = true; - } - else if (isString(ret)) { - msg = ret; - } - else if (isObject(ret)) { - if (ret.error) { - msg = ret.error; - } else { - msg = ret.ok; - isValid = true; - } - } - if (field.rules) { - rule = field.rules[field._v]; - if (rule.not) { - msg = undefined; - isValid = method === "required" || !isValid; - } - if (rule.or) { - if (isValid) { - while (field._v < field.rules.length && field.rules[field._v].or) { - field._v++; - } - } else { - transfer = true; - } - } - } - // message analysis, and throw rule level event - if (!transfer) { - if (isValid) { - msgOpt.isValid = isValid; - if (opt.showOk !== false) { - if (!isString(msg)) { - if (isString(field.ok)) { - msg = field.ok; - } else if (isString(attr(el, DATA_OK))) { - msg = attr(el, DATA_OK); - } else if (isString(opt.showOk)) { - msg = opt.showOk; - } - } - if (isString(msg)) { - msgOpt.showOk = isValid; - msgOpt.msg = msg; - } - } - $(el).trigger('valid' + CLS_NS_RULE, [method, msgOpt.msg]); - } else { - /* rule message priority: - 1. custom field message; - 2. custom DOM message - 3. global defined message; - 4. rule returned message; - 5. default message; - */ - msgOpt.msg = (getDataMsg(el, field, msg, me.messages[method]) || defaults.defaultMsg).replace('{0}', field.display || ''); - $(el).trigger('invalid' + CLS_NS_RULE, [method, msgOpt.msg]); - } - } - // output the debug message - if (opt.debug) { - debug.log(' ' + field._v + ': ' + method + ' => ' + (isValid || msgOpt.msg || isValid)); - } - // the current rule has passed, continue to validate - if (transfer || isValid && field._v < field.rules.length - 1) { - field._v++; - me._checkRule(el, field); - } - // field was invalid, or all fields was valid - else { - field._v = 0; - $(el).trigger('validated' + CLS_NS_FIELD, [field, msgOpt]); - } - }, - // Verify a rule form a field - _checkRule: function (el, field) { - var me = this, - ret, - old, - key = field.key, - rule = field.rules[field._v], - method = rule.method, - params = rule.params; - // request has been sent, wait it - if (me.submiting && me.deferred[key]) return; - old = field.old; - field._r = method; - if (!field.must && old.ret !== undefined && - old.rule === rule && old.id === el.id && - el.value && old.value === el.value) { - // get result from cache - ret = old.ret; - } - else { - // get result from current rule - ret = (getDataRule(el, method) || me.rules[method] || noop).call(me, el, params, field); - } - // asynchronous validation - if (isObject(ret) && isFunction(ret.then)) { - me.deferred[key] = ret; - // show loading message - !me.checkOnly && me.showMsg(el, { - type: 'loading', - msg: me.options.loadingMsg - }, field); - // waiting to parse the response data - ret.then( - function (d, textStatus, jqXHR) { - var data = jqXHR.responseText, - result, - dataFilter = field.dataFilter || me.options.dataFilter; - // detect if it is json format - if (this.dataType === 'json') { - data = d; - } else if (data.charAt(0) === '{') { - data = $.parseJSON(data) || {}; - } - if (!isFunction(dataFilter)) { - dataFilter = function (data) { - if (isString(data) || (isObject(data) && ('error' in data || 'ok' in data))) return data; - }; - } - // filter data - if ('status' in data && 'info' in data) { - if (data.status) { - result = {'ok': data.info} - } else { - result = {'error': data.info} - } - } else { - result = dataFilter(data); - if (result === undefined) result = dataFilter(data.data); - } - old.rule = rule; - old.ret = result; - $(el).trigger('validated' + CLS_NS_RULE, [field, result]); - }, - function (jqXHR, textStatus) { - $(el).trigger('validated' + CLS_NS_RULE, [field, textStatus]); - } - ).always(function () { - delete me.deferred[key]; - }); - // whether the field valid is unknown - field.isValid = undefined; - } - // other result - else { - $(el).trigger('validated' + CLS_NS_RULE, [field, ret]); - } - }, - // Processing the validation - _validate: function (el, field) { - // doesn't validate the element that has "disabled" or "novalidate" attribute - if (el.disabled || attr(el, NOVALIDATE) !== null) return; - var me = this, - $el = $(el), - msgOpt = {}, - group = field.group, - ret, - isValid = field.isValid = true; - if (!field.rules) me._parse(el); - if (me.options.debug) debug.info(field.key); - // group validation - if (group) { - ret = group.callback.call(me, group.$elems); - if (ret !== undefined) { - me.hideMsg(group.target, {}, field); - if (ret === true) ret = undefined; - else { - field._v = 0; - field._r = 'group'; - isValid = false; - me.hideMsg(el, {}, field); - $.extend(msgOpt, group); - } - } - } - // if the field is not required and it has a blank value - if (isValid && !field.required && !field.must && !el.value) { - if (attr(el, DATA_INPUT_STATUS) === 'tip') { - return; - } - if (!checkable(el)) { - $el.trigger('validated' + CLS_NS_FIELD, [field, {isValid: true}]); - return; - } - } - // if the results are out - if (ret !== undefined) { - $el.trigger('validated' + CLS_NS_RULE, [field, ret, msgOpt]); - } else if (field.rule) { - me._checkRule(el, field); - } - }, - /* Detecting whether the value of an element that matches a rule - * - * @interface: test - */ - test: function (el, rule) { - var me = this, - ret, - parts = rRule.exec(rule), - method, - params; - if (parts) { - method = parts[1]; - if (method in me.rules) { - params = parts[2] || parts[3]; - params = params ? params.split(', ') : undefined; - ret = me.rules[method].call(me, el, params); - } - } - return ret === true || ret === undefined || ret === null; - }, - // Get a range of validation messages - getRangeMsg: function (value, params, type, suffix) { - if (!params) return; - var me = this, - msg = me.messages[type] || '', - p = params[0].split('~'), - a = p[0], - b = p[1], - c = 'rg', - args = [''], - isNumber = +value === +value; - if (p.length === 2) { - if (a && b) { - if (isNumber && value >= +a && value <= +b) return true; - args = args.concat(p); - } else if (a && !b) { - if (isNumber && value >= +a) return true; - args.push(a); - c = 'gt'; - } else if (!a && b) { - if (isNumber && value <= +b) return true; - args.push(b); - c = 'lt'; - } - } else { - if (value === +a) return true; - args.push(a); - c = 'eq'; - } - if (msg) { - if (suffix && msg[c + suffix]) { - c += suffix; - } - args[0] = msg[c]; - } - return me.renderMsg.apply(null, args); - }, - /* @interface: renderMsg - */ - renderMsg: function () { - var args = arguments, - tpl = args[0], - i = args.length; - if (!tpl) return; - while (--i) { - tpl = tpl.replace('{' + i + '}', args[i]); - } - return tpl; - }, - _getMsgOpt: function (obj) { - return $.extend({}, this.msgOpt, isString(obj) ? {msg: obj} : obj); - }, - _getMsgDOM: function (el, opt) { - var $el = $(el), $msgbox, datafor, tgt; - if ($el.is(':input')) { - tgt = opt.target || attr(el, DATA_TARGET); - if (tgt) { - tgt = this.$el.find(tgt); - if (tgt.length) { - if (tgt.is(':input')) { - el = tgt.get(0); - } else { - $msgbox = tgt; - } - } - } - if (!$msgbox) { - datafor = !checkable(el) && el.id ? el.id : el.name; - $msgbox = this.$el.find(opt.wrapper + '.' + CLS_MSG_BOX + '[for="' + datafor + '"]'); - } - } else { - $msgbox = $el; - } - if (!$msgbox.length) { - $el = this.$el.find(tgt || el); - $msgbox = $('<' + opt.wrapper + '>').attr({ - 'class': CLS_MSG_BOX + (opt.cls ? ' ' + opt.cls : ''), - 'style': opt.style || '', - 'for': datafor - }); - if (checkable(el)) { - var $parent = $el.parent(); - $msgbox.appendTo($parent.is('label') ? $parent.parent() : $parent); - } else { - $msgbox[!opt.pos || opt.pos === 'right' ? 'insertAfter' : 'insertBefore']($el); - } - } - return $msgbox; - }, - /* @interface: showMsg - */ - showMsg: function (el, opt, /*INTERNAL*/ field) { - var me = this; - opt = me._getMsgOpt(opt); - if (!opt.msg && !opt.showOk) return; - el = $(el).get(0); - if ($(el).is(INPUT_SELECTOR)) { - // mark message status - attr(el, DATA_INPUT_STATUS, opt.type); - field = field || me.getField(el); - if (field) { - opt.style = field.msgStyle || opt.style; - opt.cls = field.msgClass || opt.cls; - opt.wrapper = field.msgWrapper || opt.wrapper; - } - } - var $msgbox = me._getMsgDOM(el, opt), - cls = $msgbox[0].className; - !rPos.test(cls) && $msgbox.addClass(opt.cls); - if (isIE6 && opt.pos === 'bottom') { - $msgbox[0].style.marginTop = $(el).outerHeight() + 'px'; - } - $msgbox.html(( (field || {}).msgMaker || me.options.msgMaker ).call(me, opt)); - $msgbox[0].style.display = ''; - isFunction(opt.show) && opt.show.call(me, $msgbox, opt.type); - }, - /* @interface: hideMsg - */ - hideMsg: function (el, opt, /*INTERNAL*/ field) { - var me = this; - el = $(el).get(0); - opt = me._getMsgOpt(opt); - if ($(el).is(INPUT_SELECTOR)) { - attr(el, DATA_INPUT_STATUS, null); - attr(el, ARIA_INVALID, null); - field = field || me.getField(el); - if (field) { - opt.wrapper = field.msgWrapper || opt.wrapper; - } - } - var $msgbox = me._getMsgDOM(el, opt); - if (!$msgbox.length) return; - if (isFunction(opt.hide)) { - opt.hide.call(me, $msgbox, opt.type); - } else { - $msgbox[0].style.display = 'none'; - } - }, - /* @interface: mapMsg - */ - mapMsg: function (obj) { - var me = this; - $.each(obj, function (name, msg) { - var el = me.elements[name] || me.$el.find(':input[name="' + name + '"]')[0]; - me.showMsg(el, msg); - }); - }, - /* @interface: setMsg - */ - setMsg: function (obj) { - new Messages(obj, this.messages); - }, - /* @interface: setRule - */ - setRule: function (obj) { - new Rules(obj, this.rules); - $.map(this.fields, function (field) { - field.old = {}; - }); - }, - // Get field information - getField: function (el) { - var me = this, - key; - if (el.id && '#' + el.id in me.fields || !el.name) { - key = '#' + el.id; - } else { - key = el.name; - } - if (attr(el, DATA_RULE)) me._parse(el); - return me.fields[key]; - }, - /* @interface: setField - */ - setField: function (key, obj) { - var fields = {}; - // update this field - if (isString(key)) { - fields[key] = obj; - } - // update fields - else if (isObject(key)) { - fields = key; - } - this._initFields(fields); - }, - /* @interface: isFormValid - */ - isFormValid: function () { - var fields = this.fields; - for (var k in fields) { - if (!fields[k].isValid) { - return fields[k].isValid; - } - } - return true; - }, - /* @interface: holdSubmit - */ - holdSubmit: function (hold) { - this.submiting = hold === undefined || hold; - }, - /* @interface: cleanUp - */ - cleanUp: function () { - this._reset(1); - }, - /* @interface: destroy - */ - destroy: function () { - this._reset(1); - this.$el.off(CLS_NS).removeData(NS); - attr(this.$el[0], NOVALIDATE, this._novalidate); - } - }; - // Rule class - function Rules(obj, context) { - var that = context ? context === true ? this : context : Rules.prototype; - if (!isObject(obj)) return; - for (var k in obj) { - that[k] = getRule(obj[k]); - } - } - - // Message class - function Messages(obj, context) { - var that = context ? context === true ? this : context : Messages.prototype; - if (!isObject(obj)) return; - for (var k in obj) { - if (!obj[k]) return; - that[k] = obj[k]; - } - } - - // Rule converted factory - function getRule(fn) { - switch ($.type(fn)) { - case 'function': - return fn; - case 'array': - return function (el) { - return fn[0].test(el.value) || fn[1] || false; - }; - case 'regexp': - return function (el) { - return fn.test(el.value); - }; - } - } - - // Convert space-separated keys to jQuery selector - function keys2selector(keys) { - var selector = ''; - $.map(keys.split(' '), function (k) { - selector += ',' + (k.charAt(0) === '#' ? k : '[name="' + k + '"]'); - }); - return selector.substring(1); - } - - // Get instance by an element - function getInstance(el) { - var wrap; - if (!el || !el.tagName) return; - switch (el.tagName) { - case 'INPUT': - case 'SELECT': - case 'TEXTAREA': - case 'BUTTON': - case 'FIELDSET': - wrap = el.form || $(el).closest('.' + CLS_WRAPPER); - break; - case 'FORM': - wrap = el; - break; - default: - wrap = $(el).closest('.' + CLS_WRAPPER); - } - return $(wrap).data(NS) || $(wrap)[NS]().data(NS); - } - - function initByInput(e) { - var el = e.currentTarget, me; - if (!el.form || attr(el.form, NOVALIDATE) !== null) return; - me = getInstance(el); - if (me) { - me._parse(el); - me['_' + e.type](e); - } else { - attr(el, DATA_RULE, null); - } - } - - // Get custom rules on the node - function getDataRule(el, method) { - var fn = $.trim(attr(el, DATA_RULE + '-' + method)); - if (!fn) return; - fn = (new Function("return " + fn))(); - if (fn) return getRule(fn); - } - - // Get custom messages on the node - function getDataMsg(el, field, ret, m) { - var msg = field.msg, - item = field._r; - if (isObject(msg)) msg = msg[item]; - if (!isString(msg)) { - msg = attr(el, DATA_MSG + '-' + item) || attr(el, DATA_MSG) || ret || ( m ? isString(m) ? m : m[item] : ''); - } - return msg; - } - - // Get message position - function getPos(str) { - var pos; - if (str) pos = rPos.exec(str); - return pos ? pos[1] : ''; - } - - // Check whether the element is checkbox or radio - function checkable(el) { - return el.tagName === 'INPUT' && el.type === 'checkbox' || el.type === 'radio'; - } - - // parse date string to timestamp - function parseDate(str) { - return Date.parse(str.replace(/\.|\-/g, '/')); - } - - // Global events - $(document) - .on('focusin', ':input[' + DATA_RULE + ']', function (e) { - initByInput(e); - }) - .on('click', 'input,button', function (e) { - var input = this; - if (!input.form) return; - if (input.type === 'submit') { - if (attr(input, NOVALIDATE) !== null) { - novalidateonce = true; - } - } - else if (input.name && checkable(input)) { - var elem = input.form.elements[input.name]; - if (elem.length) elem = elem[0]; - if (attr(elem, DATA_RULE)) { - initByInput(e); - } - } - }) - .on('submit validate', 'form', function (e) { - if (attr(this, NOVALIDATE) !== null) return; - var $form = $(this), me; - if (!$form.data(NS)) { - me = $form[NS]().data(NS); - if (!$.isEmptyObject(me.fields)) { - me._submit(e); - } else { - attr(this, NOVALIDATE, NOVALIDATE); - $form.off(CLS_NS).removeData(NS); - } - } - }); - // Built-in rules (global) - new Rules({ - /** required - * @example: - required - */ - required: function (element, params) { - var val = $.trim(element.value), - isValid = true; - if (params) { - if (params.length === 1) { - if (!val && !this.test(element, params[0])) { - attr(element, ARIA_REQUIRED, null); - return null; - } else { - attr(element, ARIA_REQUIRED, true); - } - } else if (params[0] === 'not') { - $.map(params.slice(1), function (v) { - if (val === $.trim(v)) { - isValid = false; - } - }); - } - } - return isValid && !!val; - }, - /** integer - * @example: - integer - integer[+] - integer[+0] - integer[-] - integer[-0] - */ - integer: function (element, params) { - var re, z = '0|', - p = '[1-9]\\d*', - key = params ? params[0] : '*'; - switch (key) { - case '+': - re = p; - break; - case '-': - re = '-' + p; - break; - case '+0': - re = z + p; - break; - case '-0': - re = z + '-' + p; - break; - default: - re = z + '-?' + p; - } - re = '^(?:' + re + ')$'; - return new RegExp(re).test(element.value) || this.messages.integer[key]; - }, - /** match another field - * @example: - match[password] Match the password field (two values ​​must be the same) - match[eq, password] Ditto - match[neq, count] The value must be not equal to the value of the count field - match[lt, count] The value must be less than the value of the count field - match[lte, count] The value must be less than or equal to the value of the count field - match[gt, count] The value must be greater than the value of the count field - match[gte, count] The value must be greater than or equal to the value of the count field - **/ - match: function (element, params, field) { - if (!params) return; - var me = this, - a, b, - key, msg, type = 'eq', - selector2, elem2, field2; - if (params.length === 1) { - key = params[0]; - } else { - type = params[0]; - key = params[1]; - } - selector2 = key.charAt(0) === '#' ? key : ':input[name="' + key + '"]'; - elem2 = me.$el.find(selector2)[0]; - // If the compared field is not exist - if (!elem2) return; - field2 = me.getField(elem2); - a = element.value; - b = elem2.value; - if (!field._match) { - me.$el.on('valid' + CLS_NS_FIELD + CLS_NS, selector2, function () { - $(element).trigger('validate'); - }); - field._match = field2._match = 1; - } - // If both fields are blank - if (!field.required && a === "" && b === "") { - return null; - } - if (params[2]) { - if (params[2] === 'date') { - a = parseDate(a); - b = parseDate(b); - } else if (params[2] === 'time') { - a = +a.replace(':', ''); - b = +b.replace(':', ''); - } - } - // If the compared field is incorrect, we only ensure that this field is correct. - if (type !== "eq" && !isNaN(+a) && isNaN(+b)) { - return true; - } - msg = me.messages.match[type].replace('{1}', field2.display || key); - switch (type) { - case 'lt': - return (+a < +b) || msg; - case 'lte': - return (+a <= +b) || msg; - case 'gte': - return (+a >= +b) || msg; - case 'gt': - return (+a > +b) || msg; - case 'neq': - return (a !== b) || msg; - default: - return (a === b) || msg; - } - }, - /** range numbers - * @example: - range[0~99] Number 0-99 - range[0~] Number greater than or equal to 0 - range[~100] Number less than or equal to 100 - **/ - range: function (element, params) { - return this.getRangeMsg(+element.value, params, 'range'); - }, - /** how many checkbox or radio inputs that checked - * @example: - checked; no empty, same to required - checked[1~3] 1-3 items - checked[1~] greater than 1 item - checked[~3] less than 3 items - checked[3] 3 items - **/ - checked: function (element, params) { - if (!checkable(element)) return; - var me = this, - elem, count; - count = me.$el.find('input[name="' + element.name + '"]').filter(function () { - var el = this; - if (!elem && checkable(el)) elem = el; - return !el.disabled && el.checked && $(el).is(':visible'); - }).length; - if (params) { - return me.getRangeMsg(count, params, 'checked'); - } else { - return !!count || me.messages.required; - } - }, - /** length of a characters (You can pass the second parameter "true", will calculate the length in bytes) - * @example: - length[6~16] 6-16 characters - length[6~] Greater than 6 characters - length[~16] Less than 16 characters - length[~16, true] Less than 16 characters, non-ASCII characters calculating two-character - **/ - length: function (element, params) { - if (!params) return; - var value = element.value, - len = (params[1] ? value.replace(rDoubleBytes, 'xx') : value).length; - if (params[0].charAt(0) === '~') { - params[0] = '0' + params[0]; - } - return this.getRangeMsg(len, params, 'length', (params[1] ? '_2' : '')); - }, - /** remote validation - * remote([get:]url [, name1, [name2 ...]]); - * Adaptation three kinds of results (Front for the successful, followed by a failure): - 1. text: - '' 'Error Message' - 2. json: - {"ok": ""} {"error": "Error Message"} - 3. json wrapper: - {"status": 1, "data": {"ok": ""}} {"status": 1, "data": {"error": "Error Message"}} - * @example: - The simplest: remote(path/to/server.php); - With parameters: remote(path/to/server.php, name1, name2, ...); - By GET: remote(get:path/to/server.php, name1, name2, ...); - */ - remote: function (element, params) { - if (!params) return; - var me = this, - arr = rAjaxType.exec(params[0]), - url = arr[2], - type = (arr[1] || 'POST').toUpperCase(), - search, - data = {}; - data[element.name] = element.value; - // There are extra fields - if (params[1]) { - $.map(params.slice(1), function (name) { - data[$.trim(name)] = me.$el.find(':input[name="' + name + '"]').val(); - }); - } - data = $.param(data); - if (type === 'POST') { - search = url.indexOf('?'); - if (search !== -1) { - data += '&' + url.substring(search + 1, url.length); - url = url.substring(0, search); - } - } - // Asynchronous validation need to return jqXHR objects - return $.ajax({ - url: url, - type: type, - data: data, - cache: false - }); - }, - /** filters, direct filtration without prompting error (support custom regular expressions) - * @example: - * filter filter "<>" - * filter(regexp) filter the "regexp" matched characters - */ - filter: function (element, params) { - element.value = element.value.replace(params ? (new RegExp("[" + params[0] + "]", "gm")) : rUnsafe, ''); - } - }); - /** @interface: config - * @usage: - .config( obj ) - */ - Validator.config = function (obj) { - $.each(obj, function (k, o) { - if (k === 'rules') { - new Rules(o); - } else if (k === 'messages') { - new Messages(o); - } else { - defaults[k] = o; - } - }); - }; - /** @interface: setTheme - * @usage: - .setTheme( name, obj ) - .setTheme( obj ) - */ - Validator.setTheme = function (name, obj) { - if (isObject(name)) { - $.each(name, function (i, o) { - themes[i] = o; - }); - } else if (isString(name) && isObject(obj)) { - themes[name] = obj; - } - }; - $[NS] = Validator; -})(jQuery); -(function ($) { - /* Global configuration - */ - $.validator.config({ - //stopOnError: false, - //theme: 'yellow_right', - defaultMsg: "{0}格式不正确", - loadingMsg: "正在验证...", - // Custom rules - rules: { - digits: [/^\d+$/, "请输入数字"], - letters: [/^[a-z]+$/i, "{0}只能输入字母"], - en: [/^\w+$/i, "{0}只能输入字母和数字"], - tel: [/^(?:(?:0\d{2,3}[- ]?[1-9]\d{6,7})|(?:[48]00[- ]?[1-9]\d{6}))$/, "电话格式不正确"], - mobile: [/^1[3-9]\d{9}$/, "手机号格式不正确"], - email: [/^(?:[a-z0-9]+[_\-+.]?)*[a-z0-9]+@(?:([a-z0-9]+-?)*[a-z0-9]+\.)+([a-z]{2,})+$/i, "邮箱格式不正确"], - qq: [/^[1-9]\d{4,}$/, "QQ号格式不正确"], - date: [/^\d{4}-\d{1,2}-\d{1,2}$/, "请输入正确的日期,例:yyyy-mm-dd"], - time: [/^([01]\d|2[0-3])(:[0-5]\d){1,2}$/, "请输入正确的时间,例:14:30或14:30:00"], - ID_card: [/^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])((\d{4})|\d{3}[A-Z])$/, "请输入正确的身份证号码"], - url: [/^(https?|ftp):\/\/[^\s]+$/i, "网址格式不正确"], - postcode: [/^[1-9]\d{5}$/, "邮政编码格式不正确"], - chinese: [/^[\u0391-\uFFE5]+$/, "请输入中文"], - username: [/^\w{3,12}$/, "请输入3-12位数字、字母、下划线"], - password: [/^[0-9a-zA-Z]{6,16}$/, "密码由6-16位数字、字母组成"], - accept: function (element, params) { - if (!params) return true; - var ext = params[0]; - return (ext === '*') || - (new RegExp(".(?:" + (ext || "png|jpg|jpeg|gif") + ")$", "i")).test(element.value) || - this.renderMsg("只接受{1}后缀", ext.replace('|', ',')); - } - } - }); - /* Default error messages - */ - $.validator.config({ - messages: { - required: "{0}不能为空", - remote: "{0}已被使用", - integer: { - '*': "请输入整数", - '+': "请输入正整数", - '+0': "请输入正整数或0", - '-': "请输入负整数", - '-0': "请输入负整数或0" - }, - match: { - eq: "{0}与{1}不一致", - neq: "{0}与{1}不能相同", - lt: "{0}必须小于{1}", - gt: "{0}必须大于{1}", - lte: "{0}必须小于或等于{1}", - gte: "{0}必须大于或等于{1}" - }, - range: { - rg: "请输入{1}到{2}的数", - gt: "请输入大于或等于{1}的数", - lt: "请输入小于或等于{1}的数" - }, - checked: { - eq: "请选择{1}项", - rg: "请选择{1}到{2}项", - gt: "请至少选择{1}项", - lt: "请最多选择{1}项" - }, - length: { - eq: "请输入{1}个字符", - rg: "请输入{1}到{2}个字符", - gt: "请输入大于{1}个字符", - lt: "请输入小于{1}个字符", - eq_2: "", - rg_2: "", - gt_2: "", - lt_2: "" - } - } - }); -})(jQuery); \ No newline at end of file diff --git a/public/plugin/zclip/zclip.js b/public/plugin/zclip/zclip.js deleted file mode 100644 index 63921da..0000000 --- a/public/plugin/zclip/zclip.js +++ /dev/null @@ -1,397 +0,0 @@ -/* - * zClip :: jQuery ZeroClipboard v1.1.1 - * http://steamdev.com/zclip - * - * Copyright 2011, SteamDev - * Released under the MIT license. - * http://www.opensource.org/licenses/mit-license.php - * - * Date: Wed Jun 01, 2011 - */ -(function ($) { - $.fn.zclip = function (params) { - if (typeof params == "object" && !params.length) { - var settings = $.extend({ - path: 'ZeroClipboard.swf', - copy: null, - beforeCopy: null, - afterCopy: null, - clickAfter: true, - setHandCursor: true, - setCSSEffects: true - }, params); - return this.each(function () { - var o = $(this); - if (o.is(':visible') && (typeof settings.copy == 'string' || $.isFunction(settings.copy))) { - ZeroClipboard.setMoviePath(settings.path); - var clip = new ZeroClipboard.Client(); - if ($.isFunction(settings.copy)) { - o.bind('zClip_copy', settings.copy); - } - if ($.isFunction(settings.beforeCopy)) { - o.bind('zClip_beforeCopy', settings.beforeCopy); - } - if ($.isFunction(settings.afterCopy)) { - o.bind('zClip_afterCopy', settings.afterCopy); - } - clip.setHandCursor(settings.setHandCursor); - clip.setCSSEffects(settings.setCSSEffects); - clip.addEventListener('mouseOver', function (client) { - o.trigger('mouseenter'); - }); - clip.addEventListener('mouseOut', function (client) { - o.trigger('mouseleave'); - }); - clip.addEventListener('mouseDown', function (client) { - o.trigger('mousedown'); - if (!$.isFunction(settings.copy)) { - clip.setText(settings.copy); - } else { - clip.setText(o.triggerHandler('zClip_copy')); - } - if ($.isFunction(settings.beforeCopy)) { - o.trigger('zClip_beforeCopy'); - } - }); - clip.addEventListener('complete', function (client, text) { - if ($.isFunction(settings.afterCopy)) { - o.trigger('zClip_afterCopy'); - } else { - if (text.length > 500) { - text = text.substr(0, 500) + "...\n\n(" + (text.length - 500) + " characters not shown)"; - } - o.removeClass('hover'); - alert("Copied text to clipboard:\n\n " + text); - } - if (settings.clickAfter) { - o.trigger('click'); - } - }); - clip.glue(o[0], o.parent()[0]); - $(window).bind('load resize', function () { - clip.reposition(); - }); - } - }); - } else if (typeof params == "string") { - return this.each(function () { - var o = $(this); - params = params.toLowerCase(); - var zclipId = o.data('zclipId'); - var clipElm = $('#' + zclipId + '.zclip'); - if (params == "remove") { - clipElm.remove(); - o.removeClass('active hover'); - } else if (params == "hide") { - clipElm.hide(); - o.removeClass('active hover'); - } else if (params == "show") { - clipElm.show(); - } - }); - } - } -})(jQuery); -// ZeroClipboard -// Simple Set Clipboard System -// Author: Joseph Huckaby -var ZeroClipboard = { - version: "1.0.7", - clients: {}, - // registered upload clients on page, indexed by id - moviePath: 'ZeroClipboard.swf', - // URL to movie - nextId: 1, - // ID of next movie - $: function (thingy) { - // simple DOM lookup utility function - if (typeof(thingy) == 'string') thingy = document.getElementById(thingy); - if (!thingy.addClass) { - // extend element with a few useful methods - thingy.hide = function () { - this.style.display = 'none'; - }; - thingy.show = function () { - this.style.display = ''; - }; - thingy.addClass = function (name) { - this.removeClass(name); - this.className += ' ' + name; - }; - thingy.removeClass = function (name) { - var classes = this.className.split(/\s+/); - var idx = -1; - for (var k = 0; k < classes.length; k++) { - if (classes[k] == name) { - idx = k; - k = classes.length; - } - } - if (idx > -1) { - classes.splice(idx, 1); - this.className = classes.join(' '); - } - return this; - }; - thingy.hasClass = function (name) { - return !!this.className.match(new RegExp("\\s*" + name + "\\s*")); - }; - } - return thingy; - }, - setMoviePath: function (path) { - // set path to ZeroClipboard.swf - this.moviePath = path; - }, - dispatch: function (id, eventName, args) { - // receive event from flash movie, send to client - var client = this.clients[id]; - if (client) { - client.receiveEvent(eventName, args); - } - }, - register: function (id, client) { - // register new client to receive events - this.clients[id] = client; - }, - getDOMObjectPosition: function (obj, stopObj) { - // get absolute coordinates for dom element - var info = { - left: 0, - top: 0, - width: obj.width ? obj.width : obj.offsetWidth, - height: obj.height ? obj.height : obj.offsetHeight - }; - if (obj && (obj != stopObj)) { - info.left += obj.offsetLeft; - info.top += obj.offsetTop; - } - return info; - }, - Client: function (elem) { - // constructor for new simple upload client - this.handlers = {}; - // unique ID - this.id = ZeroClipboard.nextId++; - this.movieId = 'ZeroClipboardMovie_' + this.id; - // register client with singleton to receive flash events - ZeroClipboard.register(this.id, this); - // create movie - if (elem) this.glue(elem); - } -}; -ZeroClipboard.Client.prototype = { - id: 0, - // unique ID for us - ready: false, - // whether movie is ready to receive events or not - movie: null, - // reference to movie object - clipText: '', - // text to copy to clipboard - handCursorEnabled: true, - // whether to show hand cursor, or default pointer cursor - cssEffects: true, - // enable CSS mouse effects on dom container - handlers: null, - // user event handlers - glue: function (elem, appendElem, stylesToAdd) { - // glue to DOM element - // elem can be ID or actual DOM element object - this.domElement = ZeroClipboard.$(elem); - // float just above object, or zIndex 99 if dom element isn't set - var zIndex = 99; - if (this.domElement.style.zIndex) { - zIndex = parseInt(this.domElement.style.zIndex, 10) + 1; - } - if (typeof(appendElem) == 'string') { - appendElem = ZeroClipboard.$(appendElem); - } else if (typeof(appendElem) == 'undefined') { - appendElem = document.getElementsByTagName('body')[0]; - } - // find X/Y position of domElement - var box = ZeroClipboard.getDOMObjectPosition(this.domElement, appendElem); - // create floating DIV above element - this.div = document.createElement('div'); - this.div.className = "zclip"; - this.div.id = "zclip-" + this.movieId; - $(this.domElement).data('zclipId', 'zclip-' + this.movieId); - var style = this.div.style; - style.position = 'absolute'; - style.left = '' + box.left + 'px'; - style.top = '' + box.top + 'px'; - style.width = '' + box.width + 'px'; - style.height = '' + box.height + 'px'; - style.zIndex = zIndex; - if (typeof(stylesToAdd) == 'object') { - for (addedStyle in stylesToAdd) { - style[addedStyle] = stylesToAdd[addedStyle]; - } - } - // style.backgroundColor = '#f00'; // debug - appendElem.appendChild(this.div); - this.div.innerHTML = this.getHTML(box.width, box.height); - }, - getHTML: function (width, height) { - // return HTML for movie - var html = ''; - var flashvars = 'id=' + this.id + '&width=' + width + '&height=' + height; - if (navigator.userAgent.match(/MSIE/)) { - // IE gets an OBJECT tag - var protocol = location.href.match(/^https/i) ? 'https://' : 'http://'; - html += ''; - } else { - // all other browsers get an EMBED tag - html += ''; - } - return html; - }, - hide: function () { - // temporarily hide floater offscreen - if (this.div) { - this.div.style.left = '-2000px'; - } - }, - show: function () { - // show ourselves after a call to hide() - this.reposition(); - }, - destroy: function () { - // destroy control and floater - if (this.domElement && this.div) { - this.hide(); - this.div.innerHTML = ''; - var body = document.getElementsByTagName('body')[0]; - try { - body.removeChild(this.div); - } catch (e) { - ; - } - this.domElement = null; - this.div = null; - } - }, - reposition: function (elem) { - // reposition our floating div, optionally to new container - // warning: container CANNOT change size, only position - if (elem) { - this.domElement = ZeroClipboard.$(elem); - if (!this.domElement) this.hide(); - } - if (this.domElement && this.div) { - var box = ZeroClipboard.getDOMObjectPosition(this.domElement); - var style = this.div.style; - style.left = '' + box.left + 'px'; - style.top = '' + box.top + 'px'; - } - }, - setText: function (newText) { - // set text to be copied to clipboard - this.clipText = newText; - if (this.ready) { - this.movie.setText(newText); - } - }, - addEventListener: function (eventName, func) { - // add user event listener for event - // event types: load, queueStart, fileStart, fileComplete, queueComplete, progress, error, cancel - eventName = eventName.toString().toLowerCase().replace(/^on/, ''); - if (!this.handlers[eventName]) { - this.handlers[eventName] = []; - } - this.handlers[eventName].push(func); - }, - setHandCursor: function (enabled) { - // enable hand cursor (true), or default arrow cursor (false) - this.handCursorEnabled = enabled; - if (this.ready) { - this.movie.setHandCursor(enabled); - } - }, - setCSSEffects: function (enabled) { - // enable or disable CSS effects on DOM container - this.cssEffects = !!enabled; - }, - receiveEvent: function (eventName, args) { - // receive event from flash - eventName = eventName.toString().toLowerCase().replace(/^on/, ''); - // special behavior for certain events - switch (eventName) { - case 'load': - // movie claims it is ready, but in IE this isn't always the case... - // bug fix: Cannot extend EMBED DOM elements in Firefox, must use traditional function - this.movie = document.getElementById(this.movieId); - if (!this.movie) { - var self = this; - setTimeout(function () { - self.receiveEvent('load', null); - }, 1); - return; - } - // firefox on pc needs a "kick" in order to set these in certain cases - if (!this.ready && navigator.userAgent.match(/Firefox/) && navigator.userAgent.match(/Windows/)) { - var self = this; - setTimeout(function () { - self.receiveEvent('load', null); - }, 100); - this.ready = true; - return; - } - this.ready = true; - try { - this.movie.setText(this.clipText); - } catch (e) { - } - try { - this.movie.setHandCursor(this.handCursorEnabled); - } catch (e) { - } - break; - case 'mouseover': - if (this.domElement && this.cssEffects) { - this.domElement.addClass('hover'); - if (this.recoverActive) { - this.domElement.addClass('active'); - } - } - break; - case 'mouseout': - if (this.domElement && this.cssEffects) { - this.recoverActive = false; - if (this.domElement.hasClass('active')) { - this.domElement.removeClass('active'); - this.recoverActive = true; - } - this.domElement.removeClass('hover'); - } - break; - case 'mousedown': - if (this.domElement && this.cssEffects) { - this.domElement.addClass('active'); - } - break; - case 'mouseup': - if (this.domElement && this.cssEffects) { - this.domElement.removeClass('active'); - this.recoverActive = false; - } - break; - } // switch eventName - if (this.handlers[eventName]) { - for (var idx = 0, len = this.handlers[eventName].length; idx < len; idx++) { - var func = this.handlers[eventName][idx]; - if (typeof(func) == 'function') { - // actual function reference - func(this, args); - } else if ((typeof(func) == 'object') && (func.length == 2)) { - // PHP style object + method, i.e. [myObject, 'myMethod'] - func[0][func[1]](this, args); - } else if (typeof(func) == 'string') { - // name of function - window[func](this, args); - } - } // foreach event handler defined - } // user defined handler for event - } -}; - diff --git a/public/plugin/zclip/zclip.min.js b/public/plugin/zclip/zclip.min.js deleted file mode 100644 index 2ccd4be..0000000 --- a/public/plugin/zclip/zclip.min.js +++ /dev/null @@ -1,314 +0,0 @@ -(function (a) { - a.fn.zclip = function (c) { - if (typeof c == "object" && !c.length) { - var b = a.extend({path: "ZeroClipboard.swf", copy: null, beforeCopy: null, afterCopy: null, clickAfter: true, setHandCursor: true, setCSSEffects: true}, c); - return this.each(function () { - var e = a(this); - if (e.is(":visible") && (typeof b.copy == "string" || a.isFunction(b.copy))) { - ZeroClipboard.setMoviePath(b.path); - var d = new ZeroClipboard.Client(); - if (a.isFunction(b.copy)) { - e.bind("zClip_copy", b.copy) - } - if (a.isFunction(b.beforeCopy)) { - e.bind("zClip_beforeCopy", b.beforeCopy) - } - if (a.isFunction(b.afterCopy)) { - e.bind("zClip_afterCopy", b.afterCopy) - } - d.setHandCursor(b.setHandCursor); - d.setCSSEffects(b.setCSSEffects); - d.addEventListener("mouseOver", function (f) { - e.trigger("mouseenter") - }); - d.addEventListener("mouseOut", function (f) { - e.trigger("mouseleave") - }); - d.addEventListener("mouseDown", function (f) { - e.trigger("mousedown"); - if (!a.isFunction(b.copy)) { - d.setText(b.copy) - } else { - d.setText(e.triggerHandler("zClip_copy")) - } - if (a.isFunction(b.beforeCopy)) { - e.trigger("zClip_beforeCopy") - } - }); - d.addEventListener("complete", function (f, g) { - if (a.isFunction(b.afterCopy)) { - e.trigger("zClip_afterCopy") - } else { - if (g.length > 500) { - g = g.substr(0, 500) + "...\n\n(" + (g.length - 500) + " characters not shown)" - } - e.removeClass("hover"); - alert("Copied text to clipboard:\n\n " + g) - } - if (b.clickAfter) { - e.trigger("click") - } - }); - d.glue(e[0], e.parent()[0]); - a(window).bind("load resize", function () { - d.reposition() - }) - } - }) - } else { - if (typeof c == "string") { - return this.each(function () { - var f = a(this); - c = c.toLowerCase(); - var e = f.data("zclipId"); - var d = a("#" + e + ".zclip"); - if (c == "remove") { - d.remove(); - f.removeClass("active hover") - } else { - if (c == "hide") { - d.hide(); - f.removeClass("active hover") - } else { - if (c == "show") { - d.show() - } - } - } - }) - } - } - } -})(jQuery); -var ZeroClipboard = { - version: "1.0.7", clients: {}, moviePath: "ZeroClipboard.swf", nextId: 1, $: function (a) { - if (typeof(a) == "string") { - a = document.getElementById(a) - } - if (!a.addClass) { - a.hide = function () { - this.style.display = "none" - }; - a.show = function () { - this.style.display = "" - }; - a.addClass = function (b) { - this.removeClass(b); - this.className += " " + b - }; - a.removeClass = function (d) { - var e = this.className.split(/\s+/); - var b = -1; - for (var c = 0; c < e.length; c++) { - if (e[c] == d) { - b = c; - c = e.length - } - } - if (b > -1) { - e.splice(b, 1); - this.className = e.join(" ") - } - return this - }; - a.hasClass = function (b) { - return !!this.className.match(new RegExp("\\s*" + b + "\\s*")) - } - } - return a - }, setMoviePath: function (a) { - this.moviePath = a - }, dispatch: function (d, b, c) { - var a = this.clients[d]; - if (a) { - a.receiveEvent(b, c) - } - }, register: function (b, a) { - this.clients[b] = a - }, getDOMObjectPosition: function (c, a) { - var b = {left: 0, top: 0, width: c.width ? c.width : c.offsetWidth, height: c.height ? c.height : c.offsetHeight}; - if (c && (c != a)) { - b.left += c.offsetLeft; - b.top += c.offsetTop - } - return b - }, Client: function (a) { - this.handlers = {}; - this.id = ZeroClipboard.nextId++; - this.movieId = "ZeroClipboardMovie_" + this.id; - ZeroClipboard.register(this.id, this); - if (a) { - this.glue(a) - } - } -}; -ZeroClipboard.Client.prototype = { - id: 0, ready: false, movie: null, clipText: "", handCursorEnabled: true, cssEffects: true, handlers: null, glue: function (d, b, e) { - this.domElement = ZeroClipboard.$(d); - var f = 99; - if (this.domElement.style.zIndex) { - f = parseInt(this.domElement.style.zIndex, 10) + 1 - } - if (typeof(b) == "string") { - b = ZeroClipboard.$(b) - } else { - if (typeof(b) == "undefined") { - b = document.getElementsByTagName("body")[0] - } - } - var c = ZeroClipboard.getDOMObjectPosition(this.domElement, b); - this.div = document.createElement("div"); - this.div.className = "zclip"; - this.div.id = "zclip-" + this.movieId; - $(this.domElement).data("zclipId", "zclip-" + this.movieId); - var a = this.div.style; - a.position = "absolute"; - a.left = "" + c.left + "px"; - a.top = "" + c.top + "px"; - a.width = "" + c.width + "px"; - a.height = "" + c.height + "px"; - a.zIndex = f; - if (typeof(e) == "object") { - for (addedStyle in e) { - a[addedStyle] = e[addedStyle] - } - } - b.appendChild(this.div); - this.div.innerHTML = this.getHTML(c.width, c.height) - }, getHTML: function (d, a) { - var c = ""; - var b = "id=" + this.id + "&width=" + d + "&height=" + a; - if (navigator.userAgent.match(/MSIE/)) { - var e = location.href.match(/^https/i) ? "https://" : "http://"; - c += '' - } else { - c += '' - } - return c - }, hide: function () { - if (this.div) { - this.div.style.left = "-2000px" - } - }, show: function () { - this.reposition() - }, destroy: function () { - if (this.domElement && this.div) { - this.hide(); - this.div.innerHTML = ""; - var a = document.getElementsByTagName("body")[0]; - try { - a.removeChild(this.div) - } catch (b) { - } - this.domElement = null; - this.div = null - } - }, reposition: function (c) { - if (c) { - this.domElement = ZeroClipboard.$(c); - if (!this.domElement) { - this.hide() - } - } - if (this.domElement && this.div) { - var b = ZeroClipboard.getDOMObjectPosition(this.domElement); - var a = this.div.style; - a.left = "" + b.left + "px"; - a.top = "" + b.top + "px" - } - }, setText: function (a) { - this.clipText = a; - if (this.ready) { - this.movie.setText(a) - } - }, addEventListener: function (a, b) { - a = a.toString().toLowerCase().replace(/^on/, ""); - if (!this.handlers[a]) { - this.handlers[a] = [] - } - this.handlers[a].push(b) - }, setHandCursor: function (a) { - this.handCursorEnabled = a; - if (this.ready) { - this.movie.setHandCursor(a) - } - }, setCSSEffects: function (a) { - this.cssEffects = !!a - }, receiveEvent: function (d, f) { - d = d.toString().toLowerCase().replace(/^on/, ""); - switch (d) { - case"load": - this.movie = document.getElementById(this.movieId); - if (!this.movie) { - var c = this; - setTimeout(function () { - c.receiveEvent("load", null) - }, 1); - return - } - if (!this.ready && navigator.userAgent.match(/Firefox/) && navigator.userAgent.match(/Windows/)) { - var c = this; - setTimeout(function () { - c.receiveEvent("load", null) - }, 100); - this.ready = true; - return - } - this.ready = true; - try { - this.movie.setText(this.clipText) - } catch (h) { - } - try { - this.movie.setHandCursor(this.handCursorEnabled) - } catch (h) { - } - break; - case"mouseover": - if (this.domElement && this.cssEffects) { - this.domElement.addClass("hover"); - if (this.recoverActive) { - this.domElement.addClass("active") - } - } - break; - case"mouseout": - if (this.domElement && this.cssEffects) { - this.recoverActive = false; - if (this.domElement.hasClass("active")) { - this.domElement.removeClass("active"); - this.recoverActive = true - } - this.domElement.removeClass("hover") - } - break; - case"mousedown": - if (this.domElement && this.cssEffects) { - this.domElement.addClass("active") - } - break; - case"mouseup": - if (this.domElement && this.cssEffects) { - this.domElement.removeClass("active"); - this.recoverActive = false - } - break - } - if (this.handlers[d]) { - for (var b = 0, a = this.handlers[d].length; b < a; b++) { - var g = this.handlers[d][b]; - if (typeof(g) == "function") { - g(this, f) - } else { - if ((typeof(g) == "object") && (g.length == 2)) { - g[0][g[1]](this, f) - } else { - if (typeof(g) == "string") { - window[g](this, f) - } - } - } - } - } - } -}; \ No newline at end of file diff --git a/public/plugin/zclip/zclip.swf b/public/plugin/zclip/zclip.swf deleted file mode 100644 index 13bf8e3..0000000 Binary files a/public/plugin/zclip/zclip.swf and /dev/null differ diff --git a/public/script/angular.init.js b/public/script/angular.init.js deleted file mode 100644 index 58fcbdd..0000000 --- a/public/script/angular.init.js +++ /dev/null @@ -1,28 +0,0 @@ -angular.module('ptcms', []).config(function($httpProvider){ - //对php的post处理 - $httpProvider.defaults.transformRequest = function(request){ - if(typeof(request)!='object'){ - return request; - } - var str = []; - for(var k in request){ - if(k.charAt(0)=='$'){ - delete request[k]; - continue; - } - var v='object'==typeof(request[k])?JSON.stringify(request[k]):request[k]; - str.push(encodeURIComponent(k) + "=" + encodeURIComponent(v)); - } - return str.join("&"); - }; - $httpProvider.defaults.timeout=10000; - $httpProvider.defaults.headers.post = { - 'Content-Type': 'application/x-www-form-urlencoded', - 'X-Requested-With': 'XMLHttpRequest' - }; -}).filter('to_trusted', ['$sce', function($sce){ - return function(text) { - return $sce.trustAsHtml(text); - }; -}]); -; \ No newline at end of file diff --git a/public/script/angular.min.js b/public/script/angular.min.js deleted file mode 100644 index 6d2d8f5..0000000 --- a/public/script/angular.min.js +++ /dev/null @@ -1,221 +0,0 @@ -/* - AngularJS v1.3.0-beta.8 - (c) 2010-2014 Google, Inc. http://angularjs.org - License: MIT -*/ -(function(M,T,r){'use strict';function B(b){return function(){var a=arguments[0],c,a="["+(b?b+":":"")+a+"] http://errors.angularjs.org/1.3.0-beta.8/"+(b?b+"/":"")+a;for(c=1;c").append(b).html();try{return 3===b[0].nodeType?z(c):c.match(/^(<[^>]+>)/)[1].replace(/^<([\w\-]+)/,function(a,b){return"<"+z(b)})}catch(d){return z(c)}}function fc(b){try{return decodeURIComponent(b)}catch(a){}}function gc(b){var a={},c,d;q((b||"").split("&"),function(b){b&&(c=b.split("="),d=fc(c[0]),C(d)&&(b=C(c[1])?fc(c[1]):!0,a[d]?N(a[d])?a[d].push(b):a[d]=[a[d],b]:a[d]=b))});return a}function Db(b){var a=[];q(b,function(b,d){N(b)?q(b,function(b){a.push(za(d,!0)+(!0===b?"":"="+za(b,!0)))}): -a.push(za(d,!0)+(!0===b?"":"="+za(b,!0)))});return a.length?a.join("&"):""}function kb(b){return za(b,!0).replace(/%26/gi,"&").replace(/%3D/gi,"=").replace(/%2B/gi,"+")}function za(b,a){return encodeURIComponent(b).replace(/%40/gi,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,a?"%20":"+")}function kd(b,a){var c,d,e=hc.length;b=E(b);for(d=0;d")+d[2];for(d=d[0];d--;)c=c.lastChild;f=f.concat(qa.call(c.childNodes,void 0));c=e.firstChild;c.textContent=""}else f.push(a.createTextNode(b));e.textContent="";e.innerHTML="";q(f,function(a){e.appendChild(a)});return e}function W(b){if(b instanceof W)return b;y(b)&&(b=aa(b));if(!(this instanceof W)){if(y(b)&&"<"!=b.charAt(0))throw Kb("nosel");return new W(b)}if(y(b)){var a;a=T;var c;b=(c=De.exec(b))? -[a.createElement(c[1])]:(c=Ae(b,a))?c.childNodes:[]}pc(this,b)}function Lb(b){return b.cloneNode(!0)}function Ia(b){qc(b);var a=0;for(b=b.childNodes||[];a=X?(c.preventDefault=null,c.stopPropagation=null,c.isDefaultPrevented=null):(delete c.preventDefault,delete c.stopPropagation,delete c.isDefaultPrevented)};c.elem= -b;return c}function Ja(b){var a=typeof b,c;"object"==a&&null!==b?"function"==typeof(c=b.$$hashKey)?c=b.$$hashKey():c===r&&(c=b.$$hashKey=gb()):c=b;return a+":"+c}function Ya(b){q(b,this.put,this)}function Ge(b){return(b=b.toString().replace(xc,"").match(yc))?"function("+(b[1]||"").replace(/[\s\r\n]+/," ")+")":"fn"}function Nb(b,a,c){var d;if("function"==typeof b){if(!(d=b.$inject)){d=[];if(b.length){if(a)throw y(c)&&c||(c=b.name||Ge(b)),Ka("strictdi",c);a=b.toString().replace(xc,"");a=a.match(yc); -q(a[1].split(He),function(a){a.replace(Ie,function(a,b,c){d.push(c)})})}b.$inject=d}}else N(b)?(a=b.length-1,Ta(b[a],"fn"),d=b.slice(0,a)):Ta(b,"fn",!0);return d}function Eb(b,a){function c(a){return function(b,c){if(V(b))q(b,$b(a));else return a(b,c)}}function d(a,b){Aa(a,"service");if(P(b)||N(b))b=m.instantiate(b);if(!b.$get)throw Ka("pget",a);return n[a+p]=b}function e(a,b){return d(a,{$get:b})}function f(a){var b=[],c;q(a,function(a){function d(a){var b,c;b=0;for(c=a.length;b 4096 bytes)!"));else{if(p.cookie!==L)for(L=p.cookie,d=L.split("; "),R={},f=0;fk&&this.remove(m.key),b},get:function(a){if(k").parent()[0])});var f=R(a,b,a,c,d,e);O(a,"ng-scope");return function(b, -c,d){Fb(b,"scope");var e=c?La.clone.call(a):a;q(d,function(a,b){e.data("$"+b+"Controller",a)});d=0;for(var g=e.length;darguments.length&&(b=a,a=r);Na&&(c=Z);return m(a,b,c)}var x,v,zc,u,ba,S,Z={},ea;x=c===f?d:cc(d,new Ob(E(f),d.$attr));v=x.$$element;if(L){var Q=/^\s*([@=&])(\??)\s*(\w*)\s*$/;g=E(f);S=e.$new(!0);!R||R!==L&&R!==L.$$originalDirective?g.data("$isolateScopeNoTemplate",S):g.data("$isolateScope",S);O(g,"ng-isolate-scope");q(L.scope,function(a,c){var d= -a.match(Q)||[],f=d[3]||c,g="?"==d[2],d=d[1],h,k,m,n;S.$$isolateBindings[c]=d+f;switch(d){case "@":x.$observe(f,function(a){S[c]=a});x.$$observers[f].$$scope=e;x[f]&&(S[c]=b(x[f])(e));break;case "=":if(g&&!x[f])break;k=t(x[f]);n=k.literal?ya:function(a,b){return a===b};m=k.assign||function(){h=S[c]=k(e);throw ja("nonassign",x[f],L.name);};h=S[c]=k(e);S.$watch(function(){var a=k(e);n(a,S[c])||(n(a,h)?m(e,a=S[c]):S[c]=a);return h=a},null,k.literal);break;case "&":k=t(x[f]);S[c]=function(a){return k(e, -a)};break;default:throw ja("iscp",L.name,c,a);}})}ea=m&&s;G&&q(G,function(a){var b={$scope:a===L||a.$$isolateScope?S:e,$element:v,$attrs:x,$transclude:ea},c;ba=a.controller;"@"==ba&&(ba=x[a.name]);c=J(ba,b);Z[a.name]=c;Na||v.data("$"+a.name+"Controller",c);a.controllerAs&&(b.$scope[a.controllerAs]=c)});g=0;for(zc=h.length;gH.priority)break;if(Q=H.scope)v=v||H,H.templateUrl||($a("new/isolated scope", -L,H,K),V(Q)&&(L=H));F=H.name;!H.templateUrl&&H.controller&&(Q=H.controller,G=G||{},$a("'"+F+"' controller",G[F],H,K),G[F]=H);if(Q=H.transclude)C=!0,H.$$tlb||($a("transclusion",ea,H,K),ea=H),"element"==Q?(Na=!0,x=H.priority,Q=u(c,Za,U),K=d.$$element=E(T.createComment(" "+F+": "+d[F]+" ")),c=K[0],sb(f,E(qa.call(Q,0)),c),z=Z(Q,e,x,g&&g.name,{nonTlbTranscludeDirective:ea})):(Q=E(Lb(c)).contents(),K.empty(),z=Z(Q,e));if(H.template)if($a("template",R,H,K),R=H,Q=P(H.template)?H.template(K,d):H.template, -Q=Bc(Q),H.replace){g=H;Q=Jb.test(Q)?E(W(H.type,aa(Q))):[];c=Q[0];if(1!=Q.length||1!==c.nodeType)throw ja("tplrt",F,"");sb(f,K,c);sa={$attr:{}};Q=S(c,[],sa);var X=a.splice(M+1,a.length-(M+1));L&&rb(Q);a=a.concat(Q).concat(X);w(d,sa);sa=a.length}else K.html(Q);if(H.templateUrl)$a("template",R,H,K),R=H,H.replace&&(g=H),D=I(a.splice(M,a.length-M),K,d,f,z,h,k,{controllerDirectives:G,newIsolateScopeDirective:L,templateDirective:R,nonTlbTranscludeDirective:ea}),sa=a.length;else if(H.compile)try{B=H.compile(K, -d,z),P(B)?s(null,B,Za,U):B&&s(B.pre,B.post,Za,U)}catch(Y){n(Y,ia(K))}H.terminal&&(D.terminal=!0,x=Math.max(x,H.priority))}D.scope=v&&!0===v.scope;D.transclude=C&&z;m.hasElementTranscludeDirective=Na;return D}function rb(a){for(var b=0,c=a.length;bs.priority)&&-1!=s.restrict.indexOf(f)&&(l&&(s=bc(s,{$$start:l,$$end:m})), -b.push(s),h=s)}catch(t){n(t)}}return h}function w(a,b){var c=b.$attr,d=a.$attr,e=a.$$element;q(a,function(d,e){"$"!=e.charAt(0)&&(b[e]&&(d+=("style"===e?";":" ")+b[e]),a.$set(e,d,!0,c[e]))});q(b,function(b,f){"class"==f?(O(e,b),a["class"]=(a["class"]?a["class"]+" ":"")+b):"style"==f?(e.attr("style",e.attr("style")+";"+b),a.style=(a.style?a.style+";":"")+b):"$"==f.charAt(0)||a.hasOwnProperty(f)||(a[f]=b,d[f]=c[f])})}function I(a,b,c,d,e,f,g,h){var k=[],l,n,A=b[0],D=a.shift(),t=F({},D,{templateUrl:null, -transclude:null,replace:null,$$originalDirective:D}),J=P(D.templateUrl)?D.templateUrl(b,c):D.templateUrl,v=D.type;b.empty();m.get(x.getTrustedResourceUrl(J),{cache:s}).success(function(m){var s,x;m=Bc(m);if(D.replace){m=Jb.test(m)?E(W(v,aa(m))):[];s=m[0];if(1!=m.length||1!==s.nodeType)throw ja("tplrt",D.name,J);m={$attr:{}};sb(d,b,s);var G=S(s,[],m);V(D.scope)&&rb(G);a=G.concat(a);w(c,m)}else s=A,b.html(m);a.unshift(t);l=ea(a,s,c,e,b,D,f,g,h);q(d,function(a,c){a==s&&(d[c]=b[0])});for(n=R(b[0].childNodes, -e);k.length;){m=k.shift();x=k.shift();var u=k.shift(),ba=k.shift(),G=b[0];if(x!==A){var Z=x.className;h.hasElementTranscludeDirective&&D.replace||(G=Lb(s));sb(u,E(x),G);O(E(G),Z)}x=l.transclude?L(m,l.transclude):ba;l(n,m,G,d,x)}k=null}).error(function(a,b,c,d){throw ja("tpload",d.url);});return function(a,b,c,d,e){k?(k.push(b),k.push(c),k.push(d),k.push(e)):l(n,b,c,d,e)}}function B(a,b){var c=b.priority-a.priority;return 0!==c?c:a.name!==b.name?a.name"+b+"";return c.childNodes[0].childNodes;default:return b}}function Na(a,b){if("srcdoc"==b)return x.HTML;var c=Ma(a); -if("xlinkHref"==b||"FORM"==c&&"action"==b||"IMG"!=c&&("src"==b||"ngSrc"==b))return x.RESOURCE_URL}function Q(a,c,d,e){var f=b(d,!0);if(f){if("multiple"===e&&"SELECT"===Ma(a))throw ja("selmulti",ia(a));c.push({priority:100,compile:function(){return{pre:function(c,d,k){d=k.$$observers||(k.$$observers={});if(g.test(e))throw ja("nodomevents");if(f=b(k[e],!0,Na(a,e),h[e]))k[e]=f(c),(d[e]||(d[e]=[])).$$inter=!0,(k.$$observers&&k.$$observers[e].$$scope||c).$watch(f,function(a,b){"class"===e&&a!=b?k.$updateClass(a, -b):k.$set(e,a)})}}}})}}function sb(a,b,c){var d=b[0],e=b.length,f=d.parentNode,g,h;if(a)for(g=0,h=a.length;ga.status?b:l.reject(b)}var d={method:"get",transformRequest:e.transformRequest, -transformResponse:e.transformResponse},f=function(a){function b(a){var c;q(a,function(b,d){P(b)&&(c=b(),null!=c?a[d]=c:delete a[d])})}var c=e.headers,d=F({},a.headers),f,g,c=F({},c.common,c[z(a.method)]);b(c);b(d);a:for(f in c){a=z(f);for(g in d)if(z(g)===a)continue a;d[f]=c[f]}return d}(a);F(d,a);d.headers=f;d.method=Ga(d.method);(a=Pb(d.url)?b.cookies()[d.xsrfCookieName||e.xsrfCookieName]:r)&&(f[d.xsrfHeaderName||e.xsrfHeaderName]=a);var h=[function(a){f=a.headers;var b=Fc(a.data,Ec(f),a.transformRequest); -I(a.data)&&q(f,function(a,b){"content-type"===z(b)&&delete f[b]});I(a.withCredentials)&&!I(e.withCredentials)&&(a.withCredentials=e.withCredentials);return s(a,b,f).then(c,c)},r],k=l.when(d);for(q(A,function(a){(a.request||a.requestError)&&h.unshift(a.request,a.requestError);(a.response||a.responseError)&&h.push(a.response,a.responseError)});h.length;){a=h.shift();var p=h.shift(),k=k.then(a,p)}k.success=function(a){k.then(function(b){a(b.data,b.status,b.headers,d)});return k};k.error=function(a){k.then(null, -function(b){a(b.data,b.status,b.headers,d)});return k};return k}function s(b,c,f){function g(a,b,c,e){q&&(200<=a&&300>a?q.put(ba,[a,b,Dc(c),e]):q.remove(ba));p(b,a,c,e);d.$$phase||d.$apply()}function p(a,c,d,e){c=Math.max(c,0);(200<=c&&300>c?s.resolve:s.reject)({data:a,status:c,headers:Ec(d),config:b,statusText:e})}function n(){var a=ib(m.pendingRequests,b);-1!==a&&m.pendingRequests.splice(a,1)}var s=l.defer(),A=s.promise,q,u,ba=t(b.url,b.params);m.pendingRequests.push(b);A.then(n,n);(b.cache||e.cache)&& -(!1!==b.cache&&"GET"==b.method)&&(q=V(b.cache)?b.cache:V(e.cache)?e.cache:J);if(q)if(u=q.get(ba),C(u)){if(u.then)return u.then(n,n),u;N(u)?p(u[1],u[0],da(u[2]),u[3]):p(u,200,{},"OK")}else q.put(ba,A);I(u)&&a(b.method,ba,c,g,f,b.timeout,b.withCredentials,b.responseType);return A}function t(a,b){if(!b)return a;var c=[];fd(b,function(a,b){null===a||I(a)||(N(a)||(a=[a]),q(a,function(a){V(a)&&(a=ra(a));c.push(za(b)+"="+za(a))}))});0=X&&(!b.match(/^(get|post|head|put|delete|options)$/i)||!M.XMLHttpRequest))return new M.ActiveXObject("Microsoft.XMLHTTP"); -if(M.XMLHttpRequest)return new M.XMLHttpRequest;throw B("$httpBackend")("noxhr");}function ke(){this.$get=["$browser","$window","$document",function(b,a,c){return Ne(b,Me,b.defer,a.angular.callbacks,c[0])}]}function Ne(b,a,c,d,e){function f(a,b,c){var f=e.createElement("script"),h=null;f.type="text/javascript";f.src=a;f.async=!0;h=function(a){Wa(f,"load",h);Wa(f,"error",h);e.body.removeChild(f);f=null;var g=-1,t="unknown";a&&("load"!==a.type||d[b].called||(a={type:"error"}),t=a.type,g="error"===a.type? -404:200);c&&c(g,t)};tb(f,"load",h);tb(f,"error",h);e.body.appendChild(f);return h}var h=-1;return function(e,p,k,l,n,m,s,t){function J(){D=h;G&&G();v&&v.abort()}function A(a,d,e,f,g){O&&c.cancel(O);G=v=null;0===d&&(d=e?200:"file"==ta(p).protocol?404:0);a(1223===d?204:d,e,f,g||"");b.$$completeOutstandingRequest(w)}var D;b.$$incOutstandingRequestCount();p=p||b.url();if("jsonp"==z(e)){var x="_"+(d.counter++).toString(36);d[x]=function(a){d[x].data=a;d[x].called=!0};var G=f(p.replace("JSON_CALLBACK", -"angular.callbacks."+x),x,function(a,b){A(l,a,d[x].data,"",b);d[x]=w})}else{var v=a(e);v.open(e,p,!0);q(n,function(a,b){C(a)&&v.setRequestHeader(b,a)});v.onreadystatechange=function(){if(v&&4==v.readyState){var a=null,b=null;D!==h&&(a=v.getAllResponseHeaders(),b="response"in v?v.response:v.responseText);A(l,D||v.status,b,a,v.statusText||"")}};s&&(v.withCredentials=!0);if(t)try{v.responseType=t}catch(r){if("json"!==t)throw r;}v.send(k||null)}if(0=g&&(n.resolve(s),l(m.$$intervalId),delete e[m.$$intervalId]);t||b.$apply()},h);e[m.$$intervalId]=n;return m}var e={};d.cancel=function(a){return a&&a.$$intervalId in e?(e[a.$$intervalId].reject("canceled"),clearInterval(a.$$intervalId),delete e[a.$$intervalId],!0):!1};return d}]}function qd(){this.$get=function(){return{id:"en-us",NUMBER_FORMATS:{DECIMAL_SEP:".",GROUP_SEP:",",PATTERNS:[{minInt:1,minFrac:0,maxFrac:3,posPre:"",posSuf:"",negPre:"-",negSuf:"",gSize:3, -lgSize:3},{minInt:1,minFrac:2,maxFrac:2,posPre:"\u00a4",posSuf:"",negPre:"(\u00a4",negSuf:")",gSize:3,lgSize:3}],CURRENCY_SYM:"$"},DATETIME_FORMATS:{MONTH:"January February March April May June July August September October November December".split(" "),SHORTMONTH:"Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec".split(" "),DAY:"Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),SHORTDAY:"Sun Mon Tue Wed Thu Fri Sat".split(" "),AMPMS:["AM","PM"],medium:"MMM d, y h:mm:ss a","short":"M/d/yy h:mm a", -fullDate:"EEEE, MMMM d, y",longDate:"MMMM d, y",mediumDate:"MMM d, y",shortDate:"M/d/yy",mediumTime:"h:mm:ss a",shortTime:"h:mm a"},pluralCat:function(b){return 1===b?"one":"other"}}}}function Qb(b){b=b.split("/");for(var a=b.length;a--;)b[a]=kb(b[a]);return b.join("/")}function Hc(b,a,c){b=ta(b,c);a.$$protocol=b.protocol;a.$$host=b.hostname;a.$$port=U(b.port)||Oe[b.protocol]||null}function Ic(b,a,c){var d="/"!==b.charAt(0);d&&(b="/"+b);b=ta(b,c);a.$$path=decodeURIComponent(d&&"/"===b.pathname.charAt(0)? -b.pathname.substring(1):b.pathname);a.$$search=gc(b.search);a.$$hash=decodeURIComponent(b.hash);a.$$path&&"/"!=a.$$path.charAt(0)&&(a.$$path="/"+a.$$path)}function na(b,a){if(0===a.indexOf(b))return a.substr(b.length)}function ab(b){var a=b.indexOf("#");return-1==a?b:b.substr(0,a)}function Rb(b){return b.substr(0,ab(b).lastIndexOf("/")+1)}function Jc(b,a){this.$$html5=!0;a=a||"";var c=Rb(b);Hc(b,this,b);this.$$parse=function(a){var e=na(c,a);if(!y(e))throw Sb("ipthprfx",a,c);Ic(e,this,b);this.$$path|| -(this.$$path="/");this.$$compose()};this.$$compose=function(){var a=Db(this.$$search),b=this.$$hash?"#"+kb(this.$$hash):"";this.$$url=Qb(this.$$path)+(a?"?"+a:"")+b;this.$$absUrl=c+this.$$url.substr(1)};this.$$rewrite=function(d){var e;if((e=na(b,d))!==r)return d=e,(e=na(a,e))!==r?c+(na("/",e)||e):b+d;if((e=na(c,d))!==r)return c+e;if(c==d+"/")return c}}function Tb(b,a){var c=Rb(b);Hc(b,this,b);this.$$parse=function(d){var e=na(b,d)||na(c,d),e="#"==e.charAt(0)?na(a,e):this.$$html5?e:"";if(!y(e))throw Sb("ihshprfx", -d,a);Ic(e,this,b);d=this.$$path;var f=/^\/[A-Z]:(\/.*)/;0===e.indexOf(b)&&(e=e.replace(b,""));f.exec(e)||(d=(e=f.exec(d))?e[1]:d);this.$$path=d;this.$$compose()};this.$$compose=function(){var c=Db(this.$$search),e=this.$$hash?"#"+kb(this.$$hash):"";this.$$url=Qb(this.$$path)+(c?"?"+c:"")+e;this.$$absUrl=b+(this.$$url?a+this.$$url:"")};this.$$rewrite=function(a){if(ab(b)==ab(a))return a}}function Ub(b,a){this.$$html5=!0;Tb.apply(this,arguments);var c=Rb(b);this.$$rewrite=function(d){var e;if(b==ab(d))return d; -if(e=na(c,d))return b+a+e;if(c===d+"/")return c};this.$$compose=function(){var c=Db(this.$$search),e=this.$$hash?"#"+kb(this.$$hash):"";this.$$url=Qb(this.$$path)+(c?"?"+c:"")+e;this.$$absUrl=b+a+this.$$url}}function ub(b){return function(){return this[b]}}function Kc(b,a){return function(c){if(I(c))return this[b];this[b]=a(c);this.$$compose();return this}}function le(){var b="",a=!1;this.hashPrefix=function(a){return C(a)?(b=a,this):b};this.html5Mode=function(b){return C(b)?(a=b,this):a};this.$get= -["$rootScope","$browser","$sniffer","$rootElement",function(c,d,e,f){function h(a){c.$broadcast("$locationChangeSuccess",g.absUrl(),a)}var g,p,k=d.baseHref(),l=d.url(),n;a?(n=l.substring(0,l.indexOf("/",l.indexOf("//")+2))+(k||"/"),p=e.history?Jc:Ub):(n=ab(l),p=Tb);g=new p(n,"#"+b);g.$$parse(g.$$rewrite(l));f.on("click",function(a){if(!a.ctrlKey&&!a.metaKey&&2!=a.which){for(var e=E(a.target);"a"!==z(e[0].nodeName);)if(e[0]===f[0]||!(e=e.parent())[0])return;var h=e.prop("href");V(h)&&"[object SVGAnimatedString]"=== -h.toString()&&(h=ta(h.animVal).href);if(p===Ub){var k=e.attr("href")||e.attr("xlink:href");if(0>k.indexOf("://"))if(h="#"+b,"/"==k[0])h=n+h+k;else if("#"==k[0])h=n+h+(g.path()||"/")+k;else{for(var l=g.path().split("/"),k=k.split("/"),m=0;me?Lc(d[0],d[1],d[2],d[3],d[4],c,a):function(b,f){var g=0,h;do h=Lc(d[g++],d[g++],d[g++],d[g++],d[g++],c,a)(b,f),f=r,b=h;while(ga)for(b in k++,e)e.hasOwnProperty(b)&&!d.hasOwnProperty(b)&&(q--,delete e[b])}else e!==d&&(e=d,k++);return k},function(){n?(n=!1,b(d,d,c)):b(d,g,c);if(h)if(V(d))if(fb(d)){g=Array(d.length);for(var a=0;ar&&(L=4-r,R[L]||(R[L]= -[]),C=P(d.exp)?"fn: "+(d.exp.name||d.exp.toString()):d.exp,C+="; newVal: "+ra(f)+"; oldVal: "+ra(g),R[L].push(C));else if(d===c){v=!1;break a}}catch(F){m.$$phase=null,e(F)}if(!(h=O.$$childHead||O!==this&&O.$$nextSibling))for(;O!==this&&!(h=O.$$nextSibling);)O=O.$parent}while(O=h);if((v||k.length)&&!r--)throw m.$$phase=null,a("infdig",b,ra(R));}while(v||k.length);for(m.$$phase=null;l.length;)try{l.shift()()}catch(y){e(y)}},$destroy:function(){if(!this.$$destroyed){var a=this.$parent;this.$broadcast("$destroy"); -this.$$destroyed=!0;this!==m&&(q(this.$$listenerCount,jb(null,l,this)),a.$$childHead==this&&(a.$$childHead=this.$$nextSibling),a.$$childTail==this&&(a.$$childTail=this.$$prevSibling),this.$$prevSibling&&(this.$$prevSibling.$$nextSibling=this.$$nextSibling),this.$$nextSibling&&(this.$$nextSibling.$$prevSibling=this.$$prevSibling),this.$parent=this.$$nextSibling=this.$$prevSibling=this.$$childHead=this.$$childTail=this.$root=null,this.$$listeners={},this.$$watchers=this.$$asyncQueue=this.$$postDigestQueue= -[],this.$destroy=this.$digest=this.$apply=w,this.$on=this.$watch=this.$watchGroup=function(){return w})}},$eval:function(a,b){return f(a)(this,b)},$evalAsync:function(a){m.$$phase||m.$$asyncQueue.length||h.defer(function(){m.$$asyncQueue.length&&m.$digest()});this.$$asyncQueue.push({scope:this,expression:a})},$$postDigest:function(a){this.$$postDigestQueue.push(a)},$apply:function(a){try{return p("$apply"),this.$eval(a)}catch(b){e(b)}finally{m.$$phase=null;try{m.$digest()}catch(c){throw e(c),c;}}}, -$on:function(a,b){var c=this.$$listeners[a];c||(this.$$listeners[a]=c=[]);c.push(b);var d=this;do d.$$listenerCount[a]||(d.$$listenerCount[a]=0),d.$$listenerCount[a]++;while(d=d.$parent);var e=this;return function(){c[ib(c,b)]=null;l(e,1,a)}},$emit:function(a,b){var c=[],d,f=this,g=!1,h={name:a,targetScope:f,stopPropagation:function(){g=!0},preventDefault:function(){h.defaultPrevented=!0},defaultPrevented:!1},k=[h].concat(qa.call(arguments,1)),l,m;do{d=f.$$listeners[a]||c;h.currentScope=f;l=0;for(m= -d.length;lc.msieDocumentMode)throw va("iequirks");var e=da(ha);e.isEnabled=function(){return b};e.trustAs= -d.trustAs;e.getTrusted=d.getTrusted;e.valueOf=d.valueOf;b||(e.trustAs=e.getTrusted=function(a,b){return b},e.valueOf=Da);e.parseAs=function(b,c){var d=a(c);return d.literal&&d.constant?d:function(a,c){return e.getTrusted(b,d(a,c))}};var f=e.parseAs,h=e.getTrusted,g=e.trustAs;q(ha,function(a,b){var c=z(b);e[Va("parse_as_"+c)]=function(b){return f(a,b)};e[Va("get_trusted_"+c)]=function(b){return h(a,b)};e[Va("trust_as_"+c)]=function(b){return g(a,b)}});return e}]}function se(){this.$get=["$window", -"$document",function(b,a){var c={},d=U((/android (\d+)/.exec(z((b.navigator||{}).userAgent))||[])[1]),e=/Boxee/i.test((b.navigator||{}).userAgent),f=a[0]||{},h=f.documentMode,g,p=/^(Moz|webkit|O|ms)(?=[A-Z])/,k=f.body&&f.body.style,l=!1,n=!1;if(k){for(var m in k)if(l=p.exec(m)){g=l[0];g=g.substr(0,1).toUpperCase()+g.substr(1);break}g||(g="WebkitOpacity"in k&&"webkit");l=!!("transition"in k||g+"Transition"in k);n=!!("animation"in k||g+"Animation"in k);!d||l&&n||(l=y(f.body.style.webkitTransition), -n=y(f.body.style.webkitAnimation))}return{history:!(!b.history||!b.history.pushState||4>d||e),hashchange:"onhashchange"in b&&(!h||7b;b=Math.abs(b);var h=b+"",g="",p=[],k=!1;if(-1!==h.indexOf("e")){var l=h.match(/([\d\.]+)e(-?)(\d+)/);l&&"-"==l[2]&&l[3]>e+1?h="0":(g=h,k=!0)}if(k)0b)&&(g=b.toFixed(e));else{h=(h.split(Wc)[1]||"").length;I(e)&&(e=Math.min(Math.max(a.minFrac,h),a.maxFrac));h=Math.pow(10,e);b=Math.round(b*h)/h;b=(""+b).split(Wc);h=b[0];b=b[1]||"";var l=0,n=a.lgSize,m=a.gSize;if(h.length>=n+m)for(l=h.length-n,k=0;kb&&(d="-",b=-b);for(b=""+b;b.length-c)e+=c;0===e&&-12==c&&(e=12);return wb(e,a,d)}}function xb(b,a){return function(c,d){var e=c["get"+b](),f=Ga(a?"SHORT"+b:b);return d[f][e]}} -function Xc(b){var a=(new Date(b,0,1)).getDay();return new Date(b,0,(4>=a?5:12)-a)}function Yc(b){return function(a){var c=Xc(a.getFullYear());a=+new Date(a.getFullYear(),a.getMonth(),a.getDate()+(4-a.getDay()))-+c;a=1+Math.round(a/6048E5);return wb(a,b)}}function Sc(b){function a(a){var b;if(b=a.match(c)){a=new Date(0);var f=0,h=0,g=b[8]?a.setUTCFullYear:a.setFullYear,p=b[8]?a.setUTCHours:a.setHours;b[9]&&(f=U(b[9]+b[10]),h=U(b[9]+b[11]));g.call(a,U(b[1]),U(b[2])-1,U(b[3]));f=U(b[4]||0)-f;h=U(b[5]|| -0)-h;g=U(b[6]||0);b=Math.round(1E3*parseFloat("0."+(b[7]||0)));p.call(a,f,h,g,b)}return a}var c=/^(\d{4})-?(\d\d)-?(\d\d)(?:T(\d\d)(?::?(\d\d)(?::?(\d\d)(?:\.(\d+))?)?)?(Z|([+-])(\d\d):?(\d\d))?)?$/;return function(c,e){var f="",h=[],g,p;e=e||"mediumDate";e=b.DATETIME_FORMATS[e]||e;y(c)&&(c=Ye.test(c)?U(c):a(c));Ea(c)&&(c=new Date(c));if(!pa(c))return c;for(;e;)(p=Ze.exec(e))?(h=h.concat(qa.call(p,1)),e=h.pop()):(h.push(e),e=null);q(h,function(a){g=$e[a];f+=g?g(c,b.DATETIME_FORMATS):a.replace(/(^'|'$)/g, -"").replace(/''/g,"'")});return f}}function Ue(){return function(b){return ra(b,!0)}}function Ve(){return function(b,a){if(!N(b)&&!y(b))return b;a=Infinity===Math.abs(Number(a))?Number(a):U(a);if(y(b))return a?0<=a?b.slice(0,a):b.slice(a,b.length):"";var c=[],d,e;a>b.length?a=b.length:a<-b.length&&(a=-b.length);0b||37<=b&&40>=b)||m(a)});if(e.hasEvent("paste"))a.on("paste cut",m)}a.on("change",l);d.$render=function(){a.val(d.$isEmpty(d.$viewValue)?"":d.$viewValue)};var s=c.ngPattern;s&&((e=s.match(/^\/(.*)\/([gim]*)$/))?(s=RegExp(e[1],e[2]),e=function(a){return oa(d,"pattern",d.$isEmpty(a)||s.test(a),a)}):e=function(c){var e=b.$eval(s);if(!e||!e.test)throw B("ngPattern")("noregexp",s,e,ia(a));return oa(d,"pattern",d.$isEmpty(c)||e.test(c),c)},d.$formatters.push(e), -d.$parsers.push(e));if(c.ngMinlength){var q=U(c.ngMinlength);e=function(a){return oa(d,"minlength",d.$isEmpty(a)||a.length>=q,a)};d.$parsers.push(e);d.$formatters.push(e)}if(c.ngMaxlength){var J=U(c.ngMaxlength);e=function(a){return oa(d,"maxlength",d.$isEmpty(a)||a.length<=J,a)};d.$parsers.push(e);d.$formatters.push(e)}}function Cb(b,a){return function(c){var d;return pa(c)?c:y(c)&&(b.lastIndex=0,c=b.exec(c))?(c.shift(),d={yyyy:0,MM:1,dd:1,HH:0,mm:0},q(c,function(b,c){c=c(h.min);g.$setValidity("min",b);return b?a:r},g.$parsers.push(e),g.$formatters.push(e));h.max&&(e=function(a){var b=g.$isEmpty(a)|| -c(a)<=c(h.max);g.$setValidity("max",b);return b?a:r},g.$parsers.push(e),g.$formatters.push(e))}}function Xb(b,a){b="ngClass"+b;return["$animate",function(c){function d(a,b){var c=[],d=0;a:for(;dX?function(b){b=b.nodeName?b:b[0];return b.scopeName&&"HTML"!=b.scopeName?Ga(b.scopeName+":"+b.nodeName):b.nodeName}:function(b){return b.nodeName?b.nodeName:b[0].nodeName};var hc=["ng-","data-ng-","ng:","x-ng-"],md=/[A-Z]/g,pd={full:"1.3.0-beta.8",major:1,minor:3,dot:0,codeName:"accidental-haiku"},Xa=W.cache={},mb=W.expando="ng-"+(new Date).getTime(), -Ee=1,tb=M.document.addEventListener?function(b,a,c){b.addEventListener(a,c,!1)}:function(b,a,c){b.attachEvent("on"+a,c)},Wa=M.document.removeEventListener?function(b,a,c){b.removeEventListener(a,c,!1)}:function(b,a,c){b.detachEvent("on"+a,c)};W._data=function(b){return this.cache[b[this.expando]]||{}};var ye=/([\:\-\_]+(.))/g,ze=/^moz([A-Z])/,Kb=B("jqLite"),De=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,Jb=/<|&#?\w+;/,Be=/<([\w:]+)/,Ce=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,fa= -{option:[1,'"],thead:[1,"","
"],col:[2,"","
"],tr:[2,"","
"],td:[3,"","
"],_default:[0,"",""]};fa.optgroup=fa.option;fa.tbody=fa.tfoot=fa.colgroup=fa.caption=fa.thead;fa.th=fa.td;var La=W.prototype={ready:function(b){function a(){c||(c=!0,b())}var c=!1;"complete"===T.readyState?setTimeout(a):(this.on("DOMContentLoaded",a),W(M).on("load",a))},toString:function(){var b= -[];q(this,function(a){b.push(""+a)});return"["+b.join(", ")+"]"},eq:function(b){return 0<=b?E(this[b]):E(this[this.length+b])},length:0,push:bf,sort:[].sort,splice:[].splice},qb={};q("multiple selected checked disabled readOnly required open".split(" "),function(b){qb[z(b)]=b});var wc={};q("input select option textarea button form details".split(" "),function(b){wc[Ga(b)]=!0});q({data:sc,inheritedData:pb,scope:function(b){return E(b).data("$scope")||pb(b.parentNode||b,["$isolateScope","$scope"])}, -isolateScope:function(b){return E(b).data("$isolateScope")||E(b).data("$isolateScopeNoTemplate")},controller:tc,injector:function(b){return pb(b,"$injector")},removeAttr:function(b,a){b.removeAttribute(a)},hasClass:Mb,css:function(b,a,c){a=Va(a);if(C(c))b.style[a]=c;else{var d;8>=X&&(d=b.currentStyle&&b.currentStyle[a],""===d&&(d="auto"));d=d||b.style[a];8>=X&&(d=""===d?r:d);return d}},attr:function(b,a,c){var d=z(a);if(qb[d])if(C(c))c?(b[a]=!0,b.setAttribute(a,d)):(b[a]=!1,b.removeAttribute(d)); -else return b[a]||(b.attributes.getNamedItem(a)||w).specified?d:r;else if(C(c))b.setAttribute(a,c);else if(b.getAttribute)return b=b.getAttribute(a,2),null===b?r:b},prop:function(b,a,c){if(C(c))b[a]=c;else return b[a]},text:function(){function b(b,d){var e=a[b.nodeType];if(I(d))return e?b[e]:"";b[e]=d}var a=[];9>X?(a[1]="innerText",a[3]="nodeValue"):a[1]=a[3]="textContent";b.$dv="";return b}(),val:function(b,a){if(I(a)){if("SELECT"===Ma(b)&&b.multiple){var c=[];q(b.options,function(a){a.selected&& -c.push(a.value||a.text)});return 0===c.length?null:c}return b.value}b.value=a},html:function(b,a){if(I(a))return b.innerHTML;for(var c=0,d=b.childNodes;c":function(a,c,d,e){return d(a,c)>e(a,c)},"<=":function(a,c,d,e){return d(a,c)<=e(a,c)},">=":function(a,c,d,e){return d(a,c)>=e(a,c)},"&&":function(a,c,d,e){return d(a,c)&&e(a,c)},"||":function(a,c,d,e){return d(a,c)||e(a,c)},"&":function(a,c,d,e){return d(a,c)&e(a,c)},"|":function(a,c,d,e){return e(a,c)(a,c,d(a,c))},"!":function(a,c,d){return!d(a,c)}},ef={n:"\n",f:"\f",r:"\r",t:"\t",v:"\v","'":"'",'"':'"'}, -Wb=function(a){this.options=a};Wb.prototype={constructor:Wb,lex:function(a){this.text=a;this.index=0;this.ch=r;this.lastCh=":";this.tokens=[];var c;for(a=[];this.index=a},isWhitespace:function(a){return" "===a||"\r"===a||"\t"===a||"\n"===a||"\v"===a||"\u00a0"=== -a},isIdent:function(a){return"a"<=a&&"z">=a||"A"<=a&&"Z">=a||"_"===a||"$"===a},isExpOperator:function(a){return"-"===a||"+"===a||this.isNumber(a)},throwError:function(a,c,d){d=d||this.index;c=C(c)?"s "+c+"-"+this.index+" ["+this.text.substring(c,d)+"]":" "+d;throw Ba("lexerr",a,c,this.text);},readNumber:function(){for(var a="",c=this.index;this.index","<=",">="))a=this.binaryFn(a,c.fn,this.relational());return a},additive:function(){for(var a=this.multiplicative(),c;c=this.expect("+","-");)a=this.binaryFn(a,c.fn,this.multiplicative());return a},multiplicative:function(){for(var a=this.unary(),c;c=this.expect("*","/","%");)a=this.binaryFn(a,c.fn,this.unary());return a},unary:function(){var a;return this.expect("+")?this.primary():(a=this.expect("-"))?this.binaryFn(cb.ZERO,a.fn, -this.unary()):(a=this.expect("!"))?this.unaryFn(a.fn,this.unary()):this.primary()},fieldAccess:function(a){var c=this,d=this.expect().text,e=Mc(d,this.options,this.text);return F(function(c,d,g){return e(g||a(c,d))},{assign:function(e,h,g){return vb(a(e,g),d,h,c.text,c.options)}})},objectIndex:function(a){var c=this,d=this.expression();this.consume("]");return F(function(e,f){var h=a(e,f),g=d(e,f),p;if(!h)return r;(h=bb(h[g],c.text))&&(h.then&&c.options.unwrapPromises)&&(p=h,"$$v"in h||(p.$$v=r,p.then(function(a){p.$$v= -a})),h=h.$$v);return h},{assign:function(e,f,h){var g=d(e,h);return bb(a(e,h),c.text)[g]=f}})},functionCall:function(a,c){var d=[];if(")"!==this.peekToken().text){do d.push(this.expression());while(this.expect(","))}this.consume(")");var e=this;return function(f,h){for(var g=[],p=c?c(f,h):f,k=0;ka.getHours()?c.AMPMS[0]:c.AMPMS[1]},Z:function(a){a=-1*a.getTimezoneOffset();return a=(0<=a?"+":"")+(wb(Math[0=X&&(c.href||c.name||c.$set("href",""),a.append(T.createComment("IE fix")));if(!c.href&&!c.xlinkHref&&!c.name)return function(a,c){var f="[object SVGAnimatedString]"===xa.call(c.prop("href"))?"xlink:href":"href";c.on("click",function(a){c.attr(f)||a.preventDefault()})}}}),Hb={};q(qb,function(a,c){if("multiple"!=a){var d=ma("ng-"+c);Hb[d]=function(){return{priority:100,link:function(a,f,h){a.$watch(h[d],function(a){h.$set(c, -!!a)})}}}}});q(["src","srcset","href"],function(a){var c=ma("ng-"+a);Hb[c]=function(){return{priority:99,link:function(d,e,f){var h=a,g=a;"href"===a&&"[object SVGAnimatedString]"===xa.call(e.prop("href"))&&(g="xlinkHref",f.$attr[g]="xlink:href",h=null);f.$observe(c,function(a){a&&(f.$set(g,a),X&&h&&e.prop(h,f[g]))})}}}});var Ab={$addControl:w,$removeControl:w,$setValidity:w,$setDirty:w,$setPristine:w};Zc.$inject=["$element","$attrs","$scope","$animate"];var $c=function(a){return["$timeout",function(c){return{name:"form", -restrict:a?"EAC":"E",controller:Zc,compile:function(){return{pre:function(a,e,f,h){if(!f.action){var g=function(c){a.$apply(function(){h.$commitViewValue()});c.preventDefault?c.preventDefault():c.returnValue=!1};tb(e[0],"submit",g);e.on("$destroy",function(){c(function(){Wa(e[0],"submit",g)},0,!1)})}var p=e.parent().controller("form"),k=f.name||f.ngForm;k&&vb(a,k,h,k);if(p)e.on("$destroy",function(){p.$removeControl(h);k&&vb(a,k,r,k);F(h,Ab)})}}}}}]},td=$c(),Gd=$c(!0),ff=/^(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?$/, -gf=/^[a-z0-9!#$%&'*+/=?^_`{|}~.-]+@[a-z0-9-]+(\.[a-z0-9-]+)*$/i,hf=/^\s*(\-|\+)?(\d+|(\d*(\.\d*)))\s*$/,ad=/^(\d{4})-(\d{2})-(\d{2})$/,bd=/^(\d{4})-(\d\d)-(\d\d)T(\d\d):(\d\d)$/,Yb=/^(\d{4})-W(\d\d)$/,cd=/^(\d{4})-(\d\d)$/,dd=/^(\d\d):(\d\d)$/,jf=/(\s+|^)default(\s+|$)/,ed={text:db,date:eb("date",ad,Cb(ad,["yyyy","MM","dd"]),"yyyy-MM-dd"),"datetime-local":eb("datetimelocal",bd,Cb(bd,["yyyy","MM","dd","HH","mm"]),"yyyy-MM-ddTHH:mm"),time:eb("time",dd,Cb(dd,["HH","mm"]),"HH:mm"),week:eb("week",Yb,function(a){if(pa(a))return a; -if(y(a)){Yb.lastIndex=0;var c=Yb.exec(a);if(c){a=+c[1];var d=+c[2],c=Xc(a),d=7*(d-1);return new Date(a,0,c.getDate()+d)}}return NaN},"yyyy-Www"),month:eb("month",cd,Cb(cd,["yyyy","MM"]),"yyyy-MM"),number:function(a,c,d,e,f,h){db(a,c,d,e,f,h);e.$parsers.push(function(a){var c=e.$isEmpty(a);if(c||hf.test(a))return e.$setValidity("number",!0),""===a?null:c?a:parseFloat(a);e.$setValidity("number",!1);return r});af(e,"number",c);e.$formatters.push(function(a){return e.$isEmpty(a)?"":""+a});d.min&&(a=function(a){var c= -parseFloat(d.min);return oa(e,"min",e.$isEmpty(a)||a>=c,a)},e.$parsers.push(a),e.$formatters.push(a));d.max&&(a=function(a){var c=parseFloat(d.max);return oa(e,"max",e.$isEmpty(a)||a<=c,a)},e.$parsers.push(a),e.$formatters.push(a));e.$formatters.push(function(a){return oa(e,"number",e.$isEmpty(a)||Ea(a),a)})},url:function(a,c,d,e,f,h){db(a,c,d,e,f,h);a=function(a){return oa(e,"url",e.$isEmpty(a)||ff.test(a),a)};e.$formatters.push(a);e.$parsers.push(a)},email:function(a,c,d,e,f,h){db(a,c,d,e,f,h); -a=function(a){return oa(e,"email",e.$isEmpty(a)||gf.test(a),a)};e.$formatters.push(a);e.$parsers.push(a)},radio:function(a,c,d,e){I(d.name)&&c.attr("name",gb());c.on("click",function(f){c[0].checked&&a.$apply(function(){e.$setViewValue(d.value,f&&f.type)})});e.$render=function(){c[0].checked=d.value==e.$viewValue};d.$observe("value",e.$render)},checkbox:function(a,c,d,e){var f=d.ngTrueValue,h=d.ngFalseValue;y(f)||(f=!0);y(h)||(h=!1);c.on("click",function(d){a.$apply(function(){e.$setViewValue(c[0].checked, -d&&d.type)})});e.$render=function(){c[0].checked=e.$viewValue};e.$isEmpty=function(a){return a!==f};e.$formatters.push(function(a){return a===f});e.$parsers.push(function(a){return a?f:h})},hidden:w,button:w,submit:w,reset:w,file:w},lc=["$browser","$sniffer","$filter",function(a,c,d){return{restrict:"E",require:["?ngModel"],link:function(e,f,h,g){g[0]&&(ed[z(h.type)]||ed.text)(e,f,h,g[0],c,a,d)}}}],zb="ng-valid",yb="ng-invalid",Oa="ng-pristine",Bb="ng-dirty",kf=["$scope","$exceptionHandler","$attrs", -"$element","$parse","$animate","$timeout",function(a,c,d,e,f,h,g){function p(a,c){c=c?"-"+lb(c,"-"):"";h.removeClass(e,(a?yb:zb)+c);h.addClass(e,(a?zb:yb)+c)}this.$modelValue=this.$viewValue=Number.NaN;this.$parsers=[];this.$formatters=[];this.$viewChangeListeners=[];this.$pristine=!0;this.$dirty=!1;this.$valid=!0;this.$invalid=!1;this.$name=d.name;var k=f(d.ngModel),l=k.assign,n=null,m=this;if(!l)throw B("ngModel")("nonassign",d.ngModel,ia(e));this.$render=w;this.$isEmpty=function(a){return I(a)|| -""===a||null===a||a!==a};var s=e.inheritedData("$formController")||Ab,t=0,r=this.$error={};e.addClass(Oa);p(!0);this.$setValidity=function(a,c){r[a]!==!c&&(c?(r[a]&&t--,t||(p(!0),m.$valid=!0,m.$invalid=!1)):(p(!1),m.$invalid=!0,m.$valid=!1,t++),r[a]=!c,p(c,a),s.$setValidity(a,c,m))};this.$setPristine=function(){m.$dirty=!1;m.$pristine=!0;h.removeClass(e,Bb);h.addClass(e,Oa)};this.$rollbackViewValue=function(){g.cancel(n);m.$viewValue=m.$$lastCommittedViewValue;m.$render()};this.$commitViewValue=function(){var d= -m.$viewValue;m.$$lastCommittedViewValue=d;g.cancel(n);m.$pristine&&(m.$dirty=!0,m.$pristine=!1,h.removeClass(e,Oa),h.addClass(e,Bb),s.$setDirty());q(m.$parsers,function(a){d=a(d)});m.$modelValue!==d&&(m.$modelValue=d,l(a,d),q(m.$viewChangeListeners,function(a){try{a()}catch(d){c(d)}}))};this.$setViewValue=function(a,c){m.$viewValue=a;m.$options&&!m.$options.updateOnDefault||m.$$debounceViewValueCommit(c)};this.$$debounceViewValueCommit=function(a){var c=0,d=m.$options;d&&C(d.debounce)&&(d=d.debounce, -Ea(d)?c=d:Ea(d[a])?c=d[a]:Ea(d["default"])&&(c=d["default"]));g.cancel(n);c?n=g(function(){m.$commitViewValue()},c):m.$commitViewValue()};a.$watch(function(){var c=k(a);if(m.$modelValue!==c){var d=m.$formatters,e=d.length;for(m.$modelValue=c;e--;)c=d[e](c);m.$viewValue!==c&&(m.$viewValue=m.$$lastCommittedViewValue=c,m.$render())}return c})}],Vd=function(){return{require:["ngModel","^?form","^?ngModelOptions"],controller:kf,link:{pre:function(a,c,d,e){e[2]&&(e[0].$options=e[2].$options);var f=e[0], -h=e[1]||Ab;h.$addControl(f);a.$on("$destroy",function(){h.$removeControl(f)})},post:function(a,c,d,e){var f=e[0];if(f.$options&&f.$options.updateOn)c.on(f.$options.updateOn,function(c){a.$apply(function(){f.$$debounceViewValueCommit(c&&c.type)})})}}}},Xd=ca({require:"ngModel",link:function(a,c,d,e){e.$viewChangeListeners.push(function(){a.$eval(d.ngChange)})}}),mc=function(){return{require:"?ngModel",link:function(a,c,d,e){if(e){d.required=!0;var f=function(a){if(d.required&&e.$isEmpty(a))e.$setValidity("required", -!1);else return e.$setValidity("required",!0),a};e.$formatters.push(f);e.$parsers.unshift(f);d.$observe("required",function(){f(e.$viewValue)})}}}},Wd=function(){return{require:"ngModel",link:function(a,c,d,e){var f=(a=/\/(.*)\//.exec(d.ngList))&&RegExp(a[1])||d.ngList||",";e.$parsers.push(function(a){if(!I(a)){var c=[];a&&q(a.split(f),function(a){a&&c.push(aa(a))});return c}});e.$formatters.push(function(a){return N(a)?a.join(", "):r});e.$isEmpty=function(a){return!a||!a.length}}}},lf=/^(true|false|\d+)$/, -Yd=function(){return{priority:100,compile:function(a,c){return lf.test(c.ngValue)?function(a,c,f){f.$set("value",a.$eval(f.ngValue))}:function(a,c,f){a.$watch(f.ngValue,function(a){f.$set("value",a)})}}}},Zd=function(){return{controller:["$scope","$attrs",function(a,c){var d=this;this.$options=a.$eval(c.ngModelOptions);this.$options.updateOn!==r?(this.$options.updateOnDefault=!1,this.$options.updateOn=aa(this.$options.updateOn.replace(jf,function(){d.$options.updateOnDefault=!0;return" "}))):this.$options.updateOnDefault= -!0}]}},yd=wa(function(a,c,d){c.addClass("ng-binding").data("$binding",d.ngBind);a.$watch(d.ngBind,function(a){c.text(a==r?"":a)})}),Ad=["$interpolate",function(a){return function(c,d,e){c=a(d.attr(e.$attr.ngBindTemplate));d.addClass("ng-binding").data("$binding",c);e.$observe("ngBindTemplate",function(a){d.text(a)})}}],zd=["$sce","$parse",function(a,c){return function(d,e,f){e.addClass("ng-binding").data("$binding",f.ngBindHtml);var h=c(f.ngBindHtml);d.$watch(function(){return(h(d)||"").toString()}, -function(c){e.html(a.getTrustedHtml(h(d))||"")})}}],Bd=Xb("",!0),Dd=Xb("Odd",0),Cd=Xb("Even",1),Ed=wa({compile:function(a,c){c.$set("ngCloak",r);a.removeClass("ng-cloak")}}),Fd=[function(){return{scope:!0,controller:"@",priority:500}}],nc={};q("click dblclick mousedown mouseup mouseover mouseout mousemove mouseenter mouseleave keydown keyup keypress submit focus blur copy cut paste".split(" "),function(a){var c=ma("ng-"+a);nc[c]=["$parse",function(d){return{compile:function(e,f){var h=d(f[c]);return function(c, -d,e){d.on(z(a),function(a){c.$apply(function(){h(c,{$event:a})})})}}}}]});var Id=["$animate",function(a){return{transclude:"element",priority:600,terminal:!0,restrict:"A",$$tlb:!0,link:function(c,d,e,f,h){var g,p,k;c.$watch(e.ngIf,function(f){Ra(f)?p||(p=c.$new(),h(p,function(c){c[c.length++]=T.createComment(" end ngIf: "+e.ngIf+" ");g={clone:c};a.enter(c,d.parent(),d)})):(k&&(k.remove(),k=null),p&&(p.$destroy(),p=null),g&&(k=Gb(g.clone),a.leave(k,function(){k=null}),g=null))})}}}],Jd=["$http","$templateCache", -"$anchorScroll","$animate","$sce",function(a,c,d,e,f){return{restrict:"ECA",priority:400,terminal:!0,transclude:"element",controller:Sa.noop,compile:function(h,g){var p=g.ngInclude||g.src,k=g.onload||"",l=g.autoscroll;return function(g,h,q,r,J){var A=0,D,x,G,v=function(){x&&(x.remove(),x=null);D&&(D.$destroy(),D=null);G&&(e.leave(G,function(){x=null}),x=G,G=null)};g.$watch(f.parseAsResourceUrl(p),function(f){var p=function(){!C(l)||l&&!g.$eval(l)||d()},q=++A;f?(a.get(f,{cache:c}).success(function(a){if(q=== -A){var c=g.$new();r.template=a;a=J(c,function(a){v();e.enter(a,null,h,p)});D=c;G=a;D.$emit("$includeContentLoaded");g.$eval(k)}}).error(function(){q===A&&v()}),g.$emit("$includeContentRequested")):(v(),r.template=null)})}}}}],$d=["$compile",function(a){return{restrict:"ECA",priority:-400,require:"ngInclude",link:function(c,d,e,f){d.html(f.template);a(d.contents())(c)}}}],Kd=wa({priority:450,compile:function(){return{pre:function(a,c,d){a.$eval(d.ngInit)}}}}),Ld=wa({terminal:!0,priority:1E3}),Md=["$locale", -"$interpolate",function(a,c){var d=/{}/g;return{restrict:"EA",link:function(e,f,h){var g=h.count,p=h.$attr.when&&f.attr(h.$attr.when),k=h.offset||0,l=e.$eval(p)||{},n={},m=c.startSymbol(),s=c.endSymbol(),r=/^when(Minus)?(.+)$/;q(h,function(a,c){r.test(c)&&(l[z(c.replace("when","").replace("Minus","-"))]=f.attr(h.$attr[c]))});q(l,function(a,e){n[e]=c(a.replace(d,m+g+"-"+k+s))});e.$watch(function(){var c=parseFloat(e.$eval(g));if(isNaN(c))return"";c in l||(c=a.pluralCat(c-k));return n[c](e)},function(a){f.text(a)})}}}], -Nd=["$parse","$animate",function(a,c){var d=B("ngRepeat");return{transclude:"element",priority:1E3,terminal:!0,$$tlb:!0,link:function(e,f,h,g,p){var k=h.ngRepeat,l=k.match(/^\s*([\s\S]+?)\s+in\s+([\s\S]+?)(?:\s+track\s+by\s+([\s\S]+?))?\s*$/),n,m,s,r,C,A,D={$id:Ja};if(!l)throw d("iexp",k);h=l[1];g=l[2];(l=l[3])?(n=a(l),m=function(a,c,d){A&&(D[A]=a);D[C]=c;D.$index=d;return n(e,D)}):(s=function(a,c){return Ja(c)},r=function(a){return a});l=h.match(/^(?:([\$\w]+)|\(([\$\w]+)\s*,\s*([\$\w]+)\))$/);if(!l)throw d("iidexp", -h);C=l[3]||l[1];A=l[2];var x={};e.$watchCollection(g,function(a){var g,h,l=f[0],n,D={},F,u,y,w,z,K,B=[];if(fb(a))z=a,n=m||s;else{n=m||r;z=[];for(y in a)a.hasOwnProperty(y)&&"$"!=y.charAt(0)&&z.push(y);z.sort()}F=z.length;h=B.length=z.length;for(g=0;gB;)u.pop().element.remove()}for(;w.length>z;)w.pop()[0].element.remove()}var k;if(!(k= -t.match(d)))throw mf("iexp",t,ia(f));var l=c(k[2]||k[1]),m=k[4]||k[6],n=k[5],p=c(k[3]||""),q=c(k[2]?k[1]:m),A=c(k[7]),v=k[8]?c(k[8]):null,w=[[{element:f,label:""}]];y&&(a(y)(e),y.removeClass("ng-scope"),y.remove());f.empty();f.on("change",function(){e.$apply(function(){var a,c=A(e)||[],d={},h,k,l,p,t,x,u;if(s)for(k=[],p=0,x=w.length;p@charset "UTF-8";[ng\\:cloak],[ng-cloak],[data-ng-cloak],[x-ng-cloak],.ng-cloak,.x-ng-cloak,.ng-hide{display:none !important;}ng\\:form{display:block;}'); -//# sourceMappingURL=angular.min.js.map diff --git a/public/script/jquery.cookie.js b/public/script/jquery.cookie.js deleted file mode 100644 index 43eb74a..0000000 --- a/public/script/jquery.cookie.js +++ /dev/null @@ -1,103 +0,0 @@ -/*! - * jQuery Cookie Plugin v1.4.0 - * https://github.com/carhartl/jquery-cookie - * - * Copyright 2013 Klaus Hartl - * Released under the MIT license - */ -(function (factory) { - if (typeof define === 'function' && define.amd) { - // AMD. Register as anonymous module. - define(['jquery'], factory); - } else { - // Browser globals. - factory(jQuery); - } -}(function ($) { - var pluses = /\+/g; - - function encode(s) { - return config.raw ? s : encodeURIComponent(s); - } - - function decode(s) { - return config.raw ? s : decodeURIComponent(s); - } - - function stringifyCookieValue(value) { - return encode(config.json ? JSON.stringify(value) : String(value)); - } - - function parseCookieValue(s) { - if (s.indexOf('"') === 0) { - // This is a quoted cookie as according to RFC2068, unescape... - s = s.slice(1, -1).replace(/\\"/g, '"').replace(/\\\\/g, '\\'); - } - try { - // Replace server-side written pluses with spaces. - // If we can't decode the cookie, ignore it, it's unusable. - s = decodeURIComponent(s.replace(pluses, ' ')); - } catch (e) { - return; - } - try { - // If we can't parse the cookie, ignore it, it's unusable. - return config.json ? JSON.parse(s) : s; - } catch (e) { - } - } - - function read(s, converter) { - var value = config.raw ? s : parseCookieValue(s); - return $.isFunction(converter) ? converter(value) : value; - } - - var config = $.cookie = function (key, value, options) { - - // Write - if (value !== undefined && !$.isFunction(value)) { - options = $.extend({}, config.defaults, options); - if (typeof options.expires === 'number') { - var days = options.expires, t = options.expires = new Date(); - t.setDate(t.getDate() + days); - } - return (document.cookie = [ - encode(key), '=', stringifyCookieValue(value), - options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE - options.path ? '; path=' + options.path : '', - options.domain ? '; domain=' + options.domain : '', - options.secure ? '; secure' : '' - ].join('')); - } - // Read - var result = key ? undefined : {}; - // To prevent the for loop in the first place assign an empty array - // in case there are no cookies at all. Also prevents odd result when - // calling $.cookie(). - var cookies = document.cookie ? document.cookie.split('; ') : []; - for (var i = 0, l = cookies.length; i < l; i++) { - var parts = cookies[i].split('='); - var name = decode(parts.shift()); - var cookie = parts.join('='); - if (key && key === name) { - // If second argument (value) is a function it's a converter... - result = read(cookie, value); - break; - } - // Prevent storing a cookie that we couldn't decode. - if (!key && (cookie = read(cookie)) !== undefined) { - result[name] = cookie; - } - } - return result; - }; - config.defaults = {}; - $.removeCookie = function (key, options) { - if ($.cookie(key) !== undefined) { - // Must not alter options, thus extending a fresh object... - $.cookie(key, '', $.extend({}, options, {expires: -1})); - return true; - } - return false; - }; -})); diff --git a/public/script/jquery.form.js b/public/script/jquery.form.js deleted file mode 100644 index 701d80b..0000000 --- a/public/script/jquery.form.js +++ /dev/null @@ -1,1183 +0,0 @@ -/*! - * jQuery Form Plugin - * version: 3.50.0-2014.02.05 - * Requires jQuery v1.5 or later - * Copyright (c) 2013 M. Alsup - * Examples and documentation at: http://malsup.com/jquery/form/ - * Project repository: https://github.com/malsup/form - * Dual licensed under the MIT and GPL licenses. - * https://github.com/malsup/form#copyright-and-license - */ -/*global ActiveXObject */ - -// AMD support -(function (factory) { - "use strict"; - if (typeof define === 'function' && define.amd) { - // using AMD; register as anon module - define(['jquery'], factory); - } else { - // no AMD; invoke directly - factory((typeof(jQuery) != 'undefined') ? jQuery : window.Zepto); - } -} -(function ($) { - "use strict"; - /* - Usage Note: - ----------- - Do not use both ajaxSubmit and ajaxForm on the same form. These - functions are mutually exclusive. Use ajaxSubmit if you want - to bind your own submit handler to the form. For example, - - $(document).ready(function() { - $('#myForm').on('submit', function(e) { - e.preventDefault(); // <-- important - $(this).ajaxSubmit({ - target: '#output' - }); - }); - }); - - Use ajaxForm when you want the plugin to manage all the event binding - for you. For example, - - $(document).ready(function() { - $('#myForm').ajaxForm({ - target: '#output' - }); - }); - - You can also use ajaxForm with delegation (requires jQuery v1.7+), so the - form does not have to exist when you invoke ajaxForm: - - $('#myForm').ajaxForm({ - delegation: true, - target: '#output' - }); - - When using ajaxForm, the ajaxSubmit function will be invoked for you - at the appropriate time. - */ - /** - * Feature detection - */ - var feature = {}; - feature.fileapi = $("").get(0).files !== undefined; - feature.formdata = window.FormData !== undefined; - var hasProp = !!$.fn.prop; -// attr2 uses prop when it can but checks the return type for -// an expected string. this accounts for the case where a form -// contains inputs with names like "action" or "method"; in those -// cases "prop" returns the element - $.fn.attr2 = function () { - if (!hasProp) { - return this.attr.apply(this, arguments); - } - var val = this.prop.apply(this, arguments); - if (( val && val.jquery ) || typeof val === 'string') { - return val; - } - return this.attr.apply(this, arguments); - }; - /** - * ajaxSubmit() provides a mechanism for immediately submitting - * an HTML form using AJAX. - */ - $.fn.ajaxSubmit = function (options) { - /*jshint scripturl:true */ - // fast fail if nothing selected (http://dev.jquery.com/ticket/2752) - if (!this.length) { - log('ajaxSubmit: skipping submit process - no element selected'); - return this; - } - var method, action, url, $form = this; - if (typeof options == 'function') { - options = {success: options}; - } - else if (options === undefined) { - options = {}; - } - method = options.type || this.attr2('method'); - action = options.url || this.attr2('action'); - url = (typeof action === 'string') ? $.trim(action) : ''; - url = url || window.location.href || ''; - if (url) { - // clean url (don't include hash vaue) - url = (url.match(/^([^#]+)/) || [])[1]; - } - options = $.extend(true, { - url: url, - success: $.ajaxSettings.success, - type: method || $.ajaxSettings.type, - iframeSrc: /^https/i.test(window.location.href || '') ? 'javascript:false' : 'about:blank' - }, options); - // hook for manipulating the form data before it is extracted; - // convenient for use with rich editors like tinyMCE or FCKEditor - var veto = {}; - this.trigger('form-pre-serialize', [this, options, veto]); - if (veto.veto) { - log('ajaxSubmit: submit vetoed via form-pre-serialize trigger'); - return this; - } - // provide opportunity to alter form data before it is serialized - if (options.beforeSerialize && options.beforeSerialize(this, options) === false) { - log('ajaxSubmit: submit aborted via beforeSerialize callback'); - return this; - } - var traditional = options.traditional; - if (traditional === undefined) { - traditional = $.ajaxSettings.traditional; - } - var elements = []; - var qx, a = this.formToArray(options.semantic, elements); - if (options.data) { - options.extraData = options.data; - qx = $.param(options.data, traditional); - } - // give pre-submit callback an opportunity to abort the submit - if (options.beforeSubmit && options.beforeSubmit(a, this, options) === false) { - log('ajaxSubmit: submit aborted via beforeSubmit callback'); - return this; - } - // fire vetoable 'validate' event - this.trigger('form-submit-validate', [a, this, options, veto]); - if (veto.veto) { - log('ajaxSubmit: submit vetoed via form-submit-validate trigger'); - return this; - } - var q = $.param(a, traditional); - if (qx) { - q = ( q ? (q + '&' + qx) : qx ); - } - if (options.type.toUpperCase() == 'GET') { - options.url += (options.url.indexOf('?') >= 0 ? '&' : '?') + q; - options.data = null; // data is null for 'get' - } - else { - options.data = q; // data is the query string for 'post' - } - var callbacks = []; - if (options.resetForm) { - callbacks.push(function () { - $form.resetForm(); - }); - } - if (options.clearForm) { - callbacks.push(function () { - $form.clearForm(options.includeHidden); - }); - } - // perform a load on the target only if dataType is not provided - if (!options.dataType && options.target) { - var oldSuccess = options.success || function () { - }; - callbacks.push(function (data) { - var fn = options.replaceTarget ? 'replaceWith' : 'html'; - $(options.target)[fn](data).each(oldSuccess, arguments); - }); - } - else if (options.success) { - callbacks.push(options.success); - } - options.success = function (data, status, xhr) { // jQuery 1.4+ passes xhr as 3rd arg - var context = options.context || this; // jQuery 1.4+ supports scope context - for (var i = 0, max = callbacks.length; i < max; i++) { - callbacks[i].apply(context, [data, status, xhr || $form, $form]); - } - }; - if (options.error) { - var oldError = options.error; - options.error = function (xhr, status, error) { - var context = options.context || this; - oldError.apply(context, [xhr, status, error, $form]); - }; - } - if (options.complete) { - var oldComplete = options.complete; - options.complete = function (xhr, status) { - var context = options.context || this; - oldComplete.apply(context, [xhr, status, $form]); - }; - } - // are there files to upload? - // [value] (issue #113), also see comment: - // https://github.com/malsup/form/commit/588306aedba1de01388032d5f42a60159eea9228#commitcomment-2180219 - var fileInputs = $('input[type=file]:enabled', this).filter(function () { - return $(this).val() !== ''; - }); - var hasFileInputs = fileInputs.length > 0; - var mp = 'multipart/form-data'; - var multipart = ($form.attr('enctype') == mp || $form.attr('encoding') == mp); - var fileAPI = feature.fileapi && feature.formdata; - log("fileAPI :" + fileAPI); - var shouldUseFrame = (hasFileInputs || multipart) && !fileAPI; - var jqxhr; - // options.iframe allows user to force iframe mode - // 06-NOV-09: now defaulting to iframe mode if file input is detected - if (options.iframe !== false && (options.iframe || shouldUseFrame)) { - // hack to fix Safari hang (thanks to Tim Molendijk for this) - // see: http://groups.google.com/group/jquery-dev/browse_thread/thread/36395b7ab510dd5d - if (options.closeKeepAlive) { - $.get(options.closeKeepAlive, function () { - jqxhr = fileUploadIframe(a); - }); - } - else { - jqxhr = fileUploadIframe(a); - } - } - else if ((hasFileInputs || multipart) && fileAPI) { - jqxhr = fileUploadXhr(a); - } - else { - jqxhr = $.ajax(options); - } - $form.removeData('jqxhr').data('jqxhr', jqxhr); - // clear element array - for (var k = 0; k < elements.length; k++) { - elements[k] = null; - } - // fire 'notify' event - this.trigger('form-submit-notify', [this, options]); - return this; - // utility fn for deep serialization - function deepSerialize(extraData) { - var serialized = $.param(extraData, options.traditional).split('&'); - var len = serialized.length; - var result = []; - var i, part; - for (i = 0; i < len; i++) { - // #252; undo param space replacement - serialized[i] = serialized[i].replace(/\+/g, ' '); - part = serialized[i].split('='); - // #278; use array instead of object storage, favoring array serializations - result.push([decodeURIComponent(part[0]), decodeURIComponent(part[1])]); - } - return result; - } - - // XMLHttpRequest Level 2 file uploads (big hat tip to francois2metz) - function fileUploadXhr(a) { - var formdata = new FormData(); - for (var i = 0; i < a.length; i++) { - formdata.append(a[i].name, a[i].value); - } - if (options.extraData) { - var serializedData = deepSerialize(options.extraData); - for (i = 0; i < serializedData.length; i++) { - if (serializedData[i]) { - formdata.append(serializedData[i][0], serializedData[i][1]); - } - } - } - options.data = null; - var s = $.extend(true, {}, $.ajaxSettings, options, { - contentType: false, - processData: false, - cache: false, - type: method || 'POST' - }); - if (options.uploadProgress) { - // workaround because jqXHR does not expose upload property - s.xhr = function () { - var xhr = $.ajaxSettings.xhr(); - if (xhr.upload) { - xhr.upload.addEventListener('progress', function (event) { - var percent = 0; - var position = event.loaded || event.position; - /*event.position is deprecated*/ - var total = event.total; - if (event.lengthComputable) { - percent = Math.ceil(position / total * 100); - } - options.uploadProgress(event, position, total, percent); - }, false); - } - return xhr; - }; - } - s.data = null; - var beforeSend = s.beforeSend; - s.beforeSend = function (xhr, o) { - //Send FormData() provided by user - if (options.formData) { - o.data = options.formData; - } - else { - o.data = formdata; - } - if (beforeSend) { - beforeSend.call(this, xhr, o); - } - }; - return $.ajax(s); - } - - // private function for handling file uploads (hat tip to YAHOO!) - function fileUploadIframe(a) { - var form = $form[0], el, i, s, g, id, $io, io, xhr, sub, n, timedOut, timeoutHandle; - var deferred = $.Deferred(); - // #341 - deferred.abort = function (status) { - xhr.abort(status); - }; - if (a) { - // ensure that every serialized input is still enabled - for (i = 0; i < elements.length; i++) { - el = $(elements[i]); - if (hasProp) { - el.prop('disabled', false); - } - else { - el.removeAttr('disabled'); - } - } - } - s = $.extend(true, {}, $.ajaxSettings, options); - s.context = s.context || s; - id = 'jqFormIO' + (new Date().getTime()); - if (s.iframeTarget) { - $io = $(s.iframeTarget); - n = $io.attr2('name'); - if (!n) { - $io.attr2('name', id); - } - else { - id = n; - } - } - else { - $io = $('').appendTo("body");j.find("a.Validform_close").click(function(){j.hide();i=true;if(g){g.focus().addClass("Validform_error")}return false}).focus(function(){this.blur()});d(window).bind("scroll resize",function(){!i&&h(j,400)})}d.Showmsg=function(k){c();a.util.showmsg.call(f,k,1,{})};d.Hidemsg=function(){j.hide();i=true}})(jQuery,window); diff --git a/public/script/pt.common.js b/public/script/pt.common.js deleted file mode 100644 index c7cd72c..0000000 --- a/public/script/pt.common.js +++ /dev/null @@ -1,9 +0,0 @@ -$.pt = $.pt || {}; -(function ($) { - $.pt.init = function () { - }; -})($); -$(function () { - -}); - diff --git a/template/README.md b/template/README.md deleted file mode 100644 index da8ad2c..0000000 --- a/template/README.md +++ /dev/null @@ -1 +0,0 @@ -template directorys diff --git a/template/default/common/message.html b/template/default/common/message.html deleted file mode 100644 index d41f605..0000000 --- a/template/default/common/message.html +++ /dev/null @@ -1,60 +0,0 @@ - - - {$msgname} 友情提示信息 - - - - - -
-
-
-
-

{$msgname}{$msgtitle}提示

-

{$message}

-
-
-
- {if $waitsecond} -
{$waitsecond}秒后自动跳转,如果浏览器没有自动跳转,请 点击这里
- - {/if} -
- - \ No newline at end of file diff --git a/template/default/config.ini b/template/default/config.ini deleted file mode 100644 index ae0b741..0000000 --- a/template/default/config.ini +++ /dev/null @@ -1,6 +0,0 @@ -name=默认模版 -description="这里填写模版简介" -author=杰少Pakey -version=1.0.0 -email=admin@ptcms.com -url=http://www.ptcms.com \ No newline at end of file diff --git a/template/default/config.php b/template/default/config.php deleted file mode 100644 index 2590d64..0000000 --- a/template/default/config.php +++ /dev/null @@ -1,28 +0,0 @@ - - array ( - 'name' => '焦点图', - 'value' => '大主宰|完美世界|莽荒纪|绝世唐门', - ), - 'bjtjtop' => - array ( - 'name' => '编辑推荐头条', - 'value' => '天醒之路', - ), - 'bjtj' => - array ( - 'name' => '编辑推荐列表', - 'value' => '魔天记|我欲封天|绝世武神|择天记|武极天下|灵域|永夜君王|校花的贴身高手|星战风暴', - ), - 'viptop' => - array ( - 'name' => 'vip推荐头条', - 'value' => '英雄联盟之谁与争锋|星河大帝', - ), - 'vip' => - array ( - 'name' => 'vip推荐列表', - 'value' => '剑道独尊|傲世九重天|最强弃少|天骄无双', - ), -); \ No newline at end of file diff --git a/template/default/demo.jpg b/template/default/demo.jpg deleted file mode 100644 index f354ed8..0000000 Binary files a/template/default/demo.jpg and /dev/null differ diff --git a/template/default/index/index_index.html b/template/default/index/index_index.html deleted file mode 100644 index f127558..0000000 --- a/template/default/index/index_index.html +++ /dev/null @@ -1,9 +0,0 @@ -

Hello World By PTcms Framework!

-
-

友情链接展示

-{block method="friendlink" name=list num=10} -{loop=$list} -{$loop.showname} -{/loop} -
-

广告展示

\ No newline at end of file