<?php
ini_set('include_path',"/usr/web/sites/tuve.tv/include/");
include("site.inc");
$uploaddir = '/usr/web/sites/ubixonline.com/docroot/images/profile/';
$file2 = $_GET['oid'] . ".png";
switch($_FILES['Filedata']['type']) {
case 'image/jpeg':
case 'image/pjpeg':
$orig = imagecreatefromjpeg($_FILES['Filedata']['tmp_name']);
break;
case 'image/png':
$orig = imagecreatefrompng($_FILES['Filedata']['tmp_name']);
break;
case 'image/gif':
$orig = imagecreatefromgif($_FILES['Filedata']['tmp_name']);
break;
default:
$iType = exif_imagetype($_FILES['Filedata']['tmp_name']);
switch ($iType) {
case 1:
$orig = imagecreatefromgif($_FILES['Filedata']['tmp_name']);
break;
case 2:
$orig = imagecreatefromjpeg($_FILES['Filedata']['tmp_name']);
break;
case 3:
$orig = imagecreatefrompng($_FILES['Filedata']['tmp_name']);
break;
default:
system("echo \"Type: $iType\" >> /tmp/boob");
}
}
if ($orig) {
$orig_x = imagesx($orig);
$orig_y = imagesy($orig);
$thumb_x = 300;
$thumb_y = round(($orig_y * $thumb_x) / $orig_x);
$thumb = imagecreatetruecolor($thumb_x,$thumb_y);
imagecopyresampled($thumb, $orig, 0, 0, 0, 0, $thumb_x, $thumb_y, $orig_x, $orig_y);
imagepng($thumb,$uploaddir . $file2);
$oid = $_GET['oid'];
$query = "UPDATE users SET profile_image = 'http://www.ubixonline.com/images/profile/$file2' WHERE uid = $oid";
mysql_query($query);
}
else {
return(false);
}
?>