function createHtaccessFile() { global $basePath, $offsetPath, $apacheHtaccessTemplateFile, $apacheHtaccessFile, $iisHtaccessTemplateFile, $iisHtaccessFile, $_ARRLANG, $_CORELANG; if (!@(include_once ASCMS_LIBRARY_PATH . '/FRAMEWORK/FWHtAccess.class.php')) { die('Unable to load file ' . ASCMS_LIBRARY_PATH . '/FRAMEWORK/FWHtAccess.class.php'); } $_CORELANG = $_ARRLANG; if ($this->getWebserverSoftware() == 'iis') { require_once ASCMS_LIBRARY_PATH . '/PEAR/File/HtAccess.php'; $objHtAccess = new File_HtAccess(ASCMS_DOCUMENT_ROOT . $iisHtaccessFile); $objHtAccess->setAdditional(explode("\n", $this->_getHtaccessFileTemplate($iisHtaccessTemplateFile))); $result = $objHtAccess->save(); if ($result !== true) { return sprintf($_ARRLANG['TXT_NO_WRITE_PERMISSION'], $iisHtaccessFile); } } else { $objFWHtAccess = new FWHtAccess(ASCMS_DOCUMENT_ROOT, ASCMS_PATH_OFFSET); $result = $objFWHtAccess->loadHtAccessFile($apacheHtaccessFile); if ($result !== true) { return $result; } $objFWHtAccess->setSection("core_routing", explode("\n", $this->_getHtaccessFileTemplate($apacheHtaccessTemplateFile))); $result = $objFWHtAccess->write(); if ($result !== true) { return sprintf($_ARRLANG['TXT_NO_WRITE_PERMISSION'], $apacheHtaccessFile); } } return true; }
function createHtAccess() { if (empty($_SESSION['contrexx_update']['htaccess_file_created'])) { $webServerSoftware = !empty($_SERVER['SERVER_SOFTWARE']) && stristr($_SERVER['SERVER_SOFTWARE'], 'apache') ? 'apache' : (stristr($_SERVER['SERVER_SOFTWARE'], 'iis') ? 'iis' : ''); $cl = Env::get('ClassLoader'); if ($webServerSoftware == 'iis') { $cl->loadFile(UPDATE_LIB . '/PEAR/File/HtAccess.php'); $objHtAccess = new File_HtAccess(ASCMS_DOCUMENT_ROOT . '/web.config'); $objHtAccess->setAdditional(explode("\n", @file_get_contents(dirname(__FILE__) . '/data/iis_htaccess.tpl'))); $result = $objHtAccess->save(); if ($result !== true) { return false; } } else { $cl->loadFile(UPDATE_LIB . '/FRAMEWORK/FWHtAccess.class.php'); $objFWHtAccess = new FWHtAccess(ASCMS_DOCUMENT_ROOT, ASCMS_PATH_OFFSET); $result = $objFWHtAccess->loadHtAccessFile('/.htaccess'); if ($result !== true) { return false; } $htAccessTemplate = getHtAccessTemplate(); $pathOffset = ASCMS_PATH_OFFSET; if (empty($pathOffset)) { $pathOffset = '/'; } $htAccessTemplate = str_replace('%PATH_ROOT_OFFSET%', $pathOffset, $htAccessTemplate); $objFWHtAccess->setSection('core_routing', explode("\n", $htAccessTemplate)); $objFWHtAccess->removeSection('core_modules__alias'); $objFWHtAccess->removeSection('core__language'); $result = $objFWHtAccess->write(); if ($result !== true) { return false; } } $_SESSION['contrexx_update']['htaccess_file_created'] = true; } return true; }