/** * 激活插件 */ function activePlugin($plugin) { $active_plugins = Option::get('active_plugins'); $ret = false; if (in_array($plugin, $active_plugins)) { $ret = true; } elseif (true === checkPlugin($plugin)) { $active_plugins[] = $plugin; $active_plugins = serialize($active_plugins); Option::updateOption('active_plugins', $active_plugins); $ret = true; } else { $ret = false; } //run init callback functions $r = explode('/', $plugin, 2); $plugin = $r[0]; $callback_file = "../content/plugins/{$plugin}/{$plugin}_callback.php"; if (true === $ret && file_exists($callback_file)) { require_once $callback_file; if (function_exists('callback_init')) { callback_init(); } } return $ret; }
function callback_init() { $Path = EMLOG_ROOT . "/content/plugins/download/"; $InstallFile = $Path . 'install.php'; if (is_file($InstallFile) === true) { include_once $InstallFile; $Check = DownloadMe_Install_Check(); if ($Check === true) { #"安装成功!"; @rename($InstallFile, $InstallFile . '.Download'); if (is_file($Path . DOWNLOAD_CACHE_NAME . "_Inc.php") === true) { @rename($Path . DOWNLOAD_CACHE_NAME . "_Inc.php", EMLOG_ROOT . "/content/cache/" . DOWNLOAD_CACHE_NAME . "_Inc.php"); } if (is_file($Path . DOWNLOAD_CACHE_NAME . "_Gip.php") === true) { @rename($Path . DOWNLOAD_CACHE_NAME . "_Gip.php", EMLOG_ROOT . "/content/cache/" . DOWNLOAD_CACHE_NAME . "_Gip.php"); } if (is_file($Path . "Version.php") === true) { @unlink($Path . "Version.php"); } } } elseif (is_file($InstallFile . '.Download') === true) { @rename($InstallFile . '.Download', $InstallFile); callback_init(); } else { emMsg('安装文件 ( /content/plugins/download/install.php ) 缺失,请重新下载插件安装包'); } DownloadMe_Up(); # 写入缓存 }
/** * 激活插件 * 如果存在,系统会调用 插件名_callback.php 的 callback_init() * @return bool */ function activePlugin($plugin) { global $m; if (file_exists(SYSTEM_ROOT . '/plugins/' . $plugin . '/' . $plugin . '.php')) { $m->query("UPDATE `" . DB_PREFIX . "plugins` SET `status` = '1' WHERE `name` = '{$plugin}';"); $callback_file = SYSTEM_ROOT . '/plugins/' . $plugin . '/' . $plugin . '_callback.php'; if (file_exists($callback_file)) { require_once $callback_file; if (function_exists('callback_init')) { callback_init(); } } return true; } else { return false; } }