Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Steur <thomas.steur@googlemail.com>2014-09-30 09:37:32 +0400
committerThomas Steur <thomas.steur@googlemail.com>2014-09-30 09:37:32 +0400
commita00487b0b841c4b15463b591c7f62176c4b84d15 (patch)
tree6eb893ce356a4740e044c9cdadaf84ffb2095b9d /core/Common.php
parent0edef3332289a7cbe54b58084b967907d1086d29 (diff)
coding style fixes, some PHPStorm inspection fixes, improved readability of code, few refactorings, all as part of our code cleanup strategy
Diffstat (limited to 'core/Common.php')
-rw-r--r--core/Common.php29
1 files changed, 20 insertions, 9 deletions
diff --git a/core/Common.php b/core/Common.php
index d9ddf0be25..bf18343bd3 100644
--- a/core/Common.php
+++ b/core/Common.php
@@ -362,10 +362,13 @@ class Common
*/
private static function undoMagicQuotes($value)
{
- return version_compare(PHP_VERSION, '5.4', '<')
- && get_magic_quotes_gpc()
- ? stripslashes($value)
- : $value;
+ if (version_compare(PHP_VERSION, '5.4', '<') &&
+ get_magic_quotes_gpc()) {
+
+ return stripslashes($value);
+ }
+
+ return $value;
}
/**
@@ -375,8 +378,7 @@ class Common
*/
public static function sanitizeLineBreaks($value)
{
- $value = str_replace(array("\n", "\r", "\0"), '', $value);
- return $value;
+ return str_replace(array("\n", "\r", "\0"), '', $value);
}
/**
@@ -406,6 +408,7 @@ class Common
if (is_null($requestArrayToUse)) {
$requestArrayToUse = $_GET + $_POST;
}
+
$varDefault = self::sanitizeInputValues($varDefault);
if ($varType === 'int') {
// settype accepts only integer
@@ -469,6 +472,7 @@ class Common
}
settype($value, $varType);
}
+
return $value;
}
@@ -496,14 +500,17 @@ class Common
public static function hash($str, $raw_output = false)
{
static $hashAlgorithm = null;
+
if (is_null($hashAlgorithm)) {
$hashAlgorithm = @Config::getInstance()->General['hash_algorithm'];
}
if ($hashAlgorithm) {
$hash = @hash($hashAlgorithm, $str, $raw_output);
- if ($hash !== false)
+ if ($hash !== false) {
+
return $hash;
+ }
}
return md5($str, $raw_output);
@@ -520,7 +527,7 @@ class Common
public static function getRandomString($length = 16, $alphabet = "abcdefghijklmnoprstuvwxyz0123456789")
{
$chars = $alphabet;
- $str = '';
+ $str = '';
list($usec, $sec) = explode(" ", microtime());
$seed = ((float)$sec + (float)$usec) * 100000;
@@ -530,6 +537,7 @@ class Common
$rand_key = mt_rand(0, strlen($chars) - 1);
$str .= substr($chars, $rand_key, 1);
}
+
return str_shuffle($str);
}
@@ -571,6 +579,7 @@ class Common
) {
throw new Exception("visitorId is expected to be a " . Tracker::LENGTH_HEX_ID_STRING . " hex char string");
}
+
return self::hex2bin($id);
}
@@ -584,6 +593,7 @@ class Common
{
require_once PIWIK_INCLUDE_PATH . '/libs/PiwikTracker/PiwikTracker.php';
$userIdHashed = \PiwikTracker::getUserIdHashed($userId);
+
return self::convertVisitorIdToBin($userIdHashed);
}
@@ -730,6 +740,7 @@ class Common
if ($includeInternalCodes) {
return array_merge($countriesList, $extras);
}
+
return $countriesList;
}
@@ -1054,7 +1065,7 @@ class Common
public static function sendHeader($header, $replace = true)
{
// don't send header in CLI mode
- if(!Common::isPhpCliMode() and !headers_sent()) {
+ if (!Common::isPhpCliMode() and !headers_sent()) {
header($header, $replace);
}
}