-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.php
More file actions
52 lines (35 loc) · 1.08 KB
/
server.php
File metadata and controls
52 lines (35 loc) · 1.08 KB
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
<?php
header('Cache-Control: no-cache');
include_once("php/functions.php");
if(isset($_POST["action"])) // Hvis der laves en permission eller et salg
{
connect();
$type = getPost("type");
$action = getPost("action");
$owner = getPost("owner");
$dato = currentDate();
$sql = "UPDATE `salg` SET `$type`=`$type`+($action) WHERE `dato`='$dato' AND `owner`='$owner'";
$res = mysql_query($sql) or die(mysql_error());
if(mysql_affected_rows()==0) // Hvis der ikke er noget der er opdateret, skal der indsættes en ny række
{
$sql = "INSERT INTO `salg`(`dato`,`owner`,`$type`) VALUES('$dato','$owner',1)";
mysql_query($sql) or die(mysql_error());
}
}
elseif(isset($_POST["owner"])) // Hvis der skal hentes info om nuværende salg/permission
{
connect();
$user = getPost("owner");
$dato = currentDate();
$sql = "SELECT * FROM `salg` WHERE `owner` = '$user' and `dato` = '$dato'";
$res = mysql_query($sql);
echo json_encode(mysql_fetch_assoc($res));
}
else
{
$data = array(
"error"=>"Der mangler en eller flere parametere."
);
echo json_encode($data);
}
?>