Ejemplo n.º 1
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.º 2
0
    function install()
    {
        sql_query('CREATE TABLE IF NOT EXISTS ' . sql_table('plugin_counter') . ' (
			count_time    DATETIME NOT NULL default "2003-08-15 23:00:00", 
			count_num     INT NOT NULL AUTO_INCREMENT PRIMARY KEY, 
			count_ipcheck VARCHAR(15) NOT NULL default "255.255.255.255" 
			)');
        //sql_query('CREATE INDEX key_count_time ON '. sql_table('plugin_counter') .' (count_time)');
        $check_query = "SELECT * FROM " . sql_table('plugin_counter');
        $check_rows = sql_query($check_query);
        $num_rows = sql_num_rows($check_rows);
        if ($num_rows < 1) {
            $install_date = date("Y-m-d H:i:s");
            $install_ip = $_SERVER['REMOTE_ADDR'];
            $query = "INSERT INTO " . sql_table('plugin_counter') . " VALUES ('{$install_date}','1','{$install_ip}')";
            sql_query($query);
        }
        //basic features
        $this->createOption('graphical_counter', $this->opt['graphical_counter'], 'yesno', 'yes');
        $this->createOption('graphics_path', $this->opt['graphics_path'], 'text', 'nucleus/plugins/counter/');
        $this->createOption('ext', $this->opt['ext'], 'text', 'gif');
        $this->createOption('init_val', $this->opt['init_val'], 'text', '0');
        $this->createOption('figure', $this->opt['figure'], 'text', '6/3');
        $this->createOption('flg_detail', $this->opt['flg_detail'], 'yesno', 'no');
        $this->createOption('flg_week', $this->opt['flg_week'], 'yesno', 'no');
        $this->createOption('flg_bdate', $this->opt['flg_bdate'], 'yesno', 'yes');
        $this->createOption('begin_date', $this->opt['begin_date'], 'text', 'Since ' . date("Y-m-d"));
        //count mode
        if (getNucleusVersion() < 220) {
            $this->createOption('count_mode', $this->opt['count_mode'], 'text', 'ip1');
        } else {
            $this->createOption('count_mode', $this->opt['count_mode'], 'select', 'ip1', 'Normal|normal|IP Check1(time-limit available)|ip1|IP Check2(one count in a day)|ip2');
        }
        $this->createOption('time_limit', $this->opt['time_limit'], 'text', '30');
        $this->createOption('flg_showmode', $this->opt['flg_showmode'], 'yesno', 'yes');
        $this->createOption('flg_pluglink', $this->opt['flg_pluglink'], 'yesno', 'no');
        $this->createOption('flg_erase', $this->opt['flg_erase'], 'yesno', 'no');
    }
Ejemplo n.º 3
0
 function event_PreItem($data)
 {
     global $CONF, $manager;
     if (getNucleusVersion() < '330') {
         $this->currentItem =& $data['item'];
         $pattern = '/<%CustomURL\\((.*)\\)%>/';
         $data['item']->body = preg_replace_callback($pattern, array(&$this, 'URL_Callback'), $data['item']->body);
         if ($data['item']->more) {
             $data['item']->more = preg_replace_callback($pattern, array(&$this, 'URL_Callback'), $data['item']->more);
         }
     }
     $itemid = intval($data['item']->itemid);
     $itemblog =& $manager->getBlog(getBlogIDFromItemID($itemid));
     $blogurl = $itemblog->getURL();
     if (!$blogurl) {
         $b =& $manager->getBlog($CONF['DefaultBlog']);
         if (!($blogurl = $b->getURL())) {
             $blogurl = $CONF['IndexURL'];
             if ($CONF['URLMode'] != 'pathinfo') {
                 if ($data['type'] == 'pageparser') {
                     $blogurl .= 'index.php';
                 } else {
                     $blogurl = $CONF['Self'];
                 }
             }
         }
     }
     if ($CONF['URLMode'] == 'pathinfo') {
         if (substr($blogurl, -1) == '/') {
             $blogurl = substr($blogurl, 0, -1);
         }
     }
     $CONF['BlogURL'] = $blogurl;
     $CONF['ItemURL'] = $blogurl;
     $CONF['CategoryURL'] = $blogurl;
     $CONF['ArchiveURL'] = $blogurl;
     $CONF['ArchiveListURL'] = $blogurl;
     //		$CONF['MemberURL']      = $blogurl;
 }
Ejemplo n.º 4
0
 public function event_PrePluginOptionsEdit($data)
 {
     /* Old version do not support natively */
     if (getNucleusVersion() < 400) {
         if ($data['context'] != 'global') {
             foreach ($data['options'] as $key => $option) {
                 if ($option['pid'] == $this->getID()) {
                     if (defined($option['description'])) {
                         $data['options'][$key]['description'] = constant($option['description']);
                     }
                     if ($option['type'] == 'select') {
                         foreach (explode('|', $option['typeinfo']) as $option) {
                             if (defined($option)) {
                                 $data['options'][$key]['typeinfo'] = str_replace($option, constant($option), $data['options'][$key]['typeinfo']);
                             }
                         }
                     }
                 }
             }
         } else {
             if ($data['plugid'] == $this->getID()) {
                 foreach ($data['options'] as $key => $option) {
                     if (defined($option['description'])) {
                         $data['options'][$key]['description'] = constant($option['description']);
                     }
                     if ($option['type'] == 'select') {
                         foreach (explode('|', $option['typeinfo']) as $option) {
                             if (defined($option)) {
                                 $data['options'][$key]['typeinfo'] = str_replace($option, constant($option), $data['options'][$key]['typeinfo']);
                             }
                         }
                     }
                 }
             }
         }
     }
     return;
 }