From 2f4a618900e2c3b6ea14c68cbeb5897cd2ac1a04 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Thu, 29 May 2008 12:25:56 +0000 Subject: ok... i hope i haven't messed too much with the code and everything is still working. Changes: - Ascraeus now uses constants for the phpbb root path and the php extension. This ensures more security for external applications and modifications (no more overwriting of root path and extension possible through insecure mods and register globals enabled) as well as no more globalizing needed. - A second change implemented here is an additional short-hand-notation for append_sid(). It is allowed to omit the root path and extension now (for example calling append_sid('memberlist')) - in this case the root path and extension get added automatically. The hook is called after these are added. git-svn-id: file:///svn/phpbb/trunk@8572 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/develop/add_permissions.php | 33 +-- phpBB/develop/adjust_avatars.php | 10 +- phpBB/develop/adjust_bbcodes.php | 8 +- phpBB/develop/adjust_magic_urls.php | 6 +- phpBB/develop/adjust_sizes.php | 6 +- phpBB/develop/adjust_smilies.php | 6 +- phpBB/develop/adjust_uids.php | 6 +- phpBB/develop/adjust_usernames.php | 6 +- phpBB/develop/benchmark.php | 462 ----------------------------- phpBB/develop/calc_email_hash.php | 18 +- phpBB/develop/change_smiley_ref.php | 20 +- phpBB/develop/fill.php | 18 +- phpBB/develop/generate_utf_casefold.php | 14 +- phpBB/develop/generate_utf_confusables.php | 14 +- phpBB/develop/generate_utf_tables.php | 24 +- phpBB/develop/lang_duplicates.php | 10 +- phpBB/develop/merge_attachment_tables.php | 80 ----- phpBB/develop/merge_post_tables.php | 209 ------------- phpBB/develop/mysql_upgrader.php | 5 +- phpBB/develop/posting-api.php | 6 +- phpBB/develop/repair_bots.php | 8 +- phpBB/develop/search_fill.php | 10 +- phpBB/develop/unicode_testing.php | 3 +- phpBB/develop/utf_normalizer_test.php | 16 +- 24 files changed, 96 insertions(+), 902 deletions(-) delete mode 100644 phpBB/develop/benchmark.php delete mode 100644 phpBB/develop/merge_attachment_tables.php delete mode 100644 phpBB/develop/merge_post_tables.php (limited to 'phpBB/develop') diff --git a/phpBB/develop/add_permissions.php b/phpBB/develop/add_permissions.php index 956b830465..40ece4000d 100644 --- a/phpBB/develop/add_permissions.php +++ b/phpBB/develop/add_permissions.php @@ -20,34 +20,10 @@ // die("Please read the first lines of this script for instructions on how to enable it"); - -// This script adds missing permissions -$db = $dbhost = $dbuser = $dbpasswd = $dbport = $dbname = ''; - define('IN_PHPBB', 1); -define('ANONYMOUS', 1); -$phpEx = substr(strrchr(__FILE__, '.'), 1); -$phpbb_root_path='./../'; -include($phpbb_root_path . 'config.'.$phpEx); -require($phpbb_root_path . 'includes/acm/acm_' . $acm_type . '.'.$phpEx); -require($phpbb_root_path . 'includes/db/' . $dbms . '.'.$phpEx); -include($phpbb_root_path . 'includes/functions.'.$phpEx); - -define('ACL_NEVER', 0); -define('ACL_YES', 1); -define('ACL_NO', -1); - -define('ACL_GROUPS_TABLE', $table_prefix.'acl_groups'); -define('ACL_OPTIONS_TABLE', $table_prefix.'acl_options'); -define('ACL_USERS_TABLE', $table_prefix.'acl_users'); -define('GROUPS_TABLE', $table_prefix.'groups'); -define('USERS_TABLE', $table_prefix.'users'); - -$cache = new acm(); -$db = new sql_db(); - -// Connect to DB -$db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false); +define('PHPBB_ROOT_PATH', './../'); +define('PHP_EXT', substr(strrchr(__FILE__, '.'), 1)); +require(PHPBB_ROOT_PATH . 'common.' . PHP_EXT); // auth => is_local, is_global $f_permissions = array( @@ -414,4 +390,7 @@ function mass_auth($ug_type, $forum_id, $ug_id, $acl_list, $setting) } +garbage_collection(); +exit_handler(); + ?> \ No newline at end of file diff --git a/phpBB/develop/adjust_avatars.php b/phpBB/develop/adjust_avatars.php index 81599e694b..976f7dfb7e 100755 --- a/phpBB/develop/adjust_avatars.php +++ b/phpBB/develop/adjust_avatars.php @@ -9,9 +9,9 @@ die("Please read the first lines of this script for instructions on how to enabl set_time_limit(0); define('IN_PHPBB', true); -$phpbb_root_path = './../'; -$phpEx = substr(strrchr(__FILE__, '.'), 1); -include($phpbb_root_path . 'common.'.$phpEx); +define('PHPBB_ROOT_PATH', './../'); +define('PHP_EXT', substr(strrchr(__FILE__, '.'), 1)); +include(PHPBB_ROOT_PATH . 'common.' . PHP_EXT); // Start session management $user->session_begin(); @@ -130,9 +130,9 @@ $db->sql_close(); function adjust_avatar($old_name, $midfix) { - global $config, $phpbb_root_path; + global $config; - $avatar_path = $phpbb_root_path . $config['avatar_path']; + $avatar_path = PHPBB_ROOT_PATH . $config['avatar_path']; $extension = strtolower(substr(strrchr($old_name, '.'), 1)); $new_name = $config['avatar_salt'] . '_' . $midfix . '.' . $extension; diff --git a/phpBB/develop/adjust_bbcodes.php b/phpBB/develop/adjust_bbcodes.php index f06f0112ab..27af105f28 100644 --- a/phpBB/develop/adjust_bbcodes.php +++ b/phpBB/develop/adjust_bbcodes.php @@ -11,10 +11,10 @@ die("Please read the first lines of this script for instructions on how to enabl set_time_limit(0); define('IN_PHPBB', true); -$phpbb_root_path = './../'; -$phpEx = substr(strrchr(__FILE__, '.'), 1); -include($phpbb_root_path . 'common.'.$phpEx); -include($phpbb_root_path . 'includes/message_parser.' . $phpEx); +define('PHPBB_ROOT_PATH', './../'); +define('PHP_EXT', substr(strrchr(__FILE__, '.'), 1)); +include(PHPBB_ROOT_PATH . 'common.' . PHP_EXT); +include(PHPBB_ROOT_PATH . 'includes/message_parser.' . PHP_EXT); // Start session management $user->session_begin(); diff --git a/phpBB/develop/adjust_magic_urls.php b/phpBB/develop/adjust_magic_urls.php index 1430a47a12..94a32283e0 100644 --- a/phpBB/develop/adjust_magic_urls.php +++ b/phpBB/develop/adjust_magic_urls.php @@ -10,9 +10,9 @@ die("Please read the first lines of this script for instructions on how to enabl set_time_limit(0); define('IN_PHPBB', true); -$phpbb_root_path = './../'; -$phpEx = substr(strrchr(__FILE__, '.'), 1); -include($phpbb_root_path . 'common.'.$phpEx); +define('PHPBB_ROOT_PATH', './../'); +define('PHP_EXT', substr(strrchr(__FILE__, '.'), 1)); +include(PHPBB_ROOT_PATH . 'common.' . PHP_EXT); // Start session management $user->session_begin(); diff --git a/phpBB/develop/adjust_sizes.php b/phpBB/develop/adjust_sizes.php index 7d72813056..5b4678c621 100644 --- a/phpBB/develop/adjust_sizes.php +++ b/phpBB/develop/adjust_sizes.php @@ -13,9 +13,9 @@ set_time_limit(0); @ini_set('memory_limit', '128M'); define('IN_PHPBB', true); -$phpbb_root_path = './../'; -$phpEx = substr(strrchr(__FILE__, '.'), 1); -include($phpbb_root_path . 'common.'.$phpEx); +define('PHPBB_ROOT_PATH', './../'); +define('PHP_EXT', substr(strrchr(__FILE__, '.'), 1)); +include(PHPBB_ROOT_PATH . 'common.' . PHP_EXT); // Start session management $user->session_begin(); diff --git a/phpBB/develop/adjust_smilies.php b/phpBB/develop/adjust_smilies.php index 774c8834f6..bc8ac7be95 100644 --- a/phpBB/develop/adjust_smilies.php +++ b/phpBB/develop/adjust_smilies.php @@ -7,9 +7,9 @@ die("Please read the first lines of this script for instructions on how to enabl set_time_limit(0); define('IN_PHPBB', true); -$phpbb_root_path = './../'; -$phpEx = substr(strrchr(__FILE__, '.'), 1); -include($phpbb_root_path . 'common.'.$phpEx); +define('PHPBB_ROOT_PATH', './../'); +define('PHP_EXT', substr(strrchr(__FILE__, '.'), 1)); +include(PHPBB_ROOT_PATH . 'common.' . PHP_EXT); // Start session management $user->session_begin(); diff --git a/phpBB/develop/adjust_uids.php b/phpBB/develop/adjust_uids.php index d301f3cadb..999d9a076a 100755 --- a/phpBB/develop/adjust_uids.php +++ b/phpBB/develop/adjust_uids.php @@ -12,9 +12,9 @@ set_time_limit(0); @ini_set('memory_limit', '512M'); define('IN_PHPBB', true); -$phpbb_root_path = './../'; -$phpEx = substr(strrchr(__FILE__, '.'), 1); -include($phpbb_root_path . 'common.'.$phpEx); +define('PHPBB_ROOT_PATH', './../'); +define('PHP_EXT', substr(strrchr(__FILE__, '.'), 1)); +include(PHPBB_ROOT_PATH . 'common.' . PHP_EXT); // Start session management $user->session_begin(); diff --git a/phpBB/develop/adjust_usernames.php b/phpBB/develop/adjust_usernames.php index 1afa77af16..4bae774634 100644 --- a/phpBB/develop/adjust_usernames.php +++ b/phpBB/develop/adjust_usernames.php @@ -9,9 +9,9 @@ die("Please read the first lines of this script for instructions on how to enabl set_time_limit(0); define('IN_PHPBB', true); -$phpbb_root_path = './../'; -$phpEx = substr(strrchr(__FILE__, '.'), 1); -include($phpbb_root_path . 'common.'.$phpEx); +define('PHPBB_ROOT_PATH', './../'); +define('PHP_EXT', substr(strrchr(__FILE__, '.'), 1)); +include(PHPBB_ROOT_PATH . 'common.' . PHP_EXT); // Start session management $user->session_begin(); diff --git a/phpBB/develop/benchmark.php b/phpBB/develop/benchmark.php deleted file mode 100644 index 5bbe6f53be..0000000000 --- a/phpBB/develop/benchmark.php +++ /dev/null @@ -1,462 +0,0 @@ - . -[/code] -[b]bolded[/b], [i]italic[/i] -[email]james@totalgeek.org[/email] -[url=http://www.totalgeek.org]totalgeek.org[/url] -[url]www.totalgeek.org[/url] -[list] -[*] This is the first bulleted item. -[*] This is the second bulleted item. -[/list] -[list=A] -[*] This is the first bulleted item. -[*] This is the second bulleted item. -[/list] -[quote] -And a quote! -[/quote] -'; - - -// The script expects the ID's in the tables to sequential (1,2,3,4,5), -// so no holes please (1,4,5,8)... -$nr_of_users = nrof(USERS_TABLE); -$nr_of_cats = nrof(CATEGORIES_TABLE); -$nr_of_forums = nrof(FORUMS_TABLE); -$nr_of_posts = nrof(POSTS_TABLE); - -$u = $users; - -$starttime = microtime(); - -$usercreationcount = 0; -while($users > 0) -{ - - $name = "testuser_" . substr(md5(uniqid(rand())), 0, 10); - if (make_user($name)) - { - $usercreationcount++; - $users--; - } - if (($usercreationcount % 500) == 0) - { - echo "status: $usercreationcount
\n"; - flush(); - } - -} - -if ($posts > 0) -{ - filldb($posts); -} - -$endtime = microtime(); - -if ($submit="" || !isset($submit)) -{ - ?> -Hello, welcome to this little phpBB Benchmarking script :)

- -At the moment there are:
- - - - - -
Users
Forums
Posts
-

-What do you want to create?

- -

- Users
- Posts/topics (optional: post size in bytes)
- -
- - TIME TAKEN : ".$timetaken_sec."s
\n"; - - print "

\nBack to the overview page\n"; -} - - -function filldb($newposts) -{ - global $nr_of_forums; - global $nr_of_users; - - $forum_topic_counts = array(); - - for ($i = 1; $i <= $nr_of_forums; $i++) - { - $forum_topic_counts[$i] = get_topic_count($i); - } - - for($i = 0; $i < $newposts; $i++) - { - $userid = rand(2, $nr_of_users - 1); - $forum = rand(1,$nr_of_forums); - - if ((rand(0,30) < 1) || ($forum_topic_count[$forum] == 0)) - { - // create a new topic 1 in 30 times (or when there are none); - $topic = make_topic($userid, "Testing topic $i", $forum); - $forum_topic_count[$forum]++; - } - else - { - // Otherwise create a reply(posting) somewhere. - $topic = get_smallest_topic($forum); - create_posting($userid, $topic, $forum, "reply"); - } - - if (($i % 1000) == 0) - { - echo "status: $i
"; - flush(); - } - - } -} - - -function get_smallest_topic($forum_id) -{ - global $db; - - $sql = "SELECT topic_id - FROM " . TOPICS_TABLE . " - WHERE (forum_id = $forum_id) - ORDER BY topic_replies ASC LIMIT 1"; - if($result = $db->sql_query($sql)) - { - $row = $db->sql_fetchrow($result); - $topic_id = $row['topic_id']; - - unset($result); - unset($row); - return $topic_id; - } - else - { - message_die(GENERAL_ERROR, "Couldn't get smallest topic.", "", __LINE__, __FILE__, $sql); - } - -} - - -function get_topic_count($forum_id) -{ - global $db; - - $sql = "SELECT forum_topics - FROM " . FORUMS_TABLE . " - WHERE (forum_id = $forum_id)"; - if($result = $db->sql_query($sql)) - { - $row = $db->sql_fetchrow($result); - $topic_count = $row['forum_topics']; - - unset($result); - unset($row); - return $topic_count; - } - else - { - message_die(GENERAL_ERROR, "Couldn't get topic count.", "", __LINE__, __FILE__, $sql); - } - -} - - -function make_topic($user_id, $subject, $forum_id) -{ - global $db; - $topic_type = POST_NORMAL; - $topic_vote = 0; - $current_time = time(); - - $sql = "INSERT INTO " . TOPICS_TABLE . " (topic_title, topic_poster, topic_time, forum_id, topic_status, topic_type, topic_vote) - VALUES ('$subject', $user_id, $current_time, $forum_id, " . TOPIC_UNLOCKED . ", $topic_type, $topic_vote)"; - - if( $result = $db->sql_query($sql, BEGIN_TRANSACTION) ) - { - $new_topic_id = $db->sql_nextid(); - } - else - { - message_die(GENERAL_ERROR, "Error inserting data into topics table", "", __LINE__, __FILE__, $sql); - } - - create_posting($user_id, $new_topic_id, $forum_id); - - return $new_topic_id; -} - - - -function create_posting($userid, $topic_id, $forum, $mode='newtopic') -{ - $message = generatepost(); - - return make_post($topic_id, $forum, $userid, "", $message, $mode); - -} - - - -function make_post($new_topic_id, $forum_id, $user_id, $post_username, $text, $mode='newtopic') -{ - global $db; - $current_time = time(); - $user_ip = "ac100202"; - $bbcode_on = 1; - $html_on = 1; - $smilies_on = 1; - $attach_sig = 1; - $bbcode_uid = make_bbcode_uid(); - - $post_subject = 'random subject'; - - $post_message = prepare_message($text, $html_on, $bbcode_on, $smilies_on, $bbcode_uid); - - $sql = "INSERT INTO " . POSTS_TABLE . " (topic_id, forum_id, poster_id, attach_id, icon_id, post_username, post_time, poster_ip, post_approved, bbcode_uid, enable_bbcode, enable_html, enable_smilies, enable_sig, post_subject, post_text) - VALUES ($new_topic_id, $forum_id, $user_id, 0, 0, '$post_username', $current_time, '$user_ip', 1, '$bbcode_uid', $bbcode_on, $html_on, $smilies_on, $attach_sig, '$post_subject', '$post_message')"; - $result = $db->sql_query($sql); - - if ($result) - { - $new_post_id = $db->sql_nextid(); - - $sql = "UPDATE " . TOPICS_TABLE . " - SET topic_last_post_id = $new_post_id"; - if($mode == "reply") - { - $sql .= ", topic_replies = topic_replies + 1 "; - } - $sql .= " WHERE topic_id = $new_topic_id"; - - if($db->sql_query($sql)) - { - $sql = "UPDATE " . FORUMS_TABLE . " - SET forum_last_post_id = $new_post_id, forum_posts = forum_posts + 1"; - if($mode == "newtopic") - { - $sql .= ", forum_topics = forum_topics + 1"; - } - $sql .= " WHERE forum_id = $forum_id"; - - if($db->sql_query($sql)) - { - $sql = "UPDATE " . USERS_TABLE . " - SET user_posts = user_posts + 1 - WHERE user_id = " . $user_id; - - if($db->sql_query($sql, END_TRANSACTION)) - { - // SUCCESS. - return true; - } - else - { - message_die(GENERAL_ERROR, "Error updating users table", "", __LINE__, __FILE__, $sql); - } - } - else - { - message_die(GENERAL_ERROR, "Error updating forums table", "", __LINE__, __FILE__, $sql); - } - } - else - { - // Rollback - if($db->sql_layer == "mysql") - { - $sql = "DELETE FROM " . POSTS_TABLE . " - WHERE post_id = $new_post_id"; - $db->sql_query($sql); - } - message_die(GENERAL_ERROR, "Error updating topics table", "", __LINE__, __FILE__, $sql); - } - } - else - { - message_die(GENERAL_ERROR, "Error inserting data into posts table", "", __LINE__, __FILE__, $sql); - } -} - - -function generatepost($size=850) -{ - global $bigass_text; - // Returns a string with a length between $size and $size*0.2 - $size = rand(0.2*$size, $size); - - $textsize = strlen($bigass_text); - $currentsize = 0; - // Add whole $text multiple times - while($currentsize < $size && $size-$currentsize <= $textsize) - { - $message .= $bigass_text; - $currentsize += $textsize; - } - // Add the remainder number of chars and return it. - $message .= substr($bigass_text, 0, $size-$currentsize); - - return (addslashes($message)); -} - - -function nrof($table) -{ - global $db; - $sql = "SELECT count(*) AS counted FROM $table"; - $result = $db->sql_query($sql); - $topics = $db->sql_fetchrow($result); - return $topics[counted]; -} - - -function make_user($username) -{ - global $db, $board_config; - - $password = md5("benchpass"); - $email = "nobody@localhost"; - $icq = "12345678"; - $website = "http://www.phpbb.com"; - $occupation = "phpBB tester"; - $location = "phpBB world hq"; - $interests = "Eating, sleeping, living, and breathing phpBB"; - $signature = "$username: phpBB tester."; - $signature_bbcode_uid = ""; - $avatar_filename = ""; - $viewemail = 0; - $aim = 0; - $yim = 0; - $msn = 0; - $attachsig = 1; - $allowsmilies = 1; - $allowhtml = 1; - $allowbbcode = 1; - $allowviewonline = 1; - $notifyreply = 0; - $notifypm = 0; - $user_timezone = $board_config['board_timezone']; - $user_dateformat = $board_config['default_dateformat']; - $user_lang = $board_config['default_lang']; - $user_style = $board_config['default_style']; - - - $sql = "SELECT MAX(user_id) AS total - FROM " . USERS_TABLE; - if($result = $db->sql_query($sql)) - { - $row = $db->sql_fetchrow($result); - $new_user_id = $row['total'] + 1; - - unset($result); - unset($row); - } - else - { - message_die(GENERAL_ERROR, "Couldn't obtained next user_id information.", "", __LINE__, __FILE__, $sql); - } - - $sql = "SELECT MAX(group_id) AS total - FROM " . GROUPS_TABLE; - if($result = $db->sql_query($sql)) - { - $row = $db->sql_fetchrow($result); - $new_group_id = $row['total'] + 1; - - unset($result); - unset($row); - } - else - { - message_die(GENERAL_ERROR, "Couldn't obtained next user_id information.", "", __LINE__, __FILE__, $sql); - } - - - $sql = "INSERT INTO " . USERS_TABLE . " (user_id, username, user_regdate, user_password, user_email, user_icq, user_website, user_occ, user_from, user_interests, user_sig, user_sig_bbcode_uid, user_avatar, user_viewemail, user_aim, user_yim, user_msnm, user_attachsig, user_allowsmilies, user_allowhtml, user_allowbbcode, user_allow_viewonline, user_notify, user_notify_pm, user_timezone, user_dateformat, user_lang, user_style, user_level, user_allow_pm, user_active, user_actkey) - VALUES ($new_user_id, '$username', " . time() . ", '$password', '$email', '$icq', '$website', '$occupation', '$location', '$interests', '$signature', '$signature_bbcode_uid', '$avatar_filename', $viewemail, '$aim', '$yim', '$msn', $attachsig, $allowsmilies, $allowhtml, $allowbbcode, $allowviewonline, $notifyreply, $notifypm, $user_timezone, '$user_dateformat', '$user_lang', $user_style, 0, 1, "; - - - $sql .= "1, '')"; - - if($result = $db->sql_query($sql, BEGIN_TRANSACTION)) - { - $sql = "INSERT INTO " . GROUPS_TABLE . " (group_id, group_name, group_description, group_single_user, group_moderator) - VALUES ($new_group_id, '', 'Personal User', 1, 0)"; - if($result = $db->sql_query($sql)) - { - $sql = "INSERT INTO " . USER_GROUP_TABLE . " (user_id, group_id, user_pending) - VALUES ($new_user_id, $new_group_id, 0)"; - if($result = $db->sql_query($sql, END_TRANSACTION)) - { - - // SUCCESS. - return true; - } - else - { - message_die(GENERAL_ERROR, "Couldn't insert data into user_group table", "", __LINE__, __FILE__, $sql); - } - } - else - { - message_die(GENERAL_ERROR, "Couldn't insert data into groups table", "", __LINE__, __FILE__, $sql); - } - } - else - { - message_die(GENERAL_ERROR, "Couldn't insert data into users table", "", __LINE__, __FILE__, $sql); - } - -} - -?> \ No newline at end of file diff --git a/phpBB/develop/calc_email_hash.php b/phpBB/develop/calc_email_hash.php index a67b0f52a3..cf2bb5c418 100644 --- a/phpBB/develop/calc_email_hash.php +++ b/phpBB/develop/calc_email_hash.php @@ -21,22 +21,10 @@ die("Please read the first lines of this script for instructions on how to enable it"); @set_time_limit(300); -$db = $dbhost = $dbuser = $dbpasswd = $dbport = $dbname = ''; - define('IN_PHPBB', 1); -define('ANONYMOUS', 1); -$phpEx = substr(strrchr(__FILE__, '.'), 1); -$phpbb_root_path='./../'; -include($phpbb_root_path . 'config.'.$phpEx); -require($phpbb_root_path . 'includes/acm/acm_' . $acm_type . '.'.$phpEx); -require($phpbb_root_path . 'includes/db/' . $dbms . '.'.$phpEx); -include($phpbb_root_path . 'includes/functions.'.$phpEx); - -$cache = new acm(); -$db = new sql_db(); - -// Connect to DB -$db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false); +define('PHPBB_ROOT_PATH', './../'); +define('PHP_EXT', substr(strrchr(__FILE__, '.'), 1)); +include(PHPBB_ROOT_PATH . 'common.' . PHP_EXT); $start = 0; do diff --git a/phpBB/develop/change_smiley_ref.php b/phpBB/develop/change_smiley_ref.php index db65dd52d4..4620b9c2c4 100644 --- a/phpBB/develop/change_smiley_ref.php +++ b/phpBB/develop/change_smiley_ref.php @@ -30,23 +30,9 @@ die("Please read the first lines of this script for instructions on how to enabl @set_time_limit(2400); -// This script adds missing permissions -$db = $dbhost = $dbuser = $dbpasswd = $dbport = $dbname = ''; - -define('IN_PHPBB', 1); -define('ANONYMOUS', 1); -$phpEx = substr(strrchr(__FILE__, '.'), 1); -$phpbb_root_path='./../'; -include($phpbb_root_path . 'config.'.$phpEx); -require($phpbb_root_path . 'includes/acm/acm_' . $acm_type . '.'.$phpEx); -require($phpbb_root_path . 'includes/db/' . $dbms . '.'.$phpEx); -include($phpbb_root_path . 'includes/functions.'.$phpEx); - -$cache = new acm(); -$db = new $sql_db(); - -// Connect to DB -$db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false); +define('PHPBB_ROOT_PATH', './../'); +define('PHP_EXT', substr(strrchr(__FILE__, '.'), 1)); +include(PHPBB_ROOT_PATH . 'common.' . PHP_EXT); $sql = "SELECT post_id, post_text FROM {$table_prefix}posts WHERE post_text LIKE '%{SMILE_PATH}%'"; $result = $db->sql_query($sql); diff --git a/phpBB/develop/fill.php b/phpBB/develop/fill.php index 336e510d06..39a9b128f5 100644 --- a/phpBB/develop/fill.php +++ b/phpBB/develop/fill.php @@ -21,10 +21,10 @@ die("Please read the first lines of this script for instructions on how to enabl define('IN_PHPBB', true); -$phpbb_root_path = './../'; -$phpEx = substr(strrchr(__FILE__, '.'), 1); -include($phpbb_root_path . 'common.'.$phpEx); -include($phpbb_root_path . 'includes/functions_admin.'.$phpEx); +define('PHPBB_ROOT_PATH', './../'); +define('PHP_EXT', substr(strrchr(__FILE__, '.'), 1)); +include(PHPBB_ROOT_PATH . 'common.' . PHP_EXT); +include(PHPBB_ROOT_PATH . 'includes/functions_admin.' . PHP_EXT); set_time_limit(0); header('Expires: 0'); @@ -117,14 +117,14 @@ switch ($mode) if ($topic_id >= $num_topics) { - echo 'And now for something completely different...'; + echo 'And now for something completely different...'; $db->sql_query('ANALYZE TABLES ' . TOPICS_TABLE . ', ' . POSTS_TABLE); flush(); } else { - echo 'To the next page... (' . $topic_id . '/' . $num_topics . ')'; + echo 'To the next page... (' . $topic_id . '/' . $num_topics . ')'; flush(); } break; @@ -141,7 +141,7 @@ switch ($mode) $e = explode(' ', microtime()); echo '

' . ($e[0] + $e[1] - $s[0] - $s[1]) . '
'; - echo 'Here we go again'; + echo 'Here we go again'; } else { @@ -157,11 +157,11 @@ switch ($mode) if ($end < $num_topics) { $start += $batch_size; - echo 'And now for something completely different... ($start/$num_topics)"; + echo 'And now for something completely different... ($start/$num_topics)"; } else { - echo 'Here we go again'; + echo 'Here we go again'; } } diff --git a/phpBB/develop/generate_utf_casefold.php b/phpBB/develop/generate_utf_casefold.php index 89c4aec01a..bbf0a0a75d 100644 --- a/phpBB/develop/generate_utf_casefold.php +++ b/phpBB/develop/generate_utf_casefold.php @@ -25,8 +25,8 @@ die("Please read the first lines of this script for instructions on how to enabl set_time_limit(0); define('IN_PHPBB', true); -$phpbb_root_path = '../'; -$phpEx = substr(strrchr(__FILE__, '.'), 1); +define('PHPBB_ROOT_PATH', './../'); +define('PHP_EXT', substr(strrchr(__FILE__, '.'), 1)); echo "Checking for required files\n"; download('http://unicode.org/Public/UNIDATA/CaseFolding.txt'); @@ -71,8 +71,8 @@ foreach ($array as $value) foreach ($uniarray as $idx => $contents) { - echo "Writing to case_fold_$idx.$phpEx\n"; - $fp = fopen($phpbb_root_path . 'includes/utf/data/case_fold_' . strtolower($idx) . '.' . $phpEx, 'wb'); + echo "Writing to case_fold_$idx." . PHP_EXT . "\n"; + $fp = fopen(PHPBB_ROOT_PATH . 'includes/utf/data/case_fold_' . strtolower($idx) . '.' . PHP_EXT, 'wb'); fwrite($fp, ' $contents) /** * Generate a new file */ - echo "Writing to $file.$phpEx\n"; + echo "Writing to $file." . PHP_EXT . "\n"; - if (!$fp = fopen($phpbb_root_path . 'includes/utf/data/' . $file . '.' . $phpEx, 'wb')) + if (!$fp = fopen(PHPBB_ROOT_PATH . 'includes/utf/data/' . $file . '.' . PHP_EXT, 'wb')) { trigger_error('Cannot open ' . $file . ' for write'); } @@ -288,7 +288,7 @@ echo "\n*** UTF-8 normalization tables done\n\n"; */ echo "Generating search indexer tables\n"; -$fp = fopen($phpbb_root_path . 'develop/UnicodeData.txt', 'rt'); +$fp = fopen(PHPBB_ROOT_PATH . 'develop/UnicodeData.txt', 'rt'); $map = array(); while ($line = fgets($fp, 1024)) @@ -406,8 +406,8 @@ unset($map); foreach ($file_contents as $idx => $contents) { - echo "Writing to search_indexer_$idx.$phpEx\n"; - $fp = fopen($phpbb_root_path . 'includes/utf/data/search_indexer_' . $idx . '.' . $phpEx, 'wb'); + echo "Writing to search_indexer_$idx." . PHP_EXT . "\n"; + $fp = fopen(PHPBB_ROOT_PATH . 'includes/utf/data/search_indexer_' . $idx . '.' . PHP_EXT, 'wb'); fwrite($fp, 'sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false); - -// Rename the attachments table... -$sql = "RENAME TABLE {$table_prefix}attachments TO {$table_prefix}attach_temp"; -$db->sql_query($sql); - -$sql = "CREATE TABLE {$table_prefix}attachments - SELECT d.*, a.post_id, a.user_id_from as poster_id, p.topic_id - FROM {$table_prefix}attach_desc d, {$table_prefix}attach_temp a, {$table_prefix}posts p - WHERE a.attach_id = d.attach_id - AND a.post_id = p.post_id"; -$db->sql_query($sql); - -switch ($db->sql_layer) -{ - case 'mysql': - case 'mysql4': - $sql = 'ALTER TABLE ' . $table_prefix . 'attachments - ADD PRIMARY KEY (attach_id), - ADD INDEX filetime (filetime), - ADD INDEX post_id (post_id), - ADD INDEX poster_id (poster_id), - ADD INDEX physical_filename (physical_filename(10)), - ADD INDEX filesize (filesize), - ADD INDEX topic_id (topic_id), - MODIFY COLUMN attach_id mediumint(8) UNSIGNED NOT NULL auto_increment'; - break; - - case 'mssql': - case 'mssql-odbc': - case 'msaccess': - break; - - case 'postgresql': - break; -} -$db->sql_query($sql); - -//$db->sql_query("DROP TABLE {$table_prefix}attach_temp"); - -echo "

Done

\n"; - -?> \ No newline at end of file diff --git a/phpBB/develop/merge_post_tables.php b/phpBB/develop/merge_post_tables.php deleted file mode 100644 index 3567a569c6..0000000000 --- a/phpBB/develop/merge_post_tables.php +++ /dev/null @@ -1,209 +0,0 @@ -sql_query($sql); - -$sql = "CREATE TABLE {$table_prefix}posts - SELECT p.*, pt.post_subject, pt.post_text, pt.post_checksum, pt.bbcode_bitfield, pt.bbcode_uid - FROM {$table_prefix}posts_temp p, {$table_prefix}posts_text pt - WHERE pt.post_id = p.post_id"; -$db->sql_query($sql); - -switch ($db->sql_layer) -{ - case 'mysql': - case 'mysql4': - $sql = 'ALTER TABLE ' . $table_prefix . 'posts - ADD PRIMARY KEY (post_id), - ADD INDEX topic_id (topic_id), - ADD INDEX poster_ip (poster_ip), - ADD INDEX post_approved (post_approved), - MODIFY COLUMN post_id mediumint(8) UNSIGNED NOT NULL auto_increment, - ADD COLUMN post_encoding varchar(11) DEFAULT \'iso-8859-15\' NOT NULL'; - break; - - case 'mssql': - case 'mssql-odbc': - case 'msaccess': - break; - - case 'postgresql': - break; -} -$db->sql_query($sql); - -$sql = "UPDATE {$table_prefix}topics SET topic_poster = 1 WHERE topic_poster = 0 OR topic_poster IS NULL"; -$db->sql_query($sql); -$sql = "UPDATE {$table_prefix}topics SET topic_last_poster_id = 1 WHERE topic_last_poster_id = 0 OR topic_last_poster_id IS NULL"; -$db->sql_query($sql); -$sql = "UPDATE {$table_prefix}posts SET poster_id = 1 WHERE poster_id = 0 OR poster_id IS NULL"; -$db->sql_query($sql); -$sql = "UPDATE {$table_prefix}users SET user_id = 1 WHERE user_id = 0"; -$db->sql_query($sql); - -$sql = "SELECT t.topic_id - FROM {$table_prefix}topics t - LEFT JOIN {$table_prefix}posts p ON p.topic_id = t.topic_id - WHERE p.topic_id IS NULL"; -$result = $db->sql_query($sql); - -if ($row = $db->sql_fetchrow($result)) -{ - $del_sql = ''; - do - { - $del_sql .= (($del_sql != '') ? ', ' : '') . $row['topic_id']; - } - while ($row = $db->sql_fetchrow($result)); - - $sql = "DELETE FROM {$table_prefix}topics - WHERE topic_id IN ($del_sql)"; - $db->sql_query($sql); -} -$db->sql_freeresult($result); - -$del_sql = ''; -$sql = "SELECT topic_id, MIN(post_id) AS first_post_id, MAX(post_id) AS last_post_id, COUNT(post_id) AS total_posts - FROM {$table_prefix}posts - GROUP BY topic_id"; -$result = $db->sql_query($sql); - -while ($row = $db->sql_fetchrow($result)) -{ - $del_sql .= (($del_sql != '') ? ', ' : '') . $row['topic_id']; - - $sql = "UPDATE {$table_prefix}topics - SET topic_first_post_id = " . $row['first_post_id'] . ", topic_last_post_id = " . $row['last_post_id'] . ", topic_replies = " . ($row['total_posts'] - 1) . " - WHERE topic_id = " . $row['topic_id']; - $db->sql_query($sql); -} -$db->sql_freeresult($result); - -$sql = "DELETE FROM {$table_prefix}topics WHERE topic_id NOT IN ($del_sql)"; -$db->sql_query($sql); - -$topic_count = $post_count = array(); -$sql = "SELECT forum_id, COUNT(topic_id) AS topics - FROM {$table_prefix}topics - GROUP BY forum_id"; -$result = $db->sql_query($sql); - -while ($row = $db->sql_fetchrow($result)) -{ - $topic_count[$row['forum_id']] = $row['topics']; -} -$db->sql_freeresult($result); - -$sql = "SELECT forum_id, COUNT(post_id) AS posts - FROM {$table_prefix}posts - GROUP BY forum_id"; -$result = $db->sql_query($sql); - -while ($row = $db->sql_fetchrow($result)) -{ - $post_count[$row['forum_id']] = $row['posts']; -} -$db->sql_freeresult($result); - -switch ($db->sql_layer) -{ - case 'oracle': - $sql = "SELECT f.*, p.post_time, p.post_username, u.username, u.user_id - FROM " . $table_prefix . "forums f, " . $table_prefix . "posts p, " . $table_prefix . "users u - WHERE p.post_id = f.forum_last_post_id(+) - AND u.user_id = p.poster_id(+)"; - break; - - default: - $sql = "SELECT f.forum_id, p.post_time, p.post_username, u.username, u.user_id - FROM ((" . $table_prefix . "forums f - LEFT JOIN " . $table_prefix . "posts p ON p.post_id = f.forum_last_post_id) - LEFT JOIN " . $table_prefix . "users u ON u.user_id = p.poster_id)"; - break; -} -$result = $db->sql_query($sql); - -$sql_ary = array(); -while ($row = $db->sql_fetchrow($result)) -{ - $forum_id = $row['forum_id']; - - $sql_ary[] = "UPDATE " . $table_prefix . "forums - SET forum_last_poster_id = " . ((!empty($row['user_id']) && $row['user_id'] != ANONYMOUS) ? $row['user_id'] : ANONYMOUS) . ", forum_last_poster_name = '" . ((!empty($row['user_id']) && $row['user_id'] != ANONYMOUS) ? addslashes($row['username']) : addslashes($row['post_username'])) . "', forum_last_post_time = " . $row['post_time'] . ", forum_posts = " . (($post_count[$forum_id]) ? $post_count[$forum_id] : 0) . ", forum_topics = " . (($topic_count[$forum_id]) ? $topic_count[$forum_id] : 0) . " - WHERE forum_id = $forum_id"; - - $sql = "SELECT t.topic_id, u.username, u.user_id, u2.username as user2, u2.user_id as id2, p.post_username, p2.post_username AS post_username2, p2.post_time - FROM " . $table_prefix . "topics t, " . $table_prefix . "users u, " . $table_prefix . "posts p, " . $table_prefix . "posts p2, " . $table_prefix . "users u2 - WHERE t.forum_id = $forum_id - AND u.user_id = t.topic_poster - AND p.post_id = t.topic_first_post_id - AND p2.post_id = t.topic_last_post_id - AND u2.user_id = p2.poster_id"; - $result2 = $db->sql_query($sql); - - while ($row2 = $db->sql_fetchrow($result2)) - { - $sql_ary[] = "UPDATE " . $table_prefix . "topics - SET topic_poster = " . $row2['user_id'] . ", topic_first_poster_name = '" . ((!empty($row2['user_id']) && $row2['user_id'] != ANONYMOUS) ? addslashes($row2['username']) : addslashes($row2['post_username'])) . "', topic_last_poster_id = " . ((!empty($row2['id2']) && $row2['id2'] != ANONYMOUS) ? $row2['id2'] : ANONYMOUS) . ", topic_last_post_time = " . $row2['post_time'] . ", topic_last_poster_name = '" . ((!empty($row2['id2']) && $row2['id2'] != ANONYMOUS) ? addslashes($row2['user2']) : addslashes($row2['post_username2'])) . "' - WHERE topic_id = " . $row2['topic_id']; - } - $db->sql_freeresult($result2); - - unset($row2); -} -$db->sql_freeresult($result); - -foreach ($sql_ary as $sql) -{ - $sql . "
"; - $db->sql_query($sql); -} - -echo "

Done

\n"; - -?> \ No newline at end of file diff --git a/phpBB/develop/mysql_upgrader.php b/phpBB/develop/mysql_upgrader.php index ea64a1a94f..7762858b58 100644 --- a/phpBB/develop/mysql_upgrader.php +++ b/phpBB/develop/mysql_upgrader.php @@ -21,8 +21,9 @@ die("Please read the first lines of this script for instructions on how to enable it"); define('IN_PHPBB', true); -$phpEx = substr(strrchr(__FILE__, '.'), 1); -include($phpbb_root_path . 'common.' . $phpEx); +define('PHPBB_ROOT_PATH', './../'); +define('PHP_EXT', substr(strrchr(__FILE__, '.'), 1)); +include(PHPBB_ROOT_PATH . 'common.' . PHP_EXT); $prefix = $table_prefix; diff --git a/phpBB/develop/posting-api.php b/phpBB/develop/posting-api.php index a966383df9..494cb9773d 100644 --- a/phpBB/develop/posting-api.php +++ b/phpBB/develop/posting-api.php @@ -1,8 +1,8 @@ session_begin(); @@ -34,12 +34,12 @@ $user->setup(); $search_type = $config['search_type']; -if (!file_exists($phpbb_root_path . 'includes/search/' . $search_type . '.' . $phpEx)) +if (!file_exists(PHPBB_ROOT_PATH . 'includes/search/' . $search_type . '.' . PHP_EXT)) { trigger_error('NO_SUCH_SEARCH_MODULE'); } -require($phpbb_root_path . 'includes/search/' . $search_type . '.' . $phpEx); +require(PHPBB_ROOT_PATH . 'includes/search/' . $search_type . '.' . PHP_EXT); $error = false; $search = new $search_type($error); diff --git a/phpBB/develop/unicode_testing.php b/phpBB/develop/unicode_testing.php index 25a13d1325..c8712ba53f 100644 --- a/phpBB/develop/unicode_testing.php +++ b/phpBB/develop/unicode_testing.php @@ -98,8 +98,7 @@ function utf8_normalize_nfkc($strings) if (!class_exists('utf_normalizer')) { - global $phpbb_root_path, $phpEx; - include($phpbb_root_path . 'includes/utf/utf_normalizer.' . $phpEx); + include(PHPBB_ROOT_PATH . 'includes/utf/utf_normalizer.' . PHP_EXT); } if (!is_array($strings)) diff --git a/phpBB/develop/utf_normalizer_test.php b/phpBB/develop/utf_normalizer_test.php index cf381e58fa..8a7c31a1b0 100644 --- a/phpBB/develop/utf_normalizer_test.php +++ b/phpBB/develop/utf_normalizer_test.php @@ -26,8 +26,8 @@ set_time_limit(0); error_reporting(E_ALL); define('IN_PHPBB', true); -$phpbb_root_path = '../'; -$phpEx = substr(strrchr(__FILE__, '.'), 1); +define('PHPBB_ROOT_PATH', './../'); +define('PHP_EXT', substr(strrchr(__FILE__, '.'), 1)); /** @@ -77,13 +77,13 @@ $test_suite = array( ) ); -require_once($phpbb_root_path . 'includes/utf/utf_normalizer.' . $phpEx); +require_once(PHPBB_ROOT_PATH . 'includes/utf/utf_normalizer.' . PHP_EXT); $i = $n = 0; $failed = false; $tested_chars = array(); -$fp = fopen($phpbb_root_path . 'develop/NormalizationTest.txt', 'rb'); +$fp = fopen(PHPBB_ROOT_PATH . 'develop/NormalizationTest.txt', 'rb'); while (!feof($fp)) { $line = fgets($fp); @@ -158,7 +158,7 @@ fclose($fp); */ echo "\n\nTesting for invariants...\n\n"; -$fp = fopen($phpbb_root_path . 'develop/UnicodeData.txt', 'rt'); +$fp = fopen(PHPBB_ROOT_PATH . 'develop/UnicodeData.txt', 'rt'); $n = 0; while (!feof($fp)) @@ -227,9 +227,7 @@ die("\n\nALL TESTS PASSED SUCCESSFULLY\n"); */ function download($url) { - global $phpbb_root_path; - - if (file_exists($phpbb_root_path . 'develop/' . basename($url))) + if (file_exists(PHPBB_ROOT_PATH . 'develop/' . basename($url))) { return; } @@ -241,7 +239,7 @@ function download($url) die("Can't download from $url\nPlease download it yourself and put it in the develop/ dir, kthxbai"); } - if (!$fpw = fopen($phpbb_root_path . 'develop/' . basename($url), 'wb')) + if (!$fpw = fopen(PHPBB_ROOT_PATH . 'develop/' . basename($url), 'wb')) { die("Can't open develop/" . basename($url) . " for output... please check your permissions or something"); } -- cgit v1.2.1