$enable_ssl_admin = zen_read_config_value('ENABLE_SSL_ADMIN', FALSE); $dir_fs_www_root = zen_read_config_value('DIR_FS_CATALOG', FALSE); $https_catalog = zen_read_config_value('DIR_WS_HTTPS_CATALOG', FALSE); $http_server = $zc_install->trimTrailingSlash($http_server); $http_catalog = $zc_install->trimTrailingSlash($http_catalog); $virtual_path = $zc_install->trimTrailingSlash($virtual_path); $virtual_https_server = $zc_install->trimTrailingSlash($virtual_https_server); $virtual_https_path = $zc_install->trimTrailingSlash($virtual_https_path); $dir_fs_www_root = $zc_install->trimTrailingSlash($dir_fs_www_root); $https_catalog = $zc_install->trimTrailingSlash($https_catalog); } else { //fresh install, so do auto-detect of several settings $dir_fs_www_root = $zc_install->detectDocumentRoot(); // Determine http URL and path $virtual_path = preg_replace('~/zc_install/index.php$~', '', $_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME']); $parsedUrl = zen_parse_url($virtual_path, 'array', true); // Determine the https directory. This is a best-guess since if we're not installing over SSL we can't fully know for certain. If we are in SSL mode, this is pretty reliable. $virtual_https_server = $parsedUrl['host']; $virtual_https_path = $virtual_path; } //endif $is_upgrade // Yahoo hosting and others may use / for physical path ... so instead of leaving it blank, offer '/' if ($dir_fs_www_root == '') { $dir_fs_www_root = '/'; } // Set form input values if (!isset($_POST['physical_path'])) { $_POST['physical_path'] = $dir_fs_www_root; } if (!isset($_POST['virtual_http_path'])) { $_POST['virtual_http_path'] = 'http://' . $virtual_path;
*/ /** * WE RECOMMEND THAT YOU USE SSL PROTECTION FOR YOUR ENTIRE ADMIN: * To do that, make sure you use a "https:" URL for BOTH the HTTP_SERVER and HTTPS_SERVER entries: */ define('HTTP_SERVER', 'http://localhost'); define('HTTPS_SERVER', 'https://localhost'); define('HTTP_CATALOG_SERVER', 'http://localhost'); define('HTTPS_CATALOG_SERVER', 'https://localhost'); // secure webserver for admin? Valid choices are 'true' or 'false' (including quotes). define('ENABLE_SSL_ADMIN', 'false'); // secure webserver for storefront? Valid choices are 'true' or 'false' (including quotes). define('ENABLE_SSL_CATALOG', 'false'); define('DIR_WS_ADMIN', preg_replace('#^' . str_replace('-', '\\-', zen_parse_url(HTTP_SERVER, '/path')) . '#', '', dirname($_SERVER['SCRIPT_NAME'])) . '/'); define('DIR_WS_CATALOG', '/'); define('DIR_WS_HTTPS_ADMIN', preg_replace('#^' . str_replace('-', '\\-', zen_parse_url(HTTPS_SERVER, '/path')) . '#', '', dirname($_SERVER['SCRIPT_NAME'])) . '/'); define('DIR_WS_HTTPS_CATALOG', '/'); // NOTE: be sure to leave the trailing '/' at the end of these lines if you make changes! // * DIR_WS_* = Webserver directories (virtual/URL) // these paths are relative to top of your webspace ... (ie: under the public_html or httpdocs folder) define('DIR_WS_IMAGES', 'images/'); define('DIR_WS_ICONS', DIR_WS_IMAGES . 'icons/'); define('DIR_WS_CATALOG_IMAGES', HTTP_CATALOG_SERVER . DIR_WS_CATALOG . 'images/'); define('DIR_WS_CATALOG_TEMPLATE', HTTP_CATALOG_SERVER . DIR_WS_CATALOG . 'includes/templates/'); define('DIR_WS_INCLUDES', 'includes/'); define('DIR_WS_FUNCTIONS', DIR_WS_INCLUDES . 'functions/'); define('DIR_WS_CLASSES', DIR_WS_INCLUDES . 'classes/'); define('DIR_WS_MODULES', DIR_WS_INCLUDES . 'modules/'); define('DIR_WS_LANGUAGES', DIR_WS_INCLUDES . 'languages/'); define('DIR_WS_CATALOG_LANGUAGES', HTTP_CATALOG_SERVER . DIR_WS_CATALOG . 'includes/languages/'); // * DIR_FS_* = Filesystem directories (local/physical)
function writeConfigFiles() { $virtual_http_path = zen_parse_url($this->getConfigKey('virtual_http_path')); $http_server = $virtual_http_path['scheme'] . '://' . $virtual_http_path['host']; $http_catalog = isset($virtual_http_path['path']) ? $virtual_http_path['path'] : ''; // handle /~username cases common to shared-ssl $testarray = explode('/', trim($http_catalog, '/')); if (sizeof($testarray) > 0) { if (substr($testarray[0], 0, 1) == '~') { $http_server .= '/' . $testarray[0]; array_shift($testarray); $http_catalog = implode('/', $testarray); } } $http_catalog = str_replace('//', '/', '/' . trim($http_catalog, '/') . '/'); if (isset($virtual_http_path['port']) && !empty($virtual_http_path['port'])) { $http_server .= ':' . $virtual_http_path['port']; } $sql_cache_dir = (int) $this->getConfigKey('DIR_FS_SQL_CACHE'); $cache_type = $this->getConfigKey('SQL_CACHE_METHOD'); $https_server = $this->getConfigKey('virtual_https_server'); $https_catalog = $this->getConfigKey('virtual_https_path'); //if the https:// entries were left blank, use non-SSL versions instead of blank if ($https_server == '' || trim($https_server) == '' || $https_server == 'https://' || $https_server == '://') { $https_server = $http_server; } if (trim($https_catalog) == '') { $https_catalog = $http_catalog; } // handle /~username cases common to shared-ssl $testarray = explode('/', trim(str_replace($https_server, '', $https_catalog), '/')); if (sizeof($testarray) > 0) { if (substr($testarray[0], 0, 1) == '~') { $https_server .= '/' . $testarray[0]; array_shift($testarray); $https_catalog = implode('/', $testarray); } } $https_catalog_path = preg_replace('#' . preg_quote($https_server, '/') . '#', '', $https_catalog); $https_catalog = str_replace('//', '/', '/' . trim($https_catalog_path, '/') . '/'); //now let's write the files // Catalog version first: require 'includes/store_configure.php'; $config_file_contents_catalog = $file_contents; $fp = @fopen($this->getConfigKey('DIR_FS_CATALOG') . '/includes/configure.php', 'w'); if ($fp) { fputs($fp, $file_contents); fclose($fp); @chmod($this->getConfigKey('DIR_FS_CATALOG') . '/includes/configure.php', 0444); } $http_srvr_admin = $http_server; $http_catalog_admin = $http_catalog; // if SSL is enabled for admin, put the SSL address into the HTTP_SERVER field (and set corresponding DIR_WS_ADMIN param too) if ($this->getConfigKey('ENABLE_SSL_ADMIN') == 'true') { $http_srvr_admin = $https_server; $http_catalog_admin = $https_catalog; } // now Admin version: require 'includes/admin_configure.php'; $config_file_contents_admin = $file_contents; $fp = @fopen($this->getConfigKey('DIR_FS_CATALOG') . '/admin/includes/configure.php', 'w'); if ($fp) { fputs($fp, $file_contents); fclose($fp); // @chmod($this->getConfigKey('DIR_FS_CATALOG') . '/admin/includes/configure.php', 0444); } $this->configFiles = array('catalog' => $config_file_contents_catalog, 'admin' => $config_file_contents_admin); return $this->validateConfigFiles($http_server); }