-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.php
executable file
·63 lines (51 loc) · 1.12 KB
/
functions.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
<?php
function clean($string) {
return strip_tags($string);
}
function get ($key) {
if (isset($_GET[$key])) {
return clean($_GET[$key]);
}
else {
return '';
}
}
function post ($key) {
if (isset($_POST[$key])) {
return clean($_POST[$key]);
}
else {
return '';
}
}
function session ($key) {
if (isset($_SESSION[$key])) {
return clean($_SESSION[$key]);
}
else {
return '';
}
}
function get_sql($sqlName) {
return file_get_contents(ROOT . "sql/$sqlName.sql");
}
function humanTiming ($time)
{
$time = strtotime($time);
$time = time() - $time; // to get the time since that moment
$time = ($time<1)? 1 : $time;
$tokens = array (
31536000 => 'year',
2592000 => 'month',
604800 => 'week',
86400 => 'day',
3600 => 'hour',
60 => 'minute',
1 => 'second'
);
foreach ($tokens as $unit => $text) {
if ($time < $unit) continue;
$numberOfUnits = floor($time / $unit);
return $numberOfUnits.' '.$text.(($numberOfUnits>1)?'s':'');
}
}