From 2f0b5cfc4c228940e8d2fb6c63fa67ec73cd577b Mon Sep 17 00:00:00 2001 From: the_systech Date: Thu, 5 Jul 2001 21:03:45 +0000 Subject: [PATCH] Update to use templates, and new message_die instead of error_die git-svn-id: file:///svn/phpbb/trunk@576 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/admin/db_utilities.php | 166 ++++++++++++++++++++--------------- 1 file changed, 95 insertions(+), 71 deletions(-) diff --git a/phpBB/admin/db_utilities.php b/phpBB/admin/db_utilities.php index a4886b19ee..5422ee5cc5 100644 --- a/phpBB/admin/db_utilities.php +++ b/phpBB/admin/db_utilities.php @@ -38,8 +38,23 @@ define("VERBOSE", "0"); // Bring in the necessary files to include functions we will use later. include('extension.inc'); -include('common.' . $phpEx); +include('common.'.$phpEx); +// +// Start session management +// +$userdata = session_pagestart($user_ip, PAGE_INDEX, $session_length); +init_userprefs($userdata); +// +// End sessionmanagement +// + +// +// Define Template files... +// +$template->set_filenames(array( + "body" => "admin/db_utilities.tpl")); + // define a constant for the dbms so that we don't have to redeclare it // global for each function.... define('DBMS', "$dbms"); @@ -47,27 +62,6 @@ define('DBMS', "$dbms"); // allowed. @set_time_limit(600); -function common_header() -{ -?> - - - -phpBB - Database Backup - - - - - -sql_error(); - error_die(GENERAL_ERROR, 'Failed in get_table_def (show fields) : ' . $error['message']); + message_die(GENERAL_ERROR, 'Failed in get_table_def (show fields) : ' . $error['message']); } // end if.. if ($drop == 1) { @@ -203,7 +197,7 @@ function get_table_def_postgres($db, $table, $crlf) if(!$result) { $error = $db->sql_error(); - error_die(GENERAL_ERROR, 'Failed in get_table_def (show fields) : ' . $error['message']); + message_die(GENERAL_ERROR, 'Failed in get_table_def (show fields) : ' . $error['message']); } // end if.. while ( $row = $db->sql_fetchrow($result)) { @@ -259,7 +253,7 @@ function get_table_def_postgres($db, $table, $crlf) if (!$result) { $error = $db->sql_error(); - error_die(GENERAL_ERROR, 'Failed in get_table_def (show fields) : ' . $error['message']); + message_die(GENERAL_ERROR, 'Failed in get_table_def (show fields) : ' . $error['message']); } // end if(!$result)... while ($row = $db->sql_fetchrow($result)) { @@ -297,7 +291,7 @@ function get_table_def_mysql($db, $table, $crlf) if(!result) { $error = $db->sql_error(); - error_die(GENERAL_ERROR, 'Failed in get_table_def (show fields) : ' . $error['message']); + message_die(GENERAL_ERROR, 'Failed in get_table_def (show fields) : ' . $error['message']); } while ($row = $db->sql_fetchrow($result)) { @@ -324,7 +318,7 @@ function get_table_def_mysql($db, $table, $crlf) if(!$result) { $error = $db->sql_error(); - error_die(GENERAL_ERROR, 'FAILED IN get_table_def (show keys) : ' . $error['message']); + message_die(GENERAL_ERROR, 'FAILED IN get_table_def (show keys) : ' . $error['message']); } while($row = $db->sql_fetchrow($result)) { $kname = $row['Key_name']; @@ -385,7 +379,7 @@ function get_table_content_postgres($db, $table, $handler) if (!$result) { $error = $db->sql_error(); - error_die(GENERAL_ERROR, 'Faild in get_table_content (select *): ' . $error['message']); + message_die(GENERAL_ERROR, 'Faild in get_table_content (select *): ' . $error['message']); } // end if(!$result)... $i_num_fields = $db->sql_numfields($result); for ($i = 0; $i < $i_num_fields; $i++) @@ -448,7 +442,7 @@ function get_table_content_mysql($db, $table, $handler) if(!$result) { $error = $db->sql_error(); - error_die(GENERAL_ERROR, 'Failed in get_table_content (select *): ' . $error['message']); + message_die(GENERAL_ERROR, 'Failed in get_table_content (select *): ' . $error['message']); } if($db->sql_numrows($result) > 0) { @@ -566,6 +560,18 @@ if(isset($perform)) switch($perform) { case 'backup': + if((DBMS == 'oracle') || (DBMS == 'odbc') || (DBMS == 'mssql')) + { + $db_message = '

Database backups are not currently supported for '; + $db_message .= 'your Database system (' . DBMS . ")

\n"; + $db_links = '
Return to admin'; + $template->assign_vars(array( + "U_DB_MESSAGE" => $db_message, + "U_DB_LINKS" => $db_links + )); + $template->pparse("body"); + exit; + } $tables = array('auth_access', 'auth_forums', 'banlist', 'categories', 'config', 'disallow', 'forum_access', 'forum_mods', 'forums', 'groups', 'posts', 'posts_text', 'privmsgs', 'ranks', 'session', 'session_keys', 'smilies', 'themes', 'themes_name', 'topics', 'user_group', 'users', 'words'); if(!isset($additional_tables) && !empty($additional_tables)) { @@ -582,20 +588,23 @@ if(isset($perform)) } if(!isset($backupstart)) { - common_header(); - echo "

This will perform a backup of all phpBB2 related tables.


"; - echo "

If you have any additional custom tables in the same database with phpBB that you would like to back up as well please enter their names seperated by commas in the Additional Tables textbox below.
\n"; - echo "Otherwise just select the form of backup you want to perform and click the Start Backup button below.


\n\n"; - echo "
\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "
Additional Tables:
Full Backup:
Table Structure Only:
Table Data Only:
\n"; - echo ""; - echo "

\n"; - common_footer(); + $db_message = "

This will perform a backup of all phpBB2 related tables.


\n"; + $db_message .= "

If you have any additional custom tables in the same database with phpBB that you would like to back up as well please enter their names seperated by commas in the Additional Tables textbox below.
\n"; + $db_message .= "Otherwise just select the form of backup you want to perform and click the Start Backup button below.


\n\n"; + $db_links = "
\n"; + $db_links .= "\n"; + $db_links .= "\n"; + $db_links .= "\n"; + $db_links .= "\n"; + $db_links .= "\n"; + $db_links .= "
Additional Tables:
Full Backup:
Table Structure Only:
Table Data Only:
\n"; + $db_links .= ""; + $db_links .= "

\n"; + $template->assign_vars(array( + "U_DB_MESSAGE" => $db_message, + "U_DB_LINKS" => $db_links + )); + $template->pparse("body"); exit; } // Build the sql script file... @@ -633,21 +642,25 @@ if(isset($perform)) case 'restore': if(!isset($restore_start)) { - common_header(); - echo "

This will perform a full restore of a previously Backed up phpBB database


\n"; - echo "

WARNING: This will overwrite any existing data
\n"; - echo "

\n"; - echo "\n"; - echo "Backup File:\n"; - echo "\n"; - echo "

\n"; - common_footer(); + $db_message = "

This will perform a full restore of a previously Backed up phpBB database


\n"; + $db_message .= "

WARNING: This will overwrite any existing data
\n"; + $db_links = "

\n"; + $db_links .= "\n"; + $db_links .= "Backup File:\n"; + $db_links .= "\n"; + $db_links .= "

\n"; + $template->assign_vars(array( + "U_DB_MESSAGE" => $db_message, + "U_DB_LINKS" => $db_links + )); + $template->pparse("body"); + exit; } else { // Handle the file upload .... if($backup_file == "none") { - error_die(GENERAL_ERROR, 'Backup file upload failed...'); + message_die(GENERAL_ERROR, 'Backup file upload failed...'); exit; } if(ereg("^php[0-9A-Za-z_.-]+$", basename($backup_file))) @@ -659,7 +672,7 @@ if(isset($perform)) } } else { - error_die(GENERAL_ERROR, 'Trouble Accessing uploaded file...'); + message_die(GENERAL_ERROR, 'Trouble Accessing uploaded file...'); exit; } $sql_query = trim($sql_query); @@ -681,35 +694,46 @@ if(isset($perform)) if(!$result && (!(DBMS == 'postgres' && eregi("drop table", $sql)))) { $error = $db->sql_error(); - error_die(GENERAL_ERROR, 'Error importing backup file : ' . $error['message'] . "\n$sql"); + message_die(GENERAL_ERROR, 'Error importing backup file : ' . $error['message'] . "\n$sql"); } } } } - common_header(); - echo "

The Database has been successfully restored..

\n"; - echo "


Your board should be back to the state it was when the backup was made.
\n"; - echo 'Go back to the Admin'; - echo '

'; - common_footer(); + $db_message = "

The Database has been successfully restored..

\n"; + $db_message .= "


Your board should be back to the state it was when the backup was made.

\n"; + $db_links = 'Go back to the Admin'; + $template->assign_vars(array( + "U_DB_MESSAGE" => $db_message, + "U_DB_LINKS" => $db_links + )); + $template->pparse("body"); + exit; } - exit; break; } } elseif (isset($backup_done)) { - common_header(); - echo "

Your backup file should be downloading now


\n"; - echo "Click Here to return to the Database Utilities
\n"; - common_footer(); + $db_message = "

Your backup file should be downloading now


\n"; + $db_links = "Click Here to return to the Database Utilities
\n"; + $template->assign_vars(array( + "U_DB_MESSAGE" => $db_message, + "U_DB_LINKS" => $db_links + )); + $template->pparse("body"); + exit; } else { - common_header(); - echo "\n"; - echo "\n"; - echo "\n"; - common_footer(); + $db_message = "

These Utilties will help you to backup or restore your phpBB database


\n"; + $db_links = "

Database Utilities

Backup Database
Restore Database
\n"; + $db_links .= "\n"; + $db_links .= "

Database Utilities

Backup Database
Restore Database
\n"; + $template->assign_vars(array( + "U_DB_MESSAGE" => $db_message, + "U_DB_LINKS" => $db_links + )); + $template->pparse("body"); + exit; } ?>