diff options
Diffstat (limited to 'phpBB/includes')
-rw-r--r-- | phpBB/includes/functions_posting.php | 50 | ||||
-rw-r--r-- | phpBB/includes/message_parser.php | 82 |
2 files changed, 65 insertions, 67 deletions
diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index 3580eb478a..48816824a8 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -31,7 +31,7 @@ function generate_smilies($mode, $forum_id) $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); - $user->setup(FALSE, (int) $row['forum_style']); + $user->setup(false, (int) $row['forum_style']); page_header($user->lang['SMILIES']); @@ -40,7 +40,7 @@ function generate_smilies($mode, $forum_id) ); } - $display_link = FALSE; + $display_link = false; if ($mode == 'inline') { $sql = 'SELECT smile_id @@ -50,7 +50,7 @@ function generate_smilies($mode, $forum_id) if ($row = $db->sql_fetchrow($result)) { - $display_link = TRUE; + $display_link = true; } $db->sql_freeresult($result); } @@ -77,7 +77,7 @@ function generate_smilies($mode, $forum_id) if ($mode == 'inline' && $display_link) { $template->assign_vars(array( - 'S_SHOW_EMOTICON_LINK' => TRUE, + 'S_SHOW_EMOTICON_LINK' => true, 'U_MORE_SMILIES' => $phpbb_root_path . "posting.$phpEx$SID&mode=smilies&f=$forum_id") ); } @@ -98,7 +98,7 @@ function format_display(&$message, &$signature, $uid, $siguid, $html, $bbcode, $ // If we allow users to disable display of emoticons we'll need an appropriate // check and preg_replace here - $message = (empty($smilies) || empty($config['allow_smilies'])) ? preg_replace('#<!\-\- s(.*?) \-\-><img src="\{SMILE_PATH\}\/.*? \/><!\-\- s\1 \-\->#', '\1', $message) : str_replace('<img src="{SMILE_PATH}', '<img src="' . $phpbb_root_path . $config['smilies_path'], $message); + $message = (!$smilies || !$config['allow_smilies']) ? preg_replace('#<!\-\- s(.*?) \-\-><img src="\{SMILE_PATH\}\/.*? \/><!\-\- s\1 \-\->#', '\1', $message) : str_replace('<img src="{SMILE_PATH}', '<img src="' . $phpbb_root_path . $config['smilies_path'], $message); // Replace naughty words such as farty pants if (sizeof($censors)) @@ -115,7 +115,7 @@ function format_display(&$message, &$signature, $uid, $siguid, $html, $bbcode, $ $bbcode->bbcode_second_pass($signature, $siguid); - $signature = (!$config['enable_smilies']) ? preg_replace('#<!\-\- s(.*?) \-\-><img src="\{SMILE_PATH\}\/.*? \/><!\-\- s\1 \-\->#', '\1', $signature) : str_replace('<img src="{SMILE_PATH}', '<img src="' . $phpbb_root_path . $config['smilies_path'], $signature); + $signature = (!$config['allow_smilies']) ? preg_replace('#<!\-\- s(.*?) \-\-><img src="\{SMILE_PATH\}\/.*? \/><!\-\- s\1 \-\->#', '\1', $signature) : str_replace('<img src="{SMILE_PATH}', '<img src="' . $phpbb_root_path . $config['smilies_path'], $signature); if (sizeof($censors)) { @@ -146,7 +146,7 @@ function update_last_post_information($type, $id) $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); - if (!empty($row['last_post_id'])) + if ($row['last_post_id']) { $sql = 'SELECT p.post_id, p.poster_id, p.post_time, u.username, p.post_username FROM ' . POSTS_TABLE . ' p, ' . USERS_TABLE . ' u @@ -179,7 +179,7 @@ function upload_attachment($filename, $local = false, $local_storage = '') $filedata = array(); $filedata['error'] = array(); - $filedata['post_attach'] = ($filename != '') ? TRUE : FALSE; + $filedata['post_attach'] = ($filename) ? true : false; if (!$filedata['post_attach']) { @@ -202,7 +202,7 @@ function upload_attachment($filename, $local = false, $local_storage = '') if (!in_array($filedata['extension'], $extensions['_allowed_'])) { $filedata['error'][] = sprintf($user->lang['DISALLOWED_EXTENSION'], $filedata['extension']); - $filedata['post_attach'] = FALSE; + $filedata['post_attach'] = false; return $filedata; } @@ -213,7 +213,7 @@ function upload_attachment($filename, $local = false, $local_storage = '') if (preg_match("#[\\/:*?\"<>|]#i", $filename)) { $filedata['error'][] = sprintf($user->lang['INVALID_FILENAME'], $filename); - $filedata['post_attach'] = FALSE; + $filedata['post_attach'] = false; return $filedata; } @@ -221,7 +221,7 @@ function upload_attachment($filename, $local = false, $local_storage = '') if ($file == 'none') { $filedata['error'][] = (@ini_get('upload_max_filesize') == '') ? $user->lang['ATTACHMENT_PHP_SIZE_NA'] : sprintf($user->lang['ATTACHMENT_PHP_SIZE_OVERRUN'], @ini_get('upload_max_filesize')); - $filedata['post_attach'] = FALSE; + $filedata['post_attach'] = false; return $filedata; } @@ -235,7 +235,7 @@ function upload_attachment($filename, $local = false, $local_storage = '') if ($width > $config['img_max_width'] || $height > $config['img_max_height']) { $filedata['error'][] = sprintf($user->lang['ERROR_IMAGESIZE'], $config['img_max_width'], $config['img_max_height']); - $filedata['post_attach'] = FALSE; + $filedata['post_attach'] = false; return $filedata; } } @@ -249,7 +249,7 @@ function upload_attachment($filename, $local = false, $local_storage = '') $allowed_filesize = ($allowed_filesize >= 1048576) ? round($allowed_filesize / 1048576 * 100) / 100 : (($allowed_filesize >= 1024) ? round($allowed_filesize / 1024 * 100) / 100 : $allowed_filesize); $filedata['error'][] = sprintf($user->lang['ATTACHMENT_TOO_BIG'], $allowed_filesize, $size_lang); - $filedata['post_attach'] = FALSE; + $filedata['post_attach'] = false; return $filedata; } @@ -259,7 +259,7 @@ function upload_attachment($filename, $local = false, $local_storage = '') if ($config['upload_dir_size'] + $filedata['filesize'] > $config['attachment_quota']) { $filedata['error'][] = $user->lang['ATTACH_QUOTA_REACHED']; - $filedata['post_attach'] = FALSE; + $filedata['post_attach'] = false; return $filedata; } } @@ -272,7 +272,7 @@ function upload_attachment($filename, $local = false, $local_storage = '') if ($free_space <= $filedata['filesize']) { $filedata['error'][] = $user->lang['ATTACH_QUOTA_REACHED']; - $filedata['post_attach'] = FALSE; + $filedata['post_attach'] = false; return $filedata; } } @@ -302,10 +302,10 @@ function upload_attachment($filename, $local = false, $local_storage = '') // Ok, upload the File $result = move_uploaded_attachment($upload_mode, $file, $filedata); - if ($result != '') + if ($result) { $filedata['error'][] = $result; - $filedata['post_attach'] = FALSE; + $filedata['post_attach'] = false; } return $filedata; } @@ -316,7 +316,7 @@ function move_uploaded_attachment($upload_mode, $source_filename, &$filedata) global $user, $config, $phpbb_root_path; $destination_filename = $filedata['destination_filename']; - $thumbnail = (isset($filedata['thumbnail'])) ? $filedata['thumbnail'] : FALSE; + $thumbnail = (isset($filedata['thumbnail'])) ? $filedata['thumbnail'] : false; switch ($upload_mode) { @@ -441,25 +441,25 @@ function create_thumbnail($source, $new_file, $mimetype) $source = realpath($source); $min_filesize = (int) $config['img_min_thumb_filesize']; - $img_filesize = (file_exists($source)) ? @filesize($source) : FALSE; + $img_filesize = (file_exists($source)) ? @filesize($source) : false; if (!$img_filesize || $img_filesize <= $min_filesize) { - return FALSE; + return false; } $size = getimagesize($source); if ($size[0] == 0 && $size[1] == 0) { - return FALSE; + return false; } $new_size = get_img_size_format($size[0], $size[1]); $tmp_path = $old_file = ''; - $used_imagick = FALSE; + $used_imagick = false; if ($config['img_imagick']) { @@ -468,7 +468,7 @@ function create_thumbnail($source, $new_file, $mimetype) 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; } } } @@ -508,13 +508,13 @@ function create_thumbnail($source, $new_file, $mimetype) if (!file_exists($new_file)) { - return FALSE; + return false; } @chmod($new_file, 0666); - return TRUE; + return true; } // diff --git a/phpBB/includes/message_parser.php b/phpBB/includes/message_parser.php index 4944f94c6d..ec3f4cd841 100644 --- a/phpBB/includes/message_parser.php +++ b/phpBB/includes/message_parser.php @@ -28,7 +28,7 @@ if (!function_exists('stripos')) return strpos($haystack, $m[0]); } - return FALSE; + return false; } } @@ -55,7 +55,7 @@ class parse_message $this->bbcode_uid = substr(md5(time()), 0, BBCODE_UID_LEN); } - function parse($html, $bbcode, $url, $smilies, $allow_img = TRUE, $allow_flash = TRUE, $allow_quote = TRUE) + function parse($html, $bbcode, $url, $smilies, $allow_img = true, $allow_flash = true, $allow_quote = true) { global $config, $db, $user; @@ -74,7 +74,7 @@ class parse_message } $this->html($html); - if ($bbcode && strpos($this->message, '[') !== FALSE) + if ($bbcode && strpos($this->message, '[') !== false) { $this->bbcode_init(); $disallow = array('allow_img', 'allow_flash', 'allow_quote'); @@ -82,7 +82,7 @@ class parse_message { if (!${$bool}) { - $this->bbcodes[str_replace('allow_', '', $bool)]['disabled'] = TRUE; + $this->bbcodes[str_replace('allow_', '', $bool)]['disabled'] = true; } } $this->bbcode(); @@ -125,7 +125,7 @@ class parse_message $size = strlen($this->message); foreach ($this->bbcodes as $bbcode_name => $bbcode_data) { - if (!empty($bbcode_data['disabled'])) + if ($bbcode_data['disabled']) { foreach ($bbcode_data['regexp'] as $regexp => $replacement) { @@ -237,14 +237,14 @@ class parse_message switch (strtolower($stx)) { case 'php': - $remove_tags = FALSE; + $remove_tags = false; $str_from = array('<', '>'); $str_to = array('<', '>'); $code = str_replace($str_from, $str_to, $code); if (!preg_match('/^\<\?.*?\?\>/is', $code)) { - $remove_tags = TRUE; + $remove_tags = true; $code = "<?php $code ?>"; } @@ -319,7 +319,7 @@ class parse_message for ($i = 0; $i < strlen($tok); ++$i) { $tmp_pos = strpos($in, $tok{$i}); - if ($tmp_pos !== FALSE && $tmp_pos < $pos) + if ($tmp_pos !== false && $tmp_pos < $pos) { $pos = $tmp_pos; } @@ -435,7 +435,7 @@ class parse_message for ($i = 0; $i < strlen($tok); ++$i) { $tmp_pos = strpos($in, $tok{$i}); - if ($tmp_pos !== FALSE && $tmp_pos < $pos) + if ($tmp_pos !== false && $tmp_pos < $pos) { $pos = $tmp_pos; } @@ -472,11 +472,11 @@ class parse_message array_push($close_tags, '/quote:' . $this->bbcode_uid); - if (!empty($m[1])) + if ($m[1]) { $username = preg_replace('#\[(?!b|i|u|color|url|email|/b|/i|/u|/color|/url|/email)#iU', '[$1', $m[1]); $end_tags = array(); - $error = FALSE; + $error = false; preg_match_all('#\[((?:/)?(?:[a-z]+))#i', $username, $tags); foreach ($tags[1] as $tag) @@ -490,11 +490,11 @@ class parse_message $end_tag = array_pop($end_tags); if ($end_tag != $tag) { - $error = TRUE; + $error = true; } else { - $error = FALSE; + $error = false; } } } @@ -550,13 +550,13 @@ class parse_message function validate_email($var1, $var2) { $txt = stripslashes($var2); - $email = ($var1 != '') ? stripslashes($var1) : stripslashes($var2); + $email = ($var1) ? stripslashes($var1) : stripslashes($var2); - $validated = TRUE; + $validated = true; if (!preg_match('!([a-z0-9]+[a-z0-9\-\._]*@(?:(?:[0-9]{1,3}\.){3,5}[0-9]{1,3}|[a-z0-9]+[a-z0-9\-\._]*\.[a-z]+))!i', $email)) { - $validated = FALSE; + $validated = false; } if (!$validated) @@ -577,19 +577,19 @@ class parse_message function validate_url($var1, $var2) { - $url = (!empty($var1)) ? stripslashes($var1) : stripslashes($var2); + $url = ($var1) ? stripslashes($var1) : stripslashes($var2); // Put validation regexps here - $valid = FALSE; + $valid = false; if (preg_match('#^http(s?)://#i', $url)) { - $valid = TRUE; + $valid = true; } if ($valid) { - return (empty($url)) ? '[url:' . $this->bbcode_uid . ']' . $url . '[/url:' . $this->bbcode_uid . ']' : "[url=$url:" . $this->bbcode_uid . ']' . stripslashes($var2) . '[/url:' . $this->bbcode_uid . ']'; + return (!$url) ? '[url:' . $this->bbcode_uid . ']' . $url . '[/url:' . $this->bbcode_uid . ']' : "[url=$url:" . $this->bbcode_uid . ']' . stripslashes($var2) . '[/url:' . $this->bbcode_uid . ']'; } - return '[url' . ((!empty($var1)) ? '=' . stripslashes($var1) : '') . ']' . stripslashes($var2) . '[/url]'; + return '[url' . (($var1) ? '=' . stripslashes($var1) : '') . ']' . stripslashes($var2) . '[/url]'; } // Replace magic urls of form http://xxx.xxx., www.xxx. and xxx@xxx.xxx. @@ -658,7 +658,7 @@ class parse_message { $num_matches = preg_match_all('#' . str_replace('#', '', implode('|', $match)) . '#', $this->message, $matches); - if ($num_matches !== FALSE && $num_matches > intval($config['max_post_smilies'])) + if ($num_matches !== false && $num_matches > intval($config['max_post_smilies'])) { $this->message = str_replace("\\n", "\n", $this->message); $this->warn_msg[] = $user->lang['TOO_MANY_SMILIES']; @@ -681,11 +681,11 @@ class parse_message $this->filename_data['filecomment'] = preg_replace('#&(\#[0-9]+;)#', '&\1', request_var('filecomment', '')); $this->filename_data['filename'] = ($_FILES['fileupload']['name'] != 'none') ? trim($_FILES['fileupload']['name']) : ''; - $add_file = (isset($_POST['add_file'])) ? TRUE : FALSE; - $delete_file = (isset($_POST['delete_file'])) ? TRUE : FALSE; - $edit_comment = (isset($_POST['edit_comment'])) ? TRUE : FALSE; + $add_file = (isset($_POST['add_file'])); + $delete_file = (isset($_POST['delete_file'])); + $edit_comment = (isset($_POST['edit_comment'])); - if ($submit && in_array($mode, array('post', 'reply', 'quote', 'edit')) && $this->filename_data['filename'] != '') + if ($submit && in_array($mode, array('post', 'reply', 'quote', 'edit')) && $this->filename_data['filename']) { if ($num_attachments < $config['max_attachments'] || $auth->acl_gets('m_', 'a_')) { @@ -710,7 +710,7 @@ class parse_message $this->attachment_data = array_merge(array(0 => $new_entry), $this->attachment_data); $this->filename_data['filecomment'] = ''; - // This Variable is set to FALSE here, because Attachments are entered into the + // This Variable is set to false here, because Attachments are entered into the // Database in two modes, one if the id_list is 0 and the second one if post_attach is true // Since post_attach is automatically switched to true if an Attachment got added to the filesystem, // but we are assigning an id of 0 here, we have to reset the post_attach variable to false. @@ -718,7 +718,7 @@ class parse_message // This is very relevant, because it could happen that the post got not submitted, but we do not // know this circumstance here. We could be at the posting page or we could be redirected to the entered // post. :) - $filedata['post_attach'] = FALSE; + $filedata['post_attach'] = false; } } else @@ -766,7 +766,7 @@ class parse_message } } - if (($add_file || $preview) && $this->filename_data['filename'] != '') + if (($add_file || $preview) && $this->filename_data['filename']) { if ($num_attachments < $config['max_attachments'] || $auth->acl_gets('m_', 'a_')) { @@ -812,14 +812,12 @@ class parse_message global $auth, $forum_id, $user, $config; // Process poll options - if (!empty($poll_data['poll_option_text']) && - (($auth->acl_get('f_poll', $forum_id) && !$poll_data['poll_last_vote']) || - $auth->acl_get('m_edit', $forum_id))) + if ($poll_data['poll_option_text'] && (($auth->acl_get('f_poll', $forum_id) && !$poll_data['poll_last_vote']) || $auth->acl_get('m_edit', $forum_id))) { $message = $this->message; $this->message = $poll_data['poll_option_text']; - if (($result = $this->parse($poll_data['enable_html'], $poll_data['enable_bbcode'], $poll_data['bbcode_uid'], $poll_data['enable_urls'], $poll_data['enable_smilies'], FALSE)) != '') + if (($result = $this->parse($poll_data['enable_html'], $poll_data['enable_bbcode'], $poll_data['bbcode_uid'], $poll_data['enable_urls'], $poll_data['enable_smilies'], false)) != '') { $this->warn_msg[] = $result; } @@ -847,10 +845,10 @@ class parse_message $this->warn_msg[] = $user->lang['TOO_MANY_USER_OPTIONS']; } - $poll['poll_title'] = (!empty($poll_data['poll_title'])) ? $poll_data['poll_title'] : ''; - $poll['poll_length'] = (!empty($poll_data['poll_length'])) ? intval($poll_data['poll_length']) : 0; + $poll['poll_title'] = ($poll_data['poll_title']) ? $poll_data['poll_title'] : ''; + $poll['poll_length'] = ($poll_data['poll_length']) ? intval($poll_data['poll_length']) : 0; - if (empty($poll['poll_title']) && $poll['poll_options_size']) + if (!$poll['poll_title'] && $poll['poll_options_size']) { $this->warn_msg[] = $user->lang['NO_POLL_TITLE']; } @@ -872,12 +870,12 @@ class fulltext_search // Is the fulltext indexer disabled? If yes then we need not // carry on ... it's okay ... I know when I'm not wanted boo hoo - if (empty($config['load_search_upd'])) + if (!$config['load_search_upd']) { return; } - if (empty($drop_char_match)) + if (!$drop_char_match) { $drop_char_match = array('^', '$', '&', '(', ')', '<', '>', '`', '\'', '"', '|', ',', '@', '_', '?', '%', '~', '.', '[', ']', '{', '}', ':', '\\', '/', '=', '#', '\'', ';', '!', '*'); $drop_char_replace = array(' ', ' ', ' ', ' ', ' ', ' ', ' ', '', '', ' ', ' ', ' ', ' ', '', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '' , ' ', ' ', ' ', ' ', ' ', ' ', ' '); @@ -921,13 +919,13 @@ class fulltext_search // Split words $text = explode(' ', preg_replace('#\s+#', ' ', $text)); - if (!empty($stopwords)) + if ($stopwords) { $stopped_words = array_intersect($text, $stopwords); $text = array_diff($text, $stopwords); } - if (!empty($replace_synonym)) + if ($replace_synonym) { $text = str_replace($replace_synonym, $match_synonym, $text); } @@ -941,7 +939,7 @@ class fulltext_search // Is the fulltext indexer disabled? If yes then we need not // carry on ... it's okay ... I know when I'm not wanted boo hoo - if (empty($config['load_search_upd'])) + if (!$config['load_search_upd']) { return; } @@ -1090,7 +1088,7 @@ class fulltext_search // Is the fulltext indexer disabled? If yes then we need not // carry on ... it's okay ... I know when I'm not wanted boo hoo - if (empty($config['load_search_upd'])) + if (!$config['load_search_upd']) { return; } |