From ee2ff042db37e5d4538b0ea3c0522b04c4b19d4b Mon Sep 17 00:00:00 2001 From: "Paul S. Owen" Date: Tue, 12 Jun 2001 23:30:13 +0000 Subject: [PATCH] Found that php has an imagesize function ... doh git-svn-id: file:///svn/phpbb/trunk@482 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/db/mysql_basic.sql | 4 +- phpBB/db/mysql_schema.sql | 3 ++ phpBB/db/postgres_schema.sql | 3 ++ phpBB/language/lang_english.php | 21 ++++++---- phpBB/profile.php | 73 +++++++++++++++++++++------------ 5 files changed, 68 insertions(+), 36 deletions(-) diff --git a/phpBB/db/mysql_basic.sql b/phpBB/db/mysql_basic.sql index c064cf177c..e50d5a682a 100644 --- a/phpBB/db/mysql_basic.sql +++ b/phpBB/db/mysql_basic.sql @@ -4,7 +4,7 @@ # $Id$ # -- Config -INSERT INTO phpbb_config (config_id, sitename, allow_html, allow_bbcode, allow_smilies, allow_sig, allow_namechange, selected, posts_per_page, hot_threshold, topics_per_page, flood_interval, allow_theme_create, override_themes, email_sig, email_from, default_theme, default_lang, default_dateformat, system_timezone, sys_template, avatar_filesize, avatar_path, allow_avatar_upload) VALUES ( '1', 'phpbb.com', '0', '1', '1', '1', '0', '1', '10', '10', '25', '10', '0', '0', '', '', '5', 'english', 'd M Y H:i', '0', 'Default', '6144', 'images/avatars', '0'); +INSERT INTO phpbb_config (config_id, sitename, allow_html, allow_bbcode, allow_smilies, allow_sig, allow_namechange, selected, posts_per_page, hot_threshold, topics_per_page, flood_interval, allow_theme_create, override_themes, email_sig, email_from, default_theme, default_lang, default_dateformat, system_timezone, sys_template, avatar_filesize, avatar_path, allow_avatar_upload, avatar_max_width, avatar_max_height, allow_avatar_local) VALUES ( '1', 'phpbb.com', '0', '1', '1', '1', '0', '1', '10', '10', '25', '10', '0', '0', '', '', '5', 'english', 'd M Y H:i', '0', 'Default', '6144', 'images/avatars', '0', '70', '70', '0'); # -- Categories INSERT INTO phpbb_categories (cat_id, cat_title, cat_order) VALUES (1, 'Test category 1', 1); @@ -61,4 +61,4 @@ INSERT INTO phpbb_themes (themes_id, themes_name, head_stylesheet, body_backgrou INSERT INTO phpbb_themes_name (themes_id, tr_color1_name, tr_color2_name, tr_color3_name, th_color1_name, th_color2_name, th_color3_name, td_color1_name, td_color2_name, td_color3_name, fontface1_name, fontface2_name, fontface3_name, fontsize1_name, fontsize2_name, fontsize3_name, fontcolor1_name, fontcolor2_name, fontcolor3_name, img1_name, img2_name, img3_name, img4_name) VALUES ( '5', '', '', '', 'Table Background', 'Title Header', 'Category Header', 'Table background', 'Row Color 1', 'Row Color 2', 'Verdana,Serif', 'Arial,Sans-serif', 'Verdana,serif', 'Smallest', 'Typical', 'Largest', 'All text', '', '', '', '', '', ''); INSERT INTO phpbb_themes (themes_id, themes_name, head_stylesheet, body_background, body_bgcolor, body_text, body_link, body_vlink, body_alink, body_hlink, tr_color1, tr_color2, tr_color3, th_color1, th_color2, th_color3, td_color1, td_color2, td_color3, fontface1, fontface2, fontface3, fontsize1, fontsize2, fontsize3, fontcolor1, fontcolor2, fontcolor3, img1, img2, img3, img4) VALUES ( '6', 'PSO-Blue', '', '', 'FFFFFF', '000000', '417FB9', '4E6172', '0000AA', '', '', '', '', '000000', '90BAE2', '518EC7', 'cde3f2', 'daedFd', '', 'verdana,serif', 'arial,helvetica', 'courier', '1', '2', '3', '000000', '', '', '', '', '', ''); -INSERT INTO phpbb_themes_name (themes_id, tr_color1_name, tr_color2_name, tr_color3_name, th_color1_name, th_color2_name, th_color3_name, td_color1_name, td_color2_name, td_color3_name, fontface1_name, fontface2_name, fontface3_name, fontsize1_name, fontsize2_name, fontsize3_name, fontcolor1_name, fontcolor2_name, fontcolor3_name, img1_name, img2_name, img3_name, img4_name) VALUES ( '5', '', '', '', 'Table Background', 'Title Header', 'Category Header', 'Table background', 'Row Color 1', 'Row Color 2', 'Verdana,Serif', 'Arial,Sans-serif', 'Verdana,serif', 'Smallest', 'Typical', 'Largest', 'All text', '', '', '', '', '', ''); +INSERT INTO phpbb_themes_name (themes_id, tr_color1_name, tr_color2_name, tr_color3_name, th_color1_name, th_color2_name, th_color3_name, td_color1_name, td_color2_name, td_color3_name, fontface1_name, fontface2_name, fontface3_name, fontsize1_name, fontsize2_name, fontsize3_name, fontcolor1_name, fontcolor2_name, fontcolor3_name, img1_name, img2_name, img3_name, img4_name) VALUES ( '6', '', '', '', 'Table Background', 'Title Header', 'Category Header', 'Table background', 'Row Color 1', 'Row Color 2', 'Verdana,Serif', 'Arial,Sans-serif', 'Verdana,serif', 'Smallest', 'Typical', 'Largest', 'All text', '', '', '', '', '', ''); diff --git a/phpBB/db/mysql_schema.sql b/phpBB/db/mysql_schema.sql index 26a28e1944..ed4be29726 100644 --- a/phpBB/db/mysql_schema.sql +++ b/phpBB/db/mysql_schema.sql @@ -116,6 +116,7 @@ CREATE TABLE phpbb_config ( allow_sig tinyint(1), allow_namechange tinyint(1), allow_theme_create tinyint(1), + allow_avatar_local tinyint(1) DEFAULT '0' NOT NULL, allow_avatar_upload tinyint(1) DEFAULT '0' NOT NULL, override_themes tinyint(3), posts_per_page int(10), @@ -125,6 +126,8 @@ CREATE TABLE phpbb_config ( email_from varchar(100), flood_interval int(4) NOT NULL, avatar_filesize int(11) DEFAULT '6144' NOT NULL, + avatar_max_width smallint(6) DEFAULT '70' NOT NULL, + avatar_max_height smallint(6) DEFAULT '70' NOT NULL, avatar_path varchar(255) DEFAULT 'images/avatars' NOT NULL, default_theme int(11) DEFAULT '1' NOT NULL, default_lang varchar(255), diff --git a/phpBB/db/postgres_schema.sql b/phpBB/db/postgres_schema.sql index df5462f776..075756cfc0 100644 --- a/phpBB/db/postgres_schema.sql +++ b/phpBB/db/postgres_schema.sql @@ -129,6 +129,7 @@ CREATE TABLE phpbb_config ( allow_sig int2 NOT NULL, allow_namechange int2 NOT NULL, allow_theme_create int2 NOT NULL, + allow_avatar_local int2 DEFAULT '0' NOT NULL, allow_avatar_upload int2 DEFAULT '0' NOT NULL, posts_per_page int2 NOT NULL, topics_per_page int2 NOT NULL, @@ -141,6 +142,8 @@ CREATE TABLE phpbb_config ( system_timezone int4 NOT NULL, sys_template varchar(50) NOT NULL, avatar_filesize int4 DEFAULT '6144' NOT NULL, + avatar_max_width int2 DEFAULT '70' NOT NULL, + avatar_max_height int2 DEFAULT '70' NOT NULL, avatar_path varchar(255) DEFAULT 'images/avatars' NOT NULL, override_themes int2 NOT NULL, flood_interval int NOT NULL, diff --git a/phpBB/language/lang_english.php b/phpBB/language/lang_english.php index 175dd03c7a..a91fd7211d 100755 --- a/phpBB/language/lang_english.php +++ b/phpBB/language/lang_english.php @@ -174,9 +174,9 @@ $lang['HTML'] = "HTML"; $lang['BBCode'] = "BBCode"; $lang['Smilies'] = "Smilies"; $lang['in_this_post'] = " in this post"; -$lang['is_ON'] = " is ON"; -$lang['is_OFF'] = " is OFF"; $lang['Notify'] = "Notify"; +$lang['is_ON'] = " is ON"; // this goes after either BBCode or HTML +$lang['is_OFF'] = " is OFF"; // see above $lang['Stored'] = "Your message has been entered successfully"; $lang['Click'] = "Click"; // Followed by here and then either return to topic or view message @@ -203,10 +203,19 @@ $lang['Mark'] = "Mark"; // $lang['Website'] = "Website"; $lang['From'] = "From"; + $lang['Wrong_Profile'] = "You cannot modify a profile that is not your own."; $lang['Bad_username'] = "The username you choose has been taken or is disallowed by the administrator."; $lang['Sorry_banned_email'] = "Sorry but the email address you gave has been banned from registering on this system."; +$lang['Avatar'] = "Avatar"; +$lang['Avatar_explain'] = "Displays a small graphic image below your details in posts. Only one image can be uploaded at a time with a width no greater than " . $board_config['avatar_max_width'] . " pixels, a height no greater than " . $board_config['avatar_max_height'] . " pixels and a file size no more than " . (round($board_config['avatar_filesize'] / 1024)) . " kB"; +$lang['Upload_Image'] = "Upload Image"; +$lang['Delete_Image'] = "Delete Image"; +$lang['Current_Image'] = "Current Image"; + + + // // Memberslist // @@ -400,12 +409,8 @@ $l_viewingprofile = "Viewing profile of "; $l_hidden = "hidden"; $l_boardtemplate = "Select Template"; $l_date_format = "Date format"; -$l_avatar = "Avatar"; -$l_avatar_explain = "Use this to display a small graphic image below your user details in posts. Only one image can be uploaded at a time and the size is limited to under "; // A number will be inserted after " ... under " and followed by "kB" -$l_kB = " kB"; -$l_Upload_Image = "Upload Image"; -$l_Delete_Image = "Delete Image"; -$l_Current_Image = "Current Image"; + + $l_date_format_explanation = "The syntax used is identical to the PHP date() function"; $l_password_if_changed = "You only need to supply a password if you want to change it."; $l_password_confirm_if_changed = "You only need to confirm your password if you changed it above."; diff --git a/phpBB/profile.php b/phpBB/profile.php index a4daeafa7f..1213fc8481 100644 --- a/phpBB/profile.php +++ b/phpBB/profile.php @@ -273,7 +273,7 @@ if(isset($HTTP_GET_VARS['mode']) || isset($HTTP_POST_VARS['mode'])) "AVATAR_IMG" => $board_config['avatar_path'] . "/" . stripslashes($profiledata['user_avatar']), "L_VIEWING_PROFILE" => $l_viewing_profile, - "L_USERNAME" => $l_username, + "L_USERNAME" => $lang['Username'], "L_VIEW_USERS_POSTS" => $l_view_users_posts, "L_JOINED" => $l_joined, "L_PER_DAY" => $l_per_day, @@ -286,7 +286,7 @@ if(isset($HTTP_GET_VARS['mode']) || isset($HTTP_POST_VARS['mode'])) "L_LOCATION" => $l_from, "L_OCCUPATION" => $l_occupation, "L_INTERESTS" => $l_interests, - "L_AVATAR" => $l_avatar, + "L_AVATAR" => $lang['Avatar'], "U_SEARCH_USER" => append_sid("search.$phpEx?a=".urlencode($profiledata['username'])."&f=all&b=0&d=DESC&c=100&dosearch=1"), "U_USER_WEBSITE" => stripslashes($profiledata['user_website']), @@ -430,13 +430,25 @@ if(isset($HTTP_GET_VARS['mode']) || isset($HTTP_POST_VARS['mode'])) if(!$error_type) { - $avatar_filename = $userdata['user_id'].$imgtype; - if(file_exists("./".$board_config['avatar_path']."/".$userdata['user_id'])) + list($width, $height) = getimagesize($user_avatar_loc); + + if( $width <= $board_config['avatar_max_width'] && + $height <= $board_config['avatar_max_height'] ) { - @unlink("./".$board_config['avatar_path']."/".$userdata['user_id']); + $avatar_filename = $userdata['user_id'] . $imgtype; + + if(file_exists("./" . $board_config['avatar_path'] . "/" . $userdata['user_id'])) + { + @unlink("./" . $board_config['avatar_path'] . "/" . $userdata['user_id']); + } + @copy($user_avatar_loc, "./" . $board_config['avatar_path'] . "/$avatar_filename"); + $avatar_sql = ", user_avatar = '$avatar_filename'"; + } + else + { + $error = true; + $error_msg = (!empty($error_msg)) ? $error_msg . "
The avatar must be less than " . $board_config['avatar_max_width'] . " pixels wide and " . $board_config['avatar_max_height'] . " pixels high" : "The avatar must be less than " . $board_config['avatar_max_width'] . " pixels wide and " . $board_config['avatar_max_height'] . " pixels high"; } - @copy($user_avatar_loc, "./".$board_config['avatar_path']."/$avatar_filename"); - $avatar_sql = ", user_avatar = '$avatar_filename'"; } else { @@ -611,11 +623,11 @@ if(isset($HTTP_GET_VARS['mode']) || isset($HTTP_POST_VARS['mode'])) "L_ALWAYS_ALLOW_BBCODE" => $l_alwaysbbcode, "L_ALWAYS_ALLOW_HTML" => $l_alwayshtml, "L_ALWAYS_ADD_SIGNATURE" => $l_alwayssig, - "L_AVATAR" => $l_avatar, - "L_AVATAR_EXPLAIN" => $l_avatar_explain . (round($board_config['avatar_filesize'] / 1024)). $l_kB, - "L_UPLOAD_IMAGE" => $l_Upload_Image, - "L_DELETE_IMAGE" => $l_Delete_Image, - "L_CURRENT_IMAGE" => $l_Current_Image, + "L_AVATAR" => $lang['Avatar'], + "L_AVATAR_EXPLAIN" => $lang['Avatar_explain'], + "L_UPLOAD_IMAGE" => $lang['Upload_Image'], + "L_DELETE_IMAGE" => $lang['Delete_Image'], + "L_CURRENT_IMAGE" => $lang['Current_Image'], "L_SIGNATURE" => $l_signature, "L_SIGNATURE_EXPLAIN" => $l_sigexplain, "L_PREFERENCES" => $l_preferences, @@ -814,13 +826,25 @@ if(isset($HTTP_GET_VARS['mode']) || isset($HTTP_POST_VARS['mode'])) if(!$error_type) { - $avatar_filename = $new_user_id.$imgtype; - if(file_exists("./".$board_config['avatar_path']."/".$new_user_id)) + list($width, $height) = getimagesize($user_avatar_loc); + + if( $width <= $board_config['avatar_max_width'] && + $height <= $board_config['avatar_max_height'] ) { - @unlink("./".$board_config['avatar_path']."/".$new_user_id); + $avatar_filename = $new_user_id . $imgtype; + + if(file_exists("./" . $board_config['avatar_path'] . "/" . $new_user_id)) + { + @unlink("./" . $board_config['avatar_path'] . "/" . $new_user_id); + } + @copy($user_avatar_loc, "./" . $board_config['avatar_path'] . "/$avatar_filename"); + $avatar_sql = ", user_avatar = '$avatar_filename'"; + } + else + { + $error = true; + $error_msg = (!empty($error_msg)) ? $error_msg . "
The avatar must be less than " . $board_config['avatar_max_width'] . " pixels wide and " . $board_config['avatar_max_height'] . " pixels high" : "The avatar must be less than " . $board_config['avatar_max_width'] . " pixels wide and " . $board_config['avatar_max_height'] . " pixels high"; } - @copy($user_avatar_loc, "./".$board_config['avatar_path']."/$avatar_filename"); - $avatar_sql = ", user_avatar = '$avatar_filename'"; } else { @@ -846,10 +870,8 @@ if(isset($HTTP_GET_VARS['mode']) || isset($HTTP_POST_VARS['mode'])) { $md_pass = md5($password); - $sql = "INSERT INTO ".USERS_TABLE." - (user_id, username, user_regdate, user_password, user_email, user_icq, user_website, user_occ, user_from, user_interests, user_sig, user_avatar, user_viewemail, user_aim, user_yim, user_msnm, user_attachsig, user_allowsmile, user_allowhtml, user_allowbbcode, user_timezone, user_dateformat, user_lang, user_template, user_theme, user_level, user_active, user_actkey) - VALUES - ($new_user_id, '$username', '$regdate', '$md_pass', '$email', '$icq', '$website', '$occupation', '$location', '$interests', '$signature', '$avatar_filename', '$viewemail', '$aim', '$yim', '$msn', $attachsig, $allowsmilies, '$allowhtml', $allowbbcode, $user_timezone, '$user_dateformat', '$user_lang', '$user_template', $user_theme, 0, "; + $sql = "INSERT INTO ".USERS_TABLE." (user_id, username, user_regdate, user_password, user_email, user_icq, user_website, user_occ, user_from, user_interests, user_sig, user_avatar, user_viewemail, user_aim, user_yim, user_msnm, user_attachsig, user_allowsmile, user_allowhtml, user_allowbbcode, user_timezone, user_dateformat, user_lang, user_template, user_theme, user_level, user_active, user_actkey) + VALUES ($new_user_id, '$username', '$regdate', '$md_pass', '$email', '$icq', '$website', '$occupation', '$location', '$interests', '$signature', '$avatar_filename', '$viewemail', '$aim', '$yim', '$msn', $attachsig, $allowsmilies, '$allowhtml', $allowbbcode, $user_timezone, '$user_dateformat', '$user_lang', '$user_template', $user_theme, 0, "; if($require_activation || $coppa == 1) { $act_key = generate_activation_key(); @@ -1030,11 +1052,10 @@ if(isset($HTTP_GET_VARS['mode']) || isset($HTTP_POST_VARS['mode'])) "L_ALWAYS_ALLOW_BBCODE" => $l_alwaysbbcode, "L_ALWAYS_ALLOW_HTML" => $l_alwayshtml, "L_ALWAYS_ADD_SIGNATURE" => $l_alwayssig, - "L_AVATAR" => $l_avatar, - "L_AVATAR_EXPLAIN" => $l_avatar_explain . (round($board_config['avatar_filesize'] / 1024)). $l_kB, - "L_UPLOAD_IMAGE" => $l_Upload_Image, - "L_DELETE_IMAGE" => $l_Delete_Image, - "L_CURRENT_IMAGE" => $l_Current_Image, + "L_AVATAR_EXPLAIN" => $lang['Avatar_explain'], + "L_UPLOAD_IMAGE" => $lang['Upload_Image'], + "L_DELETE_IMAGE" => $lang['Delete_Image'], + "L_CURRENT_IMAGE" => $lang['Current_Image'], "L_SIGNATURE" => $l_signature, "L_SIGNATURE_EXPLAIN" => $l_sigexplain, "L_PREFERENCES" => $l_preferences,