+++ /dev/null
-<?php\r
-/************************************************************************/\r
-/* ATutor */\r
-/************************************************************************/\r
-/* Copyright (c) 2002-2008 by Greg Gay, Joel Kronenberg & Heidi Hazelton*/\r
-/* Adaptive Technology Resource Centre / University of Toronto */\r
-/* http://atutor.ca */\r
-/* */\r
-/* This program is free software. You can redistribute it and/or */\r
-/* modify it under the terms of the GNU General Public License */\r
-/* as published by the Free Software Foundation. */\r
-/************************************************************************/\r
-// $Id$\r
-if (!defined('AT_INCLUDE_PATH')) { exit; }\r
-\r
-function resize_image($src, $dest, $src_h, $src_w, $dest_h, $dest_w, $type, $src_x=0, $src_y=0) {\r
- $thumbnail_img = imagecreatetruecolor($dest_w, $dest_h);\r
-\r
- if ($type == 'gif') {\r
- $source = imagecreatefromgif($src);\r
- } else if ($type == 'jpg') {\r
- $source = imagecreatefromjpeg($src);\r
- } else {\r
- $source = imagecreatefrompng($src);\r
- }\r
- \r
- if ($src_x > 0 || $src_y > 0){\r
- imagecopyresized($thumbnail_img, $source, 0, 0, $src_x, $src_y, $dest_w, $dest_h, $src_w, $src_h);\r
- } else {\r
- imagecopyresampled($thumbnail_img, $source, $src_x, $src_y, 0, 0, $dest_w, $dest_h, $src_w, $src_h);\r
- }\r
-\r
- if ($type == 'gif') {\r
- imagegif($thumbnail_img, $dest);\r
- } else if ($type == 'jpg') {\r
- imagejpeg($thumbnail_img, $dest, 75);\r
- } else {\r
- imagepng($thumbnail_img, $dest, 7);\r
- }\r
-}\r
-\r
-// check if GD is installed\r
-if (!extension_loaded('gd')) {\r
- require(AT_INCLUDE_PATH.'header.inc.php');\r
- $msg->printInfos('FEATURE_NOT_AVAILABLE');\r
- require(AT_INCLUDE_PATH.'footer.inc.php');\r
- exit;\r
-}\r
-\r
-// check if folder exists, if not, create it\r
-if (!is_dir(AT_CONTENT_DIR.'/profile_pictures/profile')) {\r
- mkdir(AT_CONTENT_DIR.'/profile_pictures/profile');\r
-}\r
-\r
-$gd_info = gd_info();\r
-$supported_images = array();\r
-if ($gd_info['GIF Create Support']) {\r
- $supported_images[] = 'gif';\r
-}\r
-if ($gd_info['JPG Support']) {\r
- $supported_images[] = 'jpg';\r
-}\r
-if ($gd_info['PNG Support']) {\r
- $supported_images[] = 'png';\r
-}\r
-\r
-if (!$supported_images) {\r
- require(AT_INCLUDE_PATH.'header.inc.php');\r
- $msg->printInfos('FEATURE_NOT_AVAILABLE');\r
- require(AT_INCLUDE_PATH.'footer.inc.php');\r
- exit;\r
-}\r
-\r
-if (isset($_POST['cancel'])) {\r
- $msg->addFeedback('CANCELLED');\r
- header('Location: '.$_SERVER['PHP_SELF'].'?member_id='.$member_id);\r
- exit;\r
-} else if (isset($_POST['submit'])) {\r
- if (isset($_POST['delete']) && !$_FILES['file']['size']) {\r
- profile_image_delete($member_id);\r
-\r
- $msg->addFeedback('PROFILE_UPDATED');\r
-\r
- header('Location: '.$_SERVER['PHP_SELF'].'?member_id='.$member_id);\r
- exit;\r
- } else if ($_FILES['file']['error'] == UPLOAD_ERR_FORM_SIZE) {\r
- $msg->addError(array('FILE_MAX_SIZE', $_config['prof_pic_max_file_size'] . ' ' . _AT('bytes')));\r
- header('Location: '.$_SERVER['PHP_SELF'].'?member_id='.$member_id);\r
- exit;\r
- } else if (!$_FILES['file']['size']) {\r
- header('Location: '.$_SERVER['PHP_SELF'].'?member_id='.$member_id);\r
- exit;\r
- }\r
-\r
- // check if this is a supported file type\r
- $filename = $stripslashes($_FILES['file']['name']);\r
- $path_parts = pathinfo($filename);\r
- $extension = strtolower($path_parts['extension']);\r
- $image_attributes = getimagesize($_FILES['file']['tmp_name']);\r
-\r
- if ($extension == 'jpeg') {\r
- $extension = 'jpg';\r
- }\r
-\r
- if (!in_array($extension, $supported_images)) {\r
- $msg->addError(array('FILE_ILLEGAL', $extension));\r
- header('Location: '.$_SERVER['PHP_SELF'].'?member_id='.$member_id);\r
- exit;\r
- } else if ($image_attributes[2] > IMAGETYPE_PNG) {\r
- $msg->addError(array('FILE_ILLEGAL', $extension));\r
- header('Location: '.$_SERVER['PHP_SELF'].'?member_id='.$member_id);\r
- exit;\r
- }\r
-\r
- // make sure under max file size\r
- if ($_FILES['file']['size'] > $_config['prof_pic_max_file_size']) {\r
- $msg->addError('FILE_MAX_SIZE');\r
- header('Location: '.$_SERVER['PHP_SELF'].'?member_id='.$member_id);\r
- exit;\r
- }\r
-\r
- // delete the old images (if any)\r
- profile_image_delete($member_id);\r
-\r
- $new_filename = $member_id . '.' . $extension;\r
- $original_img = AT_CONTENT_DIR.'profile_pictures/originals/'. $new_filename;\r
- $profile_img = AT_CONTENT_DIR.'profile_pictures/profile/'. $new_filename;\r
- $thumbnail_img = AT_CONTENT_DIR.'profile_pictures/thumbs/'. $new_filename;\r
-\r
- // save original\r
- if (!move_uploaded_file($_FILES['file']['tmp_name'], $original_img)) {\r
- $msg->addError('CANNOT_OVERWRITE_FILE');\r
- header('Location: '.$_SERVER['PHP_SELF'].'?member_id='.$member_id);\r
- exit;\r
- }\r
-\r
- // resize the original and save it at $thumbnail_file\r
- $width = $image_attributes[0];\r
- $height = $image_attributes[1];\r
-\r
- $thumbnail_fixed_height = 60; \r
- $thumbnail_fixed_width = 60; \r
-\r
- if ($width > $height && $height > $thumbnail_fixed_height) {\r
- $thumbnail_height= $thumbnail_fixed_height;\r
- $thumbnail_width = intval($thumbnail_fixed_height * $width / $height);\r
- resize_image($original_img, $thumbnail_img, $height, $width, $thumbnail_height, $thumbnail_width, $extension);\r
- //cropping\r
- resize_image($thumbnail_img, $thumbnail_img, $thumbnail_fixed_height, $thumbnail_fixed_width, $thumbnail_fixed_height, $thumbnail_fixed_width, $extension, ($thumbnail_width-$thumbnail_fixed_width)/2);\r
- } else if ($width <= $height && $width>$thumbnail_fixed_width) {\r
- $thumbnail_height = intval($thumbnail_fixed_width * $height / $width);\r
- $thumbnail_width = $thumbnail_fixed_width;\r
- resize_image($original_img, $thumbnail_img, $height, $width, $thumbnail_height, $thumbnail_width, $extension);\r
- //cropping\r
- resize_image($thumbnail_img, $thumbnail_img, $thumbnail_fixed_height, $thumbnail_fixed_width, $thumbnail_fixed_height, $thumbnail_fixed_width, $extension, 0, ($thumbnail_height-$thumbnail_fixed_height)/2);\r
- } else {\r
- // no resizing, just copy the image.\r
- // it's too small to resize.\r
- copy($original_img, $thumbnail_img);\r
- }\r
-\r
- // resize the original and save it to profile\r
- $profile_fixed_height = 320;\r
- $profile_fixed_width = 240;\r
- if ($width > $height && $height>$profile_fixed_height) {\r
- $profile_width = intval($profile_fixed_height * $width / $height);\r
- $profile_height = $profile_fixed_height;\r
- resize_image($original_img, $profile_img, $height, $width, $profile_height, $profile_width, $extension);\r
- //cropping\r
- resize_image($profile_img, $profile_img, $profile_fixed_height, $profile_fixed_width, $profile_fixed_height, $profile_fixed_width, $extension, ($profile_width-$profile_fixed_width)/2);\r
- } else if ($width <= $height && $width > $profile_fixed_width) {\r
- $profile_width = $profile_fixed_width;\r
- $profile_height = intval($profile_fixed_width * $height / $width);\r
- resize_image($original_img, $profile_img, $height, $width, $profile_height, $profile_width, $extension);\r
- //cropping\r
- resize_image($profile_img, $profile_img, $profile_fixed_height, $profile_fixed_width, $profile_fixed_height, $profile_fixed_width, $extension, 0, ($profile_height-$profile_fixed_height)/2);\r
- } else {\r
- // no resizing, just copy the image.\r
- // it's too small to resize.\r
- copy($original_img, $profile_img);\r
- }\r
-\r
- $msg->addFeedback('PROFILE_UPDATED');\r
-\r
- header('Location: '.$_SERVER['PHP_SELF'].'?member_id='.$member_id);\r
- exit;\r
-}\r
-\r
-require(AT_INCLUDE_PATH.'header.inc.php');\r
-\r
-?>\r
-<?php include("lib/profile_menu.inc.php") ?>\r
-<form method="post" enctype="multipart/form-data" action="<?php echo $_SERVER['PHP_SELF']; ?>?member_id=<?php echo $member_id; ?>" name="form">\r
-<input type="hidden" name="MAX_FILE_SIZE" value="<?php echo $_config['prof_pic_max_file_size']; ?>" />\r
-<div class="input-form">\r
-<?php if (profile_image_exists($member_id)): ?>\r
- <div class="row">\r
- <a href="get_profile_img.php?id=<?php echo $member_id.SEP.'size=o'; ?>"><img src="get_profile_img.php?id=<?php echo $member_id; ?>" alt="" /></a>\r
- <input type="checkbox" name="delete" value="1" id="del"/><label for="del"><?php echo _AT('delete'); ?></label>\r
- </div>\r
-<?php endif; ?>\r
- <div class="row">\r
- <h3><?php echo _AT('upload_new_picture'); ?></h3>\r
- <input type="file" name="file" /> (<?php echo implode(', ', $supported_images); ?>)</div>\r
-\r
- <div class="row buttons">\r
- <input type="submit" name="submit" value="<?php echo _AT('save'); ?>" />\r
- <input type="submit" name="cancel" value="<?php echo _AT('cancel'); ?>" />\r
- </div>\r
-</div>\r
-</form>\r
-\r
-<?php require(AT_INCLUDE_PATH.'footer.inc.php'); ?>
\ No newline at end of file