This repository has been archived by the owner on Oct 29, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
file_edit2.php
executable file
·77 lines (58 loc) · 2.07 KB
/
file_edit2.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
76
77
<?php
session_start();
require("include/functions.php");
$config_file = 'config.php';
if (file_exists($config_file)) {
require("config.php");
} else {
header("Location: error.php?e=config");
die();
}
require("include/apply_config.php");
$force_admin = TRUE;
require("include/check_admin.php");
$SoundID=filter_var($_POST["SoundID"], FILTER_SANITIZE_NUMBER_INT);
if ($_POST["OtherSoundID"]!="")
$OtherSoundID=filter_var($_POST["OtherSoundID"], FILTER_SANITIZE_NUMBER_INT);
if ($_POST["Date"]!="")
$Date=$_POST["Date"];
if ($_POST["Time"]!="")
$Time=$_POST["Time"];
$OldSiteID=query_one("SELECT SiteID FROM Sounds WHERE SoundID='$SoundID'", $connection);
$SiteID=filter_var($_POST["SiteID"], FILTER_SANITIZE_NUMBER_INT);
$SensorID=filter_var($_POST["SensorID"], FILTER_SANITIZE_NUMBER_INT);
$SoundName=filter_var($_POST["SoundName"], FILTER_SANITIZE_STRING);
$Notes=filter_var($_POST["Notes"], FILTER_SANITIZE_STRING);
$where_to=filter_var($_POST["where_to"], FILTER_SANITIZE_URL);
$date=explode("/", $Date);
$date_f=$date[2] . "-" . $date[0] . "-" . $date[1];
$query = ("UPDATE Sounds SET SoundName='$SoundName',
OtherSoundID='$OtherSoundID',
Date='$date_f',
Time='$Time',
SiteID='$SiteID',
SensorID='$SensorID',
Notes='$Notes'
WHERE SoundID='$SoundID' LIMIT 1");
$result = mysqli_query($connection, $query)
or die (mysqli_error($connection));
$query = ("UPDATE Sounds SET OtherSoundID = NULL
WHERE OtherSoundID ='0'");
$result = mysqli_query($connection, $query)
or die (mysqli_error($connection));
$query = ("UPDATE Sounds SET SensorID = NULL
WHERE SensorID ='0'");
$result = mysqli_query($connection, $query)
or die (mysqli_error($connection));
$query = ("UPDATE Sounds SET Date = NULL
WHERE Date ='0000-00-00'");
$result = mysqli_query($connection, $query)
or die (mysqli_error($connection));
$query = ("UPDATE Sounds SET Time = NULL
WHERE Time ='00:00'");
$result = mysqli_query($connection, $query)
or die (mysqli_error($connection));
// Relocate back to where you came from
header("Location: $where_to&d=1");
die();
?>