Fix a copy error.

Fixed the copy issue when the data includes insert_user, insert_update, update_user and update_date.
This commit is contained in:
FusionPBX 2022-09-20 13:56:54 -06:00 committed by GitHub
parent c9b3b7ce3f
commit a355dda5b7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 44 additions and 24 deletions

View File

@ -2077,8 +2077,8 @@ include "root.php";
$result = $prep_statement->fetchAll(PDO::FETCH_ASSOC); $result = $prep_statement->fetchAll(PDO::FETCH_ASSOC);
} }
catch(PDOException $e) { catch(PDOException $e) {
echo 'Caught exception: ', $e->getMessage(), "<br/><br/>\n"; echo 'Caught exception: '. $e->getMessage()."<br /><br />\n";
echo $sql; echo $sql. "<br /><br />\n";
exit; exit;
} }
@ -2113,7 +2113,12 @@ include "root.php";
foreach ($array as $array_key => $array_value) { foreach ($array as $array_key => $array_value) {
if (!is_array($array_value)) { if (!is_array($array_value)) {
$array_key = self::sanitize($array_key); $array_key = self::sanitize($array_key);
$sql .= $array_key.", "; if ($array_key != 'insert_user' &&
$array_key != 'insert_date' &&
$array_key != 'update_user' &&
$array_key != 'update_date') {
$sql .= $array_key.", ";
}
} }
} }
} }
@ -2127,28 +2132,35 @@ include "root.php";
} }
if (is_array($array)) { if (is_array($array)) {
foreach ($array as $array_key => $array_value) { foreach ($array as $array_key => $array_value) {
if (!is_array($array_value)) { if (!is_array($array_value)) {
if (strlen($array_value) == 0) { if ($array_key != 'insert_user' &&
$sql .= "null, "; $array_key != 'insert_date' &&
} $array_key != 'update_user' &&
elseif ($array_value === "now()") { $array_key != 'update_date') {
$sql .= "now(), "; if (strlen($array_value) == 0) {
} $sql .= "null, ";
elseif ($array_value === "user_uuid()") { }
$sql .= ':'.$array_key.", "; elseif ($array_value === "now()") {
$params[$array_key] = $_SESSION['user_uuid']; $sql .= "now(), ";
} }
elseif ($array_value === "remote_address()") { elseif ($array_value === "user_uuid()") {
$sql .= ':'.$array_key.", "; $sql .= ':'.$array_key.", ";
$params[$array_key] = $_SERVER['REMOTE_ADDR']; $params[$array_key] = $_SESSION['user_uuid'];
} }
else { elseif ($array_value === "remote_address()") {
$sql .= ':'.$array_key.", "; $sql .= ':'.$array_key.", ";
$params[$array_key] = trim($array_value); $params[$array_key] = $_SERVER['REMOTE_ADDR'];
}
else {
$sql .= ':'.$array_key.", ";
$params[$array_key] = trim($array_value);
}
} }
} }
} }
} }
$sql .= "now(), "; $sql .= "now(), ";
$sql .= ":insert_user "; $sql .= ":insert_user ";
$sql .= ");"; $sql .= ");";
@ -2539,8 +2551,12 @@ include "root.php";
} }
} }
} }
$sql .= "insert_date, "; if (!isset($row['insert_date'])) {
$sql .= "insert_user "; $sql .= "insert_date, ";
}
if (!isset($row['insert_user'])) {
$sql .= "insert_user ";
}
$sql .= ") "; $sql .= ") ";
$sql .= "VALUES "; $sql .= "VALUES ";
$sql .= "("; $sql .= "(";
@ -2575,8 +2591,12 @@ include "root.php";
} }
} }
} }
$sql .= "now(), "; if (!isset($row['insert_date'])) {
$sql .= ":insert_user "; $sql .= "now(), ";
}
if (!isset($row['insert_user'])) {
$sql .= ":insert_user ";
}
$sql .= ");"; $sql .= ");";
//add insert user parameter //add insert user parameter