public function testConnection() { $exportDirectory = $this->_fixBasePath($this->getDestination()->getPath()); $testResult = new Varien_Object(); // Check for forbidden folders $forbiddenFolders = array(Mage::getBaseDir('base'), Mage::getBaseDir('base') . DS . 'downloader'); foreach ($forbiddenFolders as $forbiddenFolder) { if (@realpath($exportDirectory) == $forbiddenFolder) { return $testResult->setSuccess(false)->setMessage(Mage::helper('xtento_orderexport')->__('It is not allowed to save export files in the directory you have specified. Please change the local export directory to be located in the ./var/ folder for example. Do not use the Magento root directory for example.')); } } if (!is_dir($exportDirectory) && !preg_match('/%exportid%/', $exportDirectory)) { // Try to create the directory. if (!@mkdir($exportDirectory)) { return $testResult->setSuccess(false)->setMessage(Mage::helper('xtento_orderexport')->__('The specified local directory does not exist. We could not create it either. Please make sure the parent directory is writable or create the directory manually: %s', $exportDirectory)); } else { $testResult->setDirectoryCreated(true); } } $this->_connection = @opendir($exportDirectory); if (!$this->_connection || @(!is_writable($exportDirectory))) { return $testResult->setSuccess(false)->setMessage(Mage::helper('xtento_orderexport')->__('Could not open local export directory for writing. Please make sure that we have rights to read and write in the directory: %s', $exportDirectory)); } if ($testResult->getDirectoryCreated()) { $testResult->setSuccess(true)->setMessage(Mage::helper('xtento_orderexport')->__('Local directory didn\'t exist and was created successfully. Connection tested successfully.')); if (!$this->getDestination()->getBackupDestination()) { $this->getDestination()->setLastResult($testResult->getSuccess())->setLastResultMessage($testResult->getMessage())->save(); } return $testResult; } else { $testResult->setSuccess(true)->setMessage(Mage::helper('xtento_orderexport')->__('Local directory exists and is writable. Connection tested successfully.')); if (!$this->getDestination()->getBackupDestination()) { $this->getDestination()->setLastResult($testResult->getSuccess())->setLastResultMessage($testResult->getMessage())->save(); } return $testResult; } }