From 9a3a8ed9f332f5483e049a82795d7215a79b1f99 Mon Sep 17 00:00:00 2001 From: Joe Hunt Date: Mon, 11 Feb 2008 14:56:31 +0000 Subject: [PATCH] Added file, update_db.php, for updating company databases from an SQL script. --- CHANGELOG.txt | 5 +++ update.html | 42 +++++++++--------- update_db.php | 117 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 144 insertions(+), 20 deletions(-) create mode 100644 update_db.php diff --git a/CHANGELOG.txt b/CHANGELOG.txt index a292e98f..670871cf 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -19,6 +19,11 @@ Legend: ! -> Note $ -> Affected files +11-Feb-2008 Joe Hunt ++ Added file, update_db.php, for updating company databases from an SQL script. +$ update_db.php (New file) + update.html + 06-Fef-2008 Joe Hunt + Added Report, Salesman Listing, rep106.php. $ /reporting/reports_main.php diff --git a/update.html b/update.html index e6114b00..5731d24f 100644 --- a/update.html +++ b/update.html @@ -4,7 +4,7 @@ - + FrontAccounting Update @@ -17,40 +17,42 @@

Important Notes

 

diff --git a/update_db.php b/update_db.php new file mode 100644 index 00000000..4b14ad70 --- /dev/null +++ b/update_db.php @@ -0,0 +1,117 @@ + + + + +
$msg

\n"; +} + +function display_notification($msg, $center=true) +{ + echo "
+ + + +
$msg

\n"; +} + + +function db_open($conn) +{ + $db = mysql_connect($conn["host"] ,$conn["dbuser"], $conn["dbpassword"]); + if (!$db) + return false; + if (!mysql_select_db($conn["dbname"], $db)) + return false; + return $db; +} + +echo "\n"; +echo "$title\n"; +echo "\n"; +echo "\n"; +echo $js; +echo " \n"; +echo ""; + +echo "



"; +echo "\n"; +echo "\n"; +echo "
FrontAccounting
\n"; + +echo "

"; +echo "
$title
\n"; +echo "
"; + +if (isset($_POST["submit"])) +{ + if (!isset($_FILES['uploadfile']['tmp_name']) || !is_uploaded_file($_FILES['uploadfile']['tmp_name'])) + { + display_error("You must select an SQL script for update");; + } + else + { + include_once($path_to_root."/config_db.php"); + if (!isset($_POST['user']) || !isset($_POST['passwd']) || $_POST['user'] == "") + { + display_error("You must select a user name and an optional password"); + } + else + { + foreach($db_connections as $id => $conn) + { + $conn['dbuser'] = $_POST['user']; + $conn['dbpassword'] = $_POST['passwd']; + if (!($db = db_open($conn))) + { + display_error("Wrong user name or password - ".mysql_error()); + } + else + { + if (!db_import($_FILES['uploadfile']['tmp_name'], $conn)) + display_error("Bad SQL file or you have already updated the company: " + . $id . " " . $conn['name']." - ".mysql_error()); + else + display_notification("Database has been updated for company: " + . $id . " " . $conn['name']); + } + } + } + } +} +if (!isset($_POST['passwd'])) + $_POST['passwd'] = ""; + +echo "
\n"; + +echo "\n"; + +text_row_ex("Database User", "user", 20); +label_row("Password", ""); +label_row("Upload Script", ""); +submit_row("submit", "Update"); + +echo "
\n";; + +echo "

"; +echo "
Choose from Database update scripts in SQL folder. No Datase is updated without a script.
\n"; +echo "
"; + +echo "
\n"; + +echo "\n"; +?> \ No newline at end of file -- 2.30.2