-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.php
55 lines (51 loc) · 960 Bytes
/
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
<?php
/* Useful functions.
* This file contains some useful functions for demo.
* @author : MarkisDev
* @copyright : https://markis.dev
*/
# A function to redirect user.
function redirect($url)
{
if (!headers_sent())
{
header('Location: '.$url);
exit;
}
else
{
echo '<script type="text/javascript">';
echo 'window.location.href="'.$url.'";';
echo '</script>';
echo '<noscript>';
echo '<meta http-equiv="refresh" content="0;url='.$url.'" />';
echo '</noscript>';
exit;
}
}
# A function which returns users IP
function client_ip()
{
if (!empty($_SERVER['HTTP_X_FORWARDED_FOR']))
{
return $_SERVER['HTTP_X_FORWARDED_FOR'];
}
else
{
return $_SERVER['REMOTE_ADDR'];
}
}
# Check user's avatar type
function is_animated($avatar)
{
$ext = substr($avatar, 0, 2);
if ($ext == "a_")
{
return ".gif";
}
else
{
return ".png";
}
}
?>