2 /************************************************************************
\r
3 * MXChange v0.2.1 Start: 11/15/2003 *
\r
4 * =============== Last change: 04/02/2004 *
\r
6 * -------------------------------------------------------------------- *
\r
7 * File : what-logs.php *
\r
8 * -------------------------------------------------------------------- *
\r
9 * Short description : Management for access log files *
\r
10 * -------------------------------------------------------------------- *
\r
11 * Kurzbeschreibung : Management fuer Zugriffslogbuecher *
\r
12 * -------------------------------------------------------------------- *
\r
14 * -------------------------------------------------------------------- *
\r
15 * Copyright (c) 2003 - 2008 by Roland Haeder *
\r
16 * For more information visit: http://www.mxchange.org *
\r
18 * This program is free software; you can redistribute it and/or modify *
\r
19 * it under the terms of the GNU General Public License as published by *
\r
20 * the Free Software Foundation; either version 2 of the License, or *
\r
21 * (at your option) any later version. *
\r
23 * This program is distributed in the hope that it will be useful, *
\r
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
\r
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
\r
26 * GNU General Public License for more details. *
\r
28 * You should have received a copy of the GNU General Public License *
\r
29 * along with this program; if not, write to the Free Software *
\r
30 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
\r
31 * MA 02110-1301 USA *
\r
32 ************************************************************************/
\r
34 // Some security stuff...
\r
35 if ((ereg(basename(__FILE__), $_SERVER['PHP_SELF'])) || (!IS_ADMIN()))
\r
37 $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4)."/security.php";
\r
40 // Add description as navigation point
\r
41 ADD_DESCR("admin", basename(__FILE__));
\r
43 if (!empty($_GET['access'])) {
\r
44 // Secure input and construct FQFN
\r
45 $access = SQL_ESCAPE(strip_tags($_GET['access']));
\r
46 $target = sprintf("%slogs/%s", PATH, $access);
\r
48 // Is the file valid and readable?
\r
49 if ((file_exists($target)) && (is_readable($target))) {
\r
51 $content = implode("", file($target));
\r
54 if (substr($access, -3, 3) == "log") {
\r
55 header("Content-Type: text/plain");
\r
56 } elseif (substr($access, -3, 3) == ".gz") {
\r
57 header("Content-Type: text/plain");
\r
59 LOAD_TEMPLATE("admin_settings_saved", false, UNKNOWN_LOGFILE_FORMAT_1.$access.UNKNOWN_LOGFILE_FORMAT_2);
\r
66 // Output the logfile's content and exit
\r
71 LOAD_TEMPLATE("admin_settings_saved", false, LOGFILE_NOT_READABLE_1.$access.LOGFILE_NOT_READABLE_2);
\r
74 // List access logfiles
\r
75 $dir = PATH.LOGS_BASE."/";
\r
77 // logs directory does exist
\r
78 OUTPUT_HTML ("<OL>");
\r
79 $handle = @opendir($dir) or mxchange_die("Cannot open directory ".LOGS_BASE."!");
\r
80 while($file = @readdir($handle)) {
\r
81 // We currenly only like files with "access" as prefix, should be more flexible!
\r
82 if (substr($file, 0, 6) == "access") {
\r
83 // Okay, let us print it out
\r
84 OUTPUT_HTML ("<LI><A href=\"".URL."/modules.php?module=admin&what=".$GLOBALS['what']."&access=".urlencode($file)."\">".$file."</A></LI>");
\r
88 OUTPUT_HTML ("</OL>");
\r
92 // logs directory does not exist
\r
93 LOAD_TEMPLATE("admin_settings_saved", false, ADMIN_LOGS_DIR_404_1.LOGS_BASE.ADMIN_LOGS_DIR_404_2);
\r