\n";
echo " ";
if (isset($_POST["submit"]))
{
$perms_ok = is_writable($path_to_root.'/company') && is_writable($path_to_root.'/company/0');
$checkdirs = $comp_subdirs;
foreach ($checkdirs as $dir) {
$perms_ok &= is_writable($path_to_root.'/company/0/'.$dir);
}
if (!$perms_ok) {
display_error("'System 'company' directory or any of its subdirectories
is not writable. Change webserver access permissions to those
directories.");
} elseif (!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']);
}
$cdir = "$path_to_root/company/$id";
if (!file_exists($cdir))
{
create_comp_dirs($cdir, $comp_subdirs);
}
}
}
}
}
if (!isset($_POST['passwd']))
$_POST['passwd'] = "";
if (!isset($_POST['user']))
$_POST['user'] = "";
echo "\n";
echo "\n";
?>