Beispiel #1
0
 public function executeFilter(HttpRequestInterface $request, HttpResponseInterface $response)
 {
     /*
      * Deny service, if the system load is too high.
      */
     if (defined('DEBUG') and DEBUG === false) {
         $maxServerLoad = isset(self::$config['load']['max']) ? (double) self::$config['load']['max'] : 80;
         if (\Koch\Functions\Functions::getServerLoad() > $maxServerLoad) {
             $response->addHeader('Retry-After', mt_rand(45, 90));
             $response->setStatusCode('503');
             $response->addContent('HTTP/1.1 503 Server too busy. Please try again later.');
             $response->sendResponse();
         }
     }
     // ensure smarty "tpl_compile" folder exists
     if (false === is_dir(APPLICATION_CACHE_PATH . 'tpl_compile') and false === @mkdir(APPLICATION_CACHE_PATH . 'tpl_compile', 0755, true)) {
         throw new Exception('Smarty Template Directories not existant.', 9);
     }
     // ensure smarty "cache" folder exists
     if (false === is_dir(APPLICATION_CACHE_PATH . 'tpl_cache') and false === @mkdir(APPLICATION_CACHE_PATH . 'tpl_cache', 0755, true)) {
         throw new Exception('Smarty Template Directories not existant.', 9);
     }
     // ensure smarty folders are writable
     if (false === is_writable(APPLICATION_CACHE_PATH . 'tpl_compile') or false === is_writable(APPLICATION_CACHE_PATH . 'tpl_cache')) {
         // if not, try to set writeable permission on the folders
         if (false === chmod(APPLICATION_CACHE_PATH . 'tpl_compile', 0755) and false === chmod(APPLICATION_CACHE_PATH . 'tpl_cache', 0755)) {
             throw new Exception('Smarty Template Directories not writable.', 10);
         }
     }
 }
Beispiel #2
0
 /**
  * Builds a class map file.
  *
  * @param string[] $dirs    One or multiple directories to scan for PHP files.
  * @param string   $mapfile Path to the classmap file to be written.
  *
  * @return bool True, if map file written, false otherwise.
  */
 public static function build($dirs, $mapfile)
 {
     $classmap = [];
     $files = [];
     $dirs = (array) $dirs;
     foreach ($dirs as $dir) {
         $files += Functions::globRecursive($dir . '/*.php');
     }
     foreach ($files as $file) {
         $classnames = self::extractClassnames($file);
         foreach ($classnames as $classname) {
             $classmap[$classname] = $file;
         }
     }
     return self::writeMapFile($classmap, $mapfile);
 }
Beispiel #3
0
 /**
  * Registers multiple Events by Name.
  */
 public static function loadEventHandlers($events)
 {
     if (empty($events) or is_array($events) === false) {
         return;
     } else {
         // ok, we got an array with some event names
         foreach ($events as $event) {
             // array[0] filename
             $filename = $array[0];
             // array[1] classname
             $classname = \Koch\Functions\Functions::ensurePrefixedWith($array[1], '\\Koch\\Event\\Event');
             // load eventhandler
             \Koch\Autoload\Loader::requireFile($filename, $classname);
             // instantiate eventhandler
             $event_object = new $classname();
             // add the eventhandler to the dispatcher
             $eventdispatcher = \Koch\Event\Dispatcher::instantiate();
             $eventdispatcher->addEventHandler($event, $event_object);
         }
     }
 }
Beispiel #4
0
 /**
  * Render Engine Configuration
  * Configures the Smarty Object.
  */
 public function configureEngine()
 {
     // Directories
     $this->renderer->compile_dir = $this->options['compile_dir'];
     $this->renderer->cache_dir = $this->options['cache_dir'];
     $this->renderer->config_dir = $this->options['config_dir'];
     /*
      * Debug Mode Settings
      */
     if (DEBUG === true) {
         $this->renderer->debugging = true;
         $this->renderer->debug_tpl = 'file:' . $this->options['debug_tpl'];
         $this->renderer->caching = 0;
         $this->renderer->cache_lifetime = 0;
         // refresh templates on every load
         // $this->renderer->cache_handler_func   = "";   // Specify your own cache_handler function
         $this->renderer->cache_modified_check = 0;
         // set to 1 to activate
         $this->renderer->clearCompiledTemplate();
         $this->renderer->clearAllCache();
         /*
          * Recompile templates only in debug mode
          * @see http://www.smarty.net/manual/de/variable.compile.check.php
          */
         // if a template was changed it would be recompiled,
         // if set to false nothing will be compiled (changes take no effect)
         $this->renderer->compile_check = true;
         // if true compiles each template everytime, overwrites $compile_check
         $this->renderer->force_compile = true;
     }
     // auto delimiter of javascript/css
     $this->renderer->auto_literal = true;
     /*
      * Caching
      */
     $this->renderer->caching = (bool) $this->options['cache_enabled'];
     // -1 ... dont expire, 0 ... refresh everytime
     $this->renderer->cache_lifetime = $this->options['cache_lifetime'];
     // $this->renderer->cache_handler_func = "";      // Specify your own cache_handler function
     $this->renderer->cache_modified_check = 1;
     // set to 1 to activate
     /*
      * Smarty Template Directories
      *
      * This sets multiple template dirs, with the following detection order:
      * The user-choosen Theme, before Module, before Core/Default/Admin-Theme.
      *
      * 1) "/themes/[frontend|backend]/theme(from_session)/"
      * 2) "/themes/[frontend|backend]/theme(from_session)/modulename/"
      * 3) "/modules/"
      * 4) "/modules/modulename/view/"
      * 5) "/themes/core/view/smarty"
      * 6) "/themes/"
      */
     $tpl_array = [$this->viewMapper->getThemeTemplatePaths(), $this->viewMapper->getModuleTemplatePaths(), APPLICATION_PATH . 'themes/core/view/smarty', APPLICATION_PATH . 'themes/'];
     // flatten that thing
     $this->renderer->template_dir = \Koch\Functions\Functions::arrayFlatten($tpl_array);
     #\Koch\Debug\Debug::printR($this->renderer->template_dir);
     /*
      * Smarty Plugins
      *
      * Configure Smarty Viewhelper Directories
      * 1) original smarty plugins           => vendor folder \smarty\plugins\
      * 2) framework                         => framework folder \view\helper\smarty
      * 3) application core smarty plugins   => application folder \core\view\helper\smarty\
      * 4) application module smarty plugins => application module \app\modules\(modulename)\view\helper\smarty\
      */
     $this->renderer->setPluginsDir([VENDOR_PATH . '/smarty/smarty/distribution/libs/plugins', __DIR__ . '/../Helper/Smarty', APPLICATION_PATH . '/Core/View/Helper/Smarty', APPLICATION_MODULES_PATH . TargetRoute::getModule() . '/View/Helper/Smarty']);
     #\Koch\Debug\Debug::printR($this->renderer->plugins_dir);
     // $this->renderer->registerPlugin('modifier', 'timemarker',  array('benchmark', 'timemarker'));
     /*
      * SMARTY FILTERS
      */
     $autoload_filters = [];
     if ($this->renderer->debugging === true) {
         $autoload_filters = ['pre' => ['inserttplnames']];
     }
     $this->renderer->autoload_filters = $autoload_filters;
     #array(       // indicates which filters will be auto-loaded
     #'pre'    => array('inserttplnames'),
     #'post'   => array(),
     #'output' => array('trimwhitespaces')
     #);
     //
     #$this->renderer->registerFilter(Smarty::FILTER_VARIABLE, 'htmlspecialchars');
     // Auto-Escape all variables
     #$this->renderer->default_modifiers = array('escape:"html":"UTF-8"');
     // compile time setting, tpls need recompiling
     $this->renderer->merge_compiled_includes = true;
 }
Beispiel #5
0
 /**
  * Renders a Koch Framework Error.
  *
  * @param int    $errno
  * @param string $errstr
  * @param string $errfile
  * @param string $errline
  * @param int    $errline
  * @param string $errcontext
  * @param string $errorname
  */
 public static function renderError($errno, $errorname, $errstr, $errfile, $errline, $errcontext)
 {
     // shorten errorfile string by removing the root path
     $errfile_short = str_replace(APPLICATION_PATH, '', $errfile);
     $short_errorstring = \Koch\Functions\Functions::shortenString($errfile, 70, '...');
     // Header
     $html = '<html><head>';
     $html .= '<title>Koch Framework Error</title>';
     $html .= '<link rel="stylesheet" href="' . WWW_ROOT_THEMES_CORE . 'css/error.css" type="text/css" />';
     $html .= '</head>';
     // Body
     $html .= '<body>';
     // Fieldset with Legend
     $html .= '<fieldset id="top" class="error_red">';
     $html .= '<legend>Koch Framework Error</legend>';
     // Add Errorlogo
     $html .= '<div style="float: left; margin: 5px; margin-right: 25px; padding: 20px;">';
     $html .= '<img src="' . WWW_ROOT_THEMES_CORE . 'images/Clansuite-Toolbar-Icon-64-error.png"';
     $html .= ' style="border: 2px groove #000000;"/></div>';
     // Open Error Table
     $html .= '<table width="80%"><tr><td>';
     // Panel 1 - Errormessage
     $html .= '<div id="panel1" class="panel">';
     $html .= '<h3>Error - ' . $errorname . ' (' . $errno . ')</h3> ';
     $html .= '<p style="font-weight: bold;">' . $errstr . '</p>';
     $html .= '<p>in file "<span style="font-weight: bold;">' . $errfile_short . '</span>"';
     $html .= ' on line #<span style="font-weight: bold;">' . $errline . '.</span></p>';
     $html .= '</div>';
     // Panel 2 - Error Context
     $html .= '<div id="panel2" class="panel">';
     $html .= '<h3>Context</h3>';
     $html .= '<p><span class="small">You are viewing the source code of the file "';
     $html .= $errfile . '" around line ' . $errline . '.</span></p>';
     $html .= Errorhandler::getErrorContext($errfile, $errline, 8) . '</div>';
     // Panel 3 - Debug Backtracing
     $html .= Errorhandler::getDebugBacktrace($short_errorstring);
     // Panel 4 - Environmental Informations at Errortime
     $html .= '<div id="panel4" class="panel">';
     $html .= '<h3>Server Environment</h3>';
     $html .= '<p><table width="95%">';
     $html .= '<tr><td colspan="2"></td></tr>';
     $html .= '<tr><td><strong>Date: </strong></td><td>' . date('r') . '</td></tr>';
     $html .= '<tr><td><strong>Remote: </strong></td><td>' . $_SERVER['REMOTE_ADDR'] . '</td></tr>';
     $html .= '<tr><td><strong>Request: </strong></td><td>' . htmlentities($_SERVER['QUERY_STRING'], ENT_QUOTES);
     $html .= '</td></tr>';
     $html .= '<tr><td><strong>PHP: </strong></td><td>' . PHP_VERSION . ' ' . PHP_EXTRA_VERSION . '</td></tr>';
     $html .= '<tr><td><strong>Server: </strong></td><td>' . $_SERVER['SERVER_SOFTWARE'] . '</td></tr>';
     $html .= '<tr><td><strong>Agent: </strong></td><td>' . $_SERVER['HTTP_USER_AGENT'] . '</td></tr>';
     $html .= '<tr><td><strong>Clansuite: </strong></td><td>';
     $html .= APPLICATION_VERSION . ' ' . APPLICATION_VERSION_STATE . ' (' . APPLICATION_VERSION_NAME . ')';
     $html .= '</td></tr>';
     $html .= '</table></p></div>';
     // Panel 5 - Backlink to Bugtracker with Errormessage -> http://trac.clansuite.com/newticket
     $html .= Errorhandler::getBugtrackerBacklinks($errorname, $errfile, $errline, $errcontext);
     // Close Error Table
     $html .= '</table>';
     // Add Footer with Support-Backlinks
     $html .= Errorhandler::getSupportBacklinks();
     // Close all html elements
     $html .= '</fieldset><br /><br />';
     $html .= '</body></html>';
     return $html;
 }
Beispiel #6
0
 /**
  * Renders a normal html textarea representation when
  * no wysiwyg editor object is attached to this textarea object.
  * Otherwise the html content of the wysiwyg editor is prepended
  * to the textarea html.!
  *
  * @return $html HTML Representation of an textarea
  */
 public function render()
 {
     $html = '';
     /**
      * Opening of textarea tag
      */
     $html .= '<textarea';
     $html .= (bool) $this->id ? ' id="' . $this->id . '"' : null;
     $html .= (bool) $this->name ? ' name="' . $this->name . '"' : null;
     $html .= (bool) $this->size ? ' size="' . $this->size . '"' : null;
     $html .= (bool) $this->cols ? ' cols="' . $this->cols . '"' : null;
     $html .= (bool) $this->rows ? ' rows="' . $this->rows . '"' : null;
     $html .= (bool) $this->class ? ' class="' . $this->class . '"' : null;
     $html .= (bool) $this->disabled ? ' disabled="disabled"' : null;
     $html .= (bool) $this->maxlength ? ' maxlength="' . $this->maxlength . '"' : null;
     $html .= (bool) $this->style ? ' style="' . $this->style . '"' : null;
     $html .= '>';
     /**
      * Content between tags (value)
      */
     $html .= \Koch\Functions\Functions::UTF8_to_HTML($this->getValue());
     /**
      * Closing of textarea tag
      */
     $html .= '</textarea>';
     /**
      * Attach HTML content of WYSIWYG Editor
      *
      * Always after the textarea !
      * Because html elements are served first, before javascript dom selections are applied upon them!
      */
     if (empty($this->editor) == false) {
         $html .= $this->getEditorFormelement()->transferPropertiesToEditor()->render();
     }
     return $html;
 }
Beispiel #7
0
 /**
  * Gets a Config Value or sets a default value.
  *
  * @example
  * Usage for one default variable:
  * self::getConfigValue('items_newswidget', '8');
  * Gets the value for the key items_newswidget from the moduleconfig or sets the value to 8.
  *
  * Usage for two default variables:
  * self::getConfigValue('items_newswidget', $_GET['numberNews'], '8');
  * Gets the value for the key items_newswidget from the moduleconfig or sets the value
  * incomming via GET, if nothing is incomming, sets the default value of 8.
  *
  * @param string $keyname     The keyname to find in the array.
  * @param mixed  $default_one Default value. Returned, if the keyname was not found.
  * @param mixed  $default_two Default value. Returned, if the keyname was not found and default_one is null.
  */
 public function getConfigValue($keyname, $default_one = null, $default_two = null)
 {
     // try a lookup of the value by keyname
     $value = \Koch\Functions\Functions::findKeyInArray($keyname, $this->config);
     // return value or default
     if (empty($value) === false) {
         return $value;
     } elseif ($default_one !== null) {
         return $default_one;
     } elseif ($default_two !== null) {
         return $default_two;
     } else {
         return;
     }
 }
Beispiel #8
0
/**
 * Smarty plugin.
 *
 * Type:     modifier<br>
 * Name:     megabytes<br>
 * Date:     Oct 07, 2008
 * Purpose:  convert a number to megabytes , kilobytes, bytes
 * Input:<br>
 *         - string = bytesize to convert to mb, kb, b
 * Example:  {$bytesize|megabytes}
 *
 * @param string
 *
 * @return string
 */
function smarty_modifier_megabytes($string)
{
    return \Koch\Functions\Functions::getsize($string);
}
Beispiel #9
0
 /**
  * Builds a url string.
  *
  * @param $url Array or String to build the url from (e.g. '/news/admin/show')
  * @param $encode bool True (default) encodes the "&" in the url (amp).
  */
 public static function buildURL($url, $encode = true)
 {
     // if urlstring is array, then a relation (urlstring => parameter_order) is given
     if (is_array($url)) {
         $parameterOrder = '';
         list($url, $parameterOrder) = each($url);
     }
     // return, if urlstring is already a qualified url (http://...)
     if (false !== strpos($url, WWW_ROOT . 'index.php?')) {
         return $url;
     }
     // only the http prefix is missing
     if (false !== strpos($url, 'index.php?')) {
         return 'http://' . $url;
     }
     // cleanup: remove all double slashes
     while (false !== strpos($url, '//')) {
         $url = str_replace('//', '/', $url);
     }
     // cleanup: remove space and slashes from begin and end of string
     $url = trim($url, ' /');
     /*
      * Mod_Rewrite is ON.
      *
      * The requested url style is:
      * ROOT/news/2
      */
     if (self::isRewriteEngineOn() === true) {
         /* self::checkEnvForModRewrite() */
         return WWW_ROOT . ltrim($url, '/');
     } else {
         /*
          * Mod_Rewrite is OFF.
          *
          * The requested url style is:
          * ROOT/index.php?mod=new&ctrl=admin&action=show&id=2
          */
         // get only the part after "index.php?"
         if (false !== strpos($url, 'index.php?')) {
             $url = strstr($url, 'index.php?');
         }
         // $urlstring contains something like "/news/show/2"
         // explode the string into an indexed array
         $urlParameters = explode('/', $url);
         // do we have a parameter_order given?
         if (isset($parameterOrder)) {
             // replace parameter names with shorthands used in the url
             $search = ['module', 'controller', 'action'];
             $replace = ['mod', 'ctrl', 'action'];
             $parameterOrder = str_replace($search, $replace, $parameterOrder);
             $urlKeys = explode('/', $parameterOrder);
         } else {
             // default static whitelist for url parameter keys
             $urlKeys = ['mod', 'ctrl', 'action', 'id', 'type'];
         }
         /*
          * This turns the indexed url parameters array into a named one.
          * [0]=> "news"  to  [mod]    => "news"
          * [1]=> "show"  to  [action] => "show"
          * [2]=> "2"     to  [id]     => "2"
          */
         $urlData = \Koch\Functions\Functions::arrayUnequalCombine($urlKeys, $urlParameters);
         // determine the separator. it defaults to "&amp;" for internal usage in html documents
         $argSeparator = $encode === true ? '&amp;' : '&';
         // Finally: build and return the url!
         return WWW_ROOT . 'index.php?' . http_build_query($urlData, '', $argSeparator);
     }
 }
Beispiel #10
0
 /**
  * formatBacktraceArgument.
  *
  * Performs a type check on the backtrace argument and beautifies it.
  *
  * This formater is based on comments for debug-backtrace in the php manual
  *
  * @link http://de2.php.net/manual/en/function.debug-backtrace.php#30296
  * @link http://de2.php.net/manual/en/function.debug-backtrace.php#47644
  *
  * @param backtraceArgument mixed The argument for type identification and string formatting.
  *
  * @return array With keys 'arg' and 'type'.
  */
 public static function formatBacktraceArgument($argument)
 {
     // do not throw a notice on PHP 5.3 - the constant was added with PHP 5.4 htmlspecialchars()
     defined('ENT_SUBSTITUTE') || define('ENT_SUBSTITUTE', 8);
     $result = [];
     $arg = '';
     $type = '';
     switch (gettype($argument)) {
         case 'boolean':
             $type .= '<span>bool</span>';
             $arg .= $argument ? 'true' : 'false';
             break;
         case 'integer':
             $type .= '<span>int</span>';
             $arg .= $argument;
             break;
         case 'float':
         case 'double':
             $type .= '<span>float/double</span>';
             $arg .= $argument;
             break;
         case 'string':
             $type .= '<span>string</span>';
             $argument = htmlspecialchars($argument, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8');
             $arg .= \Koch\Functions\Functions::shortenString($argument);
             break;
         case 'array':
             $type .= '<span>array</span>';
             $arg .= count($argument);
             break;
         case 'object':
             $type .= '<span>object</span>';
             $arg .= get_class($argument);
             /* @todo use self::getClassProperties($backtraceArgument) */
             break;
         case 'resource':
             $type .= '<span>resource</span>';
             if ($type === 'stream') {
                 $type .= '(stream)';
                 $meta = stream_get_meta_data($argument);
                 if (isset($meta['uri'])) {
                     $type .= htmlspecialchars($meta['uri'], ENT_NOQUOTES, 'UTF-8');
                 }
             }
             $arg .= mb_strstr($argument, '#') . ' - ' . get_resource_type($argument);
             break;
         case 'NULL':
             $type .= '<span>null</span>';
             $arg .= '';
             break;
         default:
             $type .= 'Unknown';
             $arg .= 'Unknown';
     }
     return compact('arg', 'type');
 }
Beispiel #11
0
 /**
  * Gets a Config Value or sets a default value.
  *
  * @example
  * Usage for one default variable:
  * self::getConfigValue('items_newswidget', '8');
  * Gets the value for the key items_newswidget from the moduleconfig or sets the value to 8.
  *
  * Usage for two default variables:
  * self::getConfigValue('items_newswidget', $_GET['numberNews'], '8');
  * Gets the value for the key items_newswidget from the moduleconfig or sets the value
  * incomming via GET, if nothing is incomming, sets the default value of 8.
  *
  * @param string $keyname     The keyname to find in the array.
  * @param mixed  $default_one A default value returned, when keyname was not found.
  * @param mixed  $default_two A default value returned, when keyname was not found and default_one is null.
  *
  * @return mixed
  */
 public static function getConfigValue($keyname, $default_one = null, $default_two = null)
 {
     // if we don't have a moduleconfig array yet, get it
     if (self::$moduleconfig === null) {
         self::$moduleconfig = self::getModuleConfig();
     }
     // try a lookup of the value by keyname
     $value = \Koch\Functions\Functions::array_find_element_by_key($keyname, self::$moduleconfig);
     // return value or default
     if (empty($value) === false) {
         return $value;
     } elseif ($default_one !== null) {
         return $default_one;
     } elseif ($default_two !== null) {
         return $default_two;
     } else {
         return;
     }
 }
Beispiel #12
0
/**
 * Smarty plugin.
 *
 * Type:     modifier<br>
 * Name:     duration<br>
 * Date:     Oct 07, 2008
 * Purpose:  show distanceOfTimeInWords from current timestamp to string timestamp
 * Input:
 * Example:  {$timestamp|duration}
 *
 * @param string
 *
 * @return string
 */
function Smarty_modifier_duration($toTimestamp)
{
    return \Koch\Functions\Functions::distanceOfTimeInWords(time(), $toTimestamp, false);
}
Beispiel #13
0
Datei: Debug.php Projekt: ksst/kf
 /**
  * The method
  * - lists all currently included and required files
  * - counts all includes files
  * - calculates the total size (combined filesize) of all inclusions.
  */
 public static function getIncludedFiles($returnArray = false)
 {
     // init vars
     $includedFiles = $files = $result = [];
     $totalSize = 0;
     // fetch all included files
     $files = get_included_files();
     // loop over all included files and sum up filesize
     foreach ($files as $file) {
         // if system under test, skip virtual file system files,
         // as they might be already deleted by tearDown() methods.
         if (defined('UNIT_TEST_RUN') or UNIT_TEST_RUN) {
             if (stripos($file, 'vfs:/') !== false) {
                 continue;
             }
         }
         $size = filesize($file);
         $includedFiles[] = ['name' => $file, 'size' => $size];
         $totalSize += $size;
     }
     $result = ['count' => count($files), 'size' => \Koch\Functions\Functions::getSize($totalSize), 'files' => $includedFiles];
     return $returnArray === true ? $result : self::printR($result);
 }
Beispiel #14
0
/**
 * Smarty plugin.
 *
 * Type:     modifier<br>
 * Name:     duration<br>
 * Date:     Oct 07, 2008
 * Purpose:  show format_seconds_to_shortstring from current timestamp in seconds
 * Input:
 *
 * Example:  {$seconds|formatseconds}
 *
 * @param string
 *
 * @return string
 */
function smarty_modifier_formatseconds($seconds)
{
    return \Koch\Functions\Functions::formatSecondsToShortstring($seconds);
}
Beispiel #15
0
Datei: Apc.php Projekt: ksst/kf
 /**
  * Get stats and usage Informations for display from APC
  * 1. Shared Memory Allocation
  * 2. Cache Infos / Meta-Data.
  */
 public function stats()
 {
     $info = [];
     // Retrieve APC Version
     $info['version'] = phpversion('apc');
     $info['phpversion'] = phpversion();
     /*
      * ========================================================
      *   Retrieves APC's Shared Memory Allocation information
      * ========================================================
      */
     $info['sma_info'] = [];
     if (true === function_exists('apc_sma_info')) {
         $info['sma_info'] = apc_sma_info(true);
         // Calculate "APC Memory Size" (Number of Segments * Size of Segment)
         $memsize = $info['sma_info']['num_seg'] * $info['sma_info']['seg_size'];
         $info['sma_info']['mem_size'] = $memsize;
         // Calculate "APC Memory Usage" ( mem_size - avail_mem )
         $memusage = $info['sma_info']['mem_size'] - $info['sma_info']['avail_mem'];
         $info['sma_info']['mem_used'] = $memusage;
         // Calculate "APC Free Memory Percentage" ( mem_size*100/mem_used )
         $memsize_total = $info['sma_info']['avail_mem'] * 100;
         $avail_mem_percent = sprintf('(%.1f%%)', $memsize_total / $info['sma_info']['mem_size']);
         $info['sma_info']['mem_avail_percentage'] = $avail_mem_percent;
     }
     if (true === function_exists('apc_cache_info')) {
         // Retrieves cached information and meta-data from APC's data store
         $info['cache_info'] = apc_cache_info();
         #\Koch\Debug\Debug::printR(apc_cache_info());
         $info['cache_info']['cached_files'] = count($info['cache_info']['cache_list']);
         $info['cache_info']['deleted_files'] = count($info['cache_info']['deleted_list']);
         /*
          * ========================================================
          *   System Cache Informations
          * ========================================================
          */
         $info['system_cache_info'] = apc_cache_info('system', false);
         // set "false" for details
         // Calculate "APC Hit Rate Percentage"
         $hits = $info['system_cache_info']['num_hits'] + $info['system_cache_info']['num_misses'];
         // div by zero fix
         if ($hits === 0) {
             $hits = 1;
         }
         $hit_rate_percentage = $info['system_cache_info']['num_hits'] * 100 / $hits;
         $info['system_cache_info']['hit_rate_percentage'] = sprintf('(%.1f%%)', $hit_rate_percentage);
         // Calculate "APC Miss Rate Percentage"
         $miss_percentage = $info['system_cache_info']['num_misses'] * 100 / $hits;
         $info['system_cache_info']['miss_rate_percentage'] = sprintf('(%.1f%%)', $miss_percentage);
         $info['system_cache_info']['files_cached'] = count($info['system_cache_info']['cache_list']);
         $info['system_cache_info']['files_deleted'] = count($info['system_cache_info']['deleted_list']);
         // Request Rate (hits, misses) / cache requests/second
         $start_time = time() - $info['system_cache_info']['start_time'];
         // div by zero fix
         if ($start_time === 0) {
             $start_time = 1;
         }
         $rate = ($info['system_cache_info']['num_hits'] + $info['system_cache_info']['num_misses']) / $start_time;
         $info['system_cache_info']['req_rate'] = sprintf('%.2f', $rate);
         $hit_rate = $info['system_cache_info']['num_hits'] / $start_time;
         $info['system_cache_info']['hit_rate'] = sprintf('%.2f', $hit_rate);
         $miss_rate = $info['system_cache_info']['num_misses'] / $start_time;
         $info['system_cache_info']['miss_rate'] = sprintf('%.2f', $miss_rate);
         $insert_rate = $info['system_cache_info']['num_inserts'] / $start_time;
         $info['system_cache_info']['insert_rate'] = sprintf('%.2f', $insert_rate);
         // size
         if (isset($info['system_cache_info']['mem_size']) and $info['system_cache_info']['mem_size'] > 0) {
             $info['system_cache_info']['size_files'] = Functions::getSize($info['system_cache_info']['mem_size']);
         } else {
             $info['system_cache_info']['size_files'] = 0;
         }
     }
     $info['settings'] = ini_get_all('apc');
     /*
      * ini_get_all array mod: for each accessvalue
      * add the name of the PHP ACCESS CONSTANTS as 'accessname'
      * @todo: cleanup?
      */
     foreach ($info['settings'] as $key => $value) {
         foreach ($value as $key2 => $value2) {
             if ($key2 === 'access') {
                 $name = '';
                 // accessvalue => constantname
                 if ($value2 === '1') {
                     $name = 'PHP_INI_USER';
                 }
                 if ($value2 === '2') {
                     $name = 'PHP_INI_PERDIR';
                 }
                 if ($value2 === '4') {
                     $name = 'PHP_INI_SYSTEM';
                 }
                 if ($value2 === '7') {
                     $name = 'PHP_INI_ALL';
                 }
                 // add accessname to the original array
                 $info['settings'][$key]['accessname'] = $name;
                 unset($name);
             }
         }
     }
     #$info['sma_info']['size_vars']  = Functions::getsize($cache_user['mem_size']);
     return $info;
 }