]> git.mxchange.org Git - mailer.git/blob - inc/modules/admin/what-usage.php
0f77c2730caa11d760d009ed4137b582a30540f8
[mailer.git] / inc / modules / admin / what-usage.php
1 <?php
2 /************************************************************************
3  * MXChange v0.2.1                                    Start: 11/15/2003 *
4  * ===============                              Last change: 04/02/2004 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : what-usage.php                                   *
8  * -------------------------------------------------------------------- *
9  * Short description : Auto-detection of usage statistics               *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Automatische Erkennung der Aufrufstatistiken     *
12  * -------------------------------------------------------------------- *
13  * $Revision::                                                        $ *
14  * $Date::                                                            $ *
15  * $Tag:: 0.2.1-FINAL                                                 $ *
16  * $Author::                                                          $ *
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 - 2008 by Roland Haeder                           *
21  * For more information visit: http://www.mxchange.org                  *
22  *                                                                      *
23  * This program is free software; you can redistribute it and/or modify *
24  * it under the terms of the GNU General Public License as published by *
25  * the Free Software Foundation; either version 2 of the License, or    *
26  * (at your option) any later version.                                  *
27  *                                                                      *
28  * This program is distributed in the hope that it will be useful,      *
29  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
30  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
31  * GNU General Public License for more details.                         *
32  *                                                                      *
33  * You should have received a copy of the GNU General Public License    *
34  * along with this program; if not, write to the Free Software          *
35  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
36  * MA  02110-1301  USA                                                  *
37  ************************************************************************/
38
39 // Some security stuff...
40 if ((!defined('__SECURITY')) || (!IS_ADMIN())) {
41         $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), '/inc') + 4) . '/security.php';
42         require($INC);
43 }
44
45 // Add description as navigation point
46 ADD_DESCR('admin', __FILE__);
47
48 // Base directory (should be moved to database)
49 $usage = getConfig('usage_base') . '/';
50
51 if (REQUEST_ISSET_GET(('image'))) {
52         if (REQUEST_GET('type') == 'usage') {
53                 $FQFN = sprintf("%s%s/usage.png",
54                 constant('PATH'),
55                 getConfig('usage_base')
56                 );
57         } else {
58                 if (strpos(REQUEST_GET('image'), "\\") > 0) REQUEST_SET_GET('image', substr(REQUEST_GET('image'), 0, strpos(REQUEST_GET('image'), "\\")));
59                 $FQFN = sprintf("%s%s/%s_usage_%s.png",
60                 constant('PATH'),
61                 getConfig('usage_base'),
62                 REQUEST_GET(('type')),
63                 REQUEST_GET(('image'))
64                 );
65         }
66
67         if (isFileReadable($FQFN)) {
68                 $image = imagecreatefrompng($FQFN);
69                 sendHeader("Content-type: image/png");
70                 imagepng($image);
71                 imagedestroy($image);
72         }
73         shutdown();
74 } elseif (!REQUEST_ISSET_GET(('usage'))) {
75         $FQFN = sprintf("%s%s/index.html",
76         constant('PATH'),
77         getConfig('usage_base')
78         );
79 } else {
80         $FQFN = sprintf("%s%s/usage_%s.html",
81         constant('PATH'),
82         getConfig('usage_base'),
83         REQUEST_GET(('usage'))
84         );
85 }
86
87 if ((!empty($FQFN)) && (isFileReadable($FQFN))) {
88         // @TODO This code is double, see LOAD_TEMPLATE and LOAD_EMAIL_TEMPLATE in functions.php
89         $tmpl_file = readFromFile($FQFN);
90         $tmpl_file = SQL_ESCAPE($tmpl_file);
91         $tmpl_file = "\$content=\"".$tmpl_file."\";";
92         eval($tmpl_file);
93         // Until here...
94
95         // Replace URLs
96         $content = str_replace("usage.png", "{!URL!}/modules.php?module=admin&amp;what=".$GLOBALS['what']."&type=usage&image=usage", $content);
97         $content = str_replace("daily_usage_", "{!URL!}/modules.php?module=admin&amp;what=".$GLOBALS['what']."&type=daily&image=", $content);
98         $content = str_replace("hourly_usage_", "{!URL!}/modules.php?module=admin&amp;what=".$GLOBALS['what']."&type=hourly&image=", $content);
99         $content = str_replace("ctry_usage_", "{!URL!}/modules.php?module=admin&amp;what=".$GLOBALS['what']."&type=ctry&image=", $content);
100         $content = str_replace("usage_", "{!URL!}/modules.php?module=admin&amp;what=".$GLOBALS['what']."&usage=", str_replace(".html", '', $content));
101
102         // Disabled due to too much trouble
103         //$content = str_replace("HREF=\"http://", "href=\"{!URL!}/modules.php?module=loader&amp;url=http://", $content);
104         $test = strtolower($content);
105
106         // Do we need to strip out above and including <body> plus trailing </html> tag?
107         if ((strpos($test, "<body") > 0) && (strpos($test, "</body>") > 0)) {
108                 // Okay, then do so.
109                 $content = substr(substr($content, 0, $body_end), $body_start);
110                 $content = substr($content, strpos($content, ">") + 1);
111         } // END - if
112
113         // Output code
114         OUTPUT_HTML("<div align=\"left\">
115   ".$content."
116 </div>");
117 } else {
118         // Nothing to load, then we have no directory 'usage'
119         LOAD_TEMPLATE('admin_settings_saved', false, sprintf(getMessage('ADMIN_USAGE_DIRECTORY_404'), getConfig('usage_base')));
120 }
121
122 //
123 ?>