-
Notifications
You must be signed in to change notification settings - Fork 1
/
_.php
33 lines (30 loc) · 946 Bytes
/
_.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
<?php
// echo "✔ $key = " . clean_input($value) . "<br>";
// echo "❌ $key is missing.<br>";
/**
* Cleans an input string from white spaces,
* slashes, and escapes HTML tags.
* @param $data <b>string</b> input string to clean
* @return <b>string</b> clean input string
*/
function clean_input($data) {
if (!is_array($data)) {
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
}
return $data;
}
function name_is_valid($name) {
return preg_match("/^[a-zA-Z ]*$/", $name);
}
function email_is_valid($email) {
return filter_var($email, FILTER_VALIDATE_EMAIL);
}
function url_is_valid($url) {
return preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i", $url);
}
function write_message($message, $text_color) {
echo "<div style='color:$text_color; font-family:Consolas; font-size:2.3em;'>• $message</div>";
}
?>