rendered paste body<?php //Check Auth session_start(); require_once "./dbconnect.php"; $login = mysql_fetch_assoc(mysql_query("SELECT * FROM `dragon_admin` ")); $db_user = $login['user']; $db_pass = $login['pass']; $shift_user = md5($db_user); $session = $_SESSION['username']; if ($session == $shift_user) { //Main Code $photo_location = "img/"; $photo_category = $_POST['gallery']; $unsorted = scandir($photo_location); $upload_filename = $_FILES['uploadedfile']['name']; function createthumb($name,$filename,$new_w,$new_h){ $system=explode('.',$name); if (preg_match('/jpg|jpeg/',$system[1])){ $src_img=imagecreatefromjpeg($name); } if (preg_match('/png/',$system[1])){ $src_img=imagecreatefrompng($name); } $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); } else { imagejpeg($dst_img,$filename); } imagedestroy($dst_img); imagedestroy($src_img); } /*if (ereg(".jpg",$upload_filename) or ereg(".jpeg",$upload_filename)) { $uploadExt = ".jpg"; } elseif (ereg(".png",$upload_filename)) { $uploadExt = ".png"; } else { header( "Location: ?page_name=photo_err"); }*/ $path_info = pathinfo('$upload_filename'); $uploadExt = $path_info['extension']; foreach ($unsorted as $filename) { if(ereg("thumb",$filename) && ereg($photo_category,$filename)) { $images_list[] .= $filename; } } $numImgs = count($images_list); $numImgs++; $target_path = $photo_location; $thumbTarget = "img/thumb_"; $target_path = $target_path . $photo_category . "photo" . $numImgs . $uploadExt; $thumbTarget = $thumbTarget . $photo_category . "photo" . $numImgs . $uploadExt; if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) { createthumb($target_path, $thumbTarget, 275, 206); header( 'Location: ?page_name=photo_conf'); } else { header( 'Location: ?page_name=photo_err'); }?>