forked from Luis-J-Ianez/cubecomps.com
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathseteventfld.php
58 lines (54 loc) · 1.31 KB
/
seteventfld.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
54
55
56
57
58
<?
require_once "lib_ref_admin.php";
require_once "lib_get.php";
function timelimitNum00($t)
{
if (!$t) return 0;
$t = substr("000:00.00",0,9-strlen($t)).$t;
// $hh = 0; // !
$hh = (int)substr($t,7,2);
$sec = (int)substr($t,4,2);
$min = (int)substr($t,0,3);
$hh = (($min*60)+$sec)*100+$hh;
return $hh;
}
function formatTimelimit00($t)
{
if (preg_match("/^[0-9]{1,2}\072[0-5][0-9]$/",$t)) $t .= ".00";
while(strlen($t)>4 && ((($ch=substr($t,0,1))=="0") || $ch==":")) $t = substr($t,1);
$l = strlen($t);
if ($l>4) $t = substr($t,0,$l-2)."00";
return $t;
}
$_GETid = _GET_num("id");
$_GETfld = _GET_fld("fld");
if ($_GETid && $_GETfld && isset($_GET["value"]))
{
require_once "db.php";
//
if ($_GETfld=="timelimit")
{
$value = _GET_key("value"); // still secure because of the following lines
if ($value && !preg_match("/^([0-9]{1,2}\072[0-5][0-9]\056[0-9]{2}|[0-5]?[0-9]\056[0-9]{2}|[0-9]{1,2}\072[0-5][0-9])$/",$value))
$value = "";
if ($value)
{
$value = formatTimelimit00($value);
if (!timelimitNum00($value)) $value = "";
}
}
else
$value = _GET_num("value");
//
strict_query("UPDATE $eventstable SET $_GETfld=? WHERE id=?", array($value,$_GETid));
//
if ($_GETfld=="timelimit")
if ($value)
$value = "cutoff $value";
else
$value = "no cutoff";
echo $value;
//
sql_close();
}
?>