-
Notifications
You must be signed in to change notification settings - Fork 1
/
functions.php
49 lines (38 loc) · 1.4 KB
/
functions.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
<?php
function deleteInactivePlanes(){
require("SQLconnect.php");
$timeoutTime=10800;
$timeToCeck=time() - $timeoutTime;
$res=$conn->query('SELECT * FROM planes WHERE last_time_edited < '.$timeToCeck);
while($row = $res->fetch_object()){
$stmt = $conn->prepare("DELETE FROM planes WHERE callsign = ?");
$stmt->bind_param("s",$row->callsign);
$stmt->execute();
}
}
function refreshInactivityTimer($callsign){
require("SQLconnect.php");
$stmt = $conn->prepare("UPDATE planes SET last_time_edited = UNIX_TIMESTAMP() WHERE callsign = ?");
$stmt->bind_param("s",$callsign);
$stmt->execute();
}
function generateOptionList($tbname,$tbcol,$conditionColumn = false ,$condition = false){
require("SQLconnect.php");
$SQLstring = 'SELECT '.$tbcol.' FROM '.$tbname;
if ($conditionColumn and $condition)
$SQLstring.=' WHERE '.$conditionColumn.' <> ?';
$stmt = $conn->prepare($SQLstring);
if ($conditionColumn and $condition)
$stmt->bind_param("s",$condition);
$stmt->execute();
$res = $stmt->get_result();
$airportList = Array();
while($airport = $res->fetch_array()){
array_push($airportList, $airport[0]);
}
foreach($airportList as $airport){
echo ('<option value="'.$airport.'">'.$airport.'</option>');
}
$conn->close();
}
?>