hide map for Character groups Quest Stations when there are no stations

This commit is contained in:
oliver 2016-04-09 13:44:37 +02:00
commit df14dfafc3
4371 changed files with 1220224 additions and 0 deletions

View file

@ -0,0 +1,17 @@
<?php
// Example file to demonstrate PiwikTracker.php
// See http://piwik.org/docs/tracking-api/
require_once '../../libs/PiwikTracker/PiwikTracker.php';
PiwikTracker::$URL = 'http://localhost/trunk/';
$piwikTracker = new PiwikTracker($idSite = 1);
// You can manually set the Visitor details (resolution, time, plugins)
// See all other ->set* functions available in the PiwikTracker class
$piwikTracker->setResolution(1600, 1400);
// Sends Tracker request via http
$piwikTracker->doTrackPageView('Document title of current page view');
// You can also track Goal conversions
$piwikTracker->doTrackGoal($idGoal = 1, $revenue = 42);
echo 'done';

View file

@ -0,0 +1,32 @@
<?php
use Piwik\API\Request;
use Piwik\FrontController;
define('PIWIK_INCLUDE_PATH', realpath('../..'));
define('PIWIK_USER_PATH', realpath('../..'));
define('PIWIK_ENABLE_DISPATCH', false);
define('PIWIK_ENABLE_ERROR_HANDLER', false);
define('PIWIK_ENABLE_SESSION_START', false);
// if you prefer not to include 'index.php', you must also define here PIWIK_DOCUMENT_ROOT
// and include "libs/upgradephp/upgrade.php" and "core/Loader.php"
require_once PIWIK_INCLUDE_PATH . "/index.php";
require_once PIWIK_INCLUDE_PATH . "/core/API/Request.php";
FrontController::getInstance()->init();
// This inits the API Request with the specified parameters
$request = new Request('
module=API
&method=UserSettings.getResolution
&idSite=7
&date=yesterday
&period=week
&format=XML
&filter_limit=3
&token_auth=anonymous
');
// Calls the API and fetch XML data back
$result = $request->process();
echo $result;

View file

@ -0,0 +1,30 @@
<?php
exit; // REMOVE this line to run the script
// this token is used to authenticate your API request.
// You can get the token on the API page inside your Piwik interface
$token_auth = 'anonymous';
// we call the REST API and request the 100 first keywords for the last month for the idsite=7
$url = "http://demo.piwik.org/";
$url .= "?module=API&method=Referrers.getKeywords";
$url .= "&idSite=7&period=month&date=yesterday";
$url .= "&format=PHP&filter_limit=20";
$url .= "&token_auth=$token_auth";
$fetched = file_get_contents($url);
$content = unserialize($fetched);
// case error
if (!$content) {
print("Error, content fetched = " . $fetched);
}
print("<h1>Keywords for the last month</h1>");
foreach ($content as $row) {
$keyword = htmlspecialchars(html_entity_decode(urldecode($row['label']), ENT_QUOTES), ENT_QUOTES);
$hits = $row['nb_visits'];
print("<b>$keyword</b> ($hits hits)<br>");
}

View file

@ -0,0 +1,39 @@
<?php
/**
* Piwik - Open source web analytics
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
*/
use Piwik\Config;
use Piwik\FrontController;
error_reporting(E_ALL | E_NOTICE);
define('PIWIK_DOCUMENT_ROOT', dirname(__FILE__) == '/' ? '' : dirname(__FILE__) . '/../..');
if (file_exists(PIWIK_DOCUMENT_ROOT . '/bootstrap.php')) {
require_once PIWIK_DOCUMENT_ROOT . '/bootstrap.php';
}
if (!defined('PIWIK_USER_PATH')) {
define('PIWIK_USER_PATH', PIWIK_DOCUMENT_ROOT);
}
if (!defined('PIWIK_INCLUDE_PATH')) {
define('PIWIK_INCLUDE_PATH', PIWIK_DOCUMENT_ROOT);
}
ignore_user_abort(true);
set_time_limit(0);
@date_default_timezone_set('UTC');
require_once PIWIK_INCLUDE_PATH . '/libs/upgradephp/upgrade.php';
require_once PIWIK_INCLUDE_PATH . '/core/testMinimumPhpVersion.php';
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();

View file

@ -0,0 +1,13 @@
Count the download for 'latest.zip' on the 20th March
# cat access.log | grep "20/Mar" | grep "latest.zip" | awk '{print $1}' | sort | uniq | wc -l
Value to be compared with the one given by Piwik in Actions > Downloads
Count the no of hits by referrers, excluding piwik.org as a referer
# cat /var/log/apache2/access.log | awk '{print $11}' | grep -vE "(^"-"$|/dev.piwik.org|/piwik.org)" | sort | uniq -c | sort -rn | head -n20
Count the no of hits by referrers
# cat /var/log/apache2/access.log | awk '{print $11}' | sort | uniq -c | sort -rn | head -n20

View file

@ -0,0 +1,233 @@
<?php
use Piwik\Common;
use Piwik\Config;
use Piwik\Db;
use Piwik\FrontController;
use Piwik\IP;
use Piwik\Log;
use Piwik\Piwik;
use Piwik\Plugins\UserCountry\LocationProvider\GeoIp\Pecl;
use Piwik\Plugins\UserCountry\LocationProvider;
use Piwik\Plugins\UserCountry\LocationProvider\GeoIp\Php;
require_once './cli-script-bootstrap.php';
ini_set("memory_limit", "512M");
$query = "SELECT count(*) FROM " . Common::prefixTable('log_visit');
$count = Db::fetchOne($query);
// when script run via browser, check for Super User & output html page to do conversion via AJAX
if (!Common::isPhpCliMode()) {
try {
Piwik::checkUserHasSuperUserAccess();
} catch (Exception $e) {
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;
}
// 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) {
// output HTML page that runs update via AJAX
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<script type="text/javascript" src="../../libs/jquery/jquery.js"></script>
<script type="text/javascript">
(function ($) {
var count = <?php echo $count; ?>;
var doIteration = function (start) {
if (start >= count) {
return;
}
var end = Math.min(start + 100, count);
$.ajax({
type: 'POST',
url: 'geoipUpdateRows.php',
data: {
start: start,
end: end
},
async: true,
error: function (xhr, status, error) {
$('body')
.append(xhr.responseText)
.append('<div style="color:red"><strong>An error occured!</strong></div>');
},
success: function (response) {
doIteration(end);
$('body').append(response);
var body = $('body')[0];
body.scrollTop = body.scrollHeight;
}
});
};
doIteration(0);
}(jQuery));
</script>
</head>
<body>
</body>
</html>
<?php
exit;
} else {
$start = Common::getRequestVar('start', 0, 'int');
$end = min($count, Common::getRequestVar('end', $count, 'int'));
$limit = $end - $start;
}
} else // command line
{
$start = 0;
$end = $count;
$limit = 1000;
}
function geoipUpdateError($message)
{
Log::error($message);
if (!Common::isPhpCliMode()) {
@header('HTTP/1.1 500 Internal Server Error', $replace = true, $responseCode = 500);
}
exit;
}
// only display notes if on command line (where start will == 0 for that part of script) or on
// first AJAX call by browser
$displayNotes = $start == 0;
// try getting the pecl location provider
$provider = new Pecl();
if (!$provider->isAvailable()) {
if ($displayNotes) {
Log::info("[note] The GeoIP PECL extension is not installed.");
}
$provider = null;
} else {
$workingOrError = $provider->isWorking();
if ($workingOrError !== true) {
if ($displayNotes) {
Log::info("[note] The GeoIP PECL extension is broken: $workingOrError");
}
if (Common::isPhpCliMode()) {
Log::info("[note] Make sure your command line PHP is configured to use the PECL extension.");
}
$provider = null;
}
}
// use php api if pecl extension cannot be used
if (is_null($provider)) {
if ($displayNotes) {
Log::info("[note] Falling back to PHP API. This may become too slow for you. If so, you can read this link on how to install the PECL extension: http://piwik.org/faq/how-to/#faq_164");
}
$provider = new Php();
if (!$provider->isAvailable()) {
if ($displayNotes) {
Log::info("[note] The GeoIP PHP API is not available. This means you do not have a GeoIP location database in your ./misc directory. The database must be named either GeoIP.dat or GeoIPCity.dat based on the type of database it is.");
}
$provider = null;
} else {
$workingOrError = $provider->isWorking();
if ($workingOrError !== true) {
if ($displayNotes) {
Log::info("[note] The GeoIP PHP API is broken: $workingOrError");
}
$provider = null;
}
}
}
if (is_null($provider)) {
geoipUpdateError("\n[error] There is no location provider that can be used with this script. Only the GeoIP PECL module or the GeoIP PHP API can be used at present. Please install and configure one of these first.");
}
$info = $provider->getInfo();
if ($displayNotes) {
Log::info("[note] Found working provider: {$info['id']}");
}
// perform update
$logVisitFieldsToUpdate = array('location_country' => LocationProvider::COUNTRY_CODE_KEY,
'location_region' => LocationProvider::REGION_CODE_KEY,
'location_city' => LocationProvider::CITY_NAME_KEY,
'location_latitude' => LocationProvider::LATITUDE_KEY,
'location_longitude' => LocationProvider::LONGITUDE_KEY);
if ($displayNotes) {
Log::info("\n$count rows to process in " . Common::prefixTable('log_visit')
. " and " . Common::prefixTable('log_conversion') . "...");
}
flush();
for (; $start < $end; $start += $limit) {
$rows = Db::fetchAll("SELECT idvisit, location_ip, " . implode(',', array_keys($logVisitFieldsToUpdate)) . "
FROM " . Common::prefixTable('log_visit') . "
LIMIT $start, $limit");
if (!count($rows)) {
continue;
}
foreach ($rows as $i => $row) {
$fieldsToSet = array();
foreach ($logVisitFieldsToUpdate as $field => $ignore) {
if (empty($fieldsToSet[$field])) {
$fieldsToSet[] = $field;
}
}
// skip if it already has a location
if (empty($fieldsToSet)) {
continue;
}
$ip = IP::N2P($row['location_ip']);
$location = $provider->getLocation(array('ip' => $ip));
if (!empty($location[LocationProvider::COUNTRY_CODE_KEY])) {
$location[LocationProvider::COUNTRY_CODE_KEY] =
strtolower($location[LocationProvider::COUNTRY_CODE_KEY]);
}
$row['location_country'] = strtolower($row['location_country']);
$columnsToSet = array();
$bind = array();
foreach ($logVisitFieldsToUpdate as $column => $locationKey) {
if (!empty($location[$locationKey])
&& $location[$locationKey] != $row[$column]
) {
$columnsToSet[] = $column . ' = ?';
$bind[] = $location[$locationKey];
}
}
if (empty($columnsToSet)) {
continue;
}
$bind[] = $row['idvisit'];
// update log_visit
$sql = "UPDATE " . Common::prefixTable('log_visit') . "
SET " . implode(', ', $columnsToSet) . "
WHERE idvisit = ?";
Db::query($sql, $bind);
// update log_conversion
$sql = "UPDATE " . Common::prefixTable('log_conversion') . "
SET " . implode(', ', $columnsToSet) . "
WHERE idvisit = ?";
Db::query($sql, $bind);
}
Log::info(round($start * 100 / $count) . "% done...");
flush();
}
if ($start >= $count) {
Log::info("100% done!");
Log::info("");
Log::info("[note] Now that you've geolocated your old visits, you need to force your reports to be re-processed. See this FAQ entry: http://piwik.org/faq/how-to/#faq_59");
}

View file

@ -0,0 +1,13 @@
<html>
<body>
<script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js'></script>
<h3 style="color:#143974">Embedding the Piwik Country widget in an Iframe</h3>
<div id="widgetIframe">
<iframe width="500" height="350"
src="http://demo.piwik.org/index.php?module=Widgetize&action=iframe&moduleToWidgetize=UserCountry&actionToWidgetize=getCountry&idSite=1&period=month&date=2010-08-31&disableLink=1&token_auth=960d9a24b89ba4feb99be754c5aac15bx"
scrolling="no" frameborder="0" marginheight="0" marginwidth="0"></iframe>
</div>
</body>
</html>

View file

@ -0,0 +1,63 @@
<?php
use Piwik\FrontController;
use Piwik\Url;
use Piwik\UrlHelper;
use Piwik\WidgetsList;
exit;
$date = date('Y-m-d');
$period = 'month';
$idSite = 1;
$url = "http://localhost/trunk/index.php?token_auth=0b809661490d605bfd77f57ed11f0b14&module=Widgetize&action=iframe&moduleToWidgetize=UserCountry&actionToWidgetize=getCountry&idSite=$idSite&period=$period&date=$date&disableLink=1";
?>
<html>
<body>
<h3 style="color:#143974">Embedding the Piwik Country widget in an Iframe</h3>
<p>Loads a widget from localhost/trunk/ with login=root, pwd=test. <a href='<?= $url ?>'>Widget URL</a></p>
<div id="widgetIframe">
<iframe width="500" height="350"
src="<?php echo $url; ?>" scrolling="no" frameborder="0" marginheight="0" marginwidth="0"></iframe>
</div>
<br/>
<?php
$_GET['idSite'] = $idSite;
define('PIWIK_INCLUDE_PATH', '../..');
define('PIWIK_ENABLE_DISPATCH', false);
define('PIWIK_ENABLE_ERROR_HANDLER', false);
define('PIWIK_ENABLE_SESSION_START', false);
require_once PIWIK_INCLUDE_PATH . "/index.php";
require_once PIWIK_INCLUDE_PATH . "/core/API/Request.php";
FrontController::getInstance()->init();
$widgets = WidgetsList::get();
foreach ($widgets as $category => $widgetsInCategory) {
echo '<h2>' . $category . '</h2>';
foreach ($widgetsInCategory as $widget) {
echo '<h3>' . $widget['name'] . '</h3>';
$widgetUrl = UrlHelper::getArrayFromQueryString($url);
$widgetUrl['moduleToWidgetize'] = $widget['parameters']['module'];
$widgetUrl['actionToWidgetize'] = $widget['parameters']['action'];
$parameters = $widget['parameters'];
unset($parameters['module']);
unset($parameters['action']);
foreach ($parameters as $name => $value) {
if (is_array($value)) {
$value = current($value);
}
$widgetUrl[$name] = $value;
}
$widgetUrl = Url::getQueryStringFromParameters($widgetUrl);
echo '<div id="widgetIframe"><iframe width="500" height="350"
src="' . $widgetUrl . '" scrolling="no" frameborder="0" marginheight="0" marginwidth="0"></iframe></div>';
}
}
?>
</body>
</html>

View file

@ -0,0 +1,159 @@
<?xml version="1.0" encoding="UTF-8"?>
<code_scheme name="Piwik-codestyle">
<option name="LINE_SEPARATOR" value="&#10;" />
<option name="RIGHT_MARGIN" value="160" />
<PHPCodeStyleSettings>
<option name="ALIGN_KEY_VALUE_PAIRS" value="true" />
<option name="LOWER_CASE_BOOLEAN_CONST" value="true" />
<option name="LOWER_CASE_NULL_CONST" value="true" />
</PHPCodeStyleSettings>
<XML>
<option name="XML_LEGACY_SETTINGS_IMPORTED" value="true" />
</XML>
<codeStyleSettings language="JavaScript">
<option name="ALIGN_MULTILINE_PARAMETERS" value="false" />
<option name="KEEP_SIMPLE_BLOCKS_IN_ONE_LINE" value="true" />
<option name="KEEP_SIMPLE_METHODS_IN_ONE_LINE" value="true" />
</codeStyleSettings>
<codeStyleSettings language="PHP">
<option name="ALIGN_MULTILINE_ARRAY_INITIALIZER_EXPRESSION" value="true" />
<arrangement>
<groups>
<group>
<type>DEPENDENT_METHODS</type>
<order>BREADTH_FIRST</order>
</group>
</groups>
<rules>
<rule>
<match>
<CONST />
</match>
</rule>
<rule>
<match>
<AND>
<FIELD />
<PUBLIC />
<STATIC />
</AND>
</match>
</rule>
<rule>
<match>
<AND>
<FIELD />
<PROTECTED />
<STATIC />
</AND>
</match>
</rule>
<rule>
<match>
<AND>
<FIELD />
<PRIVATE />
<STATIC />
</AND>
</match>
</rule>
<rule>
<match>
<AND>
<FIELD />
<PUBLIC />
</AND>
</match>
</rule>
<rule>
<match>
<AND>
<FIELD />
<PROTECTED />
</AND>
</match>
</rule>
<rule>
<match>
<AND>
<FIELD />
<PRIVATE />
</AND>
</match>
</rule>
<rule>
<match>
<CONSTRUCTOR />
</match>
</rule>
<rule>
<match>
<AND>
<METHOD />
<PUBLIC />
<STATIC />
</AND>
</match>
</rule>
<rule>
<match>
<AND>
<METHOD />
<PROTECTED />
<STATIC />
</AND>
</match>
</rule>
<rule>
<match>
<AND>
<METHOD />
<PRIVATE />
<STATIC />
</AND>
</match>
</rule>
<rule>
<match>
<AND>
<METHOD />
<PUBLIC />
</AND>
</match>
</rule>
<rule>
<match>
<AND>
<METHOD />
<PROTECTED />
</AND>
</match>
</rule>
<rule>
<match>
<AND>
<METHOD />
<PRIVATE />
</AND>
</match>
</rule>
<rule>
<match>
<TRAIT />
</match>
</rule>
<rule>
<match>
<INTERFACE />
</match>
</rule>
<rule>
<match>
<CLASS />
</match>
</rule>
</rules>
</arrangement>
</codeStyleSettings>
</code_scheme>

View file

@ -0,0 +1,21 @@
Phpstorm has an awesome feature called "Reformat code" which reformats all PHP code to follow a particular selected coding style.
Piwik uses PSR coding standard for php source code. We use a slightly customized PSR style
(because the default PSR style in Phpstorm results in some unwanted changes).
Steps:
* Use latest Phpstorm
* Copy this Piwik_codestyle.xml file in your ~/.WebIde60/config/codestyles/
* If you use Windows or Mac see which path to copy at: http://intellij-support.jetbrains.com/entries/23358108
* To automatically link to the file in Piwik:
`$ ln -s ~/dev/piwik-master/misc/others/phpstorm-codestyles/Piwik_codestyle.xml ~/.WebIde70/config/codestyles/Piwik_codestyle.xml`
* Restart PhpStorm.
* Select this coding in Settings>Code style.
Phpstorm can also be configured to apply the style automatically before commit.
You are now writing code that respects Piwik coding standards. Enjoy!
Reference: http://piwik.org/participate/coding-standards/

View file

@ -0,0 +1,5 @@
echo "
Stress testing piwik.php
========================
"
ab -n5000 -c50 "http://localhost/dev/piwiktrunk/piwik.php?url=http%3A%2F%2Flocalhost%2Fdev%2Fpiwiktrunk%2F&action_name=&idsite=1&res=1280x1024&col=24&h=18&m=46&s=59&fla=1&dir=0&qt=1&realp=1&pdf=0&wma=1&java=1&cookie=1&title=&urlref="

View file

@ -0,0 +1,27 @@
<?php
// Script that creates 100 websites, then outputs a IMG that records a pageview in each website
// Used initially to test how to handle cookies for this use case (see http://dev.piwik.org/trac/ticket/409)
use Piwik\Common;
use Piwik\FrontController;
use Piwik\Piwik;
use Piwik\Plugins\SitesManager\API;
exit;
define('PIWIK_INCLUDE_PATH', '../..');
define('PIWIK_ENABLE_DISPATCH', false);
define('PIWIK_ENABLE_ERROR_HANDLER', false);
define('PIWIK_ENABLE_SESSION_START', false);
require_once PIWIK_INCLUDE_PATH . "/index.php";
require_once PIWIK_INCLUDE_PATH . "/core/API/Request.php";
require_once PIWIK_INCLUDE_PATH . "/libs/PiwikTracker/PiwikTracker.php";
FrontController::getInstance()->init();
Piwik::setUserHasSuperUserAccess();
$count = 100;
for ($i = 0; $i <= $count; $i++) {
$id = API::getInstance()->addSite(Common::getRandomString(), 'http://piwik.org');
$t = new PiwikTracker($id, 'http://localhost/trunk/piwik.php');
echo $id . " <img width=100 height=10 border=1 src='" . $t->getUrlTrackPageView('title') . "'><br/>";
}

View file

@ -0,0 +1,154 @@
<?php
use Piwik\Common;
use Piwik\Config;
use Piwik\FrontController;
use Piwik\Log;
define('PIWIK_INCLUDE_PATH', realpath(dirname(__FILE__) . "/../.."));
define('PIWIK_ENABLE_DISPATCH', false);
define('PIWIK_ENABLE_ERROR_HANDLER', false);
define('PIWIK_ENABLE_SESSION_START', false);
require_once PIWIK_INCLUDE_PATH . "/index.php";
require_once PIWIK_INCLUDE_PATH . "/core/API/Request.php";
require_once PIWIK_INCLUDE_PATH . "/libs/PiwikTracker/PiwikTracker.php";
FrontController::getInstance()->init();
// SECURITY: DO NOT DELETE THIS LINE!
if (!Common::isPhpCliMode()) {
die("ERROR: Must be executed in CLI");
}
$process = new Piwik_StressTests_CopyLogs;
$process->init();
$process->run();
//$process->delete();
class Piwik_StressTests_CopyLogs
{
function init()
{
$config = Config::getInstance();
$config->log['log_only_when_debug_parameter'] = 0;
$config->log['log_writers'] = array('screen');
$config->log['log_level'] = 'VERBOSE';
}
function run()
{
// Copy all visits in date range into TODAY
$startDate = '2011-08-12';
$endDate = '2011-08-12';
$this->log("Starting...");
$db = \Zend_Registry::get('db');
$initial = $this->getVisitsToday();
$this->log(" Visits today so far: " . $initial);
$initialActions = $this->getActionsToday();
$this->log(" Actions today: " . $initialActions);
$initialPurchasedItems = $this->getConversionItemsToday();
$this->log(" Purchased items today: " . $initialPurchasedItems);
$initialConversions = $this->getConversionsToday();
$this->log(" Conversions today: " . $initialConversions);
$this->log(" Now copying visits between '$startDate' and '$endDate'...");
$sql = "INSERT INTO " . Common::prefixTable('log_visit') . " (`idsite`, `idvisitor`, `visitor_localtime`, `visitor_returning`, `visitor_count_visits`, `visit_first_action_time`, `visit_last_action_time`, `visit_exit_idaction_url`, `visit_exit_idaction_name`, `visit_entry_idaction_url`, `visit_entry_idaction_name`, `visit_total_actions`, `visit_total_time`, `visit_goal_converted`, `visit_goal_buyer`, `referer_type`, `referer_name`, `referer_url`, `referer_keyword`, `config_id`, `config_os`, `config_browser_name`, `config_browser_version`, `config_resolution`, `config_pdf`, `config_flash`, `config_java`, `config_director`, `config_quicktime`, `config_realplayer`, `config_windowsmedia`, `config_gears`, `config_silverlight`, `config_cookie`, `location_ip`, `location_browser_lang`, `location_country`, `location_provider`, `custom_var_k1`, `custom_var_v1`, `custom_var_k2`, `custom_var_v2`, `custom_var_k3`, `custom_var_v3`, `custom_var_k4`, `custom_var_v4`, `custom_var_k5`, `custom_var_v5`, `visitor_days_since_last`, `visitor_days_since_order`, `visitor_days_since_first`)
SELECT `idsite`, `idvisitor`, `visitor_localtime`, `visitor_returning`, `visitor_count_visits`, CONCAT(CURRENT_DATE() , \" \", FLOOR(RAND()*24) , \":\",FLOOR(RAND()*60),\":\",FLOOR(RAND()*60)), CONCAT(CURRENT_DATE() , \" \", FLOOR(RAND()*24) , \":\",FLOOR(RAND()*60),\":\",FLOOR(RAND()*60)), `visit_exit_idaction_url`, `visit_exit_idaction_name`, `visit_entry_idaction_url`, `visit_entry_idaction_name`, `visit_total_actions`, `visit_total_time`, `visit_goal_converted`, `visit_goal_buyer`, `referer_type`, `referer_name`, `referer_url`, `referer_keyword`, `config_id`, `config_os`, `config_browser_name`, `config_browser_version`, `config_resolution`, `config_pdf`, `config_flash`, `config_java`, `config_director`, `config_quicktime`, `config_realplayer`, `config_windowsmedia`, `config_gears`, `config_silverlight`, `config_cookie`, `location_ip`, `location_browser_lang`, `location_country`, `location_provider`, `custom_var_k1`, `custom_var_v1`, `custom_var_k2`, `custom_var_v2`, `custom_var_k3`, `custom_var_v3`, `custom_var_k4`, `custom_var_v4`, `custom_var_k5`, `custom_var_v5`, `visitor_days_since_last`, `visitor_days_since_order`, `visitor_days_since_first`
FROM `" . Common::prefixTable('log_visit') . "`
WHERE idsite >= 1 AND date(visit_last_action_time) between '$startDate' and '$endDate' ;";
$result = $db->query($sql);
$this->log(" Copying actions...");
$sql = "INSERT INTO " . Common::prefixTable('log_link_visit_action') . " (`idsite`, `idvisitor`, `server_time`, `idvisit`, `idaction_url`, `idaction_url_ref`, `idaction_name`, `idaction_name_ref`, `time_spent_ref_action`, `custom_var_k1`, `custom_var_v1`, `custom_var_k2`, `custom_var_v2`, `custom_var_k3`, `custom_var_v3`, `custom_var_k4`, `custom_var_v4`, `custom_var_k5`, `custom_var_v5`)
SELECT `idsite`, `idvisitor`, CONCAT(CURRENT_DATE() , \" \", FLOOR(RAND()*24) , \":\",FLOOR(RAND()*60),\":\",FLOOR(RAND()*60)), `idvisit`, `idaction_url`, `idaction_url_ref`, `idaction_name`, `idaction_name_ref`, `time_spent_ref_action`, `custom_var_k1`, `custom_var_v1`, `custom_var_k2`, `custom_var_v2`, `custom_var_k3`, `custom_var_v3`, `custom_var_k4`, `custom_var_v4`, `custom_var_k5`, `custom_var_v5`
FROM `" . Common::prefixTable('log_link_visit_action') . "`
WHERE idsite >= 1 AND date(server_time) between '$startDate' and '$endDate'
;"; // LIMIT 1000000
$result = $db->query($sql);
$this->log(" Copying conversions...");
$sql = "INSERT IGNORE INTO `" . Common::prefixTable('log_conversion') . "` (`idvisit`, `idsite`, `visitor_days_since_first`, `visitor_days_since_order`, `visitor_count_visits`, `idvisitor`, `server_time`, `idaction_url`, `idlink_va`, `referer_visit_server_date`, `referer_type`, `referer_name`, `referer_keyword`, `visitor_returning`, `location_country`, `url`, `idgoal`, `revenue`, `buster`, `idorder`, `custom_var_k1`, `custom_var_v1`, `custom_var_k2`, `custom_var_v2`, `custom_var_k3`, `custom_var_v3`, `custom_var_k4`, `custom_var_v4`, `custom_var_k5`, `custom_var_v5`, `items`, `revenue_subtotal`, `revenue_tax`, `revenue_shipping`, `revenue_discount`)
SELECT `idvisit`, `idsite`, `visitor_days_since_first`, `visitor_days_since_order`, `visitor_count_visits`, `idvisitor`, CONCAT(CURRENT_DATE() , \" \", FLOOR(RAND()*24) , \":\",FLOOR(RAND()*60),\":\",FLOOR(RAND()*60)), `idaction_url`, `idlink_va`, `referer_visit_server_date`, `referer_type`, `referer_name`, `referer_keyword`, `visitor_returning`, `location_country`, `url`, `idgoal`, `revenue`, FLOOR(`buster` * RAND()), CONCAT(`idorder`,SUBSTRING(MD5(RAND()) FROM 1 FOR 9)) , `custom_var_k1`, `custom_var_v1`, `custom_var_k2`, `custom_var_v2`, `custom_var_k3`, `custom_var_v3`, `custom_var_k4`, `custom_var_v4`, `custom_var_k5`, `custom_var_v5`, `items`, `revenue_subtotal`, `revenue_tax`, `revenue_shipping`, `revenue_discount`
FROM `" . Common::prefixTable('log_conversion') . "`
WHERE idsite >= 1 AND date(server_time) between '$startDate' and '$endDate' ;";
$result = $db->query($sql);
$this->log(" Copying purchased items...");
$sql = "INSERT INTO `" . Common::prefixTable('log_conversion_item') . "` (`idsite`, `idvisitor`, `server_time`, `idvisit`, `idorder`, `idaction_sku`, `idaction_name`, `idaction_category`, `price`, `quantity`, `deleted`)
SELECT `idsite`, `idvisitor`, CONCAT(CURRENT_DATE() , \" \", TIME(`server_time`)), `idvisit`, CONCAT(`idorder`,SUBSTRING(MD5(RAND()) FROM 1 FOR 9)) , `idaction_sku`, `idaction_name`, `idaction_category`, `price`, `quantity`, `deleted`
FROM `" . Common::prefixTable('log_conversion_item') . "`
WHERE idsite >= 1 AND date(server_time) between '$startDate' and '$endDate' ;";
$result = $db->query($sql);
$now = $this->getVisitsToday();
$actions = $this->getActionsToday();
$purchasedItems = $this->getConversionItemsToday();
$conversions = $this->getConversionsToday();
$this->log(" -------------------------------------");
$this->log(" Today visits after import: " . $now);
$this->log(" Actions: " . $actions);
$this->log(" Purchased items: " . $purchasedItems);
$this->log(" Conversions: " . $conversions);
$this->log(" - New visits created: " . ($now - $initial));
$this->log(" - Actions created: " . ($actions - $initialActions));
$this->log(" - New conversions created: " . ($conversions - $initialConversions));
$this->log(" - New purchased items created: " . ($purchasedItems - $initialPurchasedItems));
$this->log("done");
}
function delete()
{
$this->log("Deleting logs for today...");
$db = \Zend_Registry::get('db');
$sql = "DELETE FROM " . Common::prefixTable('log_visit') . "
WHERE date(visit_last_action_time) = CURRENT_DATE();";
$db->query($sql);
foreach (array('log_link_visit_action', 'log_conversion', 'log_conversion_item') as $table) {
$sql = "DELETE FROM " . Common::prefixTable($table) . "
WHERE date(server_time) = CURRENT_DATE();";
$db->query($sql);
}
$tablesToOptimize = array(
Common::prefixTable('log_link_visit_action'),
Common::prefixTable('log_conversion'),
Common::prefixTable('log_conversion_item'),
Common::prefixTable('log_visit')
);
\Piwik\Db::optimizeTables($tablesToOptimize);
$this->log("done");
}
function log($m)
{
Log::info($m);
}
function getVisitsToday()
{
$sql = "SELECT count(*) FROM `" . Common::prefixTable('log_visit') . "` WHERE idsite >= 1 AND DATE(`visit_last_action_time`) = CURRENT_DATE;";
return \Zend_Registry::get('db')->fetchOne($sql);
}
function getConversionItemsToday($table = 'log_conversion_item')
{
$sql = "SELECT count(*) FROM `" . Common::prefixTable($table) . "` WHERE idsite >= 1 AND DATE(`server_time`) = CURRENT_DATE;";
return \Zend_Registry::get('db')->fetchOne($sql);
}
function getConversionsToday()
{
return $this->getConversionItemsToday($table = "log_conversion");
}
function getActionsToday()
{
$sql = "SELECT count(*) FROM `" . Common::prefixTable('log_link_visit_action') . "` WHERE idsite >= 1 AND DATE(`server_time`) = CURRENT_DATE;";
return \Zend_Registry::get('db')->fetchOne($sql);
}
}

View file

@ -0,0 +1,30 @@
<?php
// -- Piwik Tracking API init --
require_once "../../libs/PiwikTracker/PiwikTracker.php";
PiwikTracker::$URL = 'http://localhost/piwik-master/';
// Example 1: Tracks a pageview for Website id = {$IDSITE}
$trackingURL = Piwik_getUrlTrackPageView($idSite = 16, $customTitle = 'This title will appear in the report Actions > Page titles');
?>
<html>
<body>
<!-- Piwik -->
<script type="text/javascript">
var _paq = _paq || [];
(function() {
var u=(("https:" == document.location.protocol) ? "https" : "http") + "://localhost/piwik-master/";
_paq.push(["setTrackerUrl", u+"piwik.php"]);
_paq.push(["setSiteId", "16"]);
var d=document, g=d.createElement("script"), s=d.getElementsByTagName("script")[0]; g.type="text/javascript";
g.defer=true; g.async=true; g.src=u+"js/piwik.js"; s.parentNode.insertBefore(g,s);
})();
</script>
<!-- End Piwik Code -->
This page loads a Simple Tracker request to Piwik website id=1
<?php
echo '<img src="' . htmlentities($trackingURL) . '" alt="" />';
?>
</body>
</html>

View file

@ -0,0 +1,26 @@
<?php
// How to remove the piwik/ directory if it does not work in FTP?
// 1) Download and upload this file to your webserver
// 2) Put this file in the folder that contains the piwik/ directory (above the piwik/ directory)
// For example if the piwik/ folder is at http://your-site/piwik/ you put the file in http://your-site/uninstall-delete-piwik-directory.php
// 3) Go with your browser to http://your-site/uninstall-delete-piwik-directory.php
// 4) The folder http://your-site/piwik/ should now be deleted!
// We hope you enjoyed Piwik. If you have any feedback why you stopped using Piwik,
// please let us know at hello@piwik.org - we are interested by your experience
function unlinkRecursive($dir)
{
if (!$dh = @opendir($dir)) return "Warning: folder $dir couldn't be read by PHP";
while (false !== ($obj = readdir($dh))) {
if ($obj == '.' || $obj == '..') {
continue;
}
if (!@unlink($dir . '/' . $obj)) {
unlinkRecursive($dir . '/' . $obj, true);
}
}
closedir($dh);
@rmdir($dir);
return "Folder $dir deleted!";
}
echo unlinkRecursive('piwik/');

View file

@ -0,0 +1,11 @@
<html>
<body>
<p>Number of visits per week for the last 52 weeks</p>
<div id="widgetIframe">
<iframe width="800" height="450"
src="http://piwik.org/demo/index.php?module=Widgetize&action=iframe&moduleToWidgetize=VisitsSummary&actionToWidgetize=getEvolutionGraph&idSite=1&period=week&date=last52&columns[]=nb_visits&disableLink=1"
scrolling="no" frameborder="0" marginheight="0" marginwidth="0"></iframe>
</div>
</body>
</html>