From 012e64b3d214e8c6eae2cbb21cd9881f2e623dbe Mon Sep 17 00:00:00 2001
From: hd2000 <hd2000@users.sourceforge.net>
Date: Wed, 7 Mar 2001 18:54:38 +0000
Subject: [PATCH] Added del_backup_table function to delete the backup tables

git-svn-id: file:///svn/phpbb/trunk@85 89ea8834-ac86-4346-8a33-228a782c2dd0
---
 phpBB/upgrade_20.php | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/phpBB/upgrade_20.php b/phpBB/upgrade_20.php
index 094cc5dedd..4964cf68b1 100644
--- a/phpBB/upgrade_20.php
+++ b/phpBB/upgrade_20.php
@@ -61,6 +61,13 @@ function change_column($db, $table, $column, $type, $null)
 		echo "<font color=\"#FF0000\">ERROR! count not change column $column from table $table.  Reason: <b>" . mysql_error().  "</B></FONT>";      
 }
 
+function del_backup_table($db, $table) 
+{
+	$sql = "drop table $table";
+   if (!$r = mysql_query($sql, $db))
+		echo "<font color=\"#FF0000\">ERROR! could not delete table $table.  Reason: <b>" . mysql_error().  "</B></FONT>";   
+}
+
 function add_column($db, $table, $column, $type, $null)
 {
 	$sql = "alter table $table add $column $type $null";
@@ -110,6 +117,7 @@ if($next)
 				echo "Backing up the $table_name table... <BR>";
 
 				$backup_name = $table_name . "_backup";
+            								
 				$table_create = "CREATE TABLE $backup_name (\n";
 
 				$r = mysql_query("show fields from $table_name", $db);
@@ -342,6 +350,7 @@ Backups completed ok.<P>
 			$forum_id  = $row['forum_id'];
 			$poster_id = $row['poster_id'];
 			$post_text = $row['post_text'];
+                        $post_text = addslashes('$post_text');
 
 			$sql = "insert posts (post_id, topic_id,  forum_id, poster_id, post_time, poster_ip)
 					  values ($post_id, $topic_id, $forum_id, $poster_id, $post_time, $post_ip)";
@@ -450,6 +459,27 @@ Backups completed ok.<P>
 
 		}
 
+      echo "Delete the backup tables ..<br>";
+      flush();
+
+      $tables = array("posts"    , 
+		 					 "priv_msgs", 
+							 "sessions" , 
+							 "topics"   , 
+							 "banlist"  ,
+							 "config"   ,
+							 "forums"   ,
+							 "users"    ,
+							 "access"   ,
+							 "smiles"   ,
+							 "words"    ,
+							 "forum_mods");
+   	while (list(, $drop_table) = each($tables)) 
+		{
+				$backup_name = $drop_table . '_backup';
+            del_backup_table($db, $backup_name);
+      }
+
 ?>
 All Done.
 <?php