<?

/*
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 changes to existing
	// ========================================================================================
	
	
	$query = "select * from `".$Settings['DBPrefix']."lm-Settings`";
	$result = mysql_query($query) or die (mysql_error());
	while ($row = mysql_fetch_array($result)) {
		$lmSettings[$row['Name']] = $row['Value'];
	}
	
	
	$PageTitle = '<img src="'.$ImagesURL.'/admin/admincp_links.gif" width="20" height="21"> '.$MsgText[8][24];
	$BrowserTitle = $MsgText[8][24];
	$LocationBar = '<a href="'.$IndexURL.'">'.$MsgText[0][1].'</a> > <a href="' . $MainURL . '/options.html">'.$MsgText[0][4].'</a> > <a href="'.$MainURL.'/admin/links.html">'.$MsgText[8][2].'</a> > '.$MsgText[8][24];
	
	if ($LoggedIn == 'y') {
		
		ReadPermissions();
		Global $Permissions;
		
		if ($Permissions[801] == 'y') {
		
			ReadFormArguments();
			Global $FormArguments;
			
			$FormArguments['LinkIDToEdit'] = intval($FormArguments['LinkIDToEdit']);
			
			if (count($FormArguments) > 0 && $FormArguments['LinkIDToEdit'] > 0) {
			
				if ($FormArguments['DeleteLink'] == 'y') {
				
					$query = "delete from `".$Settings['DBPrefix']."lm-Links` where RecordNumber='".$FormArguments['LinkIDToEdit']."' limit 1";
					$result = mysql_query($query) or die (mysql_error());
										
					Header('Location: '.$MainURL.'/admin/links.html');
				
				}
				else {
			
					if ($FormArguments['Title'] != '' && $FormArguments['Link'] != '') {
			
						$query = "update `".$Settings['DBPrefix']."lm-Links` set Title='".$FormArguments['Title']."', Description='".$FormArguments['Description']."', Link='".$FormArguments['Link']."', ClicksCount='".intval($FormArguments['StartingCount'])."', Category='".$FormArguments['Category']."', Category2='".$FormArguments['Category2']."', Category3='".$FormArguments['Category3']."', Category4='".$FormArguments['Category4']."', Category5='".$FormArguments['Category5']."', Category6='".$FormArguments['Category6']."', Category7='".$FormArguments['Category7']."', Category8='".$FormArguments['Category8']."', Category9='".$FormArguments['Category9']."', Category10='".$FormArguments['Category10']."' where RecordNumber='".$FormArguments['LinkIDToEdit']."' limit 1";
						$result = mysql_query($query) or die (mysql_error());
					
						
						Header('Location: '.$MainURL.'/admin/links.html');
						
					}
					else {
					
						$PageContents = $MsgText[8][27];
				
					}
						
				}				

			}
			else {
				$PageContents = $MsgText[0][98];
			}
		
		} // end if permissions are sufficient
		else {
		
			$PageContents = $MsgText[0][97];
		
		}

	}
	else {
	
		RedirectToLogin();
	
	}
				
	
	// ========================================================================================




?>
