aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes
diff options
context:
space:
mode:
authorMeik Sievertsen <acydburn@phpbb.com>2004-07-08 22:41:04 +0000
committerMeik Sievertsen <acydburn@phpbb.com>2004-07-08 22:41:04 +0000
commit05f1315ebb96b46ea384df73d387aeb05602d2b5 (patch)
tree97ba594f068532d15df4e64f27fa5c271b1f7f30 /phpBB/includes
parent48eeecb25893839ef9c9290d616083a6f1351b19 (diff)
downloadforums-05f1315ebb96b46ea384df73d387aeb05602d2b5.tar
forums-05f1315ebb96b46ea384df73d387aeb05602d2b5.tar.gz
forums-05f1315ebb96b46ea384df73d387aeb05602d2b5.tar.bz2
forums-05f1315ebb96b46ea384df73d387aeb05602d2b5.tar.xz
forums-05f1315ebb96b46ea384df73d387aeb05602d2b5.zip
- remove output buffering options from download.php (not needed anymore)
- optimized viewtopic.php a little bit - removed the create_function (was consuming too much memory) from viewtopic - check for manually added convert[.exe] program name to imagemagick path in admin_attachments - reduced filesize checking for imagemagick program (some installations require less than 20k) - added checked="checked" for "not selected" topic icon - moved parse_text_display function from functions_posting.php to functions.php (see comment above function) - check for user_id != ANONYMOUS in page_footer for displaying the administration link (there seems to be a problem checking for global options) - rewrote attachment thumbnail functions - utilize GD2 functions if available, more uptodate checks... - changed final thumbnail size calculation - define S_ROW_COUNT within template class itself - added SID to template vars in page_header - added ability to view topic/forum within admin_viewlogs - added optional acl checking to make_jumpbox, no need to duplicate the function for this small need - added custom body file for confirm_box git-svn-id: file:///svn/phpbb/trunk@4920 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/includes')
-rw-r--r--phpBB/includes/functions.php92
-rw-r--r--phpBB/includes/functions_admin.php88
-rw-r--r--phpBB/includes/functions_display.php5
-rw-r--r--phpBB/includes/functions_posting.php215
-rw-r--r--phpBB/includes/functions_privmsgs.php3
-rw-r--r--phpBB/includes/template.php4
-rw-r--r--phpBB/includes/ucp/ucp_attachments.php3
-rw-r--r--phpBB/includes/ucp/ucp_main.php18
-rw-r--r--phpBB/includes/ucp/ucp_pm_viewfolder.php2
-rw-r--r--phpBB/includes/ucp/ucp_pm_viewmessage.php6
10 files changed, 206 insertions, 230 deletions
diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php
index 1f941d0baf..30a1f20aca 100644
--- a/phpBB/includes/functions.php
+++ b/phpBB/includes/functions.php
@@ -117,6 +117,49 @@ function get_userdata($user)
return ($row = $db->sql_fetchrow($result)) ? $row : false;
}
+// prepare text to be displayed/previewed...
+// This function is here to save memory (this function is used by viewforum/viewtopic/posting... and to include another huge file is pure memory waste)
+function parse_text_display($text, $text_rules)
+{
+ global $bbcode, $user;
+
+ $text_flags = explode(':', $text_rules);
+
+ $allow_bbcode = (int) $text_flags[0] & 1;
+ $allow_smilies = (int) $text_flags[0] & 2;
+ $allow_magic_url = (int) $text_flags[0] & 4;
+
+ $bbcode_uid = trim($text_flags[1]);
+ $bbcode_bitfield = (int) $text_flags[2];
+
+ // Really, really process bbcode only if we have something to process...
+ if (!$bbcode && $allow_bbcode && strpos($text, '[') !== false)
+ {
+ global $phpbb_root_path, $phpEx;
+
+ include_once($phpbb_root_path . 'includes/bbcode.' . $phpEx);
+ $bbcode = new bbcode();
+ }
+
+ // Second parse bbcode here
+ if ($allow_bbcode)
+ {
+ $bbcode->bbcode_second_pass($text, $bbcode_uid, $bbcode_bitfield);
+ }
+
+ // If we allow users to disable display of emoticons we'll need an appropriate
+ // check and preg_replace here
+ if ($allow_smilies)
+ {
+ $text = smilie_text($text, !$allow_smilies);
+ }
+
+ // Replace naughty words such as farty pants
+ $text = str_replace("\n", '<br />', censor_text($text));
+
+ return $text;
+}
+
// Create forum rules for given forum
function generate_forum_rules($forum_data)
{
@@ -129,7 +172,6 @@ function generate_forum_rules($forum_data)
if ($forum_data['forum_rules'])
{
- include_once($phpbb_root_path . 'includes/functions_posting.' . $phpEx);
$text_flags = explode(':', $forum_data['forum_rules_flags']);
}
@@ -155,22 +197,22 @@ function generate_forum_nav(&$forum_data)
list($parent_name, $parent_type) = array_values($parent_data);
$template->assign_block_vars('navlinks', array(
- 'S_IS_CAT' => ($parent_type == FORUM_CAT) ? true : false,
- 'S_IS_LINK' => ($parent_type == FORUM_LINK) ? true : false,
- 'S_IS_POST' => ($parent_type == FORUM_POST) ? true : false,
- 'FORUM_NAME' => $parent_name,
- 'FORUM_ID' => $parent_forum_id,
- 'U_VIEW_FORUM' => "{$phpbb_root_path}viewforum.$phpEx$SID&amp;f=$parent_forum_id")
+ 'S_IS_CAT' => ($parent_type == FORUM_CAT) ? true : false,
+ 'S_IS_LINK' => ($parent_type == FORUM_LINK) ? true : false,
+ 'S_IS_POST' => ($parent_type == FORUM_POST) ? true : false,
+ 'FORUM_NAME' => $parent_name,
+ 'FORUM_ID' => $parent_forum_id,
+ 'U_VIEW_FORUM' => "{$phpbb_root_path}viewforum.$phpEx$SID&amp;f=$parent_forum_id")
);
}
$template->assign_block_vars('navlinks', array(
- 'S_IS_CAT' => ($forum_data['forum_type'] == FORUM_CAT) ? true : false,
- 'S_IS_LINK' => ($forum_data['forum_type'] == FORUM_LINK) ? true : false,
- 'S_IS_POST' => ($forum_data['forum_type'] == FORUM_POST) ? true : false,
- 'FORUM_NAME' => $forum_data['forum_name'],
- 'FORUM_ID' => $forum_data['forum_id'],
- 'U_VIEW_FORUM' => "{$phpbb_root_path}viewforum.$phpEx$SID&amp;f=" . $forum_data['forum_id'])
+ 'S_IS_CAT' => ($forum_data['forum_type'] == FORUM_CAT) ? true : false,
+ 'S_IS_LINK' => ($forum_data['forum_type'] == FORUM_LINK) ? true : false,
+ 'S_IS_POST' => ($forum_data['forum_type'] == FORUM_POST) ? true : false,
+ 'FORUM_NAME' => $forum_data['forum_name'],
+ 'FORUM_ID' => $forum_data['forum_id'],
+ 'U_VIEW_FORUM' => "{$phpbb_root_path}viewforum.$phpEx$SID&amp;f=" . $forum_data['forum_id'])
);
$template->assign_vars(array(
@@ -188,6 +230,7 @@ function get_forum_parents(&$forum_data)
global $db;
$forum_parents = array();
+
if ($forum_data['parent_id'] > 0)
{
if ($forum_data['forum_parents'] == '')
@@ -309,7 +352,7 @@ function gen_sort_selects(&$limit_days, &$sort_by_text, &$sort_days, &$sort_key,
return;
}
-function make_jumpbox($action, $forum_id = false, $select_all = false)
+function make_jumpbox($action, $forum_id = false, $select_all = false, $acl_list = false)
{
global $config, $auth, $template, $user, $db, $phpEx, $SID;
@@ -326,7 +369,7 @@ function make_jumpbox($action, $forum_id = false, $select_all = false)
$right = $cat_right = $padding = 0;
$padding_store = array('0' => 0);
$display_jumpbox = false;
- $iteration = 1;
+ $iteration = 0;
while ($row = $db->sql_fetchrow($result))
{
@@ -341,7 +384,12 @@ function make_jumpbox($action, $forum_id = false, $select_all = false)
// if the user does not have permissions to list this forum skip
continue;
}
-
+
+ if ($acl_list && !$auth->acl_get($acl_list, $row['forum_id']))
+ {
+ continue;
+ }
+
if (!$display_jumpbox)
{
$template->assign_block_vars('jumpbox_forums', array(
@@ -984,6 +1032,9 @@ function redirect($url)
$cache->unload();
}
+ // Make sure no &amp;'s are in, this will break the redirect
+ $url = str_replace('&amp;', '&', $url);
+
// Local redirect? If not, prepend the boards url
$url = (!strstr($url, '://')) ? (generate_board_url() . preg_replace('#^/?(.*?)/?$#', '/\1', trim($url))) : $url;
@@ -1011,7 +1062,7 @@ function meta_refresh($time, $url)
}
// Build Confirm box
-function confirm_box($check, $title = '', $hidden = '')
+function confirm_box($check, $title = '', $hidden = '', $html_body = 'confirm_body.html')
{
global $user, $template, $_POST, $SID, $db;
@@ -1059,7 +1110,7 @@ function confirm_box($check, $title = '', $hidden = '')
page_header($user->lang[$title]);
$template->set_filenames(array(
- 'body' => 'confirm_body.html')
+ 'body' => $html_body)
);
// If activation key already exist, we better do not re-use the key (something very strange is going on...)
@@ -1067,7 +1118,7 @@ function confirm_box($check, $title = '', $hidden = '')
{
$user->cur_page = preg_replace('#^(.*?)[&|\?]act_key=[A-Z0-9]{10}(.*?)#', '\1\2', str_replace('&amp;', '&', $user->cur_page));
}
- $user_page = $user->cur_page . ((strstr($user->cur_page, '?')) ? '&' : '?') . 'act_key=' . $act_key;
+ $user_page = $user->cur_page . ((strpos($user->cur_page, '?') !== false) ? '&' : '?') . 'act_key=' . $act_key;
$user_page = str_replace('&amp;', '&', $user_page);
$template->assign_vars(array(
@@ -1623,6 +1674,7 @@ function page_header($page_title = '')
'RECORD_USERS' => $l_online_record,
'PRIVATE_MESSAGE_INFO' => $l_privmsgs_text,
'PRIVATE_MESSAGE_INFO_UNREAD' => $l_privmsgs_text_unread,
+ 'SID' => $SID,
'L_LOGIN_LOGOUT' => $l_login_logout,
'L_INDEX' => $user->lang['FORUM_INDEX'],
@@ -1708,7 +1760,7 @@ function page_footer()
'PHPBB_VERSION' => $config['version'],
'DEBUG_OUTPUT' => (defined('DEBUG')) ? $debug_output : '',
- 'U_ACP' => ($auth->acl_get('a_')) ? "adm/index.$phpEx?sid=" . $user->data['session_id'] : '')
+ 'U_ACP' => ($auth->acl_get('a_') && $user->data['user_id'] != ANONYMOUS) ? "adm/index.$phpEx?sid=" . $user->data['session_id'] : '')
);
$template->display('body');
diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php
index 5efaecb503..b7d0adf305 100644
--- a/phpBB/includes/functions_admin.php
+++ b/phpBB/includes/functions_admin.php
@@ -207,7 +207,7 @@ function filelist($rootdir, $dir = '', $type = 'gif|jpg|jpeg|png')
}
// Posts and topics manipulation
-function move_topics($topic_ids, $forum_id, $auto_sync = TRUE)
+function move_topics($topic_ids, $forum_id, $auto_sync = true)
{
global $db;
@@ -219,16 +219,6 @@ function move_topics($topic_ids, $forum_id, $auto_sync = TRUE)
AND forum_id = " . $forum_id;
$db->sql_query($sql);
- $table_ary = array(TOPICS_TABLE, POSTS_TABLE, LOG_TABLE);
- foreach ($table_ary as $table)
- {
- $sql = "UPDATE $table
- SET forum_id = $forum_id
- WHERE topic_id " . $sql_where;
- $db->sql_query($sql);
- }
- unset($table_ary);
-
if ($auto_sync)
{
$sql = 'SELECT DISTINCT forum_id
@@ -241,8 +231,21 @@ function move_topics($topic_ids, $forum_id, $auto_sync = TRUE)
$forum_ids[] = $row['forum_id'];
}
$db->sql_freeresult($result);
+ }
+
+ $table_ary = array(TOPICS_TABLE, POSTS_TABLE, LOG_TABLE);
+ foreach ($table_ary as $table)
+ {
+ $sql = "UPDATE $table
+ SET forum_id = $forum_id
+ WHERE topic_id " . $sql_where;
+ $db->sql_query($sql);
+ }
+ unset($table_ary);
- sync('forum', 'forum_id', $forum_ids, TRUE);
+ if ($auto_sync)
+ {
+ sync('forum', 'forum_id', $forum_ids, true);
unset($forum_ids);
}
}
@@ -318,11 +321,11 @@ function delete_topics($where_type, $where_ids, $auto_sync = TRUE)
if (!count($where_ids))
{
- return array('topics' => 0, 'posts' => '0');
+ return array('topics' => 0, 'posts' => 0);
}
$return = array(
- 'posts' => delete_posts($where_type, $where_ids, FALSE)
+ 'posts' => delete_posts($where_type, $where_ids, false)
);
$sql = 'SELECT topic_id, forum_id
@@ -337,9 +340,9 @@ function delete_topics($where_type, $where_ids, $auto_sync = TRUE)
}
$db->sql_freeresult();
- $return['topics'] = count($topic_ids);
+ $return['topics'] = sizeof($topic_ids);
- if (!count($topic_ids))
+ if (!sizeof($topic_ids))
{
return $return;
}
@@ -367,30 +370,10 @@ function delete_topics($where_type, $where_ids, $auto_sync = TRUE)
if ($auto_sync)
{
- sync('forum', 'forum_id', $forum_ids, TRUE);
+ sync('forum', 'forum_id', $forum_ids, true);
sync('topic_reported', $where_type, $where_ids);
}
- // Not an option here, deleting one post takes > 200 seconds for me (only this query)
-/*
- // Optimize/vacuum tables
- switch (SQL_LAYER)
- {
- case 'mysql':
- case 'mysql4':
- $table_ary = array(TOPICS_TRACK_TABLE, POLL_VOTES_TABLE, POLL_OPTIONS_TABLE, TOPICS_WATCH_TABLE, TOPICS_TABLE);
- $sql = 'OPTIMIZE TABLE ' . implode(', ', $table_ary);
- $db->sql_query($sql);
- unset($table_ary);
-
- break;
-
- case 'postgresql':
- $db->sql_query('VACUUM');
- break;
- }
-*/
-
return $return;
}
@@ -439,38 +422,18 @@ function delete_posts($where_type, $where_ids, $auto_sync = TRUE)
}
unset($table_ary);
- delete_attachments('post', $post_ids, FALSE);
+ delete_attachments('post', $post_ids, false);
$db->sql_transaction('commit');
if ($auto_sync)
{
sync('reported', 'topic_id', $topic_ids);
- sync('topic', 'topic_id', $topic_ids, TRUE);
- sync('forum', 'forum_id', $forum_ids, TRUE);
- }
-
- // Not an option here, deleting one post takes > 200 seconds for me (only this query)
-/*
- // Optimize/vacuum tables
- switch (SQL_LAYER)
- {
- case 'mysql':
- case 'mysql4':
- $table_ary = array(POSTS_TABLE, RATINGS_TABLE, REPORTS_TABLE, SEARCH_MATCH_TABLE);
- $sql = 'OPTIMIZE TABLE ' . implode(', ', $table_ary);
- $db->sql_query($sql);
- unset($table_ary);
-
- break;
-
- case 'postgresql':
- $db->sql_query('VACUUM');
- break;
+ sync('topic', 'topic_id', $topic_ids, true);
+ sync('forum', 'forum_id', $forum_ids, true);
}
-*/
- return count($post_ids);
+ return sizeof($post_ids);
}
// Delete Attachments
@@ -1841,6 +1804,7 @@ function view_log($mode, &$log, &$log_count, $limit = 0, $offset = 0, $forum_id
$log[$i]['time'] = $row['log_time'];
$log[$i]['forum_id'] = $row['forum_id'];
$log[$i]['topic_id'] = $row['topic_id'];
+ $log[$i]['viewforum'] = ($row['forum_id'] && $auth->acl_get('f_read', $row['forum_id'])) ? ((defined('IN_ADMIN')) ? '../' : '') . "viewforum.$phpEx$SID&amp;f=" . $row['forum_id'] : '';
$log[$i]['action'] = (!empty($user->lang[$row['log_operation']])) ? $user->lang[$row['log_operation']] : ucfirst(str_replace('_', ' ', $row['log_operation']));
@@ -1896,7 +1860,7 @@ function view_log($mode, &$log, &$log_count, $limit = 0, $offset = 0, $forum_id
foreach ($log as $key => $row)
{
$log[$key]['viewtopic'] = (isset($is_auth[$row['topic_id']])) ? ((defined('IN_ADMIN')) ? '../' : '') . "viewtopic.$phpEx$SID&amp;f=" . $is_auth[$row['topic_id']] . '&amp;t=' . $row['topic_id'] : '';
- $log[$key]['viewlogs'] = (isset($is_mod[$row['topic_id']])) ? ((defined('IN_ADMIN')) ? '../' : '') . "mcp.$phpEx$SID&amp;mode=viewlogs&amp;t=" . $row['topic_id'] : '';
+ $log[$key]['viewlogs'] = (isset($is_mod[$row['topic_id']])) ? ((defined('IN_ADMIN')) ? '../' : '') . "mcp.$phpEx$SID&amp;mode=topic_view&amp;action=viewlogs&amp;t=" . $row['topic_id'] : '';
}
}
diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php
index 6140bd500a..bb820946d0 100644
--- a/phpBB/includes/functions_display.php
+++ b/phpBB/includes/functions_display.php
@@ -172,7 +172,7 @@ function display_forums($root_data = '', $display_moderators = TRUE)
$redirect = (!empty($_SERVER['REQUEST_URI'])) ? preg_replace('#^(.*?)&(amp;)?mark=.*$#', '\1', htmlspecialchars($_SERVER['REQUEST_URI'])) : "index.$phpEx$SID";
meta_refresh(3, $redirect);
- $message = (strstr('viewforum', $redirect)) ? 'RETURN_FORUM' : 'RETURN_INDEX';
+ $message = (strstr($redirect, 'viewforum')) ? 'RETURN_FORUM' : 'RETURN_INDEX';
$message = $user->lang['FORUMS_MARKED'] . '<br /><br />' . sprintf($user->lang[$message], '<a href="' . $redirect . '">', '</a> ');
trigger_error($message);
}
@@ -185,6 +185,7 @@ function display_forums($root_data = '', $display_moderators = TRUE)
// Loop through the forums
$root_id = $root_data['forum_id'];
+
foreach ($forum_rows as $row)
{
if ($row['parent_id'] == $root_id && !$row['parent_id'])
@@ -317,7 +318,7 @@ function display_forums($root_data = '', $display_moderators = TRUE)
'LAST_POSTER' => $last_poster,
'MODERATORS' => $moderators_list,
'SUBFORUMS' => $subforums_list,
-
+
'L_SUBFORUM_STR' => $l_subforums,
'L_MODERATOR_STR' => $l_moderator,
'L_FORUM_FOLDER_ALT'=> $folder_alt,
diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php
index f3aeeb67a2..720a91ed86 100644
--- a/phpBB/includes/functions_posting.php
+++ b/phpBB/includes/functions_posting.php
@@ -173,47 +173,6 @@ function parse_text_insert($text, $allow_bbcode, $allow_smilies, $allow_magic_ur
return $message_parser->message;
}
-// prepare text to be displayed/previewed...
-function parse_text_display($text, $text_rules)
-{
- global $bbcode, $user;
-
- $text_flags = explode(':', $text_rules);
-
- $allow_bbcode = (int) $text_flags[0] & 1;
- $allow_smilies = (int) $text_flags[0] & 2;
- $allow_magic_url = (int) $text_flags[0] & 4;
-
- $bbcode_uid = trim($text_flags[1]);
- $bbcode_bitfield = (int) $text_flags[2];
-
- if (!$bbcode && $allow_bbcode)
- {
- global $phpbb_root_path, $phpEx;
-
- include_once($phpbb_root_path . 'includes/bbcode.' . $phpEx);
- $bbcode = new bbcode();
- }
-
- // Second parse bbcode here
- if ($allow_bbcode)
- {
- $bbcode->bbcode_second_pass($text, $bbcode_uid, $bbcode_bitfield);
- }
-
- // If we allow users to disable display of emoticons we'll need an appropriate
- // check and preg_replace here
- if ($allow_smilies)
- {
- $text = smilie_text($text, !$allow_smilies);
- }
-
- // Replace naughty words such as farty pants
- $text = str_replace("\n", '<br />', censor_text($text));
-
- return $text;
-}
-
// prepare text to be displayed within a form (fetched from db)
function parse_text_form_display($text, $text_rules)
{
@@ -285,7 +244,7 @@ function upload_attachment($forum_id, $filename, $local = false, $local_storage
$filedata['mimetype'] = (!$local) ? $_FILES['fileupload']['type'] : 'application/octet-stream';
// Opera adds the name to the mime type
- $filedata['mimetype'] = ( strstr($filedata['mimetype'], '; name') ) ? str_replace(strstr($filedata['mimetype'], '; name'), '', $filedata['mimetype']) : $filedata['mimetype'];
+ $filedata['mimetype'] = (strstr($filedata['mimetype'], '; name')) ? str_replace(strstr($filedata['mimetype'], '; name'), '', $filedata['mimetype']) : $filedata['mimetype'];
$filedata['extension'] = array_pop(explode('.', strtolower($filename)));
$filedata['filesize'] = (!@filesize($file)) ? intval($_FILES['size']) : @filesize($file);
@@ -451,9 +410,9 @@ function move_uploaded_attachment($upload_mode, $source_filename, &$filedata)
$source = $config['upload_dir'] . '/' . $destination_filename;
$destination = $config['upload_dir'] . '/thumb_' . $destination_filename;
- if (!create_thumbnail($source_filename, $destination_filename, $filedata['mimetype']))
+ if (!create_thumbnail($source, $destination, $filedata['mimetype']))
{
- if (!create_thumbnail($source, $destination, $filedata['mimetype']))
+ if (!create_thumbnail($source_filename, 'thumb_' . $destination_filename, $filedata['mimetype']))
{
$filedata['thumbnail'] = 0;
}
@@ -464,67 +423,63 @@ function move_uploaded_attachment($upload_mode, $source_filename, &$filedata)
}
// Calculate the needed size for Thumbnail
-// I am sure i had this grabbed from some site... source: unknown
function get_img_size_format($width, $height)
{
- // Change these two values to define the Thumbnail Size
+ // Maximum Width the Image can take
$max_width = 400;
- $max_height = 200;
-
- if ($height > $max_height)
- {
- $new_width = ($max_height / $height) * $width;
- $new_height = $max_height;
- if ($new_width > $max_width)
- {
- $new_height = ($max_width / $new_width) * $new_height;
- $new_width = $max_width;
- }
- }
- else if ($width > $max_width)
+ if ($width > $height)
{
- $new_height = ($max_width / $width) * $height;
- $new_width = $max_width;
-
- if ($new_height > $max_height)
- {
- $new_width = ($max_height / $new_height) * $new_width;
- $new_height = $max_height;
- }
+ return array(
+ round($width * ($max_width / $width)),
+ round($height * ($max_width / $width))
+ );
}
- else
+ else
{
- $new_width = $width;
- $new_height = $height;
+ return array(
+ round($width * ($max_width / $height)),
+ round($height * ($max_width / $height))
+ );
}
-
- return array(
- round($new_width),
- round($new_height)
- );
}
-function get_supported_image_types()
+function get_supported_image_types($type)
{
- $types = array();
-
if (@extension_loaded('gd'))
{
- if (@function_exists('imagegif'))
- {
- $types[] = '1';
- }
- if (@function_exists('imagejpeg'))
- {
- $types[] = '2';
- }
- if (@function_exists('imagepng'))
+ $format = imagetypes();
+ $new_type = 0;
+
+ switch ($type)
{
- $types[] = '3';
+ case 1:
+ $new_type = ($format & IMG_GIF) ? IMG_GIF : 0;
+ break;
+ case 2:
+ case 9:
+ case 10:
+ case 11:
+ case 12:
+ $new_type = ($format & IMG_JPG) ? IMG_JPG : 0;
+ break;
+ case 3:
+ $new_type = ($format & IMG_PNG) ? IMG_PNG : 0;
+ break;
+ case 6:
+ case 15:
+ $new_type = ($format & IMG_WBMP) ? IMG_WBMP : 0;
+ break;
}
- }
- return $types;
+
+ return array(
+ 'gd' => ($new_type) ? true : false,
+ 'format' => $new_type,
+ 'version' => (function_exists('imagecreatetruecolor')) ? 2 : 1
+ );
+ }
+
+ return array('gd' => false);
}
// Create Thumbnail
@@ -542,61 +497,76 @@ function create_thumbnail($source, $new_file, $mimetype)
return false;
}
- $size = getimagesize($source);
+ list($width, $height, $type, ) = getimagesize($source);
- if ($size[0] == 0 && $size[1] == 0)
+ if (!$width || !$height)
{
return false;
}
- $new_size = get_img_size_format($size[0], $size[1]);
-
- $tmp_path = $old_file = '';
+ list($new_width, $new_height) = get_img_size_format($width, $height);
$used_imagick = false;
if ($config['img_imagick'])
{
- if (is_array($size) && count($size) > 0)
+ passthru($config['img_imagick'] . 'convert' . ((defined('PHP_OS') && preg_match('#win#i', PHP_OS)) ? '.exe' : '') . ' -quality 85 -antialias -sample ' . $new_width . 'x' . $new_height . ' "' . str_replace('\\', '/', $source) . '" +profile "*" "' . str_replace('\\', '/', $new_file) . '"');
+ if (file_exists($new_file))
{
- passthru($config['img_imagick'] . 'convert' . ((defined('PHP_OS') && preg_match('#win#i', PHP_OS)) ? '.exe' : '') . ' -quality 85 -antialias -sample ' . $new_size[0] . 'x' . $new_size[1] . ' "' . str_replace('\\', '/', $source) . '" +profile "*" "' . str_replace('\\', '/', $new_file) . '"');
- if (file_exists($new_file))
- {
- $used_imagick = true;
- }
+ $used_imagick = true;
}
}
if (!$used_imagick)
{
- $type = $size[2];
- $supported_types = get_supported_image_types();
+ $type = get_supported_image_types($type);
- if (in_array($type, $supported_types))
+ if ($type['gd'])
{
- switch ($type)
+ switch ($type['format'])
{
- case '1' :
+ case IMG_GIF:
$image = imagecreatefromgif($source);
- $new_image = imagecreate($new_size[0], $new_size[1]);
- imagecopyresized($new_image, $image, 0, 0, 0, 0, $new_size[0], $new_size[1], $size[0], $size[1]);
- imagegif($new_image, $new_file);
break;
-
- case '2' :
+ case IMG_JPG:
$image = imagecreatefromjpeg($source);
- $new_image = imagecreate($new_size[0], $new_size[1]);
- imagecopyresized($new_image, $image, 0, 0, 0, 0, $new_size[0], $new_size[1], $size[0], $size[1]);
- imagejpeg($new_image, $new_file, 90);
break;
-
- case '3' :
+ case IMG_PNG:
$image = imagecreatefrompng($source);
- $new_image = imagecreate($new_size[0], $new_size[1]);
- imagecopyresized($new_image, $image, 0, 0, 0, 0, $new_size[0], $new_size[1], $size[0], $size[1]);
+ break;
+ case IMG_WBMP:
+ $image = imagecreatefromwbmp($source);
+ break;
+ }
+
+ if ($type['version'] == 1)
+ {
+ $new_image = imagecreate($new_width, $new_height);
+ imagecopyresized($new_image, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
+ }
+ else
+ {
+ $new_image = imagecreatetruecolor($new_width, $new_height);
+ imagecopyresampled($new_image, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
+ }
+
+ switch ($type['format'])
+ {
+ case IMG_GIF:
+ imagegif($new_image, $new_file);
+ break;
+ case IMG_JPG:
+ imagejpeg($new_image, $new_file, 90);
+ break;
+ case IMG_PNG:
imagepng($new_image, $new_file);
break;
+ case IMG_WBMP:
+ imagewbmp($new_image, $new_file);
+ break;
}
+
+ imagedestroy($new_image);
}
}
@@ -605,7 +575,6 @@ function create_thumbnail($source, $new_file, $mimetype)
return false;
}
-
@chmod($new_file, 0666);
return true;
@@ -702,6 +671,11 @@ function posting_gen_topic_icons($mode, $icon_id)
$icons = array();
obtain_icons($icons);
+ if (!$icon_id)
+ {
+ $template->assign_var('S_NO_ICON_CHECKED', ' checked="checked"');
+ }
+
if (sizeof($icons))
{
foreach ($icons as $id => $data)
@@ -714,6 +688,7 @@ function posting_gen_topic_icons($mode, $icon_id)
'ICON_WIDTH' => $data['width'],
'ICON_HEIGHT' => $data['height'],
+ 'S_CHECKED' => ($id == $icon_id) ? true : false,
'S_ICON_CHECKED' => ($id == $icon_id) ? ' checked="checked"' : '')
);
}
@@ -907,7 +882,6 @@ function load_drafts($topic_id = 0, $forum_id = 0, $id = 0)
if (sizeof($draftrows))
{
- $row_count = 0;
$template->assign_var('S_SHOW_DRAFTS', true);
foreach ($draftrows as $draft)
@@ -946,7 +920,6 @@ function load_drafts($topic_id = 0, $forum_id = 0, $id = 0)
'U_VIEW' => $view_url,
'U_INSERT' => $insert_url,
- 'S_ROW_COUNT' => $row_count++,
'S_LINK_PM' => $link_pm,
'S_LINK_TOPIC' => $link_topic,
'S_LINK_FORUM' => $link_forum)
diff --git a/phpBB/includes/functions_privmsgs.php b/phpBB/includes/functions_privmsgs.php
index ad7502cb12..97054a6a74 100644
--- a/phpBB/includes/functions_privmsgs.php
+++ b/phpBB/includes/functions_privmsgs.php
@@ -355,7 +355,8 @@ function place_pm_into_folder($global_privmsgs_rules, $release = false)
{
case ACTION_PLACE_INTO_FOLDER:
$folder_action = true;
- $move_into_folder[$rule_ary['folder_id']][] = $msg_id;
+ $_folder_id = (int) $rule_ary['folder_id'];
+ $move_into_folder[$_folder_id][] = $msg_id;
$num_new++;
break;
diff --git a/phpBB/includes/template.php b/phpBB/includes/template.php
index 6c90b95b1b..0562324068 100644
--- a/phpBB/includes/template.php
+++ b/phpBB/includes/template.php
@@ -255,7 +255,7 @@ class template
// Assign key variable pairs from an array to a specified block
function assign_block_vars($blockname, $vararray)
{
- if (strstr($blockname, '.'))
+ if (strpos($blockname, '.') !== false)
{
// Nested block.
$blocks = explode('.', $blockname);
@@ -271,6 +271,7 @@ class template
// Now we add the block that we're actually assigning to.
// We're adding a new iteration to this block with the given
// variable assignments.
+ $vararray['S_ROW_COUNT'] = sizeof($str[$blocks[$blockcount]]);
$str[$blocks[$blockcount]][] = &$vararray;
}
else
@@ -278,6 +279,7 @@ class template
// Top-level block.
// Add a new iteration to this block with the variable assignments
// we were given.
+ $vararray['S_ROW_COUNT'] = sizeof($this->_tpldata[$blockname]);
$this->_tpldata[$blockname][] = &$vararray;
}
diff --git a/phpBB/includes/ucp/ucp_attachments.php b/phpBB/includes/ucp/ucp_attachments.php
index 16b3dc3d77..b4566c0976 100644
--- a/phpBB/includes/ucp/ucp_attachments.php
+++ b/phpBB/includes/ucp/ucp_attachments.php
@@ -122,12 +122,13 @@ class ucp_attachments extends module
'POST_ID' => $row['post_msg_id'],
'TOPIC_ID' => $row['topic_id'],
- 'S_ROW_COUNT' => $row_count++,
'S_IN_MESSAGE' => $row['in_message'],
'U_VIEW_ATTACHMENT' => $phpbb_root_path . 'download.' . $phpEx . $SID . '&amp;id=' . $row['attach_id'],
'U_VIEW_TOPIC' => $view_topic)
);
+
+ $row_count++;
}
while ($row = $db->sql_fetchrow($result));
}
diff --git a/phpBB/includes/ucp/ucp_main.php b/phpBB/includes/ucp/ucp_main.php
index b1a72f19a9..33e72eab86 100644
--- a/phpBB/includes/ucp/ucp_main.php
+++ b/phpBB/includes/ucp/ucp_main.php
@@ -57,7 +57,6 @@ class ucp_main extends module
$tracking_topics = (isset($_COOKIE[$config['cookie_name'] . '_track'])) ? unserialize(stripslashes($_COOKIE[$config['cookie_name'] . '_track'])) : array();
- $i = 0;
$topic_type = $user->lang['VIEW_TOPIC_ANNOUNCEMENT'];
$folder = 'folder_announce';
$folder_new = $folder . '_new';
@@ -137,13 +136,10 @@ class ucp_main extends module
'TOPIC_FOLDER_IMG' => $user->img($folder_img, $folder_alt),
'ATTACH_ICON_IMG' => ($auth->acl_gets('f_download', 'u_download', $forum_id) && $row['topic_attachment']) ? $user->img('icon_attach', '') : '',
- 'S_ROW_COUNT' => $i,
'S_USER_POSTED' => (!empty($row['mark_type'])) ? true : false,
'U_VIEW_TOPIC' => $view_topic_url)
);
-
- $i++;
}
$db->sql_freeresult($result);
@@ -328,7 +324,6 @@ class ucp_main extends module
ORDER BY left_id';
$result = $db->sql_query($sql);
- $i = 0;
while ($row = $db->sql_fetchrow($result))
{
$forum_id = $row['forum_id'];
@@ -378,9 +373,7 @@ class ucp_main extends module
'U_LAST_POST_AUTHOR'=> $last_poster_url,
'U_LAST_POST' => $last_post_url,
- 'U_VIEWFORUM' => "viewforum.$phpEx$SID&amp;f=" . $row['forum_id'],
-
- 'S_ROW_COUNT' => $i++)
+ 'U_VIEWFORUM' => "viewforum.$phpEx$SID&amp;f=" . $row['forum_id'])
);
}
$db->sql_freeresult($result);
@@ -400,7 +393,6 @@ class ucp_main extends module
ORDER BY t.topic_last_post_time DESC';
$result = $db->sql_query_limit($sql, $config['topics_per_page']);
- $i = 0;
while ($row = $db->sql_fetchrow($result))
{
$forum_id = $row['forum_id'];
@@ -515,7 +507,6 @@ class ucp_main extends module
'TOPIC_FOLDER_IMG' => $user->img($folder_img, $folder_alt),
'ATTACH_ICON_IMG' => ($auth->acl_gets('f_download', 'u_download', $forum_id) && $row['topic_attachment']) ? $user->img('icon_attach', '') : '',
- 'S_ROW_COUNT' => $i++,
'S_USER_POSTED' => (!empty($row['mark_type'])) ? true : false,
'U_VIEW_TOPIC' => $view_topic_url)
@@ -620,7 +611,6 @@ class ucp_main extends module
ORDER BY b.order_id ASC';
$result = $db->sql_query($sql);
- $i = 0;
while ($row = $db->sql_fetchrow($result))
{
$forum_id = $row['forum_id'];
@@ -678,9 +668,7 @@ class ucp_main extends module
'U_VIEW_TOPIC' => $view_topic_url,
'U_VIEW_FORUM' => "{$phpbb_root_path}viewforum.$phpEx$SID&amp;f={$row['forum_id']}",
'U_MOVE_UP' => ($row['order_id'] != 1) ? "{$phpbb_root_path}ucp.$phpEx$SID&amp;i=main&amp;mode=bookmarks&amp;move_up={$row['order_id']}" : '',
- 'U_MOVE_DOWN' => ($row['order_id'] != $max_order_id) ? "{$phpbb_root_path}ucp.$phpEx$SID&amp;i=main&amp;mode=bookmarks&amp;move_down={$row['order_id']}" : '',
-
- 'S_ROW_COUNT' => $i++)
+ 'U_MOVE_DOWN' => ($row['order_id'] != $max_order_id) ? "{$phpbb_root_path}ucp.$phpEx$SID&amp;i=main&amp;mode=bookmarks&amp;move_down={$row['order_id']}" : '')
);
}
@@ -839,12 +827,12 @@ class ucp_main extends module
'U_VIEW_EDIT' => "ucp.$phpEx$SID&amp;i=$id&amp;mode=$mode&amp;edit=" . $draft['draft_id'],
'U_INSERT' => $insert_url,
- 'S_ROW_COUNT' => $row_count++,
'S_LINK_TOPIC' => $link_topic,
'S_LINK_FORUM' => $link_forum,
'S_LINK_PM' => $link_pm,
'S_HIDDEN_FIELDS' => $s_hidden_fields
);
+ $row_count++;
($edit) ? $template->assign_vars($template_row) : $template->assign_block_vars('draftrow', $template_row);
}
diff --git a/phpBB/includes/ucp/ucp_pm_viewfolder.php b/phpBB/includes/ucp/ucp_pm_viewfolder.php
index 328161baa6..8c82ca7c5d 100644
--- a/phpBB/includes/ucp/ucp_pm_viewfolder.php
+++ b/phpBB/includes/ucp/ucp_pm_viewfolder.php
@@ -118,7 +118,6 @@ function view_folder($id, $mode, $folder_id, $folder, $type)
unset($recipient_list, $address);
}
- $i = 0;
$url = "{$phpbb_root_path}ucp.$phpEx$SID&amp;i=$id";
foreach ($folder_info['pm_list'] as $message_id)
@@ -160,7 +159,6 @@ function view_folder($id, $mode, $folder_id, $folder, $type)
'PM_IMG' => ($row_indicator) ? $user->img('pm_' . $row_indicator, '') : '',
'ATTACH_ICON_IMG' => ($auth->acl_get('u_download') && $row['message_attachment'] && $config['pm_attachments'] && $config['auth_download_pm']) ? $user->img('icon_attach', sprintf($user->lang['TOTAL_ATTACHMENTS'], $row['message_attachment'])) : '',
- 'S_ROW_COUNT' => $i,
'S_PM_REPORTED' => (!empty($row['message_reported']) && $auth->acl_get('m_')) ? true : false,
'U_VIEW_PM' => $view_message_url,
diff --git a/phpBB/includes/ucp/ucp_pm_viewmessage.php b/phpBB/includes/ucp/ucp_pm_viewmessage.php
index bb9cda5804..f753f6433b 100644
--- a/phpBB/includes/ucp/ucp_pm_viewmessage.php
+++ b/phpBB/includes/ucp/ucp_pm_viewmessage.php
@@ -286,7 +286,6 @@ function message_history($msg_id, $user_id, $message_row, $folder)
$title = censor_text($title);
- $i = 1;
$url = "{$phpbb_root_path}ucp.$phpEx$SID&amp;i=pm";
$next_history_pm = $previous_history_pm = $prev_id = 0;
@@ -329,13 +328,10 @@ function message_history($msg_id, $user_id, $message_row, $folder)
'U_VIEW_MESSAGE'=> "$url&amp;f=$folder_id&amp;p=" . $row['msg_id'],
'U_AUTHOR_PROFILE' => "{$phpbb_root_path}memberlist.$phpEx$SID&amp;mode=viewprofile&amp;u=$author_id",
'U_QUOTE' => ($config['auth_quote_pm'] && $auth->acl_get('u_sendpm') && $author_id != $user->data['user_id']) ? "$url&amp;mode=compose&amp;action=quote&amp;f=" . $folder_id . "&amp;p=" . $row['msg_id'] : '',
- 'U_POST_REPLY_PM' => ($author_id != $user->data['user_id'] && $auth->acl_get('u_sendpm')) ? "$url&amp;mode=compose&amp;action=reply&amp;f=$folder_id&amp;p=" . $row['msg_id'] : '',
-
- 'S_ROW_COUNT' => $i)
+ 'U_POST_REPLY_PM' => ($author_id != $user->data['user_id'] && $auth->acl_get('u_sendpm')) ? "$url&amp;mode=compose&amp;action=reply&amp;f=$folder_id&amp;p=" . $row['msg_id'] : '')
);
unset($rowset[$id]);
$prev_id = $id;
- $i++;
}
$template->assign_vars(array(