-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjson_proto.php
More file actions
38 lines (35 loc) · 997 Bytes
/
json_proto.php
File metadata and controls
38 lines (35 loc) · 997 Bytes
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
<?php
/**
* Etsii protoja, json-palvelu
*
* @package SLS-Prototracker
* @license http://opensource.org/licenses/GPL-2.0
* @author Mauri "mos" Sahlberg
* @uses globals.php
* @uses database.php
* @uses users.php
* */
require_once("globals.php");
require_once("$basepath/helpers/database.php");
require_once("$basepath/helpers/users.php");
require_once("$basepath/classes/protot.php");
require_once("$basepath/helpers/common.php");
require_once("$basepath/helpers/minrights.php");
$term = isset($_REQUEST["term"]) ? $_REQUEST["term"] : false;
$result = array(_("Ei hakutermiä"));
if($term !== false) {
$protot = new PROTOT($db);
$result = $protot->searchWithNamePart($term, $_SESSION['user']['tunniste']);
if($result===false)
$result = array();
else {
$r = array();
foreach($result as $r1) {
array_push($r, $r1["nimi"]);
$result=$r;
}
}
}
header("Content-type: application/json");
echo json_encode($result);
?>