diff --git a/phpBB/includes/bbcode.php b/phpBB/includes/bbcode.php index 90583de35a..f5c3cadba5 100644 --- a/phpBB/includes/bbcode.php +++ b/phpBB/includes/bbcode.php @@ -483,20 +483,34 @@ function bbencode_first_pass_pda($text, $uid, $open_tag, $close_tag, $close_tag_ // Mark the lowest nesting level if needed. if ($mark_lowest_level && ($curr_nesting_depth == 1)) { + if ($open_tag[0] == '[code]') + { + $code_entities_match = array('#<#', '#>#', '#"#', '#:#', '#\[#', '#\]#', '#\(#', '#\)#', '#\{#', '#\}#'); + $code_entities_replace = array('<', '>', '"', ':', '[', ']', '(', ')', '{', '}'); + $between_tags = preg_replace($code_entities_match, $code_entities_replace, $between_tags); + } $text = $before_start_tag . substr($start_tag, 0, $start_length - 1) . ":$curr_nesting_depth:$uid]"; $text .= $between_tags . substr($close_tag_new, 0, $close_tag_new_length - 1) . ":$curr_nesting_depth:$uid]"; } else { - if ($open_is_regexp) + if ($open_tag[0] == '[code]') { - $text = $before_start_tag . $start_tag; + $text = $before_start_tag . '[code]'; + $text .= $between_tags . '[/code]'; } else { - $text = $before_start_tag . substr($start_tag, 0, $start_length - 1) . ":$uid]"; + if ($open_is_regexp) + { + $text = $before_start_tag . $start_tag; + } + else + { + $text = $before_start_tag . substr($start_tag, 0, $start_length - 1) . ":$uid]"; + } + $text .= $between_tags . substr($close_tag_new, 0, $close_tag_new_length - 1) . ":$uid]"; } - $text .= $between_tags . substr($close_tag_new, 0, $close_tag_new_length - 1) . ":$uid]"; } $text .= $after_end_tag; @@ -606,7 +620,7 @@ function make_clickable($text) // matches an "xxxx://yyyy" URL at the start of a line, or after a space. // xxxx can only be alpha characters. // yyyy is anything up to the first space, newline, or comma. - $ret = preg_replace("#([\n ])([a-z]+?)://([^,\t \n\r]+)#i", "\\1\\2://\\3", $ret); + $ret = preg_replace("#([\n ])([a-z]+?)://([^\t <\n\r]+)#i", "\\1\\2://\\3", $ret); // matches a "www.xxxx.yyyy[/zzzz]" kinda lazy URL thing // Must contain at least 2 dots. xxxx contains either alphanum, or "-" @@ -614,7 +628,7 @@ function make_clickable($text) // zzzz is optional.. will contain everything up to the first space, newline, or comma. // This is slightly restrictive - it's not going to match stuff like "forums.foo.com" // This is to keep it from getting annoying and matching stuff that's not meant to be a link. - $ret = preg_replace("#([\n ])www\.([a-z0-9\-]+)\.([a-z0-9\-.\~]+)((?:/[^,\t \n\r]*)?)#i", "\\1www.\\2.\\3\\4", $ret); + $ret = preg_replace("#([\n ])www\.([a-z0-9\-]+)\.([a-z0-9\-.\~]+)((?:/[^\t <\n\r]*)?)#i", "\\1www.\\2.\\3\\4", $ret); // matches an email@domain type address at the start of a line, or after a space. // Note: Only the followed chars are valid; alphanums, "-", "_" and or ".". diff --git a/phpBB/includes/emailer.php b/phpBB/includes/emailer.php index 331d8fc3e8..641f0f21ce 100755 --- a/phpBB/includes/emailer.php +++ b/phpBB/includes/emailer.php @@ -38,8 +38,8 @@ class emailer $this->use_smtp = $use_smtp; $this->tpl_file = NULL; $this->address = NULL; - $this->msg = ""; - $this->mimeOut = ""; + $this->msg = ''; + $this->mimeOut = ''; } // @@ -47,11 +47,11 @@ class emailer // function reset() { - $this->tpl_file = ""; - $this->address = ""; - $this->msg = ""; - $this->memOut = ""; - $this->vars = ""; + $this->tpl_file = ''; + $this->address = ''; + $this->msg = ''; + $this->memOut = ''; + $this->vars = ''; } // @@ -59,13 +59,8 @@ class emailer // function email_address($address) { - - $success = true; - $this->address = ''; $this->address .= $address; - - return $success; } // @@ -84,30 +79,27 @@ class emailer $this->extra_headers = $headers; } - function use_template($template_file, $template_lang = "") + function use_template($template_file, $template_lang = '') { global $board_config, $phpbb_root_path; - if( $template_lang == "" ) + if ( $template_lang == '' ) { $template_lang = $board_config['default_lang']; } - $template_file = $phpbb_root_path . "language/lang_" . $template_lang . "/email/" . $template_file . ".tpl"; - if( !file_exists($template_file) ) + $this->tpl_file = $phpbb_root_path . 'language/lang_' . $template_lang . '/email/' . $template_file . '.tpl'; + if ( !file_exists($this->tpl_file) ) { - message_die(GENERAL_ERROR, "Couldn't find template file: $template_file", "", __LINE__, __FILE__); - } - else - { - $this->tpl_file = $template_file; - if( !$this->load_msg() ) - { - message_die(GENERAL_ERROR, "Couldn't load template file: $template_file", "", __LINE__, __FILE__); - } + message_die(GENERAL_ERROR, 'Could not find email template file ' . $template_file, '', __LINE__, __FILE__); } - return TRUE; + if ( !$this->load_msg() ) + { + message_die(GENERAL_ERROR, 'Could not load email template file ' . $template_file, '', __LINE__, __FILE__); + } + + return true; } // @@ -115,35 +107,25 @@ class emailer // function load_msg() { - if ($this->tpl_file == NULL) + if ( $this->tpl_file == NULL ) { - message_die(GENERAL_ERROR, "No template file set", "", __LINE__, __FILE__); + message_die(GENERAL_ERROR, 'No template file set', '', __LINE__, __FILE__); } - else + + if ( !($fd = fopen($this->tpl_file, 'r')) ) { - if(!($fd = fopen($this->tpl_file, 'r'))) - { - message_die(GENERAL_ERROR, "fopen failed opening template file", "", __LINE__, __FILE__); - } - else - { - $this->msg .= fread($fd, filesize($this->tpl_file)); - fclose($fd); - } + message_die(GENERAL_ERROR, 'Failed opening template file', '', __LINE__, __FILE__); } - return TRUE; + + $this->msg .= fread($fd, filesize($this->tpl_file)); + fclose($fd); + + return true; } function assign_vars($vars) { - if(empty($this->vars)) - { - $this->vars = $vars; - } - else - { - $this->vars .= $vars; - } + $this->vars = ( empty($this->vars) ) ? $vars : $this->vars . $vars; } function parse_email() @@ -165,12 +147,13 @@ class emailer // do this here because the subject may contain a variable // $match = array(); - preg_match("/^(Subject:(.*?)[\r\n]+?)?(.*?)$/is", $this->msg, $match); + preg_match("/^(Subject:(.*?)[\r\n]+?)?(Charset:(.*?)[\r\n]+?)?(.*?)$/is", $this->msg, $match); - $this->msg = ( isset($match[3]) ) ? trim($match[3]) : ''; + $this->msg = ( isset($match[5]) ) ? trim($match[5]) : ''; $this->subject = ( $this->subject != '' ) ? $this->subject : trim($match[2]); + $this->encoding = ( trim($match[4]) != '' ) ? trim($match[4]) : 'iso-8859-1'; - return TRUE; + return true; } // @@ -180,45 +163,53 @@ class emailer { global $phpEx, $phpbb_root_path; - if ($this->address == NULL) + if ( $this->address == NULL ) { - message_die(GENERAL_ERROR, "No email address set", "", __LINE__, __FILE__); + message_die(GENERAL_ERROR, 'No email address set', '', __LINE__, __FILE__); + } + + if ( !$this->parse_email() ) + { + return false; + } + + // + // Add date and encoding type + // + $universal_extra = "MIME-Version: 1.0\nContent-type: text/plain; charset=" . $this->encoding . "\nContent-transfer-encoding: 8bit\nDate: " . gmdate('D, d M Y H:i:s', time()) . " UT\n"; + $this->extra_headers = $universal_extra . $this->extra_headers; + + if ( $this->use_smtp ) + { + if ( !defined('SMTP_INCLUDED') ) + { + include($phpbb_root_path . 'includes/smtp.' . $phpEx); + } + + $result = smtpmail($this->address, $this->subject, $this->msg, $this->extra_headers); } else { - if(!$this->parse_email()) - { - return FALSE; - } - if($this->use_smtp) - { - if(!defined('SMTP_INCLUDED')) - { - include($phpbb_root_path . "includes/smtp.".$phpEx); - } - if(!smtpmail($this->address, $this->subject, $this->msg, $this->extra_headers)) - { - message_die(GENERAL_ERROR, "Sending via SMTP failed", "", __LINE__, __FILE__); - } - } - else - { - @mail($this->address, $this->subject, $this->msg, $this->extra_headers); - } + $result = @mail($this->address, $this->subject, $this->msg, $this->extra_headers); } - return TRUE; + if ( !$result ) + { + message_die(GENERAL_ERROR, 'Failed sending email', '', __LINE__, __FILE__); + } + + return true; } // - // Attach files via MIME. + // Attach files via MIME. // - function attachFile($filename, $mimetype="application/octet-stream", $szFromAddress, $szFilenameToDisplay) + function attachFile($filename, $mimetype = "application/octet-stream", $szFromAddress, $szFilenameToDisplay) { $mime_boundary = "--==================_846811060==_"; - $this->mailMsg = "--".$mime_boundary."\nContent-Type: text/plain;\n\tcharset=\"iso-8859-1\"\n\n".$this->mailMsg; + $this->mailMsg = '--' . $mime_boundary . "\nContent-Type: text/plain;\n\tcharset=\"iso-8859-1\"\n\n" . $this->mailMsg; if ($mime_filename) { @@ -234,11 +225,11 @@ class emailer $this->mimeOut .= "Content-Transfer-Encoding: quoted-printable\n"; $this->mimeOut .= "Content-Disposition: attachment;\n\tfilename=\"$szFilenameToDisplay\"\n\n"; - if ($mimetype == "message/rfc822") + if ( $mimetype == "message/rfc822" ) { $this->mimeOut .= "From: ".$szFromAddress."\n"; $this->mimeOut .= "To: ".$this->emailAddress."\n"; - $this->mimeOut .= "Date: ".date("D, d M Y G:i:s ").$this->getTimeZoneInEmailFormat()."\n"; + $this->mimeOut .= "Date: ".date("D, d M Y H:i:s") . " UT\n"; $this->mimeOut .= "Reply-To:".$szFromAddress."\n"; $this->mimeOut .= "Subject: ".$this->mailSubject."\n"; $this->mimeOut .= "X-Mailer: PHP/".phpversion()."\n"; diff --git a/phpBB/includes/usercp_avatar.php b/phpBB/includes/usercp_avatar.php index 61544d6eb6..84906954fb 100644 --- a/phpBB/includes/usercp_avatar.php +++ b/phpBB/includes/usercp_avatar.php @@ -74,7 +74,7 @@ function user_avatar_url($mode, &$error, &$error_msg, $avatar_filename) $avatar_filename = 'http://' . $avatar_filename; } - if ( !preg_match('#^(http:\/\/[a-z0-9\-]+?\.([a-z0-9\-]+\.)*[a-z]+(:[0-9]+)*\/.*?\.(gif|jpg|jpeg|png)$)#is', $avatar_filename) ) + if ( !preg_match('#^(http:\/\/[a-z0-9\-]+?\.([a-z0-9\-]+\.)*[a-z]+(:[0-9]+)*\/[^\"]*?\.(gif|jpg|jpeg|png)$)#is', $avatar_filename) ) { $error = true; $error_msg = ( !empty($error_msg) ) ? $error_msg . '
' . $lang['Wrong_remote_avatar_format'] : $lang['Wrong_remote_avatar_format']; @@ -162,7 +162,7 @@ function user_avatar_upload($mode, $avatar_mode, &$current_avatar, &$current_typ { if ( $avatar_filesize <= $board_config['avatar_filesize'] && $avatar_filesize > 0 ) { - preg_match("'image\/[x\-]*([a-z]+)'", $avatar_filetype, $avatar_filetype); + preg_match('#image\/[x\-]*([a-z]+)#', $avatar_filetype, $avatar_filetype); $avatar_filetype = $avatar_filetype[1]; } else @@ -184,7 +184,7 @@ function user_avatar_upload($mode, $avatar_mode, &$current_avatar, &$current_typ if ( $width <= $board_config['avatar_max_width'] && $height <= $board_config['avatar_max_height'] ) { - $new_filename = ( $current_avatar != '' && $mode != 'register' ) ? $current_avatar : uniqid($user_ip) . $imgtype; + $new_filename = uniqid($user_ip) . $imgtype; if ( $mode == 'editprofile' && $current_type == USER_AVATAR_UPLOAD && $current_avatar != '' ) { @@ -233,7 +233,7 @@ function user_avatar_upload($mode, $avatar_mode, &$current_avatar, &$current_typ return $avatar_sql; } -function display_avatar_gallery($mode, &$category, &$user_id, &$email, &$current_email, &$coppa, &$username, &$email, &$icq, &$aim, &$msn, &$yim, &$website, &$location, &$occupation, &$interests, &$signature, &$viewemail, &$notifypm, &$popuppm, &$notifyreply, &$attachsig, &$allowhtml, &$allowbbcode, &$allowsmilies, &$hideonline, &$style, &$language, &$timezone, &$dateformat) +function display_avatar_gallery($mode, &$category, &$user_id, &$email, &$current_email, &$coppa, &$username, &$email, &$new_password, &$cur_password, &$password_confirm, &$icq, &$aim, &$msn, &$yim, &$website, &$location, &$occupation, &$interests, &$signature, &$viewemail, &$notifypm, &$popuppm, &$notifyreply, &$attachsig, &$allowhtml, &$allowbbcode, &$allowsmilies, &$hideonline, &$style, &$language, &$timezone, &$dateformat) { global $board_config, $db, $template, $lang, $images, $theme; global $phpbb_root_path, $phpEx; @@ -309,7 +309,7 @@ function display_avatar_gallery($mode, &$category, &$user_id, &$email, &$current } } - $params = array('coppa', 'user_id', 'username', 'email', 'current_email', 'icq', 'aim', 'msn', 'yim', 'website', 'location', 'occupation', 'interests', 'signature', 'viewemail', 'notifypm', 'popuppm', 'notifyreply', 'attachsig', 'allowhtml', 'allowbbcode', 'allowsmilies', 'hideonline', 'style', 'language', 'timezone', 'dateformat'); + $params = array('coppa', 'user_id', 'username', 'email', 'current_email', 'cur_password', 'new_password', 'password_confirm', 'icq', 'aim', 'msn', 'yim', 'website', 'location', 'occupation', 'interests', 'signature', 'viewemail', 'notifypm', 'popuppm', 'notifyreply', 'attachsig', 'allowhtml', 'allowbbcode', 'allowsmilies', 'hideonline', 'style', 'language', 'timezone', 'dateformat'); $s_hidden_vars = ''; @@ -333,4 +333,4 @@ function display_avatar_gallery($mode, &$category, &$user_id, &$email, &$current return; } -?> \ No newline at end of file +?> diff --git a/phpBB/language/lang_english/email/admin_activate.tpl b/phpBB/language/lang_english/email/admin_activate.tpl index 04c8275491..ea0af53880 100644 --- a/phpBB/language/lang_english/email/admin_activate.tpl +++ b/phpBB/language/lang_english/email/admin_activate.tpl @@ -1,4 +1,5 @@ Subject: New user account +Charset: iso-8859-1 Hello, diff --git a/phpBB/language/lang_english/email/admin_send_email.tpl b/phpBB/language/lang_english/email/admin_send_email.tpl index a04796f184..234f61df52 100644 --- a/phpBB/language/lang_english/email/admin_send_email.tpl +++ b/phpBB/language/lang_english/email/admin_send_email.tpl @@ -1,3 +1,5 @@ +Charset: iso-8859-1 + The following is an email sent to you by an administrator of "{SITENAME}". If this message is spam, contains abusive or other comments you find offensive please contact the webmaster of the board at the following address: {BOARD_EMAIL} diff --git a/phpBB/language/lang_english/email/admin_welcome_activated.tpl b/phpBB/language/lang_english/email/admin_welcome_activated.tpl index abd1391df8..3b7aa48362 100644 --- a/phpBB/language/lang_english/email/admin_welcome_activated.tpl +++ b/phpBB/language/lang_english/email/admin_welcome_activated.tpl @@ -1,4 +1,5 @@ Subject: Account Activated +Charset: iso-8859-1 Hello {USERNAME}, diff --git a/phpBB/language/lang_english/email/admin_welcome_inactive.tpl b/phpBB/language/lang_english/email/admin_welcome_inactive.tpl index a9cd4e5db0..905e71696b 100644 --- a/phpBB/language/lang_english/email/admin_welcome_inactive.tpl +++ b/phpBB/language/lang_english/email/admin_welcome_inactive.tpl @@ -1,4 +1,5 @@ Subject: Welcome to {SITENAME} Forums +Charset: iso-8859-1 {WELCOME_MSG} diff --git a/phpBB/language/lang_english/email/coppa_welcome_inactive.tpl b/phpBB/language/lang_english/email/coppa_welcome_inactive.tpl index a77c7feb02..97e651a488 100644 --- a/phpBB/language/lang_english/email/coppa_welcome_inactive.tpl +++ b/phpBB/language/lang_english/email/coppa_welcome_inactive.tpl @@ -1,4 +1,5 @@ Subject: Welcome to {SITENAME} Forums +Charset: iso-8859-1 {WELCOME_MSG} diff --git a/phpBB/language/lang_english/email/group_added.tpl b/phpBB/language/lang_english/email/group_added.tpl index 81e87dbfb3..5707da9031 100644 --- a/phpBB/language/lang_english/email/group_added.tpl +++ b/phpBB/language/lang_english/email/group_added.tpl @@ -1,4 +1,5 @@ Subject: You have been added to this usergroup +Charset: iso-8859-1 Congratulations, diff --git a/phpBB/language/lang_english/email/group_approved.tpl b/phpBB/language/lang_english/email/group_approved.tpl index 60def16635..38773c513d 100644 --- a/phpBB/language/lang_english/email/group_approved.tpl +++ b/phpBB/language/lang_english/email/group_approved.tpl @@ -1,4 +1,5 @@ Subject: Your request has been approved +Charset: iso-8859-1 Congratulations, diff --git a/phpBB/language/lang_english/email/group_request.tpl b/phpBB/language/lang_english/email/group_request.tpl index 7b2811a764..8da7fa9f29 100644 --- a/phpBB/language/lang_english/email/group_request.tpl +++ b/phpBB/language/lang_english/email/group_request.tpl @@ -1,4 +1,5 @@ Subject: A request to join your group has been made +Charset: iso-8859-1 Dear {GROUP_MODERATOR}, diff --git a/phpBB/language/lang_english/email/privmsg_notify.tpl b/phpBB/language/lang_english/email/privmsg_notify.tpl index ef426d58c4..2a96ee8c61 100644 --- a/phpBB/language/lang_english/email/privmsg_notify.tpl +++ b/phpBB/language/lang_english/email/privmsg_notify.tpl @@ -1,4 +1,5 @@ Subject: New Private Message has arrived +Charset: iso-8859-1 Hello {USERNAME}, diff --git a/phpBB/language/lang_english/email/profile_send_email.tpl b/phpBB/language/lang_english/email/profile_send_email.tpl index 231efe1334..00dcde1e46 100644 --- a/phpBB/language/lang_english/email/profile_send_email.tpl +++ b/phpBB/language/lang_english/email/profile_send_email.tpl @@ -1,3 +1,5 @@ +Charset: iso-8859-1 + Hello {TO_USERNAME}, The following is an email sent to you by {FROM_USERNAME} via your account on {SITENAME}. If this message is spam, contains abusive or other comments you find offensive please contact the webmaster of the board at the following address: diff --git a/phpBB/language/lang_english/email/topic_notify.tpl b/phpBB/language/lang_english/email/topic_notify.tpl index b34b2d980a..9682ebbe69 100644 --- a/phpBB/language/lang_english/email/topic_notify.tpl +++ b/phpBB/language/lang_english/email/topic_notify.tpl @@ -1,4 +1,5 @@ Subject: Topic Reply Notification - {TOPIC_TITLE} +Charset: iso-8859-1 Hello {USERNAME}, diff --git a/phpBB/language/lang_english/email/user_activate.tpl b/phpBB/language/lang_english/email/user_activate.tpl index 7d7960c4c5..0adeb5bff2 100644 --- a/phpBB/language/lang_english/email/user_activate.tpl +++ b/phpBB/language/lang_english/email/user_activate.tpl @@ -1,4 +1,5 @@ Subject: Reactivate your account +Charset: iso-8859-1 Hello {USERNAME}, diff --git a/phpBB/language/lang_english/email/user_activate_passwd.tpl b/phpBB/language/lang_english/email/user_activate_passwd.tpl index eb60e9af4c..8c45d032fe 100644 --- a/phpBB/language/lang_english/email/user_activate_passwd.tpl +++ b/phpBB/language/lang_english/email/user_activate_passwd.tpl @@ -1,4 +1,5 @@ Subject: New password activation +Charset: iso-8859-1 Hello {USERNAME} diff --git a/phpBB/language/lang_english/email/user_welcome.tpl b/phpBB/language/lang_english/email/user_welcome.tpl index 963be09048..42dc56df3b 100644 --- a/phpBB/language/lang_english/email/user_welcome.tpl +++ b/phpBB/language/lang_english/email/user_welcome.tpl @@ -1,4 +1,5 @@ Subject: Welcome to {SITENAME} Forums +Charset: iso-8859-1 {WELCOME_MSG} diff --git a/phpBB/language/lang_english/email/user_welcome_inactive.tpl b/phpBB/language/lang_english/email/user_welcome_inactive.tpl index 726abf4d60..6ece2d4faf 100644 --- a/phpBB/language/lang_english/email/user_welcome_inactive.tpl +++ b/phpBB/language/lang_english/email/user_welcome_inactive.tpl @@ -1,4 +1,5 @@ Subject: Welcome to {SITENAME} Forums +Charset: iso-8859-1 {WELCOME_MSG}