2 /************************************************************************
3 * MXChange v0.2.1 Start: 11/15/2003 *
4 * =============== Last change: 04/02/2004 *
6 * -------------------------------------------------------------------- *
7 * File : what-logs.php *
8 * -------------------------------------------------------------------- *
9 * Short description : Management for access log files *
10 * -------------------------------------------------------------------- *
11 * Kurzbeschreibung : Management fuer Zugriffslogbuecher *
12 * -------------------------------------------------------------------- *
14 * -------------------------------------------------------------------- *
15 * Copyright (c) 2003 - 2008 by Roland Haeder *
16 * For more information visit: http://www.mxchange.org *
18 * This program is free software; you can redistribute it and/or modify *
19 * it under the terms of the GNU General Public License as published by *
20 * the Free Software Foundation; either version 2 of the License, or *
21 * (at your option) any later version. *
23 * This program is distributed in the hope that it will be useful, *
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
26 * GNU General Public License for more details. *
28 * You should have received a copy of the GNU General Public License *
29 * along with this program; if not, write to the Free Software *
30 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
32 ************************************************************************/
34 // Some security stuff...
35 if ((!defined('__SECURITY')) || (!IS_ADMIN())) {
36 $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
40 // Add description as navigation point
41 ADD_DESCR("admin", __FILE__);
43 if (REQUEST_ISSET_GET(('access'))) {
44 // Secure input and construct FQFN
45 $access = SQL_ESCAPE(strip_tags(REQUEST_GET('access')));
46 $target = sprintf("%slogs/%s", constant('PATH'), $access);
48 // Is the file valid and readable?
49 if (FILE_READABLE($target)) {
51 $content = READ_FILE($target);
54 $OUTPUT = ob_get_contents();
60 if (substr($access, -3, 3) == "log") {
62 header("Content-Type: text/plain");
63 } elseif (substr($access, -3, 3) == ".gz") {
64 // @TODO Fix content-type here
65 header("Content-Type: text/plain");
66 } elseif (substr($access, -3, 3) == ".bz2") {
67 // @TODO Fix content-type here
68 header("Content-Type: text/plain");
70 // Restore old content
74 LOAD_TEMPLATE("admin_settings_saved", false, sprintf(getMessage('ADMIN_UNKNOWN_LOGFILE_FORMAT'), $access));
78 // Output the logfile's content and exit
83 LOAD_TEMPLATE("admin_settings_saved", false, sprintf(getMessage('LOGFILE_NOT_READABLE'), $access));
86 // List access logfiles
87 $dir = PATH.getConfig('logs_base')."/";
89 // logs directory does exist
91 $handle = opendir($dir) or mxchange_die("Cannot open directory ".getConfig('logs_base')."!");
92 while ($file = readdir($handle)) {
93 // We currenly only like files with "access" as prefix, should be more flexible!
94 if (substr($file, 0, 6) == "access") {
95 // Okay, let us print it out
96 OUTPUT_HTML("<li><a href=\"{!URL!}/modules.php?module=admin&what=".$GLOBALS['what']."&access=".urlencode($file)."\">".$file."</a></li>");
100 OUTPUT_HTML("</ol>");
102 // logs directory does not exist
103 LOAD_TEMPLATE("admin_settings_saved", false, sprintf(getMessage('ADMIN_LOGS_DIR_404'), getConfig('logs_base')));