/** * Function makes backup of htaccess. * If it fails the backup will be not created. */ public function makeBackup() { $config = Mage::getSingleton('mturbo/config'); /* make back only if is enabled in configuration */ if ($config->getEnabledHtaccessBackup()) { $backupNum = $config->getNumberOfHtaccessBackups(); $backupPath = $this->websiteconfig->getBaseDir() . DS . '.htaccess.bak'; /* search free backup slot */ for ($i = 0; $i < $backupNum; $i++) { if (!file_exists($backupPath . $i)) { break; } } /* if backup slot is full, shift backups and save backup at $backupNum-1 */ if ($i == $backupNum) { $i = $backupNum - 1; for ($j = 0; $j < $backupNum - 1; $j++) { if ($j == 0) { @unlink($backupPath . $j); } @rename($backupPath . ($j + 1), $backupPath . $j); } } $htaccessPath = Mage::getBaseDir() . DS . '.htaccess'; $backupPath = $backupPath . $i; if (!copy($htaccessPath, $backupPath)) { Mage::log("I can't makes backup of htaccess"); } } }
/** * Function retrieve associated array 'name'=>'config key'. * Char * represents website code. */ public function getConfigArrayMap() { if (is_null(self::$configArrayMap)) { self::$configArrayMap = array('enabled' => 'mturbo/website/*/enabled', 'base_dir' => 'mturbo/website/*/basedir', 'server_name' => 'mturbo/website/*/servername', 'enabled_storeviews' => 'mturbo/website/*/enabledstoreviews'); } return self::$configArrayMap; }