Ejemplo n.º 1
0
    public function doBackup()
    {
        $settings = SJB_Settings::getSettings();
        if ($settings['autobackup'] && !SJB_System::getSystemSettings('isDemo') && !SJB_System::getIfTrialModeIsOn()) {
            $dirSeparator = DIRECTORY_SEPARATOR;
            $scriptPath = explode(SJB_System::getSystemSettings('SYSTEM_URL_BASE'), __FILE__);
            $scriptPath = array_shift($scriptPath);
            $path = $scriptPath . 'backup' . $dirSeparator;
            $identifier = time();
            $backupsArr = $this->getAllBackups($path);
            $this->deleteBackupAfterExpired($backupsArr);
            if ($this->isAutobackup()) {
                SessionStorage::destroy('backup_' . $identifier);
                SessionStorage::write('backup_' . $identifier, serialize(array('last_time' => time())));
                SJB_Session::unsetValue('restore');
                SJB_Session::unsetValue('error');
                $backupDir = $scriptPath . 'backup' . $dirSeparator;
                if (!is_dir($backupDir)) {
                    mkdir($backupDir);
                }
                if (!file_exists($backupDir . '.htaccess')) {
                    $handle = fopen($backupDir . '.htaccess', 'a');
                    $text = '# Apache 2.4
<IfModule mod_authz_core.c>
	<FilesMatch ".*">
		Require all denied
	</FilesMatch>
</IfModule>

# Apache 2.2
<IfModule !mod_authz_core.c>
	<FilesMatch ".*">
		Order Allow,Deny
		Deny from all
	</FilesMatch>
</IfModule>';
                    fwrite($handle, $text);
                    fclose($handle);
                }
                $backupType = SJB_System::getSettingByName('backup_type');
                switch ($backupType) {
                    case 'full':
                        $this->makeFullBackup($identifier, $scriptPath, $dirSeparator);
                        break;
                    case 'database':
                        $this->makeDatabaseBackup($identifier, $dirSeparator, $scriptPath);
                        break;
                    case 'files':
                        $this->makeFilesBackup($identifier, $scriptPath, $dirSeparator);
                        break;
                }
                SJB_Settings::updateSetting('last_autobackup', date("Y-m-d H:i:s"));
            }
        }
    }
Ejemplo n.º 2
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $errors = array();
     $formSubmitted = SJB_Request::getVar('action');
     $bitlyInfo = new SJB_Bitly($_REQUEST);
     $bitlyForm = new SJB_Form($bitlyInfo);
     if ($formSubmitted == 'saveSettings') {
         $bitlyForm->isDataValid($errors);
         if (!$errors) {
             SJB_Settings::updateSettings($_REQUEST);
             SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . "/social-media/bitly/");
         }
     }
     $tp->assign("settings", SJB_Settings::getSettings());
     $tp->assign("errors", $errors);
     $tp->display("bitly.tpl");
 }
Ejemplo n.º 3
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $errors = array();
     $form_submitted = SJB_Request::getVar('action');
     $page = SJB_Request::getVar('page');
     if ($form_submitted) {
         if (SJB_System::getSystemSettings("isDemo")) {
             $errors[] = "You don't have permissions for it. This is a Demo version of the software.";
         } else {
             if (!empty($_REQUEST['bad_words'])) {
                 $_REQUEST['bad_words'] = trim($_REQUEST['bad_words']);
             }
             SJB_Settings::updateSettings($_REQUEST);
         }
         if ($form_submitted == 'apply_settings') {
             $tp->assign("page", $page);
         }
     }
     $i18n = SJB_I18N::getInstance();
     $tp->assign("settings", SJB_Settings::getSettings());
     $ds = DIRECTORY_SEPARATOR;
     $path = SJB_BASE_DIR . "system{$ds}cache{$ds}agents_bots.txt";
     $disable_bots = file_get_contents($path);
     $tp->assign("disable_bots", $disable_bots);
     $tp->assign("timezones", timezone_identifiers_list());
     if (!SJB_SubAdmin::getSubAdminSID()) {
         $tp->assign("subadmins", SJB_SubAdminManager::getAllSubAdminsInfo());
     }
     $tp->assign("errors", $errors);
     $tp->assign("i18n_domains", $i18n->getDomainsData());
     $tp->assign("i18n_languages", $i18n->getActiveLanguagesData());
     $tp->assign("countries", SJB_CountriesManager::getAllCountriesCodesAndNames());
     $tp->assign('listingEmailTemplates', SJB_EmailTemplateEditor::getEmailTemplatesByGroup(SJB_NotificationGroups::GROUP_ID_LISTING));
     $tp->assign('productEmailTemplates', SJB_EmailTemplateEditor::getEmailTemplatesByGroup(SJB_NotificationGroups::GROUP_ID_PRODUCT));
     $tp->assign('userEmailTemplates', SJB_EmailTemplateEditor::getEmailTemplatesByGroup(SJB_NotificationGroups::GROUP_ID_USER));
     $tp->assign('otherEmailTemplates', SJB_EmailTemplateEditor::getEmailTemplatesByGroup(SJB_NotificationGroups::GROUP_ID_OTHER));
     $tp->display("settings.tpl");
 }
Ejemplo n.º 4
0
 public static function editCaptcha($info)
 {
     $captchaType = !empty($info['type']) ? $info['type'] : '';
     $info['template'] = '../../../system/plugins/captcha/edit_captcha.tpl';
     $event = !empty($info['event']) ? $info['event'] : false;
     $settings = array();
     $errors = array();
     switch ($captchaType) {
         case 'reCaptcha':
             if ($event == 'save' && !empty($info['settings'])) {
                 foreach ($info['settings'] as $setting => $val) {
                     if ($val == '') {
                         $errors[$setting] = 'empty';
                     }
                 }
                 if (!$errors) {
                     SJB_Settings::updateSettings($info['settings']);
                     if (SJB_Request::getVar('submit') == 'save') {
                         SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/system/miscellaneous/plugins/?action=settings&plugin=CaptchaPlugin');
                     }
                 }
             }
             $settings = array(array('id' => 'reCaptchaPubkey', 'caption' => 'Public Key', 'type' => 'string', 'length' => '50', 'order' => null, 'comment' => 'To get these Keys go to http://google.com/recaptcha/admin/create,<br/> register/sign in and then create a reCAPTCHA key following the given instructions.'), array('id' => 'reCaptchaPrivkey', 'caption' => 'Private Key', 'type' => 'string', 'length' => '50', 'order' => null, 'comment' => 'To get these Keys go to http://google.com/recaptcha/admin/create,<br/> register/sign in and then create a reCAPTCHA key following the given instructions.'), array('id' => 'reCaptchaTheme', 'caption' => 'Theme', 'type' => 'list', 'list_values' => array(array('id' => 'red', 'caption' => 'red'), array('id' => 'white', 'caption' => 'white'), array('id' => 'blackglass', 'caption' => 'blackglass'), array('id' => 'clean', 'caption' => 'clean')), 'length' => '50', 'order' => null));
             break;
         case 'customCaptcha':
             if ($event == 'save' && !empty($info['settings'])) {
                 foreach ($info['settings'] as $setting => $val) {
                     if ($val == '') {
                         $errors[$setting] = 'empty';
                     }
                 }
                 if (!$errors) {
                     SJB_Settings::updateSettings($info['settings']);
                     if (SJB_Request::getVar('submit') == 'save') {
                         SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/system/miscellaneous/plugins/?action=settings&plugin=CaptchaPlugin');
                     }
                 }
             }
             $fontsDir = dir(SJB_BASE_DIR . "system/plugins/captcha/fonts");
             $fonts = array();
             $i = 0;
             while (false !== ($entry = $fontsDir->read())) {
                 if (strstr($entry, '.ttf') || strstr($entry, '.TTF')) {
                     $fonts[$i]['id'] = $fonts[$i]['caption'] = str_replace('.TTF', '', str_replace('.ttf', '', $entry));
                     $i++;
                 }
             }
             $settings = array(array('id' => 'custCaptchaFont', 'caption' => 'Font', 'type' => 'list', 'length' => '50', 'list_values' => $fonts, 'order' => null), array('id' => 'custCaptchaFontSize', 'caption' => 'Font Size', 'type' => 'integer', 'length' => '50', 'comment' => 'Allow you to specify the font size in pixels for generating the CAPTCHA. The default is 24px.', 'order' => null), array('id' => 'custCaptchaHeight', 'caption' => 'Height', 'type' => 'integer', 'length' => '50', 'order' => null), array('id' => 'custCaptchaWidth', 'caption' => 'Width', 'type' => 'integer', 'length' => '50', 'order' => null), array('id' => 'custCaptchaWordlen', 'caption' => 'Word Length', 'type' => 'integer', 'comment' => 'Allow you to specify the length of the generated "word" in characters.', 'length' => '50', 'order' => null), array('id' => 'custDotNoiseLevel', 'caption' => 'Dot Noise Level', 'type' => 'integer', 'length' => '50', 'order' => null), array('id' => 'custLineNoiseLevel', 'caption' => 'Line Noise Level', 'type' => 'integer', 'length' => '50', 'order' => null));
             break;
     }
     $info['fieldErrors'] = $errors;
     $info['savedSettings'] = SJB_Settings::getSettings();
     $info['settings'] = $settings;
     return $info;
 }
Ejemplo n.º 5
0
 public function execute()
 {
     ini_set('max_execution_time', 0);
     $errors = array();
     $tp = SJB_System::getTemplateProcessor();
     $action = SJB_Request::getVar('action', false);
     $dir_separator = DIRECTORY_SEPARATOR;
     $script_path = explode(SJB_System::getSystemSettings('SYSTEM_URL_BASE'), __FILE__);
     $script_path = array_shift($script_path);
     $identifier = SJB_Request::getVar('identifier', time());
     $filename = SJB_Request::getVar('filename', false);
     $settings = array();
     if ($filename) {
         SJB_Backup::sendArchiveFile($filename, $script_path . 'backup' . $dir_separator . $filename);
     }
     if (SJB_Request::getVar('action') == "save") {
         $expPeriod = SJB_Request::getVar('backup_expired_period');
         if (!empty($expPeriod) && (!is_numeric($expPeriod) || $expPeriod < 0)) {
             $errors[] = 'EXP_PERIOD_NOT_VALID';
         }
         $ftpValid = $this->isFTPDataValid();
         if (SJB_Request::getVar('autobackup', false) && SJB_Request::getVar('ftp_backup', false) && !$ftpValid) {
             $errors[] = 'FTP_DETAILS_NOT_VALID';
         }
         if (empty($errors)) {
             $backupSettings = $_REQUEST;
             foreach ($backupSettings as $setting => $value) {
                 if (!SJB_Settings::saveSetting($setting, $value)) {
                     $errors['SETTINGS_SAVED_WITH_PROBLEMS'] = "SETTINGS_SAVED_WITH_PROBLEMS";
                 }
             }
             if (empty($errors)) {
                 $tp->assign('successSaveMessage', true);
             }
         } else {
             $settings = $_REQUEST;
         }
     }
     switch ($action) {
         case 'backup':
             if (SJB_System::getSystemSettings('isDemo')) {
                 $i18N = SJB_I18N::getInstance();
                 $str = $i18N->gettext('Backend', 'Error: You don\'t have permissions for it. This is a Demo version of the software.');
                 SJB_Session::setValue('error', $str);
                 break;
             }
             if (SJB_System::getIfTrialModeIsOn() && $_SERVER['REMOTE_ADDR'] != "91.205.51.231") {
                 $i18N = SJB_I18N::getInstance();
                 $str = $i18N->gettext('Backend', 'Error: You don\'t have permissions for it. This is a Trial version of the software.');
                 SJB_Session::setValue('error', $str);
                 break;
             }
             SessionStorage::destroy('backup_' . $identifier);
             SessionStorage::write('backup_' . $identifier, serialize(array('last_time' => time())));
             SJB_Session::unsetValue('restore');
             SJB_Session::unsetValue('error');
             $backup_type = SJB_Request::getVar('backup_type');
             $backupDir = $script_path . 'backup' . $dir_separator;
             try {
                 $this->prepareBackupDir($backupDir);
             } catch (Exception $e) {
                 SJB_Session::setValue('error', $e->getMessage());
                 exit;
             }
             switch ($backup_type) {
                 case 'full':
                     SessionStorage::write('backup_' . $identifier, serialize(array('last_time' => time())));
                     $backupDir = $script_path;
                     $name = 'db.sql';
                     SJB_Backup::dump($name, $script_path, $identifier);
                     $d = dir($script_path);
                     $contentDir = array();
                     $folders = array('.', '..', 'backup', '.svn', '.settings', '.cache', 'restore', $name);
                     while (false !== ($entry = $d->read())) {
                         if (!in_array($entry, $folders)) {
                             $contentDir[] = $entry;
                         }
                     }
                     $listFilesAndFolders = !empty($contentDir) ? $contentDir : false;
                     $backupName = 'full_backup_' . date('Y_m_d__H_i') . '.tar.gz';
                     $export_files_dir_name = '..' . $dir_separator;
                     if (SJB_Backup::archive($name, $listFilesAndFolders, $backupDir, $export_files_dir_name, $backupName, true, $identifier, 'full')) {
                         SessionStorage::write('backup_' . $identifier, serialize(array('name' => $backupName)));
                     }
                     exit;
                     break;
                 case 'database':
                     SessionStorage::write('backup_' . $identifier, serialize(array('last_time' => time())));
                     $name = 'db.sql';
                     $backupName = 'mysqldump_' . date('Y_m_d__H_i') . '.tar.gz';
                     $export_files_dir_name = '../backup' . $dir_separator;
                     SJB_Backup::dump($name, $script_path, $identifier);
                     if (SJB_Backup::archive(false, $name, $script_path, $export_files_dir_name, $backupName, false, $identifier, 'database')) {
                         SessionStorage::write('backup_' . $identifier, serialize(array('name' => $backupName)));
                     }
                     exit;
                     break;
                 case 'files':
                     SessionStorage::write('backup_' . $identifier, serialize(array('last_time' => time())));
                     $backupDir = $script_path;
                     $d = dir($script_path);
                     $contentDir = array();
                     $folders = array('.', '..', 'backup', '.svn', '.settings', '.cache', 'restore');
                     while (false !== ($entry = $d->read())) {
                         if (!in_array($entry, $folders)) {
                             $contentDir[] = $entry;
                         }
                     }
                     $listFilesAndFolders = !empty($contentDir) ? $contentDir : false;
                     $backupName = 'backup_' . date('Y_m_d__H_i') . '.tar.gz';
                     $export_files_dir_name = '..' . $dir_separator;
                     if (SJB_Backup::archive(false, $listFilesAndFolders, $backupDir, $export_files_dir_name, $backupName, true, $identifier, 'files')) {
                         SessionStorage::write('backup_' . $identifier, serialize(array('name' => $backupName)));
                     }
                     exit;
                     break;
             }
             break;
         case 'restore':
             if (SJB_System::getSystemSettings('isDemo')) {
                 SJB_Session::setValue('error', 'Error: You don\'t have permissions for it. This is a Demo version of the software.');
                 exit;
             }
             if (SJB_System::getIfTrialModeIsOn()) {
                 SJB_Session::setValue('error', 'Error: You don\'t have permissions for it. This is a Trial version of the software.');
                 exit;
             }
             SJB_Session::unsetValue('restore');
             SJB_Session::unsetValue('error');
             $error = false;
             $restoreDir = $script_path . 'restore' . $dir_separator;
             try {
                 $fileName = $this->moveUploadedFile($restoreDir);
                 $tar = new Archive_Tar($restoreDir . $fileName, 'gz');
                 $tar->_error_class = 'SJB_PEAR_Exception';
                 $tar->extractList('db.sql', $restoreDir);
                 $tar->extract($script_path);
                 if (is_file($restoreDir . 'db.sql')) {
                     SJB_Backup::restore_base_tables($restoreDir . 'db.sql');
                 }
                 SJB_Cache::getInstance()->clean();
             } catch (Exception $ex) {
                 $error = $ex->getMessage();
             }
             SJB_Filesystem::delete($restoreDir);
             if (is_file($script_path . 'install.php')) {
                 SJB_Filesystem::delete($script_path . 'install.php');
             }
             if ($error) {
                 SJB_Session::setValue('error', $error);
             } else {
                 SJB_Session::setValue('restore', 1);
             }
             exit;
             break;
         case 'send_archive':
             $name = SJB_Request::getVar('name', false);
             $archive_file_path = SJB_Path::combine(SJB_BASE_DIR . 'backup' . $dir_separator, $name);
             if ($name) {
                 SJB_Backup::sendArchiveFile($name, $archive_file_path);
             }
             break;
         case 'check':
             $sessionBackup = SessionStorage::read('backup_' . $identifier);
             $sessionBackup = $sessionBackup ? unserialize($sessionBackup) : array();
             $sessionRestore = SJB_Session::getValue('restore');
             $sessionError = SJB_Session::getValue('error');
             if (!empty($sessionBackup['name'])) {
                 $name = $sessionBackup['name'];
                 SessionStorage::destroy('backup_' . $identifier);
                 echo SJB_System::getSystemSettings('SITE_URL') . "/backup/?action=send_archive&name={$name}";
                 exit;
             } elseif (!empty($sessionRestore)) {
                 SJB_Session::unsetValue('restore');
                 echo SJB_System::getSystemSettings('SITE_URL') . '/backup/#restore';
                 exit;
             } elseif (!empty($sessionError)) {
                 echo 'Error';
                 if (SJB_System::getSystemSettings('isDemo')) {
                     echo ': You don\'t have permissions for it. This is a Demo version of the software.';
                 }
                 if (SJB_System::getIfTrialModeIsOn()) {
                     echo ': You don\'t have permissions for it. This is a Trial version of the software.';
                 }
                 exit;
             } elseif (!empty($sessionBackup['last_time'])) {
                 $period = (time() - $sessionBackup['last_time']) / 60;
                 if ($period < 5) {
                     echo 1;
                 } else {
                     SJB_Session::setValue('error', 'The backup generation process was unexpectedly interrupted. Please try again.');
                     echo 'error';
                 }
                 exit;
             } else {
                 echo 1;
             }
             exit;
             break;
         case 'delete_backup':
             $name = SJB_Request::getVar('name', false);
             if ($name) {
                 $backup = $script_path . 'backup' . $dir_separator . $name;
                 if (is_file($backup)) {
                     SJB_Filesystem::delete($backup);
                     SJB_Autobackup::deleteFileFromFtp($name);
                 } else {
                     $errors['FILE_NOT_FOUND'] = 1;
                 }
             }
             $tp->assign('errors', $errors);
             $tp->assign('delBackup', 1);
         case 'created_backups':
             $path = $script_path . 'backup' . $dir_separator;
             if (is_dir($path)) {
                 $di = new DirectoryIterator($path);
                 $backupsArr = array();
                 foreach ($di as $file) {
                     $fileName = $file->getFilename();
                     if (!$file->isDir() && !$file->isLink() && $fileName != '.htaccess') {
                         $cTime = $file->getCTime();
                         $backupsArr[$cTime]['name'] = $fileName;
                         if (preg_match('/mysqldump/', $fileName)) {
                             $backupsArr[$cTime]['type'] = 'Site database only';
                         } elseif (preg_match('/full_backup/', $fileName)) {
                             $backupsArr[$cTime]['type'] = 'Full site backup';
                         } elseif (preg_match('/backup/', $fileName)) {
                             $backupsArr[$cTime]['type'] = 'Site files only';
                         } else {
                             $backupsArr[$cTime]['type'] = 'Unknown';
                         }
                         $pattern = '/(\\w+)_(\\d+)_(\\d+)_(\\d+)__(\\d+)_(\\d+).tar.gz/i';
                         $replacement = '$2-$3-$4 $5:$6';
                         $backupsArr[$cTime]['date'] = preg_replace($pattern, $replacement, $fileName);
                     }
                 }
                 krsort($backupsArr);
                 $tp->assign('created_backups', $backupsArr);
             }
             $tp->display('created_backups.tpl');
             exit;
             break;
         case 'error':
             $sessionError = SJB_Session::getValue('error');
             if (!is_null($sessionError)) {
                 echo '<p class="error">' . $sessionError . '</p>';
                 exit;
             }
             break;
     }
     if (empty($settings)) {
         $settings = SJB_Settings::getSettings();
     }
     $tp->assign('errors', $errors);
     $tp->assign('settings', $settings);
     $tp->assign('identifier', $identifier);
     $tp->assign("uploadMaxFilesize", SJB_UploadFileManager::getIniUploadMaxFilesize());
     $tp->display('backup.tpl');
 }
Ejemplo n.º 6
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $errors = array();
     $networkFeeds = array();
     $template = 'social_media.tpl';
     $formSubmitted = SJB_Request::getVar('submit');
     $action = SJB_Request::getVar('action');
     $subAction = SJB_Request::getVar('sub_action');
     $sid = SJB_Request::getVar('sid');
     $groups = array();
     $accountInfo = null;
     $messages = array();
     $savedSettings = array();
     if (SJB_Request::getVar('error', false)) {
         $errors[] = SJB_Request::getVar('error', false);
     }
     if (SJB_Request::getVar('message', false)) {
         $messages[] = SJB_Request::getVar('message', false);
     }
     $socNetworks = array('facebook' => array('name' => 'Facebook'), 'linkedin' => array('name' => 'Linkedin'), 'twitter' => array('name' => 'Twitter'), 'googleplus' => array('name' => 'Google+'), 'bitly' => array('name' => 'Bitly'));
     $network = SJB_Request::getVar('passed_parameters_via_uri');
     if (empty($network)) {
         $network = SJB_Request::getVar('soc_network');
     }
     switch ($network) {
         case 'facebook':
             $template = 'social_media_settings.tpl';
             $objectName = 'SJB_FacebookSocial';
             break;
         case 'linkedin':
             $template = 'social_media_settings.tpl';
             $objectName = 'SJB_LinkedInSocial';
             break;
         case 'twitter':
             $template = 'social_media_settings.tpl';
             $objectName = 'SJB_TwitterSocial';
             break;
         case 'googleplus':
             $template = 'social_media_settings.tpl';
             $objectName = 'SJB_GooglePlusSocial';
             break;
         default:
             $network = '';
             $action = '';
             $objectName = '';
             break;
     }
     switch ($action) {
         case 'add_feed':
             SJB_Session::unsetValue($network);
             SJB_Session::unsetValue($network . 'Feed');
             $template = 'feed_input_form.tpl';
             $accountID = SJB_Request::getVar('account_id', false);
             $isAuthorized = SJB_Request::getVar('authorized', false);
             if ($accountID) {
                 $tp->assign('accountID', $accountID);
             }
             $feed = new $objectName();
             $addForm = new SJB_Form($feed);
             $addForm->registerTags($tp);
             $searchFormBuilder = new SJB_SearchFormBuilder($feed);
             $criteria = SJB_SearchFormBuilder::extractCriteriaFromRequestData($_REQUEST);
             $searchFormBuilder->setCriteria($criteria);
             $searchFormBuilder->registerTags($tp);
             $systemFields = $feed->details->systemFields;
             $postingFields = $feed->details->postingFields;
             $listingFields = $feed->details->commonFields;
             $tp->assign('authorized', $isAuthorized);
             $tp->assign('listingFields', $listingFields);
             $tp->assign('postingFields', $postingFields);
             $tp->assign('systemFields', $systemFields);
             $tp->assign('action', $action);
             break;
         case 'save_feed':
             $template = 'feed_input_form.tpl';
             $fieldErrors = array();
             $mediaObject = $objectName . 'Media';
             $networkSocialMedia = new $mediaObject();
             $isAuthorized = SJB_Request::getVar('authorized', false);
             $actionFeed = SJB_Request::getVar('action_feed');
             if ($actionFeed != 'add_feed' && $network != 'twitter') {
                 try {
                     $accountInfo = $networkSocialMedia->getAccountInfo($sid);
                 } catch (Exception $e) {
                     $isAuthorized = false;
                     $errors[] = SJB_I18N::getInstance()->gettext('Backend', $e->getMessage());
                 }
             }
             $isGroupsExist = !empty($accountInfo['groups']);
             if (SJB_Request::getVar('process_token', false)) {
                 $_REQUEST = unserialize(SJB_Session::getValue($network . 'Feed'));
                 $_REQUEST['process_token'] = 1;
             }
             $feed = new $objectName($_REQUEST, $isGroupsExist, $isAuthorized);
             if ($isGroupsExist) {
                 $groups = $accountInfo['groups'];
             }
             if ($sid) {
                 $feed->setSID($sid);
                 $tp->assign('feed_sid', $sid);
             }
             $criteriaSaver = new SJB_ListingCriteriaSaver();
             $criteriaSaver->setSessionForCriteria($_REQUEST);
             $requestedData = $criteriaSaver->getCriteria();
             $searchFormBuilder = new SJB_SearchFormBuilder($feed);
             $criteria = SJB_SearchFormBuilder::extractCriteriaFromRequestData($_REQUEST);
             $searchFormBuilder->setCriteria($criteria);
             $searchFormBuilder->registerTags($tp);
             $properties = $feed->getProperties();
             foreach ($properties as $key => $property) {
                 if (!$property->isSystem()) {
                     $feed->deleteProperty($key);
                 }
             }
             $this->checkToken($tp, $networkSocialMedia, $errors, array(), $network, $sid);
             $addForm = new SJB_Form($feed);
             $addForm->registerTags($tp);
             if ($addForm->isDataValid($fieldErrors)) {
                 if ($network == 'twitter') {
                     try {
                         $accessToken = $networkSocialMedia->getAccessToken($sid, $action, $errors);
                     } catch (Exception $e) {
                         $accessToken = false;
                         $errors[] = SJB_I18N::getInstance()->gettext('Backend', $e->getMessage());
                     }
                     if (empty($errors) && $accessToken != false) {
                         $feed->addProperty(array('id' => 'access_token', 'type' => 'text', 'value' => serialize($accessToken), 'is_system' => true));
                     }
                 } else {
                     if ($network == 'facebook' && !empty($accountInfo)) {
                         $feed->addProperty(array('id' => 'access_token', 'type' => 'text', 'value' => serialize($accountInfo['access_token']), 'is_system' => true));
                         $feed->addProperty(array('id' => 'account_name', 'type' => 'text', 'value' => serialize($accountInfo['account_name']), 'is_system' => true));
                     }
                 }
                 if (empty($errors)) {
                     unset($requestedData['groups']);
                     $feed->addProperty(array('id' => 'search_data', 'type' => 'text', 'value' => serialize($requestedData), 'is_system' => true));
                     $feed->saveFeed($feed, $action);
                     if ($formSubmitted == 'save') {
                         SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/social-media/' . $network . '#postJobs');
                     }
                     $tp->assign('feed_sid', $feed->getSID());
                 }
             }
             $systemFields = $feed->details->systemFields;
             $postingFields = $feed->details->postingFields;
             $listingFields = $feed->details->commonFields;
             $changeAccountUrl = "action=authorize&sid={$sid}&sub_action=change_account&soc_network={$network}";
             $tp->assign('field_errors', $fieldErrors);
             $tp->assign('change_url', $changeAccountUrl);
             $tp->assign('listingFields', $listingFields);
             $tp->assign('postingFields', $postingFields);
             $tp->assign('systemFields', $systemFields);
             $tp->assign('action', $actionFeed);
             $tp->assign('authorized', $isAuthorized);
             $tp->assign('allGroups', $groups);
             break;
         case 'grant':
             $mediaObject = $objectName . 'Media';
             $networkSocialMedia = new $mediaObject();
             $error = '';
             try {
                 $accountInfo = $networkSocialMedia->getAccountInfo($sid, $subAction);
             } catch (Exception $e) {
                 $tp->assign('authorized', false);
                 $error = $e->getMessage();
             }
             if (empty($error)) {
                 $networkSocialMedia->updateAccessToken($sid, $accountInfo['account_id'], $accountInfo['account_name']);
                 $logoutUrl = SJB_System::getSystemSettings('SITE_URL') . "/social-media/{$network}?message=ACCOUNT_UPDATED#postJobs";
             } else {
                 $logoutUrl = SJB_System::getSystemSettings('SITE_URL') . "/social-media/{$network}?error={$error}#postJobs";
             }
             // After clicking the 'Grant Permission' button and login to Facebook we are redirected to the feeds list.
             SJB_HelperFunctions::redirect($logoutUrl);
             break;
         case 'edit_feed':
             if (!SJB_Request::getVar('oauth_token', false)) {
                 SJB_Session::unsetValue($network);
             }
             if (!SJB_Request::getVar('process_token', false)) {
                 SJB_Session::unsetValue($network . 'Feed');
             }
             if ($sid) {
                 $changeAccountUrl = "action=authorize&sid={$sid}&sub_action=change_account&soc_network={$network}";
                 $feedInfo = $objectName::getFeedInfoByNetworkIdAndSID($network, $sid);
                 $feedInfo = array_merge($feedInfo, $_REQUEST);
                 $criteriaInfo = $feedInfo['search_data'] ? unserialize($feedInfo['search_data']) : '';
                 $mediaObject = $objectName . 'Media';
                 $networkSocialMedia = new $mediaObject();
                 $isAuthorized = true;
                 if ($network != 'twitter') {
                     try {
                         $accountInfo = $networkSocialMedia->getAccountInfo($sid, $subAction);
                     } catch (Exception $e) {
                         $isAuthorized = false;
                         $errors[] = SJB_I18N::getInstance()->gettext('Backend', $e->getMessage());
                     }
                 }
                 $isGroupsExist = !empty($accountInfo['groups']);
                 if ($isGroupsExist) {
                     $groups = $accountInfo['groups'];
                 }
                 if ($accountInfo && $subAction == 'changed') {
                     $feedInfo = array_merge($feedInfo, $accountInfo);
                 }
                 $feed = new $objectName($feedInfo, $isGroupsExist, $isAuthorized);
                 $editForm = new SJB_Form($feed);
                 $editForm->registerTags($tp);
                 $searchFormBuilder = new SJB_SearchFormBuilder($feed);
                 $criteria = SJB_SearchFormBuilder::extractCriteriaFromRequestData($criteriaInfo);
                 $searchFormBuilder->setCriteria($criteria);
                 $searchFormBuilder->registerTags($tp);
                 $systemFields = $feed->details->systemFields;
                 $postingFields = $feed->details->postingFields;
                 $listingFields = $feed->details->commonFields;
                 $this->checkToken($tp, $networkSocialMedia, $errors, $feedInfo, $network, $sid);
                 $tp->assign('listingFields', $listingFields);
                 $tp->assign('postingFields', $postingFields);
                 $tp->assign('systemFields', $systemFields);
                 $tp->assign('feed_sid', $sid);
                 $tp->assign('authorized', $isAuthorized);
                 $tp->assign('allGroups', $groups);
                 $tp->assign('action', $action);
                 $tp->assign('change_url', $changeAccountUrl);
                 $template = 'feed_input_form.tpl';
             }
             break;
         case 'authorize':
             if (!SJB_Request::getVar('oauth_token', false)) {
                 SJB_Session::unsetValue($network);
             }
             $mediaObject = $objectName . 'Media';
             $networkSocialMedia = new $mediaObject();
             try {
                 if ($network == 'twitter') {
                     $accessToken = $networkSocialMedia->getAccessToken($sid, $subAction, $errors);
                     $networkSocialMedia->updateFeedToken($sid, $accessToken);
                     if (SJB_Request::getVar('sub_action', null, 'GET') == 'grant') {
                         if (empty($errors)) {
                             $messages[] = 'Account is successfully updated.';
                         }
                         break;
                     }
                 } else {
                     $accountInfo = $networkSocialMedia->getAccountInfo($sid, $subAction);
                 }
             } catch (Exception $e) {
                 $errors[] = SJB_I18N::getInstance()->gettext('Backend', $e->getMessage());
             }
             $changeAccountUrl = "action=authorize&sub_action=change_account&soc_network={$network}";
             $template = 'feed_input_form.tpl';
             $isAuthorized = isset($accountInfo['account_id']);
             $isGroupsExist = !empty($accountInfo['groups']);
             $feed = new $objectName($accountInfo, $isGroupsExist, $isAuthorized);
             if ($isGroupsExist) {
                 $groups = $accountInfo['groups'];
             }
             $addForm = new SJB_Form($feed);
             $addForm->registerTags($tp);
             $searchFormBuilder = new SJB_SearchFormBuilder($feed);
             $criteria = SJB_SearchFormBuilder::extractCriteriaFromRequestData($_REQUEST);
             $searchFormBuilder->setCriteria($criteria);
             $searchFormBuilder->registerTags($tp);
             $systemFields = $feed->details->systemFields;
             $postingFields = $feed->details->postingFields;
             $listingFields = $feed->details->commonFields;
             $tp->assign('listingFields', $listingFields);
             $tp->assign('postingFields', $postingFields);
             $tp->assign('systemFields', $systemFields);
             $tp->assign('action', $action);
             $tp->assign('authorized', $isAuthorized);
             $tp->assign('change_url', $changeAccountUrl);
             $tp->assign('allGroups', $groups);
             break;
         case 'delete_feed':
             $sid = SJB_Request::getVar('sid');
             if ($sid) {
                 $feed = new $objectName();
                 $feed->deleteFeed($sid);
                 SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/social-media/' . $network . '#postJobs');
             }
             break;
         case 'status':
             $sid = SJB_Request::getVar('sid');
             $active = SJB_Request::getVar('active');
             $feedInfo = $objectName::getFeedInfoByNetworkIdAndSID($network, $sid);
             if ($feedInfo != null && ($active == '1' || $active == '0')) {
                 $objectName::updateFeedStatus($network . '_feeds', $active, $sid);
                 SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/social-media/' . $network . '#postJobs');
             } else {
                 $errors[] = 'Feed does not exist';
             }
             break;
         case 'save_settings':
             $request = $_REQUEST;
             $error = $this->checkFields($request, $objectName);
             if (!$error) {
                 SJB_Settings::updateSettings($request);
                 if ($formSubmitted == 'save') {
                     SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/social-media/');
                 } else {
                     if ($formSubmitted == 'apply') {
                         SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/social-media/' . $network);
                     }
                 }
             }
             $savedSettings = $request;
             break;
     }
     if ($network) {
         if (empty($savedSettings)) {
             $savedSettings = SJB_Settings::getSettings();
         }
         SJB_Event::dispatch('RedefineSavedSetting', $savedSettings, true);
         if ($network != 'googleplus' && $action != 'edit_feed' && $action != 'add_feed' && $action != 'save_feed') {
             $networkFeeds = SJB_SocialMedia::getFeedsInfoByNetworkID($network);
             $currentDate = date('Y-m-d', time());
             foreach ($networkFeeds as $key => $feed) {
                 if (SJB_SocialMedia::isFeedExpired($feed, $currentDate)) {
                     $networkFeeds[$key]['expired'] = true;
                 }
             }
         }
         $tp->assign('network', $network);
         $tp->assign('savedSettings', $savedSettings);
         $tp->assign('networkFeeds', $networkFeeds);
         $tp->assign('networkName', $socNetworks[$network]['name']);
         if ($network != 'twitter') {
             $networkObject = new $objectName();
             $settings = $networkObject->getConnectSettings();
             $tp->assign('settings', $settings);
         }
     } else {
         $tp->assign('socNetworks', $socNetworks);
     }
     $tp->assign('networkFeeds', $networkFeeds);
     $tp->assign('socNetworks', $socNetworks);
     $tp->assign('errors', $errors);
     $tp->assign('messages', $messages);
     $tp->display($template);
 }
Ejemplo n.º 7
0
 public static function init()
 {
     SJB_DB::init(SJB_System::getSystemSettings('DBHOST'), SJB_System::getSystemSettings('DBUSER'), SJB_System::getSystemSettings('DBPASSWORD'), SJB_System::getSystemSettings('DBNAME'));
     ini_set('zlib.output_compression', SJB_System::getSettingByName('gzip_compression'));
     $GLOBALS['fatal_error_reserve_buffer'] = str_repeat('x', 1024 * 200);
     ob_start(array('SJB_Error', 'fatalErrorHandler'));
     SJB_Session::init(SJB_System::getSystemSettings('SITE_URL'));
     $sessionId = SJB_DB::queryValue("SELECT `session_id` FROM `user_session_data_storage` WHERE `session_id` = ?s", SJB_Session::getSessionId());
     // if not updated (row not exists) - insert that value
     if (empty($sessionId)) {
         SJB_DB::query("INSERT INTO `user_session_data_storage` SET `last_activity` = NOW(), `session_id` = ?s", SJB_Session::getSessionId());
     } else {
         SJB_DB::query("UPDATE `user_session_data_storage` SET `last_activity` = NOW() WHERE `session_id` = ?s", $sessionId);
     }
     //set timezone
     if (SJB_Settings::getSettingByName('timezone')) {
         ini_set('date.timezone', SJB_Settings::getSettingByName('timezone'));
     }
     // Set Error Handler and Shutdown function
     set_error_handler(array('SJB_Error', 'errorHandler'));
     register_shutdown_function(array('SJB_System', 'shutdownFunction'));
     SJB_System::prepareGlobalArrays();
     SJB_System::setGlobalTemplateVariable('is_ajax', SJB_Request::isAjax());
     SJB_System::setGlobalTemplateVariable('site_url', SJB_System::getSystemSettings('SITE_URL'));
     SJB_System::setGlobalTemplateVariable('user_site_url', SJB_System::getSystemSettings('USER_SITE_URL'));
     SJB_System::setGlobalTemplateVariable('admin_site_url', SJB_System::getSystemSettings('ADMIN_SITE_URL'));
     SJB_System::setGlobalTemplateVariable('radius_search_unit', SJB_System::getSettingByName('radius_search_unit'));
     SJB_System::setGlobalTemplateVariable('settings', SJB_Settings::getSettings());
     ThemeManager::getCurrentTheme();
     SJB_PluginManager::loadPlugins(SJB_System::getSystemSettings('PLUGINS_DIR'));
     SJB_System::setGlobalTemplateVariable('plugins', SJB_PluginManager::getAllPluginsList());
     $GLOBALS['System']['MODULE_MANAGER'] = new SJB_ModuleManager();
     SJB_Event::dispatch('moduleManagerCreated');
     $GLOBALS['System']['MODULE_MANAGER']->executeModulesStartupFunctions();
     // define if subadmin loged in and set subamdinmode for templates
     if (SJB_System::getSystemSettings('SYSTEM_ACCESS_TYPE') == SJB_System::getSystemSettings('ADMIN_ACCESS_TYPE') && SJB_SubAdmin::getSubAdminSID()) {
         SJB_System::setGlobalTemplateVariable('subAdminSID', SJB_SubAdmin::getSubAdminSID());
     }
     $GLOBALS['uri'] = SJB_Navigator::getURI();
 }
Ejemplo n.º 8
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $action = SJB_Request::getVar('action', 'list');
     $errors = array();
     $template = 'countries.tpl';
     $paginator = new SJB_CountriesPagination();
     switch ($action) {
         case 'move_country':
         case 'save_order':
             $template = 'move_country.tpl';
             $itemSIDs = SJB_Request::getVar('item_order', array());
             try {
                 SJB_CountriesManager::saveItemsOrder($paginator->currentPage, $paginator->itemsPerPage, $itemSIDs);
                 $tp->assign('action', $action);
             } catch (Exception $e) {
                 $errors['SAVING_ORDER'] = $e->getMessage();
             }
             $countries = SJB_CountriesManager::getAllCountries();
             $tp->assign('countries', $countries);
             break;
         case 'activate':
             $countriesSIDs = array_keys(SJB_Request::getVar('countries', array()));
             foreach ($countriesSIDs as $countrySID) {
                 SJB_CountriesManager::activateCountryBySID($countrySID);
             }
             $action = 'list';
             break;
         case 'deactivate':
             $countriesSIDs = array_keys(SJB_Request::getVar('countries', array()));
             $defaultCountry = SJB_Settings::getSettingByName('default_country');
             foreach ($countriesSIDs as $countrySID) {
                 if ($defaultCountry == $countrySID) {
                     $errors['DEFAULT_DEACTIVATE'] = SJB_CountriesManager::getCountryInfoBySID($countrySID);
                 } else {
                     SJB_CountriesManager::deactivateCountryBySID($countrySID);
                 }
             }
             $action = 'list';
             break;
         case 'delete':
             $countriesSIDs = array_keys(SJB_Request::getVar('countries', array()));
             $defaultCountry = SJB_Settings::getSettingByName('default_country');
             foreach ($countriesSIDs as $countrySID) {
                 if ($defaultCountry == $countrySID) {
                     $errors['DEFAULT_DELETE'] = SJB_CountriesManager::getCountryInfoBySID($countrySID);
                 } else {
                     SJB_CountriesManager::deleteCountryBySID($countrySID);
                 }
             }
             $action = 'list';
             break;
         case 'add_country':
             $template = 'add_country.tpl';
             $formSubmitted = SJB_Request::getVar('action_add', false);
             $country = new SJB_Country($_REQUEST);
             $addCountryForm = new SJB_Form($country);
             $addCountryForm->registerTags($tp);
             if ($formSubmitted && $addCountryForm->isDataValid($errors)) {
                 SJB_CountriesManager::saveCountry($country);
                 SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . "/countries/");
             } else {
                 $formFields = $addCountryForm->getFormFieldsInfo();
                 $tp->assign('form_fields', $formFields);
             }
             break;
         case 'edit_country':
             $template = 'edit_country.tpl';
             $countrySID = SJB_Request::getVar('country_id', false);
             $formSubmitted = SJB_Request::getVar('action_add', false);
             $countryInfo = SJB_CountriesManager::getCountryInfoBySID($countrySID);
             if ($countryInfo) {
                 $countryInfo = array_merge($countryInfo, $_REQUEST);
                 $country = new SJB_Country($countryInfo);
                 $addCountryForm = new SJB_Form($country);
                 $addCountryForm->registerTags($tp);
                 $country->setSID($countrySID);
                 if ($formSubmitted && $addCountryForm->isDataValid($errors)) {
                     SJB_CountriesManager::saveCountry($country);
                     SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . "/countries/");
                 } else {
                     $formFields = $addCountryForm->getFormFieldsInfo();
                     $tp->assign('form_fields', $formFields);
                     $tp->assign('country_id', $countrySID);
                 }
             } else {
                 $tp->assign('action', 'edit');
                 $errors['WRONG_COUNTRY_ID_SPECIFIED'] = 'WRONG_COUNTRY_ID_SPECIFIED';
                 $template = 'country_errors.tpl';
             }
             break;
         case 'import_countries':
             $template = 'import_countries.tpl';
             $fileInfo = isset($_FILES['import_file']) ? $_FILES['import_file'] : null;
             $tp->assign("uploadMaxFilesize", SJB_UploadFileManager::getIniUploadMaxFilesize());
             if ($fileInfo['error']) {
                 $errors[] = SJB_UploadFileManager::getErrorId($fileInfo['error']);
             } elseif ($fileInfo) {
                 $fileFormats = array('csv', 'xls', 'xlsx');
                 $pathInfo = pathinfo($fileInfo['name']);
                 $fileExtension = isset($pathInfo['extension']) ? strtolower($pathInfo['extension']) : '';
                 if (!in_array(strtolower($fileExtension), $fileFormats)) {
                     $errors[] = 'Please choose Excel or csv file';
                 } else {
                     $importFile = new SJB_ImportFileXLS($fileInfo);
                     $importFile->parse();
                     $importedData = $importFile->getData();
                     $country = new SJB_Country();
                     $count = 0;
                     foreach ($importedData as $key => $importedColumn) {
                         if ($key == 1) {
                             $data = array_merge(array(array('country_code', 'country_name')), array($importedColumn));
                             $importedProcessor = new SJB_ImportedCountryProcessor($data, $country);
                         }
                         if (!$importedColumn) {
                             continue;
                         }
                         $countryInfo = $importedProcessor->getData($importedColumn);
                         if (!empty($countryInfo['country_code']) && !empty($countryInfo['country_name'])) {
                             $country = new SJB_Country($countryInfo);
                             $country->setPropertyValue('active', 1);
                             $countrySID = SJB_CountriesManager::getCountrySIDByCountryCode($countryInfo['country_code']);
                             if ($countrySID) {
                                 $country->setSID($countrySID);
                             }
                             SJB_CountriesManager::saveCountry($country);
                             if (!$countrySID) {
                                 $count++;
                             }
                         }
                     }
                     $tp->assign('imported_countries_count', $count);
                     $template = 'import_countries_result.tpl';
                 }
             }
             break;
         case 'change_setting':
             $action = 'list';
             $countrySID = SJB_Request::getVar('default_country');
             SJB_Settings::updateSettings(array('default_country' => $countrySID));
             break;
     }
     if ($action == 'list') {
         $countries = SJB_CountriesManager::getAllCountries(($paginator->currentPage - 1) * $paginator->itemsPerPage, $paginator->itemsPerPage);
         $countriesForDefault = SJB_CountriesManager::getAllActiveCountries();
         $paginator->setItemsCount(SJB_CountriesManager::countCountries());
         $tp->assign('paginationInfo', $paginator->getPaginationInfo());
         $tp->assign('countries', $countries);
         $tp->assign('countriesForDefault', $countriesForDefault);
         $tp->assign("settings", SJB_Settings::getSettings());
     }
     $tp->assign("errors", $errors);
     $tp->display($template);
 }
Ejemplo n.º 9
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $saved = false;
     $action = SJB_Request::getVar('action');
     $form_submitted = SJB_Request::getVar('submit');
     $template = 'plugins.tpl';
     $errors = array();
     if (SJB_Request::getVar('error', false)) {
         $errors[] = SJB_Request::getVar('error', false);
     }
     $messages = array();
     if (SJB_Request::getVar('message', false)) {
         $messages[] = SJB_Request::getVar('message', false);
     }
     switch ($action) {
         case 'save':
             $paths = SJB_Request::getVar('path');
             $active = SJB_Request::getVar('active');
             $subAdminSID = SJB_SubAdmin::getSubAdminSID();
             if (SJB_System::getSystemSettings('isDemo')) {
                 $errors[] = 'You don\'t have permissions for it. This is a Demo version of the software.';
             } else {
                 foreach ($paths as $key => $path) {
                     $config = SJB_PluginManager::getPluginConfigFromIniFile($path);
                     // check subadmins permissions
                     if ($subAdminSID) {
                         switch ($key) {
                             case 'FacebookSocialPlugin':
                                 if (!$this->acl->isAllowed('set_facebook_plug-in', $subAdminSID)) {
                                     continue 2;
                                 }
                                 break;
                             case 'LinkedinSocialPlugin':
                                 if (!$this->acl->isAllowed('set_linkedin_plug-in', $subAdminSID)) {
                                     continue 2;
                                 }
                                 break;
                             case 'PhpBBBridgePlugin':
                                 if (!$this->acl->isAllowed('set_phpbb_plug-in', $subAdminSID)) {
                                     continue 2;
                                 }
                                 break;
                             case 'TwitterIntegrationPlugin':
                                 if (!$this->acl->isAllowed('set_twitter_plug-in', $subAdminSID)) {
                                     continue 2;
                                 }
                                 break;
                             case 'WordPressBridgePlugin':
                                 if (!$this->acl->isAllowed('set_wordpress_plug-in', $subAdminSID)) {
                                     continue 2;
                                 }
                                 break;
                             case 'ShareThisPlugin':
                                 if (!$this->acl->isAllowed('set_sharethisplugin', $subAdminSID)) {
                                     continue 2;
                                 }
                                 break;
                             case 'CaptchaPlugin':
                                 if (!$this->acl->isAllowed('set_captchaplugin', $subAdminSID)) {
                                     continue 2;
                                 }
                                 break;
                             case 'IndeedPlugin':
                                 if (!$this->acl->isAllowed('set_indeedplugin', $subAdminSID)) {
                                     continue 2;
                                 }
                                 break;
                             case 'JujuPlugin':
                                 if (!$this->acl->isAllowed('set_jujuplugin', $subAdminSID)) {
                                     continue 2;
                                 }
                                 break;
                             case 'SimplyHiredPlugin':
                                 if (!$this->acl->isAllowed('set_simplyhiredplugin', $subAdminSID)) {
                                     continue 2;
                                 }
                                 break;
                             case 'GoogleAnalyticsPlugin':
                                 if (!$this->acl->isAllowed('set_googleanalyticsplugin', $subAdminSID)) {
                                     continue 2;
                                 }
                                 break;
                             case 'BeyondPlugin':
                                 if (!$this->acl->isAllowed('set_beyondplugin', $subAdminSID)) {
                                     continue 2;
                                 }
                                 break;
                         }
                     }
                     $config['active'] = $active[$key];
                     $saved = SJB_PluginManager::savePluginConfigIntoIniFile($path, $config);
                     if (!$saved) {
                         $errors[] = 'Failed to save ' . $key . ' settings';
                     }
                 }
             }
             SJB_PluginManager::reloadPlugins();
             break;
         case 'save_settings':
             $request = $_REQUEST;
             $request = self::checkRequiredFields($request);
             if (!isset($request['setting_errors'])) {
                 SJB_Settings::updateSettings($request);
                 if ($form_submitted == 'save') {
                     break;
                 } else {
                     if ($form_submitted == 'apply') {
                         $pluginName = SJB_Request::getVar('plugin');
                         SJB_HelperFunctions::redirect('?action=settings&plugin=' . $pluginName);
                     }
                 }
             } else {
                 unset($request['setting_errors']);
                 $errors = $request;
             }
         case 'settings':
             $pluginName = SJB_Request::getVar('plugin');
             $plugin = SJB_PluginManager::getPluginByName($pluginName);
             if (isset($plugin['name'])) {
                 $pluginObj = new $plugin['name']();
                 $settings = $pluginObj->pluginSettings();
                 $template = 'plugin_settings.tpl';
                 $savedSettings = SJB_Settings::getSettings();
                 SJB_Event::dispatch('RedefineSavedSetting', $savedSettings, true);
                 SJB_Event::dispatch('RedefineTemplateName', $template, true);
                 $tp->assign('plugin', $plugin);
                 $tp->assign('settings', $settings);
                 $tp->assign('savedSettings', $savedSettings);
             }
             break;
         case 'editCaptcha':
             $info = $_REQUEST;
             SJB_Event::dispatch('editCaptcha', $info, true);
             foreach ($info as $key => $val) {
                 $tp->assign($key, $val);
             }
             $template = $info['template'];
             break;
     }
     $listPlugins = SJB_PluginManager::getAllPluginsList();
     $plugins = array();
     foreach ($listPlugins as $key => $plugin) {
         $group = !empty($plugin['group']) ? $plugin['group'] : 'Common';
         $plugins[$group][$key] = $plugin;
         if (array_key_exists($key, $this->socialMediaPlugins)) {
             $plugins[$group][$key]['socialMedia'] = $this->socialMediaPlugins[$key];
         }
     }
     $tp->assign('saved', $saved);
     $tp->assign('groups', $plugins);
     $tp->assign('errors', $errors);
     $tp->assign('messages', $messages);
     $tp->display($template);
 }