mp-wp_genesis 1 <?php
mp-wp_genesis 2 /**
mp-wp_genesis 3 * general.php
mp-wp_genesis 4 *
mp-wp_genesis 5 * @package MCManager.includes
mp-wp_genesis 6 * @author Moxiecode
mp-wp_genesis 7 */
mp-wp_genesis 8
mp-wp_genesis 9 @error_reporting(E_ALL ^ E_NOTICE);
mp-wp_genesis 10 $config = array();
mp-wp_genesis 11
mp-wp_genesis 12 require_once(dirname(__FILE__) . "/../classes/utils/Logger.php");
mp-wp_genesis 13 require_once(dirname(__FILE__) . "/../classes/utils/JSON.php");
mp-wp_genesis 14 require_once(dirname(__FILE__) . "/../config.php");
mp-wp_genesis 15 require_once(dirname(__FILE__) . "/../classes/SpellChecker.php");
mp-wp_genesis 16
mp-wp_genesis 17 if (isset($config['general.engine']))
mp-wp_genesis 18 require_once(dirname(__FILE__) . "/../classes/" . $config["general.engine"] . ".php");
mp-wp_genesis 19
mp-wp_genesis 20 /**
mp-wp_genesis 21 * Returns an request value by name without magic quoting.
mp-wp_genesis 22 *
mp-wp_genesis 23 * @param String $name Name of parameter to get.
mp-wp_genesis 24 * @param String $default_value Default value to return if value not found.
mp-wp_genesis 25 * @return String request value by name without magic quoting or default value.
mp-wp_genesis 26 */
mp-wp_genesis 27 function getRequestParam($name, $default_value = false, $sanitize = false) {
mp-wp_genesis 28 if (!isset($_REQUEST[$name]))
mp-wp_genesis 29 return $default_value;
mp-wp_genesis 30
mp-wp_genesis 31 if (is_array($_REQUEST[$name])) {
mp-wp_genesis 32 $newarray = array();
mp-wp_genesis 33
mp-wp_genesis 34 foreach ($_REQUEST[$name] as $name => $value)
mp-wp_genesis 35 $newarray[formatParam($name, $sanitize)] = formatParam($value, $sanitize);
mp-wp_genesis 36
mp-wp_genesis 37 return $newarray;
mp-wp_genesis 38 }
mp-wp_genesis 39
mp-wp_genesis 40 return formatParam($_REQUEST[$name], $sanitize);
mp-wp_genesis 41 }
mp-wp_genesis 42
mp-wp_genesis 43 function &getLogger() {
mp-wp_genesis 44 global $mcLogger, $man;
mp-wp_genesis 45
mp-wp_genesis 46 if (isset($man))
mp-wp_genesis 47 $mcLogger = $man->getLogger();
mp-wp_genesis 48
mp-wp_genesis 49 if (!$mcLogger) {
mp-wp_genesis 50 $mcLogger = new Moxiecode_Logger();
mp-wp_genesis 51
mp-wp_genesis 52 // Set logger options
mp-wp_genesis 53 $mcLogger->setPath(dirname(__FILE__) . "/../logs");
mp-wp_genesis 54 $mcLogger->setMaxSize("100kb");
mp-wp_genesis 55 $mcLogger->setMaxFiles("10");
mp-wp_genesis 56 $mcLogger->setFormat("{time} - {message}");
mp-wp_genesis 57 }
mp-wp_genesis 58
mp-wp_genesis 59 return $mcLogger;
mp-wp_genesis 60 }
mp-wp_genesis 61
mp-wp_genesis 62 function debug($msg) {
mp-wp_genesis 63 $args = func_get_args();
mp-wp_genesis 64
mp-wp_genesis 65 $log = getLogger();
mp-wp_genesis 66 $log->debug(implode(', ', $args));
mp-wp_genesis 67 }
mp-wp_genesis 68
mp-wp_genesis 69 function info($msg) {
mp-wp_genesis 70 $args = func_get_args();
mp-wp_genesis 71
mp-wp_genesis 72 $log = getLogger();
mp-wp_genesis 73 $log->info(implode(', ', $args));
mp-wp_genesis 74 }
mp-wp_genesis 75
mp-wp_genesis 76 function error($msg) {
mp-wp_genesis 77 $args = func_get_args();
mp-wp_genesis 78
mp-wp_genesis 79 $log = getLogger();
mp-wp_genesis 80 $log->error(implode(', ', $args));
mp-wp_genesis 81 }
mp-wp_genesis 82
mp-wp_genesis 83 function warn($msg) {
mp-wp_genesis 84 $args = func_get_args();
mp-wp_genesis 85
mp-wp_genesis 86 $log = getLogger();
mp-wp_genesis 87 $log->warn(implode(', ', $args));
mp-wp_genesis 88 }
mp-wp_genesis 89
mp-wp_genesis 90 function fatal($msg) {
mp-wp_genesis 91 $args = func_get_args();
mp-wp_genesis 92
mp-wp_genesis 93 $log = getLogger();
mp-wp_genesis 94 $log->fatal(implode(', ', $args));
mp-wp_genesis 95 }
mp-wp_genesis 96
mp-wp_genesis 97 ?>