diff options
author | David M <davidmj@users.sourceforge.net> | 2006-02-22 22:17:36 +0000 |
---|---|---|
committer | David M <davidmj@users.sourceforge.net> | 2006-02-22 22:17:36 +0000 |
commit | ac011448ab843e8d892cb38107d05131df2ba2bf (patch) | |
tree | ea63ae699dd10dff58a55b7933efa10aed099c37 | |
parent | 6b13f94be9fdd4054e08d593f5c871a11853344e (diff) | |
download | forums-ac011448ab843e8d892cb38107d05131df2ba2bf.tar forums-ac011448ab843e8d892cb38107d05131df2ba2bf.tar.gz forums-ac011448ab843e8d892cb38107d05131df2ba2bf.tar.bz2 forums-ac011448ab843e8d892cb38107d05131df2ba2bf.tar.xz forums-ac011448ab843e8d892cb38107d05131df2ba2bf.zip |
- Remove the BBCode UIDs from the output
- Faster generation of CAPTCHA images
git-svn-id: file:///svn/phpbb/trunk@5575 89ea8834-ac86-4346-8a33-228a782c2dd0
-rw-r--r-- | phpBB/includes/ucp/ucp_confirm.php | 63 | ||||
-rw-r--r-- | phpBB/includes/ucp/ucp_pm_viewfolder.php | 98 |
2 files changed, 91 insertions, 70 deletions
diff --git a/phpBB/includes/ucp/ucp_confirm.php b/phpBB/includes/ucp/ucp_confirm.php index efbde293f0..92f7512baf 100644 --- a/phpBB/includes/ucp/ucp_confirm.php +++ b/phpBB/includes/ucp/ucp_confirm.php @@ -191,36 +191,51 @@ class ucp_confirm else { // The total length of this image, uncompressed, is just a calculation of pixels - $len = $temp_len = ($width + 1) * $height; + $len = ($width + 1) * $height; - // Optimized Adler-32 loop ported from the GNU Classpath project - $s1 = 1; - $s2 = 0; - $i = 0; - while ($temp_len > 0) + // Adler-32 hash generation + // Note: The hash is _backwards_ so we must reverse it + + if (@extension_loaded('hash')) { - // We can defer the modulo operation: - // s1 maximally grows from 65521 to 65521 + 255 * 3800 - // s2 maximally grows by 3800 * median(s1) = 2090079800 < 2^31 - $n = 3800; - if ($n > $temp_len) - { - $n = $temp_len; - } - $temp_len -= $n; - while (--$n >= 0) + $adler_hash = hash('adler32', $raw_image, true); + } + else if (@extension_loaded('mhash')) + { + $adler_hash = mhash(MHASH_ADLER32, $raw_image); + } + else + { + // Optimized Adler-32 loop ported from the GNU Classpath project + $temp_len = $len; + $s1 = 1; + $s2 = 0; + $i = 0; + while ($temp_len > 0) { - $s1 += (ord($raw_image[$i++]) & 255); - $s2 += $s1; + // We can defer the modulo operation: + // s1 maximally grows from 65521 to 65521 + 255 * 3800 + // s2 maximally grows by 3800 * median(s1) = 2090079800 < 2^31 + $n = 3800; + if ($n > $temp_len) + { + $n = $temp_len; + } + $temp_len -= $n; + while (--$n >= 0) + { + $s1 += (ord($raw_image[$i++]) & 255); + $s2 += $s1; + } + $s1 %= 65521; + $s2 %= 65521; } - $s1 %= 65521; - $s2 %= 65521; + $adler = ($s2 << 16) | $s1; + $adler_hash = pack('C4', $adler & 255, ($adler >> 8) & 255, ($adler >> 16) & 255, ($adler >> 24) & 255); } - $adler = ($s2 << 16) | $s1; - // This is the same thing as gzcompress($raw_image, 0) - $raw_image = pack('C7', 0x78, 0x01, 0x01, $len, ($len >> 8) & 255, ~$len & 255, ~($len >> 8)) . $raw_image; - $raw_image .= pack('C4', ($adler >> 24) & 255, ($adler >> 16) & 255, ($adler >> 8) & 255, $adler & 255); + // This is the same thing as gzcompress($raw_image, 0) but does not need zlib + $raw_image = pack('C7', 0x78, 0x01, 0x01, $len, ($len >> 8) & 255, ~$len & 255, ~($len >> 8)) . $raw_image . strrev($adler_hash); // The Zlib header + Adler hash make us add on 11 $len += 11; diff --git a/phpBB/includes/ucp/ucp_pm_viewfolder.php b/phpBB/includes/ucp/ucp_pm_viewfolder.php index 02b271159e..173029f0bd 100644 --- a/phpBB/includes/ucp/ucp_pm_viewfolder.php +++ b/phpBB/includes/ucp/ucp_pm_viewfolder.php @@ -17,50 +17,55 @@ function view_folder($id, $mode, $folder_id, $folder, $type) global $user, $template, $auth, $db, $cache; global $phpbb_root_path, $config, $phpEx, $SID; - $user->add_lang('viewforum'); + $submit_export = (isset($_POST['submit_export'])) ? true : false; - // Grab icons - $icons = array(); - $cache->obtain_icons($icons); + if (!$submit_export) + { + $user->add_lang('viewforum'); - $color_rows = array('marked', 'replied', 'message_reported', 'friend', 'foe'); + // Grab icons + $icons = array(); + $cache->obtain_icons($icons); - foreach ($color_rows as $var) - { - $template->assign_block_vars('pm_colour_info', array( - 'IMG' => $user->img("pm_{$var}", ''), - 'CLASS' => "pm_{$var}_colour", - 'LANG' => $user->lang[strtoupper($var) . '_MESSAGE']) - ); - } + $color_rows = array('marked', 'replied', 'message_reported', 'friend', 'foe'); - $mark_options = array('mark_important', 'delete_marked'); + foreach ($color_rows as $var) + { + $template->assign_block_vars('pm_colour_info', array( + 'IMG' => $user->img("pm_{$var}", ''), + 'CLASS' => "pm_{$var}_colour", + 'LANG' => $user->lang[strtoupper($var) . '_MESSAGE']) + ); + } - $s_mark_options = ''; - foreach ($mark_options as $mark_option) - { - $s_mark_options .= '<option value="' . $mark_option . '">' . $user->lang[strtoupper($mark_option)] . '</option>'; - } + $mark_options = array('mark_important', 'delete_marked'); - $friend = $foe = array(); + $s_mark_options = ''; + foreach ($mark_options as $mark_option) + { + $s_mark_options .= '<option value="' . $mark_option . '">' . $user->lang[strtoupper($mark_option)] . '</option>'; + } - // Get friends and foes - $sql = 'SELECT * - FROM ' . ZEBRA_TABLE . ' - WHERE user_id = ' . $user->data['user_id']; - $result = $db->sql_query($sql); + $friend = $foe = array(); - while ($row = $db->sql_fetchrow($result)) - { - $friend[$row['zebra_id']] = $row['friend']; - $foe[$row['zebra_id']] = $row['foe']; - } - $db->sql_freeresult($result); + // Get friends and foes + $sql = 'SELECT * + FROM ' . ZEBRA_TABLE . ' + WHERE user_id = ' . $user->data['user_id']; + $result = $db->sql_query($sql); - $template->assign_vars(array( - 'S_UNREAD' => ($type == 'unread'), - 'S_MARK_OPTIONS'=> $s_mark_options) - ); + while ($row = $db->sql_fetchrow($result)) + { + $friend[$row['zebra_id']] = $row['friend']; + $foe[$row['zebra_id']] = $row['foe']; + } + $db->sql_freeresult($result); + + $template->assign_vars(array( + 'S_UNREAD' => ($type == 'unread'), + 'S_MARK_OPTIONS'=> $s_mark_options) + ); + } $folder_info = get_pm_from($folder_id, $folder, $user->data['user_id'], "{$phpbb_root_path}ucp.$phpEx$SID", $type); @@ -123,11 +128,15 @@ function view_folder($id, $mode, $folder_id, $folder, $type) $data = array(); + $export_type = request_var('export_option', ''); + $enclosure = request_var('enclosure', ''); + $delimiter = request_var('delimiter', ''); + foreach ($folder_info['pm_list'] as $message_id) { $row = &$folder_info['rowset'][$message_id]; - if (isset($_REQUEST['submit_export'])) + if ($submit_export && ($export_type !== 'CSV' || ($delimiter !== '' && $enclosure !== ''))) { $sql = 'SELECT p.message_text FROM ' . PRIVMSGS_TO_TABLE . ' t, ' . PRIVMSGS_TABLE . ' p, ' . USERS_TABLE . ' u @@ -140,9 +149,11 @@ function view_folder($id, $mode, $folder_id, $folder, $type) $message_row = $db->sql_fetchrow($result); $db->sql_freeresult($result); - $data[] = array('subject' => censor_text($row['message_subject']), 'from' => $row['username'], 'date' => $user->format_date($row['message_time']), 'to' => ($folder_id == PRIVMSGS_OUTBOX || $folder_id == PRIVMSGS_SENTBOX) ? implode(', ', $address_list[$message_id]) : '', 'message' => $message_row['message_text']); + $message = preg_replace('#\[(\/?[a-z\*\+\-]+(?:=.*?)?)(?:\:?[0-9a-z]{5,})\]#', '[\1]', $message_row['message_text']); + + $data[] = array('subject' => censor_text($row['message_subject']), 'from' => $row['username'], 'date' => $user->format_date($row['message_time']), 'to' => ($folder_id == PRIVMSGS_OUTBOX || $folder_id == PRIVMSGS_SENTBOX) ? implode(', ', $address_list[$message_id]) : '', 'message' => $message); } - else + else if (!$submit_export || $export_type !== 'CSV') { $folder_img = ($row['unread']) ? 'folder_new' : 'folder'; $folder_alt = ($row['unread']) ? 'NEW_MESSAGES' : 'NO_NEW_MESSAGES'; @@ -199,27 +210,22 @@ function view_folder($id, $mode, $folder_id, $folder, $type) ); } - $type = request_var('export_option', ''); - $enclosure = request_var('enclosure', ''); - $delimiter = request_var('delimiter', ''); - $submit_export = (isset($_POST['submit_export'])) ? true : false; - // Ask the user what he wants if ($submit_export) { - if ($delimiter === '' && $type == 'CSV') + if ($export_type == 'CSV' && ($delimiter === '' || $enclosure === '')) { $template->assign_var('PROMPT', true); } else { - switch ($type) + switch ($export_type) { case 'CSV': case 'CSV_EXCEL': $mimetype = 'text/csv'; $filetype = 'csv'; - if ($type == 'CSV_EXCEL') + if ($export_type == 'CSV_EXCEL') { $enclosure = '"'; $delimiter = ','; |