public function vfsAction() { // Check for modifications to installer (to prevent problems) if (!$this->_checkForModifications()) { return; } // Load the transaction from the cache $transaction = $this->_loadTransaction(); // Get navigation $this->view->installNavigation = $this->getInstallNavigation('vfs'); $adapterType = $this->_getParam('adapter'); if (null === $adapterType) { $adapterType = $this->_session->vfsAdapter; if (null === $adapterType) { $adapterType = @$this->_vfsSettings['adapter']; } } $previousAdapterType = $this->_getParam('previousAdapter'); $this->view->form = $form = new Install_Form_VfsInfo(array('adapterType' => $adapterType)); if (!$this->getRequest()->isPost() || $adapterType != $previousAdapterType) { if (!$adapterType) { // Ignore } else { if ($adapterType == @$this->_session->vfsAdapter) { // Load from session $form->populate(array('adapter' => $adapterType, 'config' => $this->_session->vfsConfig)); } else { if ($adapterType == @$this->_vfsSettings['adapter']) { // Load from settings file $form->populate($this->_vfsSettings); } else { $form->populate(array('adapter' => $adapterType)); } } } return; } if (!$form->isValid($this->getRequest()->getPost())) { return; } // Process $values = $form->getValues(); $vfsAdapter = $values['adapter']; $vfsConfig = $values['config']; // Try to load adapter try { $vfs = Engine_Vfs::factory($vfsAdapter, $vfsConfig); } catch (Exception $e) { $form->addError('Connection error: ' . $e->getMessage()); return; } // Try to connect (getResource will force connect) try { $vfs->getResource(); } catch (Exception $e) { $form->addError('Connection error: ' . $e->getMessage()); return; } // Search for target $path = null; if (!empty($vfsConfig['search']) && $vfsConfig['search'] !== '0') { $path = $vfs->findJailedPath($vfsConfig['path'], APPLICATION_PATH . '/install/ftp_search_will_look_for_this_file'); if (!$path) { $form->addError('Your installation could not be found. Please double check your connection info and starting path. Your starting path needs to be your SocialEngine path, or a parent directory of it.'); return; } $path = dirname(dirname($path)); } else { $path = $vfsConfig['path']; } // Verify path if (!$vfs->exists($path . '/install/ftp_search_will_look_for_this_file')) { $form->addError('Specified path is not a SocialEngine install directory.'); return; } // Save config $vfsConfig['path'] = $values['config']['path'] = $path; $vfs->changeDirectory($path); $this->_session->vfsInstance = $vfs; $this->_session->vfsAdapter = $vfsAdapter; $this->_session->vfsConfig = $vfsConfig; $this->_vfsSettings = $values; // Save for later $vfsSettingsData = array('adapter' => $vfsAdapter, 'config' => array_diff_key($vfsConfig, array('password' => null, 'location' => null, 'search' => null))); @file_put_contents(APPLICATION_PATH . '/install/config/vfs.php', '<?php return ' . var_export($vfsSettingsData, true) . '?>'); // Redirect to next step return $this->_helper->redirector->gotoRoute(array('action' => 'perms')); }
public function vfsAction() { // Get vfs config $vfsConfig = array(); $vfsFile = APPLICATION_PATH . '/install/config/vfs.php'; if (file_exists($vfsFile)) { $vfsConfig = (include $vfsFile); } $this->view->form = $form = new Install_Form_VfsInfo(); // Get current vfs config $vfsConfigCurrent = $this->_session->vfs; if (!is_array($vfsConfigCurrent)) { $vfsConfigCurrent = array(); } // Adapter type $adapterType = $this->_getParam('adapter'); if (null === $adapterType) { if (!empty($vfsConfigCurrent['adapter'])) { $adapterType = @$vfsConfigCurrent['adapter']; } else { $adapterType = @$vfsConfig['adapter']; } } $previousAdapterType = $this->_getParam('previousAdapter'); // Form $this->view->form = $form = new Install_Form_VfsInfo(array('adapterType' => $adapterType)); // Populate if (!$this->getRequest()->isPost() || $adapterType != $previousAdapterType) { if (!$adapterType) { // Ignore } else { if ($adapterType == @$vfsConfigCurrent['adapter']) { // Load from session $form->populate($vfsConfigCurrent); } else { if ($adapterType == @$vfsConfig['adapter']) { // Load from settings file $form->populate($vfsConfig); } else { $form->populate(array('adapter' => $adapterType)); } } } return; } if (!$form->isValid($this->getRequest()->getPost())) { return; } // Process $vfsConfigCurrent = $form->getValues(); // Try to load adapter try { $vfs = Engine_Vfs::factory($vfsConfigCurrent['adapter'], $vfsConfigCurrent['config']); } catch (Exception $e) { $form->addError('Connection error: ' . $e->getMessage()); return; } // Try to connect (getResource will force connect) try { $vfs->getResource(); } catch (Exception $e) { $form->addError('Connection error: ' . $e->getMessage()); return; } // Search for target $path = null; if (!empty($vfsConfigCurrent['config']['search']) && $vfsConfigCurrent['config']['search'] !== '0') { $path = $vfs->findJailedPath($vfsConfig['path'], APPLICATION_PATH . '/install/ftp_search_will_look_for_this_file'); if (!$path) { $form->addError('Your installation could not be found. Please double check your connection info and starting path. Your starting path needs to be your SocialEngine path, or a parent directory of it.'); return; } $path = dirname(dirname($path)); } else { $path = $vfsConfigCurrent['config']['path']; } // Verify path if (!$vfs->exists($path . '/install/ftp_search_will_look_for_this_file')) { $form->addError('Specified path is not a SocialEngine install directory.'); return; } // Save config $vfsConfigCurrent = $vfsConfig = array('adapter' => $vfsAdapter, 'config' => $vfsConfig); $vfsConfigCurrent['config']['path'] = $path; $vfs->changeDirectory($path); $this->_session->vfsInstance = $vfs; $this->_session->vfs = $vfsConfigCurrent; // Save for later $vfsSettingsData = array('adapter' => $vfsAdapter, 'config' => array_diff_key($vfsConfigCurrent, array('password' => null, 'location' => null, 'search' => null))); @file_put_contents(APPLICATION_PATH . '/install/config/vfs.php', '<?php return ' . var_export($vfsSettingsData, true) . '?>'); return $this->_doSuccessRedirect(); }
public function indexAction() { $this->view->form = $form = new Install_Form_VfsInfo(); // Adapter type $adapterType = $this->_getParam('adapter'); if (null === $adapterType) { $adapterType = $this->_session->vfsAdapter; if (null === $adapterType) { $adapterType = @$this->_vfsSettings['adapter']; } } $previousAdapterType = $this->_getParam('previousAdapter'); // Return $return = $this->_getParam('return'); if (!$return) { if (!empty($_SERVER['HTTP_REFERER']) && false != ($parts = parse_url($_SERVER['HTTP_REFERER'])) && $parts['host'] == $_SERVER['HTTP_HOST']) { $return = $parts['path'] . (!empty($parts['query']) ? '?' . $parts['query'] : ''); } } if (!$return) { $return = $this->view->url(array('controller' => 'manage', 'action' => 'index')); } // Form $this->view->form = $form = new Install_Form_VfsInfo(array('adapterType' => $adapterType)); // Populate if (!$this->getRequest()->isPost() || $adapterType != $previousAdapterType) { if (!$adapterType) { // Ignore } else { if ($adapterType == @$this->_session->vfsAdapter) { // Load from session $form->populate(array('adapter' => $adapterType, 'config' => $this->_session->vfsConfig, 'return' => $return)); } else { if ($adapterType == @$this->_vfsSettings['adapter']) { // Load from settings file $form->populate(array_merge($this->_vfsSettings, array('return' => $return))); } else { $form->populate(array('adapter' => $adapterType, 'return' => $return)); } } } return; } if (!$form->isValid($this->getRequest()->getPost())) { return; } // Process $values = $form->getValues(); $vfsAdapter = $values['adapter']; $vfsConfig = $values['config']; // Try to load adapter try { $vfs = Engine_Vfs::factory($vfsAdapter, $vfsConfig); } catch (Exception $e) { $form->addError('Connection error: ' . $e->getMessage()); return; } // Try to connect (getResource will force connect) try { $vfs->getResource(); } catch (Exception $e) { $form->addError('Connection error: ' . $e->getMessage()); return; } // Search for target $path = null; if (!empty($vfsConfig['search']) && $vfsConfig['search'] !== '0') { $path = $vfs->findJailedPath($vfsConfig['path'], APPLICATION_PATH . '/install/ftp_search_will_look_for_this_file'); if (!$path) { $form->addError('Your installation could not be found. Please double check your connection info and starting path. Your starting path needs to be your SocialEngine path, or a parent directory of it.'); return; } $path = dirname(dirname($path)); } else { $path = $vfsConfig['path']; } // Verify path if (!$vfs->exists($path . '/install/ftp_search_will_look_for_this_file')) { $form->addError('Specified path is not a SocialEngine install directory.'); return; } // Save config $vfsConfig['path'] = $values['config']['path'] = $path; $vfs->changeDirectory($path); $this->_session->instance = $vfs; $this->_session->adapter = $vfsAdapter; $this->_session->config = $vfsConfig; $this->_vfsSettings = $values; // Save for later $vfsSettingsData = array('adapter' => $vfsAdapter, 'config' => array_diff_key($vfsConfig, array('password' => null, 'location' => null, 'search' => null))); @file_put_contents(APPLICATION_PATH . '/install/config/vfs.php', '<?php return ' . var_export($vfsSettingsData, true) . '?>'); // Redirect if (!empty($this->_session->return)) { $return = $this->_session->return; $this->_session->return = null; } return $this->_helper->redirector->gotoUrl($return, array('prependBase' => false)); }