Example #1
0
	public function HandlePage()
	{
		GetLib("class.redirects");

		// We're here because we can't find the requested URL
		// It may be a URL that has been set up as a redirect, so lets check that
		ISC_REDIRECTS::checkRedirect($_SERVER['REQUEST_URI']);

		// Send the 404 status headers
		header("HTTP/1.1 404 Not Found");

		// Simply show the 404 page
		$GLOBALS['ISC_CLASS_TEMPLATE']->SetPageTitle(GetConfig('StoreName')." - ".GetLang('NotFound'));
		$GLOBALS['ISC_CLASS_TEMPLATE']->SetTemplate("404");
		$GLOBALS['ISC_CLASS_TEMPLATE']->ParseTemplate();
	}
	private function saveNewRedirectURL()
	{
		$newUrl = trim($_POST['newurl']);
		$redirectId = (int)$_POST['id'];

		if(empty($newUrl) || $newUrl == "/") {
			ISC_JSON::output(GetLang('InvalidRedirect'));
		}

		GetLib('class.redirects');
		$newUrl = ISC_REDIRECTS::normalizeNewURLForDatabase($newUrl, $error);
		if ($newUrl === false) {
			if (empty($error)) {
				$error = GetLang('InvalidRedirect');
			}
			ISC_JSON::output($error);
		}
		$returnData = array('url' => $newUrl, 'id' => $redirectId);

		if($redirectId == 0 && substr($_POST['id'], 0, 3) == 'tmp') {
			$redirectId = $GLOBALS['ISC_CLASS_DB']->InsertQuery('redirects',  array('redirectpath'=> '', 'redirectmanual' => $newUrl, 'redirectassoctype' => ISC_REDIRECTS::REDIRECT_TYPE_MANUAL, 'redirectassocid'=>0));
			//echo "REdirect iD is " . $GLOBALS['ISC_CLASS_DB']->getErrorMsg();
			if($redirectId) {
				$returnData['id'] = $redirectId;
				$returnData['tmpredirectid'] = $_POST['id'];
				ISC_JSON::output('', true, $returnData);
				return;
			}
		} else {
			if($GLOBALS['ISC_CLASS_DB']->UpdateQuery('redirects', array('redirectmanual' => $newUrl), 'redirectid=' . $redirectId)) {
				ISC_JSON::output('', true, $returnData);
				return;
			}
		}

		ISC_JSON::output(GetLang('RedirectSaveErrorDatabase'));
	}
Example #3
0
		private function SaveUpdatedSettings()
		{
			if($_SERVER['REQUEST_METHOD'] != 'POST') {
				$this->ManageSettings();
				return;
			}

			$boolean = array (
				'UseWYSIWYG',
				'AllowPurchasing',
				'ShowInventory',
				'ShowPreOrderInventory',
				'ShowThumbsInControlPanel',
				'TagCloudsEnabled',
				'ShowAddToCartQtyBox',
				'CaptchaEnabled',
				'ShowCartSuggestions',
				'ShowThumbsInCart',
				'AutoApproveReviews',
				'SearchSuggest',
				'QuickSearch',
				'RSSNewProducts',
				'RSSPopularProducts',
				'RSSFeaturedProducts',
				'RSSCategories',
				'RSSProductSearches',
				'RSSLatestBlogEntries',
				'RSSSyndicationIcons',
				'StoreDSTCorrection',
				'SystemLogging',
				'AdministratorLogging',
				'DebugMode',
				'EnableWishlist',
				'EnableAccountCreation',
				'EnableProductComparisons',
				'ShowProductPrice',
				'ShowProductSKU',
				'ShowProductWeight',
				'ShowProductBrand',
				'ShowProductShipping',
				'ShowProductRating',
				'HidePHPErrors',
				'HTTPSSLVerifyPeer',
				'ShowAddToCartLink',
				'ShowAddThisLink',
				'BulkDiscountEnabled',
				'EnableProductTabs',
				'ForceControlPanelSSL',
				'ProductImagesTinyThumbnailsEnabled',
				'ProductImagesImageZoomEnabled',
				'DownForMaintenance',
				'EnableCustomersAlsoViewed',
				'FacebookLikeButtonEnabled',
				'FacebookLikeButtonShowFaces',
				'categoryFlyoutDropShadow',
			);

			foreach ($boolean as $var) {
				if (isset($_POST[$var]) && ($_POST[$var] == 1 || $_POST[$var] === "ON")) {
					$GLOBALS['ISC_NEW_CFG'][$var] = 1;
				} else {
					$GLOBALS['ISC_NEW_CFG'][$var] = 0;
				}
			}

			$positive_ints = array (
				'HomeFeaturedProducts',
				'HomeNewProducts',
				'HomeBlogPosts',
				'CategoryProductsPerPage',
				'CategoryListDepth',
				'ProductReviewsPerPage',
				'RSSItemsLimit',
				'RSSCacheTime',
				'EnableSEOUrls',
				'SystemLogMaxLength',
				'AdministratorLogMaxLength',
				'GuestCustomerGroup',
				'CategoryPerRow',
				'CategoryImageWidth',
				'CategoryImageHeight',
				'BrandPerRow',
				'BrandImageWidth',
				'BrandImageHeight',
				'TagCloudMinSize',
				'TagCloudMaxSize',
				'SearchResultsPerPage',
				'ProductImagesStorewideThumbnail_width',
				'ProductImagesStorewideThumbnail_height',
				'ProductImagesProductPageImage_width',
				'ProductImagesProductPageImage_height',
				'ProductImagesGalleryThumbnail_width',
				'ProductImagesGalleryThumbnail_height',
				'ProductImagesZoomImage_width',
				'ProductImagesZoomImage_height',
				'StartingOrderNumber',
				'CustomersAlsoViewedCount',
				'PCIPasswordMinLen',
				'PCIPasswordHistoryCount',
				'PCIPasswordExpiryTimeDay',
				'PCILoginAttemptCount',
				'PCILoginLockoutTimeMin',
				'PCILoginIdleTimeMin',
				'PCILoginInactiveTimeDay',
			);

			foreach ($positive_ints as $var) {
				if (isset($_POST[$var]) && (int)$_POST[$var] > 0) {
					$GLOBALS['ISC_NEW_CFG'][$var] = (int)$_POST[$var];
				} else {
					$GLOBALS['ISC_NEW_CFG'][$var] = 0;
				}
			}

			$floats = array(
				'categoryFlyoutMouseOutDelay',
			);

			foreach ($floats as $var) {
				if (!isset($_POST[$var])) {
					$GLOBALS['ISC_NEW_CFG'][$var] = 0;
				}
				$GLOBALS['ISC_NEW_CFG'][$var] = (float)$_POST[$var];
			}

			$_SESSION['RunImageResize'] = 'no';
			if(isset($_POST['AutoResizeImages']) && $_POST['AutoResizeImages'] == 'yes') {
				$_SESSION['RunImageResize'] = 'yes';
			}

			// check the starting order number
			$currentAutoIncrement = (int)GetOrderTableAutoIncrement();
			$newAutoIncrement = (int)$_POST['StartingOrderNumber'];
			if($currentAutoIncrement != $newAutoIncrement) {
				// they've changed the starting order number
				// we need to make sure that it is not lower than any current order's ID tho

				$highestOrderId = GetHighestOrderNumber();
				if($newAutoIncrement <= $highestOrderId) {
					// new starting ID is too low
					$message = GetLang('StartingOrderNumberTooLow', array(
						'currentHighest' => $highestOrderId,
						'lowestPossible' => ($highestOrderId+1),
					));
					FlashMessage($message, MSG_ERROR, 'index.php?ToDo=viewSettings&currentTab='.((int) $_POST['currentTab']));
					die();
				}

				if(!UpdateOrderTableAutoIncrement($newAutoIncrement)) {
					FlashMessage(GetLang('StartingOrderNumberAlterFailed'), MSG_ERROR, 'index.php?ToDo=viewSettings&currentTab='.((int) $_POST['currentTab']));
					die();
				}
			}

			// check image size limits and cap them, check for invalid sizes and set them as defaults
			$imageSizes = array(
				'StorewideThumbnail' => ISC_PRODUCT_DEFAULT_IMAGE_SIZE_THUMBNAIL,
				'ProductPageImage' => ISC_PRODUCT_DEFAULT_IMAGE_SIZE_STANDARD,
				'GalleryThumbnail' => ISC_PRODUCT_DEFAULT_IMAGE_SIZE_TINY,
				'ZoomImage' => ISC_PRODUCT_DEFAULT_IMAGE_SIZE_ZOOM,
			);

			foreach ($imageSizes as $imageSizeKey => $imageSizeDefault) {
				$widthKey = 'ProductImages' . $imageSizeKey . '_width';
				$heightKey = 'ProductImages' . $imageSizeKey . '_height';

				if ($GLOBALS['ISC_NEW_CFG'][$widthKey] > ISC_PRODUCT_IMAGE_MAXLONGEDGE) {
					$GLOBALS['ISC_NEW_CFG'][$widthKey] = ISC_PRODUCT_IMAGE_MAXLONGEDGE;
				} else if ($GLOBALS['ISC_NEW_CFG'][$widthKey] < 1) {
					$GLOBALS['ISC_NEW_CFG'][$widthKey] = $imageSizeDefault;
				}

				if ($GLOBALS['ISC_NEW_CFG'][$heightKey] > ISC_PRODUCT_IMAGE_MAXLONGEDGE) {
					$GLOBALS['ISC_NEW_CFG'][$heightKey] = ISC_PRODUCT_IMAGE_MAXLONGEDGE;
				} else if ($GLOBALS['ISC_NEW_CFG'][$heightKey] < 1) {
					$GLOBALS['ISC_NEW_CFG'][$heightKey] = $imageSizeDefault;
				}

			}

			// Have there been any changes to the image sizes?
			// If there were no changes, don't even touch the images database
			$imageSizes = array(
				ISC_PRODUCT_IMAGE_SIZE_THUMBNAIL => array(
					'ProductImagesStorewideThumbnail_width',
					'ProductImagesStorewideThumbnail_height',
				),
				ISC_PRODUCT_IMAGE_SIZE_STANDARD => array(
					'ProductImagesProductPageImage_width',
					'ProductImagesProductPageImage_height',
				),
				ISC_PRODUCT_IMAGE_SIZE_TINY => array(
					'ProductImagesGalleryThumbnail_width',
					'ProductImagesGalleryThumbnail_height',
				),
				ISC_PRODUCT_IMAGE_SIZE_ZOOM => array(
					'ProductImagesZoomImage_width',
					'ProductImagesZoomImage_height',
				),
			);

			// hacky :/
			$imageTimeChangedKeys = array(
				ISC_PRODUCT_IMAGE_SIZE_THUMBNAIL => 'ProductImagesStorewideThumbnail_timeChanged',
				ISC_PRODUCT_IMAGE_SIZE_STANDARD => 'ProductImagesProductPageImage_timeChanged',
				ISC_PRODUCT_IMAGE_SIZE_TINY => 'ProductImagesGalleryThumbnail_timeChanged',
				ISC_PRODUCT_IMAGE_SIZE_ZOOM => 'ProductImagesZoomImage_timeChanged',
			);

			$changedDimensions = array();
			foreach($imageSizes as $size => $dimensionSettings) {
				foreach($dimensionSettings as $dimension) {
					if($GLOBALS['ISC_NEW_CFG'][$dimension] != $GLOBALS['ISC_CFG'][$dimension]) {
						$changedDimensions[$size] = $size;
						$GLOBALS['ISC_NEW_CFG'][$imageTimeChangedKeys[$size]] = time();
					}
				}
			}

			// product images used to be deleted here if the dimensions changed but this is now inside the image class
			// and is based off the _timeChanged above

			// check if the down for maintenance message is the same as the language pack
			if(Store_DownForMaintenance::getDownForMaintenanceMessage(true) == $_POST['DownForMaintenanceMessage'] || empty($_POST['DownForMaintenanceMessage'])) {
				$GLOBALS['ISC_NEW_CFG']['DownForMaintenanceMessage'] = '';

			} else if ($GLOBALS['ISC_NEW_CFG']['DownForMaintenance'] == 1) {
				$GLOBALS['ISC_NEW_CFG']['DownForMaintenanceMessage'] = $_POST['DownForMaintenanceMessage'];
			}

			// Normalize the shop path based on users redirect to www/no-www setting
			$shopPath = $_POST['ShopPath'];
			GetLib('class.redirects');
			$shopPath = ISC_REDIRECTS::normalizeShopPath($shopPath, (int)$_POST['RedirectWWW']);
			$GLOBALS['ISC_NEW_CFG']['ShopPath'] = $shopPath;

			$strings = array (
				'SharedSSLPath',
				'SubdomainSSLPath',
				'StoreName',
				'StoreAddress',
				'serverStamp',
				'DownloadDirectory',
				'ImageDirectory',
				'HomePagePageTitle',
				'MetaKeywords',
				'MetaDesc',
				'AdminEmail',
				'OrderEmail',
				'DisplayDateFormat',
				'ExportDateFormat',
				'ExtendedDisplayDateFormat',
				'GoogleMapsAPIKey',
				'ForwardInvoiceEmails',
				'HTTPProxyPort',
				'HTTPProxyServer',
				'DimensionsDecimalToken',
				'DimensionsThousandsToken',
				'DimensionsDecimalPlaces',
				'SessionSavePath',
				'DefaultPreOrderMessage',
				'FacebookLikeButtonAdminIds',
				'CategoryListStyle',
			);

			// ignore this setting if it's posted by the client but should be hidden, otherwise process it
			if (!GetConfig('HideDeletedOrdersActionSetting')) {
				$strings[] = 'DeletedOrdersAction';
			}

			foreach ($strings as $var) {
				if (isset($_POST[$var]) && is_string($_POST[$var])) {
					$GLOBALS['ISC_NEW_CFG'][$var] = $_POST[$var];
				}
			}

			$enums = array (
				'UseSSL' => array(SSL_NONE, SSL_NORMAL, SSL_SHARED, SSL_SUBDOMAIN),
				'WeightMeasurement' => array ('LBS', 'KGS', 'Ounces', 'Grams', 'Tonnes'),
				'LengthMeasurement' => array ('Inches', 'Centimeters'),
				'StoreTimeZone' => array_keys($this->timezones),
				'Language' => $this->GetAvailableLanguagesArray(),
				'TagCartQuantityBoxes' => array ('dropdown', 'textbox'),
				'FastCartAction' => array('popup', 'cart'),
				'ProductImageMode' => array ('popup', 'lightbox'),
				'ProductBreadcrumbs' => array('showall', 'showone', 'shownone'),
				'CategoryListingMode' => array('single', 'emptychildren', 'children'),
				'CategoryDisplayMode' => array('grid', 'list'),
				'ShippingFactoringDimension' => array('depth', 'height', 'width'),
				'SearchDefaultProductSort' => array('relevance', 'alphaasc', 'alphadesc', 'featured', 'newest', 'bestselling', 'avgcustomerreview', 'priceasc', 'pricedesc'),
				'SearchDefaultContentSort' => array('relevance', 'alphaasc', 'alphadesc'),
				'SearchProductDisplayMode' => array('grid', 'list'),
				'SearchOptimisation' => array('fulltext', 'like', 'both'),
				'CharacterSet' => $this->validCharacterSets,
				'AbandonOrderLifetime' => array(1, 7, 14, 21, 30, 60, 90, 120, 150, 180),
				'RedirectWWW' => array(REDIRECT_NO_PREFERENCE, REDIRECT_TO_WWW, REDIRECT_TO_NO_WWW),
				'FacebookLikeButtonStyle' => array('standard', 'countonly'),
				'FacebookLikeButtonPosition' => array('above', 'below'),
				'FacebookLikeButtonVerb' => array('like', 'recommend'),
			);

			foreach ($enums as $var => $possible_vals) {
				if (isset($_POST[$var]) && in_array($_POST[$var], $possible_vals)) {
					$GLOBALS['ISC_NEW_CFG'][$var] = $_POST[$var];
				} else {
					$GLOBALS['ISC_NEW_CFG'][$var] = $possible_vals[0];
				}
			}

			$uploads = array(
				'CategoryDefaultImage',
				'BrandDefaultImage',
			);

			if($_POST['DefaultProductImage'] == 'custom') {
				$uploads[] = 'DefaultProductImageCustom';
			}

			foreach ($uploads as $var) {
				$imageLocation = GetConfig($var);

				if (array_key_exists($var, $_FILES) && file_exists($_FILES[$var]['tmp_name'])) {
					$ext = GetFileExtension($_FILES[$var]['name']);
					$imageLocation = GetConfig('ImageDirectory').'/' . $var . '.' . $ext;
					move_uploaded_file($_FILES[$var]['tmp_name'], ISC_BASE_PATH . '/'.$imageLocation);

					// Attempt to change the permissions on the file
					isc_chmod(ISC_BASE_PATH . '/'.$imageLocation, ISC_WRITEABLE_FILE_PERM);
				}

				if (array_key_exists('Del' . $var, $_REQUEST) && $_REQUEST['Del' . $var]) {
					@unlink(ISC_BASE_PATH . GetConfig($var));
					$imageLocation = '';
				}

				$GLOBALS['ISC_NEW_CFG'][$var] = $imageLocation;
			}

			switch($_POST['DefaultProductImage']) {
				case 'custom':
					if ($GLOBALS['ISC_NEW_CFG']['DefaultProductImageCustom'] != '') {
						$GLOBALS['ISC_NEW_CFG']['DefaultProductImage'] = $GLOBALS['ISC_NEW_CFG']['DefaultProductImageCustom'];
					}
					unset($GLOBALS['ISC_NEW_CFG']['DefaultProductImageCustom']);
					break;
				case 'template':
					$GLOBALS['ISC_NEW_CFG']['DefaultProductImage'] = 'template';
					break;
				default:
					$GLOBALS['ISC_NEW_CFG']['DefaultProductImage'] = '';
			}

			// Backup Settings
			if (gzte11(ISC_MEDIUMPRINT)) {
				$boolean = array (
					'BackupsLocal',
					'BackupsRemoteFTP',
					'BackupsAutomatic',
					'BackupsAutomaticDatabase',
					'BackupsAutomaticImages',
					'BackupsAutomaticDownloads',
				);

				foreach ($boolean as $var) {
					if (isset($_POST[$var]) && ($_POST[$var] == 1 || $_POST[$var] === "ON")) {
						$GLOBALS['ISC_NEW_CFG'][$var] = 1;
					} else {
						$GLOBALS['ISC_NEW_CFG'][$var] = 0;
					}
				}

				$strings = array (
					'BackupsRemoteFTPHost',
					'BackupsRemoteFTPUser',
					'BackupsRemoteFTPPass',
					'BackupsRemoteFTPPath',
				);

				foreach ($strings as $var) {
					if (isset($_POST[$var]) && is_string($_POST[$var])) {
						$GLOBALS['ISC_NEW_CFG'][$var] = $_POST[$var];
					}
				}

				$enums = array (
					'BackupsAutomaticMethod' => array ('ftp', 'local'),
				);

				foreach ($enums as $var => $possible_vals) {
					if (isset($_POST[$var]) && in_array($_POST[$var], $possible_vals)) {
						$GLOBALS['ISC_NEW_CFG'][$var] = $_POST[$var];
					} else {
						$GLOBALS['ISC_NEW_CFG'][$var] = $possible_vals[0];
					}
				}
			}

			// Newsletter Settings
			if (isset($_POST['SystemLogTypes'])) {
				$GLOBALS['ISC_NEW_CFG']['SystemLogTypes'] = implode(",", $_POST['SystemLogTypes']);
			} else {
				$GLOBALS['ISC_NEW_CFG']['SystemLogTypes'] = '';
			}

			if (isset($_POST['SystemLogSeverity'])) {
				$GLOBALS['ISC_NEW_CFG']['SystemLogSeverity'] = implode(",", $_POST['SystemLogSeverity']);
			} else {
				$GLOBALS['ISC_NEW_CFG']['SystemLogSeverity'] = '';
			}

			if(isset($_POST['LowInventoryEmails']) && $_POST['LowInventoryEmails'] == 1) {
				$GLOBALS['ISC_NEW_CFG']['LowInventoryNotificationAddress'] = $_POST['LowInventoryNotificationAddress'];
			}
			else {
				$GLOBALS['ISC_NEW_CFG']['LowInventoryNotificationAddress'] = '';
			}

			if(isset($_POST['ForwardInvoiceEmailsCheck']) && $_POST['ForwardInvoiceEmailsCheck'] == 1) {
				$GLOBALS['ISC_NEW_CFG']['ForwardInvoiceEmails'] = $_POST['ForwardInvoiceEmails'];
			}
			else {
				$GLOBALS['ISC_NEW_CFG']['ForwardInvoiceEmails'] = '';
			}

			// Email Server Settings
			$GLOBALS['ISC_NEW_CFG']['MailUseSMTP'] = 0;
			$GLOBALS['ISC_NEW_CFG']['MailSMTPServer'] = '';
			$GLOBALS['ISC_NEW_CFG']['MailSMTPUsername'] = '';
			$GLOBALS['ISC_NEW_CFG']['MailSMTPPassword'] = '';
			$GLOBALS['ISC_NEW_CFG']['MailSMTPPort'] = '';

			if(isset($_POST['MailUseSMTP']) && $_POST['MailUseSMTP'] == 1) {
				$GLOBALS['ISC_NEW_CFG']['MailUseSMTP'] = 1;

				$GLOBALS['ISC_NEW_CFG']['MailSMTPServer'] = $_POST['MailSMTPServer'];
				if(isset($_POST['MailSMTPUsername'])) {
					$GLOBALS['ISC_NEW_CFG']['MailSMTPUsername'] = $_POST['MailSMTPUsername'];
				}
				if(isset($_POST['MailSMTPPassword'])) {
					$GLOBALS['ISC_NEW_CFG']['MailSMTPPassword'] = $_POST['MailSMTPPassword'];
				}
				if(isset($_POST['MailSMTPPort'])) {
					$GLOBALS['ISC_NEW_CFG']['MailSMTPPort'] = $_POST['MailSMTPPort'];
				}
			}

			if(isset($_POST['VendorPhotoUploading'])) {
				$GLOBALS['ISC_NEW_CFG']['VendorPhotoSize'] = (int)$_POST['VendorPhotoSizeW'].'x'.(int)$_POST['VendorPhotoSizeH'];
			}
			else {
				$GLOBALS['ISC_NEW_CFG']['VendorPhotoSize'] = '';
			}

			if(isset($_POST['VendorLogoUploading'])) {
				$GLOBALS['ISC_NEW_CFG']['VendorLogoSize'] = (int)$_POST['VendorLogoSizeW'].'x'.(int)$_POST['VendorLogoSizeH'];
			}
			else {
				$GLOBALS['ISC_NEW_CFG']['VendorLogoSize'] = '';
			}

			// Remove any settings that have been disabled so they can't be adjusted by the end user
			$disabledFields = array(
				'DisableLicenseKeyField' => array(
					'serverStamp'
				),
				'DisableStoreUrlField' => array(
					'ShopPath'
				),
				'DisablePathFields' => array(
					'DownloadDirectory',
					'ImageDirectory'
				),
				'DisableLoggingSettingsTab' => array(
					'SystemLogging',
					'HidePHPErrors',
					'SystemLogTypes',
					'SystemLogSeverity',
					'SystemLogMaxLength',
					'AdministratorLogging',
					'AdministratorLogMaxLength'
				),
				'DisableProxyFields' => array(
					'HTTPProxyServer',
					'HTTPProxyPort',
					'HTTPSSLVerifyPeer'
				),
				'DisableBackupSettings' => array(
					'BackupsLocal',
					'BackupsRemoteFTP',
					'BackupsRemoteFTPHost',
					'BackupsRemoteFTPUser',
					'BackupsRemoteFTPPass',
					'BackupsRemoteFTPPath',
					'BackupsAutomatic',
					'BackupsAutomaticMethod',
					'BackupsAutomaticDatabase',
					'BackupsAutomaticImages',
					'BackupsAutomaticDownloads'
				),
				'HidePCISettings' => array(
					'PCIPasswordMinLen',
					'PCIPasswordHistoryCount',
					'PCIPasswordExpiryTimeDay',
					'PCILoginAttemptCount',
					'PCILoginLockoutTimeMin',
					'PCILoginIdleTimeMin',
					'PCILoginInactiveTimeDay'
				)
			);

			foreach($disabledFields as $setting => $fields) {
				if(GetConfig($setting) == true) {
					foreach($fields as $field) {
						unset($GLOBALS['ISC_NEW_CFG'][$field]);
					}
				}
			 }

			$messages = array();

			if ($this->CommitSettings($messages)) {
				$redirectUrl = 'index.php?ToDo=viewSettings&currentTab='.(int)$_POST['currentTab'];

				// Mark this step as complete in getting started
				if(GetClass('ISC_ADMIN_ENGINE')->MarkGettingStartedComplete('settings')) {
					$redirectUrl = 'index.php';
				}

				// Log this action
				$GLOBALS['ISC_CLASS_LOG']->LogAdminAction();
				FlashMessage(GetLang('SettingsSavedSuccessfully'), MSG_SUCCESS, $redirectUrl);
			} else {
				FlashMessage(sprintf(GetLang('SettingsNotSaved'), $messages), MSG_ERROR, 'index.php?ToDo=viewSettings&currentTab='.((int) $_POST['currentTab']));
			}
		}
Example #4
0
	function RewriteIncomingRequest()
	{
		// Using path info
		if (isset($_SERVER['PATH_INFO']) && $_SERVER['PATH_INFO'] !== '' && basename($_SERVER['PATH_INFO']) != 'index.php') {
			$path = $_SERVER['PATH_INFO'];
			if (isset($_SERVER['SCRIPT_NAME'])) {
				$uriTest = str_ireplace($_SERVER['SCRIPT_NAME'], "", $path);
				if($uriTest != '') {
					$uri = $uriTest;
				}
			} else if (isset($_SERVER['SCRIPT_FILENAME'])) {
				$file = str_ireplace(ISC_BASE_PATH, "", $_SERVER['SCRIPT_FILENAME']);
				$uriTest = str_ireplace($file, "", $path);
				if($uriTest != '') {
					$uri = $uriTest;
				}
			}
			$GLOBALS['UrlRewriteBase'] = $GLOBALS['ShopPath'] . "/index.php/";
		}
		// Using HTTP_X_REWRITE_URL for ISAPI_Rewrite on IIS based servers
		if(isset($_SERVER['HTTP_X_REWRITE_URL']) && !isset($uri)) {
			$uri = $_SERVER['HTTP_X_REWRITE_URL'];
			$GLOBALS['UrlRewriteBase'] = $GLOBALS['ShopPath'] . "/";
		}
		// Using REQUEST_URI
		if (isset($_SERVER['REQUEST_URI']) && !isset($uri)) {
			$uri = $_SERVER['REQUEST_URI'];
			$GLOBALS['UrlRewriteBase'] = $GLOBALS['ShopPath'] . "/";
		}
		// Using SCRIPT URL
		if (isset($_SERVER['SCRIPT_URL']) && !isset($uri)) {
			$uri = $_SERVER['SCRIPT_URL'];
			$GLOBALS['UrlRewriteBase'] = $GLOBALS['ShopPath'] . "/";
		}
		// Using REDIRECT_URL
		if (isset($_SERVER['REDIRECT_URL']) && !isset($uri)) {
			$uri = $_SERVER['REDIRECT_URL'];
			$GLOBALS['UrlRewriteBase'] = $GLOBALS['ShopPath'] . "/";
		}
		// Using REDIRECT URI
		if (isset($_SERVER['REDIRECT_URI']) && !isset($uri)) {
			$uri = $_SERVER['REDIRECT_URI'];
			$GLOBALS['UrlRewriteBase'] = $GLOBALS['ShopPath'] . "/";
		}
		// Using query string?
		if (isset($_SERVER['QUERY_STRING']) && !isset($uri)) {
			$uri = $_SERVER['QUERY_STRING'];
			$GLOBALS['UrlRewriteBase'] = $GLOBALS['ShopPath'] . "/?";
			$_SERVER['QUERY_STRING'] = preg_replace("#(.*?)\?#", "", $_SERVER['QUERY_STRING']);
		}

		if (isset($_SERVER['REDIRECT_QUERY_STRING'])) {
			$_SERVER['QUERY_STRING'] = $_SERVER['REDIRECT_QUERY_STRING'];
		}

		if(!isset($uri)) {
			$uri = '';
		}

		// Check if the user needs to be redirected to www. or no www.
		GetLib('class.redirects');
		$redirectURL = ISC_REDIRECTS::checkRedirectWWW($uri);
		if ($redirectURL) {
			ISC_REDIRECTS::redirect($redirectURL);
		}

		$originalUri = $uri;
		$appPath = preg_quote(trim($GLOBALS['AppPath'], "/"), "#");
		$uri = trim($uri, "/");
		$uri = trim(preg_replace("#".$appPath."#i", "", $uri,1), "/");

		// Strip off anything after a ? in case we've got the query string too
		$uri = preg_replace("#\?(.*)#", "", $uri);

		$GLOBALS['PathInfo'] = explode("/", $uri);

		if(strtolower($GLOBALS['PathInfo'][0]) == "index.php") {
			$GLOBALS['PathInfo'][0] = '';
		}

		if (!isset($GLOBALS['PathInfo'][0]) || !$GLOBALS['PathInfo'][0]) {
			$GLOBALS['PathInfo'][0] = "index";
		}

		if(!isset($GLOBALS['RewriteRules'][$GLOBALS['PathInfo'][0]])) {
			$GLOBALS['PathInfo'][0] = "404";
		}

		$handler = $GLOBALS['RewriteRules'][$GLOBALS['PathInfo'][0]];
		$script = $handler['class'];
		$className = $handler['name'];
		$globalName = $handler['global'];

		if (isset($handler['checkdatabase'])) {
			// before redirecting, check for a stored 301 redirect
			GetLib("class.redirects");
			ISC_REDIRECTS::checkRedirect($originalUri);
		}

		$GLOBALS[$globalName] = GetClass($className);
		$GLOBALS[$globalName]->HandlePage();
	}