process.php
Código PHP:
Ver original<?php
$session = false;
include("db-info.php");
include("loadsettings.inc.php");
$type = "public";
if (isset($_SESSION["imagehost-user"])) {
$session = true;
$username = $_SESSION["imagehost-user"];
$password = $_SESSION["imagehost-pass"];
$q = "SELECT id FROM `members` WHERE (username = '$username') and (password = '$password')";
if (!$number) {
$session = false;
}else {
$loggedId = $row[0];
if (isset($_POST["tags1"])) {
$opt = $_POST['opt'];
if ($opt == "gallery") {
$galleryid = $_POST["galleryid"];
$result = mysql_query("SELECT type FROM `galleries` WHERE id = '$galleryid'"); $type = $row['type'];
}
else {
if (isset($_POST["private"])) $type = "private";
else
$type = "public";
}
}
}
}
else
$session = false;
?>
<html>
<head>
<title><? echo $webtitle; ?> - Hosting de Imagenes</title>
<link rel="stylesheet" href="style.css" type="text/css" />
</head>
<body link=#336699 vlink=#336699 alink=#336699>
<?php include("header.php"); ?>
<center>
<div class="content-container">
<p>
<?php
function findExtension ($filename)
{
$exts = split("[/\\.]", $filename) ; $exts = $exts[$n];
return $exts;
}
function imagecreatefromunknown($path) {
$ext = findExtension($path);
switch ($ext) {
case "jpg":
break;
case "gif":
break;
case "png":
break;
}
return $img;
}
$max = 5;
$total = 0;
if (isset($_POST["tags1"])) {
$lastaccess = date("y-m-d"); $ip= $_SERVER['REMOTE_ADDR'];
//CHECK IF THE IP OF THE PERSON IS BLOCKED OR NOT
$result = mysql_query("SELECT id FROM `blockedip` WHERE ip = '$ip'"); if ($number) die("Lo sentimos! Su IP fue blockeada para subir imagenes. <br><br><a href='index.php'>Volver al Inicio</a>");
for ($i=1; $i < ($max+1); $i++)
{
if (trim($_FILES["image" . $i]["name"]) != "") {
$total = $total + 1;
if ( (trim($_POST["tags" . $i]) != "") ) {
$name = "image" . $i;
//CHECK IF VALID IMAGE TYPE
if (( ($_FILES[$name]["type"] == "image/gif")
|| ($_FILES[$name]["type"] == "image/jpeg")
|| ($_FILES[$name]["type"] == "image/pjpeg")
|| ($_FILES[$name]["type"] == "image/x-png")
|| ($_FILES[$name]["type"] == "image/bmp")
|| ($_FILES[$name]["type"] == "image/png")))
{
$size = intval(($_FILES[$name]["size"] / 1024) / 1024);
if ($session == true)
$limit = $maxsizemember;
else
$limit = $maxsizeguest;
if ($size > $limit)
die ("Lo sentimos! El tamañno de la imagen exede los $limit Mb.");
if ($_FILES[$name]["error"] > 0) {
die("Error: " . $_FILES[$name]["error"]); }
else {
$n = $_FILES[$name]["name"];
$rndName = md5($n . date("d-m-y") . time()) . "." . findExtension
($n); $uploadPath = "pictures/" . $rndName;
$tempPath = $_FILES[$name]["tmp_name"];
}
}
else
die("Lo sentimos!! \"{$_FILES[$name]["name
"]}\" Es una imagen inválida.");
$imagePath = $uploadPath;
$img = imagecreatefromunknown($imagePath);
if (($mainWidth > 0) && ($mainWidth < 10000) && ($mainHeight < 10000))
{
$a = ($mainWidth >= $mainHeight) ? $mainWidth : $mainHeight;
$div = $a / 150;
$thumbWidth = intval($mainWidth / $div); $thumbHeight = intval($mainHeight / $div);
imagecopyresampled($myThumb, $img, 0, 0, 0, 0, $thumbWidth, $thumbHeight, $mainWidth, $mainHeight); $thumbPath = "thumbnails/" . basename($imagePath);
if (($type == "public") && ($watermark == "true")) {
$dX = $mainWidth - imagesx($imgMark); $dY = $mainHeight - imagesy($imgMark);
$ext = findExtension($imagePath);
switch ($ext) {
case "jpg":
case "png":
}
}
$details = intval(filesize($imagePath) / 1024) . " kb (" . $mainWidth . " x " . $mainHeight . ")" ;
if ($session == false)
$q = "INSERT INTO `images`(id, image, thumb, tags, details, date, access, type, ip)
VALUES('$id', '$imagePath', '$thumbPath', '$tags', '$details', '$date', '$lastaccess', 'public', '$ip')";
else
{
if ($opt == "gallery")
$q = "INSERT INTO `images`(id, galleryid, image, thumb, tags, details, date, access, type, ip)
VALUES('$id', '$galleryid', '$imagePath', '$thumbPath', '$tags', '$details', '$date', '$lastaccess', 'gallery', '$ip')";
else
$q = "INSERT INTO `images`(id, userid, image, thumb, tags, details, date, access, type, ip)
VALUES('$id', '$loggedId', '$imagePath', '$thumbPath', '$tags', '$details', '$date', '$lastaccess', 'member-{$type}', '$ip')";
}
echo "<center>";
echo "<center><a href=\"show-image.php?id=$id\"><img src='thumb.php?id=$id'></a></center><br>";
echo "Imagen \"{$_FILES["image" . $i]["name"]}\" Subida correctamente <br><br>";
echo "<LABEL id='title'>Enlace Directo:</LABEL><br><input type='text' size=92 onclick=\"this.select();\" value=\"{$website}/{$imagePath}\">";
echo "<br><br>";
echo "<LABEL id='title'>Codigo BB:</LABEL><br><input type='text' size=92 onclick=\"this.select();\" value=\"[IMG={$website}/{$imagePath}]\">";
echo "<br><br>";
echo "<LABEL id='title'>Codigo BB:</LABEL><br><input type='text' size=92 onclick=\"this.select();\" value=\"[IMG]{$website}/{$imagePath}[/IMG]\">";
echo "<br><br>";
echo "<LABEL id='title'>URL:</LABEL><br><input type='text' size=92 onclick=\"this.select();\" value=\"{$website}/show-image.php?id=$id\">";
echo "<br><br><hr color='#233c9b'><br>";
echo "</center>";
}
else
echo "Lo sentimos! La imagen \"{$_FILES["image" . $i]["name"]}\" Es demasiado grande o pequeña.<br><hr color='#b1ddf6'>";
}
else
echo "Usted no inserto ningun tag para la imagen \"{$_FILES["image" . $i]["name"]}\" <br><hr color='#b1ddf6'>";
}
}
}
if ($total == 0)
echo "Lo sentimos! Debe subir al menos una imagen.";
?>
</p>
<p> </p>
<p> <center><a href="index.php"><img src="images/subirmas.png" width="148" height="40" border="0"></a></center></p>
<?php include("footer.php"); ?>
</div>
</center>
PD: Dejo los archivos no para que lo hagan ustedes, si no para que me puedan dar una idea más concreta de lo que tengo que hacer