2 /************************************************************************
3 * Mailer v0.2.1-FINAL 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 * -------------------------------------------------------------------- *
15 * $Tag:: 0.2.1-FINAL $ *
17 * Needs to be in all Files and every File needs "svn propset *
18 * svn:keywords Date Revision" (autoprobset!) at least!!!!!! *
19 * -------------------------------------------------------------------- *
20 * Copyright (c) 2003 - 2009 by Roland Haeder *
21 * Copyright (c) 2009, 2010 by Mailer Developer Team *
22 * For more information visit: http://www.mxchange.org *
24 * This program is free software; you can redistribute it and/or modify *
25 * it under the terms of the GNU General Public License as published by *
26 * the Free Software Foundation; either version 2 of the License, or *
27 * (at your option) any later version. *
29 * This program is distributed in the hope that it will be useful, *
30 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
31 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
32 * GNU General Public License for more details. *
34 * You should have received a copy of the GNU General Public License *
35 * along with this program; if not, write to the Free Software *
36 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
38 ************************************************************************/
40 // Some security stuff...
41 if ((!defined('__SECURITY')) || (!isAdmin())) {
45 // Add description as navigation point
46 addMenuDescription('admin', __FILE__);
48 if (isGetRequestParameterSet('access')) {
49 // Secure input and construct FQFN
50 $access = SQL_ESCAPE(secureString(getRequestParameter('access')));
51 $target = sprintf("%slogs/%s", getPath(), $access);
53 // Is the file valid and readable?
54 if (isFileReadable($target)) {
56 $content = readFromFile($target);
59 $OUTPUT = ob_get_contents();
65 if (substr($access, -3, 3) == 'log') {
67 sendHeader('Content-Type: text/plain');
68 } elseif (substr($access, -3, 3) == '.gz') {
69 // @TODO Fix content-type here
70 sendHeader('Content-Type: text/plain');
71 } elseif (substr($access, -3, 3) == '.bz2') {
72 // @TODO Fix content-type here
73 sendHeader('Content-Type: text/plain');
75 // Restore old content
79 loadTemplate('admin_settings_saved', false, getMaskedMessage('ADMIN_UNKNOWN_LOGFILE_FORMAT', $access));
83 // Output the logfile's content and exit
88 loadTemplate('admin_settings_saved', false, getMaskedMessage('LOGFILE_NOT_READABLE', $access));
91 // Is the directory there?
92 if (isDirectory(getPath() . getConfig('logs_base'))) {
93 // Logs directory does exist so begin the list
97 $files = getArrayFromDirectory(getConfig('logs_base'), 'access');
99 // And walk through them
100 foreach ($files as $file) {
102 $file = basename($file);
105 outputHtml('<li><a href="{%url=modules.php?module=admin&what=' . getWhat() . '&access=' . urlencode($file) . '%}">' . $file . '</a></li>');
111 // logs directory does not exist
112 loadTemplate('admin_settings_saved', false, '{--ADMIN_LOGS_DIR_404--}');