-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjson_pelaajat.php
More file actions
66 lines (59 loc) · 1.81 KB
/
json_pelaajat.php
File metadata and controls
66 lines (59 loc) · 1.81 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
/**
* Javascript-palvelu pelaajien listaamiseen
*
* @package SLS-Prototracker
* @license http://opensource.org/licenses/GPL-2.0
* @author Mauri "mos" Sahlberg
* @uses globals.php
* @uses database.php
* @uses games.php
* */
require_once("globals.php");
require_once("$basepath/helpers/common.php");
require_once("$basepath/helpers/database.php");
require_once("$basepath/classes/pelaaja.php");
require_once("$basepath/helpers/minrights.php");
$db = new SLSDB();
$draw = isset($_REQUEST["draw"]) ? $_REQUEST["draw"] : false;
$start = isset($_REQUEST["start"]) ? $_REQUEST["start"] : 0;
$length = isset($_REQUEST["length"]) ? $_REQUEST["length"] : 10;
$search = isset($_REQUEST["search"]) ? $_REQUEST["search"] : false;
$order = isset($_REQUEST["order"]) ? $_REQUEST["order"] : false;
$columns = isset($_REQUEST["columns"]) ? $_REQUEST["columns"] : false;
if(!isset($_SESSION["s_sessioid"])) {
$jason = array("draw"=>$draw, "recordsTotal"=>0, "recordsFiltered"=>0, "data"=>"");
header("Content-type: application/json");
echo json_encode($jason);
die();
}
$sessioid=$_SESSION["s_sessioid"];
$a = array("numero", "nimi");
$p = new PELAAJA($db);
$od=false;
if($order) {
$od="";
$first=true;
foreach($order as $o) {
if(isset($a[$o["column"]])) {
$od.=$first ? "" : ", ";
$od.=$a[$o["column"]]." ".$o["dir"];
$first=false;
}
}
}
$pelaajat=$p->tableFetch($start, $length, $od, $search, $sessioid);
$jason = array("draw"=>$draw, "recordsTotal"=>$pelaajat["lkm"], "recordsFiltered"=>$pelaajat["filtered"]);
$data = array();
$i=0;
foreach($pelaajat["pelaajat"] as $rivi) {
$j=0;
foreach($a as $k=>$v) {
$data[$i][$j++]=$rivi[$v];
}
$i++;
}
$jason["data"]=$data;
header("Content-type: application/json");
echo json_encode($jason);
?>