require (AT_INCLUDE_PATH.'vitals.inc.php');\r
$member_id = $_SESSION['member_id'];\r
$_custom_css = $_base_path . AT_SOCIAL_BASENAME . 'module.css'; // use a custom stylesheet\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'] || $gd_info['JPEG 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
+$savant->assign('member_id', $member_id);\r
+$savant->assign('supported_images', $supported_images);\r
$savant->display('social/profile_picture.html.php');\r
-//require('profile_picture.html.php'); ?>
\ No newline at end of file
+require(AT_INCLUDE_PATH.'footer.inc.php'); \r
+?>
\ No newline at end of file
/* as published by the Free Software Foundation. */\r
/************************************************************************/\r
// $Id: profile_picture.html.php 9418 2010-03-03 16:39:24Z greg $\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'] || $gd_info['JPEG 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
+if (!defined('AT_INCLUDE_PATH')) { exit; } ?>\r
<div class="social-wrapper">\r
<?php include("lib/profile_menu.inc.php") ?>\r
<br />\r
-<form method="post" enctype="multipart/form-data" action="<?php echo $_SERVER['PHP_SELF']; ?>?member_id=<?php echo $member_id; ?>" name="form">\r
+<form method="post" enctype="multipart/form-data" action="<?php echo $_SERVER['PHP_SELF']; ?>?member_id=<?php echo $this->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
+<?php if (profile_image_exists($this->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
+ <a href="get_profile_img.php?id=<?php echo $this->member_id.SEP.'size=o'; ?>"><img src="get_profile_img.php?id=<?php echo $this->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><label for="upload_picture"><?php echo _AT('upload_new_picture'); ?></label></h3>\r
- <input type="file" name="file" id="upload_picture"/> (<?php echo implode(', ', $supported_images); ?>)</div>\r
+ <input type="file" name="file" id="upload_picture"/> (<?php echo implode(', ', $this->supported_images); ?>)</div>\r
\r
<div class="row buttons">\r
<input type="submit" name="submit" value="<?php echo _AT('save'); ?>" />\r
</form>\r
<div style="clear:both;"></div>\r
</div>\r
-<?php require(AT_INCLUDE_PATH.'footer.inc.php'); ?>
\ No newline at end of file