diff options
Diffstat (limited to 'phpBB/upgrade.php')
-rw-r--r-- | phpBB/upgrade.php | 99 |
1 files changed, 64 insertions, 35 deletions
diff --git a/phpBB/upgrade.php b/phpBB/upgrade.php index 81ee41e41d..762a400a60 100644 --- a/phpBB/upgrade.php +++ b/phpBB/upgrade.php @@ -161,7 +161,7 @@ function query($sql, $errormsg) } } -function smiley_replace($text = "") +function smiley_replace($text = '') { global $db; @@ -186,7 +186,7 @@ function smiley_replace($text = "") } } - return ( $text != "" ) ? preg_replace($search, $replace, $text) : ""; + return ( $text != '' ) ? preg_replace($search, $replace, $text) : ''; } @@ -201,22 +201,22 @@ function get_schema() { $line = $schemafile[$i]; - if ( preg_match("/^CREATE TABLE (\w+)/i", $line, $matches) ) + if ( preg_match('/^CREATE TABLE (\w+)/i', $line, $matches) ) { // Start of a new table definition, set some variables and go to the next line. $tabledata = 1; // Replace the 'phpbb_' prefix by the user defined prefix. - $table = str_replace("phpbb_", $table_prefix, $matches[1]); + $table = str_replace('phpbb_', $table_prefix, $matches[1]); $table_def[$table] = "CREATE TABLE $table (\n"; continue; } - if ( preg_match("/^\);/", $line) ) + if ( preg_match('/^\);/', $line) ) { // End of the table definition // After this we will skip everything until the next 'CREATE' line $tabledata = 0; - $table_def[$table] .= ")"; // We don't need the closing semicolon + $table_def[$table] .= ')'; // We don't need the closing semicolon } if ( $tabledata == 1 ) @@ -224,18 +224,18 @@ function get_schema() // We are inside a table definition, parse this line. // Add the current line to the complete table definition: $table_def[$table] .= $line; - if ( preg_match("/^\s*(\w+)\s+(\w+)\((\d+)\)(.*)$/", $line, $matches) ) + if ( preg_match('/^\s*(\w+)\s+(\w+)\(([\d,]+)\)(.*)$/', $line, $matches) ) { // This is a column definition $field = $matches[1]; $type = $matches[2]; $size = $matches[3]; - preg_match("/DEFAULT (NULL|\'.*?\')[,\s](.*)$/i", $matches[4], $match); + preg_match('/DEFAULT (NULL|\'.*?\')[,\s](.*)$/i', $matches[4], $match); $default = $match[1]; - $notnull = ( preg_match("/NOT NULL/i", $matches[4]) ) ? 1 : 0; - $auto_increment = ( preg_match("/auto_increment/i", $matches[4]) ) ? 1 : 0; + $notnull = ( preg_match('/NOT NULL/i', $matches[4]) ) ? 1 : 0; + $auto_increment = ( preg_match('/auto_increment/i', $matches[4]) ) ? 1 : 0; $field_def[$table][$field] = array( 'type' => $type, @@ -246,17 +246,17 @@ function get_schema() ); } - if ( preg_match("/\s*PRIMARY\s+KEY\s*\((.*)\).*/", $line, $matches) ) + if ( preg_match('/\s*PRIMARY\s+KEY\s*\((.*)\).*/', $line, $matches) ) { // Primary key $key_def[$table]['PRIMARY'] = $matches[1]; } - else if ( preg_match("/\s*KEY\s+(\w+)\s*\((.*)\)/", $line, $matches) ) + else if ( preg_match('/\s*KEY\s+(\w+)\s*\((.*)\)/', $line, $matches) ) { // Normal key $key_def[$table][$matches[1]] = $matches[2]; } - else if ( preg_match("/^\s*(\w+)\s*(.*?),?\s*$/", $line, $matches) ) + else if ( preg_match('/^\s*(\w+)\s*(.*?),?\s*$/', $line, $matches) ) { // Column definition $create_def[$table][$matches[1]] = $matches[2]; @@ -280,11 +280,11 @@ function get_inserts() { global $table_prefix; - $insertfile = file("db/schemas/mysql_basic.sql"); + $insertfile = file('db/schemas/mysql_basic.sql'); for($i = 0; $i < count($insertfile); $i++) { - if ( preg_match("/(INSERT INTO (\w+)\s.*);/i", str_replace("phpbb_", $table_prefix, $insertfile[$i]), $matches) ) + if ( preg_match('/(INSERT INTO (\w+)\s.*);/i', str_replace('phpbb_', $table_prefix, $insertfile[$i]), $matches) ) { $returnvalue[$matches[2]][] = $matches[1]; } @@ -323,16 +323,16 @@ function output_table_content($content) function bbdecode($message) { // Undo [code] - $code_start_html = "<!-- BBCode Start --><TABLE BORDER=0 ALIGN=CENTER WIDTH=85%><TR><TD><font size=-1>Code:</font><HR></TD></TR><TR><TD><FONT SIZE=-1><PRE>"; - $code_end_html = "</PRE></FONT></TD></TR><TR><TD><HR></TD></TR></TABLE><!-- BBCode End -->"; - $message = str_replace($code_start_html, "[code]", $message); - $message = str_replace($code_end_html, "[/code]", $message); + $code_start_html = '<!-- BBCode Start --><TABLE BORDER=0 ALIGN=CENTER WIDTH=85%><TR><TD><font size=-1>Code:</font><HR></TD></TR><TR><TD><FONT SIZE=-1><PRE>'; + $code_end_html = '</PRE></FONT></TD></TR><TR><TD><HR></TD></TR></TABLE><!-- BBCode End -->'; + $message = str_replace($code_start_html, '[code]', $message); + $message = str_replace($code_end_html, '[/code]', $message); // Undo [quote] - $quote_start_html = "<!-- BBCode Quote Start --><TABLE BORDER=0 ALIGN=CENTER WIDTH=85%><TR><TD><font size=-1>Quote:</font><HR></TD></TR><TR><TD><FONT SIZE=-1><BLOCKQUOTE>"; - $quote_end_html = "</BLOCKQUOTE></FONT></TD></TR><TR><TD><HR></TD></TR></TABLE><!-- BBCode Quote End -->"; - $message = str_replace($quote_start_html, "[quote]", $message); - $message = str_replace($quote_end_html, "[/quote]", $message); + $quote_start_html = '<!-- BBCode Quote Start --><TABLE BORDER=0 ALIGN=CENTER WIDTH=85%><TR><TD><font size=-1>Quote:</font><HR></TD></TR><TR><TD><FONT SIZE=-1><BLOCKQUOTE>'; + $quote_end_html = '</BLOCKQUOTE></FONT></TD></TR><TR><TD><HR></TD></TR></TABLE><!-- BBCode Quote End -->'; + $message = str_replace($quote_start_html, '[quote]', $message); + $message = str_replace($quote_end_html, '[/quote]', $message); // Undo [b] and [i] $message = preg_replace("#<!-- BBCode Start --><B>(.*?)</B><!-- BBCode End -->#s", "[b]\\1[/b]", $message); @@ -353,17 +353,17 @@ function bbdecode($message) // Undo lists (unordered/ordered) // <li> tags: - $message = str_replace("<!-- BBCode --><LI>", "[*]", $message); + $message = str_replace('<!-- BBCode --><LI>', '[*]', $message); // [list] tags: - $message = str_replace("<!-- BBCode ulist Start --><UL>", "[list]", $message); + $message = str_replace('<!-- BBCode ulist Start --><UL>', '[list]', $message); // [list=x] tags: - $message = preg_replace("#<!-- BBCode olist Start --><OL TYPE=([A1])>#si", "[list=\\1]", $message); + $message = preg_replace('#<!-- BBCode olist Start --><OL TYPE=([A1])>#si', "[list=\\1]", $message); // [/list] tags: - $message = str_replace("</UL><!-- BBCode ulist End -->", "[/list]", $message); - $message = str_replace("</OL><!-- BBCode olist End -->", "[/list]", $message); + $message = str_replace('</UL><!-- BBCode ulist End -->', '[/list]', $message); + $message = str_replace('</OL><!-- BBCode olist End -->', '[/list]', $message); return $message; } @@ -1075,7 +1075,7 @@ if ( !empty($next) ) // undo 1.2.x encoding.. $row['post_text'] = bbdecode(stripslashes($row['post_text'])); $row['post_text'] = undo_make_clickable($row['post_text']); - $row['post_text'] = str_replace("<BR>", "\n", $row['post_text']); + $row['post_text'] = str_replace('<BR>', "\n", $row['post_text']); // make a uid $uid = make_bbcode_uid(); @@ -1086,14 +1086,14 @@ if ( !empty($next) ) $row['post_text'] = addslashes($row['post_text']); $edited_sql = ""; - if ( preg_match("/^(.*?)([\n]+<font size=\-1>\[ This message was .*?)$/s", $row['post_text'], $matches) ) + if ( preg_match('/^(.*?)([\n]+<font size=\-1>\[ This message was .*?)$/s', $row['post_text'], $matches) ) { $row['post_text'] = $matches[1]; $edit_info = $matches[2]; - $edit_times = count(explode(" message ", $edit_info)) - 1; // Taken from example for substr_count in annotated PHP manual + $edit_times = count(explode(' message ', $edit_info)) - 1; // Taken from example for substr_count in annotated PHP manual - if ( preg_match("/^.* by: (.*?) on (....)-(..)-(..) (..):(..) \]<\/font>/s", $edit_info, $matches) ) + if ( preg_match('/^.* by: (.*?) on (....)-(..)-(..) (..):(..) \]<\/font>/s', $edit_info, $matches) ) { $edited_user = $matches[1]; $edited_time = gmmktime($matches[5], $matches[6], 0, $matches[3], $matches[4], $matches[2]); @@ -1130,7 +1130,7 @@ if ( !empty($next) ) $inc++; if ( $inc == $per_pct ) { - print "."; + print '.'; flush(); $inc = 0; } @@ -1259,7 +1259,7 @@ if ( !empty($next) ) $inc++; if ( $inc == $per_pct ) { - print "."; + print '.'; flush(); $inc = 0; } @@ -1279,7 +1279,7 @@ if ( !empty($next) ) while( $row = $db->sql_fetchrow($result) ) { // Check if this moderator and this forum still exist - $sql = "SELECT NULL + $sql = "SELECT user_id FROM " . USERS_TABLE . ", " . FORUMS_TABLE . " WHERE user_id = " . $row['user_id'] . " AND forum_id = " . $row['forum_id']; @@ -1309,6 +1309,35 @@ if ( !empty($next) ) print "<span class=\"ok\"><b>OK</b></span><br />\n"; } + + print " * Setting correct user_level for moderators ::"; + flush(); + + $sql = "SELECT DISTINCT u.user_id + FROM " . USERS_TABLE . " u, " . USER_GROUP_TABLE . " ug, " . AUTH_ACCESS_TABLE . " aa + WHERE aa.auth_mod = 1 + AND ug.group_id = aa.group_id + AND u.user_id = ug.user_id + AND u.user_level <> " . ADMIN; + $result = query($sql, "Couldn't obtain list of moderators"); + + if ( $row = $db->sql_fetchrow($result) ) + { + $ug_sql = ''; + + do + { + $ug_sql .= ( ( $ug_sql != '' ) ? ', ' : '' ) . $row['user_id']; + } + while ( $row = $db->sql_fetchrow($result) ); + + $sql = "UPDATE " . USERS_TABLE . " + SET user_level = " . MOD . " + WHERE user_id IN ($ug_sql)"; + query($sql, "Couldn't set moderator status for users"); + } + + print "<span class=\"ok\"><b>OK</b></span><br />\n"; end_step('convert_privforums'); |