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
path: root/misc
diff options
context:
space:
mode:
authorKyleK <kylekatarnls@gmail.com>2014-09-14 16:18:01 +0400
committerKyleK <kylekatarnls@gmail.com>2014-09-14 16:18:01 +0400
commita9fb8c7b89def45a3754fb383ce3e76488ed7156 (patch)
treef5d0e22bc8698294367c356db2ee1cc1e12eef48 /misc
parent37599df8123f7f2678b55c42b139d619c0a4d3b9 (diff)
Replace header() with Common::sendHeader() when possible
Diffstat (limited to 'misc')
-rwxr-xr-xmisc/others/geoipUpdateRows.php4
-rw-r--r--misc/proxy-hide-piwik-url/piwik.php31
2 files changed, 23 insertions, 12 deletions
diff --git a/misc/others/geoipUpdateRows.php b/misc/others/geoipUpdateRows.php
index df480d395d..b90a2d376c 100755
--- a/misc/others/geoipUpdateRows.php
+++ b/misc/others/geoipUpdateRows.php
@@ -89,9 +89,7 @@ if (!Common::isPhpCliMode()) {
function geoipUpdateError($message)
{
Log::error($message);
- if (!Common::isPhpCliMode()) {
- @header('HTTP/1.1 500 Internal Server Error', $replace = true, $responseCode = 500);
- }
+ Common::sendHeader('HTTP/1.1 500 Internal Server Error', $replace = true, $responseCode = 500);
exit;
}
diff --git a/misc/proxy-hide-piwik-url/piwik.php b/misc/proxy-hide-piwik-url/piwik.php
index 846a82313b..19493aeccc 100644
--- a/misc/proxy-hide-piwik-url/piwik.php
+++ b/misc/proxy-hide-piwik-url/piwik.php
@@ -24,6 +24,19 @@ $TOKEN_AUTH = 'xyz';
// Maximum time, in seconds, to wait for the Piwik server to return the 1*1 GIF
$timeout = 5;
+function sendHeader($header, $replace = true)
+{
+ headers_sent() || header($head, $replace);
+}
+
+function arrayValue($array, $key, $value = null)
+{
+ if (!empty($array[$key])) {
+ $value = $array[$key];
+ }
+ return $value;
+}
+
// DO NOT MODIFY BELOW
// ---------------------------
// 1) PIWIK.JS PROXY: No _GET parameter, we serve the JS file
@@ -40,18 +53,18 @@ if (empty($_GET)) {
$lastModified = time() - 86400;
// set HTTP response headers
- header('Vary: Accept-Encoding');
+ sendHeader('Vary: Accept-Encoding');
// Returns 304 if not modified since
if (!empty($modifiedSince) && $modifiedSince < $lastModified) {
- header(sprintf("%s 304 Not Modified", $_SERVER['SERVER_PROTOCOL']));
+ sendHeader(sprintf("%s 304 Not Modified", $_SERVER['SERVER_PROTOCOL']));
} else {
- header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
- @header('Content-Type: application/javascript; charset=UTF-8');
+ sendHeader('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
+ sendHeader('Content-Type: application/javascript; charset=UTF-8');
if ($piwikJs = file_get_contents($PIWIK_URL . 'piwik.js')) {
echo $piwikJs;
} else {
- header($_SERVER['SERVER_PROTOCOL'] . '505 Internal server error');
+ sendHeader($_SERVER['SERVER_PROTOCOL'] . '505 Internal server error');
}
}
exit;
@@ -65,10 +78,10 @@ $url = sprintf("%spiwik.php?cip=%s&token_auth=%s&", $PIWIK_URL, getVisitIp(), $T
foreach ($_GET as $key => $value) {
$url .= $key . '=' . urlencode($value) . '&';
}
-header("Content-Type: image/gif");
+sendHeader("Content-Type: image/gif");
$stream_options = array('http' => array(
- 'user_agent' => @$_SERVER['HTTP_USER_AGENT'],
- 'header' => sprintf("Accept-Language: %s\r\n", @str_replace(array("\n", "\t", "\r"), "", $_SERVER['HTTP_ACCEPT_LANGUAGE'])),
+ 'user_agent' => arrayValue($_SERVER, 'HTTP_USER_AGENT', ''),
+ 'header' => sprintf("Accept-Language: %s\r\n", str_replace(array("\n", "\t", "\r"), "", arrayValue($_SERVER, 'HTTP_ACCEPT_LANGUAGE', ''))),
'timeout' => $timeout
));
$ctx = stream_context_create($stream_options);
@@ -88,5 +101,5 @@ function getVisitIp()
return $_SERVER[$ipKey];
}
}
- return @$_SERVER['REMOTE_ADDR'];
+ return arrayValue($_SERVER, 'REMOTE_ADDR');
}