Completed
Push — master ( 694826...a7f5ef )
by Ingo
26:11 queued 15:49
created

general.php ➔ info()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %
Metric Value
cc 1
eloc 4
nc 1
nop 1
dl 0
loc 6
rs 9.4285
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);
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
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) {
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[$name] = $value;
37
38
		return $newarray;
39
	}
40
41
	return $_REQUEST[$name];
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) {
0 ignored issues
show
Unused Code introduced by
The parameter $msg is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
64
	$args = func_get_args();
65
66
	$log = getLogger();
67
	$log->debug(implode(', ', $args));
68
}
69
70
function info($msg) {
0 ignored issues
show
Unused Code introduced by
The parameter $msg is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
71
	$args = func_get_args();
72
73
	$log = getLogger();
74
	$log->info(implode(', ', $args));
75
}
76
77
function error($msg) {
0 ignored issues
show
Unused Code introduced by
The parameter $msg is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
78
	$args = func_get_args();
79
80
	$log = getLogger();
81
	$log->error(implode(', ', $args));
82
}
83
84
function warn($msg) {
0 ignored issues
show
Unused Code introduced by
The parameter $msg is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
85
	$args = func_get_args();
86
87
	$log = getLogger();
88
	$log->warn(implode(', ', $args));
89
}
90
91
function fatal($msg) {
0 ignored issues
show
Unused Code introduced by
The parameter $msg is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
92
	$args = func_get_args();
93
94
	$log = getLogger();
95
	$log->fatal(implode(', ', $args));
96
}
97
98
?>
0 ignored issues
show
Best Practice introduced by
It is not recommended to use PHP's closing tag ?> in files other than templates.

Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.

A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.

Loading history...
99