diff options
author | diosmosis <benakamoorthi@fastmail.fm> | 2014-06-19 06:52:26 +0400 |
---|---|---|
committer | diosmosis <benakamoorthi@fastmail.fm> | 2014-06-19 06:52:26 +0400 |
commit | 9512794a352c84dcc5dd11d69d2e5ceb23e75dc9 (patch) | |
tree | b22ea67987bf155efcada28c659eca04bb474961 /js | |
parent | f169ee42e8bc15ffa63b5589d16280aa10e88ee1 (diff) |
Move tracker proxy logic in js/index.php to js/tracker.php & allow the removal of the comment header in piwik.js (includes test). Also remove @group from static file serve test & fix bug in modified _readfile() proxy.
Diffstat (limited to 'js')
-rw-r--r-- | js/index.php | 31 | ||||
-rw-r--r-- | js/tracker.php | 46 |
2 files changed, 48 insertions, 29 deletions
diff --git a/js/index.php b/js/index.php index 4eece69c7b..b51408b428 100644 --- a/js/index.php +++ b/js/index.php @@ -5,33 +5,6 @@ * @link http://piwik.org * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later */ -use Piwik\ProxyHttp; +define("PIWIK_KEEP_JS_TRACKER_COMMENT", 1); -/** - * Tracker proxy - */ -if($_SERVER['REQUEST_METHOD'] == 'POST' || !empty($_SERVER['QUERY_STRING'])) { - include '../piwik.php'; - exit; -} - -/** - * piwik.js proxy - * - * @see core/Piwik.php - */ -define('PIWIK_INCLUDE_PATH', '..'); -define('PIWIK_DOCUMENT_ROOT', '..'); -define('PIWIK_USER_PATH', '..'); - -require_once PIWIK_INCLUDE_PATH . '/libs/upgradephp/upgrade.php'; -require_once PIWIK_INCLUDE_PATH . '/core/Loader.php'; - -$file = '../piwik.js'; - - -$daysExpireFarFuture = 10; - -ProxyHttp::serverStaticFile($file, "application/javascript; charset=UTF-8", $daysExpireFarFuture); - -exit; +require_once __DIR__ . '/tracker.php';
\ No newline at end of file diff --git a/js/tracker.php b/js/tracker.php new file mode 100644 index 0000000000..55b8782f65 --- /dev/null +++ b/js/tracker.php @@ -0,0 +1,46 @@ +<?php +/** + * Piwik - free/libre analytics platform + * + * @link http://piwik.org + * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later + */ +use Piwik\ProxyHttp; + +/** + * Tracker proxy + */ +if($_SERVER['REQUEST_METHOD'] == 'POST' || !empty($_SERVER['QUERY_STRING'])) { + include '../piwik.php'; + exit; +} + +/** + * piwik.js proxy + * + * @see core/Piwik.php + */ +define('PIWIK_INCLUDE_PATH', '..'); +define('PIWIK_DOCUMENT_ROOT', '..'); +define('PIWIK_USER_PATH', '..'); + +require_once PIWIK_INCLUDE_PATH . '/libs/upgradephp/upgrade.php'; +require_once PIWIK_INCLUDE_PATH . '/core/Loader.php'; + +$file = '../piwik.js'; + +$daysExpireFarFuture = 10; + +$compressFileSuffix = false; +$byteStart = $byteEnd = false; +if (!defined("PIWIK_KEEP_JS_TRACKER_COMMENT") + || !PIWIK_KEEP_JS_TRACKER_COMMENT +) { + $byteStart = 369; // length of comment header in bytes + $compressFileSuffix = '.nocomment'; +} + +ProxyHttp::serverStaticFile($file, "application/javascript; charset=UTF-8", $daysExpireFarFuture, $byteStart, $byteEnd, + $compressFileSuffix); + +exit;
\ No newline at end of file |