} } // Setup SSL options and links SetupSSLOptions(); // Store the currently used protocol $protocol = 'http'; if($_SERVER['HTTPS'] == 'on') { $protocol = 'https'; } $GLOBALS['Protocol'] = $protocol; // Setup the application path based on the current location $GLOBALS['ISC_CFG']['ShopPath'] = rtrim(GetConfig('ShopPath'), '/'); $parsedLocation = ParseShopPath($GLOBALS['ISC_CFG']['ShopPath']); if(!empty($parsedLocation['appPath'])) { $GLOBALS['ISC_CFG']['AppPath'] = $parsedLocation['appPath']; } else { $GLOBALS['ISC_CFG']['AppPath'] = ''; } // Load the configuration file for the active template. // Even though we may be in the control panel, we need to do this here as the email templates // can reference these locations as well and we have emails that can be sent via the control panel require_once(ISC_BASE_PATH . "/templates/" . GetConfig('template') . "/config.php"); // Setup our available template and image paths $GLOBALS['TPL_PATH'] = GetConfig('ShopPath').'/templates/'.GetConfig('template');
public function CommitSettings(&$messages=array()) { // If the shop path has changed normalize it and set the app path too if (isset($GLOBALS['ISC_NEW_CFG']['ShopPath']) && $GLOBALS['ISC_NEW_CFG']['ShopPath'] != GetConfig('ShopPath')) { $parsedPath = ParseShopPath($GLOBALS['ISC_NEW_CFG']['ShopPath']); $GLOBALS['ISC_NEW_CFG']['ShopPath'] = $parsedPath['shopPath']; // add an event to resubscribe to ebay notifications since the notification url will now be different if (ISC_ADMIN_EBAY::checkEbayConfig()) { Interspire_Event::bind('settings_updated', array('ISC_ADMIN_EBAY', 'resubscribeNotifications')); } } // normalize our shared ssl path if (isset($GLOBALS['ISC_NEW_CFG']['SharedSSLPath']) && trim($GLOBALS['ISC_NEW_CFG']['SharedSSLPath'])) { $ssl_path_parts = parse_url($GLOBALS['ISC_NEW_CFG']['SharedSSLPath']); if (!isset($ssl_path_parts['path'])) { $ssl_path_parts['path'] = ''; } $ssl_path_parts['path'] = rtrim($ssl_path_parts['path'], '/'); // Workout the Shop Path $GLOBALS['ISC_NEW_CFG']['SharedSSLPath'] = 'https://' . $ssl_path_parts['host']; if (isset($ssl_path_parts['port']) && $ssl_path_parts['port'] != '443') { $GLOBALS['ISC_NEW_CFG']['SharedSSLPath'] .= ':'.$ssl_path_parts['port']; } $GLOBALS['ISC_NEW_CFG']['SharedSSLPath'] .= $ssl_path_parts['path']; } // normalize our subdomain ssl path if (isset($GLOBALS['ISC_NEW_CFG']['SubdomainSSLPath']) && trim($GLOBALS['ISC_NEW_CFG']['SubdomainSSLPath'])) { $ssl_path_parts = parse_url($GLOBALS['ISC_NEW_CFG']['SubdomainSSLPath']); if (!isset($ssl_path_parts['path'])) { $ssl_path_parts['path'] = ''; } $ssl_path_parts['path'] = rtrim($ssl_path_parts['path'], '/'); // Workout the Shop Path $GLOBALS['ISC_NEW_CFG']['SubdomainSSLPath'] = 'https://' . $ssl_path_parts['host']; if (isset($ssl_path_parts['port']) && $ssl_path_parts['port'] != '443') { $GLOBALS['ISC_NEW_CFG']['SubdomainSSLPath'] .= ':'.$ssl_path_parts['port']; } $GLOBALS['ISC_NEW_CFG']['SubdomainSSLPath'] .= $ssl_path_parts['path']; } if (!isset($GLOBALS['ISC_NEW_CFG'])) { $GLOBALS['ISC_NEW_CFG'] = array(); } $directories = array( 'ImageDirectory' => 'product_images', 'DownloadDirectory' => 'product_downloads' ); foreach($directories as $directory => $default) { if(isset($GLOBALS['ISC_NEW_CFG'][$directory])) { $newDirectory = ISC_BASE_PATH.'/'.$GLOBALS['ISC_NEW_CFG'][$directory]; if(!$GLOBALS['ISC_NEW_CFG'][$directory] || !is_dir($newDirectory)) { $GLOBALS['ISC_NEW_CFG'][$directory] = $default; } } } // Wht we're doing here is we copy the current configuration in to another variable and // then load the store configuration file again. We do this to prevent any settings // that may have temporarily been modified in memory from propagating to the configuration // file. We then revert back to the in memory settings $memoryConfig = $GLOBALS['ISC_CFG']; unset($GLOBALS['ISC_CFG']); require ISC_CONFIG_FILE; $originalConfig = $GLOBALS['ISC_CFG']; $GLOBALS['ISC_CFG'] = $memoryConfig; $GLOBALS['ISC_SAVE_CFG'] = array_merge($originalConfig, $GLOBALS['ISC_NEW_CFG']); // Save the var_exported vars in the globals array temporarily for saving foreach ($this->all_vars as $var) { if (!array_key_exists($var, $GLOBALS['ISC_SAVE_CFG'])) { if(array_key_exists($var, $memoryConfig)) { $GLOBALS[$var] = var_export($memoryConfig[$var], true); } else { $GLOBALS[$var] = "null"; } } else { $GLOBALS[$var] = var_export($GLOBALS['ISC_SAVE_CFG'][$var], true); } } $config_data = $this->template->render('config.file.tpl'); $setting_string = "<" . "?php\n\n"; $setting_string .= "\t// Last Updated: ".isc_date("jS M Y @ g:i A") . "\n"; $setting_string .= $config_data; if (!defined("ISC_CONFIG_FILE") || !defined("ISC_CONFIG_BACKUP_FILE")) { die("Config sanity check failed"); } // Try to copy the current config file to a backup file if (!@copy(ISC_CONFIG_FILE, ISC_CONFIG_BACKUP_FILE)) { isc_chmod(ISC_CONFIG_BACKUP_FILE, ISC_WRITEABLE_FILE_PERM); $messages = array(GetLang('CouldntBackupConfig') => MSG_INFO); } // Try to write to the config file if (!is_writable(ISC_CONFIG_FILE)) { $this->error = GetLang('CouldntSaveConfig'); return false; } if (!($fp = @fopen(ISC_CONFIG_FILE, "wb+"))) { $this->error = GetLang('CouldntSaveConfig'); return false; } if (@fwrite($fp, $setting_string)) { fclose($fp); $prevCatListDepth = GetConfig('CategoryListDepth'); // Include the config file again to initialize the new values include(ISC_CONFIG_FILE); if (isset($GLOBALS['ISC_NEW_CFG']['CategoryListDepth']) && $GLOBALS['ISC_NEW_CFG']['CategoryListDepth'] != $prevCatListDepth) { $GLOBALS['ISC_CLASS_DATA_STORE']->UpdateRootCategories(); } // trigger any events that should run after the settings have been saved Interspire_Event::trigger('settings_updated'); return true; } fclose($fp); $this->error = GetLang('CouldntSaveConfig'); return false; }