diff --git a/e107_admin/admin.php b/e107_admin/admin.php index bdccd469c..6db164577 100644 --- a/e107_admin/admin.php +++ b/e107_admin/admin.php @@ -105,7 +105,7 @@ if (count($allowed_types) == 0) //echo "Allowed filetypes = ".implode(', ',array_keys($allowed_types)).'
'; // avatar check. -$public = array(e_UPLOAD, e_UPLOAD.'avatars'); +$public = array(e_UPLOAD, e_AVATAR_UPLOAD); $exceptions = array(".","..","/","CVS","avatars","Thumbs.db",".ftpquota",".htaccess","php.ini",".cvsignore",'e107.htaccess'); //TODO use $file-class to grab list and perform this check. diff --git a/e107_admin/image.php b/e107_admin/image.php index 2f48723d3..071e2205e 100644 --- a/e107_admin/image.php +++ b/e107_admin/image.php @@ -2032,10 +2032,11 @@ if (isset($_POST['submit_show_delete_multi'])) */ if (isset($_POST['submit_show_deleteall'])) { - $handle = opendir(e_UPLOAD."avatars/"); + $handle = opendir(e_AVATAR_UPLOAD); $dirlist = array(); - while ($file = readdir($handle)) { - if (!is_dir(e_UPLOAD."avatars/{$file}") && $file != '.' && $file != '..' && $file != "index.html" && $file != "null.txt" && $file != '/' && $file != 'CVS' && $file != 'Thumbs.db') { + while ($file = readdir($handle)) + { + if (!is_dir(e_AVATAR_UPLOAD.$file) && $file != '.' && $file != '..' && $file != "index.html" && $file != "null.txt" && $file != '/' && $file != 'CVS' && $file != 'Thumbs.db') { $dirlist[] = $file; } } @@ -2050,7 +2051,7 @@ if (isset($_POST['submit_show_deleteall'])) $image_name = basename($image_name); $image_todb = $tp->toDB($image_name); if (!$sql->db_Count('user', '(*)', "WHERE user_image='-upload-{$image_todb}' OR user_sess='{$image_todb}'")) { - unlink(e_UPLOAD."avatars/".$image_name); + unlink(e_AVATAR_UPLOAD.$image_name); $imgList .= '[!br!]'.$image_name; $count++; } diff --git a/e107_admin/update_routines.php b/e107_admin/update_routines.php index cb0d00a74..35dc45cca 100644 --- a/e107_admin/update_routines.php +++ b/e107_admin/update_routines.php @@ -1151,7 +1151,7 @@ function update_706_to_800($type='') $root_media = str_replace(basename(e_MEDIA)."/","",e_MEDIA); - $user_media_dirs = array("images","avatars", "avatars/default", "avatars/uploaded", "files","temp","videos","icons"); + $user_media_dirs = array("images","avatars", "avatars/default", "avatars/upload", "files","temp","videos","icons"); // check for old paths and rename. if(is_dir($root_media."images") || is_dir($root_media."temp")) @@ -1185,9 +1185,9 @@ function update_706_to_800($type='') if ($just_check) return update_needed('Avatar paths require updating.'); foreach($avatar_images as $av) { - $apath = (strstr($av['path'],'public/')) ? 'uploaded/' : 'default/'; + $apath = (strstr($av['path'],'public/')) ? e_AVATAR_UPLOAD : e_AVATAR_DEFAULT; - @rename($av['path'].$av['fname'],e_MEDIA."avatars/".$apath. $av['fname']); + @rename($av['path'].$av['fname'], $apath. $av['fname']); } } diff --git a/e107_core/shortcodes/single/picture.sc b/e107_core/shortcodes/single/picture.sc index 3f452414a..b18240d09 100644 --- a/e107_core/shortcodes/single/picture.sc +++ b/e107_core/shortcodes/single/picture.sc @@ -24,11 +24,5 @@ else { $image = USERPHOTO; } -if($image && file_exists(e_MEDIA_AVATAR.$image)) -{ - return ""; -} -else -{ - return ""; -} + +return e107::getParser()->parseTemplate("{USER_AVATAR=".$image."}",true); diff --git a/e107_core/shortcodes/single/user_avatar.php b/e107_core/shortcodes/single/user_avatar.php index b2bef75a9..78a5afcdc 100644 --- a/e107_core/shortcodes/single/user_avatar.php +++ b/e107_core/shortcodes/single/user_avatar.php @@ -42,16 +42,31 @@ function user_avatar_shortcode($parm='') if (vartrue($image)) { - $img = (strpos($image,"://")!==false) ? $image : $tp->thumbUrl(e_MEDIA."avatars/".$image,"w=".$width."&h=".$height); - $text = " - "; + + if(strpos($image,"://")!==false) // Remove Image + { + $img = $image; + } + elseif(file_exists(e_AVATAR_DEFAULT.$image)) // Local Default Image + { + $img = $tp->thumbUrl(e_AVATAR_DEFAULT.$image,"w=".$width."&h=".$height,true); + } + elseif(file_exists(e_AVATAR_UPLOAD.$image)) // User-Uplaoded Image + { + $img = $tp->thumbUrl(e_AVATAR_UPLOAD.$image,"w=".$width."&h=".$height,true); + } + else // Image Missing. + { + $img = $tp->thumbUrl(e_IMAGE."generic/blank_avatar.jpg","w=".$width."&h=".$height,true); + } } - else + else // No image provided - so send generic. { - $img = $tp->thumbUrl(e_IMAGE."generic/blank_avatar.jpg","w=".$width."&h=".$height); - $text = ""; + $img = $tp->thumbUrl(e_IMAGE."generic/blank_avatar.jpg","w=".$width."&h=".$height,true); } + $text = ""; +// return $img; return $text; } diff --git a/e107_handlers/avatar_handler.php b/e107_handlers/avatar_handler.php index ebf3f6a22..f1f4dc849 100644 --- a/e107_handlers/avatar_handler.php +++ b/e107_handlers/avatar_handler.php @@ -18,10 +18,14 @@ if (!defined('e107_INIT')) function avatar($avatar) { + + return e107::getParser()->parseTemplate("{USER_AVATAR=".$avatar."}",true); + + global $tp; if (stristr($avatar, '-upload-') !== false) { - return e_UPLOAD.'avatars/'.str_replace('-upload-', '', $avatar); + return e_AVATAR_UPLOAD.str_replace('-upload-', '', $avatar); } elseif (stristr($avatar, 'Binary') !== false) { diff --git a/e107_handlers/e107_class.php b/e107_handlers/e107_class.php index eaa1a3745..26faa2184 100644 --- a/e107_handlers/e107_class.php +++ b/e107_handlers/e107_class.php @@ -440,10 +440,11 @@ class e107 $ret['MEDIA_IMAGES_DIRECTORY'] = $ret['MEDIA_DIRECTORY'].'images/'; $ret['MEDIA_ICONS_DIRECTORY'] = $ret['MEDIA_DIRECTORY'].'icons/'; - $ret['MEDIA_AVATARS_DIRECTORY'] = $ret['MEDIA_DIRECTORY'].'avatars/'; + $ret['MEDIA_VIDEOS_DIRECTORY'] = $ret['MEDIA_DIRECTORY'].'videos/'; $ret['MEDIA_FILES_DIRECTORY'] = $ret['MEDIA_DIRECTORY'].'files/'; $ret['MEDIA_UPLOAD_DIRECTORY'] = $ret['SYSTEM_DIRECTORY'].'temp/'; // security measure. Media is public, system is private. + $ret['AVATARS_DIRECTORY'] = $ret['MEDIA_DIRECTORY'].'avatars/'; $ret['WEB_JS_DIRECTORY'] = $ret['WEB_DIRECTORY'].'js/'; // $ret['WEB_JS_DIRECTORY'] = $ret['FILES_DIRECTORY'].'jslib/'; @@ -461,6 +462,9 @@ class e107 $ret['CACHE_IMAGE_DIRECTORY'] = $ret['CACHE_DIRECTORY'].'images/'; $ret['CACHE_DB_DIRECTORY'] = $ret['CACHE_DIRECTORY'].'db/'; $ret['CACHE_URL_DIRECTORY'] = $ret['CACHE_DIRECTORY'].'url/'; + + $ret['AVATARS_UPLOAD_DIRECTORY'] = $ret['AVATARS_DIRECTORY'].'upload/'; + $ret['AVATARS_DEFAULT_DIRECTORY'] = $ret['AVATARS_DIRECTORY'].'default/'; $ret['LOGS_DIRECTORY'] = $ret['SYSTEM_DIRECTORY'].'logs/'; $ret['BACKUP_DIRECTORY'] = $ret['SYSTEM_DIRECTORY'].'backup/'; @@ -2819,7 +2823,7 @@ class e107 define('e_MEDIA_VIDEO', $this->get_override_rel('MEDIA_VIDEOS')); define('e_MEDIA_IMAGE', $this->get_override_rel('MEDIA_IMAGES')); define('e_MEDIA_ICON', $this->get_override_rel('MEDIA_ICONS')); - define('e_MEDIA_AVATAR', $this->get_override_rel('MEDIA_AVATARS')); + // define('e_MEDIA_AVATAR', $this->get_override_rel('MEDIA_AVATARS')); define('e_DOWNLOAD', $this->get_override_rel('DOWNLOADS')); define('e_UPLOAD', $this->get_override_rel('UPLOADS')); @@ -2864,10 +2868,15 @@ class e107 define('e_MEDIA_VIDEO_ABS', $this->get_override_http('MEDIA_VIDEOS')); define('e_MEDIA_IMAGE_ABS', $this->get_override_http('MEDIA_IMAGES')); define('e_MEDIA_ICON_ABS', $this->get_override_http('MEDIA_ICONS')); - define('e_MEDIA_AVATAR_ABS', $this->get_override_http('MEDIA_AVATARS')); + // define('e_MEDIA_AVATAR_ABS', $this->get_override_http('MEDIA_AVATARS')); + + + // XXX DISCUSSS - e_JS_ABS, e_CSS_ABS etc is not following the naming standards but they're more usable. // Example: e_JS_ABS vs e_WEB_JS_ABS + + //XXX Absolute is assumed. define('e_WEB_ABS', $this->get_override_http('WEB')); define('e_JS_ABS', $this->get_override_http('WEB_JS')); define('e_CSS_ABS', $this->get_override_http('WEB_CSS')); @@ -2876,6 +2885,15 @@ class e107 define('e_JS', $this->get_override_http('WEB_JS')); // ABS Alias define('e_CSS', $this->get_override_http('WEB_CSS')); // ABS Alias + + define('e_AVATAR', $this->get_override_rel('AVATARS')); + define('e_AVATAR_UPLOAD', $this->get_override_rel('AVATARS_UPLOAD')); + define('e_AVATAR_DEFAULT', $this->get_override_rel('AVATARS_DEFAULT')); + + define('e_AVATAR_ABS', $this->get_override_http('AVATARS')); + define('e_AVATAR_UPLOAD_ABS', $this->get_override_http('AVATARS_UPLOAD')); + define('e_AVATAR_DEFAULT_ABS', $this->get_override_http('AVATARS_DEFAULT')); + } return $this; diff --git a/e107_handlers/e_parse_class.php b/e107_handlers/e_parse_class.php index 654fb2ffe..cf662d175 100644 --- a/e107_handlers/e_parse_class.php +++ b/e107_handlers/e_parse_class.php @@ -1889,7 +1889,7 @@ class e_parse extends e_parser 'e_MEDIA_VIDEO/' => '{e_MEDIA_VIDEO}', 'e_MEDIA_IMAGE/' => '{e_MEDIA_IMAGE}', 'e_MEDIA_ICON/' => '{e_MEDIA_ICON}', - 'e_MEDIA_AVATAR/' => '{e_MEDIA_AVATAR}', + 'e_AVATAR/' => '{e_AVATAR}', 'e_WEB_JS/' => '{e_WEB_JS}', 'e_WEB_CSS/' => '{e_WEB_CSS}', 'e_WEB_IMAGE/' => '{e_WEB_IMAGE}', @@ -1950,7 +1950,7 @@ class e_parse extends e_parser $e107->getFolder('media_video'), $e107->getFolder('media_image'), $e107->getFolder('media_icon'), - $e107->getFolder('media_avatar'), + $e107->getFolder('avatars'), $e107->getFolder('web_js'), $e107->getFolder('web_css'), $e107->getFolder('web_image'), @@ -1981,7 +1981,7 @@ class e_parse extends e_parser e_MEDIA_VIDEO_ABS, e_MEDIA_IMAGE_ABS, e_MEDIA_ICON_ABS, - e_MEDIA_AVATAR_ABS, + e_AVATAR_ABS, e_JS_ABS, e_CSS_ABS, e_WEB_IMAGE_ABS, @@ -2011,7 +2011,7 @@ class e_parse extends e_parser SITEURLBASE.e_MEDIA_VIDEO_ABS, SITEURLBASE.e_MEDIA_IMAGE_ABS, SITEURLBASE.e_MEDIA_ICON_ABS, - SITEURLBASE.e_MEDIA_AVATAR_ABS, + SITEURLBASE.e_AVATAR_ABS, SITEURLBASE.e_JS_ABS, SITEURLBASE.e_CSS_ABS, SITEURLBASE.e_WEB_IMAGE_ABS, @@ -2041,7 +2041,7 @@ class e_parse extends e_parser '{e_MEDIA_VIDEO}', '{e_MEDIA_IMAGE}', '{e_MEDIA_ICON}', - '{e_MEDIA_AVATAR}', + '{e_AVATAR}', '{e_WEB_JS}', '{e_WEB_CSS}', '{e_WEB_IMAGE}', @@ -2166,7 +2166,7 @@ class e_parse extends e_parser '{e_MEDIA_VIDEO}' => $e107->getFolder('media_videos'), '{e_MEDIA_IMAGE}' => $e107->getFolder('media_images'), '{e_MEDIA_ICON}' => $e107->getFolder('media_icons'), - '{e_MEDIA_AVATAR}' => $e107->getFolder('media_avatars'), + '{e_AVATAR}' => $e107->getFolder('avatars'), '{e_WEB_JS}' => $e107->getFolder('web_js'), '{e_WEB_CSS}' => $e107->getFolder('web_css'), '{e_WEB_IMAGE}' => $e107->getFolder('web_images'), @@ -2194,7 +2194,7 @@ class e_parse extends e_parser '{e_MEDIA_VIDEO}' => e_MEDIA_VIDEO, '{e_MEDIA_IMAGE}' => e_MEDIA_IMAGE, '{e_MEDIA_ICON}' => e_MEDIA_ICON, - '{e_MEDIA_AVATAR}' => e_MEDIA_AVATAR, + '{e_AVATAR}' => e_AVATAR, '{e_WEB_JS}' => e_WEB_JS, '{e_WEB_CSS}' => e_WEB_CSS, '{e_WEB_IMAGE}' => e_WEB_IMAGE, @@ -2219,7 +2219,7 @@ class e_parse extends e_parser '{e_MEDIA_VIDEO}' => e_MEDIA_VIDEO_ABS, '{e_MEDIA_IMAGE}' => e_MEDIA_IMAGE_ABS, '{e_MEDIA_ICON}' => e_MEDIA_ICON_ABS, - '{e_MEDIA_AVATAR}' => e_MEDIA_AVATAR_ABS, + '{e_AVATAR}' => e_AVATAR_ABS, '{e_WEB_JS}' => e_JS_ABS, '{e_WEB_CSS}' => e_CSS_ABS, '{e_WEB_IMAGE}' => e_WEB_IMAGE_ABS, @@ -2244,7 +2244,7 @@ class e_parse extends e_parser '{e_MEDIA_VIDEO}' => SITEURLBASE.e_MEDIA_VIDEO_ABS, '{e_MEDIA_IMAGE}' => SITEURLBASE.e_MEDIA_IMAGE_ABS, '{e_MEDIA_ICON}' => SITEURLBASE.e_MEDIA_ICON_ABS, - '{e_MEDIA_AVATAR}' => SITEURLBASE.e_MEDIA_AVATAR_ABS, + '{e_AVATAR}' => SITEURLBASE.e_AVATAR_ABS, '{e_WEB_JS}' => SITEURLBASE.e_JS_ABS, '{e_WEB_CSS}' => SITEURLBASE.e_CSS_ABS, '{e_WEB_IMAGE}' => SITEURLBASE.e_WEB_IMAGE_ABS, diff --git a/e107_handlers/user_handler.php b/e107_handlers/user_handler.php index 62209b663..975536c7d 100644 --- a/e107_handlers/user_handler.php +++ b/e107_handlers/user_handler.php @@ -93,7 +93,7 @@ class UserHandler 'user_login' => array('niceName'=> LAN_USER_03, 'fieldType' => 'string', 'vetMethod' => '0', 'vetParam' => '', 'srcName' => 'realname', 'dbClean' => 'toDB'), // Real name (no real vetting) 'user_customtitle' => array('niceName'=> LAN_USER_04, 'fieldType' => 'string', 'vetMethod' => '0', 'vetParam' => '', 'srcName' => 'customtitle', 'dbClean' => 'toDB', 'enablePref' => 'signup_option_customtitle'), // No real vetting 'user_password' => array('niceName'=> LAN_USER_05, 'fieldType' => 'string', 'vetMethod' => '0', 'vetParam' => '', 'srcName' => 'password1', 'dataType' => 2, 'minLength' => varset($pref['signup_pass_len'],1)), - 'user_sess' => array('niceName'=> LAN_USER_06, 'fieldType' => 'string', 'vetMethod' => '0', 'vetParam' => '', 'stripChars' => "#\"|'|(|)#", 'dbClean' => 'image', 'imagePath' => e_UPLOAD.'avatars/', 'maxHeight' => varset($pref['im_height'], 100), 'maxWidth' => varset($pref['im_width'], 120)), // Photo + 'user_sess' => array('niceName'=> LAN_USER_06, 'fieldType' => 'string', 'vetMethod' => '0', 'vetParam' => '', 'stripChars' => "#\"|'|(|)#", 'dbClean' => 'image', 'imagePath' => e_AVATAR_UPLOAD, 'maxHeight' => varset($pref['im_height'], 100), 'maxWidth' => varset($pref['im_width'], 120)), // Photo 'user_image' => array('niceName'=> LAN_USER_07, 'fieldType' => 'string', 'vetMethod' => '0', 'vetParam' => '', 'srcName' => 'image', 'stripChars' => "#\"|'|(|)#", 'dbClean' => 'avatar'), //, 'maxHeight' => varset($pref['im_height'], 100), 'maxWidth' => varset($pref['im_width'], 120) resized on-the-fly // Avatar 'user_email' => array('niceName'=> LAN_USER_08, 'fieldType' => 'string', 'vetMethod' => '1,3', 'vetParam' => '', 'fieldOptional' => varset($pref['disable_emailcheck'],0), 'srcName' => 'email', 'dbClean' => 'toDB'), 'user_signature' => array('niceName'=> LAN_USER_09, 'fieldType' => 'string', 'vetMethod' => '0', 'vetParam' => '', 'srcName' => 'signature', 'dbClean' => 'toDB'), diff --git a/e107_handlers/validator_class.php b/e107_handlers/validator_class.php index 321299e29..0f38fae05 100644 --- a/e107_handlers/validator_class.php +++ b/e107_handlers/validator_class.php @@ -1125,7 +1125,7 @@ class validatorClass { if (strpos('-upload-', $value) === 0) { - $img = e_UPLOAD.'avatars/'.str_replace('-upload-', '', $value); // Its a user-uploaded image + $img = e_AVATAR_UPLOAD.str_replace('-upload-', '', $value); // Its a user-uploaded image } elseif (strpos($avName, '/') !== FALSE) { @@ -1133,7 +1133,7 @@ class validatorClass } else { - $img = e_MEDIA.'avatars/'.$value; // Its a server-stored image + $img = e_AVATAR_DEFAULT.$value; // Its a server-stored image } } // Deliberately fall through into normal image processing @@ -1143,16 +1143,17 @@ class validatorClass $img = $defs['imagePath'].$value; } $img = varset($img,$value); + //XXX There should be no size limits - as image sizes are handled by thumb.php if ($size = getimagesize($img)) { // echo "Image {$img} size: {$size[0]} x {$size[1]}
"; if (isset($defs['maxWidth']) && $size[0] > $defs['maxWidth']) { // Image too wide - $errNum = ERR_IMAGE_TOO_WIDE; + // $errNum = ERR_IMAGE_TOO_WIDE; } if (isset($defs['maxHeight']) && $size[1] > $defs['maxHeight']) { // Image too high - $errNum = ERR_IMAGE_TOO_HIGH; + // $errNum = ERR_IMAGE_TOO_HIGH; } } else diff --git a/e107_plugins/forum/shortcodes/batch/view_shortcodes.php b/e107_plugins/forum/shortcodes/batch/view_shortcodes.php index 1e9b8c078..90cd91601 100644 --- a/e107_plugins/forum/shortcodes/batch/view_shortcodes.php +++ b/e107_plugins/forum/shortcodes/batch/view_shortcodes.php @@ -159,48 +159,7 @@ class plugin_forum_view_shortcodes extends e_shortcode function sc_avatar() { $tp = e107::getParser(); - //return e107::getParser()->parseTemplate("{AVATAR=".$this->postInfo['user_image']."}"); - $height = e107::getPref("im_height"); - $width = e107::getPref("im_width"); - - $img = e_IMAGE_ABS."generic/blank_avatar.jpg"; - - if ($this->postInfo['post_user'] && $this->postInfo['user_image']) - { - if(!$avatar = getcachedvars('forum_avatar_'.$this->postInfo['post_user'])) - { - if ($this->postInfo['user_image']) - { - // require_once(e_HANDLER.'avatar_handler.php'); - - if(file_exists(e_MEDIA_AVATAR."default/".$this->postInfo['user_image'])) - { - $img = e_MEDIA_AVATAR_ABS."default/".$this->postInfo['user_image']; - } - elseif(file_exists(e_MEDIA_AVATAR."uploaded/".$this->postInfo['user_image'])) - { - $img = e_MEDIA_AVATAR_ABS."uploaded/".$this->postInfo['user_image']; - } - - $avatar = "\"".$this-postInfo['user_name']."\"/>"; - } - else - { - $avatar = ""; - } - cachevars('forum_avatar_'.$this->postInfo['post_user'], $avatar); - } - return $avatar; - } - - // $img = $tp->thumbUrl(e_IMAGE."generic/blank_avatar.jpg","w=".$width."&h=".$height); - // return print_a($img, true); - - - return ""; - - return $text; - + return $tp->parseTemplate("{USER_AVATAR=".$this->postInfo['user_image']."}", true); } function sc_anon_ip() diff --git a/user.php b/user.php index 4b321e21c..4c3bf13b1 100644 --- a/user.php +++ b/user.php @@ -56,10 +56,10 @@ if (isset($_POST['delp'])) } if (USERID == $tmp[1] || (ADMIN && getperms("4"))) { - $sql->db_Select("user", "user_sess", "user_id='". USERID."'"); + $sql->select("user", "user_sess", "user_id='". USERID."'"); $row = $sql->db_Fetch(); - @unlink(e_UPLOAD."avatars/".$row['user_sess']); - $sql->db_Update("user", "user_sess='' WHERE user_id=".intval($tmp[1])); + @unlink(e_AVATAR_UPLOAD.$row['user_sess']); + $sql->update("user", "user_sess='' WHERE user_id=".intval($tmp[1])); header("location:".e_SELF."?id.".$tmp[1]); exit; } diff --git a/usersettings.php b/usersettings.php index 095b98a23..1a6428b7e 100644 --- a/usersettings.php +++ b/usersettings.php @@ -216,7 +216,7 @@ if (isset($_POST['updatesettings'])) require_once (e_HANDLER.'upload_handler.php'); require_once (e_HANDLER.'resize_handler.php'); - if ($uploaded = process_uploaded_files(e_UPLOAD.'avatars/', 'prefix+ap_'.$udata['user_id'].'_', array('overwrite' => TRUE, 'file_mask'=>'jpg,png,gif', 'max_file_count' => 2))) + if ($uploaded = process_uploaded_files(e_AVATAR_UPLOAD, 'prefix+ap_'.$udata['user_id'].'_', array('overwrite' => TRUE, 'file_mask'=>'jpg,png,gif', 'max_file_count' => 2))) { foreach ($uploaded as $upload) {