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