X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=admin%2Fdb%2Fmaintenance_db.inc;h=4e7d56ccdc443e14f3f8d3d20837c0e2304d352c;hb=76ca9fef9bb510236a6a7740fa0f60eb7db384c9;hp=cf3d60134c7f96172cef6b4f866c18029d4a4b06;hpb=e735f0a06f8a43ed4885ff51a5c0b4332c130b40;p=fa-stable.git diff --git a/admin/db/maintenance_db.inc b/admin/db/maintenance_db.inc index cf3d6013..4e7d56cc 100644 --- a/admin/db/maintenance_db.inc +++ b/admin/db/maintenance_db.inc @@ -257,10 +257,14 @@ function db_import($filename, $connection, $force=true) $allowed_commands = array( "create" => 'table_queries', + "delimiter" => 'table_queries', "alter table" => 'table_queries', "insert" => 'data_queries', "update" => 'data_queries', - "drop table if exists" => 'drop_queries'); + "drop table if exists" => 'drop_queries', + "drop function if exists" => 'drop_queries', + "drop trigger if exists" => 'drop_queries', + ); $ignored_mysql_errors = array( //errors ignored in normal (non forced) mode '1022', // duplicate key '1050', // Table %s already exists @@ -286,6 +290,7 @@ function db_import($filename, $connection, $force=true) // parse input file $query_table = ''; + $delimiter = ';'; foreach($lines as $line_no => $line) { $line = trim($line); @@ -298,6 +303,10 @@ function db_import($filename, $connection, $force=true) { if (strtolower(substr($line, 0, strlen($cmd))) == $cmd) { + if ($cmd == 'delimiter') { + $delimiter = trim(substr($line, 10)); + continue 2; + } $query_table = $table; ${$query_table}[] = array('', $line_no+1); break; @@ -307,9 +316,10 @@ function db_import($filename, $connection, $force=true) if($query_table != '') // inside allowed query { $table = $query_table; - if (substr($line, -1) == ';') // end of query found + + if (substr($line, -strlen($delimiter)) == $delimiter) // end of query found { - $line = substr($line, 0, strlen($line) - 1); // strip ';' + $line = substr($line, 0, strlen($line) - strlen($delimiter)); // strip delimiter $query_table = ''; } ${$table}[count(${$table}) - 1][0] .= $line . "\n"; @@ -367,6 +377,7 @@ function db_import($filename, $connection, $force=true) } db_query("SET foreign_key_checks=1"); + if ($delimiter != ';') db_query("delimiter ;"); // just for any case if (count($sql_errors)) { // display first failure message; the rest are probably derivative @@ -726,7 +737,7 @@ function save_to_file($path, $zip, $fileData) $c_len = strlen($zdata); // dos time - $timearray = getdate($zip); + $timearray = getdate(); $dostime = (($timearray['year'] - 1980) << 25) | ($timearray['mon'] << 21) | ($timearray['mday'] << 16) | ($timearray['hours'] << 11) | ($timearray['minutes'] << 5) | ($timearray['seconds'] >> 1); $dtime = dechex($dostime);