-
Notifications
You must be signed in to change notification settings - Fork 1
/
admin_iplog_action.php
75 lines (65 loc) · 2.23 KB
/
admin_iplog_action.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
<?php
/**
* IP Log Action Script
*
* @version $Id$
* @copyright 2009
*/
require_once("./includes/upb.initialize.php");
$where = "<a href='admin.php'>Admin</a> ".$_CONFIG["where_sep"]." <a href='admin_iplog.php'>Ip Address Logs</a>";
// Make sure user is logged in, otherwise terminate
if (!isset($_COOKIE["user_env"]) || !isset($_COOKIE["uniquekey_env"]) || !isset($_COOKIE["power_env"]) || !isset($_COOKIE["id_env"]))
{
require_once("./includes/header.php");
exitPage("
<div class='alert'><div class='alert_text'>
<strong>Access Denied!</strong></div><div style='padding:4px;'>You are not logged in.</div></div>
<meta http-equiv='refresh' content='2;URL=login.php?ref=admin_iplog.php'>");
require_once("./includes/footer.php");
exit;
}
// Make sure user has admin credentials
if (!$tdb->is_logged_in() || $_COOKIE["power_env"] < 3)
{
require_once("./includes/header.php");
exitPage("
<div class='alert'><div class='alert_text'>
<strong>Access Denied!</strong></div><div style='padding:4px;'>you are not authorized to be here.</div></div>");
require_once("./includes/footer.php");
exit;
}
switch($_GET['action'])
{
case 'download':
// User wants to download a copy of the IP Log - force a download operation
header("Content-type: application/octet-stream");
header('Content-Length: ' . filesize(DB_DIR.'/ip.log'));
header("Content-disposition: attachment; filename=\"ip.log\"");
readfile(DB_DIR.'/ip.log');
break;
case 'clear':
// Fopen the logs and write no data in order to clear them
$fp = fopen(DB_DIR.'/ip.log', 'w');
fwrite($fp, "");
fclose($fp);
require_once("./includes/header.php");
echo "
<div class='alert_confirm'>
<div class='alert_confirm_text'>
<strong>Redirecting:</div><div style='padding:4px;'>
Successfully cleared IP Log.
</div>
</div>";
redirect("admin_iplog.php", 1);
require_once("./includes/footer.php");
break;
default:
require_once("./includes/header.php");
exitPage("
<div class='alert'><div class='alert_text'>
<strong>No Action Specified!</strong></div><div style='padding:4px;'>An action must be specified to use this page</div></div>");
require_once("./includes/footer.php");
exit;
break;
}
?>