4046acd7536c21c8906698aacfb45142eacb307f
[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  *                                                                      *
14  * -------------------------------------------------------------------- *
15  * Copyright (c) 2003 - 2008 by Roland Haeder                           *
16  * For more information visit: http://www.mxchange.org                  *
17  *                                                                      *
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.                                  *
22  *                                                                      *
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.                         *
27  *                                                                      *
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,               *
31  * MA  02110-1301  USA                                                  *
32  ************************************************************************/
33
34 // Some security stuff...
35 if ((ereg(basename(__FILE__), $_SERVER['PHP_SELF'])) || (!IS_ADMIN())) {
36         $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
37         require($INC);
38 }
39
40 // Add description as navigation point
41 ADD_DESCR("admin", basename(__FILE__));
42
43 // Base directory (should be moved to database)
44 $usage = "usage/";
45
46 OPEN_TABLE("100%", "admin_content admin_content_align", "");
47
48 if (!empty($_GET['image'])) {
49         if ($_GET['type'] == "usage") {
50                 $file = sprintf("%s%susage.png", PATH, $usage);
51         } else {
52                 if (strpos($_GET['image'], "\\") > 0) $_GET['image'] = substr($_GET['image'], 0, strpos($_GET['image'], "\\"));
53                 $file = sprintf("%s%s%s_usage_%s.png", PATH, $usage, SQL_ESCAPE($_GET['type']), SQL_ESCAPE($_GET['image']));
54         }
55
56         if (FILE_READABLE($file)) {
57                 $image = imagecreatefrompng($file);
58                 header("Content-type: image/png");
59                 imagepng($image);
60                 imagedestroy($image);
61         }
62         exit();
63 } elseif (empty($_GET['usage'])) {
64         $file = sprintf("%s%sindex.html", PATH, $usage);
65 } else {
66         $file = sprintf("%s%susage_%s.html",
67                 PATH,
68                 $usage,
69                 SQL_ESCAPE($_GET['usage'])
70         );
71 }
72
73 if (!empty($file)) {
74         if (FILE_READABLE($file)) {
75                         $tmpl_file = implode("", file($file));
76                         $tmpl_file = addslashes($tmpl_file);
77                         $tmpl_file = "\$content=\"".$tmpl_file."\";";
78                         eval($tmpl_file);
79                         $content = str_replace("usage.png", URL."/modules.php?module=admin&amp;what=".$GLOBALS['what']."&type=usage&image=usage", $content);
80                         $content = str_replace("daily_usage_", URL."/modules.php?module=admin&amp;what=".$GLOBALS['what']."&type=daily&image=", $content);
81                         $content = str_replace("hourly_usage_", URL."/modules.php?module=admin&amp;what=".$GLOBALS['what']."&type=hourly&image=", $content);
82                         $content = str_replace("ctry_usage_", URL."/modules.php?module=admin&amp;what=".$GLOBALS['what']."&type=ctry&image=", $content);
83                         $content = str_replace("usage_", URL."/modules.php?module=admin&amp;what=".$GLOBALS['what']."&usage=", str_replace(".html", "", $content));
84                         // Disabled due to too much trouble
85                         //$content = str_replace("HREF=\"http://", "href=\"".URL."/modules.php?module=loader&amp;url=http://", $content);
86                         $test = strtolower($content);
87                         $body_start = strpos($test, "<body");
88                         $body_end   = strpos($test, "</body>");
89                         if (($body_start > 0) && ($body_end > 0))
90                         {
91                                 $content = substr(substr($content, 0, $body_end), $body_start);
92                                 $content = substr($content, strpos($content, ">") + 1);
93                                 OUTPUT_HTML("<DIV align=\"left\">
94   ".$content."
95 </DIV>");
96                         }
97         }
98 }
99
100 CLOSE_TABLE();
101 //
102 ?>