diff options
Diffstat (limited to 'phpBB/develop')
29 files changed, 231 insertions, 49 deletions
diff --git a/phpBB/develop/add_permissions.php b/phpBB/develop/add_permissions.php index 035c23f49c..5d9af3cad5 100644 --- a/phpBB/develop/add_permissions.php +++ b/phpBB/develop/add_permissions.php @@ -413,5 +413,3 @@ function mass_auth($ug_type, $forum_id, $ug_id, $acl_list, $setting) unset($sql_ary); } - -?>
\ No newline at end of file diff --git a/phpBB/develop/adjust_avatars.php b/phpBB/develop/adjust_avatars.php index 81599e694b..dc4ae88f37 100644 --- a/phpBB/develop/adjust_avatars.php +++ b/phpBB/develop/adjust_avatars.php @@ -143,5 +143,3 @@ function adjust_avatar($old_name, $midfix) } return false; } - -?>
\ No newline at end of file diff --git a/phpBB/develop/adjust_bbcodes.php b/phpBB/develop/adjust_bbcodes.php index f06f0112ab..5a7f065d7f 100644 --- a/phpBB/develop/adjust_bbcodes.php +++ b/phpBB/develop/adjust_bbcodes.php @@ -170,5 +170,3 @@ $db->sql_freeresult($result); // Done $db->sql_close(); - -?>
\ No newline at end of file diff --git a/phpBB/develop/adjust_magic_urls.php b/phpBB/develop/adjust_magic_urls.php index 1430a47a12..c417c755cf 100644 --- a/phpBB/develop/adjust_magic_urls.php +++ b/phpBB/develop/adjust_magic_urls.php @@ -122,5 +122,3 @@ $db->sql_freeresult($result); // Done $db->sql_close(); - -?>
\ No newline at end of file diff --git a/phpBB/develop/adjust_sizes.php b/phpBB/develop/adjust_sizes.php index 7d72813056..9b58389163 100644 --- a/phpBB/develop/adjust_sizes.php +++ b/phpBB/develop/adjust_sizes.php @@ -128,5 +128,3 @@ $db->sql_freeresult($result); // Done $db->sql_close(); - -?>
\ No newline at end of file diff --git a/phpBB/develop/adjust_smilies.php b/phpBB/develop/adjust_smilies.php index 774c8834f6..ecc3461670 100644 --- a/phpBB/develop/adjust_smilies.php +++ b/phpBB/develop/adjust_smilies.php @@ -126,5 +126,3 @@ $db->sql_freeresult($result); // Done $db->sql_close(); - -?>
\ No newline at end of file diff --git a/phpBB/develop/adjust_uids.php b/phpBB/develop/adjust_uids.php index d301f3cadb..3468475b8f 100644 --- a/phpBB/develop/adjust_uids.php +++ b/phpBB/develop/adjust_uids.php @@ -126,4 +126,3 @@ $db->sql_freeresult($result); // Done $db->sql_close(); echo 'done'; -?>
\ No newline at end of file diff --git a/phpBB/develop/adjust_usernames.php b/phpBB/develop/adjust_usernames.php index 1afa77af16..111a9a30d7 100644 --- a/phpBB/develop/adjust_usernames.php +++ b/phpBB/develop/adjust_usernames.php @@ -48,5 +48,3 @@ echo 'FINISHED'; // Done $db->sql_close(); - -?>
\ No newline at end of file diff --git a/phpBB/develop/benchmark.php b/phpBB/develop/benchmark.php index 5bbe6f53be..c867b9262e 100644 --- a/phpBB/develop/benchmark.php +++ b/phpBB/develop/benchmark.php @@ -458,5 +458,3 @@ function make_user($username) } } - -?>
\ No newline at end of file diff --git a/phpBB/develop/calc_email_hash.php b/phpBB/develop/calc_email_hash.php index a67b0f52a3..0f7540ee7d 100644 --- a/phpBB/develop/calc_email_hash.php +++ b/phpBB/develop/calc_email_hash.php @@ -72,5 +72,3 @@ do while ($start); echo "<p><b>Done</b></p>\n"; - -?>
\ No newline at end of file diff --git a/phpBB/develop/change_smiley_ref.php b/phpBB/develop/change_smiley_ref.php index db65dd52d4..23a26951bf 100644 --- a/phpBB/develop/change_smiley_ref.php +++ b/phpBB/develop/change_smiley_ref.php @@ -58,5 +58,3 @@ while ($row = $db->sql_fetchrow($result)) $db->sql_freeresult($result); echo "<p><b>Done</b></p>\n"; - -?>
\ No newline at end of file diff --git a/phpBB/develop/check_flash_bbcodes.php b/phpBB/develop/check_flash_bbcodes.php new file mode 100644 index 0000000000..b0fa399209 --- /dev/null +++ b/phpBB/develop/check_flash_bbcodes.php @@ -0,0 +1,163 @@ +<?php +/** +* +* @package phpBB3 +* @version $Id$ +* @copyright (c) 2009, 2010 phpBB Group +* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* +*/ + +/** +* This script will check your database for potentially dangerous flash BBCode tags +*/ + +// +// Security message: +// +// This script is potentially dangerous. +// Remove or comment the next line (die(".... ) to enable this script. +// Do NOT FORGET to either remove this script or disable it after you have used it. +// +die("Please read the first lines of this script for instructions on how to enable it\n"); + +/** +*/ +define('IN_PHPBB', true); +$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './'; +$phpEx = substr(strrchr(__FILE__, '.'), 1); +include($phpbb_root_path . 'common.' . $phpEx); + +if (php_sapi_name() != 'cli') +{ + header('Content-Type: text/plain'); +} + +check_table_flash_bbcodes(POSTS_TABLE, 'post_id', 'post_text', 'bbcode_uid', 'bbcode_bitfield'); +check_table_flash_bbcodes(PRIVMSGS_TABLE, 'msg_id', 'message_text', 'bbcode_uid', 'bbcode_bitfield'); +check_table_flash_bbcodes(USERS_TABLE, 'user_id', 'user_sig', 'user_sig_bbcode_uid', 'user_sig_bbcode_bitfield'); +check_table_flash_bbcodes(FORUMS_TABLE, 'forum_id', 'forum_desc', 'forum_desc_uid', 'forum_desc_bitfield'); +check_table_flash_bbcodes(FORUMS_TABLE, 'forum_id', 'forum_rules', 'forum_rules_uid', 'forum_rules_bitfield'); +check_table_flash_bbcodes(GROUPS_TABLE, 'group_id', 'group_desc', 'group_desc_uid', 'group_desc_bitfield'); + +echo "If potentially dangerous flash bbcodes were found, please reparse the posts using the Support Toolkit (http://www.phpbb.com/support/stk/) and/or file a ticket in the Incident Tracker (http://www.phpbb.com/incidents/).\n"; + +function check_table_flash_bbcodes($table_name, $id_field, $content_field, $uid_field, $bitfield_field) +{ + echo "Checking $content_field on $table_name\n"; + + $ids = get_table_flash_bbcode_pkids($table_name, $id_field, $content_field, $uid_field, $bitfield_field); + + $size = sizeof($ids); + if ($size) + { + echo "Found $size potentially dangerous flash bbcodes.\n"; + echo "$id_field: " . implode(', ', $ids) . "\n"; + } + else + { + echo "No potentially dangerous flash bbcodes found.\n"; + } + + echo "\n"; +} + +function get_table_flash_bbcode_pkids($table_name, $id_field, $content_field, $uid_field, $bitfield_field) +{ + global $db; + + $ids = array(); + + $sql = "SELECT $id_field, $content_field, $uid_field, $bitfield_field + FROM $table_name + WHERE $content_field LIKE '%[/flash:%' + AND $bitfield_field <> ''"; + + $result = $db->sql_query($sql); + while ($row = $db->sql_fetchrow($result)) + { + $uid = $row[$uid_field]; + + // thanks support toolkit + $content = html_entity_decode_utf8($row[$content_field]); + set_var($content, $content, 'string', true); + $content = utf8_normalize_nfc($content); + + $bitfield_data = $row[$bitfield_field]; + + if (!is_valid_flash_bbcode($content, $uid) && has_flash_enabled($bitfield_data)) + { + $ids[] = (int) $row[$id_field]; + } + } + $db->sql_freeresult($result); + + return $ids; +} + +function get_flash_regex($uid) +{ + return "#\[flash=([0-9]+),([0-9]+):$uid\](.*?)\[/flash:$uid\]#"; +} + +// extract all valid flash bbcodes +// check if the bbcode content is a valid URL for each match +function is_valid_flash_bbcode($cleaned_content, $uid) +{ + $regex = get_flash_regex($uid); + + $url_regex = get_preg_expression('url'); + $www_url_regex = get_preg_expression('www_url'); + + if (preg_match_all($regex, $cleaned_content, $matches)) + { + foreach ($matches[3] as $flash_url) + { + if (!preg_match("#^($url_regex|$www_url_regex)$#i", $flash_url)) + { + return false; + } + } + } + + return true; +} + +// check if a bitfield includes flash +// 11 = flash bit +function has_flash_enabled($bitfield_data) +{ + $bitfield = new bitfield($bitfield_data); + return $bitfield->get(11); +} + +// taken from support toolkit +function html_entity_decode_utf8($string) +{ + static $trans_tbl; + + // replace numeric entities + $string = preg_replace('~&#x([0-9a-f]+);~ei', 'code2utf8(hexdec("\\1"))', $string); + $string = preg_replace('~&#([0-9]+);~e', 'code2utf8(\\1)', $string); + + // replace literal entities + if (!isset($trans_tbl)) + { + $trans_tbl = array(); + + foreach (get_html_translation_table(HTML_ENTITIES) as $val=>$key) + $trans_tbl[$key] = utf8_encode($val); + } + return strtr($string, $trans_tbl); +} + +// taken from support toolkit +// Returns the utf string corresponding to the unicode value (from php.net, courtesy - romans@void.lv) +function code2utf8($num) +{ + if ($num < 128) return chr($num); + if ($num < 2048) return chr(($num >> 6) + 192) . chr(($num & 63) + 128); + if ($num < 65536) return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); + if ($num < 2097152) return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); + return ''; +} diff --git a/phpBB/develop/create_schema_files.php b/phpBB/develop/create_schema_files.php index 4fb7b0d8f7..c0ec876397 100644 --- a/phpBB/develop/create_schema_files.php +++ b/phpBB/develop/create_schema_files.php @@ -2047,5 +2047,3 @@ EOF; } echo 'done'; - -?>
\ No newline at end of file diff --git a/phpBB/develop/create_variable_overview.php b/phpBB/develop/create_variable_overview.php index 3782f53e4c..d2b7193df9 100644 --- a/phpBB/develop/create_variable_overview.php +++ b/phpBB/develop/create_variable_overview.php @@ -543,5 +543,3 @@ fclose($fp); echo '<br>Finished!'; flush(); - -?>
\ No newline at end of file diff --git a/phpBB/develop/fill.php b/phpBB/develop/fill.php index 336e510d06..c9824e88e5 100644 --- a/phpBB/develop/fill.php +++ b/phpBB/develop/fill.php @@ -186,5 +186,3 @@ function rndm_username() return $usernames[array_rand($usernames)]; } - -?>
\ No newline at end of file diff --git a/phpBB/develop/generate_utf_casefold.php b/phpBB/develop/generate_utf_casefold.php index 89c4aec01a..4f764ca471 100644 --- a/phpBB/develop/generate_utf_casefold.php +++ b/phpBB/develop/generate_utf_casefold.php @@ -152,5 +152,3 @@ function download($url) echo "\n"; } - -?>
\ No newline at end of file diff --git a/phpBB/develop/generate_utf_confusables.php b/phpBB/develop/generate_utf_confusables.php index 0ffa9720c9..bc88e67ba9 100644 --- a/phpBB/develop/generate_utf_confusables.php +++ b/phpBB/develop/generate_utf_confusables.php @@ -240,5 +240,3 @@ function download($url) echo "\n"; } - -?>
\ No newline at end of file diff --git a/phpBB/develop/generate_utf_tables.php b/phpBB/develop/generate_utf_tables.php index 3d5188163d..dbef125803 100644 --- a/phpBB/develop/generate_utf_tables.php +++ b/phpBB/develop/generate_utf_tables.php @@ -569,4 +569,4 @@ function cp_to_utf($cp) { return chr($cp); } -}
\ No newline at end of file +} diff --git a/phpBB/develop/lang_duplicates.php b/phpBB/develop/lang_duplicates.php index 5be48f69f0..3ea841b6d6 100644 --- a/phpBB/develop/lang_duplicates.php +++ b/phpBB/develop/lang_duplicates.php @@ -137,4 +137,4 @@ function find_modules($dirname) ?> </body> -</html>
\ No newline at end of file +</html> diff --git a/phpBB/develop/merge_attachment_tables.php b/phpBB/develop/merge_attachment_tables.php index ae7fe57be4..aa6be0a26e 100644 --- a/phpBB/develop/merge_attachment_tables.php +++ b/phpBB/develop/merge_attachment_tables.php @@ -76,5 +76,3 @@ $db->sql_query($sql); //$db->sql_query("DROP TABLE {$table_prefix}attach_temp"); echo "<p><b>Done</b></p>\n"; - -?>
\ No newline at end of file diff --git a/phpBB/develop/merge_post_tables.php b/phpBB/develop/merge_post_tables.php index 3567a569c6..e7e22409a5 100644 --- a/phpBB/develop/merge_post_tables.php +++ b/phpBB/develop/merge_post_tables.php @@ -205,5 +205,3 @@ foreach ($sql_ary as $sql) } echo "<p><b>Done</b></p>\n"; - -?>
\ No newline at end of file diff --git a/phpBB/develop/mysql_upgrader.php b/phpBB/develop/mysql_upgrader.php index 85da1dfa47..f61aa2e4f0 100644 --- a/phpBB/develop/mysql_upgrader.php +++ b/phpBB/develop/mysql_upgrader.php @@ -1398,5 +1398,3 @@ function get_schema_struct() return $schema_data; } - -?>
\ No newline at end of file diff --git a/phpBB/develop/nuke-db.php b/phpBB/develop/nuke-db.php index d7329c3f56..e1f64a6177 100644 --- a/phpBB/develop/nuke-db.php +++ b/phpBB/develop/nuke-db.php @@ -54,5 +54,3 @@ else flush(); } } -?> - diff --git a/phpBB/develop/regex.php b/phpBB/develop/regex.php index 8165ba1f21..46b6fff701 100644 --- a/phpBB/develop/regex.php +++ b/phpBB/develop/regex.php @@ -80,5 +80,3 @@ echo 'www.URL: ' . $www_url . "<br />\n"; // no schema and no authority $relative_url = "$segment$path_abempty(?:\?$query)?(?:\#$fragment)?"; echo 'relative URL: ' . $relative_url . "<br />\n"; - -?>
\ No newline at end of file diff --git a/phpBB/develop/remove-php-end-tags.py b/phpBB/develop/remove-php-end-tags.py new file mode 100755 index 0000000000..1707c6d519 --- /dev/null +++ b/phpBB/develop/remove-php-end-tags.py @@ -0,0 +1,65 @@ +#!/usr/bin/env python +# Remove ending PHP tags '?>' +# @author Oleg Pudeyev +# @license http://opensource.org/licenses/gpl-license.php GNU Public License + +import sys, os, os.path, optparse + +def error(message, code): + print >>sys.stderr, message + exit(code) + + +parser = optparse.OptionParser() +parser.add_option('-a', '--aggressive', help='Remove ending tags when they are followed by whitespace', action='store_true') +options, args = parser.parse_args() + +if len(args) != 1: + parser.usage() + error("Usage: remove-php-end-tags path", 2) + +path = args[0] + +if not os.path.exists(path): + error("Path does not exist: %s" % path, 3) + +if options.aggressive: + import re + + fix_re = re.compile(r'\s*\?>\s*$') + def fix_content(content): + content = fix_re.sub(r'\n', content) + return content +else: + def fix_content(content): + if content.endswith('?>'): + content = content[:-2].strip() + "\n" + return content + +def process_file(path): + f = open(path) + try: + content = f.read() + finally: + f.close() + fixed_content = fix_content(content) + if content != fixed_content: + f = open(path, 'w') + try: + f.write(fixed_content) + finally: + f.close() + +def process_dir(path): + for root, dirs, files in os.walk(path): + if '.svn' in dirs: + dirs.remove('.svn') + for file in files: + if file.endswith('.php'): + path = os.path.join(root, file) + process_file(path) + +if os.path.isdir(path): + process_dir(path) +else: + process_file(path) diff --git a/phpBB/develop/repair_bots.php b/phpBB/develop/repair_bots.php index c5aaa75d9b..790d3d9f2f 100644 --- a/phpBB/develop/repair_bots.php +++ b/phpBB/develop/repair_bots.php @@ -147,5 +147,3 @@ function add_bots($bots) } } } - -?>
\ No newline at end of file diff --git a/phpBB/develop/unicode_testing.php b/phpBB/develop/unicode_testing.php index 25a13d1325..ec3c71d078 100644 --- a/phpBB/develop/unicode_testing.php +++ b/phpBB/develop/unicode_testing.php @@ -116,5 +116,3 @@ function utf8_normalize_nfkc($strings) return $strings; } - -?>
\ No newline at end of file diff --git a/phpBB/develop/update_email_hash.php b/phpBB/develop/update_email_hash.php index 80fd4bbc17..57aebe3ca0 100644 --- a/phpBB/develop/update_email_hash.php +++ b/phpBB/develop/update_email_hash.php @@ -54,4 +54,3 @@ echo 'FINISHED'; // Done $db->sql_close(); -?>
\ No newline at end of file diff --git a/phpBB/develop/utf_normalizer_test.php b/phpBB/develop/utf_normalizer_test.php index 7705cd6851..463a274f66 100644 --- a/phpBB/develop/utf_normalizer_test.php +++ b/phpBB/develop/utf_normalizer_test.php @@ -388,4 +388,4 @@ function cp_to_utf($cp) { return chr($cp); } -}
\ No newline at end of file +} |
