-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlifx.php
70 lines (56 loc) · 1.63 KB
/
lifx.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
<?php
include('include/dbconnect.php');
// Escape user inputs for security
$actionName = $_GET['link'];
$id = $_GET['id'];
$action = $_GET['action'];
$setting2 = $bdd->query('SELECT * FROM ifttkey ORDER BY id DESC');
while($b = $setting2->fetch()) {
$key = $b['iftttkey'];
}
$linkFinal = "https://maker.ifttt.com/trigger/". $actionName . "/with/key/" . $key;
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $linkFinal);
curl_setopt($curl, CURLOPT_COOKIESESSION, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
echo $linkFinal;
$return = curl_exec($curl);
curl_close($curl);
switch ($action){
case 1:
$sql = "UPDATE component SET action1state = 1 WHERE id = $id";
if(mysqli_query($db, $sql)){
echo "Records added successfully.";
} else{
echo "ERROR: Could not able to execute $sql. " . mysqli_error($db);
}
break;
case 2:
$sql = "UPDATE component SET action2state = 1 WHERE id = $id";
if(mysqli_query($db, $sql)){
echo "Records added successfully.";
} else{
echo "ERROR: Could not able to execute $sql. " . mysqli_error($db);
}
break;
case 3:
$sql = "UPDATE component SET action3state = 1 WHERE id = $id";
if(mysqli_query($db, $sql)){
echo "Records added successfully.";
} else{
echo "ERROR: Could not able to execute $sql. " . mysqli_error($db);
}
break;
case 4:
$sql = "UPDATE component SET action4state = 1 WHERE id = $id";
if(mysqli_query($db, $sql)){
echo "Records added successfully.";
} else{
echo "ERROR: Could not able to execute $sql. " . mysqli_error($db);
}
break;
}
// Close connection
mysqli_close($db);
include('redirections/appRedirect.php');
?>