示例#1
0
 /**
  * Loads the captcha handler specified by the given name.
  * @param $p_handler
  * @return object
  */
 public static function factory($p_handler)
 {
     $pluginName = strtolower($p_handler);
     $path = WWW_DIR . '/plugins/' . $pluginName . '/classes';
     $filePath = "{$path}/Captcha_{$p_handler}.php";
     if (!file_exists($filePath)) {
         throw new InvalidCaptchaHandler($p_handler);
     }
     // check whether the plugin exists and is enabled
     $plugin = new CampPlugin($pluginName);
     if (!$plugin->exists() || !$plugin->isEnabled()) {
         return NULL;
     }
     require_once $filePath;
     $className = "Captcha_{$p_handler}";
     if (!class_exists($className)) {
         throw new InvalidCaptchaHandler($p_handler);
     }
     $captchaObj = new $className();
     return $captchaObj;
 }
示例#2
0
 $p_enabled = Input::Get('p_enabled', 'array');
 // delete from DB those which were uninstalled
 foreach (CampPlugin::getAll() as $CampPlugin) {
     if (!array_key_exists($CampPlugin->getName(), $p_plugins)) {
         if (strpos($CampPlugin->getName(), '/') !== false) {
             continue;
         }
         $CampPlugin->delete();
     }
 }
 foreach ($p_plugins as $plugin => $oldversion) {
     $CampPlugin = new CampPlugin($plugin);
     // installed version, if exists
     $currentVersion = $CampPlugin->getFsVersion();
     if ($p_enabled && array_key_exists($plugin, $p_enabled) && $p_enabled[$plugin]) {
         if ($CampPlugin->exists()) {
             if ($CampPlugin->getDbVersion() != $currentVersion) {
                 // update plugin
                 $CampPlugin->delete();
                 $CampPlugin->create($plugin, $currentVersion);
                 $CampPlugin->update();
                 $CampPlugin->enable();
                 // update autoload
                 exec('php ' . $GLOBALS['g_campsiteDir'] . '/scripts/newscoop.php autoload:update');
             } else {
                 // just enable plugin
                 $CampPlugin->enable();
             }
         } else {
             // install + enable not previously installed plugin
             $CampPlugin->create($plugin, $currentVersion);