$max_weight) {
$err = 'File must be less than ' . $max_weight/1024 . 'Ko.';
// Checking upload dir
} elseif (!file_exists($dir)) {
$err = $dir.' does not exist.';
}
if(isset($err)) {
echo '' . $err . '
Back';
} else {
// Setting extension
if ($_FILES['f']['type'] == 'image/jpeg') { $ext = '.jpg'; }
if ($_FILES['f']['type'] == 'image/png') { $ext = '.png'; }
if ($_FILES['f']['type'] == 'image/gif') { $ext = '.gif'; }
$name = empty($_POST['name']) ?
dechex(time()) :
(file_exists($_POST['name'].$ext) ? $_POST['name'].dechex(time()) : $_POST['name']);
$name = normalize($name);
if (preg_match('/^[a-z0-9_-]+$/', $name)==0) $name = dechex(time());
$filename = $name.$ext;
$fullfilename = $dir.$filename;
// Uploading file
if (move_uploaded_file($_FILES['f']['tmp_name'], $fullfilename)) {
$logline = date("Y-m-d@H:i:s/T")."\t".$_SERVER['REMOTE_ADDR']."\t".$filename."\n";
$log = fopen("uploads.log", "a");
fwrite($log, $logline);
fclose($log);
// if ($_SERVER['REMOTE_ADDR']!=trim(file_get_contents('https://media.gregseth.net/current_ip'))) {
$pagelink = 'https://pix.gregseth.net/0/'.$filename;
$from = 'epiphyte@gregseth.net';
$to = 'greg.seth+imageupload@gmail.com';
$subject = 'A new image has been uploaded on pix.gregseth.net';
$body = '
The log is:
'."\t".$logline.'
The picture is available on '.$pagelink.':
'; $headers = array(); $headers[] = 'MIME-Version: 1.0'; $headers[] = 'Content-type: text/html'; $headers[] = 'From: epiphyte@gregseth.net'; $headers[] = 'Reply-To: epiphyte@gregseth.net'; // $headers[] = 'Subject: '.$subject; $headers[] = 'X-Mailer: PHP/'.phpversion(); mail($to, $subject, $body, implode("\r\n", $headers)); // } header("Location: https://pix.gregseth.net/0/".$name.$ext); } else { echo 'Upload failed!'; } } } elseif (isset($_GET['id']) && isset($_GET['type']) && !empty($_GET['size'])) { $img=$dir.$_GET['id'].'.'.$_GET['type']; $type=str_replace('jpg','jpeg',$_GET['type']); $imgcr='imagecreatefrom'.$type; $imgecho='image'.$type; $src = (file_exists($img)) ? $imgcr($img) : imagecreatefromjpeg('404.jpg'); $sx = imagesx($src); $sy = imagesy($src); if (max($sx, $sy) <= $_GET['size']) { $dx = $sx; $dy = $sy; } else { $r=$sx/$sy; $dx = round($_GET['size'] * (($sx > $sy) ? 1 : $r)); $dy = round($_GET['size'] * (($sx > $sy) ? 1/$r : 1)); } $dest=imagecreatetruecolor($dx, $dy); if ($type=='png'||$type=='gif') { imagealphablending($dest, false); imagesavealpha($dest, true); } imagecopyresampled($dest, $src, 0, 0, 0, 0, $dx, $dy, $sx, $sy); header("Content-type: image/".$type); $imgecho($dest); exit; } elseif (isset($_GET['size']) && ($_GET['size']==0)) { $page = 'display'; } function getUrl ($size='') { $size = ($size==='') ? '' : $size.'/'; return 'https://pix.gregseth.net/'.$size.$_GET['id'].'.'.$_GET['type']; } ?>This picture hosting service comes with no warranty. That is the availability of the picture you upload is not guaranteed by any means, and can be deleted at any moment.
Your IP address is logged and linked with every upload.