<?

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



	// ========================================================================================
	// edit Existing photo
	// ========================================================================================
	
	$PageTitle = '<img src="'.$ImagesURL.'/admin/admincp_photo.gif" width="28" height="22"> '.$MsgText[3][64];
	$BrowserTitle = $MsgText[3][64];
	$LocationBar = '<a href="'.$IndexURL.'">'.$MsgText[0][1].'</a> > <a href="' . $MainURL . '/options.html">'.$MsgText[0][4].'</a> > <a href="'.$MainURL.'/admin/photos.html">'.$MsgText[3][2].'</a> > '.$MsgText[3][64];
	
	if ($LoggedIn == 'y') {
		
		ReadPermissions();
		Global $Permissions;
		
		$Arguments3 = intval($Arguments3);
		
		
		$query55 = "select * from `".$Settings['DBPrefix']."pg-Images` where RecordNumber='".$Arguments3."' limit 1";
		$result55 = mysql_query($query55) or die (mysql_error());
		$row55 = mysql_fetch_array($result55);
		
		$query55 = "select MinLevel,MinEditLevel from `".$Settings['DBPrefix']."pg-Galleries` where RecordNumber='".$row55['GalleryNumber']."' limit 1";
		$result55 = mysql_query($query55) or die (mysql_error());
		$row55 = mysql_fetch_array($result55);
		
		
		if ($Permissions[301] == 'y' && $row55['MinLevel'] <= $UserLevel && $row55['MinEditLevel'] <= $UserLevel) {
		
		
			$query = "select * from `".$Settings['DBPrefix']."pg-Settings`";
			$result = mysql_query($query) or die (mysql_error());
			while ($row = mysql_fetch_array($result)) {
				$pgSettings[$row['Name']] = $row['Value'];
			}
			
			if ($pgSettings['StorageLocationHTTP'] == '') {
				$pgSettings['StorageLocationHTTP'] = $BaseURL.'/pg_images';
			}
			if ($pgSettings['StorageLocationLocal'] == '') {
				$pgSettings['StorageLocationLocal'] = './pg_images';
			}
			
		
	
			$PageContents = '<br>';
			
			DBConnect();
												
			$query55 = "select * from `".$Settings['DBPrefix']."pg-Images` where RecordNumber='".$Arguments3."' limit 1";
			$result55 = mysql_query($query55) or die (mysql_error());
			
			if (mysql_num_rows($result55) > 0) {
				
				$row55 = mysql_fetch_array($result55);
				
				$query = "select * from `".$Settings['DBPrefix']."pg-Galleries` where MinLevel<='".$UserLevel."' ORDER BY GalleryTitle ASC, RecordNumber ASC";
				$result = mysql_query($query) or die (mysql_error());
				while ($row = mysql_fetch_array($result)) {
				
					if ($row['RecordNumber'] == $row55['GalleryNumber']) {
						$GalleriesListPrint .= '<option value="'.$row['RecordNumber'].'" selected> '.$row['GalleryTitle'].'</option>';
					}
					else {
						$GalleriesListPrint .= '<option value="'.$row['RecordNumber'].'"> '.$row['GalleryTitle'].'</option>';
					}
				
				}
				
				
				$Extensions[1] = '.gif';
				$Extensions[2] = '.jpg';
				$Extensions[3] = '.png';
			
				$ThumbExtensions[1] = '-thumb.gif';
				$ThumbExtensions[2] = '-thumb.jpg';
				$ThumbExtensions[3] = '-thumb.png';
			
			
				if (substr($pgSettings['StorageLocationHTTP'],0,1) == '/') {
					$ImageBaseHTTP = $BaseURL.$pgSettings['StorageLocationHTTP'];
				}
				else {
					$ImageBaseHTTP = $pgSettings['StorageLocationHTTP'];
				}
				
				
				if ($row55['PostedBy'] == 0) {
					$HidePosterChecked = ' checked';
				}
				
				
				if (function_exists("gd_info")) {
					$GDInfo = @gd_info();
				}
				if ($GDInfo['GIF Create Support'] == true) {
					$MsgText[3][59] = str_replace('JPEG/PNG','GIF/JPEG/PNG',$MsgText[3][59]);
				}
				
				
				$WindowWidth = ($row55['ImageWidth'] + 150);
				$WindowHeight = ($row55['ImageHeight'] + 200);
				
				$RandomNumber = sprintf("%03d", rand(0,999)) . sprintf("%02d", rand(0,99));
				
				
				$PageContents .= '<script language="Javascript">
		function ViewImage(ImageNumber,Width,Height) {
			var WindowID = window.open("'.$MainURL.'/photos/image/"+ImageNumber+".html","ViewImage","width="+Width+",height="+Height+",toolbars=no");
		}		
		</script><form action="'.$MainURL.'/admin/photos_edit_save" method="post" enctype="multipart/form-data">

				<input type="hidden" name="RecordNumberToEdit" value="'.$row55['RecordNumber'].'">
				<input type="hidden" name="CurrentGallery" value="'.$row55['GalleryNumber'].'">
				<input type="hidden" name="RandomNumber" value="'.$RandomNumber.'">

<table width="500" border="0" cellpadding="3" cellspacing="3">

<tr><td><font face="'.$FontFace.'" size="'.$FontSize.'"><b>'.$MsgText[3][35].':</b></td><td><input type="text" name="Title" size="30" maxlength="255" value="'.str_replace('"','&#'.'34;',$row55['ImageTitle']).'"></td></tr>

<tr><td><font face="'.$FontFace.'" size="'.$FontSize.'"><b>'.$MsgText[3][36].':</b></td><td><textarea name="Description" cols="40" rows="3">'.str_replace('</textarea>','&lt;/textarea>',$row55['ImageDescription']).'</textarea><!-- <br><font face="'.$FontFace.'" size="'.($FontSize-1).'">('.$MsgText[3][37].') --></td></tr>

<tr><td><font face="'.$FontFace.'" size="'.$FontSize.'"><b>'.$MsgText[3][55].':</b></td><td>
<select name="Gallery">'.$GalleriesListPrint.'</select></td></tr>

<tr><td><font face="'.$FontFace.'" size="'.$FontSize.'"><b>'.$MsgText[3][65].':</b></td><td><a href="javascript:ViewImage('.$row55['RecordNumber'].','.$WindowWidth.','.$WindowHeight.');"><img src="'.$ImageBaseHTTP.'/'.$row55['FileName'].$ThumbExtensions[$row55['FileType']].'" alt="'.$row55['ImageTitle'].'" border="0"></a></td></tr>

<tr><td valign="top"><font face="'.$FontFace.'" size="'.$FontSize.'"><b>'.$MsgText[3][66].':</b></td><td><input type="file" name="FileData"><br><font face="'.$FontFace.'" size="'.($FontSize-1).'">('.$MsgText[3][59].' '.number_format($pgSettings['MaxFileSize'],0,'','').' KBytes)</td></tr>

<!-- <tr><td><font face="'.$FontFace.'" size="'.$FontSize.'"><b>'.$MsgText[3][60].':</b></td><td><font face="'.$FontFace.'" size="'.$FontSize.'"><input type="checkbox" name="HidePoster" value="y"'.$HidePosterChecked.'> '.$MsgText[0][118].'</td></tr> -->

</table>

<br><b>'.$MsgText[0][156].':</b>&nbsp;<input type="checkbox" name="Delete" value="y"><br><br>

<br><br>
<input name="SubmitButton" type="submit" value="'.$MsgText[0][123].'"></form>';
				
		
			}
			else {
				$PageContents .= '<br>['.$MsgText[3][63].']<br>';
			}
	
				
	
	
		}
		else {
		
			$PageContents = $MsgText[0][97];
		
		}

	}
	else {
	
		RedirectToLogin();
	
	}
	

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




?>
