<?

/*
FlexCMS (http://www.flexcms.com)
Flexible, Powerful, Affordable.

Contents of this file are protected by the copyright
notice found at http://www.flexcms.com/flex/pages/copyright.html,
and its usage is subject to the terms of the licensing agreement 
available at http://www.flexcms.com/flex/pages/license.html
*/



	// ========================================================================================

	
	$PageTitle = '<img src="'.$ImagesURL.'/admin/admincp_ecom.gif" width="20" height="21" align="middle"> '.$MsgText[9][129];
	$BrowserTitle = $MsgText[9][129];
	$LocationBar = '<a href="'.$IndexURL.'">'.$MsgText[0][1].'</a> > <a href="' . $MainURL . '/options.html">'.$MsgText[0][4].'</a> > '.$MsgText[9][129];
	
	if ($LoggedIn == 'y') {
		
		ReadPermissions();
		Global $Permissions;
		
		if ($Permissions[902] == 'y') {
	
	
			ReadFormArguments();
			Global $FormArguments;
			
			if (count($FormArguments) > 0) {
											
				
				$query = "update `".$Settings['DBPrefix']."ec-Settings` set Value='".$FormArguments['TitleAlignment']."' where Name='TitleAlignment' limit 1";
				$result = mysql_query($query) or die (mysql_error());
				
				$query = "update `".$Settings['DBPrefix']."ec-Settings` set Value='".$FormArguments['TopText']."' where Name='TopText' limit 1";
				$result = mysql_query($query) or die (mysql_error());
				$query = "update `".$Settings['DBPrefix']."ec-Settings` set Value='".$FormArguments['BottomText']."' where Name='BottomText' limit 1";
				$result = mysql_query($query) or die (mysql_error());
				
				
				$query = "update `".$Settings['DBPrefix']."ec-Settings` set Value='".$FormArguments['CategoryPictureLocation']."' where Name='CategoryPictureLocation' limit 1";
				$result = mysql_query($query) or die (mysql_error());
				
				$query = "update `".$Settings['DBPrefix']."ec-Settings` set Value='".$FormArguments['DetailsPictureLocation']."' where Name='DetailsPictureLocation' limit 1";
				$result = mysql_query($query) or die (mysql_error());
				
				
				$query = "update `".$Settings['DBPrefix']."ec-Settings` set Value='".$FormArguments['MaxWidth']."' where Name='MaxWidth' limit 1";
				$result = mysql_query($query) or die (mysql_error());
				$query = "update `".$Settings['DBPrefix']."ec-Settings` set Value='".$FormArguments['MaxHeight']."' where Name='MaxHeight' limit 1";
				$result = mysql_query($query) or die (mysql_error());
				
				$query = "update `".$Settings['DBPrefix']."ec-Settings` set Value='".$FormArguments['LargeImageMaxWidth']."' where Name='LargeImageMaxWidth' limit 1";
				$result = mysql_query($query) or die (mysql_error());
				$query = "update `".$Settings['DBPrefix']."ec-Settings` set Value='".$FormArguments['LargeImageMaxHeight']."' where Name='LargeImageMaxHeight' limit 1";
				$result = mysql_query($query) or die (mysql_error());
				
				$query = "update `".$Settings['DBPrefix']."ec-Settings` set Value='".$FormArguments['ThumbMaxWidth']."' where Name='ThumbMaxWidth' limit 1";
				$result = mysql_query($query) or die (mysql_error());
				$query = "update `".$Settings['DBPrefix']."ec-Settings` set Value='".$FormArguments['ThumbMaxHeight']."' where Name='ThumbMaxHeight' limit 1";
				$result = mysql_query($query) or die (mysql_error());
				

				$query = "update `".$Settings['DBPrefix']."ec-Settings` set Value='".$FormArguments['MaxImageFileSize']."' where Name='MaxImageFileSize' limit 1";
				$result = mysql_query($query) or die (mysql_error());
				
				
				$query = "update `".$Settings['DBPrefix']."ec-Settings` set Value='".$FormArguments['OriginZipCode']."' where Name='OriginZipCode' limit 1";
				$result = mysql_query($query) or die (mysql_error());
				
				
				$query = "update `".$Settings['DBPrefix']."ec-Settings` set Value='".$FormArguments['OrdersEmail']."' where Name='OrdersEmail' limit 1";
				$result = mysql_query($query) or die (mysql_error());
				
				$query = "update `".$Settings['DBPrefix']."ec-Settings` set Value='".$FormArguments['PaypalEmail']."' where Name='PaypalEmail' limit 1";
				$result = mysql_query($query) or die (mysql_error());
				
				$query = "update `".$Settings['DBPrefix']."ec-Settings` set Value='".$FormArguments['GoogleCheckoutMerchantID']."' where Name='GoogleCheckoutMerchantID' limit 1";
				$result = mysql_query($query) or die (mysql_error());
				
				
				$query = "update `".$Settings['DBPrefix']."ec-Settings` set Value='".$FormArguments['OfflinePayableTo']."' where Name='OfflinePayableTo' limit 1";
				$result = mysql_query($query) or die (mysql_error());
				$query = "update `".$Settings['DBPrefix']."ec-Settings` set Value='".$FormArguments['OfflinePaymentDetails']."' where Name='OfflinePaymentDetails' limit 1";
				$result = mysql_query($query) or die (mysql_error());
				
				
				$query = "update `".$Settings['DBPrefix']."ec-Settings` set Value='".$FormArguments['RequireShipToBilling']."' where Name='RequireShipToBilling' limit 1";
				$result = mysql_query($query) or die (mysql_error());
				
				
				$query = "update `".$Settings['DBPrefix']."ec-Settings` set Value='".$FormArguments['DisplayActualStock']."' where Name='DisplayActualStock' limit 1";
				$result = mysql_query($query) or die (mysql_error());				
				$query = "update `".$Settings['DBPrefix']."ec-Settings` set Value='".$FormArguments['DisplayActualStockMax']."' where Name='DisplayActualStockMax' limit 1";
				$result = mysql_query($query) or die (mysql_error());
				
				
				
				
				$query = "select * from `".$Settings['DBPrefix']."ec-Settings` where Name='TitleImage' limit 1";
				$result = mysql_query($query) or die (mysql_error());
				if (mysql_num_rows($result) > 0) {
					$query = "update `".$Settings['DBPrefix']."ec-Settings` set Value='".$FormArguments['TitleImage']."' where Name='TitleImage' limit 1";
					$result = mysql_query($query) or die (mysql_error());
				}
				else {
					$query = "insert into `".$Settings['DBPrefix']."ec-Settings` (Name, Value) values ('TitleImage','".$FormArguments['TitleImage']."')";
					$result = mysql_query($query) or die (mysql_error());
				}
				
				
				$query = "select * from `".$Settings['DBPrefix']."ec-Settings` where Name='PageTitle' limit 1";
				$result = mysql_query($query) or die (mysql_error());
				if (mysql_num_rows($result) > 0) {
					$query = "update `".$Settings['DBPrefix']."ec-Settings` set Value='".$FormArguments['PageTitle']."' where Name='PageTitle' limit 1";
					$result = mysql_query($query) or die (mysql_error());
				}
				else {
					$query = "insert into `".$Settings['DBPrefix']."ec-Settings` (Name, Value) values ('PageTitle','".$FormArguments['PageTitle']."')";
					$result = mysql_query($query) or die (mysql_error());
				}
				
				
				
				
				
				if ($FormArguments['ShowInStock'] == 2 && $FormArguments['ShowInStockOther'] != '') {
					$ShowInStock = 'y';
					$ShowInStockOther = $FormArguments['ShowInStockOther'];
				}
				else if ($FormArguments['ShowInStock'] == 1 || $FormArguments['ShowInStock'] == 2) {
					$ShowInStock = 'y';
					$ShowInStockOther = '';
				}
				else {
					$ShowInStock = 'n';
					$ShowInStockOther = '';
				}
								
				$query = "update `".$Settings['DBPrefix']."ec-Settings` set Value='".$ShowInStock."' where Name='ShowInStock' limit 1";
				$result = mysql_query($query) or die (mysql_error());
				$query = "update `".$Settings['DBPrefix']."ec-Settings` set Value='".$ShowInStockOther."' where Name='ShowInStockOther' limit 1";
				$result = mysql_query($query) or die (mysql_error());
				
				
				
				if ($FormArguments['ShowSoldOut'] == 2 && $FormArguments['ShowSoldOutOther'] != '') {
					$ShowSoldOut = 'y';
					$ShowSoldOutOther = $FormArguments['ShowSoldOutOther'];
				}
				else if ($FormArguments['ShowSoldOut'] == 1 || $FormArguments['ShowSoldOut'] == 2) {
					$ShowSoldOut = 'y';
					$ShowSoldOutOther = '';
				}
				else {
					$ShowSoldOut = 'n';
					$ShowSoldOutOther = '';
				}
								
				$query = "update `".$Settings['DBPrefix']."ec-Settings` set Value='".$ShowSoldOut."' where Name='ShowSoldOut' limit 1";
				$result = mysql_query($query) or die (mysql_error());
				$query = "update `".$Settings['DBPrefix']."ec-Settings` set Value='".$ShowSoldOutOther."' where Name='ShowSoldOutOther' limit 1";
				$result = mysql_query($query) or die (mysql_error());
				
				
				
				$query = "select * from `".$Settings['DBPrefix']."ec-Settings` where Name='ShowNoPricing' limit 1";
				$result = mysql_query($query) or die (mysql_error());
				if (mysql_num_rows($result) > 0) {
					$query = "update `".$Settings['DBPrefix']."ec-Settings` set Value='".$FormArguments['ShowNoPricing']."' where Name='ShowNoPricing' limit 1";
					$result = mysql_query($query) or die (mysql_error());
				}
				else {
					$query = "insert into `".$Settings['DBPrefix']."ec-Settings` (Name, Value) values ('ShowNoPricing','".$FormArguments['ShowNoPricing']."')";
					$result = mysql_query($query) or die (mysql_error());
				}
				
				
				
				
				if (substr($FormArguments['HighlightColor'],0,1) != '#' && $FormArguments['HighlightColor'] != '') { 
					$FormArguments['HighlightColor'] = '#'.$FormArguments['HighlightColor'];
				}
				
				$query = "update `".$Settings['DBPrefix']."ec-Settings` set Value='".$FormArguments['HighlightColor']."' where Name='HighlightColor' limit 1";
				$result = mysql_query($query) or die (mysql_error());
				
				
				$query = "update `".$Settings['DBPrefix']."ec-Settings` set Value='".$FormArguments['Currency']."' where Name='Currency' limit 1";
				$result = mysql_query($query) or die (mysql_error());
				$query = "update `".$Settings['DBPrefix']."ec-Settings` set Value='".$FormArguments['CurrencyLocation']."' where Name='CurrencyLocation' limit 1";
				$result = mysql_query($query) or die (mysql_error());
				
				$query = "update `".$Settings['DBPrefix']."ec-Settings` set Value='".$FormArguments['PriceDecimals']."' where Name='PriceDecimals' limit 1";
				$result = mysql_query($query) or die (mysql_error());
				$query = "update `".$Settings['DBPrefix']."ec-Settings` set Value='".$FormArguments['DecimalSymbol']."' where Name='DecimalSymbol' limit 1";
				$result = mysql_query($query) or die (mysql_error());
				
				$query = "update `".$Settings['DBPrefix']."ec-Settings` set Value='".$FormArguments['WeightUnits']."' where Name='WeightUnits' limit 1";
				$result = mysql_query($query) or die (mysql_error());
				
				$query = "update `".$Settings['DBPrefix']."ec-Settings` set Value='".$FormArguments['ThousandsSep']."' where Name='ThousandsSep' limit 1";
				$result = mysql_query($query) or die (mysql_error());
				
				$query = "update `".$Settings['DBPrefix']."ec-Settings` set Value='".strtoupper($FormArguments['CurrencyCode'])."' where Name='CurrencyCode' limit 1";
				$result = mysql_query($query) or die (mysql_error());
				
				
				
				header('Location: ' . $MainURL . '/options.html');
				
				
			}
			else {
				$PageContents = $MsgText[0][98];
			}
			
		}
		else {
		
			$PageContents = $MsgText[0][97];
		
		}

	}
	else {
	
		RedirectToLogin();
	
	}
	
	

	// ========================================================================================




?>
