diff options
author | mattab <matthieu.aubry@gmail.com> | 2013-03-28 03:42:39 +0400 |
---|---|---|
committer | mattab <matthieu.aubry@gmail.com> | 2013-03-28 03:42:40 +0400 |
commit | ae4b03163792f0b6e933933e5d37df87dc3fd566 (patch) | |
tree | d1d7510a9728f587d3d63ebd03e4ecf3d904838b /misc/proxy-hide-piwik-url | |
parent | 158c2150f5f2e13ece459b8d131244c11b763997 (diff) |
Mass conversion of all files to the newly agreed coding standard: PSR 1/2
Converting Piwik core source files, PHP, JS, TPL, CSS
More info: http://piwik.org/participate/coding-standards/
Diffstat (limited to 'misc/proxy-hide-piwik-url')
-rw-r--r-- | misc/proxy-hide-piwik-url/piwik.php | 60 |
1 files changed, 30 insertions, 30 deletions
diff --git a/misc/proxy-hide-piwik-url/piwik.php b/misc/proxy-hide-piwik-url/piwik.php index 9bce43bb2b..eabac8c097 100644 --- a/misc/proxy-hide-piwik-url/piwik.php +++ b/misc/proxy-hide-piwik-url/piwik.php @@ -29,45 +29,45 @@ $timeout = 5; // --------------------------- // 1) PIWIK.JS PROXY: No _GET parameter, we serve the JS file if (empty($_GET)) { - $modifiedSince = false; - if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])) { - $modifiedSince = $_SERVER['HTTP_IF_MODIFIED_SINCE']; - // strip any trailing data appended to header - if (false !== ($semicolon = strpos($modifiedSince, ';'))) { - $modifiedSince = strtotime(substr($modifiedSince, 0, $semicolon)); - } - } - // Re-download the piwik.js once a day maximum - $lastModified = time()-86400; + $modifiedSince = false; + if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])) { + $modifiedSince = $_SERVER['HTTP_IF_MODIFIED_SINCE']; + // strip any trailing data appended to header + if (false !== ($semicolon = strpos($modifiedSince, ';'))) { + $modifiedSince = strtotime(substr($modifiedSince, 0, $semicolon)); + } + } + // Re-download the piwik.js once a day maximum + $lastModified = time() - 86400; - // set HTTP response headers - header('Vary: Accept-Encoding'); + // set HTTP response headers + header('Vary: Accept-Encoding'); - // Returns 304 if not modified since - if (!empty($modifiedSince) && $modifiedSince < $lastModified) { - header(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'); - if ($piwikJs = file_get_contents($PIWIK_URL.'piwik.js')) { - echo $piwikJs; - } else { - header($_SERVER['SERVER_PROTOCOL'] . '505 Internal server error'); - } - } - exit; + // Returns 304 if not modified since + if (!empty($modifiedSince) && $modifiedSince < $lastModified) { + header(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'); + if ($piwikJs = file_get_contents($PIWIK_URL . 'piwik.js')) { + echo $piwikJs; + } else { + header($_SERVER['SERVER_PROTOCOL'] . '505 Internal server error'); + } + } + exit; } // 2) PIWIK.PHP PROXY: GET parameters found, this is a tracking request, we redirect it to Piwik $url = sprintf("%spiwik.php?cip=%s&token_auth=%s&", $PIWIK_URL, @$_SERVER['REMOTE_ADDR'], $TOKEN_AUTH); -foreach($_GET as $key=>$value) { - $url .= $key .'='.urlencode($value).'&'; +foreach ($_GET as $key => $value) { + $url .= $key . '=' . urlencode($value) . '&'; } header("Content-Type: image/gif"); $stream_options = array('http' => array( - 'user_agent' => @$_SERVER['HTTP_USER_AGENT'], - 'header' => sprintf("Accept-Language: %s%s\r\n", @str_replace(array("\n","\t","\r"), "", $_SERVER['HTTP_ACCEPT_LANGUAGE'])), - 'timeout' => $timeout + 'user_agent' => @$_SERVER['HTTP_USER_AGENT'], + 'header' => sprintf("Accept-Language: %s%s\r\n", @str_replace(array("\n", "\t", "\r"), "", $_SERVER['HTTP_ACCEPT_LANGUAGE'])), + 'timeout' => $timeout )); $ctx = stream_context_create($stream_options); echo file_get_contents($url, 0, $ctx); |