]> git.bts.cx Git - cx.git/blob - cx/lib/form.php
style update
[cx.git] / cx / lib / form.php
1 <?php
2
3 function cx_form_input_sanitized($name) {
4 $input = cx_form_input_sanitized_allowing_html($name);
5
6 if ($input != null) {
7 $input = strip_tags($input);
8 }
9
10 return $input;
11 }
12
13 function cx_form_input_sanitized_allowing_html($name) {
14 if (array_key_exists($name, $_POST)) {
15 $insecure_input = $_POST[$name];
16 return $insecure_input;
17 } else {
18 return null;
19 }
20 }
21
22 function cx_form_input_sanitized_date_time($name) {
23 $sanitised_string = cx_form_input_sanitized($name);
24
25 if ($sanitised_string != null) {
26 $date = date_parse_from_format('Y-m-d H:i:s', $sanitised_string);
27 if ($date['error_count'] > 0) $date = date_parse_from_format('Y-m-d', $sanitised_string);
28 if ($date['error_count'] == 0) {
29 $timestamp = mktime($date['hour'], $date['minute'], $date['second'], $date['month'], $date['day'], $date['year']);
30 if ($timestamp != false) {
31 return $timestamp;
32 }
33 }
34 }
35
36 return null;
37 }