$msg = "<?php\n\n";
$msg .= "/*Connection Information for the database\n";
$msg .= "\$def_coy - the default company that is pre-selected on login\n\n";
$msg .= "'host' - the computer ip address or name where the database is. The default is 'localhost' assuming that the web server is also the sql server.\n\n";
$msg = "<?php\n\n";
$msg .= "/*Connection Information for the database\n";
$msg .= "\$def_coy - the default company that is pre-selected on login\n\n";
$msg .= "'host' - the computer ip address or name where the database is. The default is 'localhost' assuming that the web server is also the sql server.\n\n";
$msg .= "'dbuser' - the user name under which the company database should be accessed.\n";
$msg .= " NB it is not secure to use root as the dbuser with no password - a user with appropriate privileges must be set up.\n\n";
$msg .= "'dbpassword' - the password required for the dbuser to authorise the above database user.\n\n";
$msg .= "'dbname' - the name of the database as defined in the RDMS being used. Typically RDMS allow many databases to be maintained under the same server.\n";
$msg .= "'dbuser' - the user name under which the company database should be accessed.\n";
$msg .= " NB it is not secure to use root as the dbuser with no password - a user with appropriate privileges must be set up.\n\n";
$msg .= "'dbpassword' - the password required for the dbuser to authorise the above database user.\n\n";
$msg .= "'dbname' - the name of the database as defined in the RDMS being used. Typically RDMS allow many databases to be maintained under the same server.\n";
$msg .= "'tbpref' - prefix on table names, or '' if not used. Always use non-empty prefixes if multiply company use the same database.\n";
$msg .= "*/\n\n\n";
$msg .= "\$def_coy = " . $def_coy . ";\n\n";
$msg .= "\$tb_pref_counter = " . $tb_pref_counter . ";\n\n";
$msg .= "\$db_connections = " .var_export($db_connections, true);
$msg .= "'tbpref' - prefix on table names, or '' if not used. Always use non-empty prefixes if multiply company use the same database.\n";
$msg .= "*/\n\n\n";
$msg .= "\$def_coy = " . $def_coy . ";\n\n";
$msg .= "\$tb_pref_counter = " . $tb_pref_counter . ";\n\n";
$msg .= "\$db_connections = " .var_export($db_connections, true);
global $path_to_root, $installed_languages, $dflt_lang;
$installed_languages = array_natsort($installed_languages, 'code', 'code');
global $path_to_root, $installed_languages, $dflt_lang;
$installed_languages = array_natsort($installed_languages, 'code', 'code');
*/
function db_import($filename, $connection, $force=true, $init=true, $protect=false, $return_errors=false)
{
*/
function db_import($filename, $connection, $force=true, $init=true, $protect=false, $return_errors=false)
{
$allowed_commands = array(
"create" => 'table_queries',
$allowed_commands = array(
"create" => 'table_queries',
"drop table if exists" => 'drop_queries',
"drop function if exists" => 'drop_queries',
"drop trigger if exists" => 'drop_queries',
"drop table if exists" => 'drop_queries',
"drop function if exists" => 'drop_queries',
"drop trigger if exists" => 'drop_queries',
if (strpos($filename, ".gz") || strpos($filename, ".GZ"))
{ $lines = db_ungzip("lines", $filename);
$check_line_len = true;
if (strpos($filename, ".gz") || strpos($filename, ".GZ"))
{ $lines = db_ungzip("lines", $filename);
$check_line_len = true;
db_query("SET foreign_key_checks=1");
if ($delimiter != ';') db_query("delimiter ;"); // just for any case
db_query("SET foreign_key_checks=1");
if ($delimiter != ';') db_query("delimiter ;"); // just for any case
-function db_backup($conn, $ext='no', $comm='', $path=null)
+function db_backup($conn, $ext='no', $comm='', $path='')
{
if ($conn['tbpref'] != "")
$filename = $conn['dbname'] . "_" . $conn['tbpref'] . date("Ymd_Hi") . ".sql";
else
$filename = $conn['dbname'] . "_" . date("Ymd_Hi") . ".sql";
{
if ($conn['tbpref'] != "")
$filename = $conn['dbname'] . "_" . $conn['tbpref'] . date("Ymd_Hi") . ".sql";
else
$filename = $conn['dbname'] . "_" . date("Ymd_Hi") . ".sql";
return db_export($conn, $path . clean_file_name($filename), $ext, $comm);
}
return db_export($conn, $path . clean_file_name($filename), $ext, $comm);
}
// Generates a dump of $db database
//
function db_export($conn, $filename, $zip='no', $comment='')
{
// Generates a dump of $db database
//
function db_export($conn, $filename, $zip='no', $comment='')
{
$error = false;
// set max string size before writing to file
$max_size = 1048576 * 2; // 2 MB
// changes max size if value can be retrieved
if (ini_get("memory_limit"))
$error = false;
// set max string size before writing to file
$max_size = 1048576 * 2; // 2 MB
// changes max size if value can be retrieved
if (ini_get("memory_limit"))
//create comment
$out="# MySQL dump of database '".$conn["dbname"]."' on host '".$conn["host"]."'\n";
$out.="# Backup Date and Time: ".date("Y-m-d H:i")."\n";
//create comment
$out="# MySQL dump of database '".$conn["dbname"]."' on host '".$conn["host"]."'\n";
$out.="# Backup Date and Time: ".date("Y-m-d H:i")."\n";
$out.="# Company: ". @html_entity_decode($company, ENT_QUOTES, $_SESSION['language']->encoding)."\n";
$out.="# User: ".$_SESSION["wa_current_user"]->name."\n\n";
$out.="# Compatibility: ".get_company_pref('version_id')."\n\n";
$out.="# Company: ". @html_entity_decode($company, ENT_QUOTES, $_SESSION['language']->encoding)."\n";
$out.="# User: ".$_SESSION["wa_current_user"]->name."\n\n";
$out.="# Compatibility: ".get_company_pref('version_id')."\n\n";
// returns backup file name if name has changed (zip), else TRUE. If saving failed, return value is FALSE
function save_to_file($path, $zip, $fileData)
{
// returns backup file name if name has changed (zip), else TRUE. If saving failed, return value is FALSE
function save_to_file($path, $zip, $fileData)
{