Location: PHPKode > projects > BBCode Advanced > bbcode-advanced/images.php
<?php

#########################################################
#	GiveMeEnergy Projects								#
#	Engine by []==ThoRĀ®	for More Interactive			#
#	Contact:											#
#	hide@address.com									#
#	hide@address.com										#
#	More Interactive - www.more.it						#
#														#
#	See	More Projects WebSite for updates & patches		#
#	http://projects.moreinteractive.net/				#
#														#
#########################################################

/***************************************\
|		CHANGE PATHS HERE				|
\***************************************/
define("_IMGPATH","img");

include("lib/class.uploadFile.php");
include("lib/class.fileInfo.php");
include("lib/class.flashParser.php");
include("lib/class.manageText.php");

$op	= "";
unset($op);
$op	= (isset($_REQUEST['op']))	? $_REQUEST['op'] : "";

$baseUrl	= "images.php?zz=bbCode";

Function index()	{
	global $baseUrl;

	$notShowEm	= Array(".","..","index.htm","CVS");
	$msg		= (isset($_REQUEST['msg']) && $_REQUEST['msg'] != "")	? urlDecode($_REQUEST['msg']) : "";
	$listImg	= "";
	$thePath	= _IMGPATH."/img";
	$upping		= new Upload;
	$upping->set_directory($thePath);
	if ($handle = opendir($thePath)) {
		while (false !== ($file = readdir($handle))) {
			if (!in_array($file,$notShowEm) && StriStr($file,"".IMAGE_PREFIX_THUMB."") == "") {
				$copyClip	= "[img]".$thePath."/".$file."[/img]";
				$fileInfo	= new File_Info($thePath."/".$file);
				$fMime		= $fileInfo->getMime();
				$fSize		= $fileInfo->getSize(FILE_INFO_SIZE_KB)."KB";
				$dimension	= GetImageSize($thePath."/".$file);
				$listImg	.= "<tr>
									<td bgcolor=\"#DADADA\" class=\"withPadding3\" valign=\"top\"><img src=\"".$thePath."/_thumb_".$file."\" alt=\"".$file."\"></td> 
									<td bgcolor=\"#DADADA\" class=\"withPadding3\" valign=\"top\" width=250>
									<strong>".$file."</strong><br>
									Risoluzione: ".$dimension[0]."x".$dimension[1]."<br>
									Tipo: ".$fMime."<br>
									Dimensione: ".$fSize."<br>
									</td> 
									<td bgcolor=\"#DADADA\" class=\"withPadding3\" valign=\"top\" width=80>
									<a href=\"".$baseUrl."&amp;op=del&amp;file=".$file."\" onClick=\"return(confirm('Are you sure you want to delete this image?'))\"><img src=\"/"._IMGPATHCOMMON."/button_drop.png\" alt=\"delete\" border=0></a> 
									<a href=\"javascript:copy_clip('".$copyClip."')\"><img src=\"/"._IMGPATHCOMMON."/button_copy.png\" alt=\"copy to clipboard\" border=0></a>
									</td>
								</tr>";
			}
		}
	closedir($handle);
	}

	return $listImg;
}

Function upping()	{
	global $baseUrl;

	$msg	= "nessuna immagine caricata";
	$thePostedPhoto	= $_FILES;
	//foreach ($thePostedPhoto as $keyFile=>$file)	{
	//	echo $keyFile." => ".$file."<br>";
	//}
	//die();
	foreach ($thePostedPhoto as $keyFile=>$file)	{
		If (	($file['name'] != "none") && ($file['size'] > 0)	)	{
			$thePath	= _IMGPATH."/img";
			$upping		= new Upload;
			//	these are standard from form			//
			$upping->set_tmp_name($file['tmp_name']);
			$upping->set_file_size($file['size']);
			$upping->set_file_type($file['type']);
			//	max size								//
			$upping->set_max_size(2000000000);
			$upping->set_directory($thePath);

			//	A few replaces to filename				//
			$filename	= Str_Replace(" ","_",$file['name']);
			$filename	= Str_Replace("/","_",$filename);
			$filename	= Str_Replace("\\","_",$filename);

			$upping->set_file_name($filename);
			$upping->start_copy();
			$imageInfo 	= @GetImageSize($thePath."/".$filename);
			/*
			if ($imageInfo[0] > 600 || $imageInfo[1] > 600)	{
				if ($imageInfo[0] > $imageInfo[1])	{
					$upping->resize(300,"");
				} else {
					$upping->resize("",300);
				}
				if ($imageInfo[0] == $imageInfo[1])	{
					$upping->resize(300,300);
				}
			}
			*/
			if($upping->is_ok())	{
				$msg	= "All OK";
				$upping->set_thumbnail_name("".IMAGE_PREFIX_THUMB."".$filename);
				$upping->create_thumbnail();
				if ($imageInfo[0] > IMAGE_MAXWIDTH_THUMB || $imageInfo[1] > IMAGE_MAXHEIGHT_THUMB)	{
					if ($imageInfo[0] > $imageInfo[1])	{
						$upping->set_thumbnail_size(IMAGE_MAXWIDTH_THUMB,"");
					} else {
						$upping->set_thumbnail_size("",IMAGE_MAXHEIGHT_THUMB);
					}
					if ($imageInfo[0] == $imageInfo[1])	{
						$upping->set_thumbnail_size(IMAGE_MAXWIDTH_THUMB,IMAGE_MAXHEIGHT_THUMB);
					}
				}
			} else {
				$msg	= "ERROR: ".$upping->error()."";
			}
		}			#	=>	End if file is not none and size > 0
	}				#	=>	End foreach
	echo "<script>location.href = '".$baseUrl."&amp;msg=".urlEncode($msg)."'</script>";
}

Function del()	{
	global $baseUrl;

	$file	= (isset($_REQUEST['file']) && $_REQUEST['file'] != "")	? ManageString::StripString(Trim($_REQUEST['file'])) : "";
	$file	= Str_Replace("/","_",$file);
	$thePath	= _IMGPATH."/img";
	if ($file != "")	{
		@unlink($thePath."/".$file);
		//@unlink($thePath."/".IMAGE_PREFIX_THUMB."".$file);
		$msg	= "File deleted";
		echo "<script>location.href = '".$baseUrl."&amp;msg=".urlEncode($msg)."'</script>";
	}
}

switch ($op)	{

	default:
	case "":
		$listImg	= index();
	break;

	case "upping":
		upping();
	break;

	case "del":
		del();
	break;

}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
	<title>BBCode Test</title>
	<link href="css/style.css" rel="stylesheet" type="text/css"> 
	<script language="JavaScript" type="text/javascript" src="js/func.js"></script>
	<script language="JavaScript" type="text/javascript" src="js/popcenter.js"></script>
	<script language="JavaScript" type="text/javascript" src="js/detectPlugins.js"></script>
</head>

<body>
<table border="0" cellpadding=1 cellspacing=1 width="98%" align="center" bgcolor="#CCCCCC">
	<tr>
		<td bgcolor="#DADADA" class="bbCode20">TESTING UPLOAD</td>
	</tr>
</table>
<form action="images.php" method="post" name="f1" enctype="multipart/form-data"><input type="hidden" name="op" value="upping">
<table border="0" cellpadding=1 cellspacing=1 width="98%" align="center" bgcolor="#CCCCCC">
	<tr>
		<td bgcolor="#DADADA"><strong>Prove Upload</strong></td>
	</tr>
	<tr>
		<td bgcolor="#EAEAEA"><input type="file" name="foto1" size="40"></td>
	</tr>
	<tr>
		<td bgcolor="#EAEAEA"><input type="file" name="foto2" size="40"></td>
	</tr>
	<tr>
		<td bgcolor="#EAEAEA"><input type="file" name="foto3" size="40"></td>
	</tr>
	<tr>
		<td bgcolor="#EAEAEA"><input type="file" name="foto4" size="40"></td>
	</tr>
	<tr>
		<td bgcolor="#EAEAEA">&nbsp;</td>
	</tr>
	<tr>
		<td bgcolor="#EAEAEA"><input type="submit" name="go" value=" carica "></td>
	</tr>
</table><br>
</form>
<table border="0" cellpadding=1 cellspacing=1 width="98%" align="center" bgcolor="#CCCCCC">
	<?php echo $listImg; ?>
</table><br>
</body>
</html>
Return current item: BBCode Advanced