Ejemplo n.º 1
0
 function INIT()
 {
     global $_PLUGIN;
     $_PLUGIN = array();
     $_PLUGIN['list'] = CACHE::get('plugins');
     $_PLUGIN['obj'] = array();
     $_PLUGIN['hook'] = array();
     $_PLUGIN['page'] = array();
     foreach ($_PLUGIN['list'] as $plugin) {
         $id = $plugin['name'];
         $classfile = ROOT . './plugins/' . $id . '/plugin.class.php';
         if (file_exists($classfile)) {
             require_once $classfile;
             $classname = "plugin_{$id}";
             if (!class_exists("plugin_{$id}", false)) {
                 continue;
             }
             $_PLUGIN['obj'][$id] = new $classname();
             $methods = get_class_methods($classname);
             foreach ($methods as $method) {
                 $_PLUGIN['hook'][$method][] = $id;
             }
             if (method_exists($_PLUGIN['obj'][$id], 'getMethods')) {
                 $_PLUGIN['obj'][$id]->modules = $_PLUGIN['obj'][$id]->getMethods();
             }
             foreach ($_PLUGIN['obj'][$id]->modules as $module) {
                 self::parse_module($module, $id);
             }
         }
     }
 }
Ejemplo n.º 2
0
 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');
 }
Ejemplo n.º 3
0
 public static function loop()
 {
     if (defined('IN_XAE')) {
         return array('status' => -3);
     }
     $file_list = CACHE::get('need_download');
     list($path, $hash) = array_pop($file_list);
     if (!$path) {
         return array('status' => 1);
     }
     $ret = self::_download_file($path, $hash);
     if ($ret < 0) {
         return array('status' => $ret, 'file' => $path);
     }
     CACHE::save('need_download', $file_list);
     $max = sizeof(CACHE::get('kk_updater'));
     $current = $max - sizeof($file_list);
     return array('status' => 0, 'precent' => round($current / $max * 100), 'file' => $path);
 }
Ejemplo n.º 4
0
 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);
 }
Ejemplo n.º 5
0
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);
}
Ejemplo n.º 6
0
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];
}
Ejemplo n.º 7
0
     $query = DB::query("SELECT uid, COUNT(*) FROM `sign_log` WHERE date='{$date}' AND status='-2' GROUP BY uid");
     while ($result = DB::fetch($query)) {
         $_uid = $result['uid'];
         $data[$_uid]['skiped'] = $result['COUNT(*)'];
     }
     exit(json_encode($data));
 case 'load_user':
     $data = array();
     $query = DB::query('SELECT uid, username, email FROM member ORDER BY uid');
     while ($result = DB::fetch($query)) {
         $data[] = $result;
     }
     exit(json_encode($data));
     break;
 case 'load_setting':
     $data = CACHE::get('setting');
     unset($data['SYS_KEY']);
     exit(json_encode($data));
     break;
 case 'save_setting':
     if ($formhash != $_POST['formhash']) {
         showmessage('来源不可信,请重试', 'admin.php#setting');
     }
     saveSetting('autoupdate', $_POST['autoupdate'] ? 1 : 0);
     saveSetting('block_register', $_POST['block_register'] ? 1 : 0);
     saveSetting('invite_code', daddslashes($_POST['invite_code']));
     showmessage('设置已经保存☆Kira~', 'admin.php#setting', 2);
     break;
 case 'deluser':
     $_uid = intval($_GET['uid']);
     if ($uid == $_uid) {
Ejemplo n.º 8
0
 function handleAction()
 {
     global $uid, $formhash;
     $status = -1;
     $msg = '未登录!';
     $data = array('time' => time());
     if ($_SERVER['HTTP_USER_AGENT'] != 'Android Client For Tieba Signer') {
         exit(json_encode(array('status' => -2, 'msg' => '非法操作', 'data' => $data)));
     } else {
         if ($_GET['a'] == 'api_info') {
             $status = 0;
             $data = array('version' => '1.0.0', 'site' => $_SERVER["HTTP_HOST"]);
         } elseif ($_GET['a'] == 'do_login') {
             if (!empty($_POST['username']) && !empty($_POST['password'])) {
                 $username = daddslashes($_POST['username']);
                 $un = strtolower($username);
                 if (strlen($username) > 24) {
                     $msg = '用户名过长,请修改';
                     $status = 3;
                 } else {
                     $user = DB::fetch_first("SELECT * FROM member WHERE username='******'");
                     $verified = Widget_Password::verify($user, $_POST['password']);
                     if ($verified) {
                         $login_exp = TIMESTAMP + 3600;
                         do_login($user['uid']);
                         $status = 0;
                         $msg = "欢迎回来,{$user['username']}!";
                         $data = array('uid' => $user['uid'], 'username' => $user['username'], 'email' => $user['email'], 'formhash' => substr(md5(substr(TIMESTAMP, 0, -7) . $user['username'] . $user['uid'] . ENCRYPT_KEY . ROOT), 8, 8));
                     } else {
                         $status = 2;
                         $msg = "对不起,您的用户名或密码错误,无法登录";
                     }
                 }
             } else {
                 $status = 1;
                 $msg = '用户名或密码不得为空!';
             }
         } elseif ($_GET['a'] == 'check_login') {
             if ($uid) {
                 $status = 0;
             }
             if ($uid) {
                 $msg = '您已登录';
             }
         } elseif ($formhash != $_GET['formhash']) {
             $status = -2;
             $msg = '非法操作';
         } elseif ($uid) {
             $status = 0;
             $msg = "";
             require_once ROOT . './plugins/zw_client_api/BaiduUtil.php';
             $binded_baidu = true;
             $cookie = get_cookie($uid);
             if (empty($cookie)) {
                 $binded_baidu = false;
             } else {
                 try {
                     $baiduUtil = new BaiduUtil(get_cookie($uid));
                 } catch (Exception $e) {
                     if ($e->getCode() == -99) {
                         $binded_baidu = false;
                     }
                 }
             }
             switch ($_GET['a']) {
                 case 'baidu_info':
                     if ($binded_baidu) {
                         $msg = '百度账号信息';
                         try {
                             $baidu_account_info = $baiduUtil->fetchClientUserInfo();
                             $baidu_account_tieba_list = $baiduUtil->fetchClientLikedForumList();
                             $baidu_account_follow_list = $baiduUtil->fetchFollowList(4);
                             $baidu_account_fans_list = $baiduUtil->fetchFansList(4);
                             $data = array('id' => $baidu_account_info['data']['id'], 'username' => $baidu_account_info['data']['un'], 'avatar' => $baidu_account_info['data']['head_photo_h'], 'sex' => $baidu_account_info['data']['sex'], 'tb_age' => $baidu_account_info['data']['tb_age'], 'fans_num' => $baidu_account_info['data']['fans_num'], 'follow_num' => $baidu_account_info['data']['concern_num'], 'tb_num' => $baidu_account_info['data']['like_forum_num'], 'intro' => $baidu_account_info['data']['intro'] ? $baidu_account_info['data']['intro'] : '这个家伙很懒,什么也没有留下', 'tiebas' => $baidu_account_tieba_list['data'] ? $baidu_account_tieba_list['data'] : array(), 'follow' => $baidu_account_follow_list['data'], 'fans' => $baidu_account_fans_list['data']);
                         } catch (Exception $e) {
                             $status = "3";
                             $msg = '助手站点错误:' . $e->getMessage();
                         }
                     } else {
                         $status = 1;
                         $msg = "未绑定百度账号";
                     }
                     break;
                 case 'unbind_baidu':
                     DB::query("UPDATE member_setting SET cookie='' WHERE uid='{$uid}'");
                     DB::query("DELETE FROM my_tieba WHERE uid='{$uid}'");
                     DB::query("DELETE FROM sign_log WHERE uid='{$uid}'");
                     $msg = "已经解除百度账号绑定,您可以稍后重新进行绑定";
                     break;
                 case 'sign_log':
                     $msg = '获取成功';
                     $date = intval($_GET['date']);
                     $data['date'] = $date;
                     $data['log'] = array();
                     $query = DB::query("SELECT * FROM sign_log l LEFT JOIN my_tieba t ON t.tid=l.tid WHERE l.uid='{$uid}' AND l.date='{$date}'");
                     while ($result = DB::fetch($query)) {
                         $data['log'][] = $result;
                     }
                     $data['count'] = count($data['log']);
                     $previous_date = DB::result_first("SELECT date FROM sign_log WHERE uid='{$uid}' AND date<'{$date}' ORDER BY date DESC LIMIT 0,1");
                     $next_date = DB::result_first("SELECT date FROM sign_log WHERE uid='{$uid}' AND date>'{$date}' ORDER BY date ASC LIMIT 0,1");
                     $data['previous_date'] = $previous_date ? $previous_date : '0';
                     $data['next_date'] = $next_date ? $next_date : '0';
                     break;
                 case 'cloud_info':
                     $msg = '获取成功';
                     $data['sid'] = cloud::id();
                     break;
                 case 'plugin_info':
                     $msg = '获取成功';
                     $plugin_info = CACHE::get('plugins');
                     $data['plugins'] = array();
                     $plugin_supported = array('zw_custom_page' => array('name' => '自定义页面', 'author' => 'JerryLocke'), 'zw_blockid' => array('name' => '循环封禁', 'author' => 'JerryLocke'), 'x_tdou' => array('name' => 'T豆', 'author' => '星弦雪'), 'xxx_post' => array('name' => '客户端回帖', 'author' => '星弦雪'), 'xxx_meizi' => array('name' => '妹纸认证', 'author' => '星弦雪'));
                     foreach ($plugin_info as $plugin) {
                         if (isset($plugin_supported[$plugin['id']])) {
                             $data['plugins'][] = $plugin + $plugin_supported[$plugin['id']];
                         }
                     }
                     $data['count'] = count($data['plugins']);
                     break;
             }
         }
         echo json_encode(array('status' => $status, 'msg' => $msg, 'data' => $data));
     }
 }
Ejemplo n.º 9
0
<?php

define('IN_ADMINCP', true);
define('DISABLE_PLUGIN', true);
require_once './system/common.inc.php';
$plugin_id = htmlspecialchars($_GET['id']);
$plugins = CACHE::get('plugins');
foreach ($plugins as $plugin) {
    if ($plugin['id'] == $plugin_id) {
        $exists = true;
        break;
    }
}
if (!isset($exists)) {
    throw new Exception("Unknown plugin '{$plugin_id}'");
}
$obj = HOOK::getPlugin($plugin_id);
if ($obj instanceof Plugin) {
    $obj->handleAction();
} else {
    throw new Exception('This plugin doesn\'t support to be called directly.');
}
Ejemplo n.º 10
0
 function INIT()
 {
     global $_PLUGIN;
     $_PLUGIN = array();
     $_PLUGIN['list'] = CACHE::get('plugins');
     $_PLUGIN['obj'] = array();
     $_PLUGIN['hook'] = array();
     $_PLUGIN['page'] = array();
     $_PLUGIN['shortcut'] = array();
     foreach ($_PLUGIN['list'] as $plugin) {
         $pluginid = $plugin['id'];
         $classfile = ROOT . './plugins/' . $pluginid . '/plugin.class.php';
         if (file_exists($classfile)) {
             require_once $classfile;
             $classname = "plugin_{$pluginid}";
             if (!class_exists("plugin_{$pluginid}", false)) {
                 continue;
             }
             $_PLUGIN['obj'][$pluginid] = new $classname();
             if (method_exists($obj, '__construct') || method_exists($obj, '__destruct') || method_exists($obj, $classname)) {
                 unset($_PLUGIN['obj'][$pluginid]);
                 continue;
             }
             $methods = get_class_methods($classname);
             if (property_exists($_PLUGIN['obj'][$pluginid], 'version')) {
                 $version = $_PLUGIN['obj'][$pluginid]->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);
             }
         }
     }
 }