Merhaba Arkadaşlar

Dosya Upload - Bilgi Upload Deponuz

adında bir dosya upload scripti kurdum. Herşey tamam dosyaları yüklüyebiliyorum linkleri de alabiliyorurm. Fakat yüklenen dosyalar anadizine kaydediliyor. Benim istediği ise anadizin değil d ebir alt klasöre kaydedilmesini istiyorum. Ayarların yapıldığı dosyayı aşağıda size veriyorum. Acaba anadizine değilde alt klasöre yüklemek için ne yapmamız gerekiyor.

Şimdiden ilginiz için teşekkürler

<?php
#####################################################################
# DODOUPLOAD VERSION 1.3											#
# Written in PHP													#
# Released on March 03, 2005 under linkware							#
# Created by Dodo http://pure-essence.net/							#
# Distributed through http://regretless.com/scripts/				#
# Please link either site if you use this script.					#
# You may not redistribute this file without my written permission.	#
# Feel free to modify this file to your need.						#
# Please contact me http://pure-essence.net/domain/contact.php		#
# if you wish to redistribute a modifed version of my script!		#
#																	#
# ENJOY THE SCRIPT!													#
#####################################################################


########### REQUIRED EDITS ########################################
$require_login = 1;		// set it to 0, no login will be required
// define below if $require_login is 1
$user = "demo";
$pass = "test";

########### OPTIONAL EDITS ########################################
$numpage = 8; // number of files listed per page
$MAX_FILE_SIZE = "15000"; // in bytes!!
$date_format = "m/d/Y g:i a"; // visit php.net/date for more info

$bgcolor_alt_array[] = "#0088BB"; // first table row bg color
$bgcolor_alt_array[] = "#0077BB"; // second table row bg color
// you can add more if you want
//$bgcolor_alt_array[] = ""; // third table row bg color

$textcolor_alt_array[] = "#FFFFFF"; // first table row text color
$textcolor_alt_array[] = "#FFFFFF"; // second table row text color
// you can add more if you want
//$textcolor_alt_array[] = ""; // third table row text color

// upload files to where your index.php is
$userpath = $_SERVER['DOCUMENT_ROOT'].dirname($_SERVER['PHP_SELF']);
// or you may define your own
//$userpath = "/home/yourusername/www/tmp/upload/img";
// upload files to where your index.php is
$httppath = "http://".$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']);
// or you may define your own
//$httppath = "http://dinlemix.com/11/3/tmp/upload/img";

// if uploaded file is an image, require a certain image dimension?
$dim_requirement = null;
//$dim_requirement = array(100, 70); // this means width no bigger than 100 pixels,
									// height no bigger than 70 pixels
$require_exact_dim = 0; // make it to 1 to require the exact dim above
$require_file_type = null;	// enter the require file type if necessary
							// i.e. $require_file_type = "images/gif";
							// require all uploaded files to be only gif files
$filename_limit = 0; // set this to a number if you wish to limit the number of
						// characters in the file name the user uploads

$ignore_files = array(
'index.php',
'header.php',
'footer.php',
'readme.txt',
'error_log',			// feel free to add to the list
);


















###################################### DO NOT EDIT ############################################

header("Cache-Control: no-cache");
// Emular register_globals on
if (!ini_get('register_globals')) {
	$superglobales = array($_SERVER, $_ENV, $_FILES, $_COOKIE, $_POST, $_GET);
	if (isset($_SESSION)) {
		array_unshift($superglobales, $_SESSION);
	}
	foreach ($superglobales as $superglobal) {
		extract($superglobal, EXTR_SKIP);
	}
}
if($require_login == 1) {
	if($do == "logout") {
		setcookie('dodoupload_user', "");
		setcookie('dodoupload_pass', "");
		header("Location: ".$_SERVER['PHP_SELF']);
	} 
	// is cookie set correctly?
	if($_COOKIE['dodoupload_user'] == $user && $_COOKIE['dodoupload_pass'] == md5($pass)) {
		define("DODOUPLOADOK", 1);
	} else {
		if(empty($do)) {
			include_once("header.php");
			load_login_form();
		} else if($do == "login") {
			if($_POST['username'] != $user || $_POST['password'] != $pass) {
				include_once("header.php");
				print_error("Error", "Invalid username and/or password.");
			} else {
				setcookie('dodoupload_user', $user);
				setcookie('dodoupload_pass', md5($pass), time()+31536000);
				define("DODOUPLOADOK", 1);
			}
		}
	}
} else {
	define("DODOUPLOADOK", 1);
} // end






include_once("header.php");
// load main switch if constant pass is defined
if(defined("DODOUPLOADOK")) {
	switch($action) {
		case "uploadmulti_upload":
		case "upload":
			$uploaded_files = handle_uploaded_files("userfile");
			if(empty($uploaded_files)) {
				print_error("Error", "You didn't upload any file(s).");
			} else {
				$error = uploadfiles_error_checking($uploaded_files, $userpath, $MAX_FILE_SIZE, $dim_requirement, $require_exact_dim, $filename_limit, $require_file_type);
				if($error !== true)
					print_error("Error", $error);
				else {
					$output = upload_files($uploaded_files, $userpath);
					print_error("Success", "Following file(s) have been uploaded.<br /><br />".$output, "Back Home", $_SERVER['PHP_SELF']);
					display_upload_form();
				}

			}
			break;
		case "uploadmulti":
			if($number <= 0)
				$number = 5;
			upload_multi_form($number);
			break;
		case "edit":
			if($delete == null) {
				print_error("Error", "You have not selected any files to delete.", "Back Home", $_SERVER['PHP_SELF']);
			} else {
				if(!$confirm) {
					echo "<h1>Delete Confirmation</h1><br />";
					echo "<form method=post action=\"$_SERVER[PHP_SELF]\">\n<input type=hidden name=action value=edit>\n";
					echo "<div class=\"othertext\">Are you sure you want to delete the following file(s)?<br />\n";
					echo "<ul>\n";
					foreach($delete as $doll) {
						echo "<li><a href=\"$doll\" target=\"_blank\">$doll</a></li>\n";
						echo "<input name=\"delete[]\" value=\"$doll\" type=\"hidden\" />\n";
					}
					echo "</ul>\n";
					echo "</div><input type=\"submit\" name=\"confirm\" value=\"Yes, I'm sure!\" class=\"bottombutton\" />\n";
					echo "</form>";
				} else {
					getrid($delete);
				}
			}
			break;
		default:
			if(!in_array($sortby, array('name', 'size', 'time'))) {
				$sortby = "name";
			}
			if(!in_array($way, array('ASC', 'DESC'))) {
				$way = "ASC";
			}
			$all_files = file_reading($userpath);
			display_upload_form();
			echo "<br />\n";
			echo "<br />\n";

			if(!$thispage)
				$thispage = 1;

			// getting the number of total entries
			$totalentries = count($all_files);

			$total_pages = ceil($totalentries/$numpage);

			
			$page_string = "<div class=\"othertext\">[ ";
			$page_symbol = ($_SERVER['PHP_SELF'] == $_SERVER['REQUEST_URI']) ? "?" : "&";
			$page_symbol2 = ($page_symbol == "?") ? "\?" : $page_symbol;

			$page_string .= $pagelink = page_links($thispage, $total_pages, $_SERVER[PHP_SELF]."?sortby=$sortby&way=$way&thispage=%d");
			$page_string .= " ]\n";
			
			if($thispage != "showall") {
				$page_string .= " [ <a href=\"$_SERVER[PHP_SELF]?sortby=$sortby&way=$way&thispage=showall\">Show All</a> ]";
			} else {
				$page_string .= " [ Show All ]";
			}
			$page_string .= "</div>"; 
			############ displaying #####################

			
			if($total_pages > 1) echo $page_string."<br />";
			displaypages($thispage, $numpage, $all_files);
			if($total_pages > 1) echo "<br />".$page_string;
			
			break;
	} // end of switch
}
dodo_rules();
include("footer.php");

function file_reading($userpath) {
	global $ignore_files, $sortby, $way;
	$handle = opendir($userpath);
	
	// This while loop is used to sort the array
	while ($file = readdir($handle)) 
	{
		if($file != '.' && $file != '..' && $file != $_SERVER['PHP_SELF'] && (is_array($ignore_files) && !in_array($file, $ignore_files)) && !is_dir($file))
		{
			$dolls[] = $file; // then add it to the array
			$dolls_filesize[] = filesize($userpath."/".$file);
			$dolls_updatetime[] = filemtime($userpath."/".$file);
		}
	}
	if($dolls != null) {
		$dolls = sort_correctly($dolls, $dolls_filesize, $dolls_updatetime);
	}

	closedir($handle);
	return $dolls;
}




function sort_correctly($dolls, $dolls_filesize, $dolls_updatetime) {
	global $sortby, $way;
	if($sortby == "name") {
		if($way == "ASC") {
			
			sort($dolls);
			reset($dolls);
		} else {
			rsort($dolls);
			reset($dolls);
		}
	} elseif($sortby == "size") {
		if($way == "ASC") {
			asort($dolls_filesize);
			reset($dolls_filesize);
			$right_keys = array_keys($dolls_filesize);
		} else {
			arsort($dolls_filesize);
			reset($dolls_filesize);
			$right_keys = array_keys($dolls_filesize);
		}
	} elseif($sortby == "update") {
		if($way == "ASC") {
			asort($dolls_updatetime);
			reset($dolls_updatetime);
			$right_keys = array_keys($dolls_updatetime);
		} else {
			arsort($dolls_updatetime);
			reset($dolls_updatetime);
			$right_keys = array_keys($dolls_updatetime);
		}
	}

	if($right_keys != null) {
		$new_dolls = array();
		foreach($right_keys as $thekey) {
			$new_dolls[] = $dolls[$thekey];
		}
		$dolls = array();
		$dolls = $new_dolls;
	}
	return $dolls;
}


function displaypages($thispage, $numpage, $dolls) {
	global $bgcolor_alt_array, $textcolor_alt_array, $date_format, $sortby, $way, $userpath, $httppath;

	$size_sort_text_link = "Size(kb)";
	$time_sort_text_link = "Last updated";
	$name_sort_text_link = "Files";

	if($sortby == "name") {
		if($way == "ASC") {
			$name_sort_link = "<a href=\"$_SERVER[PHP_SELF]?thispage=$thispage&sortby=$sortby&way=DESC\" title=\"Sort by Name Descendingly!\" ><img src=\"images/desc_order.gif\" width=\"11\" height=\"10\" border=\"0\" alt=\"Sort by Name Descendingly!\" /></a>";
		} else {
			$name_sort_link = "<a href=\"$_SERVER[PHP_SELF]?thispage=$thispage&sortby=$sortby&way=ASC\" title=\"Sort by Name Ascendingly!\" ><img src=\"images/asc_order.gif\" width=\"11\" height=\"10\" border=\"0\" alt=\"Sort by Name Ascendingly!\" /></a>";
		}
		$size_sort_text_link = "<a href=\"$_SERVER[PHP_SELF]?thispage=$thispage&sortby=size&way=ASC\" title=\"Sort by Size Ascendingly!\">Size(kb)</a>";
		$time_sort_text_link = "<a href=\"$_SERVER[PHP_SELF]?thispage=$thispage&sortby=time&way=ASC\" title=\"Sort by Last Update Time Ascendingly!\">Last updated</a>";
	} elseif($sortby == "size") {
		if($way == "ASC") {
			$size_sort_link = "<a href=\"$_SERVER[PHP_SELF]?thispage=$thispage&sortby=$sortby&way=DESC\" title=\"Sort by Size Descendingly!\" ><img src=\"images/desc_order.gif\" width=\"11\" height=\"10\" border=\"0\" alt=\"Sort by Size Descendingly!\" /></a>";
		} else {
			$size_sort_link = "<a href=\"$_SERVER[PHP_SELF]?thispage=$thispage&sortby=$sortby&way=ASC\" title=\"Sort by Size Ascendingly!\" ><img src=\"images/asc_order.gif\" width=\"11\" height=\"10\" border=\"0\" alt=\"Sort by Size Ascendingly!\" /></a>";
		}
		$name_sort_text_link = "<a href=\"$_SERVER[PHP_SELF]?thispage=$thispage&sortby=name&way=ASC\" title=\"Sort by Name Ascendingly!\">Files</a>";
		$time_sort_text_link = "<a href=\"$_SERVER[PHP_SELF]?thispage=$thispage&sortby=time&way=ASC\" title=\"Sort by Last Update Time Ascendingly!\">Last updated</a>";
	} elseif($sortby == "time") {
		if($way == "ASC") {
			$time_sort_link = "<a href=\"$_SERVER[PHP_SELF]?thispage=$thispage&sortby=$sortby&way=DESC\" title=\"Sort by Last Update Time Descendingly!\" ><img src=\"images/desc_order.gif\" width=\"11\" height=\"10\" border=\"0\" alt=\"Sort by Last Update Time Descendingly!\" /></a>";
		} else {
			$time_sort_link = "<a href=\"$_SERVER[PHP_SELF]?thispage=$thispage&sortby=$sortby&way=ASC\" title=\"Sort by Last Update Time Ascendingly!\" ><img src=\"images/asc_order.gif\" width=\"11\" height=\"10\" border=\"0\" alt=\"Sort by Last Update Time Ascendingly!\" /></a>";
		}
		$name_sort_text_link = "<a href=\"$_SERVER[PHP_SELF]?thispage=$thispage&sortby=name&way=ASC\" title=\"Sort by Name Ascendingly!\">Files</a>";
		$size_sort_text_link = "<a href=\"$_SERVER[PHP_SELF]?thispage=$thispage&sortby=size&way=ASC\" title=\"Sort by Size Ascendingly!\">Size(kb)</a>";
	}


	echo "<form method=post action=\"$_SERVER[PHP_SELF]\">\n<input type=hidden name=action value=edit>\n";
	echo "<table width=\"500\" cellpadding=\"5\" cellspacing=\"1\" border=\"0\" align=\"center\" class=\"table\"  id=\"ID1\">";
	echo "<tr><td width=\"5%\" class=\"tableheader\"></td>\n";
	echo "<td align=\"center\" width=\"25%\" class=\"tableheader formtext\">$name_sort_text_link $name_sort_link</td>\n";
	echo "<td align=\"center\" width=\"20%\" class=\"tableheader formtext\">$size_sort_text_link $size_sort_link</td>\n";
	echo "<td align=\"center\" width=\"45%\" class=\"tableheader formtext\">$time_sort_text_link $time_sort_link</td>\n";
	echo "<td align=\"center\" width=\"5%\" class=\"tableheader\"><input type=checkbox value=\"CheckAll\" onClick=\"doCheckAll('ID1')\" id=\"CID1\" name=\"CID1\"></td></tr>\n";


	if($thispage == "showall") {
		for ($entry = 0; $entry < count($dolls); $entry++) {

			// if the array element is empty, break out of the for loop
			if($dolls[$entry] == "")
				break;
			$colornum++;

			$total_colors = count($bgcolor_alt_array);
			// the bgcolor is figured out by the remainder of
			// the row number divide by the total number of colors

			$remainder = $entry % $total_colors;

			// whatever the value is
			$bgcolor = $bgcolor_alt_array[$remainder];
			$textcolor = $textcolor_alt_array[$remainder];

			$index = $entry+1;


			// Varible for file size
			$filesize  = filesize($userpath."/".$dolls[$entry])/1000;	
			$filesizek = number_format($filesize, 2);

			// Variables for the time output
			$last_updated1 = filemtime($userpath."/".$dolls[$entry]);
			$last_updated  = date($date_format,$last_updated1);


			$dolls[$entry] = stripslashes($dolls[$entry]);
			echo "<tr>\n";
			mini_template($index, $textcolor, $bgcolor);
			mini_template("<a href=\"$httppath/$dolls[$entry]\" target=\"_blank\"><span style=\"color: $textcolor\">$dolls[$entry]</span></a>", $textcolor, $bgcolor);
			mini_template($filesizek, $textcolor, $bgcolor);
			mini_template($last_updated, $textcolor, $bgcolor);
			mini_template("<input type=checkbox name=delete[$entry] value=\"".$dolls[$entry]."\">", $textcolor, $bgcolor);
			echo "</tr>\n";
			
		}
	} else {

		for ($j = 0; $j < $numpage; $j++) {
			$entry = ($thispage-1)*$numpage+$j;
			// if the array element is empty, break out of the for loop
			if($dolls[$entry] == "")
				break;
			$colornum++;

			$total_colors = count($bgcolor_alt_array);
			// the bgcolor is figured out by the remainder of
			// the row number divide by the total number of colors

			$remainder = $entry % $total_colors;

			// whatever the value is
			$bgcolor = $bgcolor_alt_array[$remainder];
			$textcolor = $textcolor_alt_array[$remainder];

			$index = $entry+1;


			// Varible for file size
			$filesize  = filesize($userpath."/".$dolls[$entry])/1000;	
			$filesizek = number_format($filesize, 2);

			// Variables for the time output
			$last_updated1 = filemtime($userpath."/".$dolls[$entry]);
			$last_updated  = date($date_format,$last_updated1);


			$dolls[$entry] = stripslashes($dolls[$entry]);
			echo "<tr>\n";
			mini_template($index, $textcolor, $bgcolor);
			mini_template("<a href=\"$httppath/$dolls[$entry]\" target=\"_blank\"><span style=\"color: $textcolor\">$dolls[$entry]</span></a>", $textcolor, $bgcolor);
			mini_template($filesizek, $textcolor, $bgcolor);
			mini_template($last_updated, $textcolor, $bgcolor);
			mini_template("<input type=checkbox name=delete[$entry] value=\"".$dolls[$entry]."\">", $textcolor, $bgcolor);
			echo "</tr>\n";
			
		}
	} // end of else if it's not show all

	
	echo "</table>\n";
	echo "<table width=\"500\" cellpadding=\"5\" cellspacing=\"1\" border=\"0\" align=\"center\">";
	echo "<tr><td align=\"center\"><input type=submit value=\"Delete Checked\" class=\"bottombutton\"></td></tr></table></form>";

} // end of the function




function mini_template($text, $textcolor, $bgcolor) {
	echo "<td align=\"center\" bgcolor=\"$bgcolor\" class=\"othertext\" style=\"color: $textcolor\">$text</td>\n";
}



function display_upload_form() {
	global $MAX_FILE_SIZE, $require_login;
	// display upload html

	echo "<br />\n";
	echo "<table cellspacing=5 align=\"center\">\n";
	echo "<tr>\n";
	echo "<td>\n";
	if($require_login == 1)
		$logout = " -- <a href=\"".$_SERVER['PHP_SELF']."?do=logout\">Logout</a>";

	echo "<h1>Upload File: (Under ".$MAX_FILE_SIZE." Bytes) ".$logout."</h1>\n";
	echo "<form enctype=\"multipart/form-data\" action=\"".$_SERVER['PHP_SELF']."?action=upload\" method=\"post\">\n";
	echo "<input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"".$MAX_FILE_SIZE."\" />\n";
	echo "<input name=\"userfile[]\" TYPE=\"file\" class=\"input\" size=\"60\"><BR>\n";
	echo "<input type=\"submit\" VALUE=\"Send File\" class=\"bottombutton\"> <span class=\"othertext\"><input name=\"overwrite_me[]\" value=\"1\" type=\"checkbox\"> Overwrite old file? <a href=\"".$_SERVER['PHP_SELF']."?action=uploadmulti\">Upload multiple files at once</a></span>\n";
	echo "</form>\n";
	echo "</td>\n";
	echo "</tr>\n";
	echo "</table>\n";


} // end of function display_upload_form




function upload_multi_form($number) {
	global $bgcolor_alt_array, $textcolor_alt_array, $MAX_FILE_SIZE;
	echo "<form ENCTYPE=\"multipart/form-data\" action=\"".$_SERVER['PHP_SELF']."?action=uploadmulti_upload\" method=\"post\"><br />\n";
	echo "<p>Upload $number files. All files should be under $MAX_FILE_SIZE bytes.<br />\n";
	echo "Check the checkboxes to indicate that you wish to overwrite the old file(s).</p>\n";
	echo "<table align=\"center\" width=\"500\" cellpadding=\"5\" cellspacing=\"1\" border=\"0\" class=\"table\"  id=\"ID1\">\n";
	echo "<tr>\n";
	echo "<td class=\"tableheader\" width=\"1\" align=\"center\"><input type=checkbox value=\"CheckAll\" onClick=\"doCheckAll('ID1')\" id=\"CID1\" name=\"CID1\"></td>\n";
	echo "<td class=\"tableheader\"><b>Upload</b> <input id=\"n\" name=\"number\" value=\"".$number."\" size=\"2\" maxlength=\"2\"> files \n";
	echo "<a href=\"#\" onclick=\"window.location='".$_SERVER['PHP_SELF']."?action=uploadmulti&number='+document.getElementById('n').value\">go!</a>\n";
	//echo "<a href=\"#\" onclick=\"window.location='index.php'\">go!</a>\n";
	echo "</td>\n";
	echo "</tr>\n";
	for($i = 1; $i <= $number; $i++) {

		$j = str_pad($i, 2, "0", STR_PAD_LEFT);
		$l = $i - 1;

		
		$total_colors = count($bgcolor_alt_array);
		// the bgcolor is figured out by the remainder of
		// the row number divide by the total number of colors

		$remainder = $i % $total_colors;

		// whatever the value is
		$bgcolor = $bgcolor_alt_array[$remainder];
		$textcolor = $textcolor_alt_array[$remainder];
		
		echo "<tr>\n";
		echo "<td class=\"othertext\" bgcolor=\"".$bgcolor."\"><input type=\"checkbox\" name=\"overwrite_me[".$l."]\" value=\"1\"></td>\n";
		echo "<td class=\"othertext\" bgcolor=\"".$bgcolor."\" style=\"color: ".$textcolor.";\">File #".$j.": <input type=\"file\" name=\"userfile[".$l."]\" class=\"input\" size=\"48\" /></td>\n";
		echo "</tr>\n";
	}
	echo "</table>\n";

	echo "<p align=\"center\"><INPUT TYPE=\"submit\" VALUE=\"Send Files\" class=\"bottombutton\"></p></form>\n";
}



function figure_new_name($file_name, $abspath) {
	$name = explode(".", $file_name);

	if(is_file($abspath."/".$file_name)) {
		$i = 1;
		while(is_file($abspath."/".$name[0].$i.".".$name[1])) {
			$i++;
		}
		return $name[0].$i.".".$name[1];
	}
	return $file_name;
}



/* actually upload files */
/* move one or more $tmp_name to real_name */
function upload_files($uploaded_files, $abspath) {
	global $httppath;
	$output = "";
	for($i = 0; $i < count($uploaded_files[name]); $i++) {
		$file_name = $uploaded_files[name][$i];
		$file_overwrite = $uploaded_files[overwrite_me][$i];
		$file_tmp_name = $uploaded_files[tmp_name][$i];
		if($file_overwrite != 1)
			$file_name = figure_new_name($file_name, $abspath);
		move_uploaded_file ($file_tmp_name, $abspath."/".$file_name);
		$output .= "<a href=\"".$httppath."/".$file_name."\" target=\"_blank\">".$httppath."/".$file_name."</a><br />\n";
	}
	return $output;
}




function handle_uploaded_files($array_name) {
	global $$array_name, $_FILES;
	$newpoop = null;
	$index = 0;
	$total = count($_FILES[$array_name][name]);

	for($i = 0; $i < $total; $i++) {
		if(isset($_FILES[$array_name][error][$i]) && $_FILES[$array_name][error][$i] != 4) {
			$newpoop[name][$index] = $_FILES[$array_name][name][$i];
			$newpoop[error][$index] = $_FILES[$array_name][error][$i];
			$newpoop[size][$index] = $_FILES[$array_name][size][$i];
			$newpoop[type][$index] = $_FILES[$array_name][type][$i];
			$newpoop[tmp_name][$index] = $_FILES[$array_name][tmp_name][$i];
			$newpoop[overwrite_me][$index] = $_POST['overwrite_me'][$i];
			$index++;
		}
	}

	return $newpoop;
}


function is_type($file_type, $require_file_type) {
	return strtolower($file_type) == strtolower($require_file_type);
}


/* array of the files uploaded and the name of the array */
/* $size_requirement takes array of width and height and will check on images */
function uploadfiles_error_checking($uploaded_files, $abs_path = null, $MAX_FILE_SIZE = 1048576, $size_requirement=null, $exact=0, $filename_limit = 0, $require_file_type=null) {
	for($i = 0; $i < count($uploaded_files[name]); $i++) {
		$file_error = $uploaded_files[error][$i];
		$file_size = $uploaded_files[size][$i];
		$file_name = "<b>".$uploaded_files[name][$i]."</b>";
		$file_type = $uploaded_files[type][$i];
		$file_tmp_name = $uploaded_files[tmp_name][$i];

		if($file_error == 1) {
			$error = "The uploaded file ".$file_name." exceeds the upload_max_filesize directive in php.ini.";
		} elseif($file_size > $MAX_FILE_SIZE || (isset($file_error) && $file_size == 0)) {
			$error = "The file ".$file_name." you are uploading is bigger than the maximum size allowed: ".$MAX_FILE_SIZE." bytes.";
		} elseif($file_error == 3) {
			$error = "The uploaded file ".$file_name." was only partially uploaded.";
		} elseif($filename_limit != 0 && strlen($file_name) > $filename_limit) {
			$error = $file_name." is longer than ".$filename_limit." characters. Please reduce the length of your file name!";
		} elseif(is_image($file_type) && isset($size_requirement) && size_pass($file_tmp_name, $size_requirement, $exact) === false) {
			$error = $file_name." does not have the correct dimension. It must ";
			$error .= ($exact == 1) ? "be exactly" : "not exceed";
			$error .= " ".$size_requirement[0]." x ".$size_requirement[1]." pixels.";
		} elseif($require_file_type == 1 &&  is_type($file_type, $require_file_type) === false) {
			$error = $file_name." must be in ".$require_file_type." format!";
		}
	}

	return (isset($error)) ? $error : true;
}


function is_image($filetype) {
	return (strstr($filetype, "image/"));
}

/* check size of the uploaded file if there is  dimension requirement */
function size_pass($file_tmp_name, $size_requirement, $exact=0) {
	$size = getimagesize($file_tmp_name);
	if($exact == 0) {
		return ($size[0] <= $size_requirement[0] && $size[1] <= $size_requirement[1]);
	} else {
		return ($size[0] == $size_requirement[0] && $size[1] == $size_requirement[1]);
	}
}


function getrid($delete) {
	global $userpath;
	if($delete != null) {
		$arrayindex = array_keys($delete);
		$index = 0;
		while($index < count($delete)) {
			$result = unlink($userpath."/".$delete[$arrayindex[$index]]);
			$result = 1;
			$index++;
		}
	if($result)
		print_error("List Updated", "File(s) have been deleted.", "Back Home", $_SERVER['PHP_SELF']);
	} else {
		print_error("Error", "Nothing to Delete.", "Back Home", $_SERVER['PHP_SELF']);
	}
}




function dodo_rules() {
	$version = "1.3";
	echo "<br /><br /><center><div class=\"othertext\" style=\"font-size: 8.5pt\">DodoUpload Version ".$version.".<br />Powered by <a href=\"http://regretless.com/scripts/\" target=\"_blank\">Dodo</a>, <a href=\"http://www.tabulas.com/~dodozhang21/gallery/album27396/\" target=\"_blank\">Bubo</a> &amp; <a href=\"http://www.tabulas.com/~dodozhang21/gallery/album39075/\" target=\"_blank\">Misty</a>. <a href=\"https://www.paypal.com/xclick/business=luck@regretless.com&item_name=Feed%2BDodo%2Band%2BBubo&no_shipping=1&return=http%3A//regretless.com/scripts&cn=The%2Breason%2Bfor%2Byour%2Bdonation%2B%3A\" target=\"_blank\" title=\"Feed us!\">Feed us!</a></div></center>";
}


function print_error($title, $message, $back_text="Back", $back_link="javascript:history.back(1)") {
	$text = "<h1>$title</h1>\n<br /><div class=\"othertext\">$message<br /><br />\n<a href=\"$back_link\">$back_text</a></div>";
	echo $text;
}


function load_login_form() {
	echo "<h1> </h1>\n";
	echo "<form action=\"".$_SERVER['PHP_SELF']."?do=login\" method=\"post\">\n";
	echo "<br />\n";
	echo "Username:<br />\n";
	echo "<input name=\"username\" size=\"20\"><br />\n";
	echo "Password:<br />\n";
	echo "<input name=\"password\" type=\"password\" size=\"20\"><br />\n";
	echo "<br />\n";
	echo "<input type=\"submit\" value=\"Login\" class=\"bottombutton\">\n";
	echo "</form>\n";
}


function page_links($current, $total, $format) {
    if($total == 1)
		return;

	if(empty($current) || $current == "showall") {
		$current = 1;
	}

	$buffer = 2;
	$out = "";
	$out .= "Page ".$current." of ".$total."\n";

    if($current > 1) {
        $out .= "<a href=\"" . sprintf($format, 1) . "\" title=\"View First Page\">&laquo;</a>\n";
		$out .= "<a href=\"" . sprintf($format, $current-1) . "\" title=\"Previous Page\">&lt;</a>\n";
        for($i = ($current - $buffer); $i < $current; $i++) {
            if($i < 1) {
                continue;
            }
            $out .= "<a href=\"" . sprintf($format, $i) . "\" title=\"Page ".$i."\">".$i."</a>\n";
        }
    }
	
	$out .= "<a href=\"" . sprintf($format, $current) . "\" title=\"Current Page\"  id=\"current\">".$current."</a>\n";
	
    if($current < $total) {
        for($i = ($current + 1); $i <= ($current + $buffer); $i++) {
            if($i > $total) {
                break;
            }
            $out .= "<a href=\"" . sprintf($format, $i) . "\" title=\"Page ".$i."\">".$i."</a>\n";
        }
		$out .= "<a href=\"" . sprintf($format, $current+1) . "\" title=\"Next Page\">&gt;</a>\n";
        $out .= "<a href=\"" . sprintf($format, $total) . "\" title=\"View Last Page\">&raquo;</a>\n";
    }

    return $out;
    
}



?>