<?

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



	// ========================================================================================
	// images administration
	// ========================================================================================
	
	$PageTitle = '<img src="'.$ImagesURL.'/admin/admincp_content.gif" width="23" height="20"> '.$MsgText[0][302];
	$BrowserTitle = $MsgText[0][302];
	$LocationBar = '<a href="'.$IndexURL.'">'.$MsgText[0][1].'</a> > <a href="'.$MainURL.'/options.html">'.$MsgText[0][4].'</a> > '.$MsgText[0][302];
	
	if ($LoggedIn == 'y') {
		
		ReadPermissions();
		Global $Permissions;
		
		if ($Permissions[17] == 'y') {
		
			
			$PageContents = '<a href="#upload">'.$MsgText[0][303].'</a><br><br>';
			
			
		
			$dir = './images/uploaded/';
		
			$TypeDescriptions[1] = 'GIF';
			$TypeDescriptions[2] = 'JPEG';
			$TypeDescriptions[3] = 'PNG';
		
		
			if (is_dir($dir)) {
				if ($dh = opendir($dir)) {
		   			while (($file = readdir($dh)) !== false) {
						if (filetype($dir . $file) == 'file') {
							list($ImageWidth, $ImageHeight, $FileType, $FileAttributes) = getimagesize($dir . $file);
							
							if ($FileType == 1 || $FileType == 2 || $FileType == 3) {
																							
								$FileInformation = stat($dir . $file);
								
								// eliminate files created by the installation package
								if ($FileInformation[9] > 1087320000) {
								
									$NamesArray[] = $file;
									$TypesArray[$file] = $FileType;
									$ModifiedTimes[$file] = $FileInformation[9];
									$FileSizes[$file] = $FileInformation[7];
									
								}	
								
								
							}
						}
					}
				}
				closedir($dh);
			}
		
			
			
			
			// sort by name
			for ($g = 0; $g < count($NamesArray); $g++) {
				for ($h = 0; $h < count($NamesArray)-1; $h++) {
			
					if (strtolower($NamesArray[$h]) > strtolower($NamesArray[$h+1])) {
														
						$Swap1 = $NamesArray[$h+1];
																
						$NamesArray[$h+1] = $NamesArray[$h];
																
						$NamesArray[$h] = $Swap1;
																		
					}
									
				}
			}
			
			
			$PageContents .= '<br><table border="0" cellpadding="2" cellspacing="0"><tr>
			      <td><font face="'.$FontFace.'" size="'.$FontSize.'"><b>'.$MsgText[0][304].'</b> ('.$MsgText[0][305].')&nbsp;&nbsp;</td>
			      <td align="center"><font face="'.$FontFace.'" size="'.$FontSize.'">&nbsp;&nbsp;<b>'.$MsgText[0][306].'</b>&nbsp;&nbsp;</td>
			      <td align="right"><font face="'.$FontFace.'" size="'.$FontSize.'">&nbsp;&nbsp;<b>'.$MsgText[0][307].'</b>&nbsp;&nbsp;</td>
			      <td align="center"><font face="'.$FontFace.'" size="'.$FontSize.'">&nbsp;&nbsp;<b>'.$MsgText[0][308].'</b>&nbsp;&nbsp;</td>
				  <td><font face="'.$FontFace.'" size="'.$FontSize.'">&nbsp;&nbsp;&nbsp;<b>'.$MsgText[0][309].'</b></td>
			    </tr>';

			
			for ($g = 0; $g < count($NamesArray); $g++) {
			
			
				//$Ending = 'Bytes';
				//if ($FileSizes[$NamesArray[$g]] >= 1024) {
				//	$FileSizes[$NamesArray[$g]] = ($FileSizes[$NamesArray[$g]]/1024);
				//	$Ending = 'KBytes';
				//}
				//if ($FileSizes[$NamesArray[$g]] >= 1024) {
				//	$FileSizes[$NamesArray[$g]] = ($FileSizes[$NamesArray[$g]]/1024);
				//	$Ending = 'MBytes';
				//}
				//$FileSizePrint = number_format($FileSizes[$NamesArray[$g]],0).' '.$Ending;
				$FileSizePrint = number_format($FileSizes[$NamesArray[$g]],0);
								
				$ModifiedPrint = date ("M j, Y",$ModifiedTimes[$NamesArray[$g]]).', '.date("g:i A",$ModifiedTimes[$NamesArray[$g]]);
				
			
				$PageContents .= '<tr>
			      <td><font face="'.$FontFace.'" size="'.$FontSize.'"><a href="'.$BaseURL.'/images/uploaded/'.$NamesArray[$g].'" target="_blank">'.$NamesArray[$g].'</a>&nbsp;&nbsp;</td>
			      <td align="center"><font face="'.$FontFace.'" size="'.$FontSize.'">&nbsp;&nbsp;'.$TypeDescriptions[$TypesArray[$NamesArray[$g]]].'&nbsp;&nbsp;</td>
			      <td align="right"><font face="'.$FontFace.'" size="'.$FontSize.'">&nbsp;&nbsp;'.$FileSizePrint.'&nbsp;&nbsp;</td>
			      <td align="center"><font face="'.$FontFace.'" size="'.$FontSize.'">&nbsp;&nbsp;'.$ModifiedPrint.'&nbsp;&nbsp;</td>
				  <td><font face="'.$FontFace.'" size="'.$FontSize.'">&nbsp;&nbsp;&nbsp;<a href="'.$MainURL.'/admin/images_delete/'.$NamesArray[$g].'">'.$MsgText[0][156].'</a></td>
			    </tr>';
				
							
			}
			
			
			$PageContents .= '</table>';
			
			
			
			if (function_exists("gd_info")) {
				$GDInfo = @gd_info();
			}
			if ($GDInfo['GIF Create Support'] == true) {
				$MsgText[0][314] = $MsgText[0][537];
			}
			else {
				$JPEGPNGOnly = '<br>('.$MsgText[0][313].')';
			}
			
			
			$PageContents .= '<br><br><br><a name="upload"></a><b>'.$MsgText[0][303].':</b><br><br><form name="ImageForm" action="'.$MainURL.'/admin/images_upload" method="post" enctype="multipart/form-data">

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

<tr><td><font face="'.$FontFace.'" size="'.$FontSize.'"><b>'.$MsgText[0][310].':</b></td><td><input type="file" name="FileData"><br><font face="'.$FontFace.'" size="'.($FontSize-1).'">('.$MsgText[0][311].': '.number_format($Settings['MaxImageFileSize'],0,'','').' KBytes)</td></tr>

<tr><td><font face="'.$FontFace.'" size="'.$FontSize.'"><b>'.$MsgText[0][312].':'.$JPEGPNGOnly.'</b></td><td><font face="'.$FontFace.'" size="'.$FontSize.'">	<input type="radio" name="ImageResize" value="None" checked> '.$MsgText[0][314].'<br>
	<input type="radio" name="ImageResize" value="ResizeDimensions"> '.$MsgText[0][315].' <input type="text" name="ResizeMaxWidth" size="3"> '.$MsgText[0][316].' <input type="text" name="ResizeMaxHeight" size="3"> ('.$MsgText[0][317].')<br>
	<input type="radio" name="ImageResize" value="ScalePercent"> '.$MsgText[0][318].' <input type="text" name="ResizePercent" size="3">%<br>
</td></tr>

<tr><td><font face="'.$FontFace.'" size="'.$FontSize.'"><b>'.$MsgText[0][319].':</b></td><td><font face="'.$FontFace.'" size="'.$FontSize.'">	<input type="radio" name="NewName" value="Previous" checked> '.$MsgText[0][320].'<br>
	<input type="radio" name="NewName" value="Random"> '.$MsgText[0][321].'<br>
	<input type="radio" name="NewName" value="Enter"> '.$MsgText[0][322].': <input type="text" name="NewNameEnter" size="30"><br>
</td></tr>

<tr><td colspan="2"><font face="'.$FontFace.'" size="'.$FontSize.'"><b>'.$MsgText[0][323].'</b></td></tr>
</table><br><br><input type="hidden" name="MAX_FILE_SIZE" value="'.number_format(($Settings['MaxImageFileSize']*1024),0,'','').'"><input name="SubmitButton" type="submit" value="'.$MsgText[0][324].'"></form>';
			
			
				
		
		} // end if permissions are sufficient
		else {
		
			$PageContents = $MsgText[0][97];
		
		}

	}
	else {
	
		RedirectToLogin();
	
	}

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




?>
