El detalle es que tengo a prueba un hosting de imagenes y todo va bien solo una cosa que no me gusta que al subirla me genera un link mas o menos como este: ww w.mipagina/show-image.php?id=921158634f4e04b4a4a74cb7a1d1599f o ww w.mipagina/pictures/5dc46b614f5f1fbe04d533dee2699928.jpg uno para el miniatura y otro para el link directo,el detalle que quiero cambiar es eso la terminacion "5dc46b614f5f1fbe04d533dee2699928" poniendo un ejemplo,Por:
ww w.mipagina/pictures/NombreFecha4NumerosRamdom.jpg
Más o menos asi, y si no me entienden pues simple y sencillo que la terminacion de la imagen no sea tan larga por que tiene demasiados numeros y letras se que es el famoso Md5 y solo se que es informacion oculta entre numeros y letras, Les Dejo el codigo Espero Me Ayuden! Graciass!
Cita:
<?php
session_start();
$session = false;
include("db-info.php");
$link = mysql_connect($server, $user, $pass);
if(!mysql_select_db($database)) die(mysql_error());
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(!($result_set = mysql_query($q))) die(mysql_error());
$number = mysql_num_rows($result_set);
if (!$number) {
session_destroy();
$session = false;
}else {
$row = mysql_fetch_row($result_set);
$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'");
$n = mysql_num_rows($result);
if (!$n) die();
$row = mysql_fetch_array($result);
$type = $row['type'];
}
else {
if (isset($_POST["private"]))
$type = "private";
else
$type = "public";
}
}
}
}
else
$session = false;
//************************************************** ***********************************************
?>
<html>
<head>
<title><? echo $webtitle; ?> </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">
<!-- ################################################## ############################################# -->
<?php
function findExtension ($filename)
{
$filename = strtolower($filename) ;
$exts = split("[/\\.]", $filename) ;
$n = count($exts)-1;
$exts = $exts[$n];
return $exts;
}
function imagecreatefromunknown($path) {
$ext = findExtension($path);
switch ($ext) {
case "jpg":
$img = imagecreatefromjpeg($path);
break;
case "gif":
$img = imagecreatefromgif($path);
break;
case "png":
$img = imagecreatefrompng($path);
break;
case "jar":
$img = imagecreatefrompng($path);
break;
}
return $img;
}
$max = 5;
$total = 0;
if (isset($_POST["tags1"])) {
$date = date("d-m-y");
$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'");
$number = mysql_num_rows($result);
if ($number) die("Perdón! Su ha sido bloqueado para cualquier carga de imagen !. <br><br><a href='index.php'>Regresar a la página principal</a>");
for ($i=1; $i < ($max+1); $i++)
{
if (trim($_FILES["image" . $i]["name"]) != "") {
$total = $total + 1;
if ( (trim($_POST["tags" . $i]) != "") ) {
$tags = htmlspecialchars(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 ("erdón! El tamaño de la imagen excede el $limit Mb de limite.");
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"];
move_uploaded_file($tempPath, $uploadPath);
}
}
else
die("Perdón ! \"{$_FILES[$name]["name"]}\" es una inválida imagen.");
$imagePath = $uploadPath;
//
$img = imagecreatefromunknown($imagePath);
$mainWidth = imagesx($img);
$mainHeight = imagesy($img);
if (($mainWidth > 1) && ($mainWidth < 4000) && ($mainHeight < 3600))
{
$a = ($mainWidth >= $mainHeight) ? $mainWidth : $mainHeight;
$div = $a / 150;
$thumbWidth = intval($mainWidth / $div);
$thumbHeight = intval($mainHeight / $div);
$myThumb = imagecreatetruecolor($thumbWidth, $thumbHeight);
imagecopyresampled($myThumb, $img, 0, 0, 0, 0, $thumbWidth, $thumbHeight, $mainWidth, $mainHeight);
$thumbPath = "thumbnails/" . basename($imagePath);
imagejpeg($myThumb, $thumbPath);
//*********
$imgMark = imagecreatefromgif("watermark.gif");
$dX = $mainWidth - imagesx($imgMark);
$dY = $mainHeight - imagesy($imgMark);
imagecopymerge($img, $imgMark, $dX, $dY, 0, 0, imagesx($imgMark), imagesy($imgMark), 40);
$ext = findExtension($imagePath);
switch ($ext) {
case "jpg":
imagejpeg($img, $imagePath); break;
case "png":
imagepng($img, $imagePath); break;
}
}
//************************************************** ************************************************** **
$details = intval(filesize($imagePath) / 1024) . " kb (" . $mainWidth . " x " . $mainHeight . ")" ;
$id = md5($thumbPath . date("d-m-y") . time());
//################################################## ################################################## #####
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')";
}
if(!($result_set = mysql_query($q))) die(mysql_error());
echo "<br><br><hr color='#233c9b'><br>";
}
else
echo "Perdón! Imagen \"{$_FILES["image" . $i]["name"]}\" es demasiado pequeño o demasiado grande.<br><hr color='#b1ddf6'>";
}
else
echo "No ha introducido ninguna etiqueta de la imagen \"{$_FILES["image" . $i]["name"]}\" <br><hr color='#b1ddf6'>";
}
}
}
if ($total == 0)
echo "Perdón! Usted debe subir al menos una imagen.";
?>
session_start();
$session = false;
include("db-info.php");
$link = mysql_connect($server, $user, $pass);
if(!mysql_select_db($database)) die(mysql_error());
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(!($result_set = mysql_query($q))) die(mysql_error());
$number = mysql_num_rows($result_set);
if (!$number) {
session_destroy();
$session = false;
}else {
$row = mysql_fetch_row($result_set);
$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'");
$n = mysql_num_rows($result);
if (!$n) die();
$row = mysql_fetch_array($result);
$type = $row['type'];
}
else {
if (isset($_POST["private"]))
$type = "private";
else
$type = "public";
}
}
}
}
else
$session = false;
//************************************************** ***********************************************
?>
<html>
<head>
<title><? echo $webtitle; ?> </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">
<!-- ################################################## ############################################# -->
<?php
function findExtension ($filename)
{
$filename = strtolower($filename) ;
$exts = split("[/\\.]", $filename) ;
$n = count($exts)-1;
$exts = $exts[$n];
return $exts;
}
function imagecreatefromunknown($path) {
$ext = findExtension($path);
switch ($ext) {
case "jpg":
$img = imagecreatefromjpeg($path);
break;
case "gif":
$img = imagecreatefromgif($path);
break;
case "png":
$img = imagecreatefrompng($path);
break;
case "jar":
$img = imagecreatefrompng($path);
break;
}
return $img;
}
$max = 5;
$total = 0;
if (isset($_POST["tags1"])) {
$date = date("d-m-y");
$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'");
$number = mysql_num_rows($result);
if ($number) die("Perdón! Su ha sido bloqueado para cualquier carga de imagen !. <br><br><a href='index.php'>Regresar a la página principal</a>");
for ($i=1; $i < ($max+1); $i++)
{
if (trim($_FILES["image" . $i]["name"]) != "") {
$total = $total + 1;
if ( (trim($_POST["tags" . $i]) != "") ) {
$tags = htmlspecialchars(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 ("erdón! El tamaño de la imagen excede el $limit Mb de limite.");
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"];
move_uploaded_file($tempPath, $uploadPath);
}
}
else
die("Perdón ! \"{$_FILES[$name]["name"]}\" es una inválida imagen.");
$imagePath = $uploadPath;
//
$img = imagecreatefromunknown($imagePath);
$mainWidth = imagesx($img);
$mainHeight = imagesy($img);
if (($mainWidth > 1) && ($mainWidth < 4000) && ($mainHeight < 3600))
{
$a = ($mainWidth >= $mainHeight) ? $mainWidth : $mainHeight;
$div = $a / 150;
$thumbWidth = intval($mainWidth / $div);
$thumbHeight = intval($mainHeight / $div);
$myThumb = imagecreatetruecolor($thumbWidth, $thumbHeight);
imagecopyresampled($myThumb, $img, 0, 0, 0, 0, $thumbWidth, $thumbHeight, $mainWidth, $mainHeight);
$thumbPath = "thumbnails/" . basename($imagePath);
imagejpeg($myThumb, $thumbPath);
//*********
$imgMark = imagecreatefromgif("watermark.gif");
$dX = $mainWidth - imagesx($imgMark);
$dY = $mainHeight - imagesy($imgMark);
imagecopymerge($img, $imgMark, $dX, $dY, 0, 0, imagesx($imgMark), imagesy($imgMark), 40);
$ext = findExtension($imagePath);
switch ($ext) {
case "jpg":
imagejpeg($img, $imagePath); break;
case "png":
imagepng($img, $imagePath); break;
}
}
//************************************************** ************************************************** **
$details = intval(filesize($imagePath) / 1024) . " kb (" . $mainWidth . " x " . $mainHeight . ")" ;
$id = md5($thumbPath . date("d-m-y") . time());
//################################################## ################################################## #####
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')";
}
if(!($result_set = mysql_query($q))) die(mysql_error());
echo "<br><br><hr color='#233c9b'><br>";
}
else
echo "Perdón! Imagen \"{$_FILES["image" . $i]["name"]}\" es demasiado pequeño o demasiado grande.<br><hr color='#b1ddf6'>";
}
else
echo "No ha introducido ninguna etiqueta de la imagen \"{$_FILES["image" . $i]["name"]}\" <br><hr color='#b1ddf6'>";
}
}
}
if ($total == 0)
echo "Perdón! Usted debe subir al menos una imagen.";
?>