Ejemplo n.º 1
0
 function install()
 {
     // Can't install when faster requier Nucleus Core Version
     $ver_min = getNucleusVersion() < $this->getMinNucleusVersion();
     $pat_min = getNucleusVersion() == $this->getMinNucleusVersion() && getNucleusPatchLevel() < $this->getMinNucleusPatchLevel();
     if ($ver_min || $pat_min) {
         global $DIR_LIBS;
         // uninstall plugin again...
         include_once $DIR_LIBS . 'ADMIN.php';
         $admin = new ADMIN();
         $admin->deleteOnePlugin($this->getID());
         // ...and show error
         $admin->error(_ERROR_NUCLEUSVERSIONREQ . $this->getMinNucleusVersion() . ' patch ' . $this->getMinNucleusPatchLevel());
     }
     global $manager, $CONF;
     // Keys initialize
     if (empty($CONF['ArchiveKey'])) {
         $CONF['ArchiveKey'] = 'archive';
     }
     if (empty($CONF['ArchivesKey'])) {
         $CONF['ArchivesKey'] = 'archives';
     }
     if (empty($CONF['MemberKey'])) {
         $CONF['MemberKey'] = 'member';
     }
     if (empty($CONF['ItemKey'])) {
         $CONF['ItemKey'] = 'item';
     }
     if (empty($CONF['CategoryKey'])) {
         $CONF['CategoryKey'] = 'category';
     }
     //Plugins sort
     $plugTable = sql_table('plugin');
     $myid = intval($this->getID());
     $res = sql_query('SELECT pid, porder FROM ' . $plugTable);
     while ($p = sql_fetch_array($res)) {
         $updateQuery = 'UPDATE %s ' . 'SET    porder = %d ' . 'WHERE  pid    = %d';
         if (($pid = intval($p['pid'])) == $myid) {
             $q = sprintf($updateQuery, $plugTable, 1, $myid);
             sql_query($q);
         } else {
             $porder = intval($p['porder']);
             $q = sprintf($updateQuery, $plugTable, $porder + 1, $pid);
             sql_query($q);
         }
     }
     //create plugin's options and set default value
     $this->createOption('customurl_archive', _OP_ARCHIVE_DIR_NAME, 'text', $CONF['ArchiveKey']);
     $this->createOption('customurl_archives', _OP_ARCHIVES_DIR_NAME, 'text', $CONF['ArchivesKey']);
     $this->createOption('customurl_member', _OP_MEMBER_DIR_NAME, 'text', $CONF['MemberKey']);
     $this->createOption('customurl_dfitem', _OP_DEF_ITEM_KEY, 'text', $CONF['ItemKey']);
     $this->createOption('customurl_dfcat', _OP_DEF_CAT_KEY, 'text', $CONF['CategoryKey']);
     $this->createOption('customurl_dfscat', _OP_DEF_SCAT_KEY, 'text', 'subcategory');
     $this->createOption('customurl_incbname', _OP_INCLUDE_CBNAME, 'yesno', 'no');
     $this->createOption('customurl_tabledel', _OP_TABLE_DELETE, 'yesno', 'no');
     $this->createOption('customurl_quicklink', _OP_QUICK_LINK, 'yesno', 'yes');
     $this->createOption('customurl_notfound', _OP_NOT_FOUND, 'select', '404', '404 Not Found|404|303 See Other|303');
     $this->createBlogOption('use_customurl', _OP_USE_CURL, 'yesno', 'yes');
     $this->createBlogOption('redirect_normal', _OP_RED_NORM, 'yesno', 'yes');
     $this->createBlogOption('redirect_search', _OP_RED_SEARCH, 'yesno', 'yes');
     $this->createBlogOption('customurl_bname', _OP_BLOG_PATH, 'text');
     //		$this->createItemOption(    'customurl_iname', _OP_ITEM_PATH,
     //									'text',  $CONF['ItemKey']);
     $this->createMemberOption('customurl_mname', _OP_MEMBER_PATH, 'text');
     $this->createCategoryOption('customurl_cname', _OP_CATEGORY_PATH, 'text');
     //default archive directory name
     $this->setOption('customurl_archive', $CONF['ArchiveKey']);
     //default archives directory name
     $this->setOption('customurl_archives', $CONF['ArchivesKey']);
     //default member directory name
     $this->setOption('customurl_member', $CONF['MemberKey']);
     //default itemkey_template
     $this->setOption('customurl_dfitem', $CONF['ItemKey']);
     //default categorykey_template
     $this->setOption('customurl_dfcat', $CONF['CategoryKey']);
     //default subcategorykey_template
     $this->setOption('customurl_dfscat', 'subcategory');
     //create data table
     $sql = 'CREATE TABLE IF NOT EXISTS ' . _CUSTOMURL_TABLE . ' (' . ' `id` INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY, ' . ' `obj_param` VARCHAR(15) NOT NULL, ' . ' `obj_name` VARCHAR(128) NOT NULL, ' . ' `obj_id` INT(11) NOT NULL, ' . ' `obj_bid` INT(11) NOT NULL,' . ' INDEX (`obj_name`)' . ' )';
     sql_query($sql);
     //setting default aliases
     $this->_createNewPath('blog', 'blog', 'bnumber', 'bshortname');
     $this->_createNewPath('item', 'item', 'inumber', 'iblog');
     $this->_createNewPath('category', 'category', 'catid', 'cblog');
     $this->_createNewPath('member', 'member', 'mnumber', 'mname');
     if ($this->pluginCheck('MultipleCategories')) {
         $scatTableName = 'plug_multiple_categories_sub';
         $this->_createNewPath('subcategory', $scatTableName, 'scatid', 'catid');
     }
 }
Ejemplo n.º 2
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();
 }
Ejemplo n.º 3
0
// switch URLMode back to normal when $CONF['Self'] ends in .php
// this avoids urls like index.php/item/13/index.php/item/15
if (!isset($CONF['URLMode']) || (($CONF['URLMode'] == 'pathinfo') && (substr($CONF['Self'], strlen($CONF['Self']) - 4) == '.php'))) {
	$CONF['URLMode'] = 'normal';
}*/
/*
	Set these to 1 to allow viewing of future items or draft items
	Should really never do this, but can be useful for some plugins that might need to
	Could cause some other issues if you use future posts otr drafts
	So use with care
*/
$CONF['allowDrafts'] = 0;
$CONF['allowFuture'] = 0;
if (getNucleusPatchLevel() > 0) {
    $nucleus['version'] .= '/' . getNucleusPatchLevel();
}
// Avoid notices
if (!isset($CONF['installscript'])) {
    $CONF['installscript'] = 0;
}
/*
 * Include multibyte function if some functions related to  mbstring are not loaded.
 * By Japanese Packaging Team, Jan.31, 2011
 */
if (!function_exists('mb_convert_encoding')) {
    global $mbemu_internals;
    include_libs('mb_emulator/mb-emulator.php', true, false);
}
// we will use postVar, getVar, ... methods instead of HTTP_GET_VARS or _GET
if ($CONF['installscript'] != 1) {