hide map for Character groups Quest Stations when there are no stations
This commit is contained in:
commit
df14dfafc3
4371 changed files with 1220224 additions and 0 deletions
7
www/analytics/misc/How to install Piwik.html
Normal file
7
www/analytics/misc/How to install Piwik.html
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
<html>
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;url=http://piwik.org/docs/installation/"/>
|
||||
</head>
|
||||
<body>You will be redirected to the Piwik Installation documentation on <a href='http://piwik.org/docs/installation/'>http://piwik.org/docs/installation/</a>
|
||||
</body>
|
||||
</html>
|
||||
51
www/analytics/misc/cron/archive.php
Normal file
51
www/analytics/misc/cron/archive.php
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
<?php
|
||||
/**
|
||||
* Piwik - Open source web analytics
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
*
|
||||
* @category Piwik
|
||||
* @package Piwik
|
||||
*/
|
||||
|
||||
if (!defined('PIWIK_INCLUDE_PATH')) {
|
||||
define('PIWIK_INCLUDE_PATH', realpath(dirname(__FILE__) . "/../.."));
|
||||
}
|
||||
|
||||
if (!defined('PIWIK_USER_PATH')) {
|
||||
define('PIWIK_USER_PATH', PIWIK_INCLUDE_PATH);
|
||||
}
|
||||
|
||||
if (!class_exists('Piwik\Console', false)) {
|
||||
define('PIWIK_ENABLE_DISPATCH', false);
|
||||
define('PIWIK_ENABLE_ERROR_HANDLER', false);
|
||||
define('PIWIK_ENABLE_SESSION_START', false);
|
||||
require_once PIWIK_INCLUDE_PATH . "/index.php";
|
||||
}
|
||||
|
||||
if (!empty($_SERVER['argv'][0])) {
|
||||
$callee = $_SERVER['argv'][0];
|
||||
} else {
|
||||
$callee = '';
|
||||
}
|
||||
|
||||
if (false !== strpos($callee, 'archive.php')) {
|
||||
$piwikHome = PIWIK_INCLUDE_PATH;
|
||||
echo "
|
||||
-------------------------------------------------------
|
||||
Using this 'archive.php' script is no longer recommended.
|
||||
Please use '/path/to/php $piwikHome/console core:archive " . implode(' ', array_slice($_SERVER['argv'], 1)) . "' instead.
|
||||
To get help use '/path/to/php $piwikHome/console core:archive --help'
|
||||
-------------------------------------------------------
|
||||
\n\n";
|
||||
}
|
||||
|
||||
$archiving = new Piwik\CronArchive();
|
||||
try {
|
||||
$archiving->main();
|
||||
} catch (Piwik\CronArchiveFatalException $ex) {
|
||||
$ex->logAndExit($archiving);
|
||||
} catch (Exception $e) {
|
||||
$archiving->logFatalExceptionAndExit($e);
|
||||
}
|
||||
99
www/analytics/misc/cron/archive.sh
Executable file
99
www/analytics/misc/cron/archive.sh
Executable file
|
|
@ -0,0 +1,99 @@
|
|||
#!/bin/sh -e
|
||||
|
||||
# =======================================================================
|
||||
# BEFORE YOU USE THIS SCRIPT:
|
||||
# PLEASE DON'T.
|
||||
# =======================================================================
|
||||
#
|
||||
#
|
||||
# ==> Use archive.php instead. <==
|
||||
#
|
||||
# See documentation at http://piwik.org/setup-auto-archiving/
|
||||
# =======================================================================
|
||||
|
||||
# Description
|
||||
# This cron script will automatically run Piwik archiving every hour.
|
||||
# The script will also run scheduled tasks configured within piwik using
|
||||
# the event hook 'TaskScheduler.getScheduledTasks'
|
||||
|
||||
# It automatically fetches the Super User token_auth
|
||||
# and triggers the archiving for all websites for all periods.
|
||||
# This ensures that all reports are pre-computed and Piwik renders very fast.
|
||||
|
||||
# Documentation
|
||||
# Please check the documentation on http://piwik.org/docs/setup-auto-archiving/
|
||||
|
||||
# How to setup the crontab job?
|
||||
# Add the following lines in your crontab file, eg. /etc/cron.d/piwik-archive
|
||||
#---------------START CRON TAB--
|
||||
#MAILTO="youremail@example.com"
|
||||
#5 * * * * www-data /path/to/piwik/misc/cron/archive.sh > /dev/null
|
||||
#-----------------END CRON TAB--
|
||||
# When an error occurs (eg. php memory error, timeout) the error messages
|
||||
# will be sent to youremail@example.com.
|
||||
#
|
||||
# Optimization for high traffic websites
|
||||
# You may want to override the following settings in config/config.ini.php:
|
||||
# See documentation of the fields in your piwik/config/config.ini.php
|
||||
#
|
||||
# [General]
|
||||
# time_before_archive_considered_outdated = 3600
|
||||
# enable_browser_archiving_triggering = false
|
||||
#===========================================================================
|
||||
|
||||
for TEST_PHP_BIN in php5 php php-cli php-cgi; do
|
||||
if which $TEST_PHP_BIN >/dev/null 2>/dev/null; then
|
||||
PHP_BIN=`which $TEST_PHP_BIN`
|
||||
break
|
||||
fi
|
||||
done
|
||||
if test -z $PHP_BIN; then
|
||||
echo "php binary not found. Make sure php5 or php exists in PATH." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
act_path() {
|
||||
local pathname="$1"
|
||||
readlink -f "$pathname" 2>/dev/null || \
|
||||
realpath "$pathname" 2>/dev/null || \
|
||||
type -P "$pathname" 2>/dev/null
|
||||
}
|
||||
|
||||
ARCHIVE=`act_path ${0}`
|
||||
PIWIK_CRON_FOLDER=`dirname ${ARCHIVE}`
|
||||
PIWIK_PATH="$PIWIK_CRON_FOLDER"/../../index.php
|
||||
PIWIK_TOKEN_GENERATOR="$PIWIK_CRON_FOLDER"/../../misc/cron/updatetoken.php
|
||||
|
||||
FILENAME_TOKEN_CONTENT=`$PHP_BIN $PIWIK_TOKEN_GENERATOR`
|
||||
TOKEN_AUTH=`cat $FILENAME_TOKEN_CONTENT | cut -f2`
|
||||
|
||||
CMD_GET_ID_SITES="$PHP_BIN -q $PIWIK_PATH -- module=API&method=SitesManager.getAllSitesId&token_auth=$TOKEN_AUTH&format=csv&convertToUnicode=0"
|
||||
ID_SITES=`$CMD_GET_ID_SITES`
|
||||
|
||||
echo "Starting Piwik reports archiving..."
|
||||
echo ""
|
||||
for idsite in $ID_SITES; do
|
||||
TEST_IS_NUMERIC=`echo $idsite | egrep '^[0-9]+$'`
|
||||
if test -n "$TEST_IS_NUMERIC"; then
|
||||
for period in day week month year; do
|
||||
echo ""
|
||||
echo "Archiving period = $period for idsite = $idsite..."
|
||||
CMD="$PHP_BIN -q $PIWIK_PATH -- module=API&method=VisitsSummary.getVisits&idSite=$idsite&period=$period&date=last52&format=xml&token_auth=$TOKEN_AUTH"
|
||||
$CMD
|
||||
|
||||
done
|
||||
|
||||
echo ""
|
||||
echo "Archiving for idsite = $idsite done!"
|
||||
fi
|
||||
done
|
||||
|
||||
echo "Reports archiving finished."
|
||||
echo "---------------------------"
|
||||
echo "Starting Scheduled tasks..."
|
||||
echo ""
|
||||
CMD="$PHP_BIN -q $PIWIK_PATH -- module=API&method=CoreAdminHome.runScheduledTasks&format=csv&convertToUnicode=0&token_auth=$TOKEN_AUTH"
|
||||
$CMD
|
||||
echo ""
|
||||
echo "Finished Scheduled tasks."
|
||||
echo ""
|
||||
47
www/analytics/misc/cron/updatetoken.php
Normal file
47
www/analytics/misc/cron/updatetoken.php
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
<?php
|
||||
/**
|
||||
* Piwik - Open source web analytics
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
*
|
||||
* @category Piwik
|
||||
* @package Piwik
|
||||
*/
|
||||
|
||||
namespace Piwik;
|
||||
|
||||
if (!defined('PIWIK_INCLUDE_PATH')) {
|
||||
define('PIWIK_INCLUDE_PATH', realpath(dirname(__FILE__) . "/../.."));
|
||||
}
|
||||
|
||||
if (!defined('PIWIK_USER_PATH')) {
|
||||
define('PIWIK_USER_PATH', 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";
|
||||
|
||||
if (!Common::isPhpCliMode()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$testmode = in_array('--testmode', $_SERVER['argv']);
|
||||
if ($testmode) {
|
||||
require_once PIWIK_INCLUDE_PATH . "/tests/PHPUnit/TestingEnvironment.php";
|
||||
|
||||
\Piwik_TestingEnvironment::addHooks();
|
||||
}
|
||||
|
||||
$token = Db::get()->fetchOne("SELECT token_auth
|
||||
FROM " . Common::prefixTable("user") . "
|
||||
WHERE superuser_access = 1
|
||||
ORDER BY date_registered ASC");
|
||||
|
||||
$filename = PIWIK_INCLUDE_PATH . '/tmp/cache/token.php';
|
||||
$content = "<?php exit; //\t" . $token;
|
||||
file_put_contents($filename, $content);
|
||||
echo $filename;
|
||||
674
www/analytics/misc/gpl-3.0.txt
Normal file
674
www/analytics/misc/gpl-3.0.txt
Normal file
|
|
@ -0,0 +1,674 @@
|
|||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
||||
259
www/analytics/misc/log-analytics/README.md
Normal file
259
www/analytics/misc/log-analytics/README.md
Normal file
|
|
@ -0,0 +1,259 @@
|
|||
# Piwik Server Log Analytics: Import your server logs in Piwik!
|
||||
|
||||
## Requirements
|
||||
|
||||
* Python 2.6 or 2.7. Python 3.x is not supported.
|
||||
* Update to Piwik 1.11
|
||||
|
||||
## How to use this script?
|
||||
|
||||
The most simple way to import your logs is to run:
|
||||
|
||||
./import_logs.py --url=piwik.example.com /path/to/access.log
|
||||
|
||||
You must specify your Piwik URL with the `--url` argument.
|
||||
The script will automatically read your config.inc.php file to get the authentication
|
||||
token and communicate with your Piwik install to import the lines.
|
||||
The default mode will try to mimic the Javascript tracker as much as possible,
|
||||
and will not track bots, static files, or error requests.
|
||||
|
||||
If you wish to track all requests the following command would be used:
|
||||
|
||||
python /path/to/piwik/misc/log-analytics/import_logs.py --url=http://mysite/piwik/ access.log --idsite=1234 --recorders=4 --enable-http-errors --enable-http-redirects --enable-static --enable-bots
|
||||
|
||||
## How to import your logs automatically every day?
|
||||
|
||||
You must first make sure your logs are automatically rotated every day. The most
|
||||
popular ways to implement this are using either:
|
||||
|
||||
* logrotate: http://www.linuxcommand.org/man_pages/logrotate8.html
|
||||
It will work with any HTTP daemon.
|
||||
* rotatelogs: http://httpd.apache.org/docs/2.0/programs/rotatelogs.html
|
||||
Only works with Apache.
|
||||
* let us know what else is useful and we will add it to the list
|
||||
|
||||
Your logs should be automatically rotated and stored on your webserver, for instance in daily logs
|
||||
`/var/log/apache/access-%Y-%m-%d.log` (where %Y, %m and %d represent the year,
|
||||
month and day).
|
||||
You can then import your logs automatically each day (at 0:01). Setup a cron job with the command:
|
||||
|
||||
0 1 * * * /path/to/piwik/misc/log-analytics/import-logs.py -u piwik.example.com `date --date=yesterday +/var/log/apache/access-\%Y-\%m-\%d.log`
|
||||
|
||||
## Performance
|
||||
|
||||
With an Intel Core i5-2400 @ 3.10GHz (2 cores, 4 virtual cores with Hyper-threading),
|
||||
running Piwik and its MySQL database, between 250 and 300 records were imported per second.
|
||||
|
||||
The import_logs.py script needs CPU to read and parse the log files, but it is actually
|
||||
Piwik server itself (i.e. PHP/MySQL) which will use more CPU during data import.
|
||||
|
||||
To improve performance,
|
||||
|
||||
1. by default, the script one thread to parse and import log lines.
|
||||
you can use the `--recorders` option to specify the number of parallel threads which will
|
||||
import hits into Piwik. We recommend to set `--recorders=N` to the number N of CPU cores
|
||||
that the server hosting Piwik has. The parsing will still be single-threaded,
|
||||
but several hits will be tracked in Piwik at the same time.
|
||||
2. the script will issue hundreds of requests to piwik.php - to improve the Piwik webserver performance
|
||||
you can disable server access logging for these requests.
|
||||
Each Piwik webserver (Apache, Nginx, IIS) can also be tweaked a bit to handle more req/sec.
|
||||
|
||||
|
||||
## Setup Apache CustomLog that directly imports in Piwik
|
||||
|
||||
Since apache CustomLog directives can send log data to a script, it is possible to import hits into piwik server-side in real-time rather than processing a logfile each day.
|
||||
|
||||
This approach has many advantages, including real-time data being available on your piwik site, using real logs files instead of relying on client-side Javacsript, and not having a surge of CPU/RAM usage during log processing.
|
||||
The disadvantage is that if Piwik is unavailable, logging data will be lost. Therefore we recommend to also log into a standard log file. Bear in mind also that apache processes will wait until a request is logged before processing a new request, so if piwik runs slow so does your site: it's therefore important to tune --recorders to the right level.
|
||||
|
||||
In the most basic setup, you might have in your main config section:
|
||||
|
||||
```
|
||||
# Set up your log format as a normal extended format, with hostname at the start
|
||||
LogFormat "%v %h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" myLogFormat
|
||||
# Log to a file as usual
|
||||
CustomLog /path/to/logfile myLogFormat
|
||||
# Log to piwik as well
|
||||
CustomLog "|/path/to/import_logs.py --option1 --option2 ... -" myLogFormat
|
||||
```
|
||||
|
||||
Note: on Debian/Ubuntu, the default configuration defines the vhost_combined format. You
|
||||
can use it instead of defining myLogFormat.
|
||||
|
||||
Useful options here are:
|
||||
|
||||
* --add-sites-new-hosts (creates new websites in piwik based on %v in the LogFormat)
|
||||
* --output=/path/to/piwik.log (puts any output into a log file for reference/debugging later)
|
||||
* --recorders=4 (use whatever value seems sensible for you - higher traffic sites will need more recorders to keep up)
|
||||
* "-" so it reads straight from /dev/stdin
|
||||
|
||||
You can have as many CustomLog statements as you like. However, if you define any CustomLog directives within a <VirtualHost> block, all CustomLogs in the main config will be overridden. Therefore if you require custom logging for particular VirtualHosts, it is recommended to use mod_macro to make configuration more maintainable.
|
||||
|
||||
|
||||
## Advanced Log Analytics use case: Apache vhost, custom logs, automatic website creation
|
||||
|
||||
As a rather extreme example of what you can do, here is an apache config with:
|
||||
|
||||
* standard logging in the main config area for the majority of VirtualHosts
|
||||
* customised logging in a particular virtualhost to change the hostname (for instance, if a particular virtualhost should be logged as if it were a different site)
|
||||
* customised logging in another virtualhost which creates new websites in piwik for subsites (e.g. to have domain.com/subsite1 as a whole website in its own right). This requires setting up a custom --log-format-regex to allow "/" in the hostname section (NB the escaping necessary for apache to pass through the regex to piwik properly), and also to have multiple CustomLog directives so the subsite gets logged to both domain.com and domain.com/subsite1 websites in piwik
|
||||
* we also use mod_rewrite to set environment variables so that if you have multiple subsites with the same format , e.g. /subsite1, /subsite2, etc, you can automatically create a new piwik website for each one without having to configure them manually
|
||||
|
||||
NB use of mod_macro to ensure consistency and maintainability
|
||||
|
||||
## Apache configuration source code:
|
||||
|
||||
```
|
||||
# Set up macro with the options
|
||||
# * $vhost (this will be used as the piwik website name),
|
||||
# * $logname (the name of the LogFormat we're using),
|
||||
# * $output (which logfile to save import_logs.py output to),
|
||||
# * $env (CustomLog can be set only to fire if an environment variable is set - this contains that environment variable, so subsites only log when it's set)
|
||||
# NB the --log-format-regex line is exactly the same regex as import_logs.py's own 'common_vhost' format, but with "\/" added in the "host" section's allowed characters
|
||||
<Macro piwiklog $vhost $logname $output $env>
|
||||
LogFormat "$vhost %h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" $logname
|
||||
CustomLog "|/path/to/piwik/misc/log-analytics/import_logs.py \
|
||||
--add-sites-new-hosts \
|
||||
--config=/path/to/piwik/config/config.ini.php \
|
||||
--url='http://your.piwik.install/' \
|
||||
--recorders=4 \
|
||||
--log-format-regex='(?P<host>[\\\\w\\\\-\\\\.\\\\/]*)(?::\\\\d+)? (?P<ip>\\\\S+) \\\\S+ \\\\S+ \\\\[(?P<date>.*?) (?P<timezone>.*?)\\\\] \\\"\\\\S+ (?P<path>.*?) \\\\S+\\\" (?P<status>\\\\S+) (?P<length>\\\\S+) \\\"(?P<referrer>.*?)\\\" \\\"(?P<user_agent>.*?)\\\"' \
|
||||
--output=/var/log/piwik/$output.log \
|
||||
-" \
|
||||
$logname \
|
||||
$env
|
||||
</Macro>
|
||||
# Set up main apache logging, with:
|
||||
|
||||
# * normal %v as hostname,
|
||||
# * vhost_common as logformat name,
|
||||
# * /var/log/piwik/main.log as the logfile,
|
||||
# * no env variable needed since we always want to trigger
|
||||
Use piwiklog %v vhost_common main " "
|
||||
<VirtualHost>
|
||||
ServerName example.com
|
||||
# Set this host to log to piwik with a different hostname (and using a different output file, /var/log/piwik/example_com.log)
|
||||
Use piwiklog "another-host.com" vhost_common example_com " "
|
||||
</VirtualHost>
|
||||
|
||||
<VirtualHost>
|
||||
ServerName domain.com
|
||||
# We want to log this normally, so repeat the CustomLog from the main section
|
||||
# (if this is omitted, our other CustomLogs below will override the one in the main section, so the main site won't be logged)
|
||||
Use piwiklog %v vhost_common main " "
|
||||
|
||||
# Now set up mod_rewrite to detect our subsites and set up new piwik websites to track just hits to these (this is a bit like profiles in Google Analytics).
|
||||
# We want to match domain.com/anothersubsite and domain.com/subsite[0-9]+
|
||||
|
||||
# First to be on the safe side, unset the env we'll use to test if we're in a subsite:
|
||||
UnsetEnv vhostLogName
|
||||
|
||||
# Subsite definitions. NB check for both URI and REFERER (some files used in a page, or downloads linked from a page, may not reside within our subsite directory):
|
||||
# Do the one-off subsite first:
|
||||
RewriteCond %{REQUEST_URI} ^/anothersubsite(/|$) [OR]
|
||||
RewriteCond %{HTTP_REFERER} domain\.com/anothersubsite(/|$)
|
||||
RewriteRule ^/.* - [E=vhostLogName:anothersubsite]
|
||||
# Subsite of the form /subsite[0-9]+. NB the capture brackets in the RewriteCond rules which get mapped to %1 in the RewriteRule
|
||||
RewriteCond %{REQUEST_URI} ^/(subsite[0-9]+)(/|$)) [OR]
|
||||
RewriteCond %{HTTP_REFERER} domain\.com/(subsite[0-9]+)(/|$)
|
||||
RewriteRule ^/.* - [E=vhostLogName:subsite%1]
|
||||
|
||||
# Now set the logging to piwik setting:
|
||||
# * the hostname to domain.com/<subsitename>
|
||||
# * the logformat to vhost_domain_com_subsites (can be anything so long as it's unique)
|
||||
# * the output to go to /var/log/piwik/domain_com_subsites.log (again, can be anything)
|
||||
# * triggering only when the env variable is set, so requests to other URIs on this domain don't call this logging rule
|
||||
Use piwiklog domain.com/%{vhostLogName}e vhost_domain_com_subsites domain_com_subsites env=vhostLogName
|
||||
</VirtualHost>
|
||||
```
|
||||
|
||||
## Nginx Virtual Host Log Format
|
||||
|
||||
This log format can be specified for nginx access logs to capture multiple virtual hosts:
|
||||
|
||||
* log_format vhosts '$host $remote_addr - $remote_user [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent"';
|
||||
* access_log /PATH/TO/access.log vhosts;
|
||||
|
||||
When executing import_logs.py specify the "common_complete" format.
|
||||
|
||||
|
||||
## Import Page Speed Metric from logs
|
||||
|
||||
In Piwik> Actions> Page URLs and Page Title reports, Piwik reports the Avg. generation time, as an indicator of your website speed.
|
||||
This metric works by default when using the Javascript tracker, but you can use it with log file as well.
|
||||
|
||||
Apache can log the generation time in microseconds using %D in the LogFormat.
|
||||
This metric can be imported using a custom log format in this script.
|
||||
In the command line, add the --log-format-regex parameter that contains the group generation_time_micro.
|
||||
|
||||
Here's an example:
|
||||
Apache LogFormat "%h %l %u %t \"%r\" %>s %b %D"
|
||||
--log-format-regex="(?P<ip>\S+) \S+ \S+ \[(?P<date>.*?) (?P<timezone>.*?)\] \"\S+ (?P<path>.*?) \S+\" (?P<status>\S+) (?P<length>\S+) (?P<generation_time_micro>\S+)"
|
||||
|
||||
Note: the group <generation_time_milli> is also available if your server logs generation time in milliseconds rather than microseconds.
|
||||
|
||||
|
||||
## Setup Nginx to directly imports in Piwik via syslog
|
||||
|
||||
With the syslog patch from http://wiki.nginx.org/3rdPartyModules which is compiled in dotdeb's release, you can log to syslog and imports them live to Piwik.
|
||||
Path: Nginx -> syslog -> (syslog central server) -> this script -> piwik
|
||||
|
||||
You can use any log format that this script can handle, like Apache Combined, and Json format which needs less processing.
|
||||
|
||||
|
||||
### Setup Nginx logs
|
||||
|
||||
```
|
||||
http {
|
||||
...
|
||||
log_format piwik '{"ip": "$remote_addr",'
|
||||
'"host": "$host",'
|
||||
'"path": "$request_uri",'
|
||||
'"status": "$status",'
|
||||
'"referrer": "$http_referer",'
|
||||
'"user_agent": "$http_user_agent",'
|
||||
'"length": $bytes_sent,'
|
||||
'"generation_time_milli": $request_time,'
|
||||
'"date": "$time_iso8601"}';
|
||||
...
|
||||
server {
|
||||
...
|
||||
access_log syslog:info piwik;
|
||||
...
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
# Setup syslog-ng
|
||||
|
||||
This is the config for the central server if any. If not, you can also use this config on the same server as Nginx.
|
||||
|
||||
```
|
||||
options {
|
||||
stats_freq(600); stats_level(1);
|
||||
log_fifo_size(1280000);
|
||||
log_msg_size(8192);
|
||||
};
|
||||
source s_nginx { udp(); };
|
||||
destination d_piwik {
|
||||
program("/usr/local/piwik/piwik.sh" template("$MSG\n"));
|
||||
};
|
||||
log { source(s_nginx); filter(f_info); destination(d_piwik); };
|
||||
```
|
||||
|
||||
# piwik.sh
|
||||
|
||||
Just needed to configure the best params for import_logs.py :
|
||||
```
|
||||
#!/bin/sh
|
||||
|
||||
exec python /path/to/misc/log-analytics/import_logs.py \
|
||||
--url=http://localhost/ --token-auth=<your_auth_token> \
|
||||
--idsite=1 --recorders=4 --enable-http-errors --enable-http-redirects --enable-static --enable-bots \
|
||||
--log-format-name=nginx_json -
|
||||
```
|
||||
|
||||
|
||||
And that's all !
|
||||
|
||||
|
||||
1765
www/analytics/misc/log-analytics/import_logs.py
Executable file
1765
www/analytics/misc/log-analytics/import_logs.py
Executable file
File diff suppressed because it is too large
Load diff
17
www/analytics/misc/others/ExamplePiwikTracker.php
Normal file
17
www/analytics/misc/others/ExamplePiwikTracker.php
Normal 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';
|
||||
32
www/analytics/misc/others/api_internal_call.php
Normal file
32
www/analytics/misc/others/api_internal_call.php
Normal 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;
|
||||
|
||||
30
www/analytics/misc/others/api_rest_call.php
Normal file
30
www/analytics/misc/others/api_rest_call.php
Normal 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>");
|
||||
}
|
||||
|
||||
39
www/analytics/misc/others/cli-script-bootstrap.php
Normal file
39
www/analytics/misc/others/cli-script-bootstrap.php
Normal 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();
|
||||
13
www/analytics/misc/others/download-count.txt
Normal file
13
www/analytics/misc/others/download-count.txt
Normal 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
|
||||
233
www/analytics/misc/others/geoipUpdateRows.php
Executable file
233
www/analytics/misc/others/geoipUpdateRows.php
Executable 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");
|
||||
}
|
||||
13
www/analytics/misc/others/iframeWidget.htm
Normal file
13
www/analytics/misc/others/iframeWidget.htm
Normal 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>
|
||||
63
www/analytics/misc/others/iframeWidget_localhost.php
Normal file
63
www/analytics/misc/others/iframeWidget_localhost.php
Normal 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>
|
||||
|
|
@ -0,0 +1,159 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<code_scheme name="Piwik-codestyle">
|
||||
<option name="LINE_SEPARATOR" value=" " />
|
||||
<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>
|
||||
|
||||
21
www/analytics/misc/others/phpstorm-codestyles/README.md
Normal file
21
www/analytics/misc/others/phpstorm-codestyles/README.md
Normal 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/
|
||||
|
||||
5
www/analytics/misc/others/stress.sh
Normal file
5
www/analytics/misc/others/stress.sh
Normal 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="
|
||||
|
|
@ -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/>";
|
||||
}
|
||||
|
||||
154
www/analytics/misc/others/test_generateLotsVisitsWebsites.php
Normal file
154
www/analytics/misc/others/test_generateLotsVisitsWebsites.php
Normal 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);
|
||||
}
|
||||
}
|
||||
30
www/analytics/misc/others/tracker_simpleImageTracker.php
Normal file
30
www/analytics/misc/others/tracker_simpleImageTracker.php
Normal 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>
|
||||
|
|
@ -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/');
|
||||
11
www/analytics/misc/others/widget_example_lastvisits.html
Normal file
11
www/analytics/misc/others/widget_example_lastvisits.html
Normal 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>
|
||||
55
www/analytics/misc/proxy-hide-piwik-url/README.md
Normal file
55
www/analytics/misc/proxy-hide-piwik-url/README.md
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
## 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.
|
||||
|
||||
### 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=(("https:" == document.location.protocol) ? "https" : "http") + "://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.defer=true; g.async=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.
|
||||
73
www/analytics/misc/proxy-hide-piwik-url/piwik.php
Normal file
73
www/analytics/misc/proxy-hide-piwik-url/piwik.php
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
<?php
|
||||
/**
|
||||
* Piwik - Open source web analytics
|
||||
* 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;
|
||||
|
||||
|
||||
// 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
|
||||
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;
|
||||
}
|
||||
|
||||
// 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) . '&';
|
||||
}
|
||||
header("Content-Type: image/gif");
|
||||
$stream_options = array('http' => array(
|
||||
'user_agent' => @$_SERVER['HTTP_USER_AGENT'],
|
||||
'header' => sprintf("Accept-Language: %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);
|
||||
0
www/analytics/misc/user/.gitkeep
Executable file
0
www/analytics/misc/user/.gitkeep
Executable file
33
www/analytics/misc/user/.htaccess
Normal file
33
www/analytics/misc/user/.htaccess
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
<Files ~ "\.(php|php4|php5|inc|tpl|in|twig)$">
|
||||
<IfModule mod_access.c>
|
||||
Deny from all
|
||||
Require all denied
|
||||
</IfModule>
|
||||
<IfModule !mod_access_compat>
|
||||
<IfModule mod_authz_host.c>
|
||||
Deny from all
|
||||
Require all denied
|
||||
</IfModule>
|
||||
</IfModule>
|
||||
<IfModule mod_access_compat>
|
||||
Deny from all
|
||||
Require all denied
|
||||
</IfModule>
|
||||
</Files>
|
||||
<Files ~ "\.(test\.php|gif|ico|jpg|png|svg|js|css|swf)$">
|
||||
<IfModule mod_access.c>
|
||||
Allow from all
|
||||
Require all granted
|
||||
</IfModule>
|
||||
<IfModule !mod_access_compat>
|
||||
<IfModule mod_authz_host.c>
|
||||
Allow from all
|
||||
Require all granted
|
||||
</IfModule>
|
||||
</IfModule>
|
||||
<IfModule mod_access_compat>
|
||||
Allow from all
|
||||
Require all granted
|
||||
</IfModule>
|
||||
Satisfy any
|
||||
</Files>
|
||||
1
www/analytics/misc/user/index.html
Normal file
1
www/analytics/misc/user/index.html
Normal file
|
|
@ -0,0 +1 @@
|
|||
This directory stores the custom logo for this Piwik server. Learn more: <a href="http://piwik.org/faq/new-to-piwik/faq_129/">How do I customise the logo in Piwik?</a>
|
||||
Loading…
Add table
Add a link
Reference in a new issue