diff --git a/phpBB/develop/create_schema_files.php b/phpBB/develop/create_schema_files.php index 7f6ee07d44..06c8ca24a6 100644 --- a/phpBB/develop/create_schema_files.php +++ b/phpBB/develop/create_schema_files.php @@ -1044,9 +1044,9 @@ function get_schema_struct() 'enable_icons' => array('BOOL', 1), 'enable_prune' => array('BOOL', 0), 'prune_next' => array('TIMESTAMP', 0), - 'prune_days' => array('TINT:4', 0), - 'prune_viewed' => array('TINT:4', 0), - 'prune_freq' => array('TINT:4', 0), + 'prune_days' => array('UINT', 0), + 'prune_viewed' => array('UINT', 0), + 'prune_freq' => array('UINT', 0), ), 'PRIMARY_KEY' => 'forum_id', 'KEYS' => array( diff --git a/phpBB/includes/acp/auth.php b/phpBB/includes/acp/auth.php index 26977a6ceb..81ba5cd28b 100644 --- a/phpBB/includes/acp/auth.php +++ b/phpBB/includes/acp/auth.php @@ -518,12 +518,15 @@ class auth_admin extends auth 'S_GROUP_MODE' => ($user_mode == 'group') ? true : false) ); + @reset($content_array); while (list($forum_id, $forum_array) = each($content_array)) { // Build role dropdown options $current_role_id = (isset($cur_roles[$ug_id][$forum_id])) ? $cur_roles[$ug_id][$forum_id] : 0; $s_role_options = ''; + + @reset($roles); while (list($role_id, $role_row) = each($roles)) { $role_description = (!empty($user->lang[$role_row['role_description']])) ? $user->lang[$role_row['role_description']] : nl2br($role_row['role_description']); @@ -1056,6 +1059,7 @@ class auth_admin extends auth { global $template, $user, $phpbb_admin_path, $phpEx; + @reset($category_array); while (list($cat, $cat_array) = each($category_array)) { $template->assign_block_vars($tpl_cat, array( @@ -1066,6 +1070,7 @@ class auth_admin extends auth 'CAT_NAME' => $user->lang['permission_cat'][$cat]) ); + @reset($cat_array['permissions']); while (list($permission, $allowed) = each($cat_array['permissions'])) { if ($s_view) @@ -1125,6 +1130,7 @@ class auth_admin extends auth $permissions = $permission_row[$forum_id]; ksort($permissions); + @reset($permissions); while (list($permission, $auth_setting) = each($permissions)) { if (!isset($user->lang['acl_' . $permission])) diff --git a/phpBB/includes/bbcode.php b/phpBB/includes/bbcode.php index 906094b233..b7f274ce35 100644 --- a/phpBB/includes/bbcode.php +++ b/phpBB/includes/bbcode.php @@ -238,7 +238,7 @@ class bbcode case 6: $this->bbcode_cache[$bbcode_id] = array( 'preg' => array( - '!\[color=(#[0-9a-fA-F]{6}|[a-z\-]+):$uid\](.*?)\[/color:$uid\]!s' => $this->bbcode_tpl('color', $bbcode_id), + '!\[color=(#[0-9a-f]{6}|[a-z\-]+):$uid\](.*?)\[/color:$uid\]!is' => $this->bbcode_tpl('color', $bbcode_id), ) ); break; diff --git a/phpBB/includes/diff/engine.php b/phpBB/includes/diff/engine.php index 456b5233d3..a74fa9d263 100644 --- a/phpBB/includes/diff/engine.php +++ b/phpBB/includes/diff/engine.php @@ -271,6 +271,7 @@ class diff_engine } } + // no reset() here while (list($junk, $y) = each($matches)) { if ($y > $this->seq[$k - 1]) diff --git a/phpBB/includes/functions_convert.php b/phpBB/includes/functions_convert.php index a356101e9a..1d78b29968 100644 --- a/phpBB/includes/functions_convert.php +++ b/phpBB/includes/functions_convert.php @@ -37,10 +37,13 @@ function still_on_time() // If zero, then set to something higher to not let the user catch the ten seconds barrier. if ($max_execution_time === 0) { - $max_execution_time = 300; + $max_execution_time = 250; } - $max_execution_time = min(max(10, $max_execution_time), 300); + $max_execution_time = min(max(10, ($max_execution_time - 15)), 250); + + // For debugging purposes + // $max_execution_time = 30; global $starttime; $start_time = (empty($starttime)) ? $current_time : $starttime; @@ -1417,8 +1420,12 @@ function mass_auth($ug_type, $forum_id, $ug_id, $acl_list, $setting = ACL_NO) $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); - $sql = "INSERT INTO $table ($id_field, forum_id, auth_role_id) VALUES ($ug_id, $forum_id, " . $row['role_id'] . ')'; - $db->sql_query($sql); + // If we have no role id there is something wrong here + if ($row) + { + $sql = "INSERT INTO $table ($id_field, forum_id, auth_role_id) VALUES ($ug_id, $forum_id, " . $row['role_id'] . ')'; + $db->sql_query($sql); + } return; } diff --git a/phpBB/includes/message_parser.php b/phpBB/includes/message_parser.php index 07ba6c5b00..138c7f48bf 100644 --- a/phpBB/includes/message_parser.php +++ b/phpBB/includes/message_parser.php @@ -114,7 +114,7 @@ class bbcode_firstpass extends bbcode 'url' => array('bbcode_id' => 3, 'regexp' => array('#\[url(=(.*))?\](.*)\[/url\]#iUe' => "\$this->validate_url('\$2', '\$3')")), 'img' => array('bbcode_id' => 4, 'regexp' => array('#\[img\](https?://)([a-z0-9\-\.,\?!%\*_:;~\\&$@/=\+]+)\[/img\]#ie' => "\$this->bbcode_img('\$1\$2')")), 'size' => array('bbcode_id' => 5, 'regexp' => array('#\[size=([\-\+]?[1-2]?[0-9])\](.*?)\[/size\]#ise' => "\$this->bbcode_size('\$1', '\$2')")), - 'color' => array('bbcode_id' => 6, 'regexp' => array('!\[color=(#[0-9A-Fa-f]{6}|[a-z\-]+)\](.*?)\[/color\]!ise' => "\$this->bbcode_color('\$1', '\$2')")), + 'color' => array('bbcode_id' => 6, 'regexp' => array('!\[color=(#[0-9a-f]{6}|[a-z\-]+)\](.*?)\[/color\]!ise' => "\$this->bbcode_color('\$1', '\$2')")), 'u' => array('bbcode_id' => 7, 'regexp' => array('#\[u\](.*?)\[/u\]#ise' => "\$this->bbcode_underline('\$1')")), 'list' => array('bbcode_id' => 9, 'regexp' => array('#\[list(?:=(?:[a-z0-9]|disc|circle|square))?].*\[/list]#ise' => "\$this->bbcode_parse_list('\$0')")), 'email' => array('bbcode_id' => 10, 'regexp' => array('#\[email=?(.*?)?\](.*?)\[/email\]#ise' => "\$this->validate_email('\$1', '\$2')")), diff --git a/phpBB/install/convertors/convert_phpbb20.php b/phpBB/install/convertors/convert_phpbb20.php index d2bec49982..92a0f24913 100644 --- a/phpBB/install/convertors/convert_phpbb20.php +++ b/phpBB/install/convertors/convert_phpbb20.php @@ -390,6 +390,7 @@ if (!$get_info) array('ban_ip', 'banlist.ban_ip', 'decode_ban_ip'), array('ban_userid', 'banlist.ban_userid', 'phpbb_user_id'), + array('ban_email', 'banlist.ban_email', ''), 'where' => "banlist.ban_ip NOT LIKE '%.%'", ), @@ -397,10 +398,11 @@ if (!$get_info) array( 'target' => BANLIST_TABLE, - array('ban_email', 'banlist.ban_email', ''), - array('ban_userid', 'banlist.ban_userid', 'phpbb_user_id'), + array('ban_ip', 'banlist.ban_ip', ''), + array('ban_userid', '0', ''), + array('ban_email', '', ''), - 'where' => "banlist.ban_ip = ''", + 'where' => "banlist.ban_ip LIKE '%.%'", ), array( diff --git a/phpBB/install/convertors/functions_phpbb20.php b/phpBB/install/convertors/functions_phpbb20.php index 2f7edc18cd..b827c113b0 100644 --- a/phpBB/install/convertors/functions_phpbb20.php +++ b/phpBB/install/convertors/functions_phpbb20.php @@ -749,7 +749,7 @@ function phpbb_convert_authentication($mode) // We only check for ACL_YES equivalence entry if (isset($access[$old_auth_key]) && $access[$old_auth_key] == 1) { - mass_auth('group', $new_forum_id, $access['group_id'], $new_acl, ACL_YES); + mass_auth('group', $new_forum_id, (int) $access['group_id'], $new_acl, ACL_YES); } } } @@ -761,7 +761,7 @@ function phpbb_convert_authentication($mode) // We only check for ACL_YES equivalence entry if (isset($access[$old_auth_key]) && $access[$old_auth_key] == 1) { - mass_auth('user', $new_forum_id, phpbb_user_id($access['user_id']), $new_acl, ACL_YES); + mass_auth('user', $new_forum_id, (int) phpbb_user_id($access['user_id']), $new_acl, ACL_YES); } } } @@ -776,7 +776,7 @@ function phpbb_convert_authentication($mode) // We only check for ACL_YES equivalence entry if (isset($access[$old_auth_key]) && $access[$old_auth_key] == 1) { - mass_auth('group', $new_forum_id, $access['group_id'], $new_acl, ACL_YES); + mass_auth('group', $new_forum_id, (int) $access['group_id'], $new_acl, ACL_YES); } } } @@ -788,7 +788,7 @@ function phpbb_convert_authentication($mode) // We only check for ACL_YES equivalence entry if (isset($access[$old_auth_key]) && $access[$old_auth_key] == 1) { - mass_auth('user', $new_forum_id, phpbb_user_id($access['user_id']), $new_acl, ACL_YES); + mass_auth('user', $new_forum_id, (int) phpbb_user_id($access['user_id']), $new_acl, ACL_YES); } } } @@ -820,7 +820,7 @@ function phpbb_convert_authentication($mode) while ($row = $db->sql_fetchrow($result)) { - mass_auth('user_role', 0, phpbb_user_id($row['user_id']), 'USER_NOAVATAR'); + mass_auth('user_role', 0, (int) phpbb_user_id($row['user_id']), 'USER_NOAVATAR'); } $db->sql_freeresult($result); @@ -832,7 +832,7 @@ function phpbb_convert_authentication($mode) while ($row = $db->sql_fetchrow($result)) { - mass_auth('user_role', 0, phpbb_user_id($row['user_id']), 'USER_NOPM'); + mass_auth('user_role', 0, (int) phpbb_user_id($row['user_id']), 'USER_NOPM'); } $db->sql_freeresult($result); } @@ -848,8 +848,8 @@ function phpbb_convert_authentication($mode) { if (isset($access['auth_mod']) && $access['auth_mod'] == 1) { - mass_auth('user_role', $forum_id, phpbb_user_id($access['user_id']), 'MOD_STANDARD'); - mass_auth('user_role', $forum_id, phpbb_user_id($access['user_id']), 'FORUM_STANDARD'); + mass_auth('user_role', $forum_id, (int) phpbb_user_id($access['user_id']), 'MOD_STANDARD'); + mass_auth('user_role', $forum_id, (int) phpbb_user_id($access['user_id']), 'FORUM_STANDARD'); } } } @@ -862,8 +862,8 @@ function phpbb_convert_authentication($mode) { if (isset($access['auth_mod']) && $access['auth_mod'] == 1) { - mass_auth('group_role', $forum_id, $access['group_id'], 'MOD_STANDARD'); - mass_auth('group_role', $forum_id, $access['group_id'], 'FORUM_STANDARD'); + mass_auth('group_role', $forum_id, (int) $access['group_id'], 'MOD_STANDARD'); + mass_auth('group_role', $forum_id, (int) $access['group_id'], 'FORUM_STANDARD'); } } } diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index a003254df3..90583c8a5a 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -324,6 +324,11 @@ $database_update_info = array( USERS_TABLE => array( 'user_options' => array('UINT:11', 895), ), + FORUMS_TABLE => array( + 'prune_days' => array('UINT', 0), + 'prune_viewed' => array('UINT', 0), + 'prune_freq' => array('UINT', 0), + ), ), // Remove the following keys 'drop_keys' => array( diff --git a/phpBB/install/install_convert.php b/phpBB/install/install_convert.php index 03ed5d7f40..a4b5629596 100644 --- a/phpBB/install/install_convert.php +++ b/phpBB/install/install_convert.php @@ -479,6 +479,24 @@ class install_convert extends module // @todo Need to confirm that max post length in source is <= max post length in destination or there may be interesting formatting issues $config['max_post_chars'] = -1; + $convert->mysql_convert = false; + + switch ($db->sql_layer) + { + // Thanks MySQL, for silently converting... + case 'mysql': + case 'mysql4': + if (version_compare($db->mysql_version, '4.1.3', '>=')) + { + $convert->mysql_convert = true; + } + break; + + case 'mysqli': + $convert->mysql_convert = true; + break; + } + // Set up a user as well. We _should_ have enough of a database here at this point to do this // and it helps for any core code we call $user->session_begin(); @@ -889,24 +907,6 @@ class install_convert extends module $counting = -1; $batch_time = 0; - $convert->mysql_convert = false; - - switch ($db->sql_layer) - { - // Thanks MySQL, for silently converting... - case 'mysql': - case 'mysql4': - if (version_compare($db->mysql_version, '4.1.3', '>=')) - { - $convert->mysql_convert = true; - } - break; - - case 'mysqli': - $convert->mysql_convert = true; - break; - } - while (($counting === -1 || $counting >= $convert->batch_size) && still_on_time()) { $old_current_table = $current_table; @@ -1600,7 +1600,12 @@ class install_convert extends module { if (strpos($type, 'typecast') === 0) { - $value = settype($value, $execution); + if (!is_array($value)) + { + $value = array($value); + } + $value = $value[0]; + settype($value, $execution); } else if (strpos($type, 'function') === 0) { diff --git a/phpBB/install/schemas/mysql_40_schema.sql b/phpBB/install/schemas/mysql_40_schema.sql index 7ceacea8b9..545642ab74 100644 --- a/phpBB/install/schemas/mysql_40_schema.sql +++ b/phpBB/install/schemas/mysql_40_schema.sql @@ -254,9 +254,9 @@ CREATE TABLE phpbb_forums ( enable_icons tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, enable_prune tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, prune_next int(11) UNSIGNED DEFAULT '0' NOT NULL, - prune_days tinyint(4) DEFAULT '0' NOT NULL, - prune_viewed tinyint(4) DEFAULT '0' NOT NULL, - prune_freq tinyint(4) DEFAULT '0' NOT NULL, + prune_days mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + prune_viewed mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + prune_freq mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, PRIMARY KEY (forum_id), KEY left_right_id (left_id, right_id), KEY forum_lastpost_id (forum_last_post_id) diff --git a/phpBB/install/schemas/mysql_41_schema.sql b/phpBB/install/schemas/mysql_41_schema.sql index a34b478be1..05d81ab209 100644 --- a/phpBB/install/schemas/mysql_41_schema.sql +++ b/phpBB/install/schemas/mysql_41_schema.sql @@ -254,9 +254,9 @@ CREATE TABLE phpbb_forums ( enable_icons tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, enable_prune tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, prune_next int(11) UNSIGNED DEFAULT '0' NOT NULL, - prune_days tinyint(4) DEFAULT '0' NOT NULL, - prune_viewed tinyint(4) DEFAULT '0' NOT NULL, - prune_freq tinyint(4) DEFAULT '0' NOT NULL, + prune_days mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + prune_viewed mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, + prune_freq mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, PRIMARY KEY (forum_id), KEY left_right_id (left_id, right_id), KEY forum_lastpost_id (forum_last_post_id) diff --git a/phpBB/install/schemas/oracle_schema.sql b/phpBB/install/schemas/oracle_schema.sql index a1d1e129e7..9f3d287e83 100644 --- a/phpBB/install/schemas/oracle_schema.sql +++ b/phpBB/install/schemas/oracle_schema.sql @@ -509,9 +509,9 @@ CREATE TABLE phpbb_forums ( enable_icons number(1) DEFAULT '1' NOT NULL, enable_prune number(1) DEFAULT '0' NOT NULL, prune_next number(11) DEFAULT '0' NOT NULL, - prune_days number(4) DEFAULT '0' NOT NULL, - prune_viewed number(4) DEFAULT '0' NOT NULL, - prune_freq number(4) DEFAULT '0' NOT NULL, + prune_days number(8) DEFAULT '0' NOT NULL, + prune_viewed number(8) DEFAULT '0' NOT NULL, + prune_freq number(8) DEFAULT '0' NOT NULL, CONSTRAINT pk_phpbb_forums PRIMARY KEY (forum_id) ) / diff --git a/phpBB/install/schemas/postgres_schema.sql b/phpBB/install/schemas/postgres_schema.sql index a5a3a4b546..d0005a16a7 100644 --- a/phpBB/install/schemas/postgres_schema.sql +++ b/phpBB/install/schemas/postgres_schema.sql @@ -386,9 +386,9 @@ CREATE TABLE phpbb_forums ( enable_icons INT2 DEFAULT '1' NOT NULL CHECK (enable_icons >= 0), enable_prune INT2 DEFAULT '0' NOT NULL CHECK (enable_prune >= 0), prune_next INT4 DEFAULT '0' NOT NULL CHECK (prune_next >= 0), - prune_days INT2 DEFAULT '0' NOT NULL, - prune_viewed INT2 DEFAULT '0' NOT NULL, - prune_freq INT2 DEFAULT '0' NOT NULL, + prune_days INT4 DEFAULT '0' NOT NULL CHECK (prune_days >= 0), + prune_viewed INT4 DEFAULT '0' NOT NULL CHECK (prune_viewed >= 0), + prune_freq INT4 DEFAULT '0' NOT NULL CHECK (prune_freq >= 0), PRIMARY KEY (forum_id) ); diff --git a/phpBB/install/schemas/sqlite_schema.sql b/phpBB/install/schemas/sqlite_schema.sql index d33f38b35a..184d2332ab 100644 --- a/phpBB/install/schemas/sqlite_schema.sql +++ b/phpBB/install/schemas/sqlite_schema.sql @@ -247,9 +247,9 @@ CREATE TABLE phpbb_forums ( enable_icons INTEGER UNSIGNED NOT NULL DEFAULT '1', enable_prune INTEGER UNSIGNED NOT NULL DEFAULT '0', prune_next INTEGER UNSIGNED NOT NULL DEFAULT '0', - prune_days tinyint(4) NOT NULL DEFAULT '0', - prune_viewed tinyint(4) NOT NULL DEFAULT '0', - prune_freq tinyint(4) NOT NULL DEFAULT '0' + prune_days INTEGER UNSIGNED NOT NULL DEFAULT '0', + prune_viewed INTEGER UNSIGNED NOT NULL DEFAULT '0', + prune_freq INTEGER UNSIGNED NOT NULL DEFAULT '0' ); CREATE INDEX phpbb_forums_left_right_id ON phpbb_forums (left_id, right_id);