-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathadd_ladder.php
54 lines (42 loc) · 1.29 KB
/
add_ladder.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
<?php
header('Cache-Control: no-cache, must-revalidate');
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Content-type: application/json; charset=utf-8');
require_once 'authorisation.php';
require_once 'dbextra.php';
function add_ladder($link, $usePk)
{
$lname = reqsval('laddername');
$nation = reqsval('nation');
$start = reqsval('dateto');
$end = reqsval('datefrom');
$method = reqsval('method');
$param = reqival('param');
$cclass = reqival('compclass');
if ($lname == '')
{
$res['result'] = 'error';
$res['reason'] = 'Can\'t create a ladder with no name';
print json_encode($res);
return;
}
$query = "insert into tblLadder (ladName, ladNationCode, ladStart, ladEnd, ladHow, ladParam, ladClass) value ('$lname','$nation', '$start', '$end', '$method', $param, '$cclass')";
$result = mysql_query($query) or die('Ladder insert failed: ' . mysql_error());
$ladPk = mysql_insert_id();
return $ladPk;
}
$usePk = auth('system');
$link = db_connect();
$res = [];
$comPk = reqival('comPk');
if (!is_admin('admin',$usePk,$comPk))
{
$res['result'] = 'unauthorised';
print json_encode($res);
return;
}
$ladPk = add_ladder($link, $usePk);
$res['result'] = 'ok';
$res['comPk'] = $ladPk;
print json_encode($res);
?>