├── app ├── cache │ └── tpl │ │ └── index.html ├── index │ ├── tpl │ │ ├── index │ │ │ ├── footer.html │ │ │ ├── error.html │ │ │ ├── play.html │ │ │ ├── index.html │ │ │ └── header.html │ │ ├── user │ │ │ └── pwd.html │ │ └── area │ │ │ └── index.html │ ├── common.php │ └── ctrl │ │ ├── user.php │ │ ├── index.php │ │ ├── area.php │ │ └── api.php ├── admin │ ├── tpl │ │ ├── public │ │ │ └── header.html │ │ └── index │ │ │ ├── index.html │ │ │ ├── audit.html │ │ │ └── users.html │ ├── auth.php │ ├── ctrl │ │ ├── api.php │ │ ├── oper.php │ │ └── index.php │ └── common.php ├── common │ ├── log.php │ └── user.php └── common.php ├── robot ├── cml.e ├── com.icodef.xyjx.json └── jx_cq.py ├── static ├── image │ ├── avatar.png │ ├── logo.jpg │ └── search.png ├── ckplayer │ ├── ckplayer.swf │ ├── language.xml │ └── ckplayer.xml ├── css │ ├── css.css │ └── index.css ├── cmltable │ ├── cmltable.css │ └── cmltable.js └── js │ └── downlist.js ├── .gitignore ├── .htaccess ├── index.php ├── icf ├── lib │ ├── db.php │ ├── db │ │ ├── mysql.php │ │ └── query.php │ ├── log.php │ ├── view.php │ ├── route.php │ └── smtp.php ├── config.php ├── loader.php ├── index.php └── functions.php └── jx.sql /app/cache/tpl/index.html: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/index/tpl/index/footer.html: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /robot/cml.e: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodFrm/jx/master/robot/cml.e -------------------------------------------------------------------------------- /static/image/avatar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodFrm/jx/master/static/image/avatar.png -------------------------------------------------------------------------------- /static/image/logo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodFrm/jx/master/static/image/logo.jpg -------------------------------------------------------------------------------- /static/image/search.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodFrm/jx/master/static/image/search.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | /app/cache/tpl/*.php 3 | *.log 4 | /static/res 5 | /static/image/res 6 | 7 | -------------------------------------------------------------------------------- /robot/com.icodef.xyjx.json: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodFrm/jx/master/robot/com.icodef.xyjx.json -------------------------------------------------------------------------------- /static/ckplayer/ckplayer.swf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodFrm/jx/master/static/ckplayer/ckplayer.swf -------------------------------------------------------------------------------- /.htaccess: -------------------------------------------------------------------------------- 1 | 2 | Options +FollowSymlinks 3 | RewriteEngine On 4 | 5 | RewriteCond %{REQUEST_FILENAME} !-d 6 | RewriteCond %{REQUEST_FILENAME} !-f 7 | RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L] 8 | -------------------------------------------------------------------------------- /app/admin/tpl/public/header.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {$title} 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /app/admin/tpl/index/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Title 6 | 7 | 8 | 用户管理 9 | 软件审核 10 | 11 | -------------------------------------------------------------------------------- /app/index/tpl/index/error.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 错误页面 6 | 7 | 8 | 错误信息:{$error}
9 | 三秒后将跳转至 {$url} 10 | 11 | 16 | -------------------------------------------------------------------------------- /index.php: -------------------------------------------------------------------------------- 1 | .box-header { 6 | border-top-left-radius: 4px; 7 | border-top-right-radius: 4px; 8 | background: #e2e2e2; 9 | padding: 4px; 10 | box-shadow: 0px 0px 0px 1px #c7c6c6; 11 | } 12 | 13 | .box > .box-content { 14 | padding: 4px; 15 | background: #ffffff; 16 | box-shadow: 0px 0px 0px 1px #c7c6c6; 17 | overflow-x: hidden; 18 | min-height: 20px; 19 | } -------------------------------------------------------------------------------- /icf/lib/db/mysql.php: -------------------------------------------------------------------------------- 1 | true, 13 | 'db' => [ 14 | 'type' => 'mysql', 15 | 'server' => 'localhost', 16 | 'port' => 3306, 17 | 'db' => 'jx', 18 | 'user' => 'root', 19 | 'pwd' => '', 20 | 'prefix' => 'jx_' 21 | ], 22 | //模块,控制器,操作 默认关键字 23 | 'model_key' => 'm', 24 | 'ctrl_key' => 'c', 25 | 'action_key' => 'a', 26 | 'route' => [ 27 | 'get' => [ 28 | 'd/{sid}' => 'index->api->download', 29 | 'admin'=>'admin->index->index', 30 | 'sort/{sort_id}'=>'index->index->index', 31 | 'play/{sort_id}'=>'index->index->play' 32 | ] 33 | ], 34 | 'tpl_suffix' => 'html', 35 | 'public' => 'public', 36 | 'log' => true, 37 | 'pwd_deal' => 'df@#5!51Dw' 38 | ]; -------------------------------------------------------------------------------- /app/common/log.php: -------------------------------------------------------------------------------- 1 | insert(['log_uid' => $_COOKIE['uid'], 'log_msg' => "修改密码,被修改者UID:$uid", 'log_time' => time(), 'log_type' => 1]); 20 | return db::table()->lastinsertid(); 21 | } 22 | 23 | private static function log($msg, $type) { 24 | if (!isset($_COOKIE['uid'])) { 25 | $_COOKIE['uid'] = 0; 26 | } 27 | db::table('log')->insert(['log_uid' => $_COOKIE['uid'], 'log_msg' => $msg, 'log_time' => time(), 'log_type' => $type]); 28 | return db::table()->lastinsertid(); 29 | } 30 | 31 | public static function operIntegral($uid, $number) { 32 | return self::log(("积分操作 UID:$uid 变动:$number"), 2); 33 | } 34 | } -------------------------------------------------------------------------------- /icf/loader.php: -------------------------------------------------------------------------------- 1 | 'icf/lib']; 17 | //已加载 18 | static $loaded = []; 19 | 20 | /** 21 | * 加载类 22 | * @param $className 23 | * @return bool 24 | */ 25 | static function loadClass($className) { 26 | if (in_array($className, self::$loaded)) { 27 | return true; 28 | } 29 | self::$loaded[] = $className; 30 | //处理斜杠,linux系统中得用/ 31 | $className = str_replace('\\', '/', $className); 32 | //取出左边的路径 33 | $rootPath = substr($className, 0, strpos($className, '/')); 34 | $loadFile = __ROOT_ . '/' . (isset(loader::$path[$rootPath]) ? loader::$path[$rootPath] : $rootPath); 35 | $loadFile .= substr($className, strpos($className, '/')) . '.php'; 36 | if (is_file($loadFile)) { 37 | require_once $loadFile; 38 | } 39 | return true; 40 | } 41 | } -------------------------------------------------------------------------------- /app/index/tpl/index/play.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 7 | 8 | 播放页面 9 | 10 | 11 | 12 |
13 | 28 | 29 | -------------------------------------------------------------------------------- /static/ckplayer/language.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | [$second] 4 | [$second] 5 | 6 | 点击播放 7 | 暂停播放 8 | 静音 9 | 恢复音量 10 | 全屏 11 | 退出全屏 12 | 上一集 13 | 下一集 14 | 点击选择清晰度 15 | 16 | 17 | 音量:[$volume]% 18 | 19 | [$percentage]% 20 | 21 | [$timeh]:[$timei]:[$times] 22 | 23 | 24 | [$timeh]:[$timei]:[$times] 25 | 26 | 27 | 直播中 [$liveTimeY]-[$liveTimem]-[$liveTimed] [$liveTimeh]:[$liveTimei]:[$liveTimes] 28 | 29 | 30 | 流畅 31 | 低清 32 | 标清 33 | 高清 34 | 超清 35 | 蓝光 36 | 未知 37 | 38 | 39 | 视频地址不存在 40 | 加载失败 41 | 视频格式错误 42 | 43 | 自动 44 | -------------------------------------------------------------------------------- /app/admin/auth.php: -------------------------------------------------------------------------------- 1 | userMsg['group'] = [db::table('group')->where(['group_id' => 2])->find()]; 25 | } else { 26 | $this->userMsg = uidUser($_COOKIE['uid']); 27 | $this->userMsg['group'] = getGroup($_COOKIE['uid']); 28 | } 29 | foreach ($this->userMsg['group'] as $item) { 30 | if (isAuth($item['group_id'], $this->userMsg['auth'])) { 31 | $auth = true; 32 | break; 33 | } 34 | } 35 | if ($auth !== true) { 36 | header('Location:' . url('index/index/error', 'error=你没有相应的权限&url=' . url('/'))); 37 | exit(); 38 | } 39 | } 40 | 41 | public static function _error($msg, $url) { 42 | header('Location:' . url('index/index/error', 'error=' . $msg . '&url=' . $url)); 43 | } 44 | 45 | 46 | } -------------------------------------------------------------------------------- /app/index/common.php: -------------------------------------------------------------------------------- 1 | where('nav_father', 0)->select(); 15 | $rows = []; 16 | while ($row = $rec->fetch()) { 17 | $row['sub'] = getSubNav($row['nav_id']); 18 | $rows[] = $row; 19 | } 20 | return $rows; 21 | } 22 | 23 | function getSubNav($nav_id = 0) { 24 | $rec = db::table('nav')->where('nav_father', $nav_id)->select(); 25 | $rows = []; 26 | while ($row = $rec->fetch()) { 27 | $row['sub'] = getSubNav($row['nav_id']); 28 | $rows[] = $row; 29 | } 30 | return $rows; 31 | } 32 | 33 | function outSubNavHtml($nav) { 34 | if ($nav == []) { 35 | return ''; 36 | } 37 | $html = ''; 44 | return $html; 45 | } 46 | 47 | function outBreadcrumbHtml($sid) { 48 | $html = ''; 49 | while ($row = db::table('sort')->where(['sort_id' => $sid])->find()) { 50 | $html = '' . $row['sort_name'] . '' . '/' . $html; 51 | $sid = $row['sort_fid']; 52 | } 53 | $html = substr($html, 0, strlen($html) - 1); 54 | return (empty($html) ? '首页' : $html); 55 | } 56 | 57 | -------------------------------------------------------------------------------- /app/index/tpl/index/index.html: -------------------------------------------------------------------------------- 1 | {include 'header'} 2 |
3 |
4 | 5 |
6 |
7 | 8 |
9 |

我站提供用户下载的所有内容均来自互联网。如有内容侵犯您的版权或其他利益的,请编辑邮件并加以说明发送到我们的客服邮箱code.farmer@qq.com。我们会在三个工作日内为您删除。

10 |
11 | 50 | {include 'footer'} -------------------------------------------------------------------------------- /app/admin/ctrl/api.php: -------------------------------------------------------------------------------- 1 | ip_list)) { 22 | _404(); 23 | exit(); 24 | } 25 | if (_get('key') != 'aDgea233Emm') { 26 | _404(); 27 | exit(); 28 | } 29 | } 30 | 31 | public function apply($qq) { 32 | $user['user'] = $qq; 33 | $user['pwd'] = getRandString(8, 1); 34 | $user['email'] = "$qq@qq.com"; 35 | $path = time2path('static/res/images/', $user['avatar']) . $qq . '_' . time() . '.png'; 36 | $user['avatar'] = $user['avatar'] . $qq . '_' . time() . '.png'; 37 | getFile($path, 'http://q1.qlogo.cn/g?b=qq&nk=' . $qq . '&s=100'); 38 | return user::applyUser($user); 39 | } 40 | 41 | public function exp($user, $number) { 42 | $number = ceil($number); 43 | if ($number <= 0) { 44 | return '充值数量错误'; 45 | } 46 | if ($um = user::getUser($user)) { 47 | $lid = log::operIntegral($um['uid'], $number); 48 | $over = user::addIntegral($um['uid'], $number, $lid, 1); 49 | $home = url('/'); 50 | sendEmail($um ['email'], '积分兑换成功 - 信院计算机协会下载站', 51 | "

积分兑换成功

您成功的兑换了:{$number}点积分,您的积分余额为{$over}

" . 52 | "

快去使用吧: $home

" 53 | ); 54 | return '充值成功'; 55 | } else { 56 | return '用户不存在'; 57 | } 58 | } 59 | } -------------------------------------------------------------------------------- /icf/index.php: -------------------------------------------------------------------------------- 1 | notice('ip:' . getip() . ' url:' . getReqUrl() . ' post:' . json_encode($_POST, JSON_UNESCAPED_UNICODE) 52 | . ' cookie:' . json_encode($_COOKIE, JSON_UNESCAPED_UNICODE)); 53 | } 54 | //路由加载 55 | if (isset($config['route'])) { 56 | foreach ($config['route'] as $key => $item) { 57 | route::add($key, $item); 58 | } 59 | } 60 | route::analyze(); 61 | } 62 | } -------------------------------------------------------------------------------- /app/admin/common.php: -------------------------------------------------------------------------------- 1 | where(['uid' => $uid])->find(); 21 | } 22 | 23 | /** 24 | * 获取用户组信息 25 | * @author Farmer 26 | * @param $uid 27 | * @return array 28 | */ 29 | function getGroup($uid) { 30 | if ($rec = db::table('usergroup as a|group as b')->order('group_auth')->where(['uid' => $uid, 'a.group_id=b.group_id'])->select()) { 31 | return $rec->fetchAll(); 32 | } 33 | return []; 34 | } 35 | 36 | function isAuth($group_id, &$auth = array()) { 37 | $rec = db::table('groupauth as a|auth as b')->where(['group_id' => $group_id, 'a.auth_id=b.auth_id'])->select(); 38 | $model = input('model'); 39 | $ctrl = input('ctrl'); 40 | $action = input('action'); 41 | while ($msg = $rec->fetch()) { 42 | $auth[$msg['auth_interface']]=1; 43 | if ($count = substr_count($msg['auth_interface'], '->')) { 44 | if ($count == 1) { 45 | if (($model . '->' . $ctrl) == $msg['auth_interface']) { 46 | return true; 47 | } 48 | } else { 49 | if (($model . '->' . $ctrl . '->' . $action) == $msg['auth_interface']) { 50 | return true; 51 | } 52 | } 53 | 54 | } else { 55 | if ($msg['auth_interface'] == $model) { 56 | return true; 57 | } 58 | } 59 | } 60 | return false; 61 | } 62 | 63 | /** 64 | * 通过路径搜索文件 65 | * @author Farmer 66 | * @param $path 67 | * @return mixed 68 | */ 69 | function getPathSoft($path) { 70 | return db::table('soft_list as a')->where('soft_type', 0)->join(['user' => 'b'], 'a.soft_uid=b.uid')->where('soft_path', $path)->find(); 71 | } 72 | -------------------------------------------------------------------------------- /robot/jx_cq.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # -*- coding: UTF-8 -*- 3 | 4 | from socket import * 5 | import urllib2 6 | 7 | url='http://d.worldtreestd.com/' 8 | applyAccount =url+'admin/api/apply' 9 | excIntegral=url+'admin/api/exp' 10 | key='aDgea233Emm' 11 | def get(url): 12 | url=url+"&key="+key 13 | print url 14 | data='' 15 | try: 16 | response=urllib2.urlopen(url,timeout=20) 17 | data=response.read() 18 | # opear = urllib2.build_opener() 19 | # req = urllib2.Request(url) 20 | # res = opear.open(req,timeout=10) 21 | # data = res.read() 22 | except urllib2.HTTPError, e: 23 | if e.getcode()==404: 24 | data='接口错误!!请联系管理员' 25 | except: 26 | print url 27 | else: 28 | pass 29 | return data 30 | 31 | if __name__=='__main__': 32 | HOST='47.104.1.102' 33 | PORT=1214 34 | BUFSIZ=1024 35 | ADDR=(HOST, PORT) 36 | client=socket(AF_INET, SOCK_STREAM) 37 | client.settimeout(5) 38 | client.connect(ADDR) 39 | while True: 40 | try: 41 | data=client.recv(BUFSIZ) 42 | except: 43 | data='null' 44 | if not data: 45 | break 46 | client.send('ping') 47 | deal=data.split('\x00') 48 | if len(deal)<=1: 49 | #client.send('错误的参数') 50 | pass 51 | elif deal[1]=='1' and len(deal)==3:# 注册账号 52 | print deal 53 | getData=get(applyAccount+'?qq='+deal[2]) 54 | print getData 55 | if len(getData)>50: 56 | getData='服务器错误' 57 | client.send(deal[0]+'\x00'+'1'+'\x00'+getData) 58 | pass 59 | elif deal[1]=='2' and len(deal)==4: 60 | print deal 61 | getData=get(excIntegral+'?user='+deal[2]+'&number='+deal[3]) 62 | print "data:"+getData 63 | if len(getData)>50: 64 | getData='服务器错误' 65 | client.send(deal[0]+'\x00'+'2'+'\x00'+getData) 66 | pass 67 | else: 68 | client.send(deal[0]+'\x00'+'0'+'\x00'+'错误参数') 69 | pass 70 | print 'end' -------------------------------------------------------------------------------- /app/index/ctrl/user.php: -------------------------------------------------------------------------------- 1 | ['func' => ['\app\common\user::isUser', 'user'], 'regex' => ['/^[\x{4e00}-\x{9fa5}\w\@\.]{2,}$/u', '用户名不符合规则'], 'msg' => '请输入用户名', 'sql' => 'user'], 22 | 'pwd' => ['regex' => ['/^[\\~!@#$%^&*()-_=+|{}\[\], .?\/:;\'\"\d\w]{6,16}$/', '密码不符合规范'], 'msg' => '请输入密码'], 23 | 'npwd' => ['regex' => ['/^[\\~!@#$%^&*()-_=+|{}\[\], .?\/:;\'\"\d\w]{6,16}$/', '密码不符合规范'], 'msg' => '请输入新密码', 'sql' => 'pwd'], 24 | ], $data); 25 | if ($ret === true) { 26 | if (\app\common\user::encodePwd($this->userMsg['uid'], $_POST['pwd']) != $this->userMsg['pwd']) { 27 | return ['code' => -1, 'msg' => '旧密码不正确']; 28 | } 29 | $data['pwd'] = \app\common\user::encodePwd($this->userMsg['uid'], $data['pwd']); 30 | db::table('user')->where('uid', $this->userMsg['uid'])->update($data); 31 | db::table('token')->where('token', $_COOKIE['token'])->delete(); 32 | return ['code' => 0, 'msg' => '修改成功,请重新登陆']; 33 | } 34 | return ['code' => -1, 'msg' => $ret]; 35 | } else { 36 | view()->assign('user', $this->userMsg); 37 | view()->display(); 38 | } 39 | } 40 | 41 | public function remove_upload($sid) { 42 | if ($rows = db::table('soft_list')->where('sid', $sid)->where('soft_uid', $_COOKIE['uid'])->find()) { 43 | db::table('soft_list')->where('sid', $sid)->where('soft_uid', $_COOKIE['uid'])->update(['soft_type' => 5]); 44 | return json(['code' => 0, 'msg' => '删除成功']); 45 | } else { 46 | return json(['code' => -1, 'msg' => '未找到记录']); 47 | } 48 | } 49 | } -------------------------------------------------------------------------------- /app/index/tpl/user/pwd.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 用户信息修改页面 6 | 7 | 8 | 44 | 45 |
46 |
47 |
48 |
49 |
50 | 51 |
52 | 53 | 54 | 78 | -------------------------------------------------------------------------------- /app/admin/ctrl/oper.php: -------------------------------------------------------------------------------- 1 | $value) { 23 | $table->where($key, "%$value%", 'like'); 24 | } 25 | } 26 | $total = $table->count(); 27 | $table->limit(($page - 1) * 20, 20); 28 | $table->field($field); 29 | return ['rows' => $table->select()->fetchAll(), 'total' => $total, 'page' => ceil($total / 20), 'code' => 0, 'msg' => 'success']; 30 | } 31 | 32 | public function operUser($at = 'get', $page = 1, $keyword = '') { 33 | $ret = []; 34 | if ($at == 'get') { 35 | return self::getOper(db::table('user'), 'uid,user,email,avatar,integral', $page, ['user' => $keyword]); 36 | } else if ($at == 'add') { 37 | $_POST['avatar']=$_POST['image']; 38 | $ret = user::applyUser($_POST); 39 | if (strpos($ret, '成功') !== false) { 40 | return ['code' => 0, 'msg' => $ret]; 41 | } 42 | return ['code' => -1, 'msg' => $ret]; 43 | } else if ($at == 'cp') { 44 | $ret = isExist($_GET, [ 45 | 'npwd' => ['regex' => ['/^[\\~!@#$%^&*()-_=+|{}\[\], .?\/:;\'\"\d\w]{6,16}$/', '密码不符合规范'], 'msg' => '请输入密码', 'sql' => 'pwd'], 46 | ], $data); 47 | if ($ret === true) { 48 | db::table('user')->where('uid', _get('uid'))->update(['pwd' => user::encodePwd(_get('uid'), $data['pwd'])]); 49 | log::operChangePassword(_get('uid')); 50 | return ['code' => 0, 'msg' => '修改成功']; 51 | } 52 | return ['code' => 0, 'msg' => $ret]; 53 | } else if ($at == 'adi') { 54 | $n = ceil(_get('n')); 55 | $log = log::operIntegral(_get('uid'), $n); 56 | user::addIntegral(_get('uid'), $n, $log); 57 | return ['code' => 0, 'msg' => '操作成功']; 58 | } 59 | 60 | return $ret; 61 | } 62 | } -------------------------------------------------------------------------------- /app/index/ctrl/index.php: -------------------------------------------------------------------------------- 1 | assign('breadcrumb', outBreadcrumbHtml($sort_id)); 23 | $v->assign('sort_id', $sort_id); 24 | $v->assign('keydown', $keydown); 25 | $v->assign('user', $this->userMsg); 26 | $v->display(); 27 | } 28 | 29 | public function login() { 30 | $json = ['code' => -1, 'msg' => '系统错误']; 31 | $ret = isExist($_GET, [ 32 | 'user' => ['regex' => ['/^[\x{4e00}-\x{9fa5}\w\@\.]{2,}$/u', '用户名不符合规则'], 'msg' => '请输入用户名', 'sql' => 'user'], 33 | 'pwd' => ['regex' => ['/^[\\~!@#$%^&*()-_=+|{}\[\], .?\/:;\'\"\d\w]{6,16}$/', '密码不符合规范'], 'msg' => '请输入密码', 'sql' => 'password'], 34 | ], $data); 35 | if ($ret === true) { 36 | if ($userMsg = user::getUser($_GET['user'])) { 37 | if ($userMsg['pwd'] == user::encodePwd($userMsg['uid'], $_GET['pwd'])) { 38 | setcookie('token', getToken($userMsg['uid']), time() + 86400, '/'); 39 | setcookie('uid', $userMsg['uid'], time() + 86400, '/'); 40 | $json['code'] = 0; 41 | $json['msg'] = '登陆成功'; 42 | } else { 43 | $json['code'] = -1; 44 | $json['msg'] = '密码错误'; 45 | } 46 | } else { 47 | $json['msg'] = '账号不存在'; 48 | } 49 | } else { 50 | $json['msg'] = $ret; 51 | } 52 | return json($json); 53 | } 54 | 55 | public function play($sort_id) { 56 | view()->assign('url',__HOME_.'/d/'.$sort_id); 57 | view()->display(); 58 | } 59 | 60 | public function sign_out() { 61 | setcookie('uid', '', 0, '/'); 62 | setcookie('token', '', 0, '/'); 63 | header('location: ' . url('')); 64 | } 65 | 66 | public function error() { 67 | $v = new view(); 68 | $v->assign('error', _get('error')); 69 | $v->assign('url', _get('url')); 70 | $v->display(); 71 | } 72 | 73 | } -------------------------------------------------------------------------------- /icf/lib/log.php: -------------------------------------------------------------------------------- 1 | >> [notice] $msg"); 73 | } 74 | 75 | /** 76 | * 错误日志 77 | * @author Farmer 78 | * @param $msg 79 | * @return bool|int 80 | */ 81 | public function error($msg) { 82 | return self::wline(date('Y-m-d H:i:s') . ">>> [error] $msg"); 83 | } 84 | 85 | } -------------------------------------------------------------------------------- /app/index/tpl/index/header.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 信院计算机协会下载站 7 | 8 | 9 | 10 | 11 | 12 | 13 | 52 | 53 | 65 | 66 | -------------------------------------------------------------------------------- /app/index/tpl/area/index.html: -------------------------------------------------------------------------------- 1 | {include 'index/header'} 2 |
3 |
4 |
5 | 我所管理的分区 6 |
7 |
8 | {foreach $area_manage as $item} 9 | {$item['sort_name']} 10 | {/foreach} 11 |
12 |
13 |
14 |
15 | 分区内容条数 16 |
17 |
18 | {$total} 19 |
20 |
21 |
22 |
23 | 待审核列表 24 |
25 |
26 |
27 |
28 |
29 | 30 | 31 | 32 | 116 | {include 'index/footer'} -------------------------------------------------------------------------------- /icf/lib/view.php: -------------------------------------------------------------------------------- 1 | template load error'; 65 | return false; 66 | } 67 | $cache = __ROOT_ . '/app/cache/tpl/' . md5($path) . '.php'; 68 | self::fetch($path, $cache); 69 | return null; 70 | } 71 | 72 | /** 73 | * 生成编译文件并输出 74 | * 75 | * @author Farmer 76 | * @param string $path 77 | * @param string $cache 78 | * @return 79 | * 80 | */ 81 | private function fetch($path, $cache) { 82 | $fileData = file_get_contents($path); 83 | if (!file_exists($cache) || filemtime($path) > filemtime($cache)) { 84 | $pattern = array( 85 | '/\{(\$[\w\[\]\']+)\}/', 86 | '/{break}/', 87 | '/{continue}/', 88 | '/{if (.*?)}/', 89 | '/{\/if}/', 90 | '/{elseif (.*?)}/', 91 | '/{else}/', 92 | '/{foreach (.*?)}/', 93 | '/{\/foreach}/', 94 | "/{include '(.*?)'}/", 95 | '/{\:(.*?)}/' 96 | ); 97 | $replace = array( 98 | '', 99 | '', 100 | '', 101 | '', 102 | '', 103 | '', 104 | '', 105 | '', 106 | '', 107 | 'display("${1}");?>', 108 | '' 109 | ); 110 | $cacheData = preg_replace($pattern, $replace, $fileData); 111 | @file_put_contents($cache, $cacheData); 112 | } else { 113 | $cacheData = file_get_contents($cache); 114 | } 115 | $pattern = array( 116 | '/__PUBLIC__/', 117 | '/__HOME__/' 118 | ); 119 | $replace = array( 120 | input('config.public'), 121 | __HOME_ 122 | ); 123 | $cacheData = preg_replace($pattern, $replace, $cacheData); 124 | preg_match_all('/\{\$([a-zA-Z0-9]+)\}/', $fileData, $tmp); 125 | for ($i = 0; $i < sizeof($tmp [1]); $i++) { 126 | if (!isset (self::$tplVar [$tmp [1] [$i]])) { 127 | self::$tplVar [$tmp [1] [$i]] = ''; 128 | } 129 | } 130 | extract(self::$tplVar); 131 | eval ('?>' . $cacheData); 132 | } 133 | } -------------------------------------------------------------------------------- /app/index/ctrl/area.php: -------------------------------------------------------------------------------- 1 | getManageArea($_COOKIE['uid']); 35 | $sql = self::createAreaSql($area); 36 | $db = db::table('soft_list'); 37 | $db->where($sql); 38 | $total = $db->count(); 39 | $v->assign('total', $total); 40 | $v->assign('area_manage', $area); 41 | $v->assign('breadcrumb', '首页/' . $this->title . ''); 42 | $v->assign('user', $this->userMsg); 43 | $v->display(); 44 | } 45 | 46 | private function getManageArea($uid) { 47 | $rec = db::table('area_manager as a')->join(':sort as b', 'a.sort_id=b.sort_id') 48 | ->field(['sort_name', 'a.sort_id'])->where('uid', $uid)->select(); 49 | $retSort = []; 50 | while ($row = $rec->fetch()) { 51 | $tmp['sort_name'] = $row['sort_name']; 52 | $tmp['sort_id'] = $row['sort_id']; 53 | $retSort[$row['sort_id']] = $tmp; 54 | $retSort = array_merge($retSort, $this->forManageArea($row['sort_id'])); 55 | } 56 | return $retSort; 57 | } 58 | 59 | private function forManageArea($sid) { 60 | $retSort = []; 61 | $rec = db::table('sort') 62 | ->field(['sort_name', 'sort_id'])->where('sort_fid', $sid)->select(); 63 | while ($row = $rec->fetch()) { 64 | $tmp['sort_name'] = $row['sort_name']; 65 | $tmp['sort_id'] = $row['sort_id']; 66 | $retSort[$row['sort_id']] = $tmp; 67 | $retSort = array_merge($retSort, $this->forManageArea($row['sort_id'])); 68 | } 69 | return $retSort; 70 | } 71 | 72 | public function oper($at = 'get', $page = 1, $keyword = '') { 73 | if ($at == 'get') { 74 | $area = $this->getManageArea($_COOKIE['uid']); 75 | $sql = self::createAreaSql($area); 76 | $db = db::table('soft_list as a') 77 | ->join(':user as b', 'a.soft_uid=b.uid'); 78 | $db->where($sql)->where('soft_type', 0); 79 | $page = 80 | $json = oper::getOper($db, 81 | 'uid,sid,user,soft_filename as filename,soft_name as name,soft_path as file,soft_logo as image,soft_price as price,soft_name', 82 | $page, $keyword); 83 | foreach ($json['rows'] as $key => $item) { 84 | $json['rows'][$key]['file'] = getFileName($json['rows'][$key]['file']); 85 | } 86 | return $json; 87 | } else if ($at == 'pass') { 88 | $soft = db::table('soft_list')->where('sid', _get('sid'))->find(); 89 | $retJson = ['code' => -1]; 90 | $filePath = 'static/res/' . $soft['soft_path']; 91 | if (!is_file($filePath)) { 92 | $retJson['msg'] = '文件不存在'; 93 | return $retJson; 94 | } 95 | $tmpFile = md5($filePath) . '_' . $soft['soft_filename']; 96 | $newFile = time2path('static/res/soft/', $timePath) . $tmpFile; 97 | @rename($filePath, $newFile); 98 | db::table('soft_list')->where('sid', _get('sid'))->update(['soft_type' => 1, 'soft_path' => 'soft/' . $timePath . $tmpFile]); 99 | return ['code' => 0, 'msg' => '成功']; 100 | } else if ($at == 'refuse') { 101 | db::table('soft_list')->where('sid', _get('sid')) 102 | ->update(['soft_reason' => htmlspecialchars(_get('reason')), 'soft_type' => 2]); 103 | return ['code' => 0, 'msg' => '成功']; 104 | } 105 | } 106 | 107 | } 108 | -------------------------------------------------------------------------------- /app/admin/tpl/index/audit.html: -------------------------------------------------------------------------------- 1 | {include 'public/header'} 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | {foreach $list as $item} 14 | 15 | {if isset($item['sid'])} 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | {else} 24 | 25 | 26 | 27 | 28 | 29 | 30 | {/if} 31 | 34 | 35 | {/foreach} 36 | 37 |
软件名软件说明图标下载看看上传用户上传时间操作
{$item['soft_name']}{$item['soft_exp']}{$item['soft_path']}{$item['user']}{$item['soft_time']}{$item['name']}tmp/{$item['name']} 32 | 33 |
38 | 40 | 41 | 117 | -------------------------------------------------------------------------------- /icf/functions.php: -------------------------------------------------------------------------------- 1 | display(); 19 | } 20 | 21 | public function add() { 22 | 23 | } 24 | 25 | public function users() { 26 | view()->assign('title', '用户管理'); 27 | view()->display(); 28 | } 29 | 30 | /** 31 | * 审核文件 32 | * @author Farmer 33 | */ 34 | public function audit() { 35 | view()->assign('title', '文件审核'); 36 | $hDir = opendir(__ROOT_ . '/static/res/tmp'); 37 | $fileList = []; 38 | while ($row = readdir($hDir)) { 39 | if ($row == '.' || $row == '..') continue; 40 | $tmp = getPathSoft('tmp/' . $row); 41 | if (isset($tmp['sid'])) { 42 | $tmp['soft_time'] = date('Y-m-d H:i:s', $tmp['soft_time']); 43 | } 44 | $tmp['name'] = $row; 45 | $fileList[] = $tmp; 46 | } 47 | view()->assign('list', $fileList); 48 | view()->display(); 49 | } 50 | 51 | 52 | public function upload_image() { 53 | $json ['code'] = -2; 54 | $json ['msg'] = "系统错误"; 55 | if (isset ($_FILES ['upfile'] ['tmp_name'])) { 56 | if (is_uploaded_file($_FILES ['upfile'] ['tmp_name'])) { 57 | $upfile = $_FILES ["upfile"]; 58 | $tmp_name = $upfile ["tmp_name"]; // 上传文件的临时存放路径 59 | $error = $upfile ['error']; // 上传后系统返回的值 60 | if ($error == 0) { 61 | if ($format = isImg($tmp_name)) { 62 | $tmpFile = filePart(getFileName($upfile['name'])); 63 | $filename = $tmpFile[0] . '_' . time() . '.' . $tmpFile[1]; 64 | $destination = time2path('static/res/images/', $timePath) . $filename; 65 | $filename = $timePath . $filename; 66 | if (!(file_exists($destination))) { 67 | move_uploaded_file($tmp_name, $destination); 68 | } 69 | $json ['code'] = 0; 70 | $json ['msg'] = "上传成功"; 71 | $json ['url'] = $filename; 72 | } else { 73 | $json ['code'] = -1; 74 | $json ['msg'] = "上传失败"; 75 | } 76 | } else { 77 | $json ['code'] = $error; 78 | $json ['msg'] = '文件上传失败'; 79 | } 80 | } 81 | return json($json); 82 | } 83 | return $json; 84 | } 85 | 86 | public function operAudit() { 87 | $retJson = ['code' => -1, 'msg' => '系统错误']; 88 | if (_get('action') == 'accept') { 89 | if (!($soft_name = _get('soft_name'))) { 90 | $retJson['msg'] = '软件名不能为空'; 91 | return $retJson; 92 | } 93 | if (!is_file('static/res/images/' . _get('soft_logo'))) { 94 | $retJson['msg'] = '图片不存在'; 95 | return $retJson; 96 | } 97 | $filePath = 'static/res/' . _get('soft_path'); 98 | if (!is_file($filePath)) { 99 | $retJson['msg'] = '文件不存在'; 100 | return $retJson; 101 | } 102 | set_time_limit(0); 103 | $tmpFile = getFileName($filePath); 104 | $newFile = time2path('static/res/soft/', $timePath) . $tmpFile; 105 | @rename($filePath,$newFile); 106 | // @copy($filePath, $newFile); 107 | // @unlink($filePath); 108 | $newFile = 'soft/' . $timePath . $tmpFile; 109 | if (_get('sid')) { 110 | db::table('soft_list')->where('sid', _get('sid')) 111 | ->update([ 112 | 'soft_name' => _get('soft_name'), 113 | 'soft_exp' => _get('soft_exp'), 114 | 'soft_logo' => _get('soft_logo'), 115 | 'soft_path' => $newFile, 116 | 'soft_type' => 1, 117 | 'soft_time' => time() 118 | ]); 119 | } else { 120 | db::table('soft_list') 121 | ->insert([ 122 | 'soft_name' => _get('soft_name'), 123 | 'soft_exp' => _get('soft_exp'), 124 | 'soft_logo' => _get('soft_logo'), 125 | 'soft_path' => $newFile, 126 | 'soft_type' => 1, 127 | 'soft_time' => time(), 128 | 'soft_uid' => 0, 129 | ]); 130 | } 131 | $retJson['code'] = 0; 132 | $retJson['msg'] = '成功'; 133 | return $retJson; 134 | } else if (_get('action') == 'unaccept') { 135 | 136 | } 137 | return $retJson; 138 | } 139 | } 140 | -------------------------------------------------------------------------------- /app/common/user.php: -------------------------------------------------------------------------------- 1 | where('uid', $uid)->update('`integral`=`integral`+' . $number); 35 | $um = uidUser($uid); 36 | db::table('integral_change')->insert(['ic_uid' => $uid, 'ic_oper_type' => 100 + $type, 'ic_detail' => $detail, 37 | 'ic_number' => $number, 'ic_time' => time(), 'ic_param_id' => $param, 'ic_over_integral' => $um['integral']]); 38 | return $um['integral']; 39 | } 40 | 41 | public static function buy_soft($sid) { 42 | if ($soft = sidSoft($sid)) { 43 | if (db::table('integral_change')->where(['ic_param_id' => $sid, 'ic_uid' => _cookie('uid')])->find()) { 44 | return true; 45 | } 46 | $user = uidUser(_cookie('uid')); 47 | $spend = $soft['soft_price'] <= 0 ? 1 : $soft['soft_price'] + 1; 48 | if ($user['integral'] < $spend) { 49 | return '积分不足'; 50 | } 51 | db::table('user')->where('uid', $user['uid'])->update('`integral`=`integral`-' . $spend); 52 | $um = uidUser($user['uid']); 53 | db::table('integral_change')->insert(['ic_oper_type' => 1, 54 | 'ic_detail' => '购买' . $soft['soft_name'] . '花费' . $spend . '积分', 'ic_uid' => $user['uid'], 55 | 'ic_number' => -$spend, 56 | 'ic_time' => time(), 'ic_param_id' => $sid, 'ic_over_integral' => $um['integral']]); 57 | self::addIntegral($soft['soft_uid'], $soft['soft_price'], $sid, 3); 58 | return true; 59 | } 60 | return '软件不存在'; 61 | } 62 | 63 | /** 64 | * 验证用户名 65 | * @author Farmer 66 | * @param $user 67 | * @return bool|string 68 | */ 69 | public static function isUser($user, $my = null) { 70 | if ($um = self::getUser($user)) { 71 | if (is_null($my)) { 72 | return '用户名已经被注册'; 73 | } 74 | return ($um['user'] == $my ?: '用户名已经被注册'); 75 | } else { 76 | return true; 77 | } 78 | } 79 | 80 | public static function getUser($user) { 81 | return db::table('user')->where('uid', $user)->_or()->where('user', $user)->_or()->where('email', $user)->find(); 82 | } 83 | 84 | public static function applyUser($user) { 85 | $ret = isExist($user, [ 86 | 'user' => ['func' => ['\app\common\user::isUser'], 'regex' => ['/^[\x{4e00}-\x{9fa5}\w\@\.]{2,}$/u', '用户名不符合规则'], 'msg' => '请输入用户名', 'sql' => 'user'], 87 | 'pwd' => ['regex' => ['/^[\\~!@#$%^&*()-_=+|{}\[\], .?\/:;\'\"\d\w]{6,16}$/', '密码不符合规范'], 'msg' => '请输入密码', 'sql' => 'pwd'], 88 | 'email' => ['func' => ['\app\common\user::isEmail'], 'regex' => ['/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/', '邮箱不符合规则', 'msg' => '请输入邮箱'], 'sql' => 'email'], 89 | 'avatar' => ['func' => ['is_res'], 'msg' => '头像不存在', 'sql' => 'avatar'] 90 | ], $data); 91 | if ($ret === true) { 92 | $pwdUrl = url('index/user/pwd'); 93 | //添加用户 94 | $data['integral'] = 10; 95 | db::table('user')->insert($data); 96 | $uid = db::table()->lastinsertid(); 97 | set_time_limit(0); 98 | sendEmail($user['email'], '欢迎加入 - 信院计算机协会下载站', 99 | "

欢迎加入

您的登陆账号:{$data['user']} (邮箱,用户id都可以用于登陆 邮箱:{$data['email']}用户id为:$uid)

" . 100 | "

密码:{$data['pwd']}

密码修改可以访问 $pwdUrl进行修改

" 101 | ); 102 | db::table('user')->where('uid', $uid)->update(['pwd' => user::encodePwd($uid, $data['pwd'])]); 103 | //添加权限 104 | db::table('usergroup')->insert(['uid' => $uid, 'group_id' => 2]); 105 | db::table('usergroup')->insert(['uid' => $uid, 'group_id' => 3]); 106 | return '申请成功,请注意邮箱邮件'; 107 | } 108 | return $ret; 109 | } 110 | 111 | /** 112 | * 验证邮箱 113 | * @author Farmer 114 | * @param $user 115 | * @return bool|string 116 | */ 117 | public static function isEmail($email) { 118 | if (self::getUser($email)) { 119 | return '邮箱已经被注册'; 120 | } else { 121 | return true; 122 | } 123 | } 124 | 125 | /** 126 | * 编码密码 127 | * @author Farmer 128 | * @param $uid 129 | * @param $pwd 130 | * @return string 131 | */ 132 | public static function encodePwd($uid, $pwd) { 133 | $str = md5($uid) . md5($pwd) . _config('pwd_deal'); 134 | return md5($str); 135 | } 136 | 137 | } -------------------------------------------------------------------------------- /static/css/index.css: -------------------------------------------------------------------------------- 1 | * { 2 | font-family: 微软雅黑, "Microsoft YaHei"; 3 | } 4 | 5 | body { 6 | margin: 0 auto; 7 | min-width: 700px; 8 | width: 60%; 9 | } 10 | 11 | #header { 12 | min-width: 700px; 13 | margin-top: 10px; 14 | } 15 | 16 | a { 17 | text-decoration: none; 18 | } 19 | 20 | .logo { 21 | height: 60px; 22 | width: 60px; 23 | border-radius: 100%; 24 | } 25 | 26 | .title { 27 | display: inline; 28 | } 29 | 30 | .title > span { 31 | position: absolute; 32 | line-height: 60px; 33 | font-size: 28px; 34 | margin-left: 10px; 35 | } 36 | 37 | .login { 38 | padding: 4px; 39 | float: right; 40 | } 41 | 42 | #content { 43 | margin-top: 10px; 44 | } 45 | 46 | .soft-list > .item { 47 | border-right: 1px solid #cacaca; 48 | border-bottom: 1px solid #cacaca; 49 | border-left: 1px solid #cacaca; 50 | padding: 4px; 51 | line-height: 32px; 52 | overflow: hidden; 53 | } 54 | 55 | /** 56 | first-child 第一个 57 | */ 58 | .soft-list > .item:first-child { 59 | border-top: 1px solid #cacaca; 60 | border-top-left-radius: 4px; 61 | border-top-right-radius: 4px; 62 | } 63 | 64 | .soft-list > .item:nth-last-of-type(2) { 65 | border-bottom-left-radius: 4px; 66 | border-bottom-right-radius: 4px; 67 | } 68 | 69 | .soft-list > .item > .item-left { 70 | width: 70%; 71 | } 72 | 73 | .soft-list > .item > .item-right { 74 | width: 30%; 75 | margin: 0; 76 | text-align: center; 77 | } 78 | 79 | .download { 80 | display: block; 81 | width: 70px; 82 | padding: 0 10px 0 10px; 83 | margin: 0 auto; 84 | margin-top: 4px; 85 | border: 0; 86 | background: #72acf5; 87 | color: #fff; 88 | height: 30px; 89 | border-radius: 4px; 90 | box-shadow: 1px 2px 1px #adadad; 91 | cursor: pointer; 92 | } 93 | 94 | .soft-list > .item > .item-left, 95 | .soft-list > .item > .item-right { 96 | float: left; 97 | } 98 | 99 | .soft-list > .item > .item-left > img { 100 | width: 32px; 101 | height: 32px; 102 | } 103 | 104 | .soft-title { 105 | position: absolute; 106 | margin-left: 4px; 107 | color: #000000; 108 | } 109 | 110 | /** 111 | 说明 112 | */ 113 | .soft-exp { 114 | color: #575757; 115 | font-size: 14px; 116 | margin: 0; 117 | } 118 | 119 | .page > .page-item { 120 | display: inline-block; 121 | width: 20px; 122 | height: 20px; 123 | line-height: 20px; 124 | padding: 2px; 125 | cursor: pointer; 126 | text-align: center; 127 | float: left; 128 | border: 1px solid #cccccc; 129 | border-right: 0; 130 | user-select: none; 131 | } 132 | 133 | .page > .page-item:first-child { 134 | border-top-left-radius: 4px; 135 | border-bottom-left-radius: 4px; 136 | } 137 | 138 | .page > .page-item:last-child { 139 | border-right: 1px solid #cccccc; 140 | border-top-right-radius: 4px; 141 | border-bottom-right-radius: 4px; 142 | } 143 | 144 | .page > .page-item.active { 145 | background: #8ac7f7; 146 | color: #fff; 147 | } 148 | 149 | .btn { 150 | float: right; 151 | cursor: pointer; 152 | height: 55px; 153 | } 154 | 155 | .user-msg { 156 | float: right; 157 | } 158 | 159 | .user-msg > .left { 160 | float: left; 161 | margin-right: 10px; 162 | font-size: 12px; 163 | line-height: 30px; 164 | text-align: right; 165 | } 166 | 167 | .user-msg > .left > .user-oper { 168 | display: block; 169 | } 170 | 171 | .user-msg > .left > .user-oper > a { 172 | color: #2196F3; 173 | } 174 | 175 | .nav { 176 | margin-top: 10px; 177 | overflow: hidden; 178 | background: linear-gradient(#03A9F4, #2196F3); 179 | border-radius: 4px; 180 | } 181 | 182 | .nav > .nav-item:first-child { 183 | border-bottom-left-radius: 4px; 184 | border-top-left-radius: 4px; 185 | padding-left: 4px; 186 | } 187 | 188 | .nav > .nav-item { 189 | display: inline-block; 190 | cursor: pointer; 191 | background: linear-gradient(#03A9F4, #2196F3); 192 | padding: 4px; 193 | float: left; 194 | } 195 | 196 | .nav > .nav-item a { 197 | font-weight: 500; 198 | color: #ffffff; 199 | } 200 | 201 | .nav > .nav-item:not(:first-child):before { 202 | content: ' '; 203 | border-left: 1px solid #1cc3cc; 204 | position: relative; 205 | left: -4px; 206 | } 207 | 208 | .nav > .nav-item:hover { 209 | background: #1690f4; 210 | } 211 | 212 | .nav > .search { 213 | float: right; 214 | margin-right: 10px; 215 | } 216 | 217 | .nav > .search { 218 | height: 28px; 219 | line-height: 25px; 220 | } 221 | 222 | .search > .keydown { 223 | border-radius: 2px; 224 | border: 0; 225 | padding: 2px; 226 | outline: none; 227 | } 228 | 229 | .btn-search { 230 | border: 0; 231 | cursor: pointer; 232 | border-radius: 4px; 233 | vertical-align: middle; 234 | } 235 | 236 | .btn-search > .search-img { 237 | width: 16px; 238 | height: 16px; 239 | } 240 | 241 | .nav > .nav-item:hover > .nav-sub, 242 | .nav-sub > .nav-sub-item:hover > .nav-sub { 243 | display: block; 244 | } 245 | 246 | .nav-sub { 247 | display: none; 248 | position: absolute; 249 | margin-top: 4px; 250 | margin-left: -4px; 251 | min-width: 90px; 252 | background: rgb(215, 215, 215); 253 | border: 1px solid rgb(201, 201, 201); 254 | border-bottom-right-radius: 2px; 255 | border-bottom-left-radius: 2px; 256 | text-align: center; 257 | z-index: 100; 258 | } 259 | 260 | .nav-sub > .nav-sub-item > .nav-sub { 261 | display: none; 262 | margin: 0; 263 | top: -1px; 264 | right: calc(-100% - 2px); 265 | } 266 | 267 | .nav-sub > .nav-sub-item > .nav-sub:first-child { 268 | border-top: 1px solid rgb(201, 201, 201); 269 | } 270 | 271 | .nav-sub > .nav-sub-item:hover { 272 | background: #c2cad8; 273 | } 274 | 275 | .breadcrumb { 276 | margin-top: 4px; 277 | border: 1px solid #ccc; 278 | display: inline-block; 279 | border-radius: 3px; 280 | background: #ccc; 281 | padding: 2px; 282 | font-size: 12px; 283 | color: #929292; 284 | line-height: 15px; 285 | vertical-align: middle; 286 | min-width: 38px; 287 | text-align: center; 288 | } 289 | 290 | .breadcrumb > a { 291 | color: #03A9F4; 292 | } 293 | 294 | .select-group { 295 | /*border: 0px solid #cccccc;*/ 296 | /*border-radius: 2px;*/ 297 | border: 0px; 298 | outline: none; 299 | appearance: none; 300 | -moz-appearance: none; 301 | -webkit-appearance: none; 302 | width: 40px; 303 | font-size: 12px; 304 | } 305 | 306 | .select-group > option { 307 | text-align: center; 308 | } -------------------------------------------------------------------------------- /app/common.php: -------------------------------------------------------------------------------- 1 | $value) { 22 | if (is_string($value)) { 23 | if (empty($array[$key])) { 24 | return $value; 25 | } 26 | } else if (is_array($value)) { 27 | if (empty($array[$key])) { 28 | return $value['msg']; 29 | } 30 | if (!empty($value['regex'])) {//正则 31 | if (!preg_match($value['regex'][0], $array[$key])) { 32 | return $value['regex'][1]; 33 | } 34 | } 35 | if (!empty($value['func'])) {//对函数处理 36 | $tmpFunction = $value['func']; 37 | $funName = $value['func'][0]; 38 | $parameter = array(); 39 | unset($tmpFunction[0]); 40 | $parameter[] = $array[$key]; 41 | foreach ($tmpFunction as $v) { 42 | $parameter[] = $array[$v]; 43 | } 44 | $tmpValue = call_user_func_array($funName, $parameter); 45 | if ($tmpValue !== true) { 46 | return $tmpValue; 47 | } 48 | } 49 | if (!empty($value['enum'])) {//判断枚举类型 50 | if (!in_array($array[$key], $value['enum'][0])) { 51 | return $value['enum'][1]; 52 | } 53 | } 54 | if (!empty($value['sql'])) {//将其复制给sql插入数组 55 | $data[$value['sql']] = $array[$key]; 56 | } 57 | } 58 | } 59 | return true; 60 | } 61 | 62 | /** 63 | * 取随机字符串 64 | * @author Farmer 65 | * @param $length 66 | * @param $type 67 | * @return string 68 | */ 69 | function getRandString($length, $type = 2) { 70 | $randString = '1234567890qwwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHHJKLZXCVBNM'; 71 | $retStr = ''; 72 | for ($n = 0; $n < $length; $n++) { 73 | $retStr .= substr($randString, rand(0, 9 + $type * 24), 1); 74 | } 75 | return $retStr; 76 | } 77 | 78 | 79 | function isLogin() { 80 | if ($uid = _cookie('uid') && $token = _cookie('token')) { 81 | return verifyToken(_cookie('uid'), _cookie('token')); 82 | } 83 | return false; 84 | } 85 | 86 | /** 87 | * 获取token 88 | * @author Farmer 89 | * @param $uid 90 | * @return string 91 | */ 92 | function getToken($uid) { 93 | $token = getRandString(8, 2) . time(); 94 | db::table('token')->insert(['uid' => $uid, 'token' => $token, 'time' => time()]); 95 | db::table('token')->where('time<' . (time() - 604800))->delete(); 96 | return $token; 97 | } 98 | 99 | /** 100 | * 验证token 101 | * @author Farmer 102 | * @param $uid 103 | * @param $token 104 | * @return bool 105 | */ 106 | function verifyToken($uid, $token) { 107 | $where = ['token' => $token, 'uid' => $uid]; 108 | $tokenMsg = db::table('token')->where($where)->find(); 109 | if (!$tokenMsg) { 110 | return false; 111 | } else if ($tokenMsg['time'] + 604800 < time()) { 112 | db::table('token')->where($where)->delete($where); 113 | return false; 114 | } 115 | db::table('token')->where($where)->update(['time' => time()]); 116 | return true; 117 | } 118 | 119 | /** 120 | * 判断文件是不是图片 121 | * 122 | * @author Farmer 123 | * @param string $fileName 124 | * @return bool 125 | * 126 | */ 127 | function isImg($fileName) { 128 | $file = fopen($fileName, "rb"); 129 | $bin = fread($file, 2); // 只读2字节 130 | 131 | fclose($file); 132 | $strInfo = @unpack("C2chars", $bin); 133 | $typeCode = intval($strInfo ['chars1'] . $strInfo ['chars2']); 134 | $fileType = ''; 135 | if ($typeCode == 255216 /*jpg*/ || $typeCode == 7173 /*gif*/ || $typeCode == 13780 /*png*/) { 136 | return $typeCode; 137 | } else { 138 | return false; 139 | } 140 | } 141 | 142 | 143 | /** 144 | * 分割文件 145 | * @author Farmer 146 | * @param $filename 147 | * @return array 148 | */ 149 | function filePart($filename) { 150 | $arr = explode('.', $filename, strrpos($filename, '.') - 1); 151 | if (sizeof($arr) < 2) { 152 | $arr[] = 'png'; 153 | } 154 | return $arr; 155 | } 156 | 157 | 158 | /** 159 | * 通过路径获取文件名 160 | * @author Farmer 161 | * @param $path 162 | * @return bool|string 163 | */ 164 | function getFileName($path) { 165 | if (($pos = strrpos($path, '/')) !== false) { 166 | $pos++; 167 | } 168 | $s = substr($path, $pos); 169 | return $s; 170 | } 171 | 172 | /** 173 | * sid获取软件信息 174 | * @author Farmer 175 | * @param $sid 176 | * @return mixed 177 | */ 178 | function sidSoft($sid) { 179 | return db::table('soft_list')->where('sid', $sid)->find(); 180 | } 181 | 182 | 183 | function sendEmail($to, $title, $content) { 184 | $smtpserver = "smtp.exmail.qq.com";//SMTP服务器 185 | $smtpserverport = 465;//SMTP服务器端口 186 | $smtpusermail = "love@icodef.com";//SMTP服务器的用户邮箱 187 | $smtpemailto = $to;//发送给谁 188 | $smtpuser = "love@icodef.com";//SMTP服务器的用户帐号(或填写new2008oh@126.com,这项有些邮箱需要完整的) 189 | $emailname = "计协下载站"; 190 | $smtppass = "VAhBsdKFPUf53QZc";//SMTP服务器的用户密码 191 | $mailtitle = $title;//邮件主题 192 | $mailcontent = $content;//邮件内容 193 | $smtp = new icf\lib\smtp(); 194 | $smtp->setName($emailname); 195 | $smtp->setServer($smtpserver, $smtpusermail, $smtppass, $smtpserverport, true); //设置smtp服务器,到服务器的SSL连接 196 | $smtp->setFrom($smtpuser); //设置发件人 197 | $smtp->setReceiver($smtpemailto); //设置收件人,多个收件人,调用多次 198 | $smtp->setMail($mailtitle, $mailcontent); //设置邮件主题、内容 199 | return $smtp->sendMail(); //发送 200 | } 201 | 202 | 203 | /** 204 | * 资源是否存在 205 | * @author Farmer 206 | * @param $path 207 | * @param int $type 208 | * @return bool 209 | */ 210 | function is_res($path, $type = 1) { 211 | if ($type == 1) { 212 | return is_file('static/res/images/' . $path); 213 | } 214 | return '文件不存在'; 215 | } 216 | 217 | 218 | /** 219 | * 时间转路径并创建目录 220 | * @author Farmer 221 | * @param $path 222 | * @return bool|string 223 | */ 224 | function time2path($path = '/', &$timePath = '') { 225 | $year = date('Y'); 226 | $month = date('m'); 227 | if (!file_exists($path . $year)) { 228 | if (!mkdir($path . $year, 0777, true)) return false; 229 | } 230 | if (!file_exists($path . $year . '/' . $month)) { 231 | if (!mkdir($path . $year . '/' . $month, 0777, true)) return false; 232 | } 233 | $timePath = $year . '/' . $month . '/'; 234 | return $path . $year . '/' . $month . '/'; 235 | } 236 | 237 | 238 | function getFile($path, $url) { 239 | $ch = curl_init(); 240 | $timeout = 5; 241 | curl_setopt($ch, CURLOPT_URL, $url); 242 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 243 | curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); 244 | $content = curl_exec($ch); 245 | curl_close($ch); 246 | $fp2 = @fopen($path, 'a'); 247 | fwrite($fp2, $content); 248 | fclose($fp2); 249 | } -------------------------------------------------------------------------------- /static/cmltable/cmltable.css: -------------------------------------------------------------------------------- 1 | .cmltable { 2 | width: 100%; 3 | border: 1px solid #D5D5D5; 4 | border-spacing: 0; 5 | box-shadow: 0 1px 1px rgba(0, 0, 0, .04); 6 | font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; 7 | } 8 | 9 | .cmltable tr > th { 10 | background-color: rgb(238, 238, 238); 11 | font-weight: 400; 12 | text-align: left; 13 | padding-top: 4px; 14 | padding-bottom: 4px; 15 | } 16 | 17 | .cmltable tr > td { 18 | padding-top: 4px; 19 | padding-bottom: 4px; 20 | } 21 | 22 | .cmltable th, 23 | .cmltable td { 24 | height: 30px; 25 | } 26 | 27 | .cmltable-check { 28 | padding-left: 2px; 29 | margin-left: 4px; 30 | height: 20px; 31 | width: 20px; 32 | line-height: 20px; 33 | font-weight: bold; 34 | color: #20ABD9; 35 | display: block; 36 | background-color: #FFFFFF; 37 | border: 1px solid #C6C5C5; 38 | box-shadow: inset 0 1px 2px rgba(0, 0, 0, .1); 39 | cursor: pointer; 40 | user-select: none; 41 | text-align: center; 42 | } 43 | 44 | .cmltable-select { 45 | margin: 4px 0; 46 | min-width: 100px; 47 | height: 30px; 48 | outline: none; 49 | border: 1px solid #D5D5D5; 50 | user-select: none; 51 | box-shadow: 0 1px 1px rgba(0, 0, 0, .04); 52 | } 53 | 54 | .cmltable-select:focus { 55 | box-shadow: 0 0 1px #3DA3FF; 56 | } 57 | 58 | .cmltable-btn { 59 | outline: none; 60 | border: 1px solid #D5D5D5; 61 | width: 60px; 62 | height: 30px; 63 | background-color: #FFFFFF; 64 | cursor: pointer; 65 | border-radius: 2px; 66 | box-shadow: 1px 1px 1px rgba(0, 0, 0, .1); 67 | } 68 | 69 | .cmltable-btn:active { 70 | box-shadow: inset 1px 1px 1px rgba(0, 0, 0, .1); 71 | } 72 | 73 | .cmltable-btn:hover { 74 | background-color: #e6e6e6; 75 | } 76 | 77 | .cmltable-search { 78 | float: right; 79 | } 80 | 81 | .cmltable-search-edit { 82 | padding: 0; 83 | padding-left: 4px; 84 | margin: 0; 85 | } 86 | 87 | .cmltable-footer { 88 | margin-top: 4px; 89 | } 90 | 91 | .cmltable-footer > p { 92 | display: inline-block; 93 | margin: 0; 94 | font-size: 14px; 95 | } 96 | 97 | .cmltable-pages { 98 | float: right; 99 | margin: 0; 100 | } 101 | 102 | .cmltable-pages > button { 103 | width: 30px; 104 | height: 26px; 105 | } 106 | 107 | .cmltable-btngroup > .cmltable-btn:first-child { 108 | border-top-left-radius: 2px; 109 | border-bottom-left-radius: 2px; 110 | } 111 | 112 | .cmltable-btngroup > .cmltable-btn:last-child { 113 | border-top-right-radius: 2px; 114 | border-bottom-right-radius: 2px; 115 | border-right: 1px solid #d5d5d5; 116 | } 117 | 118 | .cmltable-btngroup > .cmltable-btn { 119 | border-radius: 0; 120 | border-right: 0; 121 | border-left: 1px solid #D5D5D5; 122 | float: left; 123 | color: #000000; 124 | } 125 | 126 | .cmltable-btn-active { 127 | cursor: auto; 128 | background-color: #0099CC; 129 | border: 0; 130 | } 131 | 132 | .cmltable-btn-active:hover { 133 | background-color: #0099cc; 134 | } 135 | 136 | .cmltable-switch{ 137 | height: 20px; 138 | width: 40px; 139 | /*border: 1px solid #c5c5c5;*/ 140 | border-radius: 2px; 141 | cursor: pointer; 142 | background-color: #f4f4f4; 143 | } 144 | 145 | .cmltable-switch >.cmltable-switch-on{ 146 | width: 50%; 147 | height: 100%; 148 | background-color: #64bd63; 149 | display: block; 150 | } 151 | 152 | 153 | .cml-msg{ 154 | position: absolute; 155 | left: 50%; 156 | top: 20%; 157 | width: 400px; 158 | margin-top: -100px; 159 | margin-left: -200px; 160 | border: 1px solid rgba(204, 204, 204, 0.4); 161 | background-color: #ffffff; 162 | border-radius: 2px; 163 | box-shadow: 1px 1px 1px rgba(204, 204, 204, 0.4); 164 | } 165 | .cml-msg > .cml-msg-header{ 166 | color: #ffffff; 167 | background-color: #0099CC; 168 | line-height: 30px; 169 | height: 30px; 170 | padding: 0 4px; 171 | } 172 | .cml-msg > .cml-msg-body{ 173 | padding:4px; 174 | min-height: 120px; 175 | border-bottom: 1px solid rgba(204, 204, 204, 0.4); 176 | text-align: center; 177 | } 178 | .cml-msg > .cml-msg-footer{ 179 | height: 40px; 180 | line-height: 40px; 181 | padding: 4px; 182 | } 183 | 184 | .cml-cover{ 185 | z-index: 10000; 186 | position: fixed; 187 | left:0; 188 | bottom: 0; 189 | right: 0; 190 | top: 0; 191 | background-color: rgba(232, 232, 232, 0.8); 192 | } 193 | .cml-btn{ 194 | border: 0; 195 | outline: none; 196 | cursor: pointer; 197 | background-color: #0099CC; 198 | color: #ffffff; 199 | min-width: 60px; 200 | height: 30px; 201 | line-height: 30px; 202 | margin-left: 10px; 203 | } 204 | 205 | .cml-btn:active{ 206 | box-shadow: inset 1px 1px; 207 | } 208 | 209 | .cml-msg{ 210 | z-index: 100000; 211 | } 212 | 213 | .cml-checkbox{ 214 | outline: none; 215 | border: 1px solid #000000; 216 | padding: 2px; 217 | display: inline-block; 218 | content: '\2714'; 219 | position: absolute; 220 | } 221 | 222 | .cml-form-label{ 223 | margin-right: 6px; 224 | padding-top: 5px; 225 | font-size: 16px; 226 | color: #888; 227 | font-weight: inherit; 228 | text-align: right; 229 | } 230 | 231 | .cml-form-input[type=text]{ 232 | min-width:200px; 233 | outline: none; 234 | line-height: 1.42857; 235 | color: #4d6b8a; 236 | background-color: #fff; 237 | background-image: none; 238 | border: 1px solid #c2cad8; 239 | border-radius: 4px; 240 | -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); 241 | box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); 242 | -webkit-transition: border-color ease-in-out 0.15s, box-shadow ease-in-out 0.15s; 243 | -o-transition: border-color ease-in-out 0.15s, box-shadow ease-in-out 0.15s; 244 | transition: border-color ease-in-out 0.15s, box-shadow ease-in-out 0.15s; 245 | background: 0 0; 246 | border: 1px solid #c2cad8; 247 | border-bottom: 1px solid #c2cad8; 248 | -webkit-border-radius: 0; 249 | -moz-border-radius: 0; 250 | -ms-border-radius: 0; 251 | -o-border-radius: 0; 252 | border-radius: 0; 253 | color: #555; 254 | box-shadow: none; 255 | padding-left: 2px; 256 | padding-right: 0; 257 | font-size: 14px; 258 | } 259 | .cml-form-textarea{ 260 | width: 60%; 261 | padding: 6px 12px; 262 | line-height: 1.42857; 263 | color: #4d6b8a; 264 | background-color: #fff; 265 | background-image: none; 266 | border-radius: 4px; 267 | -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); 268 | box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); 269 | -webkit-transition: border-color ease-in-out 0.15s, box-shadow ease-in-out 0.15s; 270 | -o-transition: border-color ease-in-out 0.15s, box-shadow ease-in-out 0.15s; 271 | transition: border-color ease-in-out 0.15s, box-shadow ease-in-out 0.15s; 272 | background: 0 0; 273 | border: 0; 274 | border: 1px solid #c2cad8; 275 | -webkit-border-radius: 0; 276 | -moz-border-radius: 0; 277 | -ms-border-radius: 0; 278 | text-indent: .5em; 279 | -o-border-radius: 0; 280 | border-radius: 0; 281 | color: #555; 282 | box-shadow: none; 283 | padding-left: 2px; 284 | padding-right: 0; 285 | font-size: 14px; 286 | } -------------------------------------------------------------------------------- /app/admin/tpl/index/users.html: -------------------------------------------------------------------------------- 1 | {include 'public/header'} 2 |
3 | 4 | 5 | 6 | 7 | 175 | -------------------------------------------------------------------------------- /static/js/downlist.js: -------------------------------------------------------------------------------- 1 | /** 2 | js,动态加载软件列表 3 | */ 4 | 5 | var vf = ['mp4']; 6 | 7 | function getFormat(name) { 8 | return name.substring(name.lastIndexOf('.') + 1); 9 | ; 10 | } 11 | 12 | function contains(arr, obj) { 13 | var i = arr.length; 14 | while (i--) { 15 | if (arr[i] === obj) { 16 | return true; 17 | } 18 | } 19 | return false; 20 | } 21 | 22 | function isVideoFile(name) { 23 | var format = getFormat(name); 24 | console.log(format); 25 | return contains(vf, format); 26 | } 27 | 28 | var dList = function (obj, sid, keydown) { 29 | obj.className += 'soft-list';//加一个class样式 30 | obj.page = 1;//记录现在的页码 31 | /** 32 | * 加载一页 33 | */ 34 | obj.load = function (page) { 35 | page = page || obj.page; 36 | get({ 37 | url: home + '/index/api/getSoftList?keydown=' + keydown + '&sid=' + sid + '&page=' + page,//URL打错了来着 38 | success: function (str) { 39 | var json = JSON.parse(str); 40 | obj.innerHTML = ''; 41 | for (var key in json.rows) { 42 | var html = ''; 43 | html = '
\n' + 44 | '
\n' + 45 | ' \n' + 46 | ' \n' + 47 | json.rows[key].soft_name + 48 | ' \n' + 49 | '

\n' + 50 | json.rows[key].soft_exp + 51 | '

\n' + 52 | '
\n' + 53 | '
\n' + 54 | ' \n'; 55 | html += timestamp2date(json.rows[key].soft_time) + 56 | ' \n' + 57 | ' 立即下载'; 59 | if (isVideoFile(json.rows[key].soft_filename)) { 60 | html += '在线播放'; 61 | } 62 | html += '购买积分:' + json.rows[key].price + '\n' + 63 | '
\n' + 64 | '
'; 65 | obj.innerHTML += html; 66 | } 67 | var html = '
\n'; 68 | if (page != 1) { 69 | html += '
<
\n'; 70 | } 71 | if (json.total > 8) {//当页码大于8 72 | page = parseInt(page); 73 | var startPage = page - 3, endPage = page + 4; 74 | if (page <= 3) { 75 | //小于4 76 | startPage = 1; 77 | endPage = 8; 78 | } else if (page + 4 > json.total) { 79 | //页数+5还比总页数大 80 | startPage = json.total - 7; 81 | endPage = json.total; 82 | } 83 | for (var i = startPage; i <= endPage; i++) {//输出页码 84 | var active = ''; 85 | if (i == page) { 86 | active = 'active'; 87 | //如果是当前页的话,就标注一下 88 | } 89 | html += '
' + i + '
'; 90 | } 91 | } else if (json.total <= 8) {//总页数小于等于8 全部输出 92 | for (var i = 1; i <= json.total; i++) {//输出页码 93 | var active = ''; 94 | if (i == page) { 95 | active = 'active'; 96 | } 97 | html += '
' + i + '
'; 98 | } 99 | } 100 | 101 | if (page != json.total) {//判断与总页数相等 102 | html += '
>
\n'; 103 | } 104 | obj.innerHTML += html; 105 | 106 | } 107 | }); 108 | } 109 | //绑定翻页 110 | bind(obj, 'click', function (ev) { 111 | var html = this.outerHTML; 112 | var page = subString(html, 'page="', '"'); 113 | obj.load(page); 114 | }, 'page-item'); 115 | //然后是翻页,有点复杂 116 | return obj; 117 | } 118 | 119 | 120 | /** 121 | * 写一个提取文本中间的函数 122 | * @param str 123 | * @param left 124 | * @param right 125 | */ 126 | function subString(str, left, right) { 127 | var leftPos = str.indexOf(left); 128 | var rightPos = str.indexOf(right, leftPos + left.length); 129 | return str.substring(leftPos + left.length, rightPos); 130 | } 131 | 132 | var bindFunc = []; 133 | 134 | /** 135 | * 试试自己实现一个 136 | * @param attr 137 | * @param func 138 | * @param select 139 | */ 140 | function bind(father, attr, func, select) { 141 | var id = {}; 142 | if (typeof father == 'string') { 143 | id = document.getElementById(father); 144 | } else if (typeof father == 'object') { 145 | id = father; 146 | } 147 | bindFunc.push({select: select, func: func}); 148 | id['on' + attr] = function (ev) { 149 | var oEvent = ev || event; 150 | var _this = oEvent.srcElement || oEvent.target; 151 | //用寻找的方法更好 152 | for (var item in bindFunc) { 153 | if (_this.className.toUpperCase().indexOf(bindFunc[item].select.toUpperCase()) >= 0) { 154 | if (bindFunc[item].func) bindFunc[item].func.call(_this, oEvent); 155 | } 156 | } 157 | } 158 | return 0; 159 | } 160 | 161 | /** 162 | * 时间戳转日期 163 | * @param time 164 | * @returns {string} 165 | */ 166 | function timestamp2date(time) { 167 | var t = new Date(time * 1000); 168 | var commonTime = t.toLocaleString(); 169 | var ret = t.getFullYear() + '/' + (t.getMonth() + 1) + '/' + t.getDate() + 170 | ' ' + zero(t.getHours()) + ':' + zero(t.getMinutes()) + ':' + zero(t.getSeconds()); 171 | return ret; 172 | } 173 | 174 | function zero(str) { 175 | str = str.toString(); 176 | if (str.length < 2) { 177 | str = '0' + str; 178 | } 179 | return str; 180 | } 181 | 182 | /** 183 | * 封装xmlhttp get 184 | * @param obj 185 | * @returns {*} 186 | */ 187 | function get(obj) { 188 | var xmlhttp; 189 | if (window.XMLHttpRequest) { 190 | xmlhttp = new XMLHttpRequest(); 191 | } 192 | else { 193 | xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); 194 | } 195 | xmlhttp.onreadystatechange = function () { 196 | if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { 197 | if (obj.success != undefined) { 198 | obj.success(xmlhttp.response); 199 | } 200 | } 201 | } 202 | xmlhttp.open("GET", obj.url, true); 203 | xmlhttp.send(); 204 | return obj; 205 | } -------------------------------------------------------------------------------- /icf/lib/route.php: -------------------------------------------------------------------------------- 1 | 20 | [ 21 | '{s}.php' => '${1}->index->index', 22 | '{s}/{s}/{s}#p' => '${1}->${2}->${3}', 23 | '{s}/{s}#p' => '${1}->${2}', 24 | '{s}#p' => '${1}->index', 25 | '{s}'=>'${1}' 26 | ], 27 | 'get' => []]; 28 | 29 | static $get_param = []; 30 | 31 | static $replace_param = ''; 32 | 33 | static $classNamePace = ''; 34 | 35 | static $get = []; 36 | 37 | static $matchUrl = ''; 38 | 39 | static function matchRule($match, $pathInfo) { 40 | //初始化 41 | self::$model = ''; 42 | self::$ctrl = ''; 43 | self::$action = ''; 44 | //处理各个参数 45 | $param = ''; 46 | if ($cut = strpos($match[0], '#')) { 47 | $param = substr($match[0], $cut + 1); 48 | $match[0] = substr($match[0], 0, $cut); 49 | if (strpos($param, 'p') !== false) { 50 | $match[0] .= '/'; 51 | $pathInfo .= '/'; 52 | } 53 | } 54 | $var = preg_replace_callback('#{(.*?)}#', function ($v) { 55 | static $count = 0; 56 | $count++; 57 | self::$get_param[$count] = $v[1]; 58 | return '([\S][^\{^\}^/]*)'; 59 | }, $match[0]); 60 | self::$replace_param = $match[1]; 61 | self::$get = []; 62 | $count = 0; 63 | preg_replace_callback('#^\/' . $var . '#', function ($v) { 64 | foreach ($v as $key => $value) { 65 | self::$replace_param = str_replace('${' . $key . '}', $value, self::$replace_param); 66 | if (isset(self::$get_param[$key])) { 67 | self::$get[self::$get_param[$key]] = $value; 68 | } 69 | } 70 | self::$matchUrl = $v[0]; 71 | return ''; 72 | }, $pathInfo, 1, $count); 73 | if ($count <= 0) { 74 | return false; 75 | } 76 | $mca = explode('->', self::$replace_param); 77 | if (sizeof($mca) == 1) { 78 | self::$model = _get(_config('model_key'), __DEFAULT_MODEL_); 79 | self::$ctrl = _get(_config('ctrl_key'), 'index'); 80 | self::$action = _get(_config('action_key'), $mca[0]); 81 | } else if (sizeof($mca) == 2) { 82 | self::$model = _get(_config('model_key'), __DEFAULT_MODEL_); 83 | self::$ctrl = _get(_config('ctrl_key'), $mca[0]); 84 | self::$action = _get(_config('action_key'), $mca[1]); 85 | } else if (sizeof($mca) == 3) { 86 | self::$model = _get(_config('model_key'), $mca[0]); 87 | self::$ctrl = _get(_config('ctrl_key'), $mca[1]); 88 | self::$action = _get(_config('action_key'), $mca[2]); 89 | } 90 | self::$classNamePace = 'app\\' . self::$model . '\\ctrl\\' . self::$ctrl; 91 | $className = str_replace('\\', '/', self::$classNamePace); 92 | if (!is_file($className . '.php')) { 93 | return false; 94 | } 95 | $tmpParam = ''; 96 | if (self::$matchUrl) { 97 | $tmpParam = substr($pathInfo, strpos($pathInfo, self::$matchUrl) + strlen(self::$matchUrl)); 98 | } 99 | if (strpos($param, 'p') !== false) { 100 | //处理后方参数 101 | preg_match_all('#/([\S][^\{^\}^/]*)/([\S][^\{^\}^/]*)#', '/' . $tmpParam, $matchArr, PREG_SET_ORDER); 102 | foreach ($matchArr as $item) { 103 | self::$get[$item[1]] = $item[2]; 104 | } 105 | } else { 106 | if ($tmpParam != '') { 107 | return false; 108 | } 109 | } 110 | return true; 111 | } 112 | 113 | /** 114 | * 解析URL,加载控制类 115 | * @access public 116 | * @author Farmer 117 | */ 118 | static function analyze() { 119 | if (isset($_SERVER['PATH_INFO'])) { 120 | $pathInfo = $_SERVER['PATH_INFO']; 121 | if (isset(self::$rule[strtolower($_SERVER['REQUEST_METHOD'])])) { 122 | $tmpRule = self::$rule[strtolower($_SERVER['REQUEST_METHOD'])]; 123 | foreach ($tmpRule as $key => $value) { 124 | //匹配规则 125 | if (self::matchRule([$key, $value], $pathInfo)) { 126 | if (self::runAction()) { 127 | return; 128 | } 129 | } 130 | } 131 | } 132 | $tmpRule = self::$rule['*']; 133 | foreach ($tmpRule as $key => $value) { 134 | //匹配规则 135 | if (self::matchRule([$key, $value], $pathInfo)) { 136 | if (self::runAction()) { 137 | return; 138 | } 139 | } 140 | } 141 | _404(); 142 | return; 143 | } else { 144 | self::$model = _get(_config('model_key'), __DEFAULT_MODEL_); 145 | self::$ctrl = _get(_config('ctrl_key'), 'index'); 146 | self::$action = _get(_config('action_key'), 'index'); 147 | self::$classNamePace = 'app\\' . self::$model . '\\ctrl\\' . self::$ctrl; 148 | $className = str_replace('\\', '/', self::$classNamePace); 149 | if (!is_file($className . '.php')) { 150 | _404(); 151 | return false; 152 | } 153 | self::runAction(); 154 | return; 155 | } 156 | } 157 | 158 | 159 | static function runAction() { 160 | input('model', route::$model); 161 | input('ctrl', route::$ctrl); 162 | input('action', route::$action); 163 | //加载全局函数 164 | $comPath = __ROOT_ . '/app/common.php'; 165 | if (file_exists($comPath)) { 166 | require_once $comPath; 167 | } 168 | //加载模块函数 169 | $comPath = __ROOT_ . '/app/' . self::$model . '/'; 170 | if (file_exists($comPath . 'common.php')) { 171 | require_once $comPath . 'common.php'; 172 | } 173 | try { 174 | $tmp = self::$classNamePace; 175 | $object = new $tmp(); 176 | // 获取方法参数 177 | $method = new \ReflectionMethod ($object, self::$action); 178 | // 参数绑定 179 | $param = []; 180 | $_GET = array_merge($_GET, self::$get); 181 | foreach ($method->getParameters() as $value) { 182 | if ($val = _get($value->getName())) { 183 | $param [] = $val; 184 | } else { 185 | $param [] = $value->getDefaultValue(); 186 | } 187 | } 188 | $data = call_user_func_array([ 189 | $object, 190 | self::$action 191 | ], $param); 192 | if (is_array($data)) { 193 | echo json($data); 194 | } else { 195 | echo $data; 196 | } 197 | } catch (\Exception $e) { 198 | if(_config('debug')) { 199 | echo 'error:'.$e->getMessage(); 200 | }else { 201 | _404(); 202 | } 203 | } 204 | return true; 205 | } 206 | 207 | /** 208 | * 添加规则 209 | * @access public 210 | * @author Farmer 211 | * @param $req_type 212 | * @param $rule 213 | * @param string $to 214 | */ 215 | static function add($req_type, $rule, $to = '') { 216 | if (is_array($rule)) { 217 | foreach ($rule as $pattern => $value) { 218 | self::$rule [$req_type][$pattern] = $value; 219 | } 220 | } else { 221 | self::$rule [$req_type][$rule] = $to; 222 | } 223 | } 224 | } -------------------------------------------------------------------------------- /app/index/ctrl/api.php: -------------------------------------------------------------------------------- 1 | where('sort_fid', $sid)->select(); 22 | while ($row = $tmpRec->fetch()) { 23 | $sql .= " `soft_sort_id`={$row['sort_id']} or "; 24 | $sql .= self::forSubSort_SQL($row['sort_id']); 25 | } 26 | return $sql; 27 | } 28 | 29 | /** 30 | * 获取列表接口 31 | * @author Farmer 32 | */ 33 | public function getSoftList($sid = 0, $keydown = '') { 34 | $retJson = ['code' => 0, 'msg' => 'success']; 35 | $page = (isset($_GET['page']) ? $_GET['page'] : 1); 36 | if ($sid > 0) { 37 | $db = db::table('soft_list'); 38 | $sql = self::forSubSort_SQL($sid); 39 | if ($sql == '') { 40 | $db->where("`soft_sort_id`=$sid"); 41 | } else { 42 | $db->where("( `soft_sort_id`=$sid or " . substr($sql, 0, strlen($sql) - 3) . ' )'); 43 | } 44 | } else { 45 | $db = db::table('soft_list'); 46 | } 47 | $db->where('soft_type', 1) 48 | ->field(['sid','soft_price'=>'price', 'soft_name', 'soft_exp', 'soft_logo', 'soft_filename', 'soft_time']) 49 | ->limit(($page - 1) * 10, 10)->order('sid'); 50 | if (!empty($keydown)) { 51 | $db->where('soft_name', "%{$keydown}%", 'like')->_or(); 52 | $db->where('soft_exp', "%{$keydown}%", 'like'); 53 | } 54 | $count = $db->count(); 55 | $rec = $db->select(); 56 | while ($row = $rec->fetch()) { 57 | $row['soft_filename'] = getFileName($row['soft_filename']); 58 | $retJson['rows'][] = $row; 59 | } 60 | $retJson['total'] = ceil($count / 10); 61 | return $retJson; 62 | } 63 | 64 | /** 65 | * 文件下载 66 | * @author Farmer 67 | * @param int $sid 68 | */ 69 | public function download($sid = 0) { 70 | if ($soft = db::table('soft_list')->where('sid', $sid)->find()) { 71 | $filename = __ROOT_ . '/static/res/' . $soft['soft_path']; 72 | if (!(@$hfile = fopen($filename, 'r'))) { 73 | return _404(); 74 | } 75 | if ($soft['soft_type'] == 1) { 76 | if (($msg = user::buy_soft($sid)) !== true) { 77 | auth::_error($msg, url('/')); 78 | return; 79 | } 80 | } else { 81 | if (!isset($this->userMsg['auth']['index->area'])) { 82 | _404(); 83 | return ''; 84 | } 85 | } 86 | header('Content-Description: File Transfer'); 87 | header('Content-type: application/octet-stream'); 88 | header('Content-Disposition: attachment; filename="' . $soft['soft_filename'] . '"'); 89 | header('Expires: 0'); 90 | header('Cache-Control: must-revalidate'); 91 | header('Pragma: public'); 92 | header('Content-Length: ' . filesize($filename)); 93 | //下载限速 94 | set_time_limit(0); 95 | while (!feof($hfile)) { 96 | print fread($hfile, 1024 * 1024 * 4);//4M/S 97 | sleep(1); 98 | } 99 | fclose($hfile); 100 | return; 101 | } 102 | return _404(); 103 | } 104 | 105 | public function applyUpload() { 106 | $sort_id = 0; 107 | $price = 0; 108 | $retJson = self::vUpload($sort_id, $price); 109 | if ($retJson['code'] != 0) { 110 | return $retJson; 111 | } 112 | db::table('soft_list')->insert([ 113 | 'soft_name' => _post('name'), 114 | 'soft_filename' => _post('filename'), 115 | 'soft_exp' => _post('exp'), 116 | 'soft_logo' => _post('logo'), 117 | 'soft_path' => '', 118 | 'soft_price' => $price, 119 | 'soft_sort_id' => $sort_id, 120 | 'soft_type' => 3, 121 | 'soft_time' => time(), 122 | 'soft_uid' => $_COOKIE['uid'], 123 | ]); 124 | $retJson = ['code' => 0, 'msg' => 'success', 'id' => db::table()->lastinsertid()]; 125 | return $retJson; 126 | } 127 | public function isUpload(){ 128 | return self::vUpload(); 129 | } 130 | private function vUpload(&$sort_id = 0, &$price = 0) { 131 | $retJson = ['code' => -1]; 132 | if ($old_row = db::table('soft_list')->where('soft_uid', $_COOKIE['uid'])->where('soft_type', 3)->find()) { 133 | $retJson['msg'] = '您有未上传完毕的任务(暂时未提供恢复,请直接找管理,下次更新╮( ̄⊿ ̄)╭)'; 134 | $retJson['sid'] = $old_row['sid']; 135 | $retJson['code'] = -2; 136 | $retJson['row'] = ['name' => $old_row['soft_name'], 'exp' => $old_row['soft_exp'], 'logo' => $old_row['soft_logo'], 'price' => $old_row['soft_price']]; 137 | return $retJson; 138 | } 139 | if (!_post('name')) { 140 | $retJson['msg'] = '软件名不能为空'; 141 | return $retJson; 142 | } 143 | if (!_post('filename')) { 144 | $retJson['msg'] = '文件名不能为空'; 145 | return $retJson; 146 | } 147 | if (ceil(($price = _post('price'))) <= 0) { 148 | $price = 0; 149 | } 150 | if (!($sort_id = _post('sort_id'))) { 151 | $retJson['msg'] = '请选择分区'; 152 | return $retJson; 153 | } 154 | if (!db::table('sort')->where('sort_id', $sort_id)->find()) { 155 | $retJson['msg'] = '分区不存在'; 156 | return $retJson; 157 | } 158 | if (!is_file('static/res/images/' . _post('logo'))) { 159 | $retJson['msg'] = '图片不存在'; 160 | return $retJson; 161 | } 162 | $retJson = ['code' => 0, 'msg' => 'success']; 163 | return $retJson; 164 | } 165 | 166 | public function upload_image() { 167 | $json ['code'] = -2; 168 | $json ['msg'] = "系统错误"; 169 | if (isset ($_FILES ['upfile'] ['tmp_name'])) { 170 | if (is_uploaded_file($_FILES ['upfile'] ['tmp_name'])) { 171 | $upfile = $_FILES ["upfile"]; 172 | $tmp_name = $upfile ["tmp_name"]; // 上传文件的临时存放路径 173 | $error = $upfile ['error']; // 上传后系统返回的值 174 | if ($error == 0) { 175 | if ($format = isImg($tmp_name)) { 176 | $tmpFile = filePart(getFileName($upfile['name'])); 177 | $filename = $tmpFile[0] . '_' . time() . '.' . $tmpFile[1]; 178 | $destination = time2path('static/res/images/', $timePath) . $filename; 179 | $filename = $timePath . $filename; 180 | if (!(file_exists($destination))) { 181 | move_uploaded_file($tmp_name, $destination); 182 | } 183 | $json ['code'] = 0; 184 | $json ['msg'] = "上传成功"; 185 | $json ['url'] = $filename; 186 | } else { 187 | $json ['code'] = -1; 188 | $json ['msg'] = "上传失败"; 189 | } 190 | } else { 191 | $json ['code'] = $error; 192 | $json ['msg'] = '文件上传失败'; 193 | } 194 | } 195 | return json($json); 196 | } 197 | return $json; 198 | } 199 | 200 | public function getSortList($sid = 0, $param = '') { 201 | if ($sid) { 202 | $result = db::table('sort')->field('sort_id,sort_name as name')->where('sort_fid', $sid)->select(); 203 | } else { 204 | $result = db::table('sort')->field('sort_id,sort_name as name')->where('sort_fid', 0)->select(); 205 | } 206 | $retRows = []; 207 | while ($row = $result->fetch()) { 208 | $tmp = ['sid' => $row['sort_id'], 'name' => $param . $row['name']]; 209 | $retRows[] = $tmp; 210 | $retRows = array_merge($retRows, $this->getSortList($row['sort_id'], $param . $row['name'] . '=>')); 211 | } 212 | if (!$sid) { 213 | return ['code' => 0, 'msg' => 'success', 'rows' => $retRows]; 214 | } 215 | return $retRows; 216 | } 217 | } -------------------------------------------------------------------------------- /icf/lib/db/query.php: -------------------------------------------------------------------------------- 1 | setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); 25 | self::$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); 26 | } 27 | //处理表前缀 28 | $this->table = input('config.db.prefix') . str_replace('|', ',' . input('config.db.prefix'), $table); 29 | } 30 | 31 | private $table = ''; 32 | private $where = ''; 33 | private $field = ''; 34 | private $order = ''; 35 | private $group = ''; 36 | private $limit = ''; 37 | private $join = ''; 38 | 39 | private $lastOper = 'and'; 40 | private $bindParam = []; 41 | 42 | /** 43 | * 条件 44 | * @author Farmer 45 | * @param $field 46 | * @param null $value 47 | * @param string $operator 48 | * @return $this 49 | */ 50 | public function where($field, $value = null, $operator = '=') { 51 | $this->where .= ' ' . (empty($this->where) ? '' : $this->lastOper . ' '); 52 | //恢复默认运算符 53 | $this->lastOper = 'and'; 54 | if (is_array($field)) { 55 | //获取最后一个 56 | $keys = array_keys($field); 57 | foreach ($field as $key => $item) { 58 | if (is_string($key)) { 59 | $this->where .= "`$key`$operator? "; 60 | $this->bindParam[] = $item; 61 | if ($key !== end($keys)) { 62 | $this->where .= 'and '; 63 | } 64 | } else if (is_numeric($key)) { 65 | $this->where .= "$item"; 66 | if ($key !== end($keys)) { 67 | $this->where .= 'and '; 68 | } 69 | } 70 | } 71 | } else if (is_string($field)) { 72 | if (is_null($value)) { 73 | $this->where .= $field; 74 | } else { 75 | $this->where .= " `$field`$operator?"; 76 | $this->bindParam[] = $value; 77 | } 78 | } 79 | return $this; 80 | } 81 | 82 | public function join($table, $on = '', $link = 'left') { 83 | if (is_array($table)) { 84 | foreach ($table as $key => $value) { 85 | if (is_string($key)) { 86 | $this->join .= " $link join `" . input('config.db.prefix') . $key . "` as $value " . (empty($on) ? '' : "on $on"); 87 | } else if (is_numeric($key)) { 88 | $this->join .= ' ' . $value; 89 | } 90 | } 91 | } else if (is_string($table)) { 92 | $table = str_replace(':', input('config.db.prefix'), $table); 93 | $this->join .= " $link join $table " . (empty($on) ? '' : "on $on"); 94 | } 95 | return $this; 96 | } 97 | 98 | /** 99 | * 插入数据 100 | * @author Farmer 101 | * @param array $items 102 | * @return bool|int 103 | */ 104 | public function insert(array $items) { 105 | if (!empty ($items)) { 106 | $param = []; 107 | $sql = 'insert into ' . $this->table . '(`' . implode('`,`', array_keys($items)) . '`) values('; 108 | foreach ($items as $value) { 109 | $sql .= '?,'; 110 | $param[] = $value; 111 | } 112 | $sql = substr($sql, 0, strlen($sql) - 1); 113 | $sql .= ')'; 114 | $result = self::$db->prepare($sql); 115 | if ($result->execute($param)) { 116 | return $result->rowCount(); 117 | } 118 | return false; 119 | } 120 | return false; 121 | } 122 | 123 | /** 124 | * and 125 | * @author Farmer 126 | * @return $this 127 | */ 128 | public function _and() { 129 | $this->lastOper = 'and'; 130 | return $this; 131 | } 132 | 133 | /** 134 | * or 135 | * @author Farmer 136 | * @return $this 137 | */ 138 | public function _or() { 139 | $this->lastOper = 'or'; 140 | return $this; 141 | } 142 | 143 | /** 144 | * 查询记录 145 | * @author Farmer 146 | * @return bool|record 147 | */ 148 | public function select() { 149 | $sql = 'select ' . ($this->field ?: '*') . " from {$this->table} {$this->join} " . ($this->where ? 'where' : ''); 150 | $sql .= $this->dealParam(); 151 | $result = self::$db->prepare($sql); 152 | if ($result->execute($this->bindParam)) { 153 | return new record($result); 154 | } 155 | return false; 156 | } 157 | 158 | public function count() { 159 | $tmpField = $this->field; 160 | $tmpLimit = $this->limit; 161 | $this->field = ''; 162 | $count = $this->field('count(*)')->find()['count(*)']; 163 | $this->field = $tmpField; 164 | $this->limit = $tmpLimit; 165 | return $count; 166 | } 167 | 168 | /** 169 | * 数据更新 170 | * @author Farmer 171 | * @param $set 172 | * @return bool|int 173 | */ 174 | public function update($set) { 175 | $data = null; 176 | if (is_string($set)) { 177 | $data = $set; 178 | } else if (is_array($set)) { 179 | foreach ($set as $key => $value) { 180 | if (is_numeric($key)) { 181 | $data .= ',' . $set[$key]; 182 | } else { 183 | $data .= ",`{$key}`=?"; 184 | $tmpParam[] = $value; 185 | } 186 | } 187 | $this->bindParam = array_merge($tmpParam, $this->bindParam); 188 | $data = substr($data, 1); 189 | } 190 | $sql = "update {$this->table} set $data where" . $this->dealParam(); 191 | $result = self::$db->prepare($sql); 192 | if ($result->execute($this->bindParam)) { 193 | return $result->rowCount(); 194 | } 195 | return false; 196 | } 197 | 198 | /** 199 | * 删除数据 200 | * @author Farmer 201 | * @return bool|int 202 | */ 203 | public function delete() { 204 | $sql = "delete from {$this->table} where" . $this->dealParam(); 205 | $result = self::$db->prepare($sql); 206 | if ($result->execute($this->bindParam)) { 207 | return $result->rowCount(); 208 | } 209 | return false; 210 | } 211 | 212 | /** 213 | * 对where等进行处理 214 | * @author Farmer 215 | * @return string 216 | */ 217 | private function dealParam() { 218 | $sql = $this->where ?: ''; 219 | $sql .= $this->group ?: ''; 220 | $sql .= $this->order ?: ''; 221 | $sql .= $this->limit ?: ''; 222 | return $sql; 223 | } 224 | 225 | /** 226 | * 绑定参数 227 | * @author Farmer 228 | * @param $key 229 | * @param string $value 230 | * @return $this 231 | */ 232 | public function bind($key, $value = '') { 233 | if (is_array($key)) { 234 | $this->bindParam = array_merge($this->bindParam, $key); 235 | } else { 236 | $this->bindParam[$key] = $value; 237 | } 238 | return $this; 239 | } 240 | 241 | /** 242 | * 排序 243 | * @author Farmer 244 | * @param $field 245 | * @param string $rule 246 | * @return $this 247 | */ 248 | public function order($field, $rule = 'desc') { 249 | $this->order = " order by `$field` $rule"; 250 | return $this; 251 | } 252 | 253 | public function group($field) { 254 | $this->group = " group by `$field`"; 255 | return $this; 256 | } 257 | 258 | /** 259 | * 分页 260 | * @author Farmer 261 | * @param $start 262 | * @param int $count 263 | * @return $this 264 | */ 265 | public function limit($start, $count = 0) { 266 | if ($count) { 267 | $this->limit = " limit $start,$count"; 268 | } else { 269 | $this->limit = " limit $start"; 270 | } 271 | return $this; 272 | } 273 | 274 | /** 275 | * 查询出单条数据 276 | * @author Farmer 277 | * @return mixed 278 | */ 279 | public function find() { 280 | return $this->limit('1')->select()->fetch(); 281 | } 282 | 283 | /** 284 | * 开始事务 285 | * @author Farmer 286 | */ 287 | public function begin() { 288 | $this->exec('begin'); 289 | } 290 | 291 | /** 292 | * 提交事务 293 | * @author Farmer 294 | */ 295 | public function commit() { 296 | $this->exec('commit'); 297 | } 298 | 299 | /** 300 | * 回滚事务 301 | * @author Farmer 302 | */ 303 | public function rollback() { 304 | $this->exec('rollback'); 305 | } 306 | 307 | public function field($field, $alias = '') { 308 | if (is_string($field)) { 309 | if (empty($alias)) { 310 | $this->field .= (empty($this->field) ? '' : ',') . $field . ' '; 311 | } else { 312 | $this->field .= (empty($this->field) ? '' : ',') . $field . ' as ' . $alias . ' '; 313 | } 314 | } else if (is_array($field)) { 315 | foreach ($field as $key => $value) { 316 | if (is_string($key)) { 317 | $this->field .= (empty($this->field) ? '' : ',') . $key . ' as ' . $value . ' '; 318 | } else if (is_string($value)) { 319 | $this->field .= (empty($this->field) ? '' : ',') . $value . ' '; 320 | } 321 | 322 | } 323 | } 324 | return $this; 325 | } 326 | 327 | /** 328 | * 上一个插入id 329 | * @author Farmer 330 | * @return string 331 | */ 332 | public function lastinsertid() { 333 | return self::$db->lastInsertId(); 334 | } 335 | 336 | public function __call($func, $arguments) { 337 | if (is_null(self::$db)) { 338 | return 0; 339 | } 340 | return call_user_func_array(array( 341 | self::$db, 342 | $func 343 | ), $arguments); 344 | } 345 | } 346 | 347 | /** 348 | * 记录集类 349 | * @author Farmer 350 | * @package icf\lib 351 | */ 352 | class record { 353 | private $result; 354 | 355 | public function __call($func, $arguments) { 356 | if (is_null($this->result)) { 357 | return 0; 358 | } 359 | return call_user_func_array(array( 360 | $this->result, 361 | $func 362 | ), $arguments); 363 | } 364 | 365 | function __construct(\PDOStatement $result) { 366 | $this->result = $result; 367 | $this->result->setFetchMode(PDO::FETCH_ASSOC); 368 | } 369 | 370 | function fetchAll() { 371 | return $this->result->fetchAll(); 372 | } 373 | 374 | function fetch() { 375 | return $this->result->fetch(); 376 | } 377 | 378 | } -------------------------------------------------------------------------------- /jx.sql: -------------------------------------------------------------------------------- 1 | /* 2 | Navicat MySQL Data Transfer 3 | 4 | Source Server : localhost_3306 5 | Source Server Version : 50505 6 | Source Host : localhost:3306 7 | Source Database : jx 8 | 9 | Target Server Type : MYSQL 10 | Target Server Version : 50505 11 | File Encoding : 65001 12 | 13 | Date: 2017-12-07 17:14:03 14 | */ 15 | 16 | SET FOREIGN_KEY_CHECKS=0; 17 | 18 | -- ---------------------------- 19 | -- Table structure for jx_area_manager 20 | -- ---------------------------- 21 | DROP TABLE IF EXISTS `jx_area_manager`; 22 | CREATE TABLE `jx_area_manager` ( 23 | `sort_id` bigint(20) NOT NULL, 24 | `uid` bigint(20) NOT NULL 25 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 26 | 27 | -- ---------------------------- 28 | -- Records of jx_area_manager 29 | -- ---------------------------- 30 | INSERT INTO `jx_area_manager` VALUES ('1', '1'); 31 | INSERT INTO `jx_area_manager` VALUES ('4', '1'); 32 | 33 | -- ---------------------------- 34 | -- Table structure for jx_auth 35 | -- ---------------------------- 36 | DROP TABLE IF EXISTS `jx_auth`; 37 | CREATE TABLE `jx_auth` ( 38 | `auth_id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '权限id', 39 | `auth_interface` varchar(255) NOT NULL COMMENT '权限接口', 40 | `remark` varchar(255) DEFAULT NULL COMMENT '备注', 41 | PRIMARY KEY (`auth_id`) 42 | ) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8; 43 | 44 | -- ---------------------------- 45 | -- Records of jx_auth 46 | -- ---------------------------- 47 | INSERT INTO `jx_auth` VALUES ('1', 'index->index', '首页浏览'); 48 | INSERT INTO `jx_auth` VALUES ('2', 'index->api->getSoftList', '列表获取'); 49 | INSERT INTO `jx_auth` VALUES ('3', 'index->api->download', '下载权限'); 50 | INSERT INTO `jx_auth` VALUES ('4', 'admin', '管理员权限'); 51 | INSERT INTO `jx_auth` VALUES ('5', 'index->user', '用户页面'); 52 | INSERT INTO `jx_auth` VALUES ('6', 'index->area', '版主权限'); 53 | INSERT INTO `jx_auth` VALUES ('7', '???', '还没想好,emm'); 54 | 55 | -- ---------------------------- 56 | -- Table structure for jx_group 57 | -- ---------------------------- 58 | DROP TABLE IF EXISTS `jx_group`; 59 | CREATE TABLE `jx_group` ( 60 | `group_id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '群组id', 61 | `group_name` varchar(255) NOT NULL, 62 | `group_auth` int(11) NOT NULL COMMENT '权限级别', 63 | PRIMARY KEY (`group_id`) 64 | ) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8; 65 | 66 | -- ---------------------------- 67 | -- Records of jx_group 68 | -- ---------------------------- 69 | INSERT INTO `jx_group` VALUES ('1', '管理员', '10'); 70 | INSERT INTO `jx_group` VALUES ('2', '游客', '1'); 71 | INSERT INTO `jx_group` VALUES ('3', '会员', '2'); 72 | INSERT INTO `jx_group` VALUES ('4', '分区管理Max', '7'); 73 | INSERT INTO `jx_group` VALUES ('5', '分区管理', '6'); 74 | 75 | -- ---------------------------- 76 | -- Table structure for jx_groupauth 77 | -- ---------------------------- 78 | DROP TABLE IF EXISTS `jx_groupauth`; 79 | CREATE TABLE `jx_groupauth` ( 80 | `group_id` int(11) NOT NULL, 81 | `auth_id` int(11) NOT NULL, 82 | KEY `auth_id` (`auth_id`), 83 | KEY `group_id` (`group_id`) 84 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 85 | 86 | -- ---------------------------- 87 | -- Records of jx_groupauth 88 | -- ---------------------------- 89 | INSERT INTO `jx_groupauth` VALUES ('2', '1'); 90 | INSERT INTO `jx_groupauth` VALUES ('2', '2'); 91 | INSERT INTO `jx_groupauth` VALUES ('3', '3'); 92 | INSERT INTO `jx_groupauth` VALUES ('1', '4'); 93 | INSERT INTO `jx_groupauth` VALUES ('3', '5'); 94 | INSERT INTO `jx_groupauth` VALUES ('7', '6'); 95 | INSERT INTO `jx_groupauth` VALUES ('4', '6'); 96 | 97 | -- ---------------------------- 98 | -- Table structure for jx_integral_change 99 | -- ---------------------------- 100 | DROP TABLE IF EXISTS `jx_integral_change`; 101 | CREATE TABLE `jx_integral_change` ( 102 | `ic_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, 103 | `ic_uid` bigint(20) unsigned NOT NULL, 104 | `ic_oper_type` int(255) NOT NULL, 105 | `ic_detail` varchar(255) NOT NULL, 106 | `ic_number` double(10,4) NOT NULL, 107 | `ic_time` bigint(20) NOT NULL, 108 | `ic_param_id` bigint(11) NOT NULL, 109 | `ic_over_integral` bigint(20) NOT NULL, 110 | PRIMARY KEY (`ic_id`) 111 | ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8; 112 | 113 | -- ---------------------------- 114 | -- Records of jx_integral_change 115 | -- ---------------------------- 116 | INSERT INTO `jx_integral_change` VALUES ('2', '1', '1', '购买putty3花费1积分', '-1.0000', '1512615682', '15', '6'); 117 | 118 | -- ---------------------------- 119 | -- Table structure for jx_log 120 | -- ---------------------------- 121 | DROP TABLE IF EXISTS `jx_log`; 122 | CREATE TABLE `jx_log` ( 123 | `log_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, 124 | `log_uid` bigint(20) unsigned NOT NULL, 125 | `log_msg` text NOT NULL, 126 | `log_time` bigint(20) unsigned NOT NULL, 127 | `log_type` int(11) NOT NULL, 128 | PRIMARY KEY (`log_id`) 129 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 130 | 131 | -- ---------------------------- 132 | -- Records of jx_log 133 | -- ---------------------------- 134 | 135 | -- ---------------------------- 136 | -- Table structure for jx_nav 137 | -- ---------------------------- 138 | DROP TABLE IF EXISTS `jx_nav`; 139 | CREATE TABLE `jx_nav` ( 140 | `nav_id` int(10) unsigned NOT NULL AUTO_INCREMENT, 141 | `nav_title` varchar(255) NOT NULL, 142 | `nav_url` varchar(255) NOT NULL, 143 | `nav_father` int(10) unsigned NOT NULL, 144 | PRIMARY KEY (`nav_id`) 145 | ) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8; 146 | 147 | -- ---------------------------- 148 | -- Records of jx_nav 149 | -- ---------------------------- 150 | INSERT INTO `jx_nav` VALUES ('1', '首页', '.', '0'); 151 | INSERT INTO `jx_nav` VALUES ('2', '软件', 'sort/1', '0'); 152 | INSERT INTO `jx_nav` VALUES ('3', '设计软件', 'sort/10', '2'); 153 | INSERT INTO `jx_nav` VALUES ('4', '编程软件', 'sort/3', '2'); 154 | 155 | -- ---------------------------- 156 | -- Table structure for jx_soft_list 157 | -- ---------------------------- 158 | DROP TABLE IF EXISTS `jx_soft_list`; 159 | CREATE TABLE `jx_soft_list` ( 160 | `sid` bigint(20) unsigned NOT NULL AUTO_INCREMENT, 161 | `soft_name` varchar(255) NOT NULL COMMENT '软件名', 162 | `soft_exp` text NOT NULL COMMENT '软件说明', 163 | `soft_logo` varchar(255) NOT NULL, 164 | `soft_path` varchar(255) NOT NULL, 165 | `soft_uid` bigint(20) unsigned NOT NULL COMMENT '上传者的uid,用户ID', 166 | `soft_price` double(10,4) NOT NULL DEFAULT '1.0000', 167 | `soft_time` bigint(20) unsigned NOT NULL COMMENT '上传的时间', 168 | `soft_type` int(11) unsigned NOT NULL COMMENT '软件状态', 169 | PRIMARY KEY (`sid`) 170 | ) ENGINE=InnoDB AUTO_INCREMENT=17 DEFAULT CHARSET=utf8; 171 | 172 | -- ---------------------------- 173 | -- Records of jx_soft_list 174 | -- ---------------------------- 175 | INSERT INTO `jx_soft_list` VALUES ('1', '软件名', '说明', '', '', '1', '0.0000', '101011', '0'); 176 | INSERT INTO `jx_soft_list` VALUES ('2', '软件名1', '说明', '', '', '1', '0.0000', '101011', '0'); 177 | INSERT INTO `jx_soft_list` VALUES ('3', '软件名12', '说明', '', '', '1', '0.0000', '101011', '0'); 178 | INSERT INTO `jx_soft_list` VALUES ('4', '软件名123', '说明', '', '', '1', '0.0000', '101011', '0'); 179 | INSERT INTO `jx_soft_list` VALUES ('5', '软件名1423', '说明', '', '', '1', '0.0000', '101011', '0'); 180 | INSERT INTO `jx_soft_list` VALUES ('6', '软件名1423', '说明', '', '', '1', '0.0000', '101011', '0'); 181 | INSERT INTO `jx_soft_list` VALUES ('7', '软件名1423', '说明', '', '', '1', '0.0000', '101011', '0'); 182 | INSERT INTO `jx_soft_list` VALUES ('8', '软件名1423', '说明', '', '', '1', '0.0000', '101011', '0'); 183 | INSERT INTO `jx_soft_list` VALUES ('9', '软件名1423', '说明', '', '', '1', '0.0000', '101011', '0'); 184 | INSERT INTO `jx_soft_list` VALUES ('10', '软件名1423', '说明', '', '', '1', '0.0000', '101011', '0'); 185 | INSERT INTO `jx_soft_list` VALUES ('11', '1232131', '说明', '2017/11/TIM截图20171123210523_1511447100.png', 'soft/2017/11/PuTTY_0.67.0.0.exe', '1', '0.0000', '1511447102', '1'); 186 | INSERT INTO `jx_soft_list` VALUES ('12', '软件名1423', '说明', '2017/11/TIM截图20171123203233_1511445287.png', 'soft/2017/11/PuTTY_0.67.0.0.exe', '1', '0.0000', '1511445535', '1'); 187 | INSERT INTO `jx_soft_list` VALUES ('13', 'tim', '2333', '32', 'tim.exe', '1', '0.0000', '101011', '1'); 188 | INSERT INTO `jx_soft_list` VALUES ('14', '电影', '看看电影', '123', 'movie/jrkl.mp4', '1', '0.0000', '101011', '1'); 189 | INSERT INTO `jx_soft_list` VALUES ('15', 'putty3', '说明', 'putty.png', 'putty.exe', '1', '0.0000', '101011', '1'); 190 | INSERT INTO `jx_soft_list` VALUES ('16', '校园网', '2333333', '2017/11/TIM截图20171123210523_1511445825.png', 'soft/2017/11/openvpn-stushare.exe', '1', '0.0000', '1511445829', '1'); 191 | 192 | -- ---------------------------- 193 | -- Table structure for jx_soft_sort 194 | -- ---------------------------- 195 | DROP TABLE IF EXISTS `jx_soft_sort`; 196 | CREATE TABLE `jx_soft_sort` ( 197 | `soft_id` bigint(20) unsigned NOT NULL, 198 | `sort_id` bigint(20) unsigned NOT NULL 199 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 200 | 201 | -- ---------------------------- 202 | -- Records of jx_soft_sort 203 | -- ---------------------------- 204 | INSERT INTO `jx_soft_sort` VALUES ('15', '10'); 205 | INSERT INTO `jx_soft_sort` VALUES ('13', '2'); 206 | INSERT INTO `jx_soft_sort` VALUES ('15', '5'); 207 | 208 | -- ---------------------------- 209 | -- Table structure for jx_sort 210 | -- ---------------------------- 211 | DROP TABLE IF EXISTS `jx_sort`; 212 | CREATE TABLE `jx_sort` ( 213 | `sort_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '目录id', 214 | `sort_name` varchar(255) NOT NULL COMMENT '目录名', 215 | `sort_exp` varchar(255) NOT NULL COMMENT '目录说明', 216 | `sort_fid` bigint(20) unsigned NOT NULL COMMENT '父目录id', 217 | PRIMARY KEY (`sort_id`) 218 | ) ENGINE=InnoDB AUTO_INCREMENT=13 DEFAULT CHARSET=utf8; 219 | 220 | -- ---------------------------- 221 | -- Records of jx_sort 222 | -- ---------------------------- 223 | INSERT INTO `jx_sort` VALUES ('1', '软件', '软件区', '0'); 224 | INSERT INTO `jx_sort` VALUES ('2', '电脑软件', '', '1'); 225 | INSERT INTO `jx_sort` VALUES ('3', '编程软件', '', '1'); 226 | INSERT INTO `jx_sort` VALUES ('4', '游戏区', '游戏区', '0'); 227 | INSERT INTO `jx_sort` VALUES ('5', '单机游戏', '', '4'); 228 | INSERT INTO `jx_sort` VALUES ('6', '网游', '', '4'); 229 | INSERT INTO `jx_sort` VALUES ('7', '电影区', '电影', '0'); 230 | INSERT INTO `jx_sort` VALUES ('8', '喜剧', '', '7'); 231 | INSERT INTO `jx_sort` VALUES ('9', '恐怖电影', '', '7'); 232 | INSERT INTO `jx_sort` VALUES ('10', '设计软件', '', '1'); 233 | 234 | -- ---------------------------- 235 | -- Table structure for jx_token 236 | -- ---------------------------- 237 | DROP TABLE IF EXISTS `jx_token`; 238 | CREATE TABLE `jx_token` ( 239 | `uid` bigint(20) unsigned NOT NULL, 240 | `token` varchar(255) NOT NULL, 241 | `time` bigint(20) unsigned NOT NULL 242 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 243 | 244 | -- ---------------------------- 245 | -- Records of jx_token 246 | -- ---------------------------- 247 | INSERT INTO `jx_token` VALUES ('1', 'vIb8Hswo1512528696', '1512545511'); 248 | INSERT INTO `jx_token` VALUES ('1', 'Stz0WWI61512614578', '1512638005'); 249 | 250 | -- ---------------------------- 251 | -- Table structure for jx_user 252 | -- ---------------------------- 253 | DROP TABLE IF EXISTS `jx_user`; 254 | CREATE TABLE `jx_user` ( 255 | `uid` bigint(20) unsigned NOT NULL AUTO_INCREMENT, 256 | `user` varchar(255) NOT NULL, 257 | `pwd` varchar(255) NOT NULL, 258 | `email` varchar(255) NOT NULL, 259 | `avatar` varchar(255) NOT NULL, 260 | `integral` double(10,4) unsigned NOT NULL COMMENT '用户积分', 261 | PRIMARY KEY (`uid`) 262 | ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; 263 | 264 | -- ---------------------------- 265 | -- Records of jx_user 266 | -- ---------------------------- 267 | INSERT INTO `jx_user` VALUES ('1', 'farmer', '5ed87229c3bf49789b879507976bbd38', 'code.farmer@qq.com', '2017/11/TIM截图20171123210523_1511447100.png', '6.0000'); 268 | 269 | -- ---------------------------- 270 | -- Table structure for jx_usergroup 271 | -- ---------------------------- 272 | DROP TABLE IF EXISTS `jx_usergroup`; 273 | CREATE TABLE `jx_usergroup` ( 274 | `uid` bigint(11) unsigned NOT NULL, 275 | `group_id` int(11) unsigned NOT NULL, 276 | `expire_time` int(11) NOT NULL DEFAULT '-1' COMMENT '用户组到期时间 永久为-1', 277 | KEY `uid` (`uid`), 278 | KEY `user_group_id` (`group_id`) 279 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 280 | 281 | -- ---------------------------- 282 | -- Records of jx_usergroup 283 | -- ---------------------------- 284 | INSERT INTO `jx_usergroup` VALUES ('1', '2', '-1'); 285 | INSERT INTO `jx_usergroup` VALUES ('1', '3', '-1'); 286 | INSERT INTO `jx_usergroup` VALUES ('1', '1', '-1'); 287 | INSERT INTO `jx_usergroup` VALUES ('1', '4', '-1'); 288 | -------------------------------------------------------------------------------- /static/cmltable/cmltable.js: -------------------------------------------------------------------------------- 1 | (function ($) { 2 | var createCMLTable = function (tableJson) { 3 | var tableDiv = $(this); 4 | var TableObject; 5 | var tableHtml = '\n\n'; 6 | var selectHtml = '\n'; 20 | } 21 | if (tableJson.action) { 22 | for (var i = 0; i < tableJson.action.length; i++) { 23 | selectHtml += ' \n'; 24 | } 25 | } 26 | tableHtml += '\n
\n'; 14 | if (columns[i].checkbox == true) { 15 | tableHtml += '
\n'; 16 | } else if (columns[i].field) { 17 | tableHtml += columns[i].title + '\n'; 18 | } 19 | tableHtml += '
\n' 27 | selectHtml += '\n'; 28 | $(this).html(selectHtml + '\n' + '' + tableHtml); 29 | $(this).find('.cmltable-sublit').click(function (event) { //选择列表框确定 30 | for (var i = 0; i < tableJson.action.length; i++) { 31 | if (tableJson.action[i].action == $(this).prev().val()) { 32 | tableJson.action[i].func(TableObject); 33 | break; 34 | } 35 | } 36 | }); 37 | $(this).find('.cmltable-check-head').click(function (event) { //全选 38 | headCheck = $(this).attr('check'); 39 | TableObject.find('.cmltable-check').each(function (index, el) { 40 | if (index == 0) return 0; 41 | if (headCheck == 'true') { 42 | $(this).text(''); 43 | $(this).attr('check', 'false'); 44 | } else { 45 | $(this).text('✔'); 46 | $(this).attr('check', 'true'); 47 | } 48 | }); 49 | 50 | }); 51 | 52 | $(this).on('click', '.cmltable-footer > .cmltable-pages > .cmltable-btn', function (event) { //下一页或者上一页 53 | var pageText = $(this).text(); 54 | if (pageText == '<') { 55 | if (parseInt(nowPage) != 1) { 56 | nowPage--; 57 | } 58 | } else if (pageText == '>') { 59 | if (parseInt(nowPage) != totalPage) { 60 | nowPage++; 61 | } 62 | } else { 63 | nowPage = pageText; 64 | } 65 | TableObject.refresh(); 66 | }); 67 | 68 | TableObject = $(this).children('.cmltable'); 69 | /** 70 | * 获取选中 71 | * @return {json} [选中项] 72 | */ 73 | TableObject.getSelect = function () { 74 | var check = {}; 75 | var i = 0; 76 | $(this).find('.cmltable-check').each(function (index, el) { 77 | if ($(this).attr('check') == 'true' && $(this).attr('cml-value') != 0) { 78 | check['id[' + i++ + ']'] = $(this).attr('cml-value'); 79 | } 80 | }); 81 | return check; 82 | }; 83 | TableObject.findById=function (keyid) { 84 | for (var n = 0; n < rows.length; n++) { 85 | if(rows[n][tableJson.keyID]==keyid){ 86 | return rows[n]; 87 | } 88 | } 89 | return false; 90 | } 91 | /** 92 | * 刷新 93 | * @return {null} 94 | */ 95 | TableObject.refresh = function () { 96 | //清空 97 | TableObject.find("tr:not(:first)").remove(); 98 | jQuery.ajax({ //读取内容 99 | url: tableJson.url, 100 | type: 'get', 101 | data: {'page': nowPage,'keyword':keyword}, 102 | success: function (jsonData) { 103 | tableDiv.find('.cmltable-page').html(jsonData['page']); 104 | tableDiv.find('.cmltable-total').html(jsonData['total']); 105 | //填入内容 106 | rows=jsonData.rows; 107 | for (var n = 0; n < jsonData.rows.length; n++) { 108 | var newRow = ""; 109 | for (var i = 0; i < columns.length; i++) { 110 | newRow += ""; 111 | if (columns[i].checkbox == true) { 112 | newRow += '
\n'; 113 | } else if (columns[i].field) { 114 | if (columns[i].format) { 115 | newRow += columns[i].format(jsonData.rows[n][columns[i].field], jsonData.rows[n][tableJson.keyID]) + '\n'; 116 | } else { 117 | newRow += jsonData.rows[n][columns[i].field] + '\n'; 118 | } 119 | 120 | } 121 | newRow += "\n"; 122 | } 123 | newRow += "\n" 124 | TableObject.find('tr:last').after(newRow); 125 | } 126 | switchInit(); 127 | var pageHtml = ''; 128 | //设置页码 129 | if (jsonData['page'] <= 8) { 130 | for (var i = 0; i < jsonData['page']; i++) { 131 | pageHtml += ''; 132 | } 133 | } 134 | pageHtml += ''; 135 | totalPage = jsonData['page']; 136 | tableDiv.find('.cmltable-pages').html(pageHtml); 137 | } 138 | }); 139 | }; 140 | $(this).find('.cmltable-search-btn').click(function (event) {//搜索 141 | keyword=$('.cmltable-search-edit').val(); 142 | TableObject.refresh(); 143 | }); 144 | TableObject.refresh(); 145 | return TableObject; 146 | }; 147 | $.fn.createCMLTable = createCMLTable; 148 | })(jQuery); 149 | 150 | 151 | jQuery(document).ready(function ($) { 152 | $('.cmltable-check').each(function (index, el) { 153 | if ($(this).attr('check') == 'true') { 154 | $(this).text('✔'); 155 | $(this).attr('check', 'true'); 156 | } else { 157 | $(this).text('1'); 158 | $(this).attr('check', 'false'); 159 | } 160 | }); 161 | $(document).on('click', '.cmltable-check', function (event) { 162 | if ($(this).attr('check') == 'true') { 163 | $(this).text(''); 164 | $(this).attr('check', 'false'); 165 | } else { 166 | $(this).text('✔'); 167 | $(this).attr('check', 'true'); 168 | } 169 | }); 170 | switchInit(); 171 | $(document).on('click', '.cmltable-switch', function (event) { 172 | if ($(this).attr('check') == 'true') { 173 | $(this).attr('check', 'false'); 174 | $(this).children('.cmltable-switch-on').css({float: 'left', background: '#64bd63'}); 175 | } else { 176 | $(this).attr('check', 'true'); 177 | $(this).children('.cmltable-switch-on').css({float: 'right', background: '#ffc800'}); 178 | } 179 | }); 180 | }); 181 | 182 | function switchInit() { 183 | $('.cmltable-switch').each(function (index, el) { 184 | if ($(this).attr('check') == 'true') { 185 | $(this).attr('check', 'true'); 186 | $(this).children('.cmltable-switch-on').css({float: 'left', background: '#64bd63'}); 187 | } else { 188 | $(this).attr('check', 'false'); 189 | $(this).children('.cmltable-switch-on').css({float: 'right', background: '#ffc800'}); 190 | } 191 | }); 192 | } 193 | 194 | function editShow(title, data) { 195 | var html = '
\n' + 196 | '
\n' + 197 | '
\n' + 198 | '
' + title + '
\n' + 199 | '
\n' + 200 | '
\n'; 201 | for (var i = 0; i < data.rows.length; i++) { 202 | if (data.rows[i].type == undefined) { 203 | data.rows[i].type = 'default'; 204 | } 205 | if (data.rows[i].value != undefined) { 206 | if (data.rows[i].type == 'html') { 207 | html += '
' + data.rows[i].value + '
'; 208 | } else if (data.rows[i].type == 'multi') { 209 | html += '
' + 210 | '' + 212 | '
'; 213 | } else if (data.rows[i].type == 'select') { 214 | html += '
'; 227 | } else { 228 | html += '
'; 229 | html += '
\n'; 231 | } 232 | 233 | } else { 234 | html += '>
\n'; 235 | } 236 | } 237 | 238 | html += '
\n' + 239 | ' \n' + 243 | '
\n' + 244 | '
'; 245 | $('body:last').append(html); 246 | $('.cml-btn.confirm').click(function () { 247 | if (data['post'] == undefined) { 248 | $('.showmsg').remove(); 249 | return; 250 | } 251 | var param = {}; 252 | for (var i = 0; i < data.rows.length; i++) { 253 | if (data.rows[i].type == undefined) { 254 | data.rows[i].type = 'default'; 255 | } 256 | if (data.rows[i].value != undefined) { 257 | if (data.rows[i].type == 'default') { 258 | param[data.rows[i].field] = $('.' + data.rows[i].field).val(); 259 | } else if (data.rows[i].type == 'select') { 260 | param[data.rows[i].field] = $('.' + data.rows[i].field).val(); 261 | } else if (data.rows[i].type == 'multi') { 262 | param[data.rows[i].field] = $('.' + data.rows[i].field).val(); 263 | } 264 | 265 | } else { 266 | html += '>\n'; 267 | } 268 | } 269 | if (data['post'](param)) { 270 | $('.showmsg').remove(); 271 | return; 272 | } 273 | 274 | }); 275 | $('.cml-btn.cancel').click(function () { 276 | $('.showmsg').remove(); 277 | return; 278 | }); 279 | var obj = {}; 280 | obj.close = function () { 281 | $('.showmsg').remove(); 282 | } 283 | return obj; 284 | } -------------------------------------------------------------------------------- /static/ckplayer/ckplayer.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | true 6 | 30 7 | 100 8 | true 9 | 0 10 | true 11 | true 12 | 200 13 | true 14 | true 15 | 200 16 | 17 | true 18 | true 19 | true 20 | true 21 | true 22 | 23 | 10 24 | 0.1 25 | 1 26 | true 27 | false 28 | 29 | false 30 | false 31 | true 32 | true 33 | 34 | 35 | false 36 | 2 37 | start 38 | 39 | 1 40 | false 41 | true 42 | 43 | 49 | 50 | 30 51 | , 52 | http://192.168.1.186/ckplayer/ckplayerX1/time.php?d=d 53 | adPlay,adPause,playOrPause,videoPlay,videoPause,videoMute,videoEscMute,videoClear,changeVolume,fastBack,fastNext,videoSeek,newVideo,getMetaDate,videoRotation,videoBrightness,videoContrast,videoSaturation,videoHue,videoZoom,videoProportion,videoError,addListener,removeListener,addElement,getElement,deleteElement,animate,animateResume,animatePause,changeConfig,getConfig,openUrl,fullScreen,quitFullScreen,switchFull,screenshot,custom 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 104 | 105 | 106 | -------------------------------------------------------------------------------- /icf/lib/smtp.php: -------------------------------------------------------------------------------- 1 | _name=$name; 89 | } 90 | /** 91 | * 设置邮件传输代理,如果是可以匿名发送有邮件的服务器,只需传递代理服务器地址就行 92 | * @access public 93 | * @param string $server 代理服务器的ip或者域名 94 | * @param string $username 认证账号 95 | * @param string $password 认证密码 96 | * @param int $port 代理服务器的端口,smtp默认25号端口 97 | * @param boolean $isSecurity 到服务器的连接是否为安全连接,默认false 98 | * @return boolean 99 | */ 100 | public function setServer($server, $username = "", $password = "", $port = 25, $isSecurity = false) { 101 | $this->_sendServer = $server; 102 | $this->_port = $port; 103 | $this->_isSecurity = $isSecurity; 104 | $this->_userName = empty($username) ? "" : base64_encode($username); 105 | $this->_password = empty($password) ? "" : base64_encode($password); 106 | return true; 107 | } 108 | 109 | /** 110 | * 设置发件人 111 | * @access public 112 | * @param string $from 发件人地址 113 | * @return boolean 114 | */ 115 | public function setFrom($from) { 116 | $this->_from = $from; 117 | return true; 118 | } 119 | 120 | /** 121 | * 设置收件人,多个收件人,调用多次. 122 | * @access public 123 | * @param string $to 收件人地址 124 | * @return boolean 125 | */ 126 | public function setReceiver($to) { 127 | $this->_to[] = $to; 128 | return true; 129 | } 130 | 131 | /** 132 | * 设置抄送,多个抄送,调用多次. 133 | * @access public 134 | * @param string $cc 抄送地址 135 | * @return boolean 136 | */ 137 | public function setCc($cc) { 138 | $this->_cc[] = $cc; 139 | return true; 140 | } 141 | 142 | /** 143 | * 设置秘密抄送,多个秘密抄送,调用多次 144 | * @access public 145 | * @param string $bcc 秘密抄送地址 146 | * @return boolean 147 | */ 148 | public function setBcc($bcc) { 149 | $this->_bcc[] = $bcc; 150 | return true; 151 | } 152 | 153 | /** 154 | * 设置邮件附件,多个附件,调用多次 155 | * @access public 156 | * @param string $file 文件地址 157 | * @return boolean 158 | */ 159 | public function addAttachment($file) { 160 | if (!file_exists($file)) { 161 | $this->_errorMessage = "file " . $file . " does not exist."; 162 | return false; 163 | } 164 | $this->_attachment[] = $file; 165 | return true; 166 | } 167 | 168 | /** 169 | * 设置邮件信息 170 | * @access public 171 | * @param string $body 邮件主题 172 | * @param string $subject 邮件主体内容,可以是纯文本,也可是是HTML文本 173 | * @return boolean 174 | */ 175 | public function setMail($subject, $body) { 176 | $this->_subject = base64_encode($subject); 177 | $this->_body = base64_encode($body); 178 | return true; 179 | } 180 | 181 | /** 182 | * 发送邮件 183 | * @access public 184 | * @return boolean 185 | */ 186 | public function sendMail() { 187 | $command = $this->getCommand(); 188 | $this->_isSecurity ? $this->socketSecurity() : $this->socket(); 189 | foreach ($command as $value) { 190 | $result = $this->_isSecurity ? $this->sendCommandSecurity($value[0], $value[1]) : $this->sendCommand($value[0], $value[1]); 191 | if ($result) { 192 | continue; 193 | } else { 194 | return false; 195 | } 196 | } 197 | //其实这里也没必要关闭,smtp命令:QUIT发出之后,服务器就关闭了连接,本地的socket资源会自动释放 198 | $this->_isSecurity ? $this->closeSecutity() : $this->close(); 199 | return true; 200 | } 201 | 202 | /** 203 | * 返回错误信息 204 | * @return string 205 | */ 206 | public function error() { 207 | if (!isset($this->_errorMessage)) { 208 | $this->_errorMessage = ""; 209 | } 210 | return $this->_errorMessage; 211 | } 212 | 213 | /** 214 | * 返回mail命令 215 | * @access protected 216 | * @return array 217 | */ 218 | protected function getCommand() { 219 | $separator = "----=_Part_" . md5($this->_from . time()) . uniqid(); //分隔符 220 | $command = array( 221 | array("HELO sendmail\r\n", 250) 222 | ); 223 | if (!empty($this->_userName)) { 224 | $command[] = array("AUTH LOGIN\r\n", 334); 225 | $command[] = array($this->_userName . "\r\n", 334); 226 | $command[] = array($this->_password . "\r\n", 235); 227 | } 228 | //设置发件人 229 | $command[] = array("MAIL FROM: <" . $this->_from . ">\r\n", 250); 230 | $header = "FROM: =?utf-8?b?".base64_encode($this->_name)."?= <" . $this->_from . ">\r\n"; 231 | //设置收件人 232 | if (!empty($this->_to)) { 233 | $count = count($this->_to); 234 | if ($count == 1) { 235 | $command[] = array("RCPT TO: <" . $this->_to[0] . ">\r\n", 250); 236 | $header .= "TO: <" . $this->_to[0] . ">\r\n"; 237 | } else { 238 | for ($i = 0; $i < $count; $i++) { 239 | $command[] = array("RCPT TO: <" . $this->_to[$i] . ">\r\n", 250); 240 | if ($i == 0) { 241 | $header .= "TO: <" . $this->_to[$i] . ">"; 242 | } elseif ($i + 1 == $count) { 243 | $header .= ",<" . $this->_to[$i] . ">\r\n"; 244 | } else { 245 | $header .= ",<" . $this->_to[$i] . ">"; 246 | } 247 | } 248 | } 249 | } 250 | //设置抄送 251 | if (!empty($this->_cc)) { 252 | $count = count($this->_cc); 253 | if ($count == 1) { 254 | $command[] = array("RCPT TO: <" . $this->_cc[0] . ">\r\n", 250); 255 | $header .= "CC: <" . $this->_cc[0] . ">\r\n"; 256 | } else { 257 | for ($i = 0; $i < $count; $i++) { 258 | $command[] = array("RCPT TO: <" . $this->_cc[$i] . ">\r\n", 250); 259 | if ($i == 0) { 260 | $header .= "CC: <" . $this->_cc[$i] . ">"; 261 | } elseif ($i + 1 == $count) { 262 | $header .= ",<" . $this->_cc[$i] . ">\r\n"; 263 | } else { 264 | $header .= ",<" . $this->_cc[$i] . ">"; 265 | } 266 | } 267 | } 268 | } 269 | //设置秘密抄送 270 | if (!empty($this->_bcc)) { 271 | $count = count($this->_bcc); 272 | if ($count == 1) { 273 | $command[] = array("RCPT TO: <" . $this->_bcc[0] . ">\r\n", 250); 274 | $header .= "BCC: <" . $this->_bcc[0] . ">\r\n"; 275 | } else { 276 | for ($i = 0; $i < $count; $i++) { 277 | $command[] = array("RCPT TO: <" . $this->_bcc[$i] . ">\r\n", 250); 278 | if ($i == 0) { 279 | $header .= "BCC: <" . $this->_bcc[$i] . ">"; 280 | } elseif ($i + 1 == $count) { 281 | $header .= ",<" . $this->_bcc[$i] . ">\r\n"; 282 | } else { 283 | $header .= ",<" . $this->_bcc[$i] . ">"; 284 | } 285 | } 286 | } 287 | } 288 | //主题 289 | $header .= "Subject: =?UTF-8?B?" . $this->_subject . "?=\r\n"; 290 | if (isset($this->_attachment)) { 291 | //含有附件的邮件头需要声明成这个 292 | $header .= "Content-Type: multipart/mixed;\r\n"; 293 | } elseif (false) { 294 | //邮件体含有图片资源的,且包含的图片在邮件内部时声明成这个,如果是引用的远程图片,就不需要了 295 | $header .= "Content-Type: multipart/related;\r\n"; 296 | } else { 297 | //html或者纯文本的邮件声明成这个 298 | $header .= "Content-Type: multipart/alternative;\r\n"; 299 | } 300 | //邮件头分隔符 301 | $header .= "\t" . 'boundary="' . $separator . '"'; 302 | $header .= "\r\nMIME-Version: 1.0\r\n"; 303 | //这里开始是邮件的body部分,body部分分成几段发送 304 | $header .= "\r\n--" . $separator . "\r\n"; 305 | $header .= "Content-Type:text/html; charset=utf-8\r\n"; 306 | $header .= "Content-Transfer-Encoding: base64\r\n\r\n"; 307 | $header .= $this->_body . "\r\n"; 308 | $header .= "--" . $separator . "\r\n"; 309 | //加入附件 310 | if (!empty($this->_attachment)) { 311 | $count = count($this->_attachment); 312 | for ($i = 0; $i < $count; $i++) { 313 | $header .= "\r\n--" . $separator . "\r\n"; 314 | $header .= "Content-Type: " . $this->getMIMEType($this->_attachment[$i]) . '; name="=?UTF-8?B?' . base64_encode(basename($this->_attachment[$i])) . '?="' . "\r\n"; 315 | $header .= "Content-Transfer-Encoding: base64\r\n"; 316 | $header .= 'Content-Disposition: attachment; filename="=?UTF-8?B?' . base64_encode(basename($this->_attachment[$i])) . '?="' . "\r\n"; 317 | $header .= "\r\n"; 318 | $header .= $this->readFile($this->_attachment[$i]); 319 | $header .= "\r\n--" . $separator . "\r\n"; 320 | } 321 | } 322 | //结束邮件数据发送 323 | $header .= "\r\n.\r\n"; 324 | 325 | $command[] = array("DATA\r\n", 354); 326 | $command[] = array($header, 250); 327 | $command[] = array("QUIT\r\n", 221); 328 | return $command; 329 | } 330 | 331 | /** 332 | * 发送命令 333 | * @access protected 334 | * @param string $command 发送到服务器的smtp命令 335 | * @param int $code 期望服务器返回的响应吗 336 | * @return boolean 337 | */ 338 | protected function sendCommand($command, $code) { 339 | // echo 'Send command:' . $command . ',expected code:' . $code . '
'; 340 | //发送命令给服务器 341 | try { 342 | if (socket_write($this->_socket, $command, strlen($command))) { 343 | //当邮件内容分多次发送时,没有$code,服务器没有返回 344 | if (empty($code)) { 345 | return true; 346 | } 347 | //读取服务器返回 348 | $data = trim(socket_read($this->_socket, 1024)); 349 | // echo 'response:' . $data . '

'; 350 | if ($data) { 351 | $pattern = "/^" . $code . "+?/"; 352 | if (preg_match($pattern, $data)) { 353 | return true; 354 | } else { 355 | $this->_errorMessage = "Error:" . $data . "|**| command:"; 356 | return false; 357 | } 358 | } else { 359 | $this->_errorMessage = "Error:" . socket_strerror(socket_last_error()); 360 | return false; 361 | } 362 | } else { 363 | $this->_errorMessage = "Error:" . socket_strerror(socket_last_error()); 364 | return false; 365 | } 366 | } catch (Exception $e) { 367 | $this->_errorMessage = "Error:" . $e->getMessage(); 368 | } 369 | } 370 | 371 | /** 372 | * 安全连接发送命令 373 | * @access protected 374 | * @param string $command 发送到服务器的smtp命令 375 | * @param int $code 期望服务器返回的响应吗 376 | * @return boolean 377 | */ 378 | protected function sendCommandSecurity($command, $code) { 379 | // echo 'Send command:' . $command . ',expected code:' . $code . '
'; 380 | try { 381 | if (fwrite($this->_socket, $command)) { 382 | //当邮件内容分多次发送时,没有$code,服务器没有返回 383 | if (empty($code)) { 384 | return true; 385 | } 386 | //读取服务器返回 387 | $data = trim(fread($this->_socket, 1024)); 388 | // echo 'response:' . $data . '

'; 389 | if ($data) { 390 | $pattern = "/^" . $code . "+?/"; 391 | if (preg_match($pattern, $data)) { 392 | return true; 393 | } else { 394 | $this->_errorMessage = "Error:" . $data . "|**| command:"; 395 | return false; 396 | } 397 | } else { 398 | return false; 399 | } 400 | } else { 401 | $this->_errorMessage = "Error: " . $command . " send failed"; 402 | return false; 403 | } 404 | } catch (Exception $e) { 405 | $this->_errorMessage = "Error:" . $e->getMessage(); 406 | } 407 | } 408 | 409 | /** 410 | * 读取附件文件内容,返回base64编码后的文件内容 411 | * @access protected 412 | * @param string $file 文件 413 | * @return mixed 414 | */ 415 | protected function readFile($file) { 416 | if (file_exists($file)) { 417 | $file_obj = file_get_contents($file); 418 | return base64_encode($file_obj); 419 | } else { 420 | $this->_errorMessage = "file " . $file . " dose not exist"; 421 | return false; 422 | } 423 | } 424 | 425 | /** 426 | * 获取附件MIME类型 427 | * @access protected 428 | * @param string $file 文件 429 | * @return mixed 430 | */ 431 | protected function getMIMEType($file) { 432 | if (file_exists($file)) { 433 | $mime = mime_content_type($file); 434 | /*if(! preg_match("/gif|jpg|png|jpeg/", $mime)){ 435 | $mime = "application/octet-stream"; 436 | }*/ 437 | return $mime; 438 | } else { 439 | return false; 440 | } 441 | } 442 | 443 | /** 444 | * 建立到服务器的网络连接 445 | * @access protected 446 | * @return boolean 447 | */ 448 | protected function socket() { 449 | //创建socket资源 450 | $this->_socket = socket_create(AF_INET, SOCK_STREAM, getprotobyname('tcp')); 451 | if (!$this->_socket) { 452 | $this->_errorMessage = socket_strerror(socket_last_error()); 453 | return false; 454 | } 455 | socket_set_block($this->_socket);//设置阻塞模式 456 | //连接服务器 457 | if (!socket_connect($this->_socket, $this->_sendServer, $this->_port)) { 458 | $this->_errorMessage = socket_strerror(socket_last_error()); 459 | return false; 460 | } 461 | $str = socket_read($this->_socket, 1024); 462 | if (!preg_match("/220+?/", $str)) { 463 | $this->_errorMessage = $str; 464 | return false; 465 | } 466 | return true; 467 | } 468 | 469 | /** 470 | * 建立到服务器的SSL网络连接 471 | * @access protected 472 | * @return boolean 473 | */ 474 | protected function socketSecurity() { 475 | $remoteAddr = "tcp://" . $this->_sendServer . ":" . $this->_port; 476 | $this->_socket = stream_socket_client($remoteAddr, $errno, $errstr, 30); 477 | if (!$this->_socket) { 478 | $this->_errorMessage = $errstr; 479 | return false; 480 | } 481 | //设置加密连接,默认是ssl,如果需要tls连接,可以查看php手册stream_socket_enable_crypto函数的解释 482 | stream_socket_enable_crypto($this->_socket, true, STREAM_CRYPTO_METHOD_SSLv23_CLIENT); 483 | stream_set_blocking($this->_socket, 1); //设置阻塞模式 484 | $str = fread($this->_socket, 1024); 485 | if (!preg_match("/220+?/", $str)) { 486 | $this->_errorMessage = $str; 487 | return false; 488 | } 489 | return true; 490 | } 491 | 492 | /** 493 | * 关闭socket 494 | * @access protected 495 | * @return boolean 496 | */ 497 | protected function close() { 498 | if (isset($this->_socket) && is_object($this->_socket)) { 499 | $this->_socket->close(); 500 | return true; 501 | } 502 | $this->_errorMessage = "No resource can to be close"; 503 | return false; 504 | } 505 | 506 | /** 507 | * 关闭安全socket 508 | * @access protected 509 | * @return boolean 510 | */ 511 | protected function closeSecutity() { 512 | if (isset($this->_socket) && is_object($this->_socket)) { 513 | stream_socket_shutdown($this->_socket, STREAM_SHUT_WR); 514 | return true; 515 | } 516 | $this->_errorMessage = "No resource can to be close"; 517 | return false; 518 | } 519 | } --------------------------------------------------------------------------------