-
Notifications
You must be signed in to change notification settings - Fork 1
/
json.php
49 lines (47 loc) · 1.8 KB
/
json.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
require_once realpath($_SERVER['DOCUMENT_ROOT']) . '/includes/global.php';
require_once realpath($_SERVER['DOCUMENT_ROOT']) . '/includes/database-class.php';
require_once realpath($_SERVER['DOCUMENT_ROOT']) . '/includes/hashids.php';
if ($_GET['np'] != "") {
$ntpdhash = $_GET['np'];
$npHashMethod = new Hashids(HASH_NP_SALT, HASH_NP_CHAR, HASH_NP_ALPHABET);
$ntpdid = implode($npHashMethod->decode($ntpdhash));
$database = new Database();
$database->query('SELECT * FROM notepads WHERE id = :ntpdid LIMIT 1');
$database->bind(':ntpdid', $ntpdid);
$checkResult = $database->single();
if ($database->rowCount() == 1) {
$database->query('SELECT * FROM notes WHERE npid = :ntpdid ORDER BY id DESC');
$database->bind(':ntpdid', $ntpdid);
$npDataResults = $database->resultset();
$npDataArray = array();
foreach ($npDataResults as $npDataResult) {
$npDataArray[] = array(
'id' => $npDataResult["id"],
'org' => $npDataResult["org"],
'checked' => $npDataResult["checked"],
'color' => $npDataResult["color"],
'text' => $npDataResult["text"]
);
}
header("Content-Type: application/json");
header("Expires: Sun, 01 Jan 2014 00:00:00 GMT");
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
echo json_encode($npDataArray, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_NUMERIC_CHECK | JSON_PRETTY_PRINT);
exit;
} else {
goto error;
}
} else {
goto error;
}
error:
$thisLang = ($_GET['lang'] != "") ? $_GET['lang'] : DEFAULT_LANG_CODE;
loadLocale($thisLang);
define("PAGETITLE", $locale["error"]["title"] . " - " . $locale["core"]["app_name"]);
define("PAGEDESC", $locale["error"]["meta_desc"]);
include realpath($_SERVER['DOCUMENT_ROOT']) . '/404.php';
exit;
?>