Example #1
0
/**
 * 运行钩子(插件使用)
 */
function runhook($method)
{
    $time_start = getmicrotime();
    $data = '';
    $getpclass = FALSE;
    $hook_appid = getcache('hook', 'plugins');
    if (!empty($hook_appid)) {
        foreach ($hook_appid as $appid => $p) {
            $pluginfilepath = PC_PATH . 'plugin' . DIRECTORY_SEPARATOR . $p . DIRECTORY_SEPARATOR . 'hook.class.php';
            $getpclass = TRUE;
            include_once $pluginfilepath;
        }
        $hook_appid = array_flip($hook_appid);
        if ($getpclass) {
            $pclass = new ReflectionClass('hook');
            foreach ($pclass->getMethods() as $r) {
                $legalmethods[] = $r->getName();
            }
        }
        if (in_array($method, $legalmethods)) {
            foreach (get_declared_classes() as $class) {
                $refclass = new ReflectionClass($class);
                if ($refclass->isSubclassOf('hook')) {
                    if ($_method = $refclass->getMethod($method)) {
                        $classname = $refclass->getName();
                        if ($_method->isPublic() && $_method->isFinal()) {
                            plugin_stat($hook_appid[$classname]);
                            $data .= $_method->invoke(null);
                        }
                    }
                }
            }
        }
        return $data;
    }
}
Example #2
0
if (isset($_GET['id'])) {
    if (!preg_match("/^[a-z0-9_\\-]+\$/i", $_GET['id'])) {
        showmessage(L('illegal_parameters'));
    }
    list($identification, $filename, $action) = explode('-', $_GET['id']);
    $filename = !empty($filename) ? $filename : $identification;
    $action = !empty($action) ? $action : 'init';
}
if (!preg_match("/^[a-z0-9_\\-]+\$/i", $identification)) {
    showmessage(L('plugin_not_exist', '', 'plugin'));
}
$cache = getcache($identification, 'plugins');
if (!$cache['disable'] || $filename == 'plugin_admin' || $filename == 'hook') {
    showmessage(L('plugin_not_exist', '', 'plugin'));
} else {
    $status = plugin_stat($cache['appid']);
    if ($status == 0 || $app_status == 1) {
        showmessage(L('plugin_developing', '', 'plugin'));
    } elseif ($status == 3) {
        showmessage(L('plugin_be_locked', '', 'plugin'));
    }
    $iframe = string2array($cache['iframe']);
    if ($iframe['url']) {
        $cache_var = getcache($identification . '_var', 'plugins');
        plugin_base::creat_iframe($cache, $cache_var);
    } else {
        plugin_base::creat_app($identification, $filename, $action);
    }
}
class plugin_base
{