]> git.mxchange.org Git - mailer.git/blobdiff - inc/modules/admin/what-usage.php
Added update_year.sh (still not fully flexible) and updated all years with it.
[mailer.git] / inc / modules / admin / what-usage.php
index a3e1aafa36a4585aa62b0bad90a0508505c8f807..121fcbcce70d6ec398d21820cb6a8e6109d0484e 100644 (file)
@@ -16,8 +16,8 @@
  * $Author::                                                          $ *
  * -------------------------------------------------------------------- *
  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
- * Copyright (c) 2009 - 2011 by Mailer Developer Team                   *
- * For more information visit: http://www.mxchange.org                  *
+ * Copyright (c) 2009 - 2015 by Mailer Developer Team                   *
+ * For more information visit: http://mxchange.org                      *
  *                                                                      *
  * This program is free software; you can redistribute it and/or modify *
  * it under the terms of the GNU General Public License as published by *
@@ -47,24 +47,26 @@ addYouAreHereLink('admin', __FILE__);
 $usage = getConfig('usage_base') . '/';
 
 // Init FQFN
-$FQFN = sprintf("%s%s/index.html",
+$FQFN = sprintf('%s%s/index.html',
        getPath(),
        getConfig('usage_base')
 );
 
-if (isGetRequestParameterSet('image')) {
-       if (getRequestParameter('type') == 'usage') {
-               $FQFN = sprintf("%s%s/usage.png",
+if (isGetRequestElementSet('image')) {
+       if (getRequestElement('type') == 'usage') {
+               $FQFN = sprintf('%s%s/usage.png',
                        getPath(),
                        getConfig('usage_base')
                );
        } else {
-               if (strpos(getRequestParameter('image'), "\\") > 0) setGetRequestParameter('image', substr(getRequestParameter('image'), 0, strpos(getRequestParameter('image'), "\\")));
-               $FQFN = sprintf("%s%s/%s_usage_%s.png",
+               if (strpos(getRequestElement('image'), chr(92)) > 0) {
+                       setGetRequestElement('image', substr(getRequestElement('image'), 0, strpos(getRequestElement('image'), chr(92))));
+               } // END - if
+               $FQFN = sprintf('%s%s/%s_usage_%s.png',
                        getPath(),
                        getConfig('usage_base'),
-                       getRequestParameter('type'),
-                       getRequestParameter('image')
+                       getRequestElement('type'),
+                       getRequestElement('image')
                );
        }
 
@@ -74,26 +76,43 @@ if (isGetRequestParameterSet('image')) {
                imagepng($image);
                imagedestroy($image);
        } // END - if
-       shutdown();
-} elseif (isGetRequestParameterSet('usage')) {
-       $FQFN = sprintf("%s%s/usage_%s.html",
+       doShutdown();
+} elseif (isGetRequestElementSet('usage')) {
+       $FQFN = sprintf('%s%s/usage_%s.html',
                getPath(),
                getConfig('usage_base'),
-               getRequestParameter('usage')
+               getRequestElement('usage')
        );
 }
 
 if ((!empty($FQFN)) && (isFileReadable($FQFN))) {
        // @TODO This code is double, see loadTemplate() and loadEmailTemplate() in functions.php
-       eval('$content="' . SQL_ESCAPE(readFromFile($FQFN)) . '";');
+       eval('$content="' . sqlEscapeString(readFromFile($FQFN)) . '";');
        // Until here...
 
        // Replace URLs
-       $content = str_replace('usage.png'    , '{?URL?}/modules.php?module=admin&what=' . getWhat() . '&type=usage&image=usage', $content);
-       $content = str_replace('daily_usage_' , '{?URL?}/modules.php?module=admin&what=' . getWhat() . '&type=daily&image='     , $content);
-       $content = str_replace('hourly_usage_', '{?URL?}/modules.php?module=admin&what=' . getWhat() . '&type=hourly&image='    , $content);
-       $content = str_replace('ctry_usage_'  , '{?URL?}/modules.php?module=admin&what=' . getWhat() . '&type=ctry&image='      , $content);
-       $content = str_replace('usage_'       , '{?URL?}/modules.php?module=admin&what=' . getWhat() . '&usage='                    , str_replace('.html', '', $content));
+       $content = str_replace(
+               // From:
+               array(
+                       'usage.png',
+                       'daily_usage_',
+                       'hourly_usage_',
+                       'ctry_usage_',
+                       'usage_',
+                       '.html',
+               ),
+               // To:
+               array(
+                       '{?URL?}/modules.php?module=admin&what=' . getWhat() . '&type=usage&image=usage',
+                       '{?URL?}/modules.php?module=admin&what=' . getWhat() . '&type=daily&image=',
+                       '{?URL?}/modules.php?module=admin&what=' . getWhat() . '&type=hourly&image=',
+                       '{?URL?}/modules.php?module=admin&what=' . getWhat() . '&type=ctry&image=',
+                       '{?URL?}/modules.php?module=admin&what=' . getWhat() . '&usage=',
+                       '',
+               ),
+               // Target to replace on:
+               $content
+       );
        $test = strtolower($content);
 
        // Do we need to strip out above and including <body> plus trailing </html> tag?
@@ -106,8 +125,8 @@ if ((!empty($FQFN)) && (isFileReadable($FQFN))) {
        // Output code
        outputHtml($content);
 } else {
-       // Nothing to load, then we have no directory 'usage'
-       loadTemplate('admin_settings_saved', false, '{--ADMIN_USAGE_DIRECTORY_404--}');
+       // Nothing to load, then there is no directory 'usage'
+       displayMessage('{--ADMIN_USAGE_DIRECTORY_404--}');
 }
 
 // [EOF]