CODE
<?
require "include/functions.php";
$title2 = "Upload";
include("header.php");
$sesusername = $_COOKIE['imgu_username'];
$uid = $_COOKIE['imgu_uid'];
$leftsize = 0;
$sizeleft2 = 0;
if (!isset($HTTP_POST_FILES['userfile'])) exit;
if (is_uploaded_file($HTTP_POST_FILES['userfile']['tmp_name'])) {
$filesize = $HTTP_POST_FILES['userfile']['size'];
if ($HTTP_POST_FILES['userfile']['size']>$max_size) {
echo "<font color=\"#333333\" face=\"Geneva, Arial, Helvetica, sans-serif\">File Size too Big!</font><br>\n"; exit; }
if ($HTTP_POST_FILES['userfile']['type']=="image/gif") {
$type = ".gif";
}
if ($HTTP_POST_FILES['userfile']['type']=="image/pjpeg") {
$type = ".jpg";
}
if ($HTTP_POST_FILES['userfile']['type']=="image/jpeg") {
$type = ".jpeg";
}
if ($HTTP_POST_FILES['userfile']['type']=="image/png") {
$type = ".png";
}
/*
if ($HTTP_POST_FILES['userfile']['type']=="application/x-shockwave-flash") {
$type = ".swf";
$tnFileUrl = "http://imgupload.eu/image/swf.png";
}
if ($HTTP_POST_FILES['userfile']['type']=="image/bmp") {
$type = ".bmp";
}
if ($HTTP_POST_FILES['userfile']['type']=="application/pdf") {
$type = ".pdf";
$tnFileUrl = "http://imgupload.eu/image/pdf.png";
}
if ($HTTP_POST_FILES['userfile']['type']=="application/x-compressed") {
$type = ".zip";
$tnFileUrl = "http://imgupload.eu/image/zip.png";
}
if (file_exists("./".$path . $HTTP_POST_FILES['userfile']['name'])) {
echo "<font color=\"#333333\" face=\"Geneva, Arial, Helvetica, sans-serif\">A File with that name exists, please rename your file.</font><br>\n"; exit; }
*/
//SQL stuff
list($width, $height, $attr) = array_values(getimagesize($HTTP_POST_FILES['userfile']['tmp_name']));
$added = sqlesc(get_date_time());
if($loggedin){
mysql_query("INSERT INTO img (username, uid, size, width, height, type, date) VALUES('$sesusername', '$uid', '$filesize', '$width', '$height', '$type', $added)") or sqlerr(__FILE__, __LINE__);
} else {
mysql_query("INSERT INTO img (size, width, height, type, date) VALUES($filesize, $width, $height, '$type', $added)") or sqlerr(__FILE__, __LINE__);;
}
$id = mysql_insert_id();
$zufall = "$id";
//$zufall = rand(1,9999999999);
$fupl = "$zufall";
$res = copy($HTTP_POST_FILES['userfile']['tmp_name'], "./".$path .$fupl .$type);
if (!$res) { echo "<font color=\"#333333\" face=\"Geneva, Arial, Helvetica, sans-serif\">Upload Failed, please try again</font><br>\n"; exit; } else {
print ("<br>");
//set url variable
$domst = "";
$drecks = "/";
$imgf = $fupl .$type;
$thbf = $tpath.$imgf;
$urlf = $domst .$domain .$drecks .$path .$imgf;
//create thumbnails
function createthumb($name,$filename,$new_w,$new_h){
$system=explode('.',$name);
if (preg_match('/jpg|jpeg|JPG/',$system[1])){
$src_img=imagecreatefromjpeg($name);
}
if (preg_match('/png|PNG/',$system[1])){
$src_img=imagecreatefrompng($name);
}
if (preg_match('/gif|GIF/',$system[1])){
$src_img=imagecreatefromgif($name);
}
$old_x=imageSX($src_img);
$old_y=imageSY($src_img);
if ($old_x > $old_y) {
$thumb_w=$new_w;
$thumb_h=$old_y*($new_h/$old_x);
}
if ($old_x < $old_y) {
$thumb_w=$old_x*($new_w/$old_y);
$thumb_h=$new_h;
}
if ($old_x == $old_y) {
$thumb_w=$new_w;
$thumb_h=$new_h;
}
$dst_img=ImageCreateTrueColor($thumb_w,$thumb_h);
imagecopyresampled($dst_img,$src_img,0,0,0,0,$thumb_w,$thumb_h,$old_x,$old_y);
if (preg_match("/png/",$system[1]))
{
imagepng($dst_img,$filename);
}
if (preg_match("/gif/",$system[1]))
{
imagegif($dst_img,$filename);
}
else {
imagejpeg($dst_img,$filename);
}
imagedestroy($dst_img);
imagedestroy($src_img);
}
createthumb($path.$imgf,$tpath.$imgf,$tsize,$tsize);
write_log("Image $id was uploaded");
if ($loggedin) {
$sqls = mysql_query("SELECT * FROM users WHERE username='$sesusername'") or sqlerr(__FILE__, __LINE__);
$user_info = mysql_fetch_assoc($sqls) or sqlerr(__FILE__, __LINE__);
$leftsize = $user_info[size];
$images = $user_info[images];
$images++;
if ($leftsize <= 0) {
die ("You don't have enought disk space to upload this picture. You can buy space from <a href=\"buy.php\">here</a> or <a href=\"deleteimage.php\">delete</a> old pictures."); }
$sizeleft = $leftsize - $filesize;
mysql_query("UPDATE users SET size='$sizeleft', images='$images' WHERE id='$user_info[id]'") or sqlerr(__FILE__, __LINE__);} else{ echo'';}
?><div id="content_container">
<div class="content">
<p class="item_top">Code for image <?=$imgf;?></p>
<a href="<? echo $domst .$domain .$drecks ?>viewer.php?id=<? echo $imgf; ?>"><b>See</b></a> the image.
Please don't change any codes while linking!
<br>
Please use clickable thumbnail codes (they save ImgUpload's bandwidth):
<input name="thetext" type="text" id="thetext" style="width: 500px;" onClick="highlight(this);" value="<a href=<? echo $domst .$domain .$drecks; ?>viewer.php?id=<? echo $imgf; ?>><img src=<? echo $domst.$domain.$drecks.$tpath.$imgf; ?>></a>" size="70">
Thumbnail for Websites <br>
<input name="thetext" type="text" id="thetext" style="width: 500px;" onClick="highlight(this);" value="[URL=<? echo $domst .$domain .$drecks; ?>viewer.php?id=<? echo $imgf; ?>][IMG]<? echo $domst.$domain.$drecks.$tpath.$imgf; ?>[/IMG][/URL]" size="70">
Thumbnail for forum(1)<br>
<input name="thetext" type="text" id="thetext" style="width: 500px;" onClick="highlight(this);" value="[url=<? echo $domst .$domain .$drecks; ?>viewer.php?id=<? echo $imgf; ?>][img]<? echo $domst.$domain.$drecks.$tpath.$imgf; ?>[/img][/url]" size="70">
Thumbnail for forum(2)<br>
<input onClick="highlight(this);" style="width: 300px;" size="70" value="Thanks to ImgUpload for [URL=http://ImgUpload.eu]Free Image Hosting[/URL]" type="text">
Link back to ImgUpload or use the <a href="links.php"><b>banners and buttons</b></a>.
<table border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td>
<br>
<a href='viewer.php?id=<? echo $imgf; ?>'><img src='<? echo $thbf ?>' border="0"></a>
</td>
</tr>
</tbody>
</table>
<br>
<input name="thetext" type="text" id="thetext" style="width: 500px;" onClick="highlight(this);" value="[URL=http://ImgUpload.eu][IMG]<? echo $urlf; ?>[/IMG][/URL]" size="70">
Hotlink for forums (1)
<br>
<input name="thetext" type="text" id="thetext" style="width: 500px;" onClick="highlight(this);" value="[url=http://ImgUpload.eu][img]<? echo $urlf; ?>[/img][/url]" size="70">
Hotlink for forums (2)
<br>
<input name="thetext" type="text" id="thetext" style="width: 500px;" onClick="highlight(this);" value="<a href="http://ImgUpload.eu"><img src="<? echo $urlf; ?>" border="0" alt="Image Hosted by ImgUpload.NET" /></a>" size="70">
Hotlink for Websites
<br>
<input name="thetext" type="text" id="thetext" style="width: 500px;" onClick="highlight(this);" value="<? echo $domst .$domain .$drecks ?>viewer.php?id=<? echo $imgf; ?>" size="70">
<a href="<? echo $domst .$domain .$drecks ?>viewer.php?id=<? echo $imgf; ?>"><b>Show</b></a> image to friends<br>
<input name="thetext" type="text" id="thetext" style="width: 500px;" onClick="highlight(this);" value="<? echo $urlf; ?>" size="70">
Direct link to image
<br>
<br>
</div>
<? include("footer.php");
}
} else { echo "<font color=\"#333333\" face=\"Geneva, Arial, Helvetica, sans-serif\">Sorry we don't allow that file type.!</font><br>\n"; exit; }
?>