-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathusefull_functions.php
More file actions
107 lines (95 loc) · 2.59 KB
/
usefull_functions.php
File metadata and controls
107 lines (95 loc) · 2.59 KB
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<?php
require_once(__DIR__ . "/global.php");
function fok()
{
HtmlFooter();
die();
}
function HtmlFooter()
{
?>
</body>
</html>
<?php
}
function HtmlHeader($title)
{
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title><?php echo "TestVPN - " . $title; ?></title>
<link rel="stylesheet" href="style.css">
<script src="main.js"></script>
</head>
<body>
<a>
<?php
/*
// The problem is that the website is on the vpn server so it doesnt work well
// It will always show the real not the TestVPN ip and it might confuse customers that their vpn suck (but it doesnt :p)
// Get City
$ip = $_SERVER['REMOTE_ADDR'];
$details = json_decode(file_get_contents("http://ipinfo.io/{$ip}/json"));
echo "Your ip: $ip city: $details->city";
*/
?>
</a>
<?php
}
function GetAccountAge($username) //Totally working but unused yet
{
$db = new PDO(DATABASE_PATH);
$db->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING );
$stmt = $db->prepare('SELECT * FROM Accounts WHERE Username = ?');
$stmt->execute(array($username));
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
if ($rows)
{
$register_date = new DateTime($rows[0]['RegisterDate']);
$current_date = date_create(date("Y-m-d"));
$interval = $current_date->diff($register_date);
return $interval->days;
//working but only interesting for debugging
/*
$register_date_str = $register_date->format('Y-m-d');
$current_date_str = $current_date->format('Y-m-d');
echo "<a>Total days: $interval->days</a></br>";
echo "<a>Your registerd " . $interval->y . " years, " . $interval->m." months, ".$interval->d." days ago </br></a>";
echo "<a>Register date=$register_date_str </br></a>";
echo "<a>Today date=$current_date_str </br></a>";
*/
}
return -1;
}
function AntiXSS($str)
{
$str = filter_var($str, FILTER_SANITIZE_STRING);
$str = htmlspecialchars($str);
return $str;
}
function IsLoggedIn()
{
if (empty($_SESSION['IsLogged']) || $_SESSION['IsLogged'] != "online")
return false;
return true;
}
function CheckAccountState($username)
{
$db = new PDO(DATABASE_PATH);
$db->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING );
$stmt = $db->prepare('SELECT * FROM Accounts WHERE Username = ?');
$stmt->execute(array($username));
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
if ($rows)
{
//could check for frozen or banned account here
}
else
{
echo "<a>Invalid account</a></br>";
echo "<form class=\"form\"><input type=\"button\" value=\"Login\" onclick=\"window.location.href='login.php'\"/></form>";
fok();
}
}
?>