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", basename(__FILE__));
43 if (!empty($_GET['access'])) {
44 // Secure input and construct FQFN
45 $access = SQL_ESCAPE(strip_tags($_GET['access']));
46 $target = sprintf("%slogs/%s", PATH, $access);
48 // Is the file valid and readable?
49 if (FILE_READABLE($target)) {
51 $content = implode("", file($target));
54 if (substr($access, -3, 3) == "log") {
55 header("Content-Type: text/plain");
56 } elseif (substr($access, -3, 3) == ".gz") {
57 header("Content-Type: text/plain");
59 LOAD_TEMPLATE("admin_settings_saved", false, UNKNOWN_LOGFILE_FORMAT_1.$access.UNKNOWN_LOGFILE_FORMAT_2);
66 // Output the logfile's content and exit
71 LOAD_TEMPLATE("admin_settings_saved", false, LOGFILE_NOT_READABLE_1.$access.LOGFILE_NOT_READABLE_2);
74 // List access logfiles
75 $dir = PATH.LOGS_BASE."/";
77 // logs directory does exist
79 $handle = @opendir($dir) or mxchange_die("Cannot open directory ".LOGS_BASE."!");
80 while($file = @readdir($handle)) {
81 // We currenly only like files with "access" as prefix, should be more flexible!
82 if (substr($file, 0, 6) == "access") {
83 // Okay, let us print it out
84 OUTPUT_HTML("<LI><A href=\"".URL."/modules.php?module=admin&what=".$GLOBALS['what']."&access=".urlencode($file)."\">".$file."</A></LI>");
92 // logs directory does not exist
93 LOAD_TEMPLATE("admin_settings_saved", false, ADMIN_LOGS_DIR_404_1.LOGS_BASE.ADMIN_LOGS_DIR_404_2);