diff options
author | Matthieu Napoli <matthieu@mnapoli.fr> | 2014-12-05 05:20:43 +0300 |
---|---|---|
committer | Matthieu Napoli <matthieu@mnapoli.fr> | 2014-12-05 05:20:43 +0300 |
commit | 80ab3b99438bc0d64a9c689e5ad71f585b3c0227 (patch) | |
tree | 51756aa5ac66272e49802b2da9ec3be17c62fd63 /misc | |
parent | e0871a1ddbd3cc803cc778484b334789e64cfd44 (diff) | |
parent | 3d8f3ce87b8dc58934717792576530dd3c457bfb (diff) |
Merge branch 'master' into log-refactoring-1
Conflicts:
CHANGELOG.md
Diffstat (limited to 'misc')
-rwxr-xr-x | misc/log-analytics/import_logs.py | 6 | ||||
-rw-r--r-- | misc/others/cli-script-bootstrap.php | 2 | ||||
-rwxr-xr-x | misc/others/geoipUpdateRows.php | 6 | ||||
-rw-r--r-- | misc/proxy-hide-piwik-url/README.md | 56 | ||||
-rw-r--r-- | misc/proxy-hide-piwik-url/piwik.php | 105 |
5 files changed, 13 insertions, 162 deletions
diff --git a/misc/log-analytics/import_logs.py b/misc/log-analytics/import_logs.py index 6674e2f2fa..7b46ea3e11 100755 --- a/misc/log-analytics/import_logs.py +++ b/misc/log-analytics/import_logs.py @@ -1539,7 +1539,7 @@ class Parser(object): file = sys.stdin else: if not os.path.exists(filename): - print >> sys.stderr, 'File %s does not exist' % filename + print >> sys.stderr, "\n=====> Warning: File %s does not exist <=====" % filename return else: if filename.endswith('.bz2'): @@ -1610,6 +1610,10 @@ class Parser(object): except BaseFormatException: hit.path, _, hit.query_string = hit.full_path.partition(config.options.query_string_delimiter) + # IIS detaults to - when there is no query string, but we want empty string + if hit.query_string == '-': + hit.query_string = '' + hit.extension = hit.path.rsplit('.')[-1].lower() try: diff --git a/misc/others/cli-script-bootstrap.php b/misc/others/cli-script-bootstrap.php index f26d45abcc..9f89cfe319 100644 --- a/misc/others/cli-script-bootstrap.php +++ b/misc/others/cli-script-bootstrap.php @@ -34,7 +34,5 @@ require_once PIWIK_INCLUDE_PATH . '/core/Loader.php'; $GLOBALS['PIWIK_TRACKER_DEBUG'] = false; define('PIWIK_ENABLE_DISPATCH', false); -Config::getInstance()->log['log_writers'][] = 'screen'; -Config::getInstance()->log['log_level'] = 'VERBOSE'; Config::getInstance()->log['string_message_format'] = "%message%"; FrontController::getInstance()->init();
\ No newline at end of file diff --git a/misc/others/geoipUpdateRows.php b/misc/others/geoipUpdateRows.php index 09ae69d3d4..23e72fc413 100755 --- a/misc/others/geoipUpdateRows.php +++ b/misc/others/geoipUpdateRows.php @@ -23,6 +23,12 @@ if (!Common::isPhpCliMode()) { Log::error('[error] You must be logged in as Super User to run this script. Please login in to Piwik and refresh this page.'); exit; } +} + +Log::getInstance()->setLogLevel(Log::VERBOSE); +Log::getInstance()->addLogWriter('screen'); + +if (!Common::isPhpCliMode()) { // the 'start' query param will be supplied by the AJAX requests, so if it's not there, the // user is viewing the page in the browser. if (Common::getRequestVar('start', false) === false) { diff --git a/misc/proxy-hide-piwik-url/README.md b/misc/proxy-hide-piwik-url/README.md index 8c726b20ac..cf2bebf1e4 100644 --- a/misc/proxy-hide-piwik-url/README.md +++ b/misc/proxy-hide-piwik-url/README.md @@ -1,55 +1,3 @@ -## Piwik Proxy Hide URL -This script allows to track statistics using Piwik, without revealing the -Piwik Server URL. This is useful for users who track multiple websites -on the same Piwik server, but don't want to show the Piwik server URL in -the source code of all tracked websites. +# Piwik Proxy Hide URL -### Requirements -To run this properly you will need - - * Piwik server latest version - * One or several website(s) to track with this Piwik server, for example http://trackedsite.com - * The website to track must run on a server with PHP5 support - * In your php.ini you must check that the following is set: `allow_url_fopen = On` - -### How to track trackedsite.com in your Piwik without revealing the Piwik server URL? - -1. In your Piwik server, login as Super user -2. create a user, set the login for example: "UserTrackingAPI" -3. Assign this user "admin" permission on all websites you wish to track without showing the Piwik URL -4. Copy the "token_auth" for this user, and paste it below in this file, in `$TOKEN_AUTH = "xyz"` -5. In this file, below this help test, edit $PIWIK_URL variable and change http://your-piwik-domain.example.org/piwik/ with the URL to your Piwik server. -6. Upload this modified piwik.php file in the website root directory, for example at: http://trackedsite.com/piwik.php - This file (http://trackedsite.com/piwik.php) will be called by the Piwik Javascript, - instead of calling directly the (secret) Piwik Server URL (http://your-piwik-domain.example.org/piwik/). -7. You now need to add the modified Piwik Javascript Code to the footer of your pages at http://trackedsite.com/ - Go to Piwik > Settings > Websites > Show Javascript Tracking Code. - Copy the Javascript snippet. Then, edit this code and change the last lines to the following: - - ``` - [...] - (function() { - var u="//trackedsite.com/"; - _paq.push(["setTrackerUrl", u+"piwik.php"]); - _paq.push(["setSiteId", "trackedsite-id"]); - var d=document, g=d.createElement("script"), s=d.getElementsByTagName("script")[0]; - g.type="text/javascript"; g.async=true; g.defer=true; g.src=u+"piwik.php"; s.parentNode.insertBefore(g,s); - })(); - </script> - <!-- End Piwik Code --> - ``` - - What's changed in this code snippet compared to the normal Piwik code? - - * the (secret) Piwik URL is now replaced by your website URL - * the "piwik.js" becomes "piwik.php" because this piwik.php proxy script will also display and proxy the Javascript file - * the `<noscript>` part of the code at the end is removed, - since it is not currently used by Piwik, and it contains the (secret) Piwik URL which you want to hide. - * make sure to replace trackedsite-id with your idsite again. - - 8. Paste the modified Piwik Javascript code in your website "trackedsite.com" pages you wish to track. - This modified Javascript Code will then track visits/pages/conversions by calling trackedsite.com/piwik.php - which will then automatically call your (hidden) Piwik Server URL. - 9. Done! - At this stage, example.com should be tracked by your Piwik without showing the Piwik server URL. - Repeat the steps 6, 7 and 8 for each website you wish to track in Piwik. +The proxy script has been moved to [piwik/tracker-proxy](https://github.com/piwik/tracker-proxy). diff --git a/misc/proxy-hide-piwik-url/piwik.php b/misc/proxy-hide-piwik-url/piwik.php deleted file mode 100644 index d1c9e9ca3c..0000000000 --- a/misc/proxy-hide-piwik-url/piwik.php +++ /dev/null @@ -1,105 +0,0 @@ -<?php -/** - * Piwik - free/libre analytics platform - * Piwik Proxy Hide URL - * - * @link http://piwik.org/faq/how-to/#faq_132 - * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later - */ - -// ----- -// Important: read the instructions in README.md or at: -// https://github.com/piwik/piwik/tree/master/misc/proxy-hide-piwik-url#piwik-proxy-hide-url -// ----- - -// Edit the line below, and replace http://your-piwik-domain.example.org/piwik/ -// with your Piwik URL ending with a slash. -// This URL will never be revealed to visitors or search engines. -$PIWIK_URL = 'http://your-piwik-domain.example.org/piwik/'; - -// Edit the line below, and replace xyz by the token_auth for the user "UserTrackingAPI" -// which you created when you followed instructions above. -$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($header, $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 -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; - - // set HTTP response headers - sendHeader('Vary: Accept-Encoding'); - - // Returns 304 if not modified since - if (!empty($modifiedSince) && $modifiedSince < $lastModified) { - sendHeader(sprintf("%s 304 Not Modified", $_SERVER['SERVER_PROTOCOL'])); - } else { - 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 { - sendHeader($_SERVER['SERVER_PROTOCOL'] . '505 Internal server error'); - } - } - exit; -} - -@ini_set('magic_quotes_runtime', 0); - -// 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, getVisitIp(), $TOKEN_AUTH); - -foreach ($_GET as $key => $value) { - $url .= urlencode($key ). '=' . urlencode($value) . '&'; -} -sendHeader("Content-Type: image/gif"); -$stream_options = array('http' => array( - '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); -echo file_get_contents($url, 0, $ctx); - -function getVisitIp() -{ - $matchIp = '/^([0-9]{1,3}\.){3}[0-9]{1,3}$/'; - $ipKeys = array( - 'HTTP_X_FORWARDED_FOR', - 'HTTP_CLIENT_IP', - 'HTTP_CF_CONNECTING_IP', - ); - foreach($ipKeys as $ipKey) { - if (isset($_SERVER[$ipKey]) - && preg_match($matchIp, $_SERVER[$ipKey])) { - return $_SERVER[$ipKey]; - } - } - return arrayValue($_SERVER, 'REMOTE_ADDR'); -} |