<?

/*
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 guestbook prefs
	// ========================================================================================
	
	$PageTitle = $MsgText[6][19];
	$BrowserTitle = $MsgText[6][19];
	$LocationBar = '<a href="'.$IndexURL.'">'.$MsgText[0][1].'</a> > <a href="' . $MainURL . '/options.html">'.$MsgText[0][4].'</a> > '.$MsgText[6][19];
	
	if ($LoggedIn == 'y') {
		
		ReadPermissions();
		Global $Permissions;
		
		if ($Permissions[602] == 'y') {
	
	
			ReadFormArguments();
			Global $FormArguments;
			
			if (count($FormArguments) > 0) {
											
								
				$query = "update `".$Settings['DBPrefix']."gb-Settings` set Value='".intval($FormArguments['EntriesPerPage'])."' where Name='EntriesPerPage' limit 1";
				$result = mysql_query($query) or die (mysql_error());
				
				
				$query = "update `".$Settings['DBPrefix']."gb-Settings` set Value='".$FormArguments['SortDirection']."' where Name='SortDirection' limit 1";
				$result = mysql_query($query) or die (mysql_error());
				
				
				$query = "update `".$Settings['DBPrefix']."gb-Settings` set Value='".$FormArguments['TitleAlignment']."' where Name='TitleAlignment' limit 1";
				$result = mysql_query($query) or die (mysql_error());
				
				
				$query = "update `".$Settings['DBPrefix']."gb-Settings` set Value='".$FormArguments['RequireApproval']."' where Name='RequireApproval' 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']."gb-Settings` set Value='".$Notify."' where Name='Notify' limit 1";
				$result = mysql_query($query) or die (mysql_error());
				$query = "update `".$Settings['DBPrefix']."gb-Settings` set Value='".$NotifyEmail."' where Name='NotifyEmail' limit 1";
				$result = mysql_query($query) or die (mysql_error());
				
				
				
				$query = "select * from `".$Settings['DBPrefix']."gb-Settings` where Name='TitleImage' limit 1";
				$result = mysql_query($query) or die (mysql_error());
				if (mysql_num_rows($result) > 0) {
					$query = "update `".$Settings['DBPrefix']."gb-Settings` set Value='".$FormArguments['TitleImage']."' where Name='TitleImage' limit 1";
					$result = mysql_query($query) or die (mysql_error());
				}
				else {
					$query = "insert into `".$Settings['DBPrefix']."gb-Settings` (Name, Value) values ('TitleImage','".$FormArguments['TitleImage']."')";
					$result = mysql_query($query) or die (mysql_error());
				}
				
				
				$query = "select * from `".$Settings['DBPrefix']."gb-Settings` where Name='PageTitle' limit 1";
				$result = mysql_query($query) or die (mysql_error());
				if (mysql_num_rows($result) > 0) {
					$query = "update `".$Settings['DBPrefix']."gb-Settings` set Value='".$FormArguments['PageTitle']."' where Name='PageTitle' limit 1";
					$result = mysql_query($query) or die (mysql_error());
				}
				else {
					$query = "insert into `".$Settings['DBPrefix']."gb-Settings` (Name, Value) values ('PageTitle','".$FormArguments['PageTitle']."')";
					$result = mysql_query($query) or die (mysql_error());
				}
				
				
				
				$query = "select * from `".$Settings['DBPrefix']."gb-Settings` where Name='TopText' limit 1";
				$result = mysql_query($query) or die (mysql_error());
				if (mysql_num_rows($result) > 0) {
					$query = "update `".$Settings['DBPrefix']."gb-Settings` set Value='".$FormArguments['TopText']."' where Name='TopText' limit 1";
					$result = mysql_query($query) or die (mysql_error());
				}
				else {
					$query = "insert into `".$Settings['DBPrefix']."gb-Settings` (Name, Value) values ('TopText','".$FormArguments['TopText']."')";
					$result = mysql_query($query) or die (mysql_error());
				}
				
				
				$query = "select * from `".$Settings['DBPrefix']."gb-Settings` where Name='TopTextAlignment' limit 1";
				$result = mysql_query($query) or die (mysql_error());
				if (mysql_num_rows($result) > 0) {
					$query = "update `".$Settings['DBPrefix']."gb-Settings` set Value='".$FormArguments['TopTextAlignment']."' where Name='TopTextAlignment' limit 1";
					$result = mysql_query($query) or die (mysql_error());
				}
				else {
					$query = "insert into `".$Settings['DBPrefix']."gb-Settings` (Name, Value) values ('TopTextAlignment','".$FormArguments['TopTextAlignment']."')";
					$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();
	
	}
	
	

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




?>
