Exemple #1
0
 /**
  * 激活插件
  */
 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;
 }
Exemple #2
0
 function checkInstallWpadmPlugins()
 {
     $return = false;
     $i = 1;
     foreach (main::$plugins as $plugin) {
         if (checkPlugin($plugin)) {
             $i++;
         }
     }
     if ($i > 2) {
         $return = true;
     }
     return $return;
 }
Exemple #3
0
doStripslashes();
$CACHE = Cache::getInstance();
$userData = array();
define('ISLOGIN', LoginAuth::isLogin());
//用户组:admin管理员, writer联合撰写人, visitor访客
define('ROLE_ADMIN', 'admin');
define('ROLE_WRITER', 'writer');
define('ROLE_VISITOR', 'visitor');
//用户角色
define('ROLE', ISLOGIN === true ? $userData['role'] : ROLE_VISITOR);
//用户ID
define('UID', ISLOGIN === true ? $userData['uid'] : '');
//站点固定地址
define('BLOG_URL', Option::get('blogurl'));
//模板库地址
define('TPLS_URL', BLOG_URL . 'content/templates/');
//模板库路径
define('TPLS_PATH', EMLOG_ROOT . '/content/templates/');
//解决前台多域名ajax跨域
define('DYNAMIC_BLOGURL', getBlogUrl());
//前台模板URL
define('TEMPLATE_URL', TPLS_URL . Option::get('nonce_templet') . '/');
$active_plugins = Option::get('active_plugins');
$emHooks = array();
if ($active_plugins && is_array($active_plugins)) {
    foreach ($active_plugins as $plugin) {
        if (true === checkPlugin($plugin)) {
            include_once EMLOG_ROOT . '/content/plugins/' . $plugin;
        }
    }
}
Exemple #4
0
 /**
  * @todo document this
  */
 function action_pluginadd()
 {
     global $member, $manager, $DIR_PLUGINS;
     // check if allowed
     $member->isAdmin() or $this->disallow();
     $name = postVar('filename');
     if ($manager->pluginInstalled($name)) {
         $this->error(_ERROR_DUPPLUGIN);
     }
     if (!checkPlugin($name)) {
         $this->error(_ERROR_PLUGFILEERROR . ' (' . htmlspecialchars($name) . ')');
     }
     // get number of currently installed plugins
     $res = sql_query('SELECT * FROM ' . sql_table('plugin'));
     $numCurrent = sql_num_rows($res);
     // plugin will be added as last one in the list
     $newOrder = $numCurrent + 1;
     $manager->notify('PreAddPlugin', array('file' => &$name));
     // do this before calling getPlugin (in case the plugin id is used there)
     $query = 'INSERT INTO ' . sql_table('plugin') . ' (porder, pfile) VALUES (' . $newOrder . ',"' . sql_real_escape_string($name) . '")';
     sql_query($query);
     $iPid = sql_insert_id();
     $manager->clearCachedInfo('installedPlugins');
     // Load the plugin for condition checking and instalation
     $plugin =& $manager->getPlugin($name);
     // check if it got loaded (could have failed)
     if (!$plugin) {
         sql_query('DELETE FROM ' . sql_table('plugin') . ' WHERE pid=' . intval($iPid));
         $manager->clearCachedInfo('installedPlugins');
         $this->error(_ERROR_PLUGIN_LOAD);
     }
     // check if plugin needs a newer Nucleus version
     if (getNucleusVersion() < $plugin->getMinNucleusVersion()) {
         // uninstall plugin again...
         $this->deleteOnePlugin($plugin->getID());
         // ...and show error
         $this->error(_ERROR_NUCLEUSVERSIONREQ . htmlspecialchars($plugin->getMinNucleusVersion()));
     }
     // check if plugin needs a newer Nucleus version
     if (getNucleusVersion() == $plugin->getMinNucleusVersion() && getNucleusPatchLevel() < $plugin->getMinNucleusPatchLevel()) {
         // uninstall plugin again...
         $this->deleteOnePlugin($plugin->getID());
         // ...and show error
         $this->error(_ERROR_NUCLEUSVERSIONREQ . htmlspecialchars($plugin->getMinNucleusVersion() . ' patch ' . $plugin->getMinNucleusPatchLevel()));
     }
     $pluginList = $plugin->getPluginDep();
     foreach ($pluginList as $pluginName) {
         $res = sql_query('SELECT * FROM ' . sql_table('plugin') . ' WHERE pfile="' . $pluginName . '"');
         if (sql_num_rows($res) == 0) {
             // uninstall plugin again...
             $this->deleteOnePlugin($plugin->getID());
             $this->error(sprintf(_ERROR_INSREQPLUGIN, htmlspecialchars($pluginName, ENT_QUOTES)));
         }
     }
     // call the install method of the plugin
     $plugin->install();
     $manager->notify('PostAddPlugin', array('plugin' => &$plugin));
     // update all events
     $this->action_pluginupdate();
 }
Exemple #5
0
define('OA_UPGRADE_UPGRADE', 35);
define('OA_UPGRADE_INSTALL', 36);
// Load session data (required for login check)
require_once MAX_PATH . '/www/admin/lib-sessions.inc.php';
phpAds_SessionDataFetch();
// Hack! - Plugins pre 2.7.31 may require [pluginpaths][extensions] to be set
$GLOBALS['_MAX']['CONF']['pluginPaths']['extensions'] = $GLOBALS['_MAX']['CONF']['pluginPaths']['plugins'];
$GLOBALS['_MAX']['CONF']['pluginPaths']['packages'] = $GLOBALS['_MAX']['CONF']['pluginPaths']['extensions'] . 'etc/';
$aErrors = array();
$result = array('name' => '', 'status' => 'Invalid Request', 'errors' => &$aErrors);
if (validRequest($result)) {
    if ($_REQUEST['status'] === '0') {
        $result = installPlugin($_REQUEST['plugin']);
    } else {
        if ($_REQUEST['status'] === '1') {
            $result = checkPlugin($_REQUEST['plugin']);
        }
    }
}
// Undo hack
unset($GLOBALS['_MAX']['CONF']['pluginPaths']['extensions']);
$oSettings = new OA_Admin_Settings();
$oSettings->writeConfigChange();
require_once MAX_PATH . '/lib/JSON/JSON.php';
$json = new Services_JSON();
$output = $json->encode($result);
header("Content-Type: application/x-javascript");
echo $output;
function getPlugin($pluginName)
{
    include MAX_PATH . '/etc/default_plugins.php';
Exemple #6
0
  </form>
</div>
<?php 
$allTabs = array("index.php" => "Home", "services.php" => "Services", "devices.php" => "Devices", "location.php" => "Locations", "contacts.php" => "Contacts", "statistics.php" => "Statistics", "monitor.php" => "Events", "plugins.php" => "Plugins");
//After knowing their active status, put them on
echo "<div id='controlBar'>";
foreach ($allTabs as $link => $tName) {
    echo "<ul>";
    echo "<a href='" . $link . "'>";
    if (preg_match("/" . $link . "/", $_SERVER['REQUEST_URI'])) {
        echo "<li id='active'>";
    } else {
        echo "<li>";
    }
    echo "<font class='topMenu' icon='" . strtolower($tName) . "'>" . $tName . "</font>";
    $name = checkPlugin(strtolower($tName));
    if (!empty($name)) {
        echo "<ul>";
        foreach ($name as $id => $value) {
            $curPlugin = new Plugins($id);
            $className = $curPlugin->get_class_name();
            echo "<a href='pluginTemplate.php?tab=" . $link . "&pluginID=" . $id . "&className=" . $className . "'><li class='topMenuItem'><font class='subTopMenu' icon='plugIcon" . $id . "'>" . $value . "</font></li></a>";
        }
        echo "</ul>";
    }
    echo "</li></a>\n\t\t\t  </ul>";
}
echo "</div>";
?>

</div>