forked from kkaiser1952/NCM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdelete-row.php
75 lines (58 loc) · 1.94 KB
/
delete-row.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?php
//date_default_timezone_set("America/Chicago");
require_once "dbConnectDtls.php";
function getRealIpAddr() {
if (!empty($_SERVER['HTTP_CLIENT_IP'])) //check ip from share internet
{
$ip=$_SERVER['HTTP_CLIENT_IP'];
}
elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) //to check ip is pass from proxy
{
$ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
}
else
{
$ip=$_SERVER['REMOTE_ADDR'];
}
return $ip;
}
$ipaddress = getRealIpAddr();
$recordID = $_POST['id'];
//echo("in delete-row.php id= $id \n");
// The following code gets some info from NetLog about the recordID that is being deleted.
// It uses that info to write the delete to the TimeLog.
// Then it deletes that recordID from NetLog
// Set the deleted datetime for the TimeLog
$dltdTS = now(CONST_USER_TIMEZONE,CONST_SERVER_TIMEZONE,CONST_SERVER_DATEFORMAT);
try {
// This SQL uses the maximum logdate and the recordID to gather its info
$CurrentSQL = "SELECT netID, ID, callsign
FROM NetLog
WHERE recordID = $recordID
";
foreach($db_found->query($CurrentSQL) as $row) {
$netID = $row[netID];
$id = $row[ID];
$cs1 = $row[callsign];
}
// This SQL puts the info from NetLog into the TimeLog table
$TSsql = "INSERT INTO TimeLog (recordID, timestamp, id, netID, callsign, comment, ipaddress)
VALUES ( $recordID, '$dltdTS' ,'$id' ,'$netID' ,'GENCOMM' ,'The call $cs1 with this ID was deleted', '$ipaddress')";
$db_found->exec($TSsql);
}
catch(PDOException $e) {
echo $TSsql . "<br>" . $e->getMessage();
}
try {
// This SQL does the actual delete from NetLog
$sql = "DELETE FROM NetLog
WHERE recordID = $recordID
" ;
$stmt = $db_found->prepare($sql);
$stmt->execute();
echo "Record " . $stmt->rowCount() . " DELETED successfully";
}
catch(PDOException $e) {
echo $sql . "<br>" . $e->getMessage();
}
?>