Merge branch '145-plain-text-mail-cannot-be-send-by-email_problems_mr' into 'develop'

fixed error in function check mr

See merge request !921
This commit is contained in:
vgilc 2017-10-16 10:26:31 +02:00
commit 4c3e200946
1 changed files with 66 additions and 62 deletions

View File

@ -1319,70 +1319,74 @@ function mysql_db_process_file ($path, $handle_error = true) {
// --------------------------------------------------------------- // ---------------------------------------------------------------
function db_run_sql_file ($location) { function db_run_sql_file ($location) {
global $config; global $config;
// Load file // Load file
$commands = file_get_contents($location); $commands = file_get_contents($location);
// Delete comments // Delete comments
$lines = explode("\n", $commands); $lines = explode("\n", $commands);
$commands = ''; $commands = '';
foreach ($lines as $line) { foreach ($lines as $line) {
$line = trim($line); $line = trim($line);
if ($line && !preg_match('/^--/', $line) && !preg_match('/^\/\*/', $line)) { if ($line && !preg_match('/^--/', $line) && !preg_match('/^\/\*/', $line)) {
$commands .= $line;
}
}
// Convert to array $line = preg_replace('/;$/',"__;__", $line);
$commands = explode(";", $commands); $commands .= $line;
}
}
if ($config['mysqli']) { // Convert to array
$mysqli = new mysqli($config["dbhost"], $config["dbuser"], $config["dbpass"], $config["dbname"], $config["dbport"]); $commands = explode("__;__", $commands);
// Run commands if ($config['mysqli']) {
$mysqli->query($config['dbconnection'], 'SET AUTOCOMMIT = 0'); $mysqli = new mysqli($config["dbhost"], $config["dbuser"], $config["dbpass"], $config["dbname"], $config["dbport"]);
$mysqli->query($config['dbconnection'], 'START TRANSACTION');
}
else {
// Run commands
mysql_db_process_sql_begin(); // Begin transaction
}
foreach ($commands as $command) { // Run commands
if (trim($command)) { $mysqli->query($config['dbconnection'], 'SET AUTOCOMMIT = 0');
if ($config['mysqli']) { $mysqli->query($config['dbconnection'], 'START TRANSACTION');
$result = $mysqli->query($command); }
} else {
else { // Run commands
$result = mysql_query($command); mysql_db_process_sql_begin(); // Begin transaction
} }
if (!$result) { foreach ($commands as $command) {
break; // Error if (trim($command)) {
} $command .= ";";
}
}
if ($result) { if ($config['mysqli']) {
if ($config['mysqli']) { $result = $mysqli->query($command);
$mysqli->query($config['dbconnection'], 'COMMIT'); }
$mysqli->query($config['dbconnection'], 'SET AUTOCOMMIT = 1'); else {
} $result = mysql_query($command);
else { }
mysql_db_process_sql_commit(); // Save results
} if (!$result) {
return true; break; // Error
} }
else { }
if ($config['mysqli']) { }
$mysqli->query($config['dbconnection'], 'ROLLBACK ');
$mysqli->query($config['dbconnection'], 'SET AUTOCOMMIT = 1'); if ($result) {
} if ($config['mysqli']) {
else { $mysqli->query($config['dbconnection'], 'COMMIT');
mysql_db_process_sql_rollback(); // Undo results $mysqli->query($config['dbconnection'], 'SET AUTOCOMMIT = 1');
} }
return false; else {
} mysql_db_process_sql_commit(); // Save results
}
return true;
}
else {
if ($config['mysqli']) {
$mysqli->query($config['dbconnection'], 'ROLLBACK ');
$mysqli->query($config['dbconnection'], 'SET AUTOCOMMIT = 1');
}
else {
mysql_db_process_sql_rollback(); // Undo results
}
return false;
}
} }
?> ?>