コード例 #1
0
 /**
  * Upgrade outdated site settings
  */
 function updateSite()
 {
     self::$arySettings = array('tracking_code' => '', 'site_id' => get_option('wp-piwik_siteid', NULL), 'last_tracking_code_update' => 0, 'dashboard_revision' => get_option('wp-piwik_dashboardid', 0));
     self::$aryGlobalSettings['last_settings_update'] = time();
     // Remove deprecated option values
     $aryRemoveOptions = array('wp-piwik_siteid', 'wp-piwik_404', 'wp-piwik_scriptupdate', 'wp-piwik_dashboardid', 'wp-piwik_jscode');
     foreach ($aryRemoveOptions as $strRemoveOption) {
         delete_option($strRemoveOption);
     }
     // Save upgraded or default settings
     self::saveSettings();
     // Reload settings
     self::loadSettings();
 }
コード例 #2
0
<?php

require '../../../wp-load.php';
$arySettings = wp_piwik::loadSettings();
/* PIWIK PROXY SCRIPT */
/* 
 == Description ==
 This script allows to track statistics using Piwik, without revealing the
 Piwik Server URL. This is useful for users who track multiple websites 
 in the same Piwik server, but don't want to show in the source code of all tracked 
 websites the Piwik server 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://piwik-server.com/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://piwik-server.com/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.