If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.
try this... dont know if its what your looking for...
<?php
########### REQUIRED EDITS ########################################
$require_login = 0; // set it to 0, no login will be required
// define below if $require_login is 1
$user = "user";
$pass = "pass";
########### OPTIONAL EDITS ########################################
$numpage = 10; // number of files listed per page
$MAX_FILE_SIZE = "15000"; // in bytes!!
$date_format = "m.d.Y-H:i:s 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://yourdomain.com/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 ############################################
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];
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 = "".$uploaded_files[name][$i]."";
$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']);
}
}
Thank you all for replying my topic so fast.Yes i need a script where people can login and register and then upload stuff.Also this script should be able to show last uploads by members.I want to start a file hosting company.Plz dont post scripts which use MYSQL database bcoz i dont know abt it.
I will be very thankfull.
Comment