-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfunctions.php
85 lines (84 loc) · 2.06 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<?php
function get_client_ip() {
$ipaddress = '';
if (getenv('HTTP_CLIENT_IP'))
$ipaddress = getenv('HTTP_CLIENT_IP');
else if(getenv('HTTP_X_FORWARDED_FOR'))
$ipaddress = getenv('HTTP_X_FORWARDED_FOR');
else if(getenv('HTTP_X_FORWARDED'))
$ipaddress = getenv('HTTP_X_FORWARDED');
else if(getenv('HTTP_FORWARDED_FOR'))
$ipaddress = getenv('HTTP_FORWARDED_FOR');
else if(getenv('HTTP_FORWARDED'))
$ipaddress = getenv('HTTP_FORWARDED');
else if(getenv('REMOTE_ADDR'))
$ipaddress = getenv('REMOTE_ADDR');
else
$ipaddress = 'UNKNOWN';
return $ipaddress;
}
function makeTime($timestamp) {
$ts = $timestamp;
$cts = time();
$str = "";
$result = $cts-$ts;
if ($result < 31556952) {
if ($result < 2629746) {
if ($result < 86400) {
if ($result < 3600) {
if ($result < 60) {
$n = $result/1;
if ($n == 1){
$str = " second";
}else{
$str = " seconds";
}
$final = $n.$str;
}else{
$n = floor($result/60);
if ($n == 1){
$str = " minute";
}else{
$str = " minutes";
}
$final = $n.$str;
}
}else{
$n = floor($result/3600);
if ($n == 1){
$str = " hour";
}else{
$str = " hours";
}
$final = $n.$str;
}
}else{
$n = floor($result/86400);
if ($n == 1){
$str = " day";
}else{
$str = " days";
}
$final = $n.$str;
}
}else{
$n = floor($result/2629746);
if ($n == 1){
$str = " month";
}else{
$str = " months";
}
$final = $n.$str;
}
}else{
$n = floor($result/31556952);
if ($n == 1){
$str = " year";
}else{
$str = " years";
}
$final = $n.$str;
}
return $final;
}
?>