]> git.bts.cx Git - cx.git/blob - cx/lib/form.php
Don't break when there's no hero image
[cx.git] / cx / lib / form.php
1 <?php
2
3 function cx_form_input_sanitized($name) {
4 if (array_key_exists($name, $_POST)) {
5 $insecure_input = $_POST[$name];
6 $tagless_input = strip_tags($insecure_input);
7 return $tagless_input;
8 } else {
9 return null;
10 }
11 }
12
13 function cx_form_input_sanitized_date_time($name) {
14 $sanitised_string = cx_form_input_sanitized($name);
15
16 if ($sanitised_string != null) {
17 $date = date_parse_from_format('Y-m-d H:i:s', $sanitised_string);
18 if ($date['error_count'] > 0) $date = date_parse_from_format('Y-m-d', $sanitised_string);
19 if ($date['error_count'] == 0) {
20 $timestamp = mktime($date['hour'], $date['minute'], $date['second'], $date['month'], $date['day'], $date['year']);
21 if ($timestamp != false) {
22 return $timestamp;
23 }
24 }
25 }
26
27 return null;
28 }