\n";
echo "\n";
echo "File Loaction:
\n";
echo "
\n";
echo "

\n";
echo "\n";
ob_end_flush();
}
elseif ($conf['cookie']['use'] == true && isset($_COOKIE[$conf['cookie']['name']])) {
echo "You already have uploaded a file in lower than ".$conf['cookie']['time']." minutes... Please wait!
\n";
ob_end_flush();
}
else {
if (!is_dir($conf['dir']['name']) && !mkdir($conf['dir']['name'],0777)) {
echo "Couldn't upload file, the directory ".$conf['dir']['name']." doesn't exists!...
\n";
ob_end_flush();
}
// Retrieve the file extension...
$gext = explode(".",$_FILES['upload']['name']);
$ext = $gext[(count($gext)-1)];
$noext = str_replace(".".$ext,"",$_FILES['upload']['name']);
unset($gext);
if (!is_numeric(array_search($ext,$conf['dir']['formats']))) {
echo 'Only the following extensions are valid: ';
foreach ($conf['dir']['formats'] as $myval) { echo "".$myval." "; }
echo "
\n";
ob_end_flush();
}
if (!isset($conf['dir']['encrypt']) || $conf['dir']['encrypt'] == false) {
$listfiles = scandir($conf['dir']['name']);
if ($listfiles == false) {
echo "Couldn't list the upload directory!...
\n";
ob_end_flush();
}
$files = 0;
foreach ($listfiles as $val) { if ($val != "." && $val != ".." && !is_dir($val)) { $files++; } }
unset($listfiles);
$file['fullname'] = "{$files}.{$ext}";
$file['name'] = $files;
if (is_file($file['fullname'])) {
echo "Random error while renaming your file!...
\n";
ob_end_flush();
}
}
else {
if ($conf['dir']['uhash'] == true) { $mfile = md5($noext).rand(1,999999999999); }
else { $mfile = $noext.rand(1,999999999999); }
$file['fullname'] = $mfile.".".$ext;
$file['name'] = $mfile;
unset($mfile);
if (is_file($file['fullname'])) {
echo "Your file can't be renamed as a file with the same renamed name exists. Please try again!...
\n";
ob_end_flush();
}
}
$file['extension'] = $ext;
if($_FILES['upload']['error'] != 0 && $_FILES['upload']['error'] != 2) {
echo "Random error while uploading your file!...
\n";
ob_end_flush();
}
elseif($_FILES['upload']['error'] == 2) {
echo "Your file size is higher than ".round(($conf['dir']['filesize']/1048576),1)." MB (megabytes)...
\n";
ob_end_flush();
}
if(move_uploaded_file($_FILES['upload']['tmp_name'],"{$conf['dir']['name']}/{$file['fullname']}")) {
$buildurl = $_SERVER["SERVER_NAME"]."/";
$mhu = explode("/",$_SERVER["REQUEST_URI"]);
for ($x = 0; $x < (count($mhu)-2); $x++) { if ($x != count($mhu)) { $buildurl .= $mhu[$x]."/"; } }
$buildurl .= "{$conf['dir']['name']}/{$file['fullname']}";
unset($mhu);
$file_link = str_replace(array('.png','.jpg','.jpeg','.gif','.bmp','.PNG','.JPG','.JPEG','.GIF','.BMP'),'',$file['fullname']);
echo "Your file has been successfully uploaded!. Click here to see it!.
\n";
echo "Or Upload again!\n";
if ($conf['cookie']['use'] == true) {
setcookie($conf['cookie']['name'],$file['fullname'],time()+($conf['cookie']['time']*60));
}
if ($conf['inf']['log'] == true) {
if (getenv('HTTP_CLIENT_IP')) { $ip = getenv('HTTP_CLIENT_IP'); }
elseif (getenv('HTTP_X_FORWARDED_FOR')) { $ip = getenv('HTTP_X_FORWARDED_FOR'); }
elseif (getenv('HTTP_X_FORWARDED')) { $ip = getenv('HTTP_X_FORWARDED'); }
elseif (getenv('HTTP_FORWARDED_FOR')) { $ip = getenv('HTTP_FORWARDED_FOR'); }
elseif (getenv('HTTP_FORWARDED')) { $ip = getenv('HTTP_FORWARDED'); }
else { $ip = $_SERVER['REMOTE_ADDR']; }
$fload = fopen($conf['inf']['file'],"a");
fwrite($fload,"=> Uploaded file {$file['fullname']} by user @ IP {$ip}\n");
fclose($fload);
unset($fload,$ip);
}
}
else {
echo "Couldn't upload the file!...
\n";
}
}
ob_end_flush();
?>