示例#1
0
 public function user()
 {
     $_DCOOKIE = array();
     $this->cookiepre = $this->cookiepre . substr(md5($this->cookiepath . '|' . $this->cookiedomain), 0, 4) . '_';
     $prelength = strlen($this->cookiepre);
     foreach ($_COOKIE as $key => $val) {
         if (substr($key, 0, $prelength) == $this->cookiepre) {
             $_DCOOKIE[substr($key, $prelength)] = Lua::clean($val);
         }
     }
     unset($prelength);
     if (isset($_DCOOKIE['auth'])) {
         $authkey = md5($this->authkey . $_SERVER['HTTP_USER_AGENT']);
         $auth = Lua::clean(explode("\t", $this->authcode($_DCOOKIE['auth'], 'DECODE', $authkey)));
         list($discuz_pw, $discuz_uid) = empty($auth) || count($auth) < 2 ? array('', '') : $auth;
         if ($discuz_uid) {
             Doo::db()->reconnect('X15');
             $query = "select u.uid,u.username,u.password,p.gender from pre_common_member u left join pre_common_member_profile p on p.uid=u.uid where u.uid='{$discuz_uid}'";
             $query = str_replace('pre_', $this->tablepre, $query);
             $user = Lua::get_one($query);
             Doo::db()->reconnect('dev');
             if (!empty($user) && $user['password'] == $discuz_pw) {
                 unset($user['password']);
                 return $user;
             }
         }
     }
     return array();
 }
示例#2
0
 public function user()
 {
     $_DCOOKIE = array();
     $prelength = strlen($this->cookiepre);
     foreach ($_COOKIE as $key => $val) {
         if (substr($key, 0, $prelength) == $this->cookiepre) {
             $_DCOOKIE[substr($key, $prelength)] = Lua::clean($val);
         }
     }
     unset($prelength);
     $discuz_auth_key = md5($this->authkey . $_SERVER['HTTP_USER_AGENT']);
     list($discuz_pw, $discuz_secques, $discuz_uid) = isset($_DCOOKIE['auth']) ? Lua::clean(explode("\t", $this->authcode($_DCOOKIE['auth'], 'DECODE', $discuz_auth_key)), 1) : array('', '', 0);
     $discuz_uid = intval($discuz_uid);
     Doo::db()->reconnect('dz7');
     $query = "select m.uid,m.username,m.password,m.gender as sex,mf.avatar as icon from cdb_members m left join cdb_memberfields mf on mf.uid=m.uid where m.uid='{$discuz_uid}'";
     $query = str_replace('cdb_', $this->tablepre, $query);
     $user = Lua::get_one($query);
     Doo::db()->reconnect('dev');
     if ($user && $discuz_pw == $user['password']) {
         unset($user['password']);
         $user['hash'] = substr(md5(substr(TIMESTAMP, 0, -7) . iconv('utf-8', 'gbk', $user['username']) . $discuz_uid . $discuz_pw . $discuz_auth_key), 8, 8);
         return $user;
     }
     return array();
 }
示例#3
0
 public function beforeRun($resource, $action)
 {
     $this->dir = ADMIN_ROOT . '/moban/';
     $this->img = '/' . ADMIN_ROOT . '/static/';
     $session = Doo::session('Lua');
     $auth = $session->get('auth');
     if (empty($auth)) {
         $sets = Doo::cache('php')->get('loginset');
         if ($sets && $sets['cardit'] == 1) {
             $xxxx = array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J');
             $nums = range(1, 9);
             shuffle($xxxx);
             shuffle($nums);
             $aaaa = $xxxx[0] . $nums[0];
             $bbbb = $xxxx[1] . $nums[1];
             $session->cardcode = $aaaa . '@' . $bbbb;
         }
         include Lua::display('login', $this->dir);
         exit;
     }
     $auth = empty($auth) ? array(0, '') : Lua::clean(explode("\t", Lua::authcode($auth, 'DECODE')), 1);
     $user = Lua::get_one("select * from lua_admin where uid='" . intval($auth[0]) . "' and password='******' and gid='1'");
     if (empty($user) || $user && $this->clientIP() != $user['loginip']) {
         $session->auth = '';
         Lua::admin_msg('操作提示', '请先登录', '/' . ADMIN_ROOT);
     }
     $rs = $this->acl()->process($user['perm'], $resource, $action);
     if ($rs) {
         return $rs;
     }
     $this->user = $user;
     $this->page = Lua::get_post('p') ? intval(Lua::get_post('p')) : 1;
     // 图片识别码, 借鉴自 supesite
     define('FILE_HASH', substr(md5($user['uid'] . '/' . time() . Lua::random(6)), 8, 16));
 }
示例#4
0
 public function logout()
 {
     $session = Doo::session('Lua');
     $auth = $session->get('auth');
     $auth = empty($auth) ? array(0, '') : Lua::clean(explode("\t", Lua::authcode($auth, 'DECODE')), 1);
     $user = Lua::get_one("select * from lua_admin where uid='" . intval($auth[0]) . "' and password='******' and gid='1'");
     if ($user) {
         Lua::write_log($user, '退出系统', '---', $user['channel']);
     }
     $session->auth = '';
     Lua::admin_msg('操作提示', '成功退出系统', '/' . ADMIN_ROOT);
 }
示例#5
0
 public function _doit()
 {
     $dirs = date('Y-m-d');
     $path = $this->cache . $dirs . '/';
     $configFile = $path . 'config.php';
     Doo::loadHelper('DooFile');
     $fileManager = new DooFile(0777);
     if (!file_exists($configFile)) {
         if (!file_exists($path)) {
             $fileManager->create($path);
         }
         $tables = Doo::db()->fetchAll("SHOW TABLE STATUS");
         $b_table = $d_table = '';
         foreach ($tables as $row) {
             $b_table .= $row['Name'] . ",";
             $d_table .= "\$tb['" . $row['Name'] . "']=0;\r\n";
         }
         $b_table = substr($b_table, 0, strlen($b_table) - 1);
         $string = "<?php\r\n\$b_table=\"" . $b_table . "\";\r\n" . $d_table . "?>";
         $fileManager->create($configFile, $string);
         $this->jsonp('写入配置文件 ...');
     } else {
         include $configFile;
     }
     $btb = explode(",", $b_table);
     $count = count($btb);
     $t = intval(Lua::post('t'));
     $s = intval(Lua::post('s'));
     $p = intval(Lua::post('p'));
     $alltotal = intval(Lua::post('alltotal'));
     $fnum = intval(Lua::post('fnum'));
     $dumpsql = '';
     if ($t >= $count) {
         echo 'success';
         exit;
     }
     if (empty($s)) {
         $num = Doo::db()->fetchRow("SHOW TABLE STATUS LIKE '" . $btb[$t] . "';");
         $num = $num['Rows'];
         $dumpsql .= "self::query(\"DROP TABLE IF EXISTS `" . $btb[$t] . "`;\");\r\n";
         Doo::db()->query("SET SQL_QUOTE_SHOW_CREATE=1");
         $r = Doo::db()->fetchRow("SHOW CREATE TABLE `" . $btb[$t] . "`;");
         $create = str_replace("\"", "\\\"", $r['Create Table']);
         $dumpsql .= "self::create(\"" . $create . "\");\r\n";
     } else {
         $num = (int) $alltotal;
     }
     $fields = Doo::db()->fetchAll("SHOW FIELDS FROM `" . $btb[$t] . "`");
     if (empty($fnum)) {
         $field_num = count($fields);
     } else {
         $field_num = $fnum;
     }
     $b = 0;
     $list = Doo::db()->fetchAll("select * from `" . $btb[$t] . "` limit {$s},{$num}");
     if ($list) {
         foreach ($list as $v) {
             $b = 1;
             $s++;
             $dumpsql .= "self::query(\"replace into `" . $btb[$t] . "` values(";
             $first = 1;
             for ($i = 0; $i < $field_num; $i++) {
                 if (empty($first)) {
                     $dumpsql .= ',';
                 } else {
                     $first = 0;
                 }
                 $_field_name = $fields[$i]['Field'];
                 if (!isset($v[$_field_name])) {
                     $dumpsql .= 'NULL';
                 } else {
                     $dumpsql .= '\'' . Lua::clean($v[$_field_name]) . '\'';
                 }
             }
             $dumpsql .= ");\");\r\n";
             if (strlen($dumpsql) >= 2048 * 1024) {
                 $p++;
                 $sfile = $path . "/" . $btb[$t] . "_" . $p . ".php";
                 $fileManager->create($sfile, "<?php\r\n" . $dumpsql . "?>");
                 $this->jsonp('Table Name&nbsp;:&nbsp;<b>' . $btb[$t] . '</b><br />Table&nbsp;:&nbsp;<b>' . ($t + 1) . '/' . $count . '</b><br />Record&nbsp;:&nbsp;<b>' . $s . '/' . $num . '</b><br />备份一组数据成功,正在进入下一组......', $s, $p, $t, $alltotal, $fnum);
             }
         }
     }
     if (empty($p) || $b == 1) {
         $p++;
         $sfile = $path . "/" . $btb[$t] . "_" . $p . ".php";
         $fileManager->create($sfile, "<?php\r\n" . $dumpsql . "?>");
     }
     if (empty($p)) {
         $p = 0;
     }
     $text = $fileManager->readFileContents($configFile);
     $rep1 = "\$tb['" . $btb[$t] . "']=0;";
     $rep2 = "\$tb['" . $btb[$t] . "']=" . $p . ";";
     $text = str_replace($rep1, $rep2, $text);
     $fileManager->create($configFile, $text);
     $t++;
     $this->jsonp('备份' . $btb[$t - 1] . '表成功,正在进入下一个表备份......', 0, 0, $t, 0, 0);
 }