<?

/*
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
*/



	// ========================================================================================
	// save preferences
	// ========================================================================================
	
	$PageTitle = $MsgText[0][62];
	$BrowserTitle = $MsgText[0][62];
	$LocationBar = '<a href="'.$IndexURL.'">'.$MsgText[0][1].'</a> > <a href="'.$MainURL.'/options.html">'.$MsgText[0][4].'</a> > '.$MsgText[0][62];
	
	if ($LoggedIn == 'y') {
		
		ReadPermissions();
		Global $Permissions;
		
		if ($Permissions[7] == 'y') {
	
			ReadFormArguments();
			Global $FormArguments;
			
			if (count($FormArguments) > 0) {
			
			
			DBConnect();
			
			$query = "update `".$Settings['DBPrefix']."core-Settings` set Value='".$FormArguments['ShowBottomLogin']."' where Name='ShowBottomLogin' limit 1";
			$result = mysql_query($query) or die (mysql_error());
			
			$query = "update `".$Settings['DBPrefix']."core-Settings` set Value='".$FormArguments['AllowGuestRegistrations']."' where Name='AllowGuestRegistrations' limit 1";
			$result = mysql_query($query) or die (mysql_error());
			
			$query = "update `".$Settings['DBPrefix']."core-Settings` set Value='".$FormArguments['AllowUsernameChanges']."' where Name='AllowUsernameChanges' limit 1";
			$result = mysql_query($query) or die (mysql_error());
			
			$query = "update `".$Settings['DBPrefix']."core-Settings` set Value='".$FormArguments['ShowProcessingTime']."' where Name='ShowProcessingTime' limit 1";
			$result = mysql_query($query) or die (mysql_error());
			
			$query = "update `".$Settings['DBPrefix']."core-Settings` set Value='".$FormArguments['ShowPoweredBy']."' where Name='spb' limit 1";
			$result = mysql_query($query) or die (mysql_error());
			
			
			
			$query = "update `".$Settings['DBPrefix']."core-Settings` set Value='".$FormArguments['SiteCountry']."' where Name='SiteCountry' limit 1";
			$result = mysql_query($query) or die (mysql_error());
			
			$query = "update `".$Settings['DBPrefix']."core-Settings` set Value='".$FormArguments['SiteName']."' where Name='SiteName' limit 1";
			$result = mysql_query($query) or die (mysql_error());
			
			$query = "update `".$Settings['DBPrefix']."core-Settings` set Value='".$FormArguments['LongSiteName']."' where Name='LongSiteName' limit 1";
			$result = mysql_query($query) or die (mysql_error());
			
			$query = "update `".$Settings['DBPrefix']."core-Settings` set Value='".$FormArguments['AddSiteToTitle']."' where Name='AddSiteToTitle' limit 1";
			$result = mysql_query($query) or die (mysql_error());
			$query = "update `".$Settings['DBPrefix']."core-Settings` set Value='".$FormArguments['AddSiteToTitleSep']."' where Name='AddSiteToTitleSep' limit 1";
			$result = mysql_query($query) or die (mysql_error());
			
			$query = "update `".$Settings['DBPrefix']."core-Settings` set Value='".$FormArguments['ContactEmail']."' where Name='ContactEmail' limit 1";
			$result = mysql_query($query) or die (mysql_error());
			
			$query = "update `".$Settings['DBPrefix']."core-Settings` set Value='".$FormArguments['Copyright']."' where Name='Copyright' limit 1";
			$result = mysql_query($query) or die (mysql_error());
			
			$query = "update `".$Settings['DBPrefix']."core-Settings` set Value='".$FormArguments['Footer']."' where Name='Footer' limit 1";
			$result = mysql_query($query) or die (mysql_error());
			
			
			
				if ($FormArguments['Notify'] == 2 && $FormArguments['NotifyAddress'] != '') {
					$Notify = 'y';
					$NotifyEmail = $FormArguments['NotifyAddress'];
				}
				else if ($FormArguments['Notify'] == 1 || $FormArguments['Notify'] == 2) {
					$Notify = 'y';
					$NotifyEmail = '';
				}
				else {
					$Notify = 'n';
					$NotifyEmail = '';
				}
				
				
				$query = "update `".$Settings['DBPrefix']."core-Settings` set Value='".$Notify."' where Name='Notify' limit 1";
				$result = mysql_query($query) or die (mysql_error());
				$query = "update `".$Settings['DBPrefix']."core-Settings` set Value='".$NotifyEmail."' where Name='NotifyEmail' limit 1";
				$result = mysql_query($query) or die (mysql_error());
			
			
						
			if ($FormArguments['VerifyEmails'] == 'y') {
				$query = "select Value from `".$Settings['DBPrefix']."core-Settings` where Name='VerifyEmails' limit 1";
				$result = mysql_query($query) or die (mysql_error());
				$row = mysql_fetch_array($result);
				
				if ($row['Value'] != 'y') {
					$query = "update `".$Settings['DBPrefix']."core-Users` set Verified='y'";
					$result = mysql_query($query) or die (mysql_error());
				}
			}
			
			$query = "update `".$Settings['DBPrefix']."core-Settings` set Value='".$FormArguments['VerifyEmails']."' where Name='VerifyEmails' limit 1";
			$result = mysql_query($query) or die (mysql_error());
			
			
			$query = "update `".$Settings['DBPrefix']."core-Settings` set Value='".$FormArguments['ShowNavigationLinks']."' where Name='ShowNavigationLinks' limit 1";
			$result = mysql_query($query) or die (mysql_error());
			
			$query = "update `".$Settings['DBPrefix']."core-Settings` set Value='".$FormArguments['MetaDescription']."' where Name='MetaDescription' limit 1";
			$result = mysql_query($query) or die (mysql_error());
			
			$query = "update `".$Settings['DBPrefix']."core-Settings` set Value='".$FormArguments['MetaKeywords']."' where Name='MetaKeywords' limit 1";
			$result = mysql_query($query) or die (mysql_error());
			
			$query = "update `".$Settings['DBPrefix']."core-Settings` set Value='".$FormArguments['DestAfterLogin']."' where Name='DestAfterLogin' limit 1";
			$result = mysql_query($query) or die (mysql_error());
			
			$query = "update `".$Settings['DBPrefix']."core-Settings` set Value='".$FormArguments['DefaultLanguage']."' where Name='DefaultLanguage' limit 1";
			$result = mysql_query($query) or die (mysql_error());
			
			$query = "update `".$Settings['DBPrefix']."core-Settings` set Value='".$FormArguments['UsersPerPage']."' where Name='UsersPerPage' limit 1";
			$result = mysql_query($query) or die (mysql_error());
			
			
			$query = "update `".$Settings['DBPrefix']."core-Settings` set Value='".$FormArguments['CustomLoginCode']."' where Name='CustomLoginCode' limit 1";
			$result = mysql_query($query) or die (mysql_error());
			
			
			$query = "update `".$Settings['DBPrefix']."core-Settings` set Value='".intval($FormArguments['FileManagerMaxFileSize'])."' where Name='FileManagerMaxFileSize' limit 1";
			$result = mysql_query($query) or die (mysql_error());
			
			
			
					
			
			if (substr($FormArguments['BG'],0,1) != '#' && $FormArguments['BG'] != '') { $FormArguments['BG'] = '#'.$FormArguments['BG']; }
			if (substr($FormArguments['Text'],0,1) != '#' && $FormArguments['Text'] != '') { $FormArguments['Text'] = '#'.$FormArguments['Text']; }
			if (substr($FormArguments['Link'],0,1) != '#' && $FormArguments['Link'] != '') { $FormArguments['Link'] = '#'.$FormArguments['Link']; }
			if (substr($FormArguments['VLink'],0,1) != '#' && $FormArguments['VLink'] != '') { $FormArguments['VLink'] = '#'.$FormArguments['VLink']; }
			if (substr($FormArguments['ALink'],0,1) != '#' && $FormArguments['ALink'] != '') { $FormArguments['ALink'] = '#'.$FormArguments['ALink']; }
			if (substr($FormArguments['BBG'],0,1) != '#' && $FormArguments['BBG'] != '') { $FormArguments['BBG'] = '#'.$FormArguments['BBG']; }
			if (substr($FormArguments['BText'],0,1) != '#' && $FormArguments['BText'] != '') { $FormArguments['BText'] = '#'.$FormArguments['BText']; }
			if (substr($FormArguments['BLink'],0,1) != '#' && $FormArguments['BLink'] != '') { $FormArguments['BLink'] = '#'.$FormArguments['BLink']; }
			if (substr($FormArguments['BVLink'],0,1) != '#' && $FormArguments['BVLink'] != '') { $FormArguments['BVLink'] = '#'.$FormArguments['BVLink']; }
			if (substr($FormArguments['BALink'],0,1) != '#' && $FormArguments['BALink'] != '') { $FormArguments['BALink'] = '#'.$FormArguments['BALink']; }
			if (substr($FormArguments['LinkHover'],0,1) != '#' && $FormArguments['LinkHover'] != '') { $FormArguments['LinkHover'] = '#'.$FormArguments['LinkHover']; }
			if (substr($FormArguments['BLinkHover'],0,1) != '#' && $FormArguments['BLinkHover'] != '') { $FormArguments['BLinkHover'] = '#'.$FormArguments['BLinkHover']; }
			
			
			$Overrides = $FormArguments['FontFace'].'%%'.$FormArguments['FontSize'].'%%'.$FormArguments['BG'].'%%'.$FormArguments['Text'].'%%'.$FormArguments['Link'].'%%'.$FormArguments['VLink'].'%%'.$FormArguments['ALink'].'%%'.$FormArguments['BText'].'%%'.$FormArguments['BLink'].'%%'.$FormArguments['BVLink'].'%%'.$FormArguments['BALink'].'%%'.$FormArguments['BBG'].'%%'.$FormArguments['FormStyle'].'%%'.$FormArguments['LinkHover'].'%%'.$FormArguments['BLinkHover'].'%%'.$FormArguments['LinkDecoration'].'%%'.$FormArguments['BLinkDecoration'];
			
			$query = "update `".$Settings['DBPrefix']."core-Settings` set Value='".$Overrides."' where Name='Overrides' 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();
	
	}

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




?>
