friends help me in this,
PHP Code:
<?php
error_reporting(E_warning);
$time = date("d.m.Y, H:i:s");
$Browser = ' $_SERVER[HTTP_USER_AGENT]';
$ip='$_SERVER[REMOTE_ADDR]';
$desc=trim($_POST['desc']);
$user=trim($_POST['user']);
if(!$desc) $desc="No description available.";
if(!$user) $user="Guest";
// apare input-ul atata timp cat nu e Opera MIni 3.
if (preg_match("/Opera Mini/i", $Browser) && !preg_match("/Opera Mini\/3.0/i", $Browser)) $OperaMini = TRUE;
$no="no";
header("Cache-Control: no-cache, must-revalidate");
header("Content-type: text/html; charset=ISO-8859-1");
echo "<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>\n";
echo "<!DOCTYPE html PUBLIC \"-//WAPFORUM//DTD XHTML Mobile 1.0//EN\"
\"http://www.wapforum.org/DTD/xhtml-mobile10.dtd\">\n";
echo "<html xmlns=\"http://www.w3.org/1999/xhtml\">\n";
echo "<head>\n";
include("config.php");
echo "<title>Upload File</title>";
echo "<link rel='stylesheet' href='style.css' type='text/css'/>";
echo "</head>\n";
echo "<body>";
echo "<table bgcolor=\"#F5DEB3\" width=\"100%\">";
echo "<tr><td><center><font color='red' size='5'>Hex</font><font color='blue' size='5'>Load</font><br/>First ever site to exchange files with no restrictions at all</center></td></tr></table>";
echo "<div class='hl'>Upload file</div>";
if($_GET[page] !=="add"){
echo "<form method=\"post\" enctype=\"multipart/form-data\" action=\"upload.php?page=add\">";
if ($OperaMini) {
echo "<input type='text' name='file1' size='30'/> <a href='op:fileselect'>Browse files</a><br>";
}
else {
echo "<input type=\"file\" name=\"filetoupload\"><br>";
}
echo "<input type=\"Submit\" name=\"uploadform\" value=\"Upload File\">";
echo "(No file size limit)";
echo "</div>";
echo "<div class=\"hl\">Optional</div>";
echo "<div class=\"txt\"><b><font color=\"green\">User:</font></b>";
echo "<br/><input type=\"text\" value=\"".$COOKIE["HexLoadUser"]."\" name=\"user\" size=\"30\" /><br/>";
echo "<div class=\"txt\"><b><font color=\"green\">Description:</font></b>";
echo "<br/><textarea name=\"desc\" rows=\"4\" cols=\"40\"></textarea><br/>";
echo "<small>Notice: once you submit the file, it will be available to public.</small>";
echo "<br/><b>Please wait while the file is uploaded, it may take several minutes depending by the size of the file and by your internet bandwidth.</b>";
echo "</div>";
echo "</form>";
}
if ($_REQUEST[file1]) {
$file1 = $_REQUEST[file1];
$file1 = explode("=", $file1);
$file_content = $file1[1];
$filename = str_replace("file", "", $file1[0]);
$size = strlen($file_content);
}
else {
$filename = $_FILES['filetoupload']['name'];
$size = $_FILES['filetoupload']['size'];
}
$ext = strrchr($filename,'.');
$truext=str_replace(".","",$ext);
$truext=strtolower($truext);
$ext=strtolower($ext);
$upload_dir=htmlspecialchars("$truext/");
$filename=str_replace(" ","_",$filename);
$filename=str_replace("`","",$filename);
$filename=str_replace("]","",$filename);
$filename=str_replace("[","",$filename);
$filename=str_replace("~","",$filename);
$filename=str_replace("@","",$filename);
$filename=str_replace("#","",$filename);
$filename=str_replace("%","",$filename);
$filename=str_replace("^","",$filename);
$filename=str_replace("*","",$filename);
$filename=str_replace("|","",$filename);
$filename=str_replace("$","",$filename);
$filename=str_replace("<","",$filename);
$filename=str_replace("<","",$filename);
$filename=str_replace(">","",$filename);
$filename=str_replace(">","",$filename);
$filename=str_replace("\"","",$filename);
$filename=str_replace("'","",$filename);
$filename=str_replace("\\","",$filename);
if($_GET['page']=="add"){
if (!$filename)
{
echo "<b>Please select a file for upload.</b><br />";
echo "<br /><div class='hl2'>";
echo "<a href=\"upload.php\"><b>[Upload] </b></a>";
echo "<a href=\"index.php\"><b>[Menu]</b></a>";
echo "<div><br />";
echo "<table bgcolor=\"#F5DEB3\" width=\"100%\"><tr><td><center><a href=\"http://www.hexload.com\">© www.hexload.com</a></center></td></tr></table>";
die();
}
if (($extlimit == "yes") && (in_array($ext,$limitedext)))
{
echo("Extension <b>$ext</b> was disabled due security reasons.The file was NOT uploaded!<br />");
echo "<br />";
echo "<br /><div class='hl2'>";
echo "<a href=\"upload.php\"><b>[Upload] </b></a>";
echo "<a href=\"index.php\"><b>[Menu]</b></a>";
echo "<div><br />";
echo "<table bgcolor=\"#F5DEB3\" width=\"100%\"><tr><td><center><a href=\"http://www.hexload.com\">© www.hexload.com</a></center></td></tr></table>";
die();
}
if(strlen($filename)>$lungime_nume)
{
echo "<b><font color=\"red\">Your file name has a name too long.Please rename it!</font></b><br />";
echo "<br /><div class='hl2'>";
echo "<a href=\"upload.php\"><b>[Upload] </b></a>";
echo "<a href=\"index.php\"><b>[Menu]</b></a>";
echo "<div><br />";
echo "<table bgcolor=\"#F5DEB3\" width=\"100%\"><tr><td><center><a href=\"http://www.hexload.com\">© www.hexload.com</a></center></td></tr></table>";
die();
}
if ($size > $size_bytes)
{
echo "<b><font color=\"red\">Your file size is too big.Maximum allowed is $mb MB.</font></b><br />";
echo "<br /><div class='hl2'>";
echo "<a href=\"upload.php\"><b>[Upload] </b></a>";
echo "<a href=\"index.php\"><b>[Menu]</b></a>";
echo "<div><br />";
echo "<table bgcolor=\"#F5DEB3\" width=\"100%\"><tr><td><center><a href=\"http://www.hexload.com\">© www.hexload.com</a></center></td></tr></table>";
die();
}
if (file_exists("$upload_dir/$filename"))
{
echo("<b><font color=\"red\">File already exist.Please rename your file!</font></b><br />");
echo "<br /><div class='hl2'>";
echo "<a href=\"upload.php\"><b>[Upload] </b></a>";
echo "<a href=\"index.php\"><b>[Menu]</b></a>";
echo "<div><br />";
echo "<table bgcolor=\"#F5DEB3\" width=\"100%\"><tr><td><center><a href=\"http://www.hexload.com\">© www.hexload.com</a></center></td></tr></table>";
die();
}
if ($file1) {
if(!is_dir($upload_dir)){mkdir($upload_dir); chmod($upload_dir,0777); copy("htaccess.txt","$upload_dir.htaccess");}
$fp = fopen($upload_dir.$filename, "w") or die("File cannot be saved due server permissions");
fwrite($fp, base64_decode($file_content));
if (fclose($fp)) $Uploaded = TRUE;
}
else {
if(!is_dir($upload_dir)){mkdir($upload_dir); chmod($upload_dir,0777); copy("htaccess.txt","$upload_dir.htaccess");}
move_uploaded_file($_FILES['filetoupload']['tmp_name'], $upload_dir.$filename) or die("Cannot move uploaded file");/// i am getting this condition error.. while it was working fine before , i didnt make any change in any code ever then also it automatically again giving this condition error. its copying file ext. directory, .htaccess but not have to move file.. why??
$Uploaded = TRUE;
}
if ($Uploaded)
{
mysql_query("INSERT INTO hrzshare (banned,file,user,browse,ip,ftype,uploaded,description,size) VALUES ('$no','$filename','$user','$Browser','$ip','$truext','$time','$desc','$size')");
$sql = mysql_query("SELECT * FROM hrzshare WHERE file = '$filename' ");
while($row = mysql_fetch_array($sql)){
$id = $row['id'];}
echo ("<b><font color=\"red\">Your file was uploaded </font><a href=\"file.php?id=$id\">here</a></b><br />
<u>Copy and paste the following code:</u><br />
<textarea name=\"link\" rows=\"5\" cols=\"40\">".$url."/file.php?id=".$id."</textarea><br />");
echo "<br /><div class='hl2'>";
echo "<a href=\"upload.php\"><b>[Upload] </b></a>";
echo "<a href=\"index.php\"><b>[Menu]</b></a>";
echo "<div><br />";
echo "<table bgcolor=\"#F5DEB3\" width=\"100%\"><tr><td><center><a href=\"http://www.hexload.com\">© www.hexload.com</a></center></td></tr></table>";
die();
}
else
{
echo "<b><font color=\"red\">Unexpected error.Please try again.</font></b><br />";
echo "<br />";
echo "<br /><div class='hl2'>";
echo "<a href=\"upload.php\"><b>[Upload] </b></a>";
echo "<a href=\"index.php\"><b>[Menu]</b></a>";
echo "</div>";
echo "<table bgcolor=\"#F5DEB3\" width=\"100%\"><tr><td><center><a href=\"http://www.hexload.com\">© www.hexload.com</a></center></td></tr></table>";
die();
}
}
echo "<br /><div class='hl2'>";
echo "<a href=\"upload.php\"><b>[Upload] </b></a>";
echo "<a href=\"index.php\"><b>[Menu]</b></a>";
echo "</div>";
echo "<table bgcolor=\"#F5DEB3\" width=\"100%\"><tr><td><center><a href=\"http://www.hexload.com\">© www.hexload.com</a></center></td></tr></table>";
echo "</body>";
echo "</html>";
?>
Comment