-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheve_deliver.php
More file actions
29 lines (28 loc) · 1.01 KB
/
eve_deliver.php
File metadata and controls
29 lines (28 loc) · 1.01 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
<?php
$response = array();
require_once('db_constants.php');
if (isset($_GET['q']) && $_GET['q'] == SALT) {
// connecting to db
$bdd = new PDO('mysql:host=' . DB_HOST . ';dbname=' . DB_NAME . ';charset=utf8', DB_USERNAME, DB_PASSWORD);
$clause = ' WHERE (state = \'published\' OR state = \'deleted\') ';
if (isset($_GET['timestamp'])) {
$clause .= " AND date > '" . $_GET['timestamp'] . "'";
}
$result = $bdd->query("SELECT * FROM " . TABLE_EVENTS . $clause);
if ($result->rowCount() > 0) {
while ($row = $result->fetch()) {
$product = array();
$product['id'] = utf8_encode($row['id']);
$product['name'] = utf8_encode($row['name']);
$product['description'] = utf8_encode($row['description']);
$product['start'] = utf8_encode($row['start']);
$product['end'] = utf8_encode($row['end']);
$product['place'] = utf8_encode($row['place']);
$product['picture'] = utf8_encode($row['picture']);
$product['state'] = utf8_encode($row['state']);
array_push($response, $product);
}
}
echo json_encode($response);
}
?>