|
From: Paul S. O. <ps...@us...> - 2002-04-08 16:38:57
|
Update of /cvsroot/phpbb/phpBB2
In directory usw-pr-cvs1:/tmp/cvs-serv11713
Modified Files:
Tag: phpBB-2_0_0
upgrade.php
Log Message:
Fix user_timezone problem (in association with new schemas) + fix setting of user_level for moderators
Index: upgrade.php
===================================================================
RCS file: /cvsroot/phpbb/phpBB2/upgrade.php,v
retrieving revision 1.27
retrieving revision 1.27.2.1
diff -C2 -r1.27 -r1.27.2.1
*** upgrade.php 25 Mar 2002 20:28:11 -0000 1.27
--- upgrade.php 8 Apr 2002 01:11:06 -0000 1.27.2.1
***************
*** 162,166 ****
}
! function smiley_replace($text = "")
{
global $db;
--- 162,166 ----
}
! function smiley_replace($text = '')
{
global $db;
***************
*** 187,191 ****
}
! return ( $text != "" ) ? preg_replace($search, $replace, $text) : "";
}
--- 187,191 ----
}
! return ( $text != '' ) ? preg_replace($search, $replace, $text) : '';
}
***************
*** 202,221 ****
$line = $schemafile[$i];
! 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_def[$table] = "CREATE TABLE $table (\n";
continue;
}
! 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
}
--- 202,221 ----
$line = $schemafile[$i];
! 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_def[$table] = "CREATE TABLE $table (\n";
continue;
}
! 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
}
***************
*** 225,229 ****
// Add the current line to the complete table definition:
$table_def[$table] .= $line;
! if ( preg_match("/^\s*(\w+)\s+(\w+)\((\d+)\)(.*)$/", $line, $matches) )
{
// This is a column definition
--- 225,229 ----
// Add the current line to the complete table definition:
$table_def[$table] .= $line;
! if ( preg_match('/^\s*(\w+)\s+(\w+)\(([\d,]+)\)(.*)$/', $line, $matches) )
{
// This is a column definition
***************
*** 232,240 ****
$size = $matches[3];
! 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;
$field_def[$table][$field] = array(
--- 232,240 ----
$size = $matches[3];
! 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;
$field_def[$table][$field] = array(
***************
*** 247,261 ****
}
! 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) )
{
// Normal key
$key_def[$table][$matches[1]] = $matches[2];
}
! else if ( preg_match("/^\s*(\w+)\s*(.*?),?\s*$/", $line, $matches) )
{
// Column definition
--- 247,261 ----
}
! 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) )
{
// Normal key
$key_def[$table][$matches[1]] = $matches[2];
}
! else if ( preg_match('/^\s*(\w+)\s*(.*?),?\s*$/', $line, $matches) )
{
// Column definition
***************
*** 281,289 ****
global $table_prefix;
! $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) )
{
$returnvalue[$matches[2]][] = $matches[1];
--- 281,289 ----
global $table_prefix;
! $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) )
{
$returnvalue[$matches[2]][] = $matches[1];
***************
*** 324,337 ****
{
// 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);
// 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);
// Undo [b] and [i]
--- 324,337 ----
{
// 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);
// 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);
// Undo [b] and [i]
***************
*** 354,368 ****
// <li> tags:
! $message = str_replace("<!-- BBCode --><LI>", "[*]", $message);
// [list] tags:
! $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);
// [/list] tags:
! $message = str_replace("</UL><!-- BBCode ulist End -->", "[/list]", $message);
! $message = str_replace("</OL><!-- BBCode olist End -->", "[/list]", $message);
return $message;
--- 354,368 ----
// <li> tags:
! $message = str_replace('<!-- BBCode --><LI>', '[*]', $message);
// [list] tags:
! $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);
// [/list] tags:
! $message = str_replace('</UL><!-- BBCode ulist End -->', '[/list]', $message);
! $message = str_replace('</OL><!-- BBCode olist End -->', '[/list]', $message);
return $message;
***************
*** 1076,1080 ****
$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']);
// make a uid
--- 1076,1080 ----
$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']);
// make a uid
***************
*** 1087,1098 ****
$edited_sql = "";
! 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
! if ( preg_match("/^.* by: (.*?) on (....)-(..)-(..) (..):(..) \]<\/font>/s", $edit_info, $matches) )
{
$edited_user = $matches[1];
--- 1087,1098 ----
$edited_sql = "";
! 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
! if ( preg_match('/^.* by: (.*?) on (....)-(..)-(..) (..):(..) \]<\/font>/s', $edit_info, $matches) )
{
$edited_user = $matches[1];
***************
*** 1131,1135 ****
if ( $inc == $per_pct )
{
! print ".";
flush();
$inc = 0;
--- 1131,1135 ----
if ( $inc == $per_pct )
{
! print '.';
flush();
$inc = 0;
***************
*** 1260,1264 ****
if ( $inc == $per_pct )
{
! print ".";
flush();
$inc = 0;
--- 1260,1264 ----
if ( $inc == $per_pct )
{
! print '.';
flush();
$inc = 0;
***************
*** 1280,1284 ****
{
// Check if this moderator and this forum still exist
! $sql = "SELECT NULL
FROM " . USERS_TABLE . ", " . FORUMS_TABLE . "
WHERE user_id = " . $row['user_id'] . "
--- 1280,1284 ----
{
// Check if this moderator and this forum still exist
! $sql = "SELECT user_id
FROM " . USERS_TABLE . ", " . FORUMS_TABLE . "
WHERE user_id = " . $row['user_id'] . "
***************
*** 1310,1313 ****
--- 1310,1342 ----
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');
|