-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproc_form.php
87 lines (76 loc) · 2.04 KB
/
proc_form.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<?php
include "page_header_notify.php";
include "include_mysql.php";
include "include_common.php";
$fid=$_POST['fid'];
$fvalid=1;
if( $link=connect() )
{
$isOK=1;
$col="";
$val="";
$sql="select `iid`, `req`, `vld`, `remark` from `form" . $fid . "`;";
if( !$r=query($link, $sql) ) $isOK=0;
while( $row=mysqli_fetch_array($r) )
{
$col=$col . "`C" . $row['iid'] . "`, ";
$frmval=isset($_POST['C'.$row['iid']]) ? $_POST['C'.$row['iid']] : "";
// Validating input values
$req=isset($row['req']) ? (int)$row['req'] : 0;
$remark=isset($row['remark']) ? (int)$row['remark'] : 0;
$vld=isset($row['vld']) ? unescape($row['vld']) : "";
if( $req )
{
if( empty($frmval) )
{
$fvalid=0;
break;
}
}
if( $remark>0 )
{
if( !preg_match("/" . addcslashes($vld, "/") . "/", $frmval) )
{
$fvalid=0;
break;
}
}
else if( $remark==-1 )
{
$tmpvld=explode("||", $vld);
if( !is_numeric($frmval) || !( ((int)$frmval) >= ((int)$tmpvld[0]) && ((int)$frmval) <= ((int)$tmpvld[1]) ) )
{
$fvalid=0;
break;
}
}
$frmval=escape($link, $frmval);
if( gettype($frmval)!="array" )
$val = $val . "'" . $frmval . "', ";
else
$val = $val . "'" . join("||", $frmval) . "', ";
}
if( $fvalid )
{
$col=substr($col, 0, strlen($col)-2);
$val=substr($val, 0, strlen($val)-2);
$datetime=new DateTime(null, new DateTimeZone('Asia/Taipei'));
$sql="insert into `result" . $fid . "` (`rtime`, `rIP`, " . $col . ") values ('" . $datetime->format("Y-m-d H:i:s") . "', '" . getIP() . "', " . $val . ");";
// echo $sql . "<br>";
if( !query($link, $sql) ) $isOK=0;
if( $isOK )
{
echo "<h3>註冊完成! 2秒後" . $rdrPbl . "</h3>";
redirect("list_public.php", 2000);
}
else
warn_back($opFailed, 2000);
}
else
{
echo "<div class=\"err\">欄位不符合規定!</div>";
warn_back("請檢查是否有填寫所有必填欄位,以及正確的格式。", 3000);
}
}
include "page_footer.php";
?>