diff --git a/phpBB/includes/emailer.php b/phpBB/includes/emailer.php index d08ca0f3a6..f0d330dfbe 100755 --- a/phpBB/includes/emailer.php +++ b/phpBB/includes/emailer.php @@ -208,7 +208,7 @@ class emailer } // Build header - $this->extra_headers = (($this->replyto !='') ? "Reply-to: <$this->replyto>\r\n" : '') . (($this->from != '') ? "From: <$this->from>\r\n" : "From: <" . $config['board_email'] . ">\r\n") . "Return-Path: <" . $config['board_email'] . ">\r\nMessage-ID: <" . md5(uniqid(time())) . "@" . $config['server_name'] . ">\r\nMIME-Version: 1.0\r\nContent-type: text/plain; charset=" . $this->encoding . "\r\nContent-transfer-encoding: 8bit\r\nDate: " . gmdate('D, d M Y H:i:s Z', time()) . "\r\nX-Priority: 3\r\nX-MSMail-Priority: Normal\r\nX-Mailer: PHP\r\n" . (($cc != '') ? "Cc:$cc\r\n" : '') . (($bcc != '') ? "Bcc:$bcc\r\n" : '') . trim($this->extra_headers); + $this->extra_headers = (($this->replyto !='') ? "Reply-to: <$this->replyto>\r\n" : '') . (($this->from != '') ? "From: <$this->from>\r\n" : "From: <" . $config['board_email'] . ">\r\n") . "Return-Path: <" . $config['board_email'] . ">\r\nMessage-ID: <" . md5(uniqid(time())) . "@" . $config['server_name'] . ">\r\nMIME-Version: 1.0\r\nContent-type: text/plain; charset=" . $this->encoding . "\r\nContent-transfer-encoding: 8bit\r\nDate: " . gmdate('D, d M Y H:i:s Z', time()) . "\r\nX-Priority: 3\r\nX-MSMail-Priority: Normal\r\nX-Mailer: PHP\r\nX-MimeOLE: Produced By phpBB2\r\n" . trim($this->extra_headers) . (($cc != '') ? "Cc:$cc\r\n" : '') . (($bcc != '') ? "Bcc:$bcc\r\n" : ''); // Send message ... removed $this->encode() from subject for time being if (!$this->use_queue) @@ -219,9 +219,9 @@ class emailer { $this->queue->put('emailer', array( 'smtp_delivery' => $config['smtp_delivery'], - 'to' => $to, - 'subject' => $this->subject, - 'msg' => $this->msg, + 'to' => $to, + 'subject' => $this->subject, + 'msg' => $this->msg, 'extra_headers' => $this->extra_headers) ); @@ -240,7 +240,7 @@ class emailer // Encodes the given string for proper display for this encoding ... nabbed // from php.net and modified. There is an alternative encoding method which - // may produce lesd output but it's questionable as to its worth in this + // may produce less output but it's questionable as to its worth in this // scenario IMO function encode($str) { diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index d293157bd7..9a0dbd94b0 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -505,13 +505,12 @@ function markread($mode, $forum_id = 0, $topic_id = 0, $marktime = false) } else { - $tracking = (isset($_COOKIE[$config['cookie_name'] . '_f'])) ? unserialize(stripslashes($_COOKIE[$config['cookie_name'] . '_f'])) : array(); - if (empty($tracking[$forum_id]) || $tracking[$forum_id] < $current_time) - { - $tracking[$forum_id] = $current_time; - } + $tracking = (isset($_COOKIE[$config['cookie_name'] . '_track'])) ? unserialize(stripslashes($_COOKIE[$config['cookie_name'] . '_track'])) : array(); - setcookie($config['cookie_name'] . '_f', serialize($tracking), time() + 31536000, $config['cookie_path'], $config['cookie_domain'], $config['cookie_secure']); + unset($tracking[$forum_id]); + $tracking[$forum_id][0] = base_convert($current_time - $config['board_startdate'], 10, 36); + + setcookie($config['cookie_name'] . '_track', serialize($tracking), time() + 31536000, $config['cookie_path'], $config['cookie_domain'], $config['cookie_secure']); unset($tracking); } break; @@ -578,9 +577,9 @@ function markread($mode, $forum_id = 0, $topic_id = 0, $marktime = false) $db->sql_query($sql); } } - else if (empty($tracking[$row['forum_id']]) || $tracking[$row['forum_id']] < $current_time) + else { - $tracking[$row['forum_id']] = $current_time; + $tracking[$row['forum_id']][0] = base_convert($current_time - $config['board_startdate'], 10, 36); } } while ($row = $db->sql_fetchrow($result)); @@ -590,7 +589,7 @@ function markread($mode, $forum_id = 0, $topic_id = 0, $marktime = false) if (!$config['load_db_lastread']) { - setcookie($config['cookie_name'] . '_f', serialize($tracking), time() + 31536000, $config['cookie_path'], $config['cookie_domain'], $config['cookie_secure']); + setcookie($config['cookie_name'] . '_track', serialize($tracking), time() + 31536000, $config['cookie_path'], $config['cookie_domain'], $config['cookie_secure']); unset($tracking); } } @@ -619,13 +618,34 @@ function markread($mode, $forum_id = 0, $topic_id = 0, $marktime = false) if (!$config['load_db_lastread']) { - $tracking = (isset($_COOKIE[$config['cookie_name'] . '_t'])) ? unserialize(stripslashes($_COOKIE[$config['cookie_name'] . '_t'])) : array(); - if (empty($tracking[$topic_id]) || $tracking[$topic_id] < $current_time) + $tracking = array(); + if (isset($_COOKIE[$config['cookie_name'] . '_track'])) { - $tracking[$topic_id] = $current_time; + $tracking = unserialize(stripslashes($_COOKIE[$config['cookie_name'] . '_track'])); + + // If the cookie grows larger than 3000 characters we will remove + // the smallest value + if (strlen($_COOKIE[$config['cookie_name'] . '_track']) > 3000) + { + foreach ($tracking as $f => $t_ary) + { + if (!isset($m_value) || min($t_ary) < $m_value) + { + $m_value = min($t_ary); + $m_tkey = array_search($m_value, $t_ary); + $m_fkey = $f; + } + } + unset($tracking[$m_fkey][$m_tkey]); + } } - setcookie($config['cookie_name'] . '_t', serialize($tracking), time() + 31536000, $config['cookie_path'], $config['cookie_domain'], $config['cookie_secure']); + if (base_convert($tracking[$forum_id][0], 36, 10) < $current_time) + { + $tracking[$forum_id][base_convert($topic_id, 10, 36)] = base_convert($current_time - $config['board_startdate'], 10, 36); + + setcookie($config['cookie_name'] . '_track', serialize($tracking), time() + 31536000, $config['cookie_path'], $config['cookie_domain'], $config['cookie_secure']); + } unset($tracking); } break; @@ -768,6 +788,47 @@ function obtain_icons(&$icons) return; } +// Obtain ranks +function obtain_ranks(&$ranks) +{ + global $db, $cache; + + if ($cache->exists('ranks')) + { + $ranks = $cache->get('ranks'); + } + else + { + $sql = 'SELECT * + FROM ' . RANKS_TABLE . ' + ORDER BY rank_min DESC'; + $result = $db->sql_query($sql); + + $ranks = array(); + while ($row = $db->sql_fetchrow($result)) + { + if ($row['rank_special']) + { + $ranks['special'][$row['rank_id']] = array( + 'rank_title' => $row['rank_title'], + 'rank_image' => $row['rank_image'] + ); + } + else + { + $ranks['normal'][] = array( + 'rank_title' => $row['rank_title'], + 'rank_min' => $row['rank_min'], + 'rank_image' => $row['rank_image'] + ); + } + } + $db->sql_freeresult($result); + + $cache->put('ranks', $ranks); + } +} + // Obtain allowed extensions function obtain_attach_extensions(&$extensions) { diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index 46ea43254e..e9d9dbd6bd 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -44,26 +44,23 @@ function display_forums($root_data = '', $display_moderators = TRUE) break; default: - $sql_lastread = 'LEFT JOIN ' . FORUMS_TRACK_TABLE . ' ft ON (ft.user_id = ' . $user->data['user_id'] . ' - AND ft.forum_id = f.forum_id)'; + $sql_from = '(' . FORUMS_TABLE . ' f LEFT JOIN ' . FORUMS_TRACK_TABLE . ' ft ON (ft.user_id = ' . $user->data['user_id'] . ' AND ft.forum_id = f.forum_id)'; break; } $lastread_select = ', ft.mark_time '; } else { - $lastread_select = ''; - $sql_lastread = ''; + $sql_from = FORUMS_TABLE . ' f '; + $lastread_select = $sql_lastread = ''; - $tracking_forums = (isset($_COOKIE[$config['cookie_name'] . '_f'])) ? unserialize(stripslashes($_COOKIE[$config['cookie_name'] . '_f'])) : array(); - $tracking_topics = (isset($_COOKIE[$config['cookie_name'] . '_t'])) ? unserialize(stripslashes($_COOKIE[$config['cookie_name'] . '_t'])) : array(); + $tracking_topics = (isset($_COOKIE[$config['cookie_name'] . '_track'])) ? unserialize(stripslashes($_COOKIE[$config['cookie_name'] . '_track'])) : array(); } $sql = "SELECT f.* $lastread_select - FROM (" . FORUMS_TABLE . " f - $sql_lastread) - $sql_where - ORDER BY left_id"; + FROM $sql_from + $sql_where + ORDER BY f.left_id"; $result = $db->sql_query($sql); $branch_root_id = $root_data['forum_id']; @@ -133,20 +130,9 @@ function display_forums($root_data = '', $display_moderators = TRUE) } } -/* - if (!empty($forum_unread[$forum_id])) - { - $forum_unread[$parent_id] = true; - } -*/ + $mark_time_forum = ($config['load_db_lastread']) ? $row['mark_time'] : ((isset($tracking_topics[$forum_id][0])) ? base_convert($tracking_topics[$forum_id][0], 36, 10) + $config['board_startdate'] : 0); - if (!isset($forum_unread[$parent_id])) - { - $forum_unread[$parent_id] = false; - } - - $check_time = (!$config['load_db_lastread']) ? $tracking_forums[$forum_id] : $row['mark_time']; - if ($check_time < $row['forum_last_post_time'] && $user->data['user_id'] != ANONYMOUS) + if ($mark_time_forum < $row['forum_last_post_time'] && $user->data['user_id'] != ANONYMOUS) { $forum_unread[$parent_id] = true; } @@ -154,27 +140,56 @@ function display_forums($root_data = '', $display_moderators = TRUE) $db->sql_freeresult(); /* - if ($config['load_db_lastread']) + if (isset($tracking_topics) && $user->data['user_id'] != ANONYMOUS) { - } - else - { - $forum_unread = array(); - $sql = "SELECT forum_id, topic_id, topic_last_post_time + $min_forum_time = base_convert(min($tracking_topics[$forum_id]), 36, 10) + $config['board_startdate']; + $max_forum_time = base_convert(max($tracking_topics[$forum_id]), 36, 10) + $config['board_startdate']; + + + // $mark_time_forum && $mark_time_topic + $sql = "SELECT topic_id, topic_last_post_time FROM " . TOPICS_TABLE . " - WHERE topic_last_post_time > " . ((sizeof($tracking_forums)) ? min($tracking_forums) : time() - 86400) . " - $sql_forum_track; + WHERE forum_id = $forum_id + AND topic_last_post_time > $min_forum_time";//AND topic_last_post_time < $max_forum_time $result = $db->sql_query($sql); - while ($row = $db->sql_fetchrow($result)) + $mark_time = 0; + if ($row2 = $db->sql_fetchrow($result)) { - if (($tracking_forums[$row['forum_id']] > $tracking_topics[$row['topic_id']] && - $row['topic_last_post_time'] > $tracking_forums[$row['forum_id']]) || - ($tracking_topics[$row['topic_id']] > $tracking_forums[$row['forum_id']] && - $row['topic_last_post_time'] > $tracking_topics[$row['topic_id']])) + do { - $forum_unread[$row['forum_id']] = $row['topic_last_post_time']; + $mtopic_id = base_convert($row2['topic_id'], 10, 36); + $tracking_topics[$forum_id][$mtopic_id] = base_convert($tracking_topics[$forum_id][$mtopic_id], 36, 10); + $tracking_topics[$forum_id][0] = base_convert($tracking_topics[$forum_id][0], 36, 10); + + echo $row2['topic_id'] . " :: " . $tracking_topics[$forum_id][$mtopic_id] . " :: " . $tracking_topics[$forum_id][0] . " :: " . $row2['topic_last_post_time'] . " :: " . $row['post_time'] . "
"; + + if ((($row2['topic_id'] != $topic_id && + ($tracking_topics[$forum_id][$mtopic_id] >= $row2['topic_last_post_time'] || + $tracking_topics[$forum_id][0] >= $row2['topic_last_post_time'])) || + ($row2['topic_id'] == $topic_id && $row['post_time'] <= $row2['topic_last_post_time'])) && + !isset($mark_read)) + { + $mark_read = true; + } + else + { + $mark_read = false; + } + $mark_time = max($mark_time, $row2['topic_last_post_time']); } + while ($row2 = $db->sql_fetchrow($result)); + } + $db->sql_freeresult($result); + + if ($mark_read) + { + markread('mark', $forum_id, false, $mark_time); + echo "HERE :: $mark_time :: " . time(); + } + else + { + echo "HERE2"; } } */ @@ -245,14 +260,14 @@ function display_forums($root_data = '', $display_moderators = TRUE) } } - $folder_image = ($forum_unread[$forum_id]) ? 'sub_forum_new' : 'sub_forum'; + $folder_image = (!empty($forum_unread[$forum_id])) ? 'sub_forum_new' : 'sub_forum'; } else { switch ($row['forum_type']) { case FORUM_POST: - $folder_image = ($forum_unread[$forum_id]) ? 'forum_new' : 'forum'; + $folder_image = (!empty($forum_unread[$forum_id])) ? 'forum_new' : 'forum'; break; case FORUM_LINK: @@ -273,7 +288,7 @@ function display_forums($root_data = '', $display_moderators = TRUE) } else { - $folder_alt = ($forum_unread[$forum_id]) ? 'NEW_POSTS' : 'NO_NEW_POSTS'; + $folder_alt = (!empty($forum_unread[$forum_id])) ? 'NEW_POSTS' : 'NO_NEW_POSTS'; } diff --git a/phpBB/includes/functions_jabber.php b/phpBB/includes/functions_jabber.php index 5417f47bdf..aca7d39473 100644 --- a/phpBB/includes/functions_jabber.php +++ b/phpBB/includes/functions_jabber.php @@ -172,6 +172,51 @@ class Jabber } } + function AccountRegistration($reg_email = NULL, $reg_name = NULL) + { + $packet = $this->SendIq($this->server, 'get', 'reg_01', 'jabber:iq:register'); + + if ($packet) + { + $key = $this->GetInfoFromIqKey($packet); // just in case a key was passed back from the server + unset($packet); + + $payload = "{$this->username} + {$this->password} + $reg_email + $reg_name\n"; + + $payload .= ($key) ? "$key\n" : ''; + + $packet = $this->SendIq($this->server, 'set', 'reg_01', 'jabber:iq:register', $payload); + + if ($this->GetInfoFromIqType($packet) == 'result') + { + $return_code = (isset($packet['iq']['#']['query'][0]['#']['registered'][0]['#'])) ? 1 : 2; + $this->jid = ($this->resource) ? "{$this->username}@{$this->server}/{$this->resource}" : "{$this->username}@{$this->server}"; + } + elseif ($this->GetInfoFromIqType($packet) == 'error' && isset($packet['iq']['#']['error'][0]['#'])) + { + // "conflict" error, i.e. already registered + if ($packet['iq']['#']['error'][0]['@']['code'] == '409') + { + $return_code = 1; + } + else + { + $return_code = 'Error ' . $packet['iq']['#']['error'][0]['@']['code'] . ': ' . $packet['iq']['#']['error'][0]['#']; + } + } + + return $return_code; + + } + else + { + return 3; + } + } + function SendPacket($xml) { $xml = trim($xml); diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index d8616db231..8fa26793b2 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -365,7 +365,7 @@ class ucp extends user function avatar_remote(&$data) { - global $config, $db, $user; + global $config, $db, $user, $phpbb_root_path; if (!preg_match('#^(http[s]*?)|(ftp)://#i', $data['remotelink'])) { @@ -474,7 +474,7 @@ class ucp extends user } unset($url_ary); - $tmp_path = (!@ini_get('safe_mode')) ? false : './' . $config['avatar_path'] . '/tmp'; + $tmp_path = (!@ini_get('safe_mode')) ? false : $phpbb_root_path . 'cache/tmp'; $filename = tempnam($tmp_path, uniqid(rand()) . '-'); if (!($fp = @fopen($filename, 'wb'))) @@ -498,9 +498,9 @@ class ucp extends user list($width, $height) = getimagesize($filename); - if ($width > $config['avatar_max_width'] || $height > $config['avatar_max_height'] || !$width || !$height) + if ($width > $config['avatar_max_width'] || $height > $config['avatar_max_height'] || $width < $config['avatar_min_width'] || $height < $config['avatar_min_height'] || !$width || !$height) { - $this->error[] = sprintf($user->lang['AVATAR_WRONG_SIZE'], $config['avatar_max_width'], $config['avatar_max_height']); + $this->error[] = sprintf($user->lang['AVATAR_WRONG_SIZE'], $config['avatar_min_width'], $config['avatar_min_height'], $config['avatar_max_width'], $config['avatar_max_height']); return true; }