function _do_register($username, $password, $email) { $user = array('username' => $username, 'password' => 'FAKE_PASSWORD', 'email' => $email); $uid = DB::insert('member', $user); $user['uid'] = $uid; $password = Widget_Password::encrypt($user, $password); DB::query("UPDATE member SET password='******' WHERE uid='{$uid}'"); DB::insert('member_setting', array('uid' => $uid, 'cookie' => '')); HOOK::run('register_user', true, $user); CACHE::update('username'); CACHE::save('user_setting_' . $uid, ''); return $uid; }
public static function loop() { if (defined('IN_XAE')) { return array('status' => -3); } $file_list = CACHE::get('need_download'); list($path, $hash) = array_pop($file_list); if (!$path) { return array('status' => 1); } $ret = self::_download_file($path, $hash); if ($ret < 0) { return array('status' => $ret, 'file' => $path); } CACHE::save('need_download', $file_list); $max = sizeof(CACHE::get('kk_updater')); $current = $max - sizeof($file_list); return array('status' => 0, 'precent' => round($current / $max * 100), 'file' => $path); }
function _load_setting() { $this->_setting = CACHE::get('mail_' . $this->id); if ($this->_setting) { return; } $this->_setting = array(); if ($this->config) { foreach ($this->config as $k => $v) { $this->_setting[$v[1]] = $v[3]; } } $class = getSetting('mail_class'); $query = DB::query("SELECT * FROM setting WHERE k LIKE '_mail_{$class}_%'"); while ($result = DB::fetch($query)) { $key = str_replace("_mail_{$class}_", '', $result['k']); $this->_setting[$key] = $result['v']; } CACHE::save('mail_' . $this->id, $this->_setting); }
$class = getSetting('mail_class'); $obj = $classes[$class]; if (!$obj) { showmessage('选择的邮件发送方式不正确.', 'admin.php#setting'); } if (!$obj->isAvailable()) { showmessage('选择的邮件发送方式不可用.', 'admin.php#setting'); } $_config = $obj->config; if ($_POST['formhash'] == $formhash) { foreach ($_config as $k => $v) { $key = $v[1]; $value = daddslashes($_POST[$key]); saveSetting("_mail_{$class}_{$key}", $value); } CACHE::save("mail_{$class}", ''); showmessage('保存成功!', 'admin.php#setting'); } $out = array(); $setting = array(); $query = DB::query("SELECT * FROM setting WHERE k LIKE '_mail_{$class}_%'"); while ($result = DB::fetch($query)) { $key = str_replace("_mail_{$class}_", '', $result['k']); $setting[$key] = $result['v']; } foreach ($_config as $k => $v) { $key = $v[1]; $item = array('key' => $v[1], 'name' => $v[0], 'description' => $v[2], 'value' => isset($setting[$key]) ? $setting[$key] : $v[3], 'type' => $v[4] ? $v[4] : 'text'); $out[] = $item; } echo json_encode($out);
function get_setting($uid) { static $user_setting = array(); if ($user_setting[$uid]) { return $user_setting[$uid]; } $cached_result = CACHE::get('user_setting_' . $uid); if (!$cached_result) { $cached_result = DB::fetch_first("SELECT * FROM member_setting WHERE uid='{$uid}'"); unset($cached_result['cookie']); CACHE::save('user_setting_' . $uid, $cached_result); } return $user_setting[$uid] = $cached_result; }
function handleAction() { global $uid; if (!is_admin($uid)) { exit('Access Denied'); } $data = array(); $data['msgx'] = 0; $setting = json_decode($this->getSetting('setting'), true); switch ($_GET['action']) { case 'getsetting': $query = DB::query("SELECT * FROM `zw_mailauth_list`;"); while ($result = DB::fetch($query)) { $result['regtime'] = date("Y年m月d日 H:m:s", $result['regtime']); $data['list'][] = $result; } $data['count'] = count($data['list']); $data['setting'] = json_decode($this->getSetting('setting'), true); break; case 'savesetting': $mailaddrepeat = $_POST['mailaddrepeat'] == 1 ? 1 : 0; $this->saveSetting('setting', json_encode(array('deathtime' => $_POST['deathtime'], 'title' => $_POST['title'], 'format' => $_POST['format'], 'mailaddrepeat' => $mailaddrepeat, 'abledomain' => $_POST['abledomain'], 'unabledomain' => $_POST['unabledomain'], 'unableaddress' => $_POST['unableaddress']))); $data['msg'] = '保存成功!'; break; case 'clear': $deltime = time() - $setting['deathtime'] * 60; DB::query("DELETE FROM `zw_mailauth_list` WHERE `regtime`<{$deltime}"); $data['msg'] = "清除成功!"; break; case 'alldel': DB::query('TRUNCATE TABLE `zw_mailauth_list`'); $data['msg'] = '已经全部删除!'; break; case 'allpass': $query = DB::query("SELECT * FROM `zw_mailauth_list`;"); while ($result = DB::fetch($query)) { $list[] = $result; } DB::query('TRUNCATE TABLE `zw_mailauth_list`'); for ($i = 0; $i < count($list); $i++) { $uid = DB::insert('member', array('username' => $list[$i]['username'], 'password' => $list[$i]['password'], 'email' => $list[$i]['email'])); DB::insert('member_setting', array('uid' => $uid)); CACHE::update('username'); CACHE::save('user_setting_' . $uid, ''); } $data['msg'] = '已经全部通过!'; break; case 'allresend': $query = DB::query("SELECT * FROM `zw_mailauth_list`"); while ($result = DB::fetch($query)) { $list[] = $result; } for ($i = 0; $i < count($list); $i++) { $content = $this->getMailContent($setting['format'], $list[$i]['username'], $list[$i]['authcode'], $list[$i]['deathtime']); DB::insert('mail_queue', array('to' => $list[$i]['email'], 'subject' => $setting['title'], 'content' => $content)); } DB::query("UPDATE `zw_mailauth_list` SET `regtime`=" . time()); saveSetting('mail_queue', 1); $data['msg'] = '已经全部加入到邮件队列中,稍后将自动发送!'; break; case 'resend': $result = DB::fetch_first("SELECT * FROM `zw_mailauth_list` WHERE `id`=" . intval($_GET['vid'])); $content = $this->getMailContent($setting['format'], $result['username'], $result['authcode'], $setting['deathtime']); DB::query("UPDATE `zw_mailauth_list` SET `regtime`=" . time() . " WHERE `id`=" . intval($_GET['vid'])); DB::insert('mail_queue', array('to' => $result['email'], 'subject' => $setting['title'], 'content' => $content)); saveSetting('mail_queue', 1); $data['msg'] = "新的验证邮件已经加入到队列中,稍后将自动发送!"; break; case 'pass': $result = DB::fetch_first("SELECT * FROM `zw_mailauth_list` WHERE `id`=" . intval($_GET['vid'])); $uid = DB::insert('member', array('username' => $result['username'], 'password' => $result['password'], 'email' => $result['email'])); DB::insert('member_setting', array('uid' => $uid)); CACHE::update('username'); CACHE::save('user_setting_' . $uid, ''); DB::query("DELETE FROM `zw_mailauth_list` WHERE id=" . intval($_GET['vid'])); $data['msg'] = '已经通过帐号的邮箱验证!'; break; case 'del': DB::query("DELETE FROM `zw_mailauth_list` WHERE id=" . intval($_GET['vid'])); $data['msg'] = '成功删除该记录!'; break; default: $data['msg'] = '没有指定 Action!!'; } echo json_encode($data); }
if (!preg_match('/BAIDUID=(.+?)/', $cookie)) { showmessage('Cookie 信息不完整,请尝试重新获取', './#baidu_bind', 1); } if (!verify_cookie($cookie)) { showmessage('无法登陆百度贴吧,请检查 Cookie 是否填写正确', './#baidu_bind', 1); } $cookie = daddslashes($cookie); save_cookie($uid, $cookie); showmessage('您的 Cookie 信息已经更新<script type="text/javascript" src="?action=refresh_liked_tieba&formhash=' . $formhash . '"></script>', './#baidu_bind', 1); break; case 'update_setting': if ($_POST['formhash'] != $formhash) { break; } DB::update('member_setting', array('error_mail' => $_POST['error_mail'] ? 1 : 0, 'send_mail' => $_POST['send_mail'] ? 1 : 0, 'zhidao_sign' => $_POST['zhidao_sign'] ? 1 : 0, 'wenku_sign' => $_POST['wenku_sign'] ? 1 : 0), "uid='{$uid}'"); CACHE::save('user_setting_' . $uid, ''); showmessage('设置已经保存', './#setting', 1); break; case 'change_password': if ($_POST['formhash'] != $formhash) { break; } $user = DB::fetch_first("SELECT * FROM member WHERE uid='{$uid}'"); if (!$_POST['old_password']) { showmessage('请输入旧密码', './#setting', 1); } if (!$_POST['new_password']) { showmessage('请输入新密码', './#setting', 1); } if ($_POST['new_password'] != $_POST['new_password2']) { showmessage('两次输入的新密码不一样,请检查', './#setting', 1);