/**
  * Singleton
  * @return Application_Model_ConfigsMapper
  */
 public static function i()
 {
     if (self::$_instance == null) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }
 public function __construct()
 {
     $conf = new Application_Model_Config();
     Application_Model_ConfigsMapper::i()->fetchByKey('languageFile', $conf);
     if ($conf->getId() !== null) {
         $this->lang = $conf->getValue();
     }
 }
 public function saveAction()
 {
     /* @var $request Zend_Controller_Request_Http */
     $request = $this->getRequest();
     $configs = Application_Model_ConfigsMapper::i()->fetchAll();
     if ($request->isPost()) {
         $form = $this->_initConfigsForm($configs, $request->getPost());
         if (!$form->isErrors()) {
             $post = $request->getPost();
             $isError = false;
             foreach ($configs as $config) {
                 /* @var $config Application_Model_Config */
                 if ($config->getSection() == 'plugins') {
                     continue;
                 }
                 // plugins config will not be handled here
                 $postStoreName = $config->getSection() . "_" . str_replace('.', '_', $config->getKey());
                 // ISSUE-15: https://code.google.com/p/vlc-shares/issues/detail?id=15
                 // This is a workaround it: remove slashes if magic_quotes is enabled
                 // FIXME remove this workaround in vlc-shares 0.6+
                 $postValue = $request->getPost($postStoreName);
                 if (get_magic_quotes_gpc()) {
                     //$postValue = str_replace(array('\\\\' , '=\\"'), array('\\', '="'), $postValue );
                     $postValue = stripslashes($postValue);
                 }
                 if (array_key_exists($postStoreName, $post) && $config->getValue() != $postValue) {
                     // new value
                     try {
                         $config->setValue($postValue);
                         Application_Model_ConfigsMapper::i()->save($config);
                         if (stripos($config->getKey(), 'password') != false) {
                             X_Debug::i("New config: {$config->getSection()}.{$config->getKey()} = ***********");
                         } else {
                             X_Debug::i("New config: {$config->getSection()}.{$config->getKey()} = {$config->getValue()}");
                         }
                     } catch (Exception $e) {
                         $isError = true;
                         $this->_helper->flashMessenger(X_Env::_('configs_save_err_db') . ": {$e->getMessage()}");
                     }
                 }
             }
             if (!$isError) {
                 $this->_helper->flashMessenger(X_Env::_('configs_save_done'));
             }
             if ($form->getValue('isapply') == '1') {
                 $this->_helper->redirector('index', 'configs');
             } else {
                 $this->_helper->redirector('index', 'manage');
             }
         } else {
             $this->_forward('index');
         }
     } else {
         $this->_helper->flashMessenger(X_Env::_('configs_save_nodata'));
         $this->_helper->redirector('index', 'configs');
     }
 }
 public function clearLastCheck()
 {
     X_Debug::i("Resetting last check");
     $c = new Application_Model_Config();
     Application_Model_ConfigsMapper::i()->fetchByKey($this->getId() . '.autocheck.last', $c);
     if ($c->getId()) {
         $c->setValue('');
         try {
             Application_Model_ConfigsMapper::i()->save($c);
         } catch (Exception $e) {
             X_Debug::e("Error while storing last check time in db");
         }
     }
     @unlink(APPLICATION_PATH . '/../data/updatenotifier/lastcheck.txt');
 }
 public function saveAction()
 {
     /* @var $request Zend_Controller_Request_Http */
     $request = $this->getRequest();
     //$configs = Application_Model_ConfigsMapper::i()->fetchAll();
     if ($request->isPost()) {
         try {
             $redirect = explode(':', $request->getPost('redirect', 'config:index'));
         } catch (Exception $e) {
             $redirect = array('config', 'index');
         }
         $section = 'plugins';
         $key = $this->getRequest()->getParam('key', false);
         if ($key === false) {
             $this->_helper->flashMessenger(array('type' => 'error', 'text' => X_Env::_('config_invalidkey')));
             $this->_helper->redirector('index', 'manage');
         }
         $configs = Application_Model_ConfigsMapper::i()->fetchBySectionNamespace($section, $key);
         $form = $this->_initConfigsForm($section, $key, $configs, $request->getPost());
         //$form = $this->_initConfigsForm($configs, $request->getPost());
         $form->addElement('hidden', 'redirect', array('value' => "{$redirect[0]}:{$redirect[1]}", 'ignore' => true, 'decorators' => array('ViewHelper')));
         if (!$form->isErrors()) {
             $post = $request->getPost();
             $isError = false;
             foreach ($configs as $config) {
                 /* @var $config Application_Model_Config */
                 //if ( $config->getSection() == 'plugins' ) continue; // plugins config will not be handled here
                 $postStoreName = $config->getSection() . "_" . str_replace('.', '_', $config->getKey());
                 // ISSUE-15: https://code.google.com/p/vlc-shares/issues/detail?id=15
                 // This is a workaround it: remove slashes if magic_quotes is enabled
                 $postValue = $request->getPost($postStoreName);
                 if (get_magic_quotes_gpc()) {
                     //$postValue = str_replace(array('\\\\' , '=\\"'), array('\\', '="'), $postValue );
                     $postValue = stripslashes($postValue);
                 }
                 if (array_key_exists($postStoreName, $post) && $config->getValue() != $postValue) {
                     // new value
                     try {
                         $config->setValue($postValue);
                         Application_Model_ConfigsMapper::i()->save($config);
                         if (stripos($config->getKey(), 'password') != false) {
                             X_Debug::i("New config: {$config->getKey()} = ***********");
                         } else {
                             X_Debug::i("New config: {$config->getKey()} = {$config->getValue()}");
                         }
                     } catch (Exception $e) {
                         $isError = true;
                         $form->{$postStoreName}->addError($e->getMessage());
                         $this->_helper->flashMessenger(X_Env::_('configs_save_err_db') . ": {$e->getMessage()}");
                     }
                 }
             }
             if (!$isError) {
                 $this->_helper->flashMessenger(X_Env::_('configs_save_done'));
                 $this->_helper->redirector($redirect[1], $redirect[0]);
             } else {
                 $ns = new Zend_Session_Namespace('vlc-shares::config');
                 $ns->errors = true;
                 $ns->data = $this->getRequest()->getPost();
                 $this->_forward('index');
             }
         } else {
             $this->_forward('index');
         }
     } else {
         $this->_helper->flashMessenger(X_Env::_('configs_save_nodata'));
         $this->_helper->redirector('index', 'config');
     }
 }
 public function saveAction()
 {
     /* @var $request Zend_Controller_Request_Http */
     $request = $this->getRequest();
     $filter = $request->getParam('filter', false);
     if (!$filter) {
         //$this->_helper->redirector('index', 'gconfigs');
         $this->_helper->viewRenderer->setNoRender(true);
         return;
     }
     @(list($section, $key) = explode(':', $filter, 2));
     X_Debug::i("Filter: section = {{$section}}, baseKey = {{$key}}");
     if ($section && $key) {
         $configs = Application_Model_ConfigsMapper::i()->fetchBySectionNamespace($section, $key);
     } elseif ($section) {
         $configs = Application_Model_ConfigsMapper::i()->fetchBySection($section);
     }
     if ($request->isPost()) {
         $form = $this->_initConfigsForm($section, $key, $configs, $request->getPost());
         if (!$form->isErrors()) {
             $post = $request->getPost();
             $isError = false;
             foreach ($configs as $config) {
                 /* @var $config Application_Model_Config */
                 $postStoreName = $config->getSection() . "_" . str_replace('.', '_', $config->getKey());
                 $postValue = $request->getPost($postStoreName);
                 if (array_key_exists($postStoreName, $post) && $config->getValue() != $postValue) {
                     // new value
                     try {
                         $config->setValue($postValue);
                         Application_Model_ConfigsMapper::i()->save($config);
                         if (stripos($config->getKey(), 'password') != false) {
                             X_Debug::i("New config: {$config->getSection()}.{$config->getKey()} = ***********");
                         } else {
                             X_Debug::i("New config: {$config->getSection()}.{$config->getKey()} = {$config->getValue()}");
                         }
                     } catch (Exception $e) {
                         $isError = true;
                         $this->_helper->flashMessenger(X_Env::_('configs_save_err_db') . ": {$e->getMessage()}");
                     }
                 }
             }
             if (!$isError) {
                 $this->_helper->flashMessenger(X_Env::_('configs_save_done'));
             }
             $this->_helper->redirector('index', 'gconfigs', null, array('filter' => $this->getRequest()->getParam('filter')));
         } else {
             $this->_forward('index', 'gconfigs', null, array('filter' => $this->getRequest()->getParam('filter')));
         }
     } else {
         $this->_helper->flashMessenger(X_Env::_('configs_save_nodata'));
         $this->_helper->redirector('index', 'configs');
     }
 }
 /**
  * Restore core configs and plugins list in db 
  * This is not a trigger of plugin API. It's called by Backupper plugin
  * @param array $items Array format: 
  * 		array(
  * 			'plugins' => array(
  * 				array(
  * 					'key' => PLUGIN_KEY
  * 					'enabled' => 1|0
  *				),...
  *			),
  *			'configs' => array(
  *				array(
  *					'key' => CONFIG_KEY
  *					'value' => CONFIG_VALUE
  *					'section' => CONFIG_SECTION
  *				)
  *			)
  *		)
  */
 function restoreItems($items)
 {
     $pluginsStatusChanged = 0;
     $pluginsStatusErrors = 0;
     $configsStatusChanged = 0;
     $configsStatusErrors = 0;
     // as first thing i restore plugins status
     $plugins = Application_Model_PluginsMapper::i()->fetchAll();
     foreach ($plugins as $plugin) {
         /* @var $plugin Application_Model_Plugin */
         if (array_key_exists($plugin->getKey(), $items['plugins'])) {
             if ($plugin->isEnabled() != (bool) @$items['plugins'][$plugin->getKey()]['enabled']) {
                 $plugin->setEnabled((bool) @$items['plugins'][$plugin->getKey()]['enabled']);
                 // i need to commit change
                 try {
                     Application_Model_PluginsMapper::i()->save($plugin);
                     $pluginsStatusChanged++;
                 } catch (Exception $e) {
                     X_Debug::e("Failed to update plugin {$plugin->getKey()} status to {$items['plugins'][$plugin->getKey()]['enabled']}");
                     $pluginsStatusErrors++;
                 }
             }
         }
     }
     // then i restore configs status
     $configs = Application_Model_ConfigsMapper::i()->fetchAll();
     foreach ($configs as $config) {
         /* @var $config Application_Model_Config */
         if (array_key_exists($config->getKey(), $items['configs'])) {
             if ($config->getSection() == @$items['configs'][$config->getKey()]['section'] && $config->getValue() != $items['configs'][$config->getKey()]['value']) {
                 $config->setValue(@$items['configs'][$config->getKey()]['value']);
                 // i need to commit change
                 try {
                     Application_Model_ConfigsMapper::i()->save($config);
                     $configsStatusChanged++;
                 } catch (Exception $e) {
                     X_Debug::e("Failed to update plugin {$config->getKey()} status to {$items['configs'][$config->getKey()]['value']}");
                     $configsStatusErrors++;
                 }
             }
         }
     }
     // return a custom message with restore results
     return X_Env::_('p_backupper_restorereport_main') . '<br/><dl style="margin: 1em 3em;">' . '<dt>' . X_Env::_('p_backupper_restorereport_configchanged') . '</dt>' . '<dd>' . $configsStatusChanged . '</dd>' . '<dt>' . X_Env::_('p_backupper_restorereport_configerrors') . '</dt>' . '<dd>' . $configsStatusErrors . '</dd>' . '<dt>' . X_Env::_('p_backupper_restorereport_pluginchanged') . '</dt>' . '<dd>' . $pluginsStatusChanged . '</dd>' . '<dt>' . X_Env::_('p_backupper_restorereport_pluginerrors') . '</dt>' . '<dd>' . $pluginsStatusErrors . '</dd>' . '</dl>';
 }
 function alertAction()
 {
     $status = $this->getRequest()->getParam('status', false);
     $config = new Application_Model_Config();
     Application_Model_ConfigsMapper::i()->fetchByKey("backupper.alert.enabled", $config);
     if ($config->getId() == null) {
         // i need to add a new config, yeah!
         $config->setKey('backupper.alert.enabled')->setValue(1)->setDefault(1)->setSection('plugins')->setType(Application_Model_Config::TYPE_BOOLEAN);
     }
     switch ($status) {
         case 'on':
             $config->setValue(1);
             break;
         case 'off':
             $config->setValue(0);
             break;
         default:
             $this->_helper->flashMessenger(array('text' => X_Env::_('p_backupper_err_unknownstatus'), 'type' => 'error'));
             $this->_helper->redirector('index', 'backupper');
             break;
     }
     try {
         Application_Model_ConfigsMapper::i()->save($config);
         $this->_helper->flashMessenger(array('text' => X_Env::_('p_backupper_alertstatuschanged'), 'type' => 'info'));
     } catch (Exception $e) {
         X_Debug::e('Unable to store alert.enabled status: ' . $e->getMessage());
         $this->_helper->flashMessenger(array('text' => X_Env::_('p_backupper_err_dberror') . ": {$e->getMessage()}", 'type' => 'error'));
     }
     $this->_helper->redirector('index', 'backupper');
 }
 public function init()
 {
     // Set the method for the display form to POST
     $this->setMethod('post');
     $this->setName('autoconfigs');
     $sections = Application_Model_ConfigsMapper::i()->fetchSections();
     // general section go on top
     $displayGroup = array('general' => array());
     $configs = $this->configs;
     foreach ($configs as $config) {
         /* @var $config Application_Model_Config */
         if ($config->getClass() == "hidden") {
             continue;
         }
         // hidden configs aren't shown
         $elementType = '';
         $defaultStr = null;
         switch ($config->getType()) {
             case Application_Model_Config::TYPE_RADIO:
                 $elementType = 'radio';
                 $defaultStr = $config->getDefault();
                 break;
             case Application_Model_Config::TYPE_BOOLEAN:
                 $elementType = 'radio';
                 $opt = array(1 => X_Env::_('configs_options_yes'), 0 => X_Env::_('configs_options_no'));
                 $defaultStr = $opt[$config->getDefault()];
                 break;
             case Application_Model_Config::TYPE_TEXTAREA:
                 $elementType = 'textarea';
                 $defaultStr = $config->getDefault();
                 break;
             case Application_Model_Config::TYPE_SELECT:
                 $elementType = 'select';
                 $defaultStr = $config->getDefault();
                 break;
                 // case Application_Model_Config::TYPE_FILE: $elementType = 'file'; break; // TODO check for it
             // case Application_Model_Config::TYPE_FILE: $elementType = 'file'; break; // TODO check for it
             case Application_Model_Config::TYPE_TEXT:
             default:
                 $elementType = 'text';
                 $defaultStr = $config->getDefault();
                 break;
         }
         $elementName = $config->getSection() . '_' . str_replace('.', '_', $config->getKey());
         $elementLabel = $config->getLabel() != null && $config->getLabel() != '' ? X_Env::_($config->getLabel()) : $config->getKey();
         $elementDescription = ($config->getDescription() ? X_Env::_($config->getDescription()) . '<br/>' : '') . ($config->getDefault() != null ? "<br/><i>Default:</i> " . $defaultStr : '<br/><i>Default:</i> ' . X_Env::_('configs_options_novalue'));
         $element = $this->createElement($elementType, $elementName, array('label' => $elementLabel, 'description' => $elementDescription));
         $element->getDecorator('composite')->setOption('class', $config->getClass());
         /*
         $element->getDecorator('description')->setEscape(false);
         $element->getDecorator('htmlTag')->setOption('class', $config->getClass());
         $element->getDecorator('label')->setOption('class', $element->getDecorator('label')->getOption('class') . ' ' . $config->getClass());
         */
         if ($config->getType() == Application_Model_Config::TYPE_BOOLEAN) {
             $element->setMultiOptions(array(1 => X_Env::_('configs_options_yes'), 0 => X_Env::_('configs_options_no')));
         }
         $this->addElement($element);
     }
     // Add the submit button
     $this->addElement('submit', 'submit', array('ignore' => true, 'label' => X_Env::_('configs_form_submit'), 'decorators' => array('ViewHelper')));
     // Add the submit button
     $this->addElement('button', 'abort', array('onClick' => 'javascript:history.back();', 'ignore' => true, 'label' => X_Env::_('configs_form_abort'), 'decorators' => array('ViewHelper')));
     // Add the submit button
     $this->addElement('hidden', 'isapply', array('ignore' => true, 'value' => 0, 'decorators' => array('ViewHelper')));
     // Add the submit button
     $this->addElement('hidden', 'redirect', array('ignore' => true, 'decorators' => array('ViewHelper')));
     // And finally add some CSRF protection
     $this->addElement('hash', 'csrf', array('salt' => 'autoconfigs', 'ignore' => true, 'decorators' => array('ViewHelper')));
     $this->addDisplayGroup(array('submit', 'abort', 'csrf', 'isapply', 'redirect'), 'buttons', array('decorators' => $this->getDefaultButtonsDisplayGroupDecorators()));
     //$this->addDisplayGroup(array('submit', 'abort', 'hash'), 'buttons');
 }
 public function reportAction()
 {
     $results = array();
     $results[] = '-----------------------';
     $results[] = 'vlc-shares: ' . X_VlcShares::VERSION;
     $results[] = 'zend-framework: ' . Zend_Version::VERSION;
     $results[] = '';
     $results[] = 'Configs:';
     $vlcshares = Application_Model_ConfigsMapper::i()->fetchAll();
     foreach ($vlcshares as $conf) {
         /* @var $conf Application_Model_Config */
         if ($conf->getSection() == 'plugins') {
             continue;
         }
         $results[] = "\t{$conf->getSection()}/{$conf->getKey()} = {$conf->getValue()}";
     }
     $results[] = '';
     $results[] = 'Plugins:';
     $plugins = X_VlcShares_Plugins::broker()->getPlugins();
     foreach ($plugins as $id => $plugin) {
         $results[] = "\t{$id} => " . get_class($plugin);
     }
     $results[] = '';
     $results[] = 'Tests:';
     $tests = $this->doSystemTests();
     if ($this->options) {
         $tests->merge(X_VlcShares_Plugins::broker()->preGetTestItems($this->options, $this));
         // normal links
         $tests->merge(X_VlcShares_Plugins::broker()->getTestItems($this->options, $this));
         // bottom links
         $tests->merge(X_VlcShares_Plugins::broker()->postGetTestItems($this->options, $this));
     }
     foreach ($tests->getItems() as $test) {
         /* @var $test X_Page_Item_Test */
         $results[] = "\t{$test->getLabel()} ({$test->getType()}): {$test->getReason()}";
     }
     $results[] = '';
     $results[] = '';
     $results[] = '';
     $results[] = '-----------------------';
     $results[] = 'Server:';
     foreach ($_SERVER as $k => $v) {
         $results[] = "\t{$k} = {$v}";
     }
     // PHP SETTINGS
     $results[] = '';
     $results[] = '';
     $results[] = '';
     $results[] = '-----------------------';
     $results[] = 'PHP: ' . PHP_VERSION . ' ' . PHP_OS . ' ' . PHP_SAPI;
     $results[] = 'Loaded extesions:';
     $exts = get_loaded_extensions();
     foreach ($exts as $ext) {
         $results[] = "\t{$ext}";
     }
     $results[] = '';
     $php = ini_get_all(null, false);
     foreach ($php as $k => $v) {
         $results[] = "\t{$k} = {$v}";
     }
     $results[] = '';
     $results[] = '';
     $results[] = '';
     $results[] = '-----------------------';
     $results[] = 'Debug log:';
     $results[] = '';
     $this->getResponse()->setHeader('Content-Type', 'plain/text');
     $this->getResponse()->setHeader('Content-Disposition', 'attachment; filename=vlc-shares_report_' . time() . '.txt');
     $this->_helper->viewRenderer->setNoRender(true);
     $this->_helper->layout->disableLayout();
     echo implode(PHP_EOL, $results);
     $debugPath = sys_get_temp_dir() . '/vlcShares.debug.log';
     if ($this->options->general->debug->path != null && trim($this->options->general->debug->path) != '') {
         $debugPath = $this->options->general->debug->path;
     }
     // read and append to stdout
     @readfile($debugPath);
 }
 protected function _initConfigs()
 {
     $this->bootstrap('db');
     // TODO cache
     // read configuration from the db as an array
     $configA = array();
     $configs = Application_Model_ConfigsMapper::i()->fetchAll();
     foreach ($configs as $config) {
         /* @var $config Application_Model_Config */
         $key = $config->getKey();
         $_array = $config->getValue();
         $exploded = explode('.', $key);
         $_first = true;
         for ($i = count($exploded) - 1; $i >= 0; $i--) {
             $_array = array($exploded[$i] => $_array);
         }
         $_array = array($config->getSection() => $_array);
         $configA = array_merge_recursive($configA, $_array);
     }
     //echo '<pre>'.print_r($configA, true).'</pre>';
     return new Zend_Config($configA);
     //return new Zend_Config_Ini(X_VlcShares::config()); // old way
 }
 public function saveAction()
 {
     $lang = $this->getRequest()->getParam('lang', false);
     $lang = $lang !== false ? str_replace('../', '', $lang) : $lang;
     if ($lang !== false && file_exists(APPLICATION_PATH . "/../languages/{$lang}")) {
         $config = new Application_Model_Config();
         Application_Model_ConfigsMapper::i()->fetchByKey('languageFile', $config);
         if ($config->getId() !== null) {
             $config->setValue($lang);
             try {
                 Application_Model_ConfigsMapper::i()->save($config);
                 $this->_helper->flashMessenger(array('type' => 'success', 'text' => X_Env::_('installer_language_done')));
                 //$this->_helper->redirector('execute');
             } catch (Exception $e) {
                 $this->_helper->flashMessenger(array('type' => 'fatal', 'text' => X_Env::_("installer_err_db") . ": {$e->getMessage()}"));
             }
         }
     } else {
         $this->_helper->flashMessenger(array('type' => 'error', 'text' => X_Env::_('installer_invalid_language')));
         $this->_helper->redirector('index');
     }
     // check for admin username/password
     $form = new Application_Form_Installer();
     $form->removeElement('lang');
     $form->removeElement('plugins');
     if (!$form->isValid($this->getRequest()->getPost())) {
         $ns = new Zend_Session_Namespace('vlc-shares::installer');
         $ns->errors = true;
         $ns->data = $this->getRequest()->getPost();
         $this->_helper->flashMessenger(array('type' => 'error', 'text' => X_Env::_('installer_invalid_data')));
         $this->_helper->redirector('index');
         return;
     }
     $username = $form->getValue('username');
     $password = $form->getValue('password');
     if (Application_Model_AuthAccountsMapper::i()->getCount(true) == 0) {
         // try to reenable/create a new account
         try {
             $account = new Application_Model_AuthAccount();
             Application_Model_AuthAccountsMapper::i()->fetchByUsername($username);
             $account->setUsername($username)->setPassword(md5("{$username}:{$password}"))->setEnabled(true)->setPassphrase(md5("{$username}:{$password}:" . rand(10000, 99999) . time()))->setAltAllowed(true);
             Application_Model_AuthAccountsMapper::i()->save($account);
             // adding permissions
             X_VlcShares_Plugins::helpers()->acl()->grantPermission($username, Application_Model_AclClass::CLASS_ADMIN);
             X_VlcShares_Plugins::helpers()->acl()->grantPermission($username, Application_Model_AclClass::CLASS_BROWSE);
             $this->_helper->flashMessenger(array('type' => 'success', 'text' => X_Env::_('installer_newaccount_done')));
         } catch (Exception $e) {
             $this->_helper->flashMessenger(X_Env::_('installer_err_db') . ": {$e->getMessage()}");
             $this->_helper->redirector('index');
             return;
         }
         // after that account is stored, try to do a login
         if (X_VlcShares_Plugins::broker()->isRegistered('auth')) {
             $auth = X_VlcShares_Plugins::broker()->getPlugins('auth');
         } else {
             $auth = new X_VlcShares_Plugins_Auth();
         }
         if (!$auth->isLoggedIn()) {
             $auth->doLogin($username);
         }
     }
     try {
         // enable auth plugin after authentication
         if ($form->getValue('auth', '0') == '1') {
             /*
             		    	$plugin = new Application_Model_Plugin();
             		    	Application_Model_PluginsMapper::i()->fetchByClass('X_VlcShares_Plugins_Auth', $plugin);
             		    	//Application_Model_PluginsMapper::i()->delete($plugin);
             $plugin->setEnabled(true);
             Application_Model_PluginsMapper::i()->save($plugin);
             */
             $config = new Application_Model_Config();
             Application_Model_ConfigsMapper::i()->fetchByKey('auth.login.enabled', $config);
             $config->setValue('1');
             Application_Model_ConfigsMapper::i()->save($config);
         }
         // check forker url
         $forkerUrl = $form->getValue('threads', false);
         if ($forkerUrl) {
             $config = new Application_Model_Config();
             Application_Model_ConfigsMapper::i()->fetchByKey('threads.forker', $config);
             $config->setValue($forkerUrl);
             Application_Model_ConfigsMapper::i()->save($config);
         }
     } catch (Exception $e) {
         $this->_helper->flashMessenger(X_Env::_('installer_err_db') . ": {$e->getMessage()}");
         $this->_helper->redirector('index');
     }
     $plugins = $this->getRequest()->getParam('plugins', array());
     //ini_set('max_execution_time', 0);
     ignore_user_abort(true);
     if (is_array($plugins)) {
         /* @var $pluginInstaller X_VlcShares_Plugins_PluginInstaller */
         $pluginInstaller = X_VlcShares_Plugins::broker()->getPlugins('plugininstaller');
         foreach ($plugins as $plugin) {
             // allow 30 seconds for each plugin
             set_time_limit(30);
             try {
                 $pluginInstaller->installPlugin($plugin, true);
                 $this->_helper->flashMessenger(array('type' => 'success', 'text' => X_Env::_('plugin_install_done') . ": {$plugin}"));
             } catch (Exception $e) {
                 $this->_helper->flashMessenger(array('text' => X_Env::_('plugin_err_installerror') . ": " . $e->getMessage(), 'type' => 'error'));
             }
             // download the plugin file
             /*
             $http = new Zend_Http_Client($plugin);
             $http->setStream(true);
             
             $response = $http->request();
             
             if ( $this->_installPlugin($response->getStreamName()) ) {
             	$this->_helper->flashMessenger(array('type' => 'success', 'text' => X_Env::_('plugin_install_done') . ": $plugin"));
             }
             */
         }
     }
     $this->_helper->redirector('execute');
 }