Repository: kookxiang/Tieba_Sign Branch: reborn Commit: 906f2cf15387 Files: 89 Total size: 275.3 KB Directory structure: gitextract_mw9r9d_v/ ├── README.md ├── admin.php ├── ajax.php ├── api.php ├── config.yaml ├── index.php ├── install/ │ ├── index.php │ ├── install.sql │ ├── openshift.php │ └── sae.php ├── member.php ├── plugin.php ├── plugins/ │ ├── cloud_stat/ │ │ ├── cloud_stat.cron.php │ │ ├── index.inc.php │ │ └── plugin.class.php │ ├── debug_info/ │ │ └── plugin.class.php │ ├── register_limit/ │ │ └── plugin.class.php │ ├── stat/ │ │ └── plugin.class.php │ └── xxx_post/ │ ├── c_daily.cron.php │ ├── c_first.cron.php │ ├── c_se.cron.php │ ├── c_sxbk.cron.php │ ├── core.php │ ├── index.php │ ├── main.js │ └── plugin.class.php ├── robots.txt ├── system/ │ ├── class/ │ │ ├── cache.php │ │ ├── cloud.php │ │ ├── core.php │ │ ├── db.php │ │ ├── hook.php │ │ ├── kerror.php │ │ ├── mail/ │ │ │ ├── phpmail.php │ │ │ ├── saemail.php │ │ │ └── smtp.php │ │ ├── mail.php │ │ ├── multithread.php │ │ ├── plugin.php │ │ ├── updater.php │ │ ├── widget/ │ │ │ └── widget_password.php │ │ └── xmlparse.php │ ├── common.inc.php │ └── function/ │ ├── cache/ │ │ ├── cache_plugin.php │ │ ├── cache_plugins.php │ │ ├── cache_setting.php │ │ └── cache_username.php │ ├── core.php │ ├── member.php │ ├── sae.php │ ├── sign.php │ └── updater/ │ ├── 1.13.php │ ├── 1.14.1.15.php │ ├── 1.14.1.16.php │ ├── 1.14.1.23.php │ ├── 1.14.2.6.php │ ├── 1.14.4.12.php │ ├── 1.14.4.14.php │ ├── 1.14.4.24.php │ ├── 1.14.5.12.php │ ├── 1.14.5.20.php │ ├── 1.14.5.27.php │ ├── 1.14.6.2.php │ ├── 1.16.6.23.php │ └── fallback.php └── template/ └── default/ ├── admin.php ├── index.php ├── js/ │ ├── admin.js │ ├── fwin.js │ ├── kk_dropdown.js │ ├── main.js │ └── member.js ├── member.php ├── message.php ├── mobile/ │ └── message.php ├── style/ │ └── main.css ├── template.xml └── widget/ ├── bind_status.php ├── find_password.php ├── footer.php ├── guide.php ├── header.php ├── liked_tieba.php ├── login.php ├── meta.php ├── register.php ├── setting.php ├── sidebar.php └── sign_log.php ================================================ FILE CONTENTS ================================================ ================================================ FILE: README.md ================================================ # Tieba Sign Front-end environment for TiebaSign-Backend services, which provides faster auto-sign experience in http://tieba.baidu.com and can handle much more user at the same time. This front-end project only provides basic registration / management / log view features. Signing features was not included in this project. ## WARNING You cannot use these code in your own server. It required a closed source server-side application which was powered by Go. 这份代码不能直接部署到服务器上,因为还需要一个 Go 语言的服务端程序才可以正常运行(不开源)。 If you want to deploy a server, please use the [old branch](https://github.com/kookxiang/Tieba_Sign/tree/master). 如果你想搭建贴吧签到助手,请使用 [老版本](https://github.com/kookxiang/Tieba_Sign/tree/master). ================================================ FILE: admin.php ================================================ 新增{$insert}个贴吧, 删除{$deleted}个贴吧", 'admin.php#user', 1); break; case 'reset_failure': $_uid = intval($_GET['uid']); if($formhash != $_GET['formhash']) showmessage('来源不可信,请重试', 'admin.php#stat'); $date = date('Ymd'); DB::query("UPDATE sign_log SET status='0', retry='0' WHERE uid='{$_uid}' AND date='{$date}' AND status<0"); showmessage('已经重置,稍后系统将自动重试', 'admin.php#stat', 1); break; case 'reset_failure_all': if(!defined('AFENABLED')) exit(); if($formhash != $_GET['formhash']) showmessage('来源不可信,请重试', 'admin.php#stat'); $date = date('Ymd'); DB::query("UPDATE sign_log SET status='0', retry='0' WHERE date='{$date}' AND status<0"); showmessage('已经重置,稍后系统将自动重试', 'admin.php#stat', 1); break; case 'mail_setting': if($formhash != $_POST['formhash']) showmessage('来源不可信,请重试', 'admin.php#setting'); $classes = getClasses(); $class = $_POST['mail_sender']; if(!$classes[$class]) showmessage('选择的邮件发送方式不正确.', 'admin.php#setting'); if(!$classes[$class]->isAvailable()) showmessage('选择的邮件发送方式不可用.', 'admin.php#setting'); saveSetting('mail_class', $class); showmessage('保存成功
(请确认高级设置配置有效)', 'admin.php#setting'); break; case 'mail_advanced': $classes = getClasses(); $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); break; case 'switch_channel': if($formhash != $_GET['formhash']) showmessage('来源不可信,请重试', 'admin.php#updater'); $channel = $_GET['channel']; if($channel != 'dev' && $channel != 'stable') showmessage('未知分支ID', 'admin.php#updater'); saveSetting('channel', $channel); showmessage('分支切换成功.', 'admin.php#updater#'); case 'install_plugin': if($formhash != $_GET['formhash']) showmessage('来源不可信,请重试', 'admin.php#plugin'); require_once SYSTEM_ROOT.'./class/plugin.php'; $plugin_id = $_GET['pluginid']; if(preg_match('/[^A-Za-z0-9_-.]/', $plugin_id)) showmessage('插件ID不合法,请与插件作者联系', 'admin.php#plugin'); $classfile = ROOT.'./plugins/'.$plugin_id.'/plugin.class.php'; if(!file_exists($classfile)) showmessage('插件文件缺失,请与插件作者联系', 'admin.php#plugin'); require_once $classfile; $classname = "plugin_{$plugin_id}"; if(!class_exists("plugin_{$plugin_id}", false)) showmessage('插件类不合规范,请与插件作者联系', 'admin.php#plugin'); $obj = new $classname(); $method_blacklist = array('__construct', '__destruct', $classname); foreach($method_blacklist as $method) if(method_exists($obj, $method)) showmessage('插件不符合性能要求规定,请与插件作者联系', 'admin.php#plugin'); if ($obj instanceof Plugin){ $obj->checkCompatibility(); $compatibilityMode = false; }else{ // 弹出旧版插件提示 $compatibilityMode = true; } $version = 0; if(property_exists($obj, 'version')) $version = $obj->version; DB::insert('plugin', array('name' => $plugin_id, 'version' => $version, 'enable' => 0)); CACHE::update('plugins'); if($compatibilityMode){ if(method_exists($obj, 'on_install')) $obj->on_install(); }else{ $obj->install(); } showmessage('安装插件成功!', 'admin.php#plugin#'); case 'uninstall_plugin': if($formhash != $_GET['formhash']) showmessage('来源不可信,请重试', 'admin.php#plugin'); $plugin_id = $_GET['pluginid']; if(preg_match('/[^A-Za-z0-9_-.]/', $plugin_id)) showmessage('插件ID不合法,请与插件作者联系', 'admin.php#plugin'); DB::query("DELETE FROM `plugin` WHERE name='{$plugin_id}'"); DB::query("DELETE FROM plugin_var WHERE pluginid='".addslashes($plugin_id)."'"); $classfile = ROOT.'./plugins/'.$plugin_id.'/plugin.class.php'; if(file_exists($classfile)){ require_once $classfile; $classname = "plugin_{$plugin_id}"; if(class_exists("plugin_{$plugin_id}", false)){ $obj = new $classname(); if ($obj instanceof Plugin){ $compatibilityMode = false; }else{ $compatibilityMode = true; } if(property_exists($obj, 'modules')){ foreach($obj->modules as $module){ if($module['type'] == 'cron'){ DB::query("DELETE FROM cron WHERE id='".$module['cron']['id']."'"); } } } if($compatibilityMode){ if(method_exists($obj, 'on_uninstall')) $obj->on_uninstall(); }else{ $obj->uninstall(); } } } CACHE::update('plugin'); CACHE::update('plugins'); showmessage('卸载插件成功!', 'admin.php#plugin#'); case 'enable_plugin': if($formhash != $_GET['formhash']) showmessage('来源不可信,请重试', 'admin.php#plugin'); $plugin_id = $_GET['pluginid']; if(preg_match('/[^A-Za-z0-9_-.]/', $plugin_id)) showmessage('插件ID不合法,请与插件作者联系', 'admin.php#plugin'); DB::query("UPDATE `plugin` SET `enable`=1 WHERE name='{$plugin_id}'"); $classname = "plugin_{$plugin_id}"; $obj = new $classname(); $method_blacklist = array('__construct', '__destruct', $classname); foreach($method_blacklist as $method) if(method_exists($obj, $method)) showmessage('插件不符合性能要求规定,请与插件作者联系', 'admin.php#plugin'); if (property_exists($obj, 'modules')){ foreach($obj->modules as $module){ if($module['type'] == 'cron'){ DB::insert('cron', array_merge($module['cron'], array('nextrun' => TIMESTAMP)), false, true); } } } CACHE::update('plugins'); showmessage('启用插件成功!', 'admin.php#plugin#'); case 'update_check': $ret = Updater::check(); if(is_array($ret)){ $return = array( 'status' => 1, 'files' => $ret, ); }else{ $return = array( 'status' => $ret, 'files' => array(), ); } echo json_encode($return); exit(); case 'get_file': echo json_encode(Updater::loop()); exit(); case 'write_file': echo json_encode(Updater::write_file()); exit(); case 'disable_plugin': if($formhash != $_GET['formhash']) showmessage('来源不可信,请重试', 'admin.php#plugin'); $plugin_id = $_GET['pluginid']; if(preg_match('/[^A-Za-z0-9_-.]/', $plugin_id)) showmessage('插件ID不合法,请与插件作者联系', 'admin.php#plugin'); DB::query("UPDATE `plugin` SET `enable`=0 WHERE name='{$plugin_id}'"); $classname = "plugin_{$plugin_id}"; $obj = new $classname (); if(property_exists ($obj, 'modules')){ foreach($obj->modules as $module){ if($module ['type'] == 'cron'){ DB::query("DELETE FROM cron WHERE id='".$module['cron']['id']."'"); } } } CACHE::update('plugins'); showmessage('禁用插件成功!', 'admin.php#plugin#'); case 'config_plugin': $plugin_id = $_REQUEST['pluginid']; if($_POST['submit'] && $formhash != $_GET['formhash']) showmessage('来源不可信,请重试', 'admin.php#plugin'); if(preg_match('/[^A-Za-z0-9_-.]/', $plugin_id)) showmessage('插件ID不合法,请与插件作者联系', 'admin.php#plugin'); $classfile = ROOT.'./plugins/'.$plugin_id.'/plugin.class.php'; if(!file_exists($classfile)) showmessage('插件文件缺失,请与插件作者联系', 'admin.php#plugin'); require_once $classfile; $classname = "plugin_{$plugin_id}"; if(!class_exists("plugin_{$plugin_id}", false)) showmessage('插件类不合规范,请与插件作者联系', 'admin.php#plugin'); $obj = new $classname(); if(method_exists($obj, 'on_config')){ echo json_encode(array('html' => $obj->on_config())); }else{ echo json_encode(array('html' => '错误:该插件没有高级配置面板!')); } break; case 'eNaBlEaFc': if($formhash != $_GET['formhash']) showmessage('来源不可信,请重试', 'admin.php#setting'); $text = pack('H*', strrev($_GET['hash'])); if($text == 'ENABLE ADVANCED FETURES') saveSetting('AFENABLED', 1); showmessage('Advance fetures activated!', 'admin.php#setting', 1); break; case 'mail_test': if($formhash != $_GET['formhash']) showmessage('来源不可信,请重试', 'admin.php#setting'); $to = DB::result_first("SELECT email FROM member WHERE uid='{$uid}'"); $subject = '[贴吧签到助手] 邮件单发测试'; $content = "

此封邮件仅用于检测邮件系统是否正常工作。

此封邮件是由邮件系统直接发送的

"; $mail = new mail_content(); $mail->address = $to; $mail->subject = $subject; $mail->message = $content; $sender = new mail_sender(); if($sender->sendMail($mail)){ $subject = '[贴吧签到助手] 邮件群发测试'; $content = "

此封邮件仅用于检测邮件队列是否正常工作。

此封邮件是从系统邮件队列中读取并发送的

"; DB::insert('mail_queue', array( 'to' => $to, 'subject' => $subject, 'content' => $content, )); saveSetting('mail_queue', 1); showmessage('2 封邮件已经发送,请查收', 'admin.php#setting', 2); }else showmessage('邮件发送失败,请检查设置后重试', 'admin.php#setting', 2); break; case 'send_mail': if($formhash != $_POST['formhash']) showmessage('来源不可信,请重试', 'admin.php#setting'); $title = daddslashes($_POST['title']); $content = daddslashes($_POST['content']); $content = nl2br(htmlspecialchars($content)); $content .= "

—— 本邮件由 贴吧签到助手 ({$siteurl}) 管理员发送

"; $query = DB::query("SELECT email FROM member"); while($result = DB::fetch($query)){ DB::insert('mail_queue', array( 'to' => $result['email'], 'subject' => $title, 'content' => $content, )); } saveSetting('mail_queue', 1); showmessage('已经添加至邮件队列,稍后将由系统自动发送', 'admin.php#mail'); break; case 'cloud_sync': $ret = cloud::sync(); showmessage($ret ? '站点信息同步成功!' : '同步信息失败,请稍后再试', 'admin.php#setting'); break; case 'load_plugin': exit(json_encode(getPlugins())); break; case 'load_template': exit(json_encode(getTemplates())); break; case 'load_cron': exit(json_encode(getCron())); break; case 'skip_cron': if(!defined('AFENABLED')) exit(); if($formhash != $_GET['formhash']) showmessage('来源不可信,请重试', 'admin.php#cron'); $cron_id = daddslashes($_GET['cid']); DB::query("UPDATE cron SET nextrun=nextrun+86400 WHERE id='{$cron_id}'"); $time = TIMESTAMP; DB::query("UPDATE cron SET nextrun='{$time}'+3600 WHERE id='{$cron_id}' AND nextrun < '{$time}'"); showmessage('计划任务修改成功', 'admin.php#cron'); break; case 'clear_cron_cache': if(!defined('AFENABLED')) exit(); if($formhash != $_GET['formhash']) showmessage('来源不可信,请重试', 'admin.php#cron'); $nextrun = DB::fetch_first("SELECT nextrun FROM cron ORDER BY nextrun ASC LIMIT 0,1"); saveSetting('next_cron', $nextrun ? $nextrun['nextrun'] : TIMESTAMP + 1200); showmessage('缓存已清除', 'admin.php#cron'); break; case 'clear_cache': if(!defined('AFENABLED')) exit(); if($formhash != $_GET['formhash']) showmessage('来源不可信,请重试', 'admin.php#cron'); CACHE::clear(); showmessage('缓存已清除', 'admin.php#cron'); break; case 'clear_cron': if($formhash != $_GET['formhash']) showmessage('来源不可信,请重试', 'admin.php#cron'); $query = DB::query("SELECT * FROM cron ORDER BY `order`"); $deleted = 0; while($cron = DB::fetch($query)){ list($pluginid, $cronscript) = explode('/', $cron['id'], 2); if($pluginid && $cronscript){ $path = ROOT."./plugins/{$pluginid}/{$cronscript}.cron.php"; }else{ $path = SYSTEM_ROOT."./function/cron/{$cron[id]}.php"; } if(!file_exists($path)){ DB::query("DELETE FROM cron WHERE id='".addslashes($cron['id'])."'"); $deleted++; } } showmessage("共清理了 {$deleted} 个无效的计划任务"); break; case 'set_template': if($formhash != $_GET['formhash']) showmessage('来源不可信,请重试', 'admin.php#plugin'); if(preg_match('/[^A-Za-z0-9_-.]/', $_GET['template'])) showmessage('模板ID(文件夹名)不合法,请与模板作者联系', 'admin.php#template'); $templatefile = ROOT.'./template/'.$_GET['template'].'/template.xml'; if (file_exists($templatefile)) { $info = xml2array(file_get_contents($templatefile)); if(!$info || !$info['target_version'] || !is_array($info['target_version']) || $info['ui_version']!=UI_VERSION) showmessage('此模板不兼容当前版本', 'admin.php#template'); saveSetting('template', daddslashes($_GET['template'])); if(!in_array(VERSION, $info['target_version'])) showmessage('模板切换成功!
注:此风格不适宜当前版本,可能有轻微错位.', 'admin.php#template#'); showmessage('模板切换成功!', 'admin.php#template#'); } else showmessage('非法操作!', 'admin.php#template'); break; default: $classes = getClasses(); if(getSetting('next_cron') < TIMESTAMP - 7200) define('CRON_ERROR', true); include template('admin'); break; } function getClasses(){ $handle = opendir(SYSTEM_ROOT.'./class/mail/'); $classes = array(); while (1){ $file = readdir($handle); if (!$file) break; if (strexists($file, '.php')){ $classname = str_replace('.php', '', $file); require_once SYSTEM_ROOT."./class/mail/{$classname}.php"; $obj = new $classname(); $classes[$obj->id] = $obj; } } return $classes; } function getPlugins(){ $handle = opendir(ROOT.'./plugins/'); $plugins = $new_plugins = $installed = array(); $query = DB::query('SELECT name FROM plugin'); while($row = DB::fetch($query)) $installed[] = $row['name']; while (1){ $folder = readdir($handle); if (!$folder) break; if ($folder == '.' || $folder == '..') continue; $classfile = ROOT.'./plugins/'.$folder.'/plugin.class.php'; if(!file_exists($classfile)) continue; require_once $classfile; $classname = "plugin_{$folder}"; if(!class_exists("plugin_{$folder}", false)) continue; $obj = new $classname(); $arr = array('id' => $folder, 'description' => $obj->description, 'config' => method_exists($obj, 'on_config'), 'enabled' => is_plugin_enabled($folder), 'version' => getPluginVersion($folder), 'installed' => in_array($folder, $installed)); if($arr['installed']){ $plugins[] = $arr; }else{ $new_plugins[] = $arr; } } return array_merge($plugins, $new_plugins); } function getTemplates(){ $handle = opendir(ROOT.'./template/'); $templates = array(); $current_template = getSetting('template'); if(empty($current_template)) $current_template = 'default'; while (true){ $folder = readdir($handle); if (!$folder) break; if ($folder == '.' || $folder == '..') continue; $infofile = ROOT."./template/{$folder}/template.xml"; if(!file_exists($infofile)) continue; $info = xml2array(file_get_contents($infofile)); $templates[] = array( 'id' => $folder, 'name' => !empty($info['name'])? htmlspecialchars($info['name']) : '未知模板', 'author' => !empty($info['author'])? htmlspecialchars($info['author']) : '佚名', 'version' => !empty($info['version'])? htmlspecialchars($info['version']) : '0.0.0', 'site' => !empty($info['site'])? htmlspecialchars($info['site']) : 'http://www.kookxiang.com', 'preview' => (empty($info['preview']) || !file_exists(ROOT."./template/{$folder}/{$info['preview']}")) ? "template/default/nopreview.png" : "template/{$folder}/{$info['preview']}", 'current' => $folder == $current_template, ); } return $templates; } function getCron(){ $query = DB::query("SELECT * FROM cron ORDER BY `order`"); $system_cron = $plugin_cron = array(); while($cron = DB::fetch($query)){ unset($cron['enabled']); $cron['_id'] = $cron['id']; $cron['nextrun'] = $cron['nextrun'] - TIMESTAMP; list($pluginid, $cronscript) = explode('/', $cron['id'], 2); if($pluginid && $cronscript){ $cron['id'] = "{$cronscript}.cron.php"; $cron['type'] = "插件 {$pluginid} 任务"; $plugin_cron[] = $cron; }else{ $cron['id'] = "{$cron[id]}.php"; $cron['type'] = "系统内置任务"; $system_cron[] = $cron; } } return array_merge($system_cron, $plugin_cron); } function is_plugin_enabled($pluginid){ static $enabled_plugin; if(!isset($enabled_plugin)){ $enabled_plugin = array(); $arr = CACHE::get('plugins'); foreach($arr as $plugin){ $enabled_plugin[] = $plugin['id']; } } return in_array($pluginid, $enabled_plugin); } function getPluginVersion($pluginid){ static $plugin_version; if(!isset($plugin_version)){ $plugin_version = array(); $query = DB::query("SELECT name, version FROM `plugin`"); while($result = DB::fetch($query)){ $plugin_version[ $result['name'] ] = $result['version']; } } return $plugin_version[$pluginid] ? $plugin_version[$pluginid] : 0; } ================================================ FILE: ajax.php ================================================ '{$date}' ORDER BY date ASC LIMIT 0,1"); break; } echo json_encode($data); ================================================ FILE: api.php ================================================ ')); save_cookie($uid, $cookie); showmessage('绑定百度账号成功!
正在同步喜欢的贴吧...', './#baidu_bind', 1); } ?> ================================================ FILE: config.yaml ================================================ --- name: appid version: 1 cron: - description: SignTask url: cron.php schedule: */1 * * * * handle: - expire: if( path ~ "css" ) time 864000 - expire: if( path ~ "png" ) time 864000 - compress: if ( out_header["Content-Length"]>=512 ) compress ================================================ FILE: index.php ================================================ 您可以稍后重新进行绑定', './#baidu_bind#', 1); case 'update_cookie': if(!$_POST['cookie']) break; $cookie = daddslashes($_POST['cookie']); if(!preg_match('/BDUSS=(.+?)/', $cookie)) showmessage('Cookie 信息不完整,请尝试重新获取', './#baidu_bind', 1); 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 信息已经更新', './#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); if(!Widget_Password::verify($user, $_POST['old_password'])) showmessage('旧密码错误!请检查输入', './#setting', 1); $newpassword = Widget_Password::encrypt($user, $_POST['new_password']); DB::update('member', array('password' => $newpassword), "uid='{$uid}'"); HOOK::run('change_password', true, $uid); showmessage('您的密码已经更新', './#setting', 1); break; case 'reset_failure': if($formhash != $_GET['formhash']) showmessage('请稍候...', '?action=reset_failure&formhash='.$formhash, 0); $date = date('Ymd'); DB::query("UPDATE sign_log SET status='0', retry='0' WHERE uid='{$uid}' AND date='{$date}' AND status<0"); showmessage('已经重置失败状态,稍后系统将自动重试', './#signlog', 1); break; case 'refresh_liked_tieba': if($formhash != $_GET['formhash']) showmessage('刷新中,请稍候...', '?action=refresh_liked_tieba&formhash='.$formhash, 0); list($insert, $deleted) = update_liked_tieba($uid); showmessage("喜欢的贴吧列表已经更新,
新增{$insert}个贴吧, 删除{$deleted}个贴吧", './#liked_tieba', 1); break; } header('Location: ./'); exit(); } if($_GET['ignore_update']){ dsetcookie('ignore_update', '1', 7200); exit(); }elseif(is_admin($uid) && !$_COOKIE['ignore_update']){ if(getSetting('new_version')) define('NEW_VERSION', true); } if(getSetting('account_switch')){ // Multi User Support $query = DB::query("SELECT * FROM member_bind WHERE uid='{$uid}'"); $users = array(); while($result = DB::fetch($query)){ $users[ $result['_uid'] ] = $result['username']; } } include template('index'); ================================================ FILE: install/index.php ================================================ if(confirm("要使用 OpenShift 一键安装向导吗?")) location.href="openshift.php";'; } $content = '

欢迎使用 贴吧签到助手 安装向导!

本程序将会指引你在服务器上配置好“贴吧签到助手”

点击右侧的“下一步”按钮开始

'; show_install_page('Welcome', $content); break; case 'check': $content = '

安装前,程序需要检查当前的服务器环境是否允许运行“贴吧签到助手”

请确保表格中每一行均为绿色,以避免可能带来的问题

'; $content .= ''; $content .= ''; $content .= ''; $content .= ''; $content .= ''; $content .= '
项目要求当前状态
PHP 版本5.2'.PHP_VERSION.'
PHP: allow_url_fopen'.show_status(true).''.show_status(ini_get('allow_url_fopen')).'
CURL'.show_status(true).''.show_status(function_exists('curl_init')).'
Socket 连接'.show_status(true).''.show_status(function_exists('fsockopen') || function_exists('pfsockopen')).'
system/config.inc.php'.show_status(true, '可写').''.show_status(is_writable($config_file), '可写', '不可写').'
'; if(function_exists('curl_init') && (function_exists('fsockopen') || function_exists('pfsockopen')) && is_writable($config_file)) $content .= '

'; show_install_page('服务器兼容性检查', $content); break; case 'database': $content = '

请填写数据库连接信息


'; $content .= '
'; $content .= '

数据库服务器:

'; $content .= '

数据库端口:

'; $content .= '

数据库用户名:

'; $content .= '

数据库密码:

'; $content .= '

数据库名:

'; if(function_exists('mysql_pconnect')) $content .= '

 

'; $content .= '

管理员用户名:

'; $content .= '

管理员密码:

'; $content .= '

管理员邮箱:

'; $content .= '

 

'; $content .= '
'; $content .= ''; show_install_page('数据库配置', $content); break; case 'install': $db_host = $_POST['db_server']; $db_port = intval($_POST['db_port']); $db_username = $_POST['db_username']; $db_password = $_POST['db_password']; $db_name = $_POST['db_name']; $db_pconnect = isset($_POST['pconnect']); $function = $db_pconnect ? 'mysql_connect' : 'mysql_pconnect'; $link = mysql_connect("{$db_host}:{$db_port}", $db_username, $db_password); if(!$link) show_back('数据库配置', '错误:无法连接数据库服务器!

'.mysql_error()); $selected = mysql_select_db($db_name, $link); if(!$selected){ // 尝试新建 mysql_query("CREATE DATABASE `{$db_name}`", $link); $selected = mysql_select_db($db_name, $link); if(!$selected) show_back('数据库配置', '错误:指定的数据库不可用

'.mysql_error()); } mysql_query("SET character_set_connection=utf8, character_set_results=utf8, character_set_client=binary"); $syskey = random(32); $username = addslashes($_POST['username']); $password = md5($syskey.md5($_POST['password']).$syskey); $email = addslashes($_POST['email']); if(!$username || !$password || !$email) show_back('注册账号', '您输入的信息不完整'); if(preg_match('/[<>\'\\"]/i', $username)) show_back('注册账号', '用户名中有被禁止使用的关键字'); if(strlen($username) < 6) show_back('注册账号', '用户名至少要6个字符(即2个中文 或 6个英文),请修改'); if(strlen($username) > 24) show_back('注册账号', '用户名过长,请修改'); $install_script = file_get_contents(dirname(__FILE__).'/install.sql'); preg_match('/version ([0-9a-z.]+)/i', $install_script, $match); $version = trim($match[1]); if(!$version) show_back('正在安装', '安装脚本有误,请重新上传'); $err = runquery($install_script, $link); if($err) show_back('正在安装', '安装过程出现错误:

'.$err); mysql_query("INSERT INTO member SET username='{$username}', password='{$password}', email='{$email}'"); $uid = mysql_insert_id($link); mysql_query("INSERT INTO member_setting SET uid='{$uid}', cookie=''"); saveSetting('block_register', 1); saveSetting('jquery_mode', 2); saveSetting('admin_uid', $uid); saveSetting('SYS_KEY', $syskey); $_config = array( 'version' => $version, 'db' => array( 'server' => $db_host, 'port' => $db_port, 'username' => $db_username, 'password' => $db_password, 'name' => $db_name, 'pconnect' => $db_pconnect, ), ); $content = ''; file_put_contents($config_file, $content); $content = '

贴吧签到助手 已经成功安装!

要正常签到,请为脚本 cron.php 添加每分钟一次的计划任务。

系统默认关闭用户注册,如果有需要,请到后台启用用户注册功能。


'; show_install_page('安装成功', $content); } function show_back($title, $text){ $content = '

'.$text.'

'; $content .= '

'; show_install_page($title, $content); } function show_install_page($title, $content){ global $extra_script; $template = '贴吧签到助手
载入中...

贴吧签到助手 - 安装向导

{title}

{content}
'.$extra_script.''; echo str_replace(array('{title}', '{content}'), array($title, $content), $template); exit(); } function show_status($status, $on_txt = 'On', $off_txt = 'Off'){ return $status ? ''.$on_txt.'' : ''.$off_txt.''; } function runquery($sql, $link){ $sql = str_replace("\r", "\n", $sql); foreach(explode(";\n", $sql) as $query) { $query = trim($query); if(!$query) continue; $ret = mysql_query($query, $link); if(!$ret) return mysql_error(); } } function saveSetting($k, $v){ global $link; $v = addslashes($v); mysql_query("REPLACE INTO setting SET v='{$v}', k='{$k}'", $link); } function random($length, $numeric = 0) { $seed = base_convert(md5(microtime().$_SERVER['DOCUMENT_ROOT']), 16, $numeric ? 10 : 35); $seed = $numeric ? (str_replace('0', '', $seed).'012340567890') : ($seed.'zZ'.strtoupper($seed)); $hash = ''; $max = strlen($seed) - 1; for($i = 0; $i < $length; $i++) { $hash .= $seed{mt_rand(0, $max)}; } return $hash; } ?> ================================================ FILE: install/install.sql ================================================ /* Install script for version 1.14.4.14 */ DROP TABLE IF EXISTS `cache`; DROP TABLE IF EXISTS `cron`; DROP TABLE IF EXISTS `download`; DROP TABLE IF EXISTS `mail_queue`; DROP TABLE IF EXISTS `member`; DROP TABLE IF EXISTS `member_bind`; DROP TABLE IF EXISTS `member_setting`; DROP TABLE IF EXISTS `my_tieba`; DROP TABLE IF EXISTS `plugin`; DROP TABLE IF EXISTS `plugin_var`; DROP TABLE IF EXISTS `setting`; DROP TABLE IF EXISTS `sign_log`; DROP TABLE IF EXISTS `update_source`; CREATE TABLE IF NOT EXISTS `cache` ( `k` varchar(32) NOT NULL, `v` text NOT NULL, PRIMARY KEY (`k`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; CREATE TABLE IF NOT EXISTS `cron` ( `id` varchar(16) NOT NULL, `enabled` tinyint(1) NOT NULL, `nextrun` int(10) unsigned NOT NULL, `order` tinyint(4) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; INSERT INTO `cron` (`id`, `enabled`, `nextrun`, `order`) VALUES ('daily', 1, 0, 0), ('ext_sign', 1, 0, 50), ('mail', 1, 0, 100), ('sign', 1, 0, 20), ('sign_retry', 1, 0, 110), ('update_tieba', 1, 0, 10); CREATE TABLE IF NOT EXISTS `download` ( `path` varchar(128) NOT NULL, `content` text NOT NULL, PRIMARY KEY (`path`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; CREATE TABLE IF NOT EXISTS `mail_queue` ( `id` int(11) NOT NULL AUTO_INCREMENT, `to` varchar(255) NOT NULL, `subject` varchar(255) NOT NULL, `content` text NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; CREATE TABLE IF NOT EXISTS `member` ( `uid` int(11) unsigned NOT NULL AUTO_INCREMENT, `username` varchar(24) DEFAULT NULL, `password` varchar(32) NOT NULL, `email` varchar(32) NOT NULL, PRIMARY KEY (`uid`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; CREATE TABLE IF NOT EXISTS `member_bind` ( `uid` int(10) unsigned NOT NULL, `_uid` int(10) unsigned NOT NULL, `username` varchar(12) NOT NULL, KEY `uid` (`uid`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; CREATE TABLE IF NOT EXISTS `member_setting` ( `uid` int(10) unsigned NOT NULL, `error_mail` tinyint(1) NOT NULL DEFAULT '1', `send_mail` tinyint(1) NOT NULL DEFAULT '0', `zhidao_sign` tinyint(1) NOT NULL DEFAULT '0', `wenku_sign` tinyint(1) NOT NULL DEFAULT '0', `cookie` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, PRIMARY KEY (`uid`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; CREATE TABLE IF NOT EXISTS `my_tieba` ( `tid` int(10) unsigned NOT NULL AUTO_INCREMENT, `uid` int(10) unsigned NOT NULL, `fid` int(10) unsigned NOT NULL, `name` varchar(127) NOT NULL, `unicode_name` varchar(512) NOT NULL, `skiped` tinyint(1) NOT NULL DEFAULT '0', PRIMARY KEY (`tid`), KEY `uid` (`uid`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; CREATE TABLE IF NOT EXISTS `plugin` ( `id` int(11) NOT NULL AUTO_INCREMENT, `enable` tinyint(1) NOT NULL DEFAULT '1', `name` varchar(64) NOT NULL, `version` varchar(8) NOT NULL DEFAULT '0', PRIMARY KEY (`id`), UNIQUE KEY `name` (`name`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; INSERT INTO `plugin` (`id`, `enable`, `name`, `version`) VALUES (1, 1, 'debug_info', ''); CREATE TABLE IF NOT EXISTS `plugin_var` ( `pluginid` varchar(64) NOT NULL, `key` varchar(32) NOT NULL DEFAULT '', `value` text NOT NULL, PRIMARY KEY (`pluginid`,`key`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; CREATE TABLE IF NOT EXISTS `setting` ( `k` varchar(32) NOT NULL, `v` varchar(256) NOT NULL, PRIMARY KEY (`k`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; CREATE TABLE IF NOT EXISTS `sign_log` ( `tid` int(10) unsigned NOT NULL, `uid` int(10) unsigned NOT NULL, `date` int(11) NOT NULL DEFAULT '0', `status` tinyint(4) NOT NULL DEFAULT '0', `exp` tinyint(4) NOT NULL DEFAULT '0', `retry` tinyint(3) unsigned NOT NULL DEFAULT '0', UNIQUE KEY `tid` (`tid`,`date`), KEY `uid` (`uid`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; CREATE TABLE IF NOT EXISTS `update_source` ( `id` varchar(16) NOT NULL, `path` varchar(128) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; ================================================ FILE: install/openshift.php ================================================ 欢迎使用 贴吧签到助手 安装向导!

本程序将会指引你在服务器上配置好“贴吧签到助手”

点击右侧的“下一步”按钮开始


Openshift one-key installer. Thanks to 郁闷de说

'; show_install_page('Welcome', $content); break; case 'database': $content = '

请设置站点管理员信息


'; $content .= '
'; $content .= '

管理员用户名:

'; $content .= '

管理员密码:

'; $content .= '

管理员邮箱:

'; $content .= '

 

'; $content .= '
'; $content .= ''; show_install_page('站点配置', $content); break; case 'install': $db_host = getenv('OPENSHIFT_MYSQL_DB_HOST'); $db_port = intval(getenv('OPENSHIFT_MYSQL_DB_PORT')); $db_username = getenv('OPENSHIFT_MYSQL_DB_USERNAME'); $db_password = getenv('OPENSHIFT_MYSQL_DB_PASSWORD'); $db_name = getenv('OPENSHIFT_APP_NAME'); $db_pconnect = false; $function = $db_pconnect ? 'mysql_connect' : 'mysql_pconnect'; $link = mysql_connect("{$db_host}:{$db_port}", $db_username, $db_password); if(!$link) show_back('数据库配置', '错误:无法连接数据库服务器!

'.mysql_error()); $selected = mysql_select_db($db_name, $link); if(!$selected){ // 尝试新建 mysql_query("CREATE DATABASE `{$db_name}`", $link); $selected = mysql_select_db($db_name, $link); if(!$selected) show_back('数据库配置', '错误:指定的数据库不可用

'.mysql_error()); } mysql_query("SET character_set_connection=utf8, character_set_results=utf8, character_set_client=binary"); $syskey = random(32); $username = addslashes($_POST['username']); $password = md5($syskey.md5($_POST['password']).$syskey); $email = addslashes($_POST['email']); if(!$username || !$password || !$email) show_back('注册账号', '您输入的信息不完整'); if(preg_match('/[<>\'\\"]/i', $username)) show_back('注册账号', '用户名中有被禁止使用的关键字'); if(strlen($username) < 6) show_back('注册账号', '用户名至少要6个字符(即2个中文 或 6个英文),请修改'); if(strlen($username) > 24) show_back('注册账号', '用户名过长,请修改'); $install_script = file_get_contents(dirname(__FILE__).'/install.sql'); preg_match('/version ([0-9a-z.]+)/i', $install_script, $match); $version = trim($match[1]); if(!$version) show_back('正在安装', '安装脚本有误,请重新上传'); $err = runquery($install_script, $link); mysql_query("INSERT INTO member SET username='{$username}', password='{$password}', email='{$email}'"); $uid = mysql_insert_id($link); mysql_query("INSERT INTO member_setting SET uid='{$uid}', cookie=''"); saveSetting('block_register', 1); saveSetting('jquery_mode', 2); saveSetting('admin_uid', $uid); saveSetting('SYS_KEY', $syskey); if($err) show_back('正在安装', '安装过程出现错误:

'.mysql_error()); $_config = array( 'version' => $version, 'db' => array( 'server' => $db_host, 'port' => $db_port, 'username' => $db_username, 'password' => $db_password, 'name' => $db_name, 'pconnect' => $db_pconnect, ), ); $content = ''; file_put_contents($config_file, $content); $content = '

贴吧签到助手 已经成功安装!

系统默认关闭用户注册,如果有需要,请到后台启用用户注册功能。

Openshift 用户如出现错误请前往管理界面重启应用


'; show_install_page('安装成功', $content); } function show_back($title, $text){ $content = '

'.$text.'

'; $content .= '

'; show_install_page($title, $content); } function show_install_page($title, $content){ $template = '贴吧签到助手
载入中...

贴吧签到助手 - 安装向导

{title}

{content}
'; echo str_replace(array('{title}', '{content}'), array($title, $content), $template); exit(); } function show_status($status, $on_txt = 'On', $off_txt = 'Off'){ return $status ? ''.$on_txt.'' : ''.$off_txt.''; } function runquery($sql, $link){ $sql = str_replace("\r", "\n", $sql); foreach(explode(";\n", trim($sql)) as $query) { $query = trim($query); if(!$query) continue; $ret = mysql_query($query, $link); if(!$ret) return mysql_error(); } } function saveSetting($k, $v){ global $link; $v = addslashes($v); mysql_query("REPLACE INTO setting SET v='{$v}', k='{$k}'", $link); } function random($length, $numeric = 0) { $seed = base_convert(md5(microtime().$_SERVER['DOCUMENT_ROOT']), 16, $numeric ? 10 : 35); $seed = $numeric ? (str_replace('0', '', $seed).'012340567890') : ($seed.'zZ'.strtoupper($seed)); $hash = ''; $max = strlen($seed) - 1; for($i = 0; $i < $length; $i++) { $hash .= $seed{mt_rand(0, $max)}; } return $hash; } ?> ================================================ FILE: install/sae.php ================================================ array( 'server' => SAE_MYSQL_HOST_M, 'port' => SAE_MYSQL_PORT, 'username' => SAE_MYSQL_USER, 'password' => SAE_MYSQL_PASS, 'name' => SAE_MYSQL_DB, 'pconnect' => false, ), ); require_once '../system/class/error.php'; set_exception_handler(array('error', 'exception_error')); require_once '../system/class/db.php'; $query = DB::query("SELECT v FROM setting LIMIT 0,1", 'SILENT'); if($query){ header('Location: ..'); exit(); } switch($_GET['step']){ default: $content = '

欢迎使用 贴吧签到助手 安装向导!

本程序将会指引你在服务器上配置好“贴吧签到助手”

点击右侧的“下一步”按钮开始

'; show_install_page('Welcome', $content); break; case 'database': $content = '

请填写基本信息


'; $content .= '
'; $content .= '

管理员用户名:

'; $content .= '

管理员密码:

'; $content .= '

管理员邮箱:

'; $content .= '

 

'; $content .= '
'; $content .= ''; show_install_page('系统配置', $content); break; case 'install': $syskey = random(32); $username = addslashes($_POST['username']); $password = md5($syskey.md5($_POST['password']).$syskey); $email = addslashes($_POST['email']); if(!$username || !$password || !$email) show_back('注册账号', '您输入的信息不完整'); if(preg_match('/[<>\'\\"]/i', $username)) show_back('注册账号', '用户名中有被禁止使用的关键字'); if(strlen($username) < 6) show_back('注册账号', '用户名至少要6个字符(即2个中文 或 6个英文),请修改'); if(strlen($username) > 24) show_back('注册账号', '用户名过长,请修改'); $install_script = file_get_contents(dirname(__FILE__).'/install.sql'); preg_match('/version ([0-9a-z.]+)/i', $install_script, $match); $version = trim($match[1]); if(!$version) show_back('正在安装', '安装脚本有误,请重新上传'); $err = runquery($install_script); DB::query("INSERT INTO member SET username='{$username}', password='{$password}', email='{$email}'"); $uid = DB::insert_id(); DB::query("INSERT INTO member_setting SET uid='{$uid}', cookie=''"); saveSetting('block_register', 1); saveSetting('jquery_mode', 2); saveSetting('admin_uid', $uid); saveSetting('SYS_KEY', $syskey); saveSetting('version', $version); $_config = array( 'db' => array( 'server' => $db_host, 'port' => $db_port, 'username' => $db_username, 'password' => $db_password, 'name' => $db_name, 'pconnect' => $db_pconnect, ), ); $content = ''; file_put_contents($config_file, $content); $content = '

贴吧签到助手 已经成功安装!

系统默认关闭用户注册,如果有需要,请到后台启用用户注册功能。


'; show_install_page('安装成功', $content); } function show_back($title, $text){ $content = '

'.$text.'

'; $content .= '

'; show_install_page($title, $content); } function show_install_page($title, $content){ $template = '贴吧签到助手
载入中...

贴吧签到助手 - 安装向导

{title}

{content}
'; echo str_replace(array('{title}', '{content}'), array($title, $content), $template); exit(); } function show_status($status, $on_txt = 'On', $off_txt = 'Off'){ return $status ? ''.$on_txt.'' : ''.$off_txt.''; } function runquery($sql, $link){ $sql = str_replace("\r", "\n", $sql); foreach(explode(";\n", trim($sql)) as $query) { $query = trim($query); if(!$query) continue; DB::query($query, $link); } } function saveSetting($k, $v){ global $link; $v = addslashes($v); DB::query("REPLACE INTO setting SET v='{$v}', k='{$k}'", $link); } function random($length, $numeric = 0) { $seed = base_convert(md5(microtime().$_SERVER['DOCUMENT_ROOT']), 16, $numeric ? 10 : 35); $seed = $numeric ? (str_replace('0', '', $seed).'012340567890') : ($seed.'zZ'.strtoupper($seed)); $hash = ''; $max = strlen($seed) - 1; for($i = 0; $i < $length; $i++) { $hash .= $seed{mt_rand(0, $max)}; } return $hash; } ?> ================================================ FILE: member.php ================================================ 24) showmessage('用户名过长,请修改', dreferer(), 5); $user = DB::fetch_first("SELECT * FROM member WHERE username='{$_username}'"); $userid = $user['uid']; $verified = Widget_Password::verify($user, $_POST['password']); if($verified){ $exists = DB::result_first("SELECT _uid FROM member_bind WHERE uid='{$uid}' AND _uid='{$userid}'"); if($exists) showmessage('您此前已经绑定过此帐号', './#'); DB::insert('member_bind', array( 'uid' => $uid, '_uid' => $userid, 'username' => $user['username'], )); $exists = DB::result_first("SELECT uid FROM member_bind WHERE _uid='{$uid}' AND uid='{$userid}'"); if(!$exists){ $username = DB::result_first("SELECT username FROM member WHERE uid='{$uid}'"); DB::insert('member_bind', array( 'uid' => $userid, '_uid' => $uid, 'username' => $username, )); } showmessage("您已经成功绑定用户“{$user[username]}”", './'); }else{ showmessage('用户名/密码不正确!', './#'); } }elseif($uid && $_GET['action'] == 'switch'){ if($_GET['formhash'] != $formhash) showmessage('来源不可信,请重试', './'); $target_uid = intval($_GET['uid']); $uid = DB::result_first("SELECT _uid FROM member_bind WHERE uid='{$uid}' AND _uid='{$target_uid}'"); if(!$uid) showmessage('您尚未绑定该账号,无法进行切换', './'); $username = get_username($uid); do_login($uid); showmessage("您已经成功切换至 {$username}!", dreferer(), 1); }elseif($uid){ showmessage('您已经登录了~', dreferer(), 1); }elseif($_GET['action'] == 'find_password'){ if($_GET['token']){ $str = authcode($_GET['token'], 'DECODE'); if(!$str) showmessage('链接有误,请重新获取', './'); list($uid, $exptime, $password, $random) = explode("\t", $str); if($exptime < TIMESTAMP) showmessage('链接已过期,请重新获取', './'); $user = DB::fetch_first("SELECT * FROM member WHERE uid='{$uid}' AND password='{$password}'"); if(!$user) showmessage('链接已经失效,请重新获取', './'); $new_password = random(10); $newpassword = Widget_Password::encrypt($user, $new_password); DB::update('member', array('password' => $newpassword), "uid='{$uid}'"); showmessage("您的密码已经重置为:
{$new_password}

请使用新密码登录并修改密码。"); }elseif($_POST['username'] && $_POST['email']){ $username = daddslashes($_POST['username']); $email = daddslashes($_POST['email']); $user = DB::fetch_first("SELECT * FROM member WHERE username='{$username}' AND email='{$email}'"); if(!$user) showmessage('用户名 / 邮箱有误', './'); $info = array( $user['uid'], // UID TIMESTAMP + 3600, // Token 过期时间 $user['password'], // 当前密码 random(32), // 随机字符 ); $token = urlencode(authcode(implode("\t", $info), 'ENCODE')); $link = "{$siteurl}member.php?action=find_password&token={$token}"; $message = <<我们已经收到您的找回密码申请,请您点击下方的链接重新设置密码:

{$link}

(注:请在一小时内点击上面的链接,我们将向您提供新的密码)


如果您没有要求重置密码却收到本邮件,请及时删除此邮件以确保账户安全。

EOF; DB::insert('mail_queue', array( 'to' => $user['email'], 'subject' => "贴吧签到助手 - 密码找回", 'content' => $message, )); saveSetting('mail_queue', 1); showmessage('邮件发送成功,请到邮箱查收', './'); } header('Location: member.php'); exit(); }elseif($_GET['action'] == 'register'){ if(getSetting('block_register')) showmessage('抱歉,当前站点禁止新用户注册', 'member.php'); $count = DB::result_first('SELECT COUNT(*) FROM member'); if($_POST && strexists($_SERVER['HTTP_REFERER'], 'member.php')){ list($time, $hash, $member_count) = explode("\t", authcode($_COOKIE['key'], 'DECODE')); if(getSetting('register_check') && $time > TIMESTAMP - 5 || $time < TIMESTAMP - 300) $_POST = array(); if(getSetting('register_limit') && $member_count != $count) showmessage('当前注册人数过多,请您稍后再试', 'member.php'); if($count > 1000) showmessage('超过当前站点最大用户数量上限,无法注册', 'member.php'); $_POST['username'] = $_POST['password'] = $_POST['email'] = null; foreach($_POST as $key => $value){ $key = authcode($key, 'DECODE', $hash); if($key == 'username'){ $_POST['username'] = $value; }elseif($key == 'password'){ $_POST['password'] = $value; }elseif($key == 'email'){ $_POST['email'] = $value; } } if(!$_POST['username']){ showmessage('请输入用户名', 'member.php'); }elseif(!$_POST['password']){ showmessage('请输入密码', 'member.php'); }elseif(!$_POST['email']){ showmessage('请输入您的邮箱', 'member.php'); }else{ if($invite_code && $_POST['invite_code'] != $invite_code) showmessage('邀请码有误', 'member.php'); $username = daddslashes($_POST['username']); $email = daddslashes($_POST['email']); if(!is_email($email)) showmessage('邮箱格式不正确,请修改', dreferer(), 5); if(!$username || !$_POST['password'] || !$email) showmessage('您输入的信息不完整', 'member.php'); if(preg_match('/[<>\'\\"]/i', $username)) showmessage('用户名中有被禁止使用的关键字', 'member.php'); if(strlen($username) < 6) showmessage('用户名至少要6个字符(即2个中文 或 6个英文),请修改', dreferer(), 5); if(strlen($username) > 24) showmessage('用户名过长,请修改', dreferer(), 5); $un = strtolower($username); if(strexists($un, 'admin') || strexists($un, 'guanli')) showmessage('用户名不和谐,请修改', dreferer(), 5); $user = DB::fetch_first("SELECT * FROM member WHERE username='{$username}'"); if($user) showmessage('用户名已经存在', 'member.php'); HOOK::run('before_register'); $uid = do_register($username, $_POST['password'], $email); do_login($uid); HOOK::run('register_finish', false, $uid); showmessage("注册成功,您的用户名是 {$username} 记住了哦~!", dreferer(), 3); } } header('Location: member.php'); exit(); }elseif($_POST){ if($_POST['username'] && $_POST['password']){ $username = daddslashes($_POST['username']); $un = strtolower($username); if(strlen($username) > 24) showmessage('用户名过长,请修改', dreferer(), 5); $user = DB::fetch_first("SELECT * FROM member WHERE username='{$username}'"); $verified = Widget_Password::verify($user, $_POST['password']); if($verified) { $login_exp = TIMESTAMP + 3600; do_login($user['uid']); $username = $user['username']; showmessage("欢迎回来,{$username}!", dreferer(), 1); }else{ showmessage('对不起,您的用户名或密码错误,无法登录.', 'member.php', 3); } } } $count = DB::result_first('SELECT COUNT(*) FROM member'); $hash = random(6); $time = TIMESTAMP; dsetcookie('key', authcode("{$time}\t{$hash}\t{$count}", 'ENCODE')); $form_username = authcode('username', 'ENCODE', $hash); $form_password = authcode('password', 'ENCODE', $hash); $form_email = authcode('email', 'ENCODE', $hash); include template('member'); ================================================ FILE: plugin.php ================================================ handleAction(); } else { throw new Exception('This plugin doesn\'t support to be called directly.'); } ================================================ FILE: plugins/cloud_stat/cloud_stat.cron.php ================================================ getSetting('tieba')); $exp = intval($obj->getSetting('exp')); $tieba += DB::result_first("SELECT COUNT(*) FROM sign_log WHERE status=2 AND date='{$date}'"); $obj->saveSetting('tieba', $tieba); $exp += DB::result_first("SELECT SUM(exp) FROM sign_log WHERE status=2 AND date='{$date}'"); $obj->saveSetting('exp', $exp); /* send data */ $sid = cloud::id(); $key = cloud::key(); $sign = md5($key.$sid.$tieba.$exp.$key); $ret = kk_fetch_url("http://api.ikk.me/stat.php?sid={$sid}&tieba={$tieba}&exp={$exp}&sign={$sign}"); if($ret) { $data = json_decode($ret); if($data){ $obj->saveSetting('cloud_tieba', $data->tieba); $obj->saveSetting('cloud_exp', $data->exp); } } cron_set_nextrun($tomorrow + 3600); ================================================ FILE: plugins/cloud_stat/index.inc.php ================================================

签到云统计 *

* 数据源自 贴吧签到助手 开放平台 旗下所有签到站点.

================================================ FILE: plugins/cloud_stat/plugin.class.php ================================================ 'page', 'id' => 'index', 'title' => '签到云统计', 'file' => 'index.inc.php'), array('type' => 'cron', 'cron' => array('id' => 'cloud_stat/cloud_stat', 'order' => '105')), ); var $version = '1.1'; function checkCompatibility(){ if(version_compare(VERSION, '1.14.4.24', '<')) showmessage('本插件不兼容此版的贴吧签到助手.'); } function install(){ $count = DB::result_first('SELECT COUNT(*) FROM sign_log WHERE status=2'); $this->saveSetting('tieba', $count); $count = DB::result_first('SELECT SUM(exp) FROM sign_log WHERE status=2'); $this->saveSetting('exp', $count); $ret = kk_fetch_url("http://api.ikk.me/stat.php"); if(!$ret) return; $data = json_decode($ret); if(!$data) return; $this->saveSetting('cloud_tieba', $data->tieba); $this->saveSetting('cloud_exp', $data->exp); } function mklink($sourceFile, $targetFile){ return @file_put_contents($targetFile, ''); } function on_upgrade($from_version){ switch($from_version){ case '1.0': DB::query("UPDATE cron SET id='cloud_stat/cloud_stat' WHERE id='cloud_stat'"); return '1.1'; default: throw new Exception("Unknown plugin version: {$from_version}"); } } function handleAction(){ echo json_encode(array( 'ctieba' => intval($this->getSetting('cloud_tieba')), 'cexp' => intval($this->getSetting('cloud_exp')), 'tieba' => intval($this->getSetting('tieba')), 'exp' => intval($this->getSetting('exp')), )); } } ================================================ FILE: plugins/debug_info/plugin.class.php ================================================ 0) DB::query("UPDATE kk_ip_limit SET lastact='{$time}' WHERE a='{$a}' AND b='{$b}' AND c='{$c}' AND d='{$d}'"); if($count >= $this->getSetting('ip_reglimit', 5)) showmessage('达到单 IP 注册上限,禁止注册。', dreferer()); if($count > 0){ DB::query("UPDATE kk_ip_limit SET count=count+1 WHERE a='{$a}' AND b='{$b}' AND c='{$c}' AND d='{$d}'"); }else{ DB::query("INSERT INTO kk_ip_limit SET count=1, lastact='{$time}', a='{$a}', b='{$b}', c='{$c}', d='{$d}'"); } } function on_config(){ if($_POST['limit']){ $this->saveSetting('ip_reglimit', $_POST['limit']); showmessage('设置已经保存!'); }else{ return '

单个 IP 注册上限:

'; } } } ================================================ FILE: plugins/stat/plugin.class.php ================================================ getSetting('code'); if($data) return ''; } function on_config(){ if($_POST['code']){ $this->saveSetting('code', $_POST['code']); showmessage('设置已经保存!'); }else{ return '

页脚统计代码:

'; } } } ================================================ FILE: plugins/xxx_post/c_daily.cron.php ================================================ getSetting('se'); if(!$setime) $setime=21; $nxrun =$today+$setime*3600; DB::query("update cron set nextrun='$nxrun' where id='xxx_post/c_se'"); cron_set_nextrun($tomorrow + 600); ================================================ FILE: plugins/xxx_post/c_first.cron.php ================================================ getSetting('first_end'); if(!$first_end) $first_end=15; $first_end_time=$today+$first_end*3600; if($first_end_time time()){ $count = DB::result_first("select COUNT(*) from xxx_post_log as a left join xxx_post_setting as b on a.uid=b.uid where a.date='$date' and a.status time()){ $count = DB::result_first("select COUNT(*) from xxx_post_log as a left join xxx_post_setting as b on a.uid=b.uid where a.date='$date' and a.statusgetSetting('sxbk')!=1) {cron_set_nextrun($tomorrow + 5400);$count=0;} $endtime = TIMESTAMP + 45; if($count){ require_once ROOT.'./plugins/xxx_post/core.php'; while($endtime > time()){ $count = DB::result_first("select COUNT(*) from xxx_post_log as a left join xxx_post_setting as b on a.uid=b.uid where a.date='$date' and a.retry<40 and b.runtime<".TIMESTAMP." and b.frequency=4"); if($count==0) break; $offset = rand(1, $count) - 1; $sid = DB::result_first("select sid from xxx_post_log as a left join xxx_post_setting as b on a.uid=b.uid where a.date='$date' and a.retry<40 and b.runtime<".TIMESTAMP." and b.frequency=4 LIMIT $offset,1"); if(!$sid) break; $tiezi=DB::fetch_first("SELECT * FROM xxx_post_posts WHERE sid='$sid'"); if(!$tiezi){ DB::query("UPDATE xxx_post_log SET retry=retry+1 WHERE sid='$sid' AND date='$date'"); continue; } $x_content_count = DB::result_first("SELECT COUNT(*) FROM xxx_post_content WHERE uid='{$tiezi[uid]}'"); $x_content_offset = rand(1, $x_content_count) - 1; $x_content = DB::result_first("SELECT content FROM xxx_post_content WHERE uid='{$tiezi[uid]}' limit $x_content_offset,1"); list($statue,$result) = client_rppost($tiezi['uid'],$tiezi,$x_content); if($statue == 2){ $x_delay=DB::result_first("select delay from xxx_post_setting where uid={$tiezi[uid]}"); if($x_delay){ $runtime=TIMESTAMP+$x_delay*56; DB::query("UPDATE xxx_post_setting SET runtime=$runtime WHERE uid='{$tiezi[uid]}'"); } DB::query("UPDATE xxx_post_log SET status=status+1 WHERE sid='$sid' AND date='$date'"); }else if($statue==1||$statue==8) DB::query("UPDATE xxx_post_log SET retry=60 WHERE sid='$sid' AND date='$date'"); else if($statue==5||$statue==7) continue; else DB::query("UPDATE xxx_post_log SET retry=retry+1 WHERE sid='$sid' AND date='$date'"); if(!defined('SIGN_LOOP')) break; sleep(1); } }else{ cron_set_nextrun($tomorrow + 5400); } ================================================ FILE: plugins/xxx_post/core.php ================================================ [A-z0-9 -_]+?)}\'/', $contents, $jsontids); foreach ($jsontids['json'] as $jsontid){ $jsontid=str_replace('"','"', '{'.$jsontid.'}'); if($tids[]=json_decode($jsontid)->is_top == 0) $tids[]=json_decode($jsontid)->id; } $tid=$tids[rand(0,count($tids)-1)]; return $tid; } function client_rppost($uid, $tieba, $content) { $cookie = get_cookie ( $uid ); preg_match ( '/BDUSS=([^ ;]+);/i', $cookie, $matches ); $BDUSS = trim ( $matches [1] ); $setting = DB::fetch_first ( "SELECT * FROM xxx_post_setting WHERE uid='{$uid}'" ); if ($setting ['client_type'] == 5) $setting ['client_type'] = rand ( 1, 4 ); if (! $BDUSS) return array (- 1,'找不到 BDUSS Cookie' ); if (! $content) $content=get_random_content(); if (! $tieba['tid']) $tieba['tid']=get_random_tid($tieba ['name']); $formdata = array ( 'BDUSS' => $BDUSS, '_client_id' => 'wappc_136' . random ( 10, true ) . '_' . random ( 3, true ), '_client_type' => $setting ['client_type'], '_client_version' => '5.0.0', '_phone_imei' => md5 ( random ( 16 ) ), 'anonymous' => 0, 'content' => $content, 'fid' => $tieba ['fid'], 'kw' => urldecode ( $tieba ['name'] ), 'net_type' => 3, 'tbs' => get_tbs ( $tieba ['uid'] ), 'tid' => $tieba ['tid'], 'title' => "" ); $adddata = ''; foreach ( $formdata as $k => $v ) $adddata .= $k . '=' . $v; $sign = strtoupper ( md5 ( $adddata . 'tiebaclient!!!' ) ); $formdata ['sign'] = $sign; $ch = curl_init ( 'http://c.tieba.baidu.com/c/c/post/add' ); curl_setopt ( $ch, CURLOPT_HTTPHEADER, array ( 'Content-Type: application/x-www-form-urlencoded' ) ); curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, true ); curl_setopt ( $ch, CURLOPT_COOKIE, $cookie ); curl_setopt ( $ch, CURLOPT_POST, true ); curl_setopt ( $ch, CURLOPT_POSTFIELDS, http_build_query ( $formdata ) ); $re = @json_decode ( curl_exec ( $ch ), ture ); curl_close ( $ch ); switch ($setting ['client_type']) { case '1' : $client_res = "iphone"; break; case '2' : $client_res = "android"; break; case '3' : $client_res = "WindowsPhone"; break; case '4' : $client_res = "Windows8"; break; } if (!$re) return array (0,'JSON 解析错误' ); if ($re ['error_code'] == 0) return array (2,"使用" . $client_res . '客户端发帖成功,查看帖子'); else if ($re ['error_code'] == 5) return array (5,"需要输入验证码,请检查你是否已经关注该贴吧。" ); else if ($re ['error_code'] == 7) return array (7,"您的操作太频繁了!" ); else if ($re ['error_code'] == 8) return array (8,"您已经被封禁" ); else return array($re ['error_code'],"未知错误,错误代码:" . $re ['error_code']); } ?> ================================================ FILE: plugins/xxx_post/index.php ================================================

客户端回帖

当前插件版本:0.3.1 | 更新日期:14-04-29 | Designed By @星弦雪

常规

客户端类型:

回帖频率: 每次回 贴(最多为getSetting('max_runtime', 6); ?>),发出一贴后等待 分钟再发下一帖


测试

随机选取一个帖子,进行一次回帖测试,检查你的设置有没有问题

测试回帖


添加需要回的帖子

序号贴吧贴子操作
载入中请稍后

添加贴子 添加贴吧 全部删除


添加回帖内容

回帖时随机使用其中之一,不添加的话会使用系统内置的

序号回帖内容操作
载入中请稍后

添加内容 批量添加 全部删除

当天的回帖记录

如果帖子已从回帖列表删除,则不会在这里显示

序号贴吧贴子成功失败
载入中请稍后

使用该插件需做好每日被永封的准备,因发帖插件导致的账号被封、被屏蔽,请使用者自行承担后果

关于封禁与解封

其实解封很简单的= =(作者表示已经被永封过无数次)

如果被度受永封的话:

1.绑定手机秒解

2.申请人工解封的话,只要你不是丧心病狂地每分钟一贴,一般都可以通过

如果被吧务封禁的话,只好找吧务承认错误并表示永不再犯= =(不过在官方水楼里刷的话应该吧务不会插手)

================================================ FILE: plugins/xxx_post/main.js ================================================ $("#menu_xxx_post-index").click(function (){ if($(".nav-tabs >.active").index()==0) {load_post_set();load_post_adv_set();} else if($(".nav-tabs >.active").index()==1) load_post_log(); }); $('#x_p_frequency').change(function(){ if($('#x_p_frequency').val()==4) $("#x_p_runtimes_hide").fadeOut("slow"); else $("#x_p_runtimes_hide").fadeIn("slow"); }); $("#xxx_post_add_tid").click(function(){ createWindow().setTitle("添加帖子").setContent('

你可以指定帖子进行回复

请输入帖子的地址:

例如:http://tieba.baidu.com/p/2692275116

').addButton("确定", function(){ $('#xxx_post_tid_form').submit(); }).addCloseButton("取消").append(); }); $("#x_p_add_tb").click(function(){ createWindow().setTitle("添加帖吧").setContent('

你可以只指定贴吧,并从该贴吧首页随机选择帖子进行回复

请输入帖吧的名字(不要带“吧”字):

例如:要添加chrome吧,请输入chrome

').addButton("确定", function(){ $('#xxx_post_add_tb_form').submit(); }).addCloseButton("取消").append(); }); $("#xxx_post_add_content").click(function(){ createWindow().setTitle("添加回帖内容").setContent('

请输入要回复的内容(最多1000字符):

').addButton("确定", function(){ $('#xxx_post_content_form').submit(); }).addCloseButton("取消").append(); }); $("#x_p_add_con").click(function(){ createWindow().setTitle("批量添加内容").setContent('

请输入要回复的内容(每行算一条):

').addButton("确定", function(){ $('#x_p_cont_form').submit(); }).addCloseButton("取消").append(); }); $("#x_p_del_con").click(function(){ createWindow().setTitle("批量删除").setContent('你确定要删除全部回复内容吗?').addButton("确定", function(){msg_callback_action('plugin.php?id=xxx_post&action=del-all-cont',x_reload);}).addCloseButton("取消").append(); }); $("#x_p_del_tid").click(function(){ createWindow().setTitle("批量删除").setContent('你确定要删除全部贴子吗?').addButton("确定", function(){msg_callback_action('plugin.php?id=xxx_post&action=del-all-tid',x_reload);}).addCloseButton("取消").append(); }); $(".x_tab_content>div").each(function(i){ $(this).addClass("x_tab_content_"+i); if(i!=0) $(this).hide(); }); $(".nav-tabs >li>a").click(function(){ if($(this).parent().hasClass("active")) return 0; else{ $(".x_tab_content>.x_tab_content_"+$(this).parent().siblings().filter(".active").index()).hide(); $(this).parent().siblings().filter(".active").removeClass("active"); $(".x_tab_content>.x_tab_content_"+$(this).parent().index()).show(); $(this).parent().addClass("active"); if($(this).parent().index()==0) {load_post_set();load_post_adv_set();} else if($(this).parent().index()==1) load_post_log(); } }); function x_reload(){ load_post_set();load_post_adv_set(); } function load_post_set(){ showloading(); $.getJSON("plugin.php?id=xxx_post&action=post-settings", function(result){ show_post_set(result); }).fail(function() { createWindow().setTitle('系统错误').setContent('发生未知错误: 无法获取设置').addButton('确定', function(){ location.reload(); }).append(); }).always(function(){ hideloading(); }); } function show_post_set(result){ $('#xxx_post_show').html(''); $('#xxx_post_contents').html(''); if(result.count1){ $.each(result.tiebas, function(i, field){ $("#xxx_post_show").append(""+(i+1)+""+field.name+""+field.post_name+"删除"); });}else{ $('#xxx_post_show').html('暂无记录'); } if(result.count2){ $.each(result.contents, function(i, field){ $("#xxx_post_contents").append(""+(i+1)+""+field.content+"删除"); });}else{ $('#xxx_post_contents').html('暂无记录'); } } function load_post_adv_set(){ showloading(); $.getJSON("plugin.php?id=xxx_post&action=post-adv-settings", function(result){ $('#x_p_client_type').val(result.settings.client_type).removeAttr('disabled'); $('#x_p_frequency').val(result.settings.frequency).removeAttr('disabled'); $('#x_p_delay').val(result.settings.delay).removeAttr('disabled'); $('#x_p_runtimes').val(result.settings.runtimes).removeAttr('disabled'); if(result.settings.frequency==4) $("#x_p_runtimes_hide").hide(); }).fail(function() { createWindow().setTitle('系统错误').setContent('发生未知错误: 无法获取设置').addButton('确定', function(){ location.reload(); }).append(); }).always(function(){ hideloading(); }); } function load_post_log(){ showloading(); $.getJSON("plugin.php?id=xxx_post&action=post-log", function(result){ show_post_log(result); }).fail(function() { createWindow().setTitle('系统错误').setContent('发生未知错误: 无法获取回帖报告').addButton('确定', function(){ location.reload(); }).append(); }).always(function(){ hideloading(); }); } function load_post_history(date){ showloading(); $.getJSON("plugin.php?id=xxx_post&action=post-history&date="+date, function(result){ show_post_log(result); }).fail(function() { createWindow().setTitle('系统错误').setContent('发生未知错误: 无法获取签到报告').addButton('确定', function(){ location.reload(); }).append(); }).always(function(){ hideloading(); }); } function show_post_log(result){ if(!result || result.count == 0){ $('#x_p_log_tab').html('暂无记录'); return; } $('#x_p_log_tab').html(''); $('#x_p_post_log_tite').html(result.date+" 回帖记录"); $.each(result.log, function(i, field){ $("#x_p_log_tab").append(""+(i+1)+""+field.name+""+field.post_name+""+field.status+""+field.retry+""); }); var pager_text = ''; if(result.before_date) pager_text += '« 前一天'; pager_text += '今天'; if(result.after_date) pager_text += '后一天 »'; $('#x_p_pager_text').html(pager_text); } function delsid(sid){ createWindow().setTitle('删除帖子').setContent('确认要删除这个帖子的自动回复吗?').addButton('确定', function(){ msg_callback_action("plugin.php?id=xxx_post&action=delsid&sid="+sid,x_reload); }).addCloseButton('取消').append(); return false; } function delcont(cid){ createWindow().setTitle('删除帖子').setContent('确认要删除这个回复内容吗?').addButton('确定', function(){ msg_callback_action("plugin.php?id=xxx_post&action=delcont&cid="+cid,x_reload); }).addCloseButton('取消').append(); return false; } ================================================ FILE: plugins/xxx_post/plugin.class.php ================================================ 'index', 'type' => 'page','title' => '客户端回帖','file' => 'index.php'), array('type' => 'cron', 'cron' => array('id' => 'xxx_post/c_daily', 'order' => '101')), array('type' => 'cron', 'cron' => array('id' => 'xxx_post/c_first', 'order' => '103')), array('type' => 'cron', 'cron' => array('id' => 'xxx_post/c_se', 'order' => '105')), array('type' => 'cron', 'cron' => array('id' => 'xxx_post/c_sxbk', 'order' => '109')), ); var $version='0.3.1'; function checkCompatibility(){ if(version_compare(VERSION, '1.14.4.24', '<')) showmessage('签到助手版本过低,请升级'); } function page_footer_js() { echo ''; } function install() { $query = DB::query ( 'SHOW TABLES' ); $tables = array (); while ($table= DB::fetch($query)) $tables[]=implode ('', $table ); if (!in_array ( 'xxx_post_posts', $tables )){ runquery(" CREATE TABLE IF NOT EXISTS `xxx_post_posts` ( `sid` int(10) unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY, `uid` int(10) unsigned NOT NULL, `fid` int(10) unsigned NOT NULL, `tid` int(12) unsigned NOT NULL, `name` varchar(127) NOT NULL, `unicode_name` varchar(512) NOT NULL, `post_name` varchar(127) NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=utf8; CREATE TABLE IF NOT EXISTS `xxx_post_setting` ( `uid` int(10) unsigned NOT NULL PRIMARY KEY, `client_type` tinyint(1) NOT NULL DEFAULT '5', `frequency` tinyint(1) NOT NULL DEFAULT '2', `delay` tinyint(2) NOT NULL DEFAULT '1', `runtime` int(10) unsigned NOT NULL DEFAULT '0', `runtimes` int(5) unsigned NOT NULL DEFAULT '6' ) ENGINE=MyISAM DEFAULT CHARSET=utf8; CREATE TABLE IF NOT EXISTS `xxx_post_content` ( `cid` int(10) unsigned AUTO_INCREMENT PRIMARY KEY, `uid` int(10) unsigned NOT NULL, `content` varchar(1024) NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=utf8; CREATE TABLE IF NOT EXISTS `xxx_post_log` ( `sid` int(10) unsigned NOT NULL, `uid` int(10) unsigned NOT NULL, `date` int(11) NOT NULL DEFAULT '0', `status` tinyint(4) NOT NULL DEFAULT '0', `retry` tinyint(3) unsigned NOT NULL DEFAULT '0', UNIQUE KEY `sid` (`sid`,`date`), KEY `uid` (`uid`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; "); $this->saveSetting ( 'sxbk', '0' ); $this->saveSetting ( 'se', '21' ); $this->saveSetting ( 'first_end','15'); } } function uninstall() { DB::query ( "DROP TABLE xxx_post_content,xxx_post_log,xxx_post_posts,xxx_post_setting" ); showmessage ( "数据库删除成功。" ); } function on_upgrade($from_version){ switch ($from_version){ case '0': case '0.2.2_13': case '0.2.3': case '0.3.0': runquery(" UPDATE cron SET id='xxx_post/c_daily' WHERE id='xxx_post_daily'; UPDATE cron SET id='xxx_post/c_first' WHERE id='xxx_post'; UPDATE cron SET id='xxx_post/c_se' WHERE id='xxx_post_se'; UPDATE cron SET id='xxx_post/c_sxbk' WHERE id='xxx_post_sxbk'; "); $this->saveSetting ( 'sxbk', '0' ); $this->saveSetting ( 'se', '21' ); $this->saveSetting ( 'first_end','15'); return '0.3.1'; default: throw new Exception("Unknown plugin version: {$from_version}"); } } function on_config() { if ($_POST) { $sxbkset=trim($_POST ['sxbkset']); $se_set=intval(trim($_POST['se_set'])); $first_end=intval(trim($_POST['first_end'])); $max_runtime=intval($_POST['max_runtime']); $max_runtime = max(6, $max_runtime); if (! $sxbkset) $sxbkset = 0; if($se_set<12) $se_set=12; else if ($se_set>22) $se_set=22; if($first_end<1) $first_end=1; else if ($first_end>22) $first_end=22; $this->saveSetting('sxbk',$sxbkset); $this->saveSetting('se',$se_set); $this->saveSetting('first_end',$first_end); $this->saveSetting('max_runtime', $max_runtime); showmessage ( "设置保存成功" ); } else { $sxbk=$this->getSetting('sxbk'); $se_set=$this->getSetting('se'); $first_end=$this->getSetting('first_end'); $max_runtime=$this->getSetting('max_runtime', 6); $sxbk = $sxbk ? 'checked="cheched"' : ''; return <<

时间控制(24小时制):

点之前结束第一次回帖

点之后开始第二次回帖

每位用户每次最多回个帖子

EOF; } } function handleAction(){ global $uid; if(!$uid) return; switch ($_GET ['action']) { case 'delsid' : $_sid = intval ( $_GET ['sid'] ); DB::query ( "DELETE FROM xxx_post_posts WHERE sid='{$_sid}'" ); $data ['msg'] = "删除成功"; break; case 'del-all-tid' : DB::query ( "DELETE FROM xxx_post_posts WHERE uid='{$uid}'" ); $data ['msg'] = "删除成功"; break; case 'delcont' : $cid = intval ( $_GET ['cid'] ); DB::query ( "DELETE FROM xxx_post_content WHERE cid='{$cid}'" ); $data ['msg'] = "删除成功"; break; case 'del-all-cont' : DB::query ( "DELETE FROM xxx_post_content WHERE uid='{$uid}'" ); $data ['msg'] = "删除成功"; break; case 'set-content' : $contx = $_POST ['post_content']; if (! $contx) { $data ['msg'] = "设置失败,请输入字符串"; } else { DB::insert ( 'xxx_post_content', array ( 'uid' => $uid, 'content' => $contx ) ); $data ['msg'] = "设置成功"; } break; case 'set-cont-plus' : $contplus = $_POST ['x_p_contant']; if (! trim ( $contplus )) { $data ['msg'] = "设置失败,请输入字符串"; } else { $cp_array = explode ( "\n", trim ( $contplus ) ); foreach ( $cp_array as $contx ) { if (! trim ( $contx )) continue; DB::insert ( 'xxx_post_content', array ( 'uid' => $uid, 'content' => $contx ) ); } $data ['msg'] = "设置成功"; } break; case 'set-settings' : $client_type = intval($_POST ['x_p_client_type']); $frequency = intval($_POST ['x_p_frequency']); $runtimes = intval($_POST ['x_p_runtimes']); $delay = intval($_POST ['x_p_delay']); $max_runtime=$this->getSetting('max_runtime', 6); $runtimes = min($max_runtime, $runtimes); if ($delay < 0) $delay = 0; else if ($delay > 15) $delay = 15; if ($runtimes < 1) $delay = 1; else if ($runtimes > 6) $delay = 6; DB::query ( "replace into xxx_post_setting (uid,client_type,frequency,delay,runtimes) values($uid,$client_type,$frequency,$delay,$runtimes)" ); $data ['msg'] = "设置成功"; break; case 'post-settings' : $query = DB::query ( "SELECT * FROM xxx_post_posts WHERE uid='$uid'" ); while ( $result = DB::fetch ( $query ) ) { $data ['tiebas'] [] = $result; } $query = DB::query ( "SELECT * FROM xxx_post_content WHERE uid='$uid'" ); while ( $result = DB::fetch ( $query ) ) { $data ['contents'] [] = $result; } $data ['count1'] = count ( $data ['tiebas'] ); $data ['count2'] = count ( $data ['contents'] ); break; case 'post-adv-settings' : $query = DB::query ( "SELECT * FROM xxx_post_setting WHERE uid='$uid'" ); while ( $result = DB::fetch ( $query ) ) { $data ['settings'] = $result; } if (! $data ['settings'] ['client_type']) { DB::query ( "insert into xxx_post_setting set uid=$uid"); $data ['settings'] ['client_type'] = 5; $data ['settings'] ['frequency'] = 2; $data ['settings'] ['delay'] = 1; $data ['settings'] ['runtimes'] = 6; } break; case 'add-tieba' : $tieba = $_POST ['xxx_post_add_tieba']; $ch = curl_init ('http://tieba.baidu.com/f?kw='.urlencode(iconv("utf-8", "gbk", $tieba)).'&fr=index'); curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, 1 ); $contents = curl_exec ( $ch ); curl_close ( $ch ); $fid = 0; preg_match('/"forum_id"\s?:\s?(?\d+)/', $contents, $fids); $fid = $fids ['fid']; if ($fid == 0) { $data ['msg'] = "添加失败,请检查贴吧名称并重试"; $data ['msgx'] = 0; break; } preg_match ( '/fname="(.+?)"/', $contents, $fnames ); $unicode_name = urlencode($fnames [1]); $fname = $fnames [1]; DB::insert ( 'xxx_post_posts', array ( 'uid' => $uid, 'fid' => $fid, 'tid' => 0, 'name' => $fname, 'unicode_name' => $unicode_name, 'post_name' =>'随机' ) ); $data ['msg'] = "添加成功"; break; case 'get-tid' : $tieurl = $_POST ['xxx_post_tid']; preg_match ( '/tieba\.baidu\.com\/p\/(?\d+)/', $tieurl, $tids ); $tid=$tids ['tid']; $ch = curl_init ('http://tieba.baidu.com/p/'.$tid); curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, 1 ); $contents = curl_exec ( $ch ); curl_close ( $ch ); $fid = 0; preg_match ( '/"forum_id"\s?:\s?(?\d+)/', $contents, $fids ); $fid =$fids ['fid']; if ($fid == 0) { $data ['msg'] = "添加失败,请检查帖子地址并重试"; $data ['msgx'] = 0; break; } preg_match ( '/fname="(.+?)"/', $contents, $fnames ); $unicode_name = urlencode($fnames [1]); $fname = $fnames [1]; preg_match ( '/title:"(.*?)"/', $contents, $post_names ); $post_name = $post_names [1]; DB::insert ( 'xxx_post_posts', array ( 'uid' => $uid, 'fid' => $fid, 'tid' => $tid, 'name' => $fname, 'unicode_name' => $unicode_name, 'post_name' => $post_name ) ); $data ['msg'] = "添加成功"; break; case 'test_post' : include 'plugins/xxx_post/core.php'; $tiezi_count = DB::result_first ( "SELECT COUNT(*) FROM xxx_post_posts WHERE uid='$uid'" ); $tiezi_offset = rand(1, $tiezi_count) - 1; $tiezi=DB::fetch_first ( "SELECT * FROM xxx_post_posts WHERE uid='$uid' limit $tiezi_offset,1" ); if (! $tiezi) showmessage ('没有添加帖子,请先添加!'); $x_content_count = DB::result_first("SELECT COUNT(*) FROM xxx_post_content WHERE uid='$uid'"); $x_content_offset = rand(1, $x_content_count) - 1; $x_content = DB::result_first("SELECT content FROM xxx_post_content WHERE uid='$uid' limit $x_content_offset,1"); list ( $status, $result ) = client_rppost ( $uid, $tiezi, $x_content); $status = $status == 2 ? '发帖成功' : '发帖失败'; showmessage ( "

测试帖子:【{$tiezi[name]}吧】{$tiezi[post_name]}

测试结果:{$status}

详细信息:{$result}

" ); break; case 'post-log' : $date = date ( 'Ymd' ); $data ['date'] = date ( 'Y-m-d' ); case 'post-history' : if ($_GET ['action'] == 'post-history') { $date = intval ( $_GET ['date'] ); $data ['date'] = substr ( $date, 0, 4 ) . '-' . substr ( $date, 4, 2 ) . '-' . substr ( $date, 6, 2 ); } $data ['log'] = array (); $query = DB::query ( "SELECT * FROM xxx_post_log l LEFT JOIN xxx_post_posts t ON t.sid=l.sid WHERE l.uid='$uid' AND l.date='$date'" ); while ( $result = DB::fetch ( $query ) ) { if (! $result ['sid']) continue; $data ['log'] [] = $result; } $data ['count'] = count ( $data ['log'] ); $data ['before_date'] = DB::result_first ( "SELECT date FROM xxx_post_log WHERE uid='{$uid}' AND date<'{$date}' ORDER BY date DESC LIMIT 0,1" ); $data ['after_date'] = DB::result_first ( "SELECT date FROM xxx_post_log WHERE uid='{$uid}' AND date>'{$date}' ORDER BY date ASC LIMIT 0,1" ); break; } echo json_encode ( $data ); } } ================================================ FILE: robots.txt ================================================ User-agent: * Disallow: / ================================================ FILE: system/class/cache.php ================================================ init_header(); $this->init_useragent(); Updater::init(); $this->init_syskey(); $this->init_cookie(); cloud::init(); HOOK::INIT(); $this->init_final(); } function __destruct() { if (!defined('SYSTEM_STARTED')) return; HOOK::run('on_unload'); flush(); ob_end_flush(); $this->init_mail(); } function init_header() { ob_start(); header('Content-type: text/html; charset=utf-8'); header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); header('Cache-Control: no-cache'); header('Pragma: no-cache'); @date_default_timezone_set('Asia/Shanghai'); } function init_useragent() { $ua = strtolower($_SERVER['HTTP_USER_AGENT']); if (strpos($ua, 'wap') || strpos($ua, 'mobi') || strpos($ua, 'opera') || $_GET['mobile']) { define('IN_MOBILE', true); } else { define('IN_MOBILE', false); } if (strpos($ua, 'bot') || strpos($ua, 'spider')) define('IN_ROBOT', true); } function init_syskey() { define('ENCRYPT_KEY', getSetting('SYS_KEY')); } function init_cookie() { global $cookiever, $uid, $username; $cookiever = '2'; if (!empty($_COOKIE['token'])) { list($cc, $uid, $username, $exptime, $password) = explode("\t", authcode($_COOKIE['token'], 'DECODE')); if (!$uid || $cc != $cookiever) { unset($uid, $username, $exptime); dsetcookie('token'); } elseif ($exptime < TIMESTAMP) { $user = DB::fetch_first("SELECT * FROM member WHERE uid='{$uid}'"); $_password = substr(md5($user['password']), 8, 8); if ($user && $password == $_password) { $exptime = TIMESTAMP + 900; dsetcookie('token', authcode("{$cookiever}\t{$uid}\t{$user[username]}\t{$exptime}\t{$password}", 'ENCODE')); } else { unset($uid, $username, $exptime); dsetcookie('token'); } } } else { $uid = $username = ''; } } function init_final() { define('SYSTEM_STARTED', true); @ignore_user_abort(true); if(getSetting('AFENABLED')) define('AFENABLED', true); HOOK::run('on_load'); } function init_mail() { $queue = getSetting('mail_queue'); if (!$queue) return; $mail = DB::fetch_first("SELECT * FROM mail_queue LIMIT 0,1"); if ($mail) { DB::query("DELETE FROM mail_queue WHERE id='{$mail[id]}'"); $_mail = new mail_content(); $_mail->address = $mail['to']; $_mail->subject = $mail['subject']; $_mail->message = $mail['content']; $sender = new mail_sender(); $sender->sendMail($_mail); } else { saveSetting('mail_queue', 0); } } } ================================================ FILE: system/class/db.php ================================================ curlink = $this->_dbconnect($_config['db']['server'].':'.$_config['db']['port'], $_config['db']['username'], $_config['db']['password'], 'utf8', $_config['db']['name'], $_config['db']['pconnect']); } function _dbconnect($dbhost, $dbuser, $dbpw, $dbcharset, $dbname, $pconnect) { $link = null; $func = empty($pconnect) ? 'mysql_connect' : 'mysql_pconnect'; if (!$link = @$func($dbhost, $dbuser, $dbpw, 1)) { $this->halt('Couldn\'t connect to MySQL Server'); } else { $this->curlink = $link; if ($this->version() > '4.1') { $serverset = $dbcharset ? 'character_set_connection='.$dbcharset.', character_set_results='.$dbcharset.', character_set_client=binary' : ''; $serverset .= $this->version() > '5.0.1' ? ((empty($serverset) ? '' : ',').'sql_mode=\'\'') : ''; $serverset && mysql_query("SET $serverset", $link); } $dbname && @mysql_select_db($dbname, $link); } return $link; } function select_db($dbname) { return mysql_select_db($dbname, $this->curlink); } function fetch_array($query, $result_type = MYSQL_ASSOC) { return mysql_fetch_array($query, $result_type); } function fetch_first($sql) { return $this->fetch_array($this->query($sql)); } function result_first($sql) { return $this->result($this->query($sql), 0); } function query($sql, $type = '') { $func = $type == 'UNBUFFERED' && @function_exists('mysql_unbuffered_query') ? 'mysql_unbuffered_query' : 'mysql_query'; if (!$this->curlink) $this->connect(); if (!($query = $func($sql, $this->curlink))) { if ($type != 'SILENT') { $this->halt('MySQL Query ERROR', $sql); } } return $this->last_query = $query; } function affected_rows() { return mysql_affected_rows($this->curlink); } function error() { return (($this->curlink) ? mysql_error($this->curlink) : mysql_error()); } function errno() { return intval(($this->curlink) ? mysql_errno($this->curlink) : mysql_errno()); } function result($query, $row = 0) { $query = @mysql_result($query, $row); return $query; } function num_rows($query) { $query = mysql_num_rows($query); return $query; } function num_fields($query) { return mysql_num_fields($query); } function free_result($query) { return mysql_free_result($query); } function insert_id() { return ($id = mysql_insert_id($this->curlink)) >= 0 ? $id : $this->result($this->query("SELECT last_insert_id()"), 0); } function fetch_row($query) { $query = mysql_fetch_row($query); return $query; } function fetch_fields($query) { return mysql_fetch_field($query); } function version() { if (empty($this->version)) { $this->version = mysql_get_server_info($this->curlink); } return $this->version; } function close() { return mysql_close($this->curlink); } function halt($message = '', $sql = '') { kerror::db_error($message, $sql); } function __destruct() { $this->close(); } } class db_mysqli { var $curlink; var $last_query; function connect() { global $_config; $this->curlink = $this->_dbconnect($_config['db']['server'].':'.$_config['db']['port'], $_config['db']['username'], $_config['db']['password'], 'utf8', $_config['db']['name'], $_config['db']['pconnect']); } function _dbconnect($dbhost, $dbuser, $dbpw, $dbcharset, $dbname, $pconnect) { $link = null; if (!$link = mysqli_connect($dbhost, $dbuser, $dbpw)) { $this->halt('Couldn\'t connect to MySQL Server'); } else { $this->curlink = $link; $serverset = $dbcharset ? 'character_set_connection='.$dbcharset.', character_set_results='.$dbcharset.', character_set_client=binary,sql_mode=\'\'' : ''; $serverset && mysqli_query($link, "SET $serverset"); $dbname && @mysqli_select_db($link, $dbname); } return $link; } function select_db($dbname) { return mysqli_select_db($this->curlink, $dbname); } function fetch_array($query, $result_type = MYSQLI_ASSOC) { return mysqli_fetch_array($query, $result_type); } function fetch_first($sql) { return $this->fetch_array($this->query($sql)); } function result_first($sql) { return $this->result($this->query($sql), 0); } function query($sql, $type = '') { if (!$this->curlink) $this->connect(); if (!($query = mysqli_query($this->curlink, $sql))) { if ($type != 'SILENT') { $this->halt('MySQL Query ERROR', $sql); } } return $this->last_query = $query; } function affected_rows() { return mysqli_affected_rows($this->curlink); } function error() { return (($this->curlink) ? mysqli_error($this->curlink) : mysqli_error()); } function errno() { return intval(($this->curlink) ? mysqli_errno($this->curlink) : mysqli_errno()); } function result($query, $row = 0) { $query = mysqli_fetch_row($query)[$row]; return $query; } function num_rows($query) { $query = mysqli_num_rows($query); return $query; } function num_fields($query) { return mysqli_num_fields($query); } function free_result($query) { return mysqli_free_result($query); } function insert_id() { return ($id = mysqli_insert_id($this->curlink)) >= 0 ? $id : $this->result($this->query("SELECT last_insert_id()"), 0); } function fetch_row($query) { $query = mysqli_fetch_row($query); return $query; } function fetch_fields($query) { return mysqli_fetch_field($query); } function version() { if (empty($this->version)) { $this->version = mysqli_get_server_info($this->curlink); } return $this->version; } function close() { return mysqli_close($this->curlink); } function halt($message = '', $sql = '') { kerror::db_error($message, $sql); } function __destruct() { $this->close(); } } class DB { public static function delete($table, $condition, $limit = 0, $unbuffered = true) { if (empty($condition)) { $where = '1'; } elseif (is_array($condition)) { $where = DB::implode_field_value($condition, ' AND '); } else { $where = $condition; } $sql = "DELETE FROM {$table} WHERE $where ".($limit ? "LIMIT $limit" : ''); return DB::query($sql, ($unbuffered ? 'UNBUFFERED' : '')); } public static function insert($table, $data, $return_insert_id = true, $replace = false, $silent = false) { $sql = DB::implode_field_value($data); $cmd = $replace ? 'REPLACE INTO' : 'INSERT INTO'; $silent = $silent ? 'SILENT' : ''; $return = DB::query("$cmd $table SET $sql", $silent); return $return_insert_id ? DB::insert_id() : $return; } public static function update($table, $data, $condition, $unbuffered = false, $low_priority = false) { $sql = DB::implode_field_value($data); $cmd = "UPDATE ".($low_priority ? 'LOW_PRIORITY' : ''); $where = ''; if (empty($condition)) { $where = '1'; } elseif (is_array($condition)) { $where = DB::implode_field_value($condition, ' AND '); } else { $where = $condition; } $res = DB::query("$cmd $table SET $sql WHERE $where", $unbuffered ? 'UNBUFFERED' : ''); return $res; } public static function implode_field_value($array, $glue = ',') { $sql = $comma = ''; foreach ($array as $k => $v) { $sql .= $comma."`$k`='$v'"; $comma = $glue; } return $sql; } public static function insert_id() { return DB::_execute('insert_id'); } public static function fetch($resourceid, $type = MYSQLI_ASSOC) { return DB::_execute('fetch_array', $resourceid, $type); } public static function fetch_first($sql) { return DB::_execute('fetch_first', $sql); } public static function fetch_all($sql) { $query = DB::_execute('query', $sql); $return = array(); while ($result = DB::fetch($query)) { $return[] = $result; } return $return; } public static function result($resourceid, $row = 0) { return DB::_execute('result', $resourceid, $row); } public static function result_first($sql) { return DB::_execute('result_first', $sql); } public static function query($sql, $type = '') { return DB::_execute('query', $sql, $type); } public static function num_rows($resourceid) { return DB::_execute('num_rows', $resourceid); } public static function affected_rows() { return DB::_execute('affected_rows'); } public static function free_result($query) { return DB::_execute('free_result', $query); } public static function error() { return DB::_execute('error'); } public static function errno() { return DB::_execute('errno'); } private static function _execute($cmd , $arg1 = '', $arg2 = '') { static $db; if (empty($db)) $db = &DB::object(); $res = $db->$cmd($arg1, $arg2); return $res; } public static function &object() { static $db; if (empty($db)) { if (function_exists('mysql_connect')) { $db = new db_mysql(); } else { $db = new db_mysqli(); } } return $db; } } ================================================ FILE: system/class/hook.php ================================================ version; if($version && $plugin['ver'] != $version){ if(method_exists($_PLUGIN['obj'][$pluginid], 'on_upgrade')){ $return_ver = $_PLUGIN['obj'][$pluginid]->on_upgrade($plugin['ver']); if($return_ver){ DB::query("UPDATE `plugin` SET `version`='{$return_ver}' WHERE name='{$pluginid}'"); }else{ DB::query("UPDATE `plugin` SET `version`='{$version}' WHERE name='{$pluginid}'"); } }else{ DB::query("UPDATE `plugin` SET `version`='{$version}' WHERE name='{$pluginid}'"); } // Reload cron scripts DB::query("DELETE FROM cron WHERE id LIKE '%".$pluginid."%'"); foreach($_PLUGIN['obj'][$pluginid]->modules as $module){ if($module['type'] == 'cron'){ DB::insert('cron', array_merge($module['cron'], array('nextrun' => TIMESTAMP)), false, true); } } CACHE::update('plugins'); } } foreach ($methods as $method) $_PLUGIN['hook'][$method][] = $pluginid; if(method_exists($_PLUGIN['obj'][$pluginid], 'getMethods')) $_PLUGIN['obj'][$pluginid]->modules = $_PLUGIN['obj'][$pluginid]->getMethods(); if(method_exists($_PLUGIN['obj'][$pluginid], 'getModules')) $_PLUGIN['obj'][$pluginid]->modules = $_PLUGIN['obj'][$pluginid]->getModules(); foreach ($_PLUGIN['obj'][$pluginid]->modules as $module) self::parse_module($module, $pluginid); } } } public static function parse_module($module, $pluginid){ global $_PLUGIN; switch ($module['type']){ case 'page': $_PLUGIN['page'][] = array( 'id' => "{$pluginid}-{$module[id]}", 'title' => $module['title'], 'file' => ROOT."./plugins/{$pluginid}/".$module['file'], 'admin' => $module['admin'], ); break; case 'shortcut': $_PLUGIN['shortcut'][] = array( 'title' => $module['title'], 'link' => $module['link'], 'admin' => $module['admin'], ); break; case 'cron': break; default: throw new Exception('Unknown module type: '.$module['type']); } } public static function page_menu(){ global $_PLUGIN, $uid; if($_PLUGIN['page']){ foreach ($_PLUGIN['page'] as $page){ if($page['admin'] && !is_admin($uid)) continue; echo "
  • {$page[title]}
  • "; } } if($_PLUGIN['shortcut']){ foreach ($_PLUGIN['shortcut'] as $page){ if($page['admin'] && !is_admin($uid)) continue; echo "
  • {$page[title]}
  • "; } } } public static function page_contents(){ global $_PLUGIN, $uid; if($_PLUGIN['page']){ foreach($_PLUGIN['page'] as $page){ if($page['admin'] && !is_admin($uid)) continue; echo "
    "; @include $page['file']; echo "
    \r\n"; } } } public static function run($hookname, $ignore_unabled = false){ global $_PLUGIN; if(defined('DISABLE_PLUGIN') && !$ignore_unabled) return; $hooks = $_PLUGIN['hook'][$hookname]; if(!$hooks) return; $args = func_get_args(); unset($args[0], $args[1]); foreach($hooks as $pluginid){ try{ echo call_user_func_array(array(&$_PLUGIN['obj'][$pluginid], $hookname), $args); }catch(Exception $e){ kerror::exception_error($e); } } } public static function getPlugin($plugin_id){ global $_PLUGIN; if($_PLUGIN['obj'][$plugin_id]){ return $_PLUGIN['obj'][$plugin_id]; }elseif(defined('DISABLE_PLUGIN')){ $classname = 'plugin_'.$plugin_id; return $_PLUGIN['obj'][$plugin_id] = new $classname(); } } } ================================================ FILE: system/class/kerror.php ================================================ $message", $showtrace, 0); } if ($halt) { exit(); } else { return $message; } } public static function debug_backtrace() { $skipfunc[] = 'kerror->debug_backtrace'; $skipfunc[] = 'kerror->db_error'; $skipfunc[] = 'kerror->template_error'; $skipfunc[] = 'kerror->system_error'; $skipfunc[] = 'db_mysql->halt'; $skipfunc[] = 'db_mysql->query'; $skipfunc[] = 'DB::_execute'; $show = $log = ''; $debug_backtrace = debug_backtrace(); krsort($debug_backtrace); foreach ($debug_backtrace as $k => $error) { $file = str_replace(ROOT, '', $error['file']); $func = isset($error['class']) ? $error['class'] : ''; $func .= isset($error['type']) ? $error['type'] : ''; $func .= isset($error['function']) ? $error['function'] : ''; if (in_array($func, $skipfunc)) { break; } $error[line] = sprintf('%04d', $error['line']); $show .= "
  • [Line: $error[line]]".$file."($func)
  • "; $log .= !empty($log) ? '->' : ''; $file.':'.$error['line']; $log .= $file.':'.$error['line']; } return array($show, $log); } public static function db_error($message, $sql) { global $_G; list($showtrace, $logtrace) = kerror::debug_backtrace(); $db = &DB::object(); $dberrno = $db->errno(); $dberror = str_replace($db->tablepre, '', $db->error()); $sql = htmlspecialchars(str_replace($db->tablepre, '', $sql)); $msg = '
  • '.$message.'
  • '; $msg .= $dberrno ? '
  • ['.$dberrno.'] '.$dberror.'
  • ' : ''; $msg .= $sql ? '
  • [Query] '.$sql.'
  • ' : ''; kerror::show_error('db', $msg, $showtrace, false); exit(); } public static function exception_error($exception) { if ($exception instanceof DbException) { $type = 'db'; } else { $type = 'system'; } if ($type == 'db') { $errormsg = '('.$exception->getCode().') '; $errormsg .= self::sql_clear($exception->getMessage()); if ($exception->getSql()) { $errormsg .= '
    '; $errormsg .= self::sql_clear($exception->getSql()); $errormsg .= '
    '; } } else { $errormsg = $exception->getMessage(); } $trace = $exception->getTrace(); krsort($trace); $trace[] = array('file' => $exception->getFile(), 'line' => $exception->getLine(), 'function' => 'ErrorHandler'); $phpmsg = array(); foreach ($trace as $error) { if (!empty($error['function'])) { $fun = ''; if (!empty($error['class'])) { $fun .= $error['class'].$error['type']; } $fun .= $error['function'].'('; if (!empty($error['args'])) { $mark = ''; foreach($error['args'] as $arg) { $fun .= $mark; if (is_array($arg)) { $fun .= 'Array'; } elseif (is_bool($arg)) { $fun .= $arg ? 'true' : 'false'; } elseif (is_int($arg)) { $fun .= (defined('DEBUG_FLAG') && DEBUG_FLAG) ? $arg : '%d'; } elseif (is_float($arg)) { $fun .= (defined('DEBUG_FLAG') && DEBUG_FLAG) ? $arg : '%f'; } else { $fun .= (defined('DEBUG_FLAG') && DEBUG_FLAG) ? '\''.htmlspecialchars(substr(self::clear($arg), 0, 10)).(strlen($arg) > 10 ? ' ...' : '').'\'' : '%s'; } $mark = ', '; } } $fun .= ')'; $error['function'] = $fun; } $phpmsg[] = array('file' => str_replace(array(ROOT, '\\'), array('', '/'), $error['file']), 'line' => $error['line'], 'function' => $error['function'],); } self::show_error($type, $errormsg, $phpmsg); exit(); } public static function show_error($type, $errormsg, $phpmsg = '', $exit = true) { ob_end_clean(); ob_start(); $host = $_SERVER['HTTP_HOST']; $title = $type == 'db' ? 'Database' : 'System'; echo <<$host - $title Error

    KK Tieba Signer $title Error

    $errormsg
    EOT; if (is_array($phpmsg) && !empty($phpmsg)) { echo '
    '; echo '

    PHP Debug

    '; echo ''; echo ''; foreach($phpmsg as $k => $msg) { $k++; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; } echo '
    No.FileLineCode
    '.$k.''.$msg['file'].''.$msg['line'].''.$msg['function'].'
    '; } echo '
    '; $exit && exit(); } public static function clear($message) { return str_replace(array("\t", "\r", "\n"), " ", $message); } public static function sql_clear($message) { $message = self::clear($message); $message = str_replace(DB::object()->tablepre, '', $message); $message = htmlspecialchars($message); return $message; } } ================================================ FILE: system/class/mail/phpmail.php ================================================ address; $headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-Type: text/html;charset=utf-8\r\n"; $headers .= "Content-Transfer-Encoding: Base64\r\n"; $headers .= 'From: =?UTF-8?B?'.base64_encode('贴吧签到助手').'?= <'.$this->_get_setting('from').">\r\n"; return mail($address, '=?UTF-8?B?'.base64_encode($mail->subject).'?=', base64_encode($mail->message), $headers); } } ?> ================================================ FILE: system/class/mail/saemail.php ================================================ setOpt(array( 'from' => '贴吧签到助手 <'.$this->_get_setting('address').'>', 'to' => $mail->address, 'smtp_host' => $this->_get_setting('smtp_server'), 'smtp_username' => $this->_get_setting('smtp_name'), 'smtp_password' => $this->_get_setting('smtp_pass'), 'subject' => $mail->subject, 'content' => $mail->message, 'content_type' => 'HTML', )); $saemail->send(); return true; } } ?> ================================================ FILE: system/class/mail/smtp.php ================================================ send($mail->address, $mail->subject, $mail->message); } } class _smtp { private $smtpServer = ''; private $port = '25'; private $timeout = '45'; private $username = ''; private $password = ''; private $address = ''; private $newline = "\r\n"; private $localdomain = 'localhost'; private $charset = 'utf-8'; private $contentTransferEncoding = false; private $debug = false; private $smtpConnect = false; private $to = false; private $subject = false; private $message = false; private $headers = false; private $logArray = array(); public $Error = ''; public function _smtp($obj){ $this->smtpServer = $obj->_get_setting('smtp_server'); $this->address = $obj->_get_setting('address'); $this->username = $obj->_get_setting('smtp_name'); $this->password = $obj->_get_setting('smtp_pass'); } public function send($to, $subject, $message) { global $_config; $this->to = &$to; $this->subject = &$subject; $this->message = &$message; if(!$this->Connect2Server()) { if(!$this->debug) return false; echo $this->Error.$this->newline.''.$this->newline; return false; } return true; } private function Connect2Server() { $this->smtpConnect = fsockopen($this->smtpServer, $this->port, $errno, $error, $this->timeout); $this->logArray['CONNECT_RESPONSE'] = $this->readResponse(); if (!is_resource($this->smtpConnect)) return false; $this->logArray['connection'] = 'Connection accepted: '.$this->readResponse(); $this->sendCommand("EHLO {$this->localdomain}"); $this->logArray['EHLO'] = $this->readResponse(); $this->sendCommand('AUTH LOGIN'); $this->logArray['AUTH_REQUEST'] = $this->readResponse(); $this->sendCommand(base64_encode($this->username)); $this->logArray['REQUEST_USER'] = $this->readResponse(); $this->sendCommand(base64_encode($this->password)); $this->logArray['REQUEST_PASSWD'] = $this->readResponse(); if (substr($this->logArray['REQUEST_PASSWD'], 0, 3)!='235') { $this->Error .= 'Authorization error! '.$this->logArray['REQUEST_PASSWD'].$this->newline; return false; } $this->sendCommand("MAIL FROM: {$this->address}"); $this->logArray['MAIL_FROM_RESPONSE'] = $this->readResponse(); if (substr($this->logArray['MAIL_FROM_RESPONSE'], 0, 3)!='250') { $this->Error .= 'Mistake in sender\'s address! '.$this->logArray['MAIL_FROM_RESPONSE'].$this->newline; return false; } $this->sendCommand("RCPT TO: {$this->to}"); $this->logArray['RCPT_TO_RESPONCE'] = $this->readResponse(); if (substr($this->logArray['RCPT_TO_RESPONCE'], 0, 3)!='250') { $this->Error .= 'Mistake in reciepent address! '.$this->logArray['RCPT_TO_RESPONCE'].$this->newline; } $this->sendCommand('DATA'); $this->logArray['DATA_RESPONSE'] = $this->readResponse(); if (!$this->sendMail()) return false; $this->sendCommand('QUIT'); $this->logArray['QUIT_RESPONSE'] = $this->readResponse(); fclose($this->smtpConnect); return true; } private function sendMail() { $this->sendHeaders(); $this->sendCommand($this->message); $this->sendCommand('.'); $this->logArray['SEND_DATA_RESPONSE'] = $this->readResponse(); if(substr($this->logArray['SEND_DATA_RESPONSE'], 0, 3)!='250') { $this->Error .= 'Mistake in sending data! '.$this->logArray['SEND_DATA_RESPONSE'].$this->newline; return false; } return true; } private function readResponse() { $data = ''; while($str = fgets($this->smtpConnect, 4096)) { $data .= $str; if(substr($str, 3, 1) == " ") { break; } } return $data; } private function sendCommand($string) { fputs($this->smtpConnect, $string.$this->newline); return ; } private function sendHeaders() { $this->sendCommand('Date: '.date('D, j M Y G:i:s').' +0700'); $this->sendCommand("From: <{$this->address}>"); $this->sendCommand("Reply-To: <{$this->address}>"); $this->sendCommand("To: <{$this->to}>"); $this->sendCommand("Subject: {$this->subject}"); $this->sendCommand('MIME-Version: 1.0'); $this->sendCommand("Content-Type: text/html; charset={$this->charset}"); if ($this->contentTransferEncoding) $this->sendCommand("Content-Transfer-Encoding: {$this->contentTransferEncoding}"); $this->sendCommand($this->newline); return ; } public function __destruct() { if (is_resource($this->smtpConnect)) fclose($this->smtpConnect); } } ?> ================================================ FILE: system/class/mail.php ================================================ _setting) $this->_load_setting(); return $this->_setting[$key]; } 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 mail_content { var $address; var $subject; var $message; } class mail_sender { var $obj; function __construct() { $sender = getSetting('mail_class'); $file = SYSTEM_ROOT."./class/mail/{$sender}.php"; if (file_exists($file)) { require_once $file; $this->obj = new $sender(); } } function sendMail($mail) { if (!$this->obj) return false; return $this->obj->send($mail); } } ================================================ FILE: system/class/multithread.php ================================================ = '{$time}'"); if($threadCount >= $max_thread) return false; DB::query("DELETE FROM process WHERE exptime < '{$time}'"); $time += $ttl; $pid = random(16); DB::query("INSERT INTO process SET exptime='{$time}', id='{$pid}'"); return true; } public static function newCronThread(){ global $siteurl, $real_siteurl; $url = $real_siteurl ? $real_siteurl : $siteurl; $matches = parse_url($url); $host = $matches['host']; $port = !empty($matches['port']) ? $matches['port'] : 80; $path = $matches['path'] ? $matches['path'] : '/'; $header = "GET {$path}cron.php HTTP/1.0\r\n"; $header .= "Accept: */*\r\n"; $header .= "Host: {$host}:{$port}\r\n"; $header .= "Connection: Close\r\n\r\n"; $fp = fsocketopen($host, $port); if(!$fp) return false; stream_set_timeout($fp, 1); @fwrite($fp, $header); @fgets($fp); fclose($fp); return true; } } ================================================ FILE: system/class/plugin.php ================================================ getPluginId() ]; return isset($vars[$key]) ? $vars[$key] : $default_value; } function saveSetting($key, $value){ $pluginid = $this->getPluginId(); $vars = CACHE::get('plugin'); if(!$vars) $vars = array(); if(!$vars[ $pluginid ]) $vars[ $pluginid ] = array(); $vars[ $pluginid ][ $key ] = $value; DB::query("REPLACE INTO plugin_var SET `key` = '".addslashes($key)."', `value` = '".addslashes($value)."', pluginid='".addslashes($pluginid)."'"); CACHE::clean('plugin'); } function checkCompatibility(){ return true; } function install(){ // install script } function uninstall(){ // uninstall script } function handleAction(){ throw new Exception('This plugin doesn\'t support to be called directly.'); } private function getPluginId(){ return str_replace('plugin_', '', get_class($this)); } } ================================================ FILE: system/class/updater.php ================================================ -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); } public static function write_file(){ $err_file = $files = array(); $query = DB::query('SELECT * FROM download ORDER BY path ASC'); while($file = DB::fetch($query)){ list($part, $path) = explode('|', $file['path'], 2); if(!$files[ $path ]){ $file['content'] = pack('H*', $file['content']); $files[ $path ] = $file; } else { $files[ $path ]['content'] .= pack('H*', $file['content']); } } if(!$files) return array('status' => -255); foreach($files as $path => $file) { if(!self::_is_writable(ROOT.$path)) $err_file[] = $path; } if($err_file) array('status' => -1, 'files' => $err_file); foreach($files as $path => $file) { self::_write(ROOT.$path, $file['content']); if(md5_file(ROOT.$path) != md5($file['content'])) return array('status' => -2, 'file' => $path); } DB::query('DELETE FROM download'); saveSetting('new_version', 0); return array('status' => 0); } private static function _write($path, $content){ $fp = @fopen($path, 'wb'); if(!$fp) return false; fwrite($fp, $content); fclose($fp); return true; } private static function _is_writable($path){ if(!file_exists($path)){ if(!file_exists(dirname($path))) @mkdir(dirname($path), 0777, true); @touch($path); @chmod($path, 0777); }else{ if(!is_writable($path)) @chmod($path, 0777); } return is_writable($path); } private static function _download_file($path, $hash, $try = 1) { $d = getSetting('channel') == 'dev' ? 'tieba_sign' : 'tieba_sign_stable'; $content = kk_fetch_url(self::UPDATE_SERVER."get_file.php?d={$d}&f={$path}"); if (!$content) { if ($try == 3) { return -1; } else { return self::_download_file($path, $hash, $try + 1); } } if (md5($content) != $hash) { if ($try == 3) { return -2; } else { return self::_download_file($path, $hash, $try + 1); } } $length = $part = 0; while($length < strlen($content)){ $part++; $part_length = strlen($content) - $length > 8192 ? 8192 : strlen($content) - $length; $_countent = substr($content, $length, $part_length); $length += $part_length; $_part = str_pad($part, 4, "0", STR_PAD_LEFT); DB::insert('download', array('path' => "{$_part}|".$path, 'content' => bin2hex($_countent))); } return 0; } private static function _getPluginList(){ $pluginList = array(); $list_dir = dir(ROOT.'./plugins/'); while($dirName = $list_dir->read()){ if($dirName == '.' || $dirName == '..' || !is_dir(ROOT."./plugins/{$dirName}")) continue; $pluginList[] = $dirName; } return $pluginList; } } ?> ================================================ FILE: system/class/widget/widget_password.php ================================================ XMLparse($isnormal); } function XMLparse($isnormal) { $this->isnormal = $isnormal; $this->parser = xml_parser_create('UTF-8'); xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, false); xml_set_object($this->parser, $this); xml_set_element_handler($this->parser, 'open','close'); xml_set_character_data_handler($this->parser, 'data'); } function destruct() { xml_parser_free($this->parser); } function parse(&$data) { $this->document = array(); $this->stack = array(); return xml_parse($this->parser, $data, true) && !$this->failed ? $this->document : ''; } function open(&$parser, $tag, $attributes) { $this->data = ''; $this->failed = FALSE; if(!$this->isnormal) { if(isset($attributes['id']) && !is_string($this->document[$attributes['id']])) { $this->document = &$this->document[$attributes['id']]; } else { $this->failed = TRUE; } } else { if(!isset($this->document[$tag]) || !is_string($this->document[$tag])) { $this->document = &$this->document[$tag]; } else { $this->failed = TRUE; } } $this->stack[] = &$this->document; $this->last_opened_tag = $tag; $this->attrs = $attributes; } function data(&$parser, $data) { if($this->last_opened_tag != NULL) { $this->data .= $data; } } function close(&$parser, $tag) { if($this->last_opened_tag == $tag) { $this->document = $this->data; $this->last_opened_tag = NULL; } array_pop($this->stack); if($this->stack) { $this->document = &$this->stack[count($this->stack)-1]; } } } ?> ================================================ FILE: system/common.inc.php ================================================ init(); $formhash = substr(md5(substr(TIMESTAMP, 0, -7).$username.$uid.ENCRYPT_KEY.ROOT), 8, 8); $sitepath = substr($_SERVER['PHP_SELF'], 0, strrpos($_SERVER['PHP_SELF'], '/')); $siteurl = htmlspecialchars(($_SERVER['SERVER_PORT'] == '443' ? 'https://' : 'http://').$_SERVER['HTTP_HOST'].$sitepath.'/'); ================================================ FILE: system/function/cache/cache_plugin.php ================================================ $result['name'], 'ver' => $result['version']); } ================================================ FILE: system/function/cache/cache_setting.php ================================================ $val) { $string[$key] = daddslashes($val, $force, $strip); } } else { $string = addslashes($strip ? stripslashes($string) : $string); } } return $string; } function template($file){ global $template_loaded; $template_loaded = false; HOOK::run(str_replace('/', '_', "template_load_{$file}")); $template_name = defined('IN_ADMINCP') ? 'default' : getSetting('template'); if(IN_MOBILE){ $mobilefile = ROOT."./template/{$template_name}/mobile/{$file}.php"; if(file_exists($mobilefile)) return $mobilefile; $mobilefile_default = ROOT."./template/default/mobile/{$file}.php"; if(file_exists($mobilefile_default)) return $mobilefile_default; } $path = ROOT."./template/{$template_name}/{$file}.php"; if(file_exists($path)) return $path; $path = ROOT."./template/default/{$file}.php"; if(file_exists($path)) return $path; error::system_error("Missing template '{$file}'."); } function dgmdate($timestamp, $d_format = 'Y-m-d H:i') { $timestamp += 8 * 3600; $todaytimestamp = TIMESTAMP - (TIMESTAMP + 8 * 3600) % 86400 + 8 * 3600; $s = gmdate($d_format, $timestamp); $time = TIMESTAMP + 8 * 3600 - $timestamp; if($timestamp >= $todaytimestamp) { if($time > 3600) { return ''.intval($time / 3600).' 小时前'; } elseif($time > 1800) { return '半小时前'; } elseif($time > 60) { return ''.intval($time / 60).' 分钟前'; } elseif($time > 0) { return ''.$time.' 秒前'; } elseif($time == 0) { return '刚刚'; } else { return $s; } } elseif(($days = intval(($todaytimestamp - $timestamp) / 86400)) >= 0 && $days < 7) { if($days == 0) { return '昨天 '.gmdate('H:i', $timestamp).''; } elseif($days == 1) { return '前天 '.gmdate('H:i', $timestamp).''; } else { return ''.($days + 1).' 天前'; } } else { return $s; } } function authcode($string, $operation = 'DECODE', $key = '', $expiry = 0) { $ckey_length = 4; $key = md5($key ? $key : ENCRYPT_KEY); $keya = md5(substr($key, 0, 16)); $keyb = md5(substr($key, 16, 16)); $keyc = $ckey_length ? ($operation == 'DECODE' ? substr($string, 0, $ckey_length): substr(md5(microtime()), -$ckey_length)) : ''; $cryptkey = $keya.md5($keya.$keyc); $key_length = strlen($cryptkey); $string = $operation == 'DECODE' ? base64_decode(substr($string, $ckey_length)) : sprintf('%010d', $expiry ? $expiry + time() : 0).substr(md5($string.$keyb), 0, 16).$string; $string_length = strlen($string); $result = ''; $box = range(0, 255); $rndkey = array(); for($i = 0; $i <= 255; $i++) { $rndkey[$i] = ord($cryptkey[$i % $key_length]); } for($j = $i = 0; $i < 256; $i++) { $j = ($j + $box[$i] + $rndkey[$i]) % 256; $tmp = $box[$i]; $box[$i] = $box[$j]; $box[$j] = $tmp; } for($a = $j = $i = 0; $i < $string_length; $i++) { $a = ($a + 1) % 256; $j = ($j + $box[$a]) % 256; $tmp = $box[$a]; $box[$a] = $box[$j]; $box[$j] = $tmp; $result .= chr(ord($string[$i]) ^ ($box[($box[$a] + $box[$j]) % 256])); } if($operation == 'DECODE') { if((substr($result, 0, 10) == 0 || substr($result, 0, 10) - time() > 0) && substr($result, 10, 16) == substr(md5(substr($result, 26).$keyb), 0, 16)) { return substr($result, 26); } else { return ''; } } else { return $keyc.str_replace('=', '', base64_encode($result)); } } function showmessage($msg = '', $redirect = '', $delay = 3){ if($_GET['format'] == 'json'){ $result = array('msg' => $msg, 'redirect' => $redirect, 'delay' => $delay); echo json_encode($result); exit(); } include template('message'); exit(); } function random($length, $numeric = 0) { $seed = base_convert(md5(microtime().$_SERVER['DOCUMENT_ROOT']), 16, $numeric ? 10 : 35); $seed = $numeric ? (str_replace('0', '', $seed).'012340567890') : ($seed.'zZ'.strtoupper($seed)); $hash = ''; $max = strlen($seed) - 1; for($i = 0; $i < $length; $i++) { $hash .= $seed{mt_rand(0, $max)}; } return $hash; } function dreferer(){ return $_SERVER['HTTP_REFERER'] && !strexists($_SERVER['HTTP_REFERER'], 'member') ? $_SERVER['HTTP_REFERER'] : './'; } function strexists($string, $find) { return !(strpos($string, $find) === FALSE); } function cutstr($string, $length, $dot = ' ...') { if(strlen($string) <= $length) return $string; $pre = chr(1); $end = chr(1); $string = str_replace(array('&', '"', '<', '>'), array($pre.'&'.$end, $pre.'"'.$end, $pre.'<'.$end, $pre.'>'.$end), $string); $strcut = ''; $n = $tn = $noc = 0; while($n < strlen($string)) { $t = ord($string[$n]); if($t == 9 || $t == 10 || (32 <= $t && $t <= 126)) { $tn = 1; $n++; $noc++; } elseif(194 <= $t && $t <= 223) { $tn = 2; $n += 2; $noc += 2; } elseif(224 <= $t && $t <= 239) { $tn = 3; $n += 3; $noc += 2; } elseif(240 <= $t && $t <= 247) { $tn = 4; $n += 4; $noc += 2; } elseif(248 <= $t && $t <= 251) { $tn = 5; $n += 5; $noc += 2; } elseif($t == 252 || $t == 253) { $tn = 6; $n += 6; $noc += 2; } else { $n++; } if($noc >= $length) break; } if($noc > $length) $n -= $tn; $strcut = substr($string, 0, $n); $strcut = str_replace(array($pre.'&'.$end, $pre.'"'.$end, $pre.'<'.$end, $pre.'>'.$end), array('&', '"', '<', '>'), $strcut); $pos = strrpos($strcut, chr(1)); if($pos !== false) $strcut = substr($strcut,0,$pos); return $strcut.$dot; } function wrap_text($str) { $str = trim($str); $str = str_replace("\t", '', $str); $str = str_replace("\r", '', $str); $str = str_replace("\n", '', $str); $str = str_replace(' ', '', $str); return trim($str); } function get_cookie($uid){ static $cookie = array(); if($cookie[$uid]) return $cookie[$uid]; $cookie[$uid] = DB::result_first("SELECT cookie FROM member_setting WHERE uid='{$uid}'"); //$cookie[$uid] = strrev(str_rot13(pack('H*', $cookie[$uid]))); return $cookie[$uid]; } function save_cookie($uid, $cookie){ //$cookie = bin2hex(str_rot13(strrev(addslashes($cookie)))); DB::query("UPDATE member_setting SET cookie='{$cookie}' WHERE uid='{$uid}'"); } function get_username($uid){ static $username = array(); if($username[$uid]) return $username[$uid]; $username = CACHE::get('username'); return $username[$uid]; } 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 getSetting($k, $force = false){ if($force) return $setting[$k] = DB::result_first("SELECT v FROM setting WHERE k='{$k}'"); $cache = CACHE::get('setting'); return $cache[$k]; } function saveSetting($k, $v){ if(!defined('IN_XAE') && $k == 'version') return saveVersion($v); static $cache_cleaned = false; $v = addslashes($v); DB::query("REPLACE INTO setting SET v='{$v}', k='{$k}'"); if($cache_cleaned) return; CACHE::clean('setting'); $cache_cleaned = true; } function runquery($sql){ $sql = str_replace("\r", "\n", $sql); foreach(explode(";\n", trim($sql)) as $query) { $query = trim($query); if($query) DB::query($query); } } function jquery_path(){ $path = defined('IN_ADMINCP') ? 0 : getSetting('jquery_mode'); switch($path){ case 'google': return '//ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js'; case 'microsoft': return '//ajax.aspnetcdn.com/ajax/jQuery/jquery-1.12.4.min.js'; case 'cloudflare': return '//cdnjs.cloudflare.com/ajax/libs/jquery/1.12.4/jquery.min.js'; case 'jsdelivr': return '//cdn.jsdelivr.net/jquery/1.12.4/jquery.min.js'; case 'lug-ustc': return '//ajax.lug.ustc.edu.cn/ajax/libs/jquery/1.12.4/jquery.min.js'; default: case 'builtin': return 'system/js/jquery.min.js'; } } function kk_fetch_url($url, $limit = 0, $post = '', $cookie = '', $ignore = FALSE, $ip = '', $timeout = 15, $block = TRUE, $encodetype = 'URLENCODE', $allowcurl = TRUE, $position = 0) { $return = ''; $matches = parse_url($url); $scheme = $matches['scheme']; $host = $matches['host']; $path = $matches['path'] ? $matches['path'].($matches['query'] ? '?'.$matches['query'] : '') : '/'; $port = !empty($matches['port']) ? $matches['port'] : 80; if(function_exists('curl_init') && function_exists('curl_exec') && $allowcurl) { $ch = curl_init(); $ip && curl_setopt($ch, CURLOPT_HTTPHEADER, array("Host: ".$host)); curl_setopt($ch, CURLOPT_URL, $scheme.'://'.($ip ? $ip : $host).':'.$port.$path); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); if($post) { curl_setopt($ch, CURLOPT_POST, 1); if($encodetype == 'URLENCODE') { curl_setopt($ch, CURLOPT_POSTFIELDS, $post); } else { parse_str($post, $postarray); curl_setopt($ch, CURLOPT_POSTFIELDS, $postarray); } } if($cookie) { curl_setopt($ch, CURLOPT_COOKIE, $cookie); } curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); $data = curl_exec($ch); $status = curl_getinfo($ch); $errno = curl_errno($ch); curl_close($ch); if($errno || $status['http_code'] != 200) { return; } else { return !$limit ? $data : substr($data, 0, $limit); } } if($post) { $out = "POST $path HTTP/1.0\r\n"; $header = "Accept: */*\r\n"; $header .= "Accept-Language: zh-cn\r\n"; $boundary = $encodetype == 'URLENCODE' ? '' : '; boundary='.trim(substr(trim($post), 2, strpos(trim($post), "\n") - 2)); $header .= $encodetype == 'URLENCODE' ? "Content-Type: application/x-www-form-urlencoded\r\n" : "Content-Type: multipart/form-data$boundary\r\n"; $header .= "User-Agent: $_SERVER[HTTP_USER_AGENT]\r\n"; $header .= "Host: $host:$port\r\n"; $header .= 'Content-Length: '.strlen($post)."\r\n"; $header .= "Connection: Close\r\n"; $header .= "Cache-Control: no-cache\r\n"; $header .= "Cookie: $cookie\r\n\r\n"; $out .= $header.$post; } else { $out = "GET $path HTTP/1.0\r\n"; $header = "Accept: */*\r\n"; $header .= "Accept-Language: zh-cn\r\n"; $header .= "User-Agent: $_SERVER[HTTP_USER_AGENT]\r\n"; $header .= "Host: $host:$port\r\n"; $header .= "Connection: Close\r\n"; $header .= "Cookie: $cookie\r\n\r\n"; $out .= $header; } $fpflag = 0; if(!$fp = @fsocketopen(($ip ? $ip : $host), $port, $errno, $errstr, $timeout)) { $context = array( 'http' => array( 'method' => $post ? 'POST' : 'GET', 'header' => $header, 'content' => $post, 'timeout' => $timeout, ), ); $context = stream_context_create($context); $fp = @fopen($scheme.'://'.($ip ? $ip : $host).':'.$port.$path, 'b', false, $context); $fpflag = 1; } if(!$fp) { return ''; } else { stream_set_blocking($fp, $block); stream_set_timeout($fp, $timeout); @fwrite($fp, $out); if($ignore){ @fclose($fp); return; } $status = stream_get_meta_data($fp); if(!$status['timed_out']) { while (!feof($fp) && !$fpflag) { if(($header = @fgets($fp)) && ($header == "\r\n" || $header == "\n")) { break; } } if($position) { for($i=0; $i<$position; $i++) { $char = fgetc($fp); if($char == "\n" && $oldchar != "\r") { $i++; } $oldchar = $char; } } if($limit) { $return = stream_get_contents($fp, $limit); } else { $return = stream_get_contents($fp); } } @fclose($fp); return $return; } } function fsocketopen($hostname, $port = 80, &$errno, &$errstr, $timeout = 15) { $fp = ''; if(function_exists('fsockopen')) { $fp = @fsockopen($hostname, $port, $errno, $errstr, $timeout); } elseif(function_exists('pfsockopen')) { $fp = @pfsockopen($hostname, $port, $errno, $errstr, $timeout); } elseif(function_exists('stream_socket_client')) { $fp = @stream_socket_client($hostname.':'.$port, $errno, $errstr, $timeout); } return $fp; } function xml2array(&$xml, $isnormal = FALSE) { $xml_parser = new XMLparse($isnormal); $data = $xml_parser->parse($xml); $xml_parser->destruct(); return $data; } function array2xml($arr, $htmlon = TRUE, $isnormal = FALSE, $level = 1) { $s = $level == 1 ? "\r\n\r\n" : ''; $space = str_repeat("\t", $level); foreach($arr as $k => $v) { if(!is_array($v)) { $s .= $space."".($htmlon ? '' : '')."\r\n"; } else { $s .= $space."\r\n".array2xml($v, $htmlon, $isnormal, $level + 1).$space."\r\n"; } } $s = preg_replace("/([\x01-\x08\x0b-\x0c\x0e-\x1f])+/", ' ', $s); return $level == 1 ? $s."" : $s; } function save_config_file(){ global $_config; if (!$_config) return; $content = ''; if(!is_writable(SYSTEM_ROOT.'./config.inc.php')) throw new Exception('Config file is not writable!'); file_put_contents(SYSTEM_ROOT.'./config.inc.php', $content); } function saveVersion($version){ global $_config; if (!$_config) return; $_config['version'] = $version; save_config_file(); } function mklink($sourceFile, $targetFile){ return @file_put_contents($targetFile, ''); } function cron_set_nextrun($timestamp){ if(!defined('CRON_ID')) throw new Exception('Unknown cron id'); $timestamp = intval($timestamp); DB::query("UPDATE cron SET nextrun='{$timestamp}' WHERE id='".addslashes(CRON_ID)."'"); $nextrun = DB::fetch_first("SELECT nextrun FROM cron ORDER BY nextrun ASC LIMIT 0,1"); saveSetting('next_cron', $nextrun ? $nextrun['nextrun'] : TIMESTAMP + 1200); } // Function link function get_tbs($uid){ require_once SYSTEM_ROOT.'./function/sign.php'; return _get_tbs($uid); } function verify_cookie($cookie){ require_once SYSTEM_ROOT.'./function/sign.php'; return _verify_cookie($cookie); } function get_baidu_userinfo($uid){ require_once SYSTEM_ROOT.'./function/sign.php'; return _get_baidu_userinfo($uid); } function client_sign($uid, $tieba){ require_once SYSTEM_ROOT.'./function/sign.php'; return _client_sign($uid, $tieba); } function zhidao_sign($uid){ require_once SYSTEM_ROOT.'./function/sign.php'; return _zhidao_sign($uid); } function wenku_sign($uid){ require_once SYSTEM_ROOT.'./function/sign.php'; return _wenku_sign($uid); } function update_liked_tieba($uid, $ignore_error = false, $allow_deletion = true){ require_once SYSTEM_ROOT.'./function/sign.php'; return _update_liked_tieba($uid, $ignore_error, $allow_deletion); } function get_liked_tieba($cookie){ require_once SYSTEM_ROOT.'./function/sign.php'; return _get_liked_tieba($cookie); } function do_login($uid){ require_once SYSTEM_ROOT.'./function/member.php'; _do_login($uid); } function do_register($username,$password,$email){ require_once SYSTEM_ROOT.'./function/member.php'; return _do_register($username,$password,$email); } function delete_user($uid){ require_once SYSTEM_ROOT.'./function/member.php'; _delete_user($uid); } ================================================ FILE: system/function/member.php ================================================ $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='{$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; } ================================================ FILE: system/function/sae.php ================================================ array( 'server' => SAE_MYSQL_HOST_M, 'port' => SAE_MYSQL_PORT, 'username' => SAE_MYSQL_USER, 'password' => SAE_MYSQL_PASS, 'name' => SAE_MYSQL_DB, 'pconnect' => false, ), ); $real_siteurl = 'http://'.$_SERVER['HTTP_APPNAME'].'.sinaapp.com/'; ?> ================================================ FILE: system/function/sign.php ================================================ 4); $tbs_url = 'http://tieba.baidu.com/f/user/json_userinfo'; $ch = curl_init($tbs_url); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Referer: http://tieba.baidu.com/')); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_COOKIE, $cookie); $tbs_json = curl_exec($ch); curl_close($ch); $tbs_json = mb_convert_encoding($tbs_json, "utf8", "gbk"); return json_decode($tbs_json, true); } function _get_liked_tieba($cookie){ $pn = 0; $kw_name = array(); $retry = 0; while (true){ $pn++; $mylikeurl = "http://tieba.baidu.com/f/like/mylike?&pn=$pn"; $result = kk_fetch_url($mylikeurl, 0, '', $cookie); $result = wrap_text($result); $pre_reg = '/.*? $value) { $uname = urlencode($value); $_uname = preg_quote($value); preg_match('/balvid="([0-9]+)"/i', $result, $fid); $kw_name[] = array( 'name' => mb_convert_encoding($value, 'utf-8', 'gbk'), 'uname' => $uname, 'fid' => $fid[1], ); $count++; } if ($count==0) { if ($retry >= 2) break; $retry++; $pn--; continue; } $retry = 0; } return $kw_name; } function _update_liked_tieba($uid, $ignore_error = false, $allow_deletion = true){ $date = date('Ymd', TIMESTAMP + 900); $cookie = get_cookie($uid); if(!$cookie){ if($ignore_error) return; showmessage('请先填写 Cookie 信息再更新', './#baidu_bind'); } $liked_tieba = get_liked_tieba($cookie); $insert = $deleted = 0; if(!$liked_tieba){ if($ignore_error) return; showmessage('无法获取喜欢的贴吧,请更新 Cookie 信息', './#baidu_bind'); } if($limit = getSetting('max_tieba')){ $count = count($liked_tieba); if($limit < $count){ if($ignore_error) return; showmessage("

    您共计关注了 {$count} 个贴吧,

    管理员限制了每位用户最多关注 {$limit} 个贴吧

    ", './#liked_tieba'); } } $my_tieba = array(); $query = DB::query("SELECT name, fid, tid FROM my_tieba WHERE uid='{$uid}'"); while($r = DB::fetch($query)) { $my_tieba[$r['name']] = $r; } foreach($liked_tieba as $tieba){ if($my_tieba[$tieba['name']]){ unset($my_tieba[$tieba['name']]); if(!$my_tieba[$tieba['name']]['fid']) DB::update('my_tieba', array( 'fid' => $tieba['fid'], ), array( 'uid' => $uid, 'name' => $tieba['name'], ), true); continue; }else{ DB::insert('my_tieba', array( 'uid' => $uid, 'fid' => $tieba['fid'], 'name' => $tieba['name'], 'unicode_name' => $tieba['uname'], ), false, true, true); $insert++; } } DB::query("INSERT IGNORE INTO sign_log (tid, uid, `date`) SELECT tid, uid, '{$date}' FROM my_tieba"); if($my_tieba && $allow_deletion){ $tieba_ids = array(); foreach($my_tieba as $tieba){ $tieba_ids[] = $tieba['tid']; } $str = "'".implode("', '", $tieba_ids)."'"; $deleted = count($my_tieba); DB::query("DELETE FROM my_tieba WHERE uid='{$uid}' AND tid IN ({$str})"); DB::query("DELETE FROM sign_log WHERE uid='{$uid}' AND tid IN ({$str})"); } return array($insert, $deleted); } function _client_sign($uid, $tieba){ $cookie = get_cookie($uid); preg_match('/BDUSS=([^ ;]+);/i', $cookie, $matches); $BDUSS = trim($matches[1]); if(!$BDUSS) return array(-1, '找不到 BDUSS Cookie', 0); $ch = curl_init('http://c.tieba.baidu.com/c/c/forum/sign'); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded', 'User-Agent: Mozilla/5.0 (SymbianOS/9.3; Series60/3.2 NokiaE72-1/021.021; Profile/MIDP-2.1 Configuration/CLDC-1.1 ) AppleWebKit/525 (KHTML, like Gecko) Version/3.0 BrowserNG/7.1.16352')); curl_setopt($ch, CURLOPT_COOKIE, $cookie); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POST, 1); $array = array( 'BDUSS' => $BDUSS, '_client_id' => '03-00-DA-59-05-00-72-96-06-00-01-00-04-00-4C-43-01-00-34-F4-02-00-BC-25-09-00-4E-36', '_client_type' => '4', '_client_version' => '1.2.1.17', '_phone_imei' => '540b43b59d21b7a4824e1fd31b08e9a6', 'fid' => $tieba['fid'], 'kw' => urldecode($tieba['unicode_name']), 'net_type' => '3', 'tbs' => get_tbs($uid), ); $sign_str = ''; foreach($array as $k=>$v) $sign_str .= $k.'='.$v; $sign = strtoupper(md5($sign_str.'tiebaclient!!!')); $array['sign'] = $sign; curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($array)); $sign_json = curl_exec($ch); curl_close($ch); $res = @json_decode($sign_json, true); if(!$res) return array(1, 'JSON 解析错误', 0); if($res['user_info']){ $exp = $res['user_info']['sign_bonus_point']; return array(2, "签到成功,经验值上升 {$exp}", $exp); }else{ switch($res['error_code']){ case '340010': // 已经签过 case '160002': case '3': return array(2, $res['error_msg'], 0); case '1': // 未登录 return array(-1, "ERROR-{$res[error_code]}: ".$res['error_msg'].' (Cookie 过期或不正确)', 0); case '160004': // 不支持 return array(-1, "ERROR-{$res[error_code]}: ".$res['error_msg'], 0); case '160003': // 零点 稍后再试 case '160008': // 太快了 return array(1, "ERROR-{$res[error_code]}: ".$res['error_msg'], 0); default: return array(1, "ERROR-{$res[error_code]}: ".$res['error_msg'], 0); } } } function _client_sign_old($uid, $tieba){ $cookie = get_cookie($uid); preg_match('/BDUSS=([^ ;]+);/i', $cookie, $matches); $BDUSS = trim($matches[1]); if(!$BDUSS) return array(-1, '找不到 BDUSS Cookie', 0); $ch = curl_init('http://c.tieba.baidu.com/c/c/forum/sign'); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded', 'User-Agent: BaiduTieba for Android 5.1.3', 'client_user_token: '.random(6, true))); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POST, 1); $array = array( 'BDUSS' => $BDUSS, '_client_id' => 'wappc_138'.random(10, true).'_'.random(3, true), '_client_type' => '2', '_client_version' => '5.1.3', '_phone_imei' => md5(random(16, true)), 'cuid' => strtoupper(md5(random(16))).'|'.random(15, true), 'fid' => $tieba['fid'], 'from' => 'tieba', 'kw' => urldecode($tieba['unicode_name']), 'model' => 'Aries', 'net_type' => '3', 'stErrorNums' => '0', 'stMethod' => '1', 'stMode' => '1', 'stSize' => random(5, true), 'stTime' => random(4, true), 'stTimesNum' => '0', 'tbs' => get_tbs($uid), 'timestamp' => time().rand(1000, 9999), ); $sign_str = ''; foreach($array as $k=>$v) $sign_str .= $k.'='.$v; $sign = strtoupper(md5($sign_str.'tiebaclient!!!')); $array['sign'] = $sign; curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($array)); $sign_json = curl_exec($ch); curl_close($ch); $res = @json_decode($sign_json, true); if(!$res) return array(1, 'JSON 解析错误', 0); if($res['user_info']){ $exp = $res['user_info']['sign_bonus_point']; return array(2, "签到成功,经验值上升 {$exp}", $exp); }else{ switch($res['error_code']){ case '340010': // 已经签过 case '160002': case '3': return array(2, $res['error_msg'], 0); case '1': // 未登录 return array(-1, "ERROR-{$res[error_code]}: ".$res['error_msg'].' (Cookie 过期或不正确)', 0); case '160004': // 不支持 return array(-1, "ERROR-{$res[error_code]}: ".$res['error_msg'], 0); case '160003': // 零点 稍后再试 case '160008': // 太快了 return array(1, "ERROR-{$res[error_code]}: ".$res['error_msg'], 0); default: return array(1, "ERROR-{$res[error_code]}: ".$res['error_msg'], 0); } } } function _zhidao_sign($uid){ $ch = curl_init('http://zhidao.baidu.com/submit/user'); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded')); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_COOKIE, get_cookie($uid)); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, 'cm=100509&t='.TIMESTAMP); $result = curl_exec($ch); curl_close($ch); return @json_decode($result); } function _wenku_sign($uid){ $ch = curl_init('http://wenku.baidu.com/task/submit/signin'); curl_setopt($ch, CURLOPT_HTTPHEADER, array('User-Agent: Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.43 BIDUBrowser/2.x Safari/537.31')); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_COOKIE, get_cookie($uid)); $result = curl_exec($ch); curl_close($ch); return @json_decode($result); } ================================================ FILE: system/function/updater/1.13.php ================================================
    请修改计划任务为以下内容:
    http://域名/cron.php   * * * * *(每分钟一次)'); }elseif($current_version == '1.13.9.4'){ DB::insert('cron', array( 'id' => 'sign_retry', 'enabled' => 1, 'nextrun' => TIMESTAMP, 'order' => '110', )); saveSetting('version', '1.13.10.6'); showmessage('成功更新到 1.13.10.6!', './'); }elseif($current_version == '1.13.10.6'){ DB::query('ALTER TABLE `member` CHANGE `username` `username` VARCHAR(24)'); saveSetting('version', '1.13.10.13'); showmessage('成功更新到 1.13.10.13!', './', 1); }elseif($current_version == '1.13.10.13'){ DB::query('ALTER TABLE `my_tieba` DROP INDEX `name`'); DB::query('ALTER TABLE `my_tieba` ADD INDEX (`uid`)'); DB::query('ALTER TABLE `member_setting` DROP `use_bdbowser`, DROP `sign_method`'); saveSetting('version', '1.13.10.20'); showmessage('成功更新到 1.13.10.20!', './'); }elseif($current_version == '1.13.10.20'){ saveSetting('version', '1.13.11.5'); showmessage('成功更新到 1.13.11.5!', './'); }elseif($current_version == '1.13.11.5'){ DB::query(' CREATE TABLE IF NOT EXISTS `plugin` ( id int(11) NOT NULL AUTO_INCREMENT, `name` varchar(64) NOT NULL, module text NOT NULL, PRIMARY KEY (id), UNIQUE KEY `name` (`name`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 '); DB::insert('plugin', array('name' => 'debug_info')); DB::insert('plugin', array('name' => 'update_log')); saveSetting('version', '1.13.11.9'); showmessage('成功更新到 1.13.11.9!', './'); }elseif($current_version == '1.13.11.9'){ runquery(" ALTER TABLE `plugin` ADD `enable` TINYINT(1) NOT NULL DEFAULT '1' AFTER `id`; ALTER TABLE `plugin` ADD `version` VARCHAR(8) NOT NULL DEFAULT '0'; ALTER TABLE `member_setting` ADD `cookie` TEXT BINARY CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL; "); $query = DB::query('SELECT uid, cookie FROM member'); while($result = DB::fetch($query)){ save_cookie($result['uid'], $result['cookie']); } DB::query('ALTER TABLE `member` DROP `cookie`'); $query = DB::query('SHOW columns FROM `plugin`'); while($result = DB::fetch($query)){ if($result['Field'] == 'module') DB::query('ALTER TABLE `plugin` DROP `module`'); } CACHE::clear(); CACHE::update('plugins'); saveSetting('register_limit', 1); saveSetting('register_check', 1); saveSetting('jquery_mode', 2); saveSetting('version', '1.13.12.15'); showmessage('成功更新到 1.13.12.15!', './'); }elseif($current_version == '1.13.12.15'){ saveSetting('version', '1.13.12.25'); showmessage('成功更新到 1.13.12.25!', './'); }elseif($current_version == '1.13.12.25'){ if($_config['adminid']) saveSetting('admin_uid', $_config['adminid']); saveSetting('version', '1.14.1.15'); showmessage('成功更新到 1.14.1.15!', './'); } ?> ================================================ FILE: system/function/updater/1.14.1.15.php ================================================ ================================================ FILE: system/function/updater/1.14.1.16.php ================================================ ================================================ FILE: system/function/updater/1.14.1.23.php ================================================ ================================================ FILE: system/function/updater/1.14.2.6.php ================================================ ================================================ FILE: system/function/updater/1.14.4.12.php ================================================ ================================================ FILE: system/function/updater/1.14.4.14.php ================================================ ================================================ FILE: system/function/updater/1.14.4.24.php ================================================ ================================================ FILE: system/function/updater/1.14.5.12.php ================================================ ================================================ FILE: system/function/updater/1.14.5.20.php ================================================ ================================================ FILE: system/function/updater/1.14.5.27.php ================================================ ================================================ FILE: system/function/updater/1.14.6.2.php ================================================ Error while upgrade from version {$current_version} to version ".VERSION.'.'); ?> ================================================ FILE: template/default/admin.php ================================================ 管理中心 - 贴吧签到助手
    载入中...

    贴吧签到助手 - 管理中心

    正在加载 jQuery 组件...

    首次加载需要较长时间,请您耐心等待.

    jQuery 加载完成前,您暂时无法操作本页面.


    如果您长时间停留在此页面,请手动刷新网页.

    '; ?> ================================================ FILE: template/default/index.php ================================================ <?php echo $title; ?>
    载入中...

    正在加载 jQuery 组件...

    首次加载需要较长时间,请您耐心等待.

    jQuery 加载完成前,您暂时无法操作本页面.


    如果您长时间停留在此页面,请手动刷新网页.

    ================================================ FILE: template/default/js/admin.js ================================================ $(document).ready(function() { $('#menu>li').click(function (){ if(isMobile()) $('.sidebar').fadeOut(); if(!$(this).attr('id')) return; if($(this).hasClass('selected')) return; $('.menu li.selected').removeClass('selected'); $(this).addClass('selected'); var content_id = $(this).attr('id').replace('menu_', '#content-'); $('.main-content>div').addClass('hidden'); $(content_id).removeClass('hidden'); var callback = $(this).attr('id').replace('menu_', 'load_'); eval('if (typeof '+callback+' == "function") '+callback+'(); '); }); $('#content-updater .filelist button').click(function(){ $('#content-updater .filelist').hide(); $('#content-updater .result').html('正在更新系统文件,请耐心等待...'); updater_get_file(); }); $('#switch_to_dev').click(function(){ switch_channel('dev', '

    确定要切换到开发版么?

    开发版具有一定的不稳定性,且有可能无法切换回稳定版

    '); }); $('#switch_to_stable').click(function(){ switch_channel('stable', '

    确定要切换到稳定版么?

    如果开发版版本号与稳定版不同,可能导致系统无法使用。
    切换前请慎重考虑!

    '); }); var copyright_time = 0, copyright_clicks = 1; $('.copyright').click(function(){ console.log('You\'d clicked copyright text :D'); if(AF == 1) return; if(Date.now() - copyright_time > 500){ copyright_time = Date.now(); copyright_clicks = 1; return; } copyright_time = Date.now(); if(copyright_clicks < 7){ copyright_clicks++; } else { var fwin = createWindow(); var contents = ''; contents += '

    To avoid the abuse of these tools, this dialog has been written in English.

    '; contents += '

    These tools are more helpful is you are a professional user.

    '; contents += '

    Some of these fetures may be harmful to your site, and we DON\'T take any responsibility. please comfirm you\'d read this.

    '; contents += '

    '; fwin.setTitle('Enable Advanced Fetures?').setContent(contents).addCloseButton('Dismiss').append(); } }); $('#reset_failure_all').click(function(){ createWindow().setTitle("全部重置").setContent('你确定要重置所有用户无法签到的贴吧吗?这将消耗大量服务器资源').addButton("确定", function(){msg_callback_action('admin.php?action=reset_failure&formhash='+formhash,load_stat);}).addCloseButton("取消").append(); }); $('#mail_advanced_config').click(function(){ post_win($('#mail_setting').attr('action'), 'mail_setting', function(){ showloading(); $.getJSON("admin.php?action=mail_advanced", function(result){ if(!result) return; var content = ''; for(var i=0; i

    '; content += ''; content += '

    '; } if(result.length == 0){ content += '

    此邮件接口无高级设置项目

    '; } createWindow().setTitle('邮件高级设置').setContent('
    '+content+'
    ').addButton('确定', function(){ $('#advanced_mail_config').submit(); }).addCloseButton('取消').append(); }).fail(function() { createWindow().setTitle('邮件高级设置').setContent('发生未知错误: 无法打开高级设置面板').addCloseButton('确定').append(); }).always(function(){ hideloading(); }); }, true); return false; }); $('.menubtn').click(function(){ $('.sidebar').fadeIn(); autohide_sidebar(); }); $(window).on('hashchange', function() { parse_hash(); }); hideloading(); while(location.hash.lastIndexOf('#') > 0) location.hash = location.hash.substring(0, location.hash.lastIndexOf('#')); parse_hash(); }); function load_user(){ showloading(); $.getJSON("admin.php?action=load_user", function(result){ if(!result) return; $('#content-user table tbody').html(''); $.each(result, function(i, field){ $("#content-user table tbody").append(""+field.uid+""+field.username+""+field.email+""+(isMobile() ? '刷新' : '刷新喜欢的贴吧')+" | "+(isMobile() ? '删除' : '删除用户')+""); }); }).fail(function() { createWindow().setTitle('系统错误').setContent('发生未知错误: 无法获取用户列表').addCloseButton('确定').append(); }).always(function(){ hideloading(); }); } function switch_channel(channel, tips){ createWindow().setTitle('切换分支').setContent(tips).addButton('确定', function(){ msg_redirect_action("admin.php?action=switch_channel&channel="+channel+"&formhash="+formhash); }).addCloseButton('取消').append(); } function updater_get_file(){ $.getJSON("admin.php?action=get_file", function(result){ if(!result) return; if(result.status == 1){ return updater_write_file(); }else if(result.status < 0){ $('#content-updater .result').html('更新过程出现错误!'); switch(result.status){ case -1: $('#content-updater .result').append('下载文件 '+result.file+' 失败'); break; case -2: $('#content-updater .result').append('校验文件 '+result.file+' 出错'); break; case -3: $('#content-updater .result').append('当前环境不支持自动更新,请使用论坛提供的 SVN 更新工具进行更新'); break; } setTimeout(function(){ location.reload(); }, 10000); return; } $('#content-updater .result').html('正在下载 '+result.file+',请耐心等待... ('+result.precent+'%)'); setTimeout(updater_get_file, 50); }).fail(function() { $('#content-updater .result').html('发生未知错误: 程序意外终止'); setTimeout(load_updater, 3000); }); } function updater_write_file(){ $.getJSON("admin.php?action=write_file", function(result){ if(!result) return; if(result.status == -1){ $('#content-updater .result').html('以下文件不可写入,请设置好权限后再进行升级'); $('#content-updater .filelist').show(); $('#content-updater .filelist ul').html(''); $.each(result.files, function(i, field){ $('#content-updater .filelist ul').append('
  • '+field+'
  • '); }); return; }else if(result.status == -2){ $('#content-updater .result').html('更新过程出现错误!'); switch(result._status){ case -1: $('#content-updater .result').append('下载文件 '+result.file+' 失败'); break; case -2: $('#content-updater .result').append('校验文件 '+result.file+' 出错'); break; } setTimeout(function(){ location.reload(); }, 5000); return; } $('#content-updater .result').html('文件更新结束!'); setTimeout(function(){ location.reload(); }, 1500); }).fail(function() { $('#content-updater .result').html('发生未知错误: 程序意外终止'); setTimeout(load_updater, 3000); }); } function load_stat(){ showloading(); $.getJSON("admin.php?action=load_userstat", function(result){ if(!result) return; $('#content-stat table tbody').html(''); $.each(result, function(i, field){ if(parseInt(field.unsupport) > 0) field.unsupport += ' (重置)'; $("#content-stat table tbody").append(""+field.uid+""+field.username+""+field.succeed+""+field.skiped+""+field.waiting+""+field.retry+""+field.unsupport+""); }); }).fail(function() { createWindow().setTitle('系统错误').setContent('发生未知错误: 无法获取用户统计数据').addCloseButton('确定').append(); }).always(function(){ hideloading(); }); } function load_updater(){ $('#content-updater .filelist').hide(); $('#content-updater .result').html('正在检查更新...'); $.getJSON("admin.php?action=update_check", function(result){ if(!result) return; if(result.status<0){ $('#content-updater .result').html('错误: 与更新服务器断开连接'); return; }else if(result.status == 0){ $('#content-updater .result').html('所有文件都是最新的!'); return; } $('#content-updater .result').html('以下文件可以更新: '); $('#content-updater .filelist').show(); $('#content-updater .filelist ul').html(''); $.each(result.files, function(i, field){ $('#content-updater .filelist ul').append('
  • '+field+'
  • '); }); }).fail(function() { createWindow().setTitle('系统错误').setContent('发生未知错误: 无法获取数据').addCloseButton('确定').append(); }); } function load_setting(){ showloading(); $.getJSON("admin.php?action=load_setting", function(result){ if(!result) return; $('#account_switch').attr('checked', result.account_switch == 1); $('#register_check').attr('checked', result.register_check == 1); $('#register_limit').attr('checked', result.register_limit == 1); $('#autoupdate').attr('checked', result.autoupdate == 1); $('#block_register').attr('checked', result.block_register == 1); $('#invite_code').attr('value', result.invite_code ? result.invite_code : ''); $('#beian_no').attr('value', result.beian_no ? result.beian_no : ''); $('#stat_code').html(result.stat_code ? result.stat_code : ''); $('#max_tieba').val(result.max_tieba); $('#extra_title').val(result.extra_title); if(AF == 1) $('#admin_uid').val(result.admin_uid); $('input[name=jquery_mode]').attr('checked', false); var target = $('input[name="jquery_mode"][value="' + result.jquery_mode + '"]'); if (target.length == 0) target = $('input[name="jquery_mode"]').eq(0); target.prop('checked', true); }).fail(function() { createWindow().setTitle('系统错误').setContent('发生未知错误: 无法获取当前系统设置').addCloseButton('确定').append(); }).always(function(){ hideloading(); }); } function load_cron(){ showloading(); $.getJSON("admin.php?action=load_cron", function(result){ if(!result) return; $('#content-cron table tbody').html(''); $.each(result, function(i, field){ var content = ''; content += ''; content += ''+(i+1)+''; content += ''+field.type+''; content += ''+field.id+''; if(field.nextrun > 0){ content += ''+format_time(field.nextrun)+'后'; content += '执行完毕'; }else{ content += ''+format_time(-field.nextrun)+'前'; content += AF == 1 ? '队列中 (跳过)' : '队列中'; } content += ''; $('#content-cron table tbody').append(content); }); }).fail(function() { createWindow().setTitle('系统错误').setContent('发生未知错误: 无法获取计划任务列表').addCloseButton('确定').append(); }).always(function(){ hideloading(); }); } function format_time(time){ if(time > 604800){ return '>7天'; }else if(time > 86400){ return Math.floor(time / 86400)+'天'; }else if(time > 3600){ return Math.floor(time / 3600)+'小时'; }else if(time > 60){ return Math.floor(time / 60)+'分钟'; }else{ return time+'秒'; } } function load_plugin(){ showloading(); $.getJSON("admin.php?action=load_plugin", function(result){ if(!result) return; $('#content-plugin table tbody').html(''); $.each(result, function(i, field){ var mod_actions = ''; if(field.installed){ if(field.enabled){ mod_actions += '禁用 | '; if(field.config) mod_actions += '设置 | '; }else{ mod_actions += '启用 | '; } mod_actions += '卸载'; }else{ mod_actions += '安装'; } $("#content-plugin table tbody").append(""+(i+1)+""+field.id+""+field.description+""+field.version+""+mod_actions+""); }); $('.link_enable, .link_disable').click(function(){ return msg_callback_action(this.href, load_plugin); }); $('.link_install').click(function(){ var link = this.href; createWindow().setTitle('安装插件').setContent('

    确定要安装这个插件吗?

    ').addButton('确定', function(){ msg_callback_action(link, load_plugin); }).addCloseButton('取消').append(); return false; }); $('.link_uninstall').click(function(){ var link = this.href; createWindow().setTitle('卸载插件').setContent('

    确定要卸载这个插件吗?

    (卸载后该插件的数据可能会丢失)

    ').addButton('确定', function(){ msg_callback_action(link, load_plugin); }).addCloseButton('取消').append(); return false; }); $('.link_config').click(function(){ var link = this.href; showloading(); $.getJSON(link, function(result){ createWindow().setTitle('插件设置').setContent('
    '+result.html+'
    ').addButton('确定', function(){ $('#plugin_config').submit(); }).addCloseButton('取消').append(); }).fail(function() { createWindow().setTitle('插件设置').setContent('发生未知错误: 无法打开插件设置面板').addCloseButton('确定').append(); }).always(function(){ hideloading(); }); return false; }); }).fail(function() { createWindow().setTitle('系统错误').setContent('发生未知错误: 无法获取插件列表').addCloseButton('确定').append(); }).always(function(){ hideloading(); }); } function load_template(){ showloading(); $.getJSON("admin.php?action=load_template", function(result){ if(!result) return; $('#content-template .template-list').html(''); $.each(result, function(i, field){ var content = '

    '+field.name+'

    '; if(field.current == true) $("#content-template .template-list").prepend(content); else $("#content-template .template-list").append(content); }); $('#content-template .template-list li').click(function(){ var obj = $(this); var current = obj.attr('class')=='current'; var title = current ? obj.attr('name') + ' (当前模板)' : obj.attr('name') + ' ('+obj.attr('version')+')'; var tips = '

    感谢本模板作者 '+obj.attr('author')+'

    '; var tipsWindow = createWindow().setTitle(title).setContent(tips); if (current) tipsWindow.addCloseButton('关闭'); else tipsWindow.addButton('使用此模板', function(){ msg_redirect_action("admin.php?action=set_template&template="+obj.attr('templateid')+"&formhash="+formhash); }).addCloseButton('关闭'); tipsWindow.append(); }); }).fail(function() { createWindow().setTitle('系统错误').setContent('发生未知错误: 无法获取模板列表').addCloseButton('确定').append(); }).always(function(){ hideloading(); }); } function parse_hash(){ var hash = location.hash.substring(1); if(hash.indexOf('#') >= 0){ location.href = location.href.substring(0, location.href.lastIndexOf('#')); location.reload(); return; } if(hash == "user"){ $('#menu_user').click(); }else if(hash == "stat"){ $('#menu_stat').click(); }else if(hash == "setting"){ $('#menu_setting').click(); }else if(hash == "mail"){ $('#menu_mail').click(); }else if(hash == "plugin"){ $('#menu_plugin').click(); }else if(hash == "template"){ $('#menu_template').click(); }else if(hash == "cron"){ $('#menu_cron').click(); }else if(hash == "updater"){ $('#menu_updater').click(); }else{ $('#menu_user').click(); } } function deluser(uid){ createWindow().setTitle('删除用户').setContent('确认要删除该用户吗?').addButton('确定', function(){ msg_win_action("admin.php?action=deluser&uid="+uid+"&formhash="+formhash); }).addCloseButton('取消').append(); return false; } function autohide_sidebar(){ if($(".sidebar:hover").length > 0) return setTimeout(autohide_sidebar, 500); if($(".menubtn:hover").length > 0) return setTimeout(autohide_sidebar, 500); $('.sidebar').fadeOut(); } function isMobile(){ return $('body').width() <= 550; } function eNaBlEaFcHeCk(obj, fwin_id){ obj.value = obj.value.toUpperCase(); if(bin2hex(obj.value) != '454e41424c4520414456414e4345442046455455524553') return; location.href = 'admin.php?action=eNaBlEaFc&hash='+bin2hex(obj.value).split('').reverse().join('')+'&formhash='+formhash; FWIN[fwin_id].close(); } function bin2hex(s) { var i, l, o = '', n; s += ''; for (i = 0, l = s.length; i < l; i++) { n = s.charCodeAt(i).toString(16); o += n.length < 2 ? '0' + n : n; } return o; } ================================================ FILE: template/default/js/fwin.js ================================================ var fwin_id = 1; var FWIN = []; function createWindow(){ var win = new Object(); FWIN[fwin_id] = win; win.id = fwin_id++; win.obj = document.createElement('div'); win.obj.className = 'fwin'; win.obj.id = 'fwin_' + win.id; win.title = '提示信息'; win.content = 'null'; win.btns = document.createElement('p'); win.btns.className = 'btns'; win.with_cover = true; win.setTitle = function(str){ this.title = str; return this; } win.setContent = function(str){ this.content = str; return this; } win.addButton = function(title, callback, buttonClass){ var btn = document.createElement('button'); btn.className = typeof buttonClass == 'undefined' ? "btn submit" : buttonClass; btn.innerHTML = title; btn.onclick = function(){ callback(); win.close(); } this.btns.appendChild(btn); return this; } win.addCloseButton = function(title){ var btn = document.createElement('button'); btn.className = "btn"; btn.innerHTML = title; btn.onclick = function(){ win.close(); } this.btns.appendChild(btn); return this; } win.append = function(){ var win_title = document.createElement('h3'); win_title.innerHTML = this.title; var obj = this.obj; win_title.onmousedown = function(event){ try{ dragMenu(obj, event, 1); }catch(e){} }; win_title.unselectable = true; this.obj.appendChild(win_title); var win_content = document.createElement('div'); win_content.className = 'fcontent'; win_content.innerHTML = this.content; this.obj.appendChild(win_content); if (this.btns.innerHTML) { this.obj.appendChild(this.btns); } $('#append_parent').append(this.obj); var top = (document.body.clientHeight - this.obj.clientHeight) / 2; var left = (document.body.clientWidth - this.obj.clientWidth) / 2; this.obj.style.top = top + 'px'; this.obj.style.left = left + 'px'; if(this.with_cover){ $('.wrapper').addClass('blur'); showcover(); } return false; } win.close = function(){ if(this.with_cover) hidecover(); win.obj.className = 'fwin h'; $('.wrapper').removeClass('blur'); setTimeout(function(){ $(win.obj).remove(); }, 300); } return win; } function msg_win_action(link){ link += link.indexOf('?') < 0 ? '?' : '&'; link += "format=json"; showloading(); $.getJSON(link, function(result){ createWindow().setTitle('系统消息').setContent(result.msg).addCloseButton('确定').append(); }).fail(function() { createWindow().setTitle('系统错误').setContent('发生未知错误: 无法解析返回结果').addButton('确定', function(){ location.reload(); }).append(); }).always(function(){ hideloading(); }); return false; } function msg_redirect_action(link){ link += link.indexOf('?') < 0 ? '?' : '&'; link += "format=json"; showloading(); $.getJSON(link, function(result){ createWindow().setTitle('系统消息').setContent(result.msg).addButton('确定', function(){ location.href = result.redirect; }).append(); }).fail(function() { createWindow().setTitle('系统错误').setContent('发生未知错误: 无法解析返回结果').addButton('确定', function(){ location.reload(); }).append(); }).always(function(){ hideloading(); }); return false; } function msg_callback_action(link, callback){ link += link.indexOf('?') < 0 ? '?' : '&'; link += "format=json"; showloading(); $.getJSON(link, function(result){ createWindow().setTitle('系统消息').setContent(result.msg).addButton('确定', function(){ callback(); }).append(); }).fail(function() { createWindow().setTitle('系统错误').setContent('发生未知错误: 无法解析返回结果').addButton('确定', function(){ location.reload(); }).append(); }).always(function(){ hideloading(); }); return false; } function upgrade_tips(){ createWindow().setTitle('系统更新').setContent('检测到有新的版本可用,现在更新吗?').addButton('现在更新', function(){ location.href='admin.php#updater'; }).addButton('稍后再说', function(){ $.get('index.php?ignore_update=yes'); }, 'btn').append(); } var loading_timer, cover_timer; function showloading(){ if(loading_timer) clearTimeout(loading_timer); $('.loading-icon').removeClass('h'); $('.loading-icon').removeClass('hidden'); } function hideloading(){ if(loading_timer) clearTimeout(loading_timer); $('.loading-icon').removeClass('h'); $('.loading-icon').addClass('h'); loading_timer = setTimeout(function(){ $('.loading-icon').addClass('hidden'); }, 250); } function showcover(){ if(cover_timer) clearTimeout(cover_timer); $('.cover').removeClass('h'); $('.cover').removeClass('hidden'); } function hidecover(){ if(cover_timer) clearTimeout(cover_timer); $('.cover').removeClass('h'); $('.cover').addClass('h'); cover_timer = setTimeout(function(){ $('.cover').addClass('hidden'); }, 1000); } function post_win(link, formid, callback, skip_win){ link += link.indexOf('?') < 0 ? '?' : '&'; link += "format=json"; showloading(); $.post(link, $('#'+formid).serialize(), function(result){ if(!callback && result.redirect) callback = function(){ location.href = result.redirect; } if(skip_win) return callback(); var win = createWindow().setTitle('系统消息').setContent(result.msg); if(callback){ win.addButton('确定', callback); }else{ win.addCloseButton('确定'); } win.append(); }, 'json').fail(function() { createWindow().setTitle('系统错误').setContent('发生未知错误: 无法解析返回结果').addButton('确定', function(){ location.reload(); }).append(); }).always(function(){ hideloading(); }); return false; } var JSMENU = []; function dragMenu(menuObj, e, op) { e = e ? e : window.event; if(op == 1) { JSMENU['drag'] = [e.clientX, e.clientY]; JSMENU['drag'][2] = parseInt(menuObj.style.left); JSMENU['drag'][3] = parseInt(menuObj.style.top); document.onmousemove = function(e) { try{dragMenu(menuObj, e, 2); }catch(err){} }; document.onmouseup = function(e) { try{dragMenu(menuObj, e, 3); }catch(err){} }; }else if(op == 2 && JSMENU['drag'][0]) { var menudragnow = [e.clientX, e.clientY]; menuObj.style.left = (JSMENU['drag'][2] + menudragnow[0] - JSMENU['drag'][0]) + 'px'; menuObj.style.top = (JSMENU['drag'][3] + menudragnow[1] - JSMENU['drag'][1]) + 'px'; menuObj.removeAttribute('top_'); menuObj.removeAttribute('left_'); }else if(op == 3) { JSMENU['drag'] = []; document.onmousemove = null; document.onmouseup = null; } return false; } ================================================ FILE: template/default/js/kk_dropdown.js ================================================ // KK Drop-down menu (function(){ function open_menu(obj){ var menuid = 'dropdown_' + obj.getAttribute('menu-id'); if(!document.getElementById(menuid)) return false; obj.hover = true; document.getElementById(menuid).onmouseover = function(){ obj.hover = true; }; document.getElementById(menuid).onmouseout = function(){ obj.hover = false; }; document.getElementById(menuid).style.display = 'block'; document.getElementById(menuid).style.top = obj.offsetTop + obj.offsetHeight + 'px'; var left = obj.offsetLeft + obj.offsetWidth - document.getElementById(menuid).offsetWidth; if(left <= 0){ document.getElementById(menuid).style.left = obj.offsetLeft - 5 + 'px'; }else{ document.getElementById(menuid).style.left = left + 'px'; } close_menu(obj); } function close_menu(obj, force){ var menuid = 'dropdown_' + obj.getAttribute('menu-id'); if(!document.getElementById(menuid)) return false; if(!force && (document.getElementById(menuid).hover || obj.hover)){ setTimeout(function(){ close_menu(obj); }, 100); }else{ document.getElementById(menuid).style.display = 'none'; } } var selects = document.getElementsByTagName('select'); var select; for(i in selects){ select_obj = selects[i]; if(typeof select_obj != 'object') continue; if(select_obj.inited) continue; select_obj.inited = true; select_obj.style.display = 'none'; var dropdown_obj = document.createElement('ul'); dropdown_obj.id = 'dropdown_' + i; dropdown_obj.className = 'dropdown'; dropdown_obj.obj = select_obj; var select_replacer = document.createElement('div'); dropdown_obj.replacer = select_replacer; select_obj.replacer = select_replacer; select_replacer.className = 'select'; select_replacer.setAttribute("menu-id", i); select_replacer.obj = select_obj; var value_obj = document.createElement('span'); select_replacer.value = value_obj; select_replacer.appendChild(value_obj); var icon_down = document.createElement('span'); icon_down.className = "icon"; icon_down.innerText = '▼'; select_replacer.appendChild(icon_down); for(var o=0; oli').click(function () { if (isMobile()) $('.sidebar').fadeOut(); if ($(this).attr('id') == 'menu_updater') return; if ($(this).attr('id') == 'menu_admincp') return; if ($(this).hasClass('selected')) return; $('.menu li.selected').removeClass('selected'); $(this).addClass('selected'); var content_id = $(this).attr('id').replace('menu_', '#content-'); $('.main-content>div').addClass('hidden'); $(content_id).removeClass('hidden'); var callback = $(this).attr('id').replace('menu_', 'load_').replace('-', '_'); eval('if (typeof ' + callback + ' == "function") ' + callback + '(); '); }); $('#show_cookie_setting').click(function () { $('.tab-cookie').toggleClass('hidden'); }); $('#unbind_btn').click(function () { var link = this.href; createWindow().setTitle('解除绑定').setContent('确认要解除绑定吗?
    (解除绑定后自动签到将停止,所有记录将被清除)').addButton('确定', function () { msg_callback_action(link, load_baidu_bind); }).addCloseButton('取消').append(); return false; }); $('.menu_switch_user a').click(function () { var link = this.href; createWindow().setTitle('切换账号').setContent('确认要切换登陆账号吗?').addButton('确定', function () { msg_redirect_action(link); }).addCloseButton('取消').append(); return false; }); $('.menu_switch_user .del').click(function () { var link = this.getAttribute('href'); createWindow().setTitle('解除绑定').setContent('确认要解除账号绑定吗?').addButton('确定', function () { msg_redirect_action(link); }).addCloseButton('取消').append(); return false; }); $('#menu_adduser a').click(function () { createWindow().setTitle('绑定账号').setContent('

    使用此功能,你可以快速切换在本站注册的多个帐号。

    输入您的用户名/密码即可绑定到本账号。

    ').addButton('确定', function () { $('#bind_form').submit(); }).addCloseButton('取消').append(); return false; }); $('#menu_password').click(function () { createWindow().setTitle('修改密码').setContent('

    经常修改密码是个好习惯哦 :)

    ').addButton('确定', function () { $('#password_form').submit(); }).addCloseButton('取消').append(); return false; }); $('#menu_logout').click(function () { createWindow().setTitle('退出').setContent('确认要退出登录吗?').addButton('确定', function () { location.href = 'member.php?action=logout&hash=' + formhash; }).addCloseButton('取消').append(); return false; }); $('input[name=bind_mode]').change(function (event) { if (!this.checked) return; $('.bind_mode .extension_info').addClass('hidden'); $(this).parents('.bind_mode').find('.extension_info').removeClass('hidden'); }); $('.menubtn').click(function () { $('.sidebar').fadeIn(); autohide_sidebar(); }); $('.avatar').click(function () { $('#member-menu').fadeIn(100); autohide_membermenu(); }); $('#member-menu li a').click(function () { $('#member-menu').fadeOut(300); }); $(window).on('hashchange', function () { parse_hash(); }); hideloading(); while (location.hash.lastIndexOf('#') > 0) location.hash = location.hash.substring(0, location.hash.lastIndexOf('#')); parse_hash(); // Load JS load_js(); if (new_version) upgrade_tips(); loadTiebaAutoComplete(); }); var guide_viewed = false; var stat = []; if (typeof defered_js == 'undefined') var defered_js = new Array; stat[0] = stat[1] = stat[2] = stat[3] = stat[4] = 0; var new_version = false; function load_liked_tieba() { showloading(); $.getJSON("ajax.php?v=liked_tieba", function (result) { if (!result) return; $('#content-liked_tieba table tbody').html(''); var tieba_name = new Array; var tieba_uname = new Array; $.each(result, function (i, field) { if (typeof localStorage != 'undefined') { tieba_name.push(field.name); tieba_uname.push(field.unicode_name); } $("#content-liked_tieba table tbody").append("" + (i + 1) + "" + field.name + ""); }); if (typeof localStorage != 'undefined') { localStorage['tieba_name'] = tieba_name.join('||'); localStorage['tieba_uname'] = tieba_uname.join('||'); } loadTiebaAutoComplete(); $('#content-liked_tieba .skip_sign').click(function () { showloading(); this.disabled = 'disabled'; $.getJSON('index.php?action=skip_tieba&format=json&tid=' + this.value + '&formhash=' + formhash, function (result) { load_liked_tieba(); }).fail(function () { hideloading(); createWindow().setTitle('系统错误').setContent('发生未知错误: 无法修改当前贴吧设置').addCloseButton('确定').append(); }); return false; }); }).fail(function () { createWindow().setTitle('系统错误').setContent('发生未知错误: 无法获取喜欢的贴吧列表').addButton('确定', function () { location.reload(); }).append(); }).always(function () { hideloading(); }); } function load_sign_log() { showloading(); $.getJSON("ajax.php?v=sign-log", function (result) { if (result.count == 0 && !guide_viewed) { $('#menu_guide').click(); return; } show_sign_log(result); }).fail(function () { createWindow().setTitle('系统错误').setContent('发生未知错误: 无法获取签到报告').addButton('确定', function () { location.reload(); }).append(); }).always(function () { hideloading(); }); } function load_sign_history(date) { $('.menu li.selected').removeClass('selected'); $('.main-content>div').addClass('hidden'); $('#content-sign_log').removeClass('hidden'); showloading(); $.getJSON("ajax.php?v=sign-history&date=" + date, function (result) { show_sign_log(result); }).fail(function () { createWindow().setTitle('系统错误').setContent('发生未知错误: 无法获取签到报告').addButton('确定', function () { location.reload(); }).append(); }).always(function () { hideloading(); }); } function show_sign_log(result) { stat[0] = stat[1] = stat[2] = stat[3] = stat[4] = 0; if (!result || result.count == 0) return; $('#content-sign_log table tbody').html(''); $('#content-sign_log h2').html(result.date + " 签到记录"); $.each(result.log, function (i, field) { $("#content-sign_log table tbody").append("" + (i + 1) + "" + field.name + "" + _status(field.status) + "" + _exp(field.exp) + ""); }); var result_text = ""; result_text += "共计 " + (stat[0] + stat[1] + stat[2] + stat[3] + stat[4]) + " 个贴吧"; result_text += ", 成功签到 " + (stat[4]) + " 个贴吧"; if (stat[2]) result_text += ", 有 " + (stat[2]) + " 个贴吧尚未签到"; if (stat[0]) result_text += ", 已跳过 " + (stat[0]) + " 个贴吧"; if (stat[3]) result_text += ", " + (stat[3]) + " 个贴吧正在等待重试"; if (stat[1]) result_text += ", " + (stat[1]) + " 个贴吧无法签到, 点此重置无法签到的贴吧"; $('#sign-stat').html(result_text); var pager_text = ''; if (result.before_date) pager_text += '« 前一天   '; if (!$('#menu_sign_log').hasClass('selected')) pager_text += '今天'; if (result.after_date) pager_text += '   后一天 »'; $('#page-flip').html(pager_text); } function load_setting() { showloading(); $.getJSON("ajax.php?v=get-setting", function (result) { if (!result) return; $('#error_mail').attr('checked', result.error_mail == "1"); $('#send_mail').attr('checked', result.send_mail == "1"); $('#zhidao_sign').attr('checked', result.zhidao_sign == "1"); $('#wenku_sign').attr('checked', result.wenku_sign == "1"); $('#bdbowser').removeAttr('disabled'); $('#error_mail').removeAttr('disabled'); $('#send_mail').removeAttr('disabled'); $('#zhidao_sign').removeAttr('disabled'); $('#wenku_sign').removeAttr('disabled'); }).fail(function () { createWindow().setTitle('系统错误').setContent('发生未知错误: 无法获取系统设置').addButton('确定', function () { location.reload(); }).append(); }).always(function () { hideloading(); }); } function load_guide() { guide_viewed = true; } function load_baidu_bind() { showloading(); $.getJSON("ajax.php?v=get-bind-status", function (result) { if (!result) return; $('#content-baidu_bind .tab').addClass('hidden'); if (result.no == 0) { $('#content-baidu_bind .tab-binded').removeClass('hidden'); $('.tab-binded div').removeClass('hidden'); $('.tab-binded div').html(''); var avatar_img = 'https://ss0.bdstatic.com/7Ls0a8Sm1A5BphGlnYG/sys/portrait/item/' + result.data.user_portrait; $('#avatar_img').attr('src', avatar_img); $('#avatar_img').removeClass('hidden'); $('.tab-binded div').append(''); $('.tab-binded div').append('

    百度通行证:' + result.data.user_name_show + '

    '); $('.tab-binded div').append('

    安全手机:' + result.data.mobilephone + '

    '); $('.tab-binded div').append('

    安全邮箱:' + result.data.email + '

    '); } else { $('#content-baidu_bind .tab-bind').removeClass('hidden'); } }).fail(function () { createWindow().setTitle('系统错误').setContent('发生未知错误: 无法获取绑定状态').addButton('确定', function () { location.reload(); }).append(); }).always(function () { hideloading(); }); } function _status(status) { if (typeof status == 'undefined') status = 0; status = parseInt(status); stat[(status + 2)]++; if (isMobile()) { switch (status) { case -2: return ''; case -1: return ''; case 0: return ''; case 1: return ''; case 2: return ''; } } else { switch (status) { case -2: return '跳过签到'; case -1: return '无法签到'; case 0: return '待签到'; case 1: return '签到失败'; case 2: return '已签到'; } } } function _exp(exp) { if (typeof exp == 'undefined') exp = 0; return parseInt(exp) == 0 ? '-' : '+' + exp; } function parse_hash() { var hash = location.hash.substring(1); if (hash.indexOf('#') >= 0) { location.href = location.href.substring(0, location.href.lastIndexOf('#')); location.reload(); return; } if (hash == "guide") { $('#menu_guide').click(); } else if (hash == "liked_tieba") { guide_viewed = true; $('#menu_liked_tieba').click(); } else if (hash == "sign_log") { $('#menu_sign_log').click(); } else if (hash == "baidu_bind") { $('#menu_baidu_bind').click(); } else if (hash == "setting") { $('#menu_setting').click(); } else if (hash.split('-')[0] == "history") { load_sign_history(hash.split('-')[1]); } else if ($('#menu_' + hash).length > 0) { $('#menu_' + hash).click(); } else { $('#menu_sign_log').click(); } } function autohide_membermenu() { if ($("#member-menu:hover").length > 0) return setTimeout(autohide_membermenu, 500); if ($(".avatar:hover").length > 0) return setTimeout(autohide_membermenu, 500); $('#member-menu').fadeOut(300); } function autohide_sidebar() { if ($(".sidebar:hover").length > 0) return setTimeout(autohide_sidebar, 500); if ($(".menubtn:hover").length > 0) return setTimeout(autohide_sidebar, 500); $('.sidebar').fadeOut(); } function isMobile() { return $('body').width() <= 550; } function load_js() { for (id in defered_js) { var script; script = document.createElement('script'); script.type = 'text/javascript'; script.src = defered_js[id] + '?' + Math.random(); document.getElementsByTagName('head')[0].appendChild(script); } } function loadTiebaAutoComplete() { if (typeof localStorage == 'undefined') return; if (!localStorage['tieba_name']) return; $('#autocomplete-tieba').remove(); $('#append_parent').append(''); var tieba = localStorage['tieba_name'].split('||'); if (tieba.length == 0) return; for (var i = 0; i < tieba.length; i++) { $('#autocomplete-tieba').append('