Hola amigos, mi problema es urgente, me han hackeado mi upload, necesito un codigo para protejerlo, el codigo php del upload no es mio, yo solo le modifique artas cosas, todos mis codigos dentro de mi upload son:
upload.php:
<?php
$varrand = substr(md5(uniqid(rand())),0,10);
$varallw = $varallw = array("image/bmp","image/gif","image/jpeg","image/pjpeg","image/png","image /x-png");
$varpath = "https://xxx.webcindario.com/img/";
$varstat = "";
if ($_POST["action"] == "upload") {
if (is_uploaded_file($_FILES["imagen"]["tmp_name"])) {
$varname = $_FILES["imagen"]['name'];
$vartemp = $_FILES['imagen']['tmp_name'];
$vartype = $_FILES['imagen']['type'];
if (in_array($vartype, $varallw) && $varname != "") {
$arrname = explode(".", $varname);
$varname = $varrand.".".$arrname[1];
if (copy($vartemp, "img/".$varname)) {
$varpath = $varpath.$varname;
$varstat = "ok";
} else {
$varstat = "Error al subir el archivo.";
}
} else {
$varstat = "Tipo de archivo no valido.";
}
}
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>ProUpload ~ Tu hosting de imagenes</title>
<link href="style-def.css" rel="stylesheet" type="text/css" />
<body style="background-color:transparent">
</head>
<body>
<a target="_self" border="0" href="https://xxx.webcindario.com/upload.php">Inicio</a> | <a border="0" href="https://xxx.webcindario.com/gallery.php">Galeria</a>
<table width="420" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="413" height="40"><span style="font-size: small"><strong>Titulo</strong></span></td>
</tr>
<tr>
<td>Tu Hosting de Imagenes</td>
</tr>
<tr>
<form action="upload.php" method="post" enctype="multipart/form-data">
<td height="50" valign="top">
<input name="imagen" type="file" id="imagen" size="35" />
<input name="enviar" type="submit" id="enviar" value="Subir Imagen" />
<input name="action" type="hidden" value="upload" /> </td>
</form>
</tr>
<td>Maximo peso: 1 MB.<br />
Tipos de archivos: jpg,jpeg,png,gif,bmp.</td>
<?php if ($varstat == "ok") { ?>
<tr>
<td><img alt="" src="linea.png" /><br /><strong>Confirmación:</strong><br>
Archivo subido satisfactoriamente. Puedes utilizar las siguientes opciones para enlazarlo:<br>
<strong>Enlace Directo:</strong><br>
<input name='txt1' type='text' onClick="javascript:select();" value='<?php echo $varpath; ?>' size='60'>
<br>
<strong>Enlace Para ver la IMG:</strong><br>
<input name='txt2' type='text' onClick="javascript:select();" value='https://xxx.webcindario.com/view.php?image=<?php echo $varname; ?>' size='60'>
<br>
<strong>Enlace HTML:</strong><br>
<input name='txt3' type='text' onClick="javascript:select();" value='<a href="https://xxx.webcindario.com/view.php?image=<?php echo $varname; ?>"><img src="<?php echo $varpath; ?>" border="0" /></a>' size='60'>
<br>
<strong>Enlace BBCode:</strong><br>
<input name='txt4' type='text' onClick="javascript:select();" value='[URL=https://xxx.webcindario.com/view.php?image=<?php echo $varname; ?>][img]<?php echo $varpath; ?>[/img][/URL]' size='60'></td>
</tr>
<?php } else { ?>
<?php if ($varstat != "") { ?>
<tr>
<td><img alt="" src="linea.png" /><br /><strong>Error:</strong><br>
<?php echo $varstat; ?></td>
</tr>
<?php } ?>
<?php } ?>
</table>
<?php if ($varstat == "ok") { ?>
<p align="center"><br /><span style="font-size: 1px"> </span><a target="_blank" href="<?php echo $varpath; ?>"><img alt="<?php echo $_GET['image']; ?>" height="100" src="img/<?php echo $varname; ?>"></a></p>
<?php } ?>
<?php if ($_GET['image'] != "") { ?>
<p align="center"><br /><span style="font-size: 1px"> </span><a target="_blank" href="<?php echo $varpath; ?>"><img alt="<?php echo $_GET['image']; ?>" height="100" src="img/<?php echo $_GET['image']; ?>"></a></p>
<?php } ?>
</body>
</html>
gallery.php:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>ProUpload ~ Tu hosting imagenes</title>
<link href="style-def.css" rel="stylesheet" type="text/css" />
<body style="background-color:transparent">
</head>
<body>
<a target="_self" border="0" href="https://xxx.webcindario.com/upload.php">Inicio</a> | <a border="0" href="https://xxx.webcindario.com/gallery.php">Galeria</a>
<table width="420" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="413" height="40"><span style="font-size: small"><strong>Titulo</strong></span></td>
</tr>
<tr>
<td>Tu Hosting de Imagenes<br /><img alt="" src="linea.png" /><br /><strong>Galeria de Imagenes:</strong><br>
Las imagenes que usted puede ver son propiedad de los usuarios que han publicado esta imagenes en ProUpload.<br></td>
</tr>
<tr>
<td>
<?php
if ($gestor = opendir('img')) {
while (false !== ($arch = readdir($gestor))) {
if ($arch != "." && $arch != "..") {
echo "<a href="view.php?image=".$arch."" class="linkli">".$arch."</a><br />";
}
}
closedir($gestor);
}
?>
</td>
</tr>
view.php:
<?php
$varrand = substr(md5(uniqid(rand())),0,10);
$varallw = $varallw = array("image/bmp","image/gif","image/jpeg","image/pjpeg","image/png","image /x-png");
$varpath = "https://xxx.webcindario.com/img/";
$varstat = "";
if ($_POST["action"] == "upload") {
if (is_uploaded_file($_FILES["imagen"]["tmp_name"])) {
$varname = $_FILES["imagen"]['name'];
$vartemp = $_FILES['imagen']['tmp_name'];
$vartype = $_FILES['imagen']['type'];
if (in_array($vartype, $varallw) && $varname != "") {
$arrname = explode(".", $varname);
$varname = $varrand.".".$arrname[1];
if (copy($vartemp, "img/".$varname)) {
$varpath = $varpath.$varname;
$varstat = "ok";
} else {
$varstat = "Error al subir el archivo.";
}
} else {
$varstat = "Tipo de archivo no valido.";
}
}
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>ProUpload ~ Tu hosting de imagenes</title>
<link href="style-def.css" rel="stylesheet" type="text/css" />
<body style="background-color:transparent">
</head>
<body>
<a target="_self" border="0" href="https://xxx.webcindario.com/upload.php">Inicio</a> | <a border="0" href="https://xxx.webcindario.com/gallery.php">Galeria</a>
<table width="420" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="413" height="40"><span style="font-size: small"><strong>Titulo</strong></span></td>
</tr>
<tr>
<td>Tu Hosting de Imagenes</td>
</tr>
<?php if ($varstat == "") { ?>
<tr>
<td><img alt="" src="linea.png" /><br /><strong>Ver la Imagen:</strong><br>
Archivo alojado gratis en xxx. Puedes utilizar las siguientes opciones para enlazarlo:<br>
<strong>Enlace Directo:</strong><br>
<input name='txt1' type='text' onClick="javascript:select();" value='https://xxx.webcindario.com/img/<?php echo $_GET['image']; ?>' size='60'>
<br>
<strong>Enlace Para ver la IMG:</strong><br>
<input name='txt2' type='text' onClick="javascript:select();" value='https://xxx.webcindario.com/view.php?image=<?php echo $_GET['image']; ?>' size='60'>
<br>
<strong>Enlace HTML:</strong><br>
<input name='txt3' type='text' onClick="javascript:select();" value='<a href="https://xxx.webcindario.com/view.php?image=<?php echo $_GET['image']; ?>"><img src="https://xxx.webcindario.com/img/<?php echo $_GET['image']; ?>" border="0" /></a>' size='60'>
<br>
<strong>Enlace BBCode:</strong><br>
<input name='txt4' type='text' onClick="javascript:select();" value='[URL=https://xxx.webcindario.com/view.php?image=<?php echo $_GET['image']; ?>][img]https://xxx.webcindario.com/img/<?php echo $_GET['image']; ?>[/img][/URL]' size='60'></td>
</tr>
<?php } else { ?>
<?php if ($varstat != "") { ?>
<tr>
<td><img alt="" src="linea.png" /><br /><strong>Error:</strong><br>
<?php echo $varstat; ?></td>
</tr>
<?php } ?>
<?php } ?>
</table>
<?php if ($varstat == "ok") { ?>
<p align="center"><br /><span style="font-size: 1px"> </span><a target="_blank" href="img/<?php echo $_GET['image']; ?>"><img alt="<?php echo $_GET['image']; ?>" height="100" src="img/<?php echo $_GET['image']; ?>"></a></p>
<?php } ?>
<?php if ($_GET['image'] != "") { ?>
<p align="center"><br /><span style="font-size: 1px"> </span><a target="_blank" href="img/<?php echo $_GET['image']; ?>"><img alt="<?php echo $_GET['image']; ?>" height="100" src="img/<?php echo $_GET['image']; ?>"></a></p>
<?php } ?>
Espero que me ayuden es urgente, gracias!