2 //ini_set("display_errors", "on");
4 include_once($path_to_root. "/admin/db/maintenance_db.inc");
5 include_once($path_to_root. "/includes/db/connect_db.inc");
6 include_once($path_to_root. "/includes/ui/ui_view.inc");
7 include_once($path_to_root. "/includes/ui/ui_input.inc");
9 $js = get_js_png_fix();
10 $js .= get_js_set_focus("user");
11 $image = $path_to_root."/themes/default/images/logo_frontaccounting.png";
12 $title = "Update All Company Databases";
14 function display_error($msg, $center=true)
16 echo "<center><table border='1' cellpadding='3' cellspacing='0' style='border-collapse: collapse' bordercolor='#CC3300' width='50%'>
18 <td " . ($center?"align='center' ":"") . " width='100%' bgcolor='#ffcccc'><font color='#dd2200'>$msg</font></td>
20 </table></center><br>\n";
23 function display_notification($msg, $center=true)
25 echo "<center><table border='1' cellpadding='3' cellspacing='0' style='border-collapse: collapse' bordercolor='#33cc00' width='50%'>
27 <td " . ($center?"align='center' ":"") . " width='100%' bgcolor='#ccffcc'><font color='#007700'>$msg</font></td>
29 </table></center><br>\n";
33 function db_open($conn)
35 $db = mysql_connect($conn["host"] ,$conn["dbuser"], $conn["dbpassword"]);
38 if (!mysql_select_db($conn["dbname"], $db))
43 echo "<html dir='ltr' >\n";
44 echo "<head><title>$title</title>\n";
45 echo "<meta http-equiv='Content-type' content='text/html'; charset='iso-8859-1'>\n";
46 echo "<link href='$path_to_root/themes/default/default.css' rel='stylesheet' type='text/css' />\n";
49 echo "<body style='background-color:#f9f9f9;' onload='setFocus();'>";
51 echo "<br><br><br><br>";
52 echo "<table align='center' width='50%' cellpadding=3 border=1 bordercolor='#cccccc' style='border-collapse: collapse'>\n";
53 echo "<tr><td align='center' valign='bottom'><img src='$image' alt='FrontAccounting' width='250' height='50' onload='fixPNG(this)' border='0' /></td></tr>\n";
57 echo "<center><span class='headingtext'>$title</span></center>\n";
60 if (isset($_POST["submit"]))
62 if (!isset($_FILES['uploadfile']['tmp_name']) || !is_uploaded_file($_FILES['uploadfile']['tmp_name']))
64 display_error("You must select an SQL script for update");;
68 include_once($path_to_root."/config_db.php");
69 if (!isset($_POST['user']) || !isset($_POST['passwd']) || $_POST['user'] == "")
71 display_error("You must select a user name and an optional password");
75 foreach($db_connections as $id => $conn)
77 $conn['dbuser'] = $_POST['user'];
78 $conn['dbpassword'] = $_POST['passwd'];
79 if (!($db = db_open($conn)))
81 display_error("Wrong user name or password - ".mysql_error());
85 if (!db_import($_FILES['uploadfile']['tmp_name'], $conn))
86 display_error("Bad SQL file or you have already updated the company: "
87 . $id . " " . $conn['name']." - ".mysql_error());
89 display_notification("Database has been updated for company: "
90 . $id . " " . $conn['name']);
96 if (!isset($_POST['passwd']))
97 $_POST['passwd'] = "";
99 echo "<form enctype='multipart/form-data' method='post' action='".$_SERVER['PHP_SELF']."'>\n";
101 echo "<table align='center' width='50%' cellpadding=3 border=1 bordercolor='#cccccc' style='border-collapse: collapse'>\n";
103 text_row_ex("Database User", "user", 20);
104 label_row("Password", "<input name='passwd' type='password' value='".$_POST['passwd']."' />");
105 label_row("Upload Script", "<input name='uploadfile' type='file'>");
106 submit_row("submit", "Update");
111 echo "<center><span>Choose from Database update scripts in SQL folder. No Datase is updated without a script.</span></center>\n";
116 echo "</body></html>\n";