update Piwik to version 2.16 (fixes #91)
This commit is contained in:
parent
296343bf3b
commit
d885a4baa9
5833 changed files with 418860 additions and 226988 deletions
5
www/analytics/misc/cron/.htaccess
Normal file
5
www/analytics/misc/cron/.htaccess
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
# Allow direct web access to Web cron
|
||||
<Files "archive.php">
|
||||
Order Allow,Deny
|
||||
Allow from all
|
||||
</Files>
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* Piwik - Open source web analytics
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
|
|
@ -17,12 +17,10 @@ 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";
|
||||
}
|
||||
define('PIWIK_ENABLE_ERROR_HANDLER', false);
|
||||
define('PIWIK_ENABLE_SESSION_START', false);
|
||||
|
||||
require_once PIWIK_INCLUDE_PATH . '/core/Common.php';
|
||||
|
||||
if (!empty($_SERVER['argv'][0])) {
|
||||
$callee = $_SERVER['argv'][0];
|
||||
|
|
@ -35,17 +33,43 @@ if (false !== strpos($callee, 'archive.php')) {
|
|||
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.
|
||||
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'
|
||||
See also: http://piwik.org/docs/setup-auto-archiving/
|
||||
|
||||
If you cannot use the console because it requires CLI
|
||||
try 'php archive.php --url=http://your.piwik/path'
|
||||
-------------------------------------------------------
|
||||
\n\n";
|
||||
}
|
||||
|
||||
$archiving = new Piwik\CronArchive();
|
||||
try {
|
||||
$archiving->main();
|
||||
} catch (Piwik\CronArchiveFatalException $ex) {
|
||||
$ex->logAndExit($archiving);
|
||||
} catch (Exception $e) {
|
||||
$archiving->logFatalExceptionAndExit($e);
|
||||
}
|
||||
|
||||
if (Piwik\Common::isPhpCliMode()) {
|
||||
require_once PIWIK_INCLUDE_PATH . "/core/bootstrap.php";
|
||||
|
||||
$console = new Piwik\Console();
|
||||
|
||||
// manipulate command line arguments so CoreArchiver command will be executed
|
||||
$script = array_shift($_SERVER['argv']);
|
||||
array_unshift($_SERVER['argv'], 'core:archive');
|
||||
array_unshift($_SERVER['argv'], $script);
|
||||
|
||||
$console->run();
|
||||
} else { // if running via web request, use CoreAdminHome.runCronArchiving method
|
||||
Piwik\Common::sendHeader('Content-type: text/plain');
|
||||
$_GET['module'] = 'API';
|
||||
$_GET['method'] = 'CoreAdminHome.runCronArchiving';
|
||||
$_GET['format'] = 'console'; // will use Content-type text/plain
|
||||
|
||||
if(!isset($_GET['token_auth'])) {
|
||||
echo "
|
||||
<b>You must specify the Super User token_auth as a parameter to this script, eg. <code>?token_auth=XYZ</code> if you wish to run this script through the browser. </b><br>
|
||||
However it is recommended to run it <a href='http://piwik.org/docs/setup-auto-archiving/'>via cron in the command line</a>, since it can take a long time to run.<br/>
|
||||
In a shell, execute for example the following to trigger archiving on the local Piwik server:<br/>
|
||||
<code>$ /path/to/php /path/to/piwik/console core:archive --url=http://your-website.org/path/to/piwik/</code>
|
||||
\n\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
require_once PIWIK_INCLUDE_PATH . "/index.php";
|
||||
}
|
||||
|
|
@ -1,52 +1,19 @@
|
|||
#!/bin/sh -e
|
||||
|
||||
# =======================================================================
|
||||
# BEFORE YOU USE THIS SCRIPT:
|
||||
# PLEASE DON'T.
|
||||
# =======================================================================
|
||||
# WARNING: this script archive.sh is DEPRECATED!
|
||||
#
|
||||
#
|
||||
# ==> Use archive.php instead. <==
|
||||
# => Replace your cron with `/usr/bin/php5 /path/to/piwik/console core:archive --url=http://example.org/piwik/`
|
||||
#
|
||||
# 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
|
||||
|
|
@ -61,39 +28,16 @@ act_path() {
|
|||
|
||||
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
|
||||
PIWIK_PATH="$PIWIK_CRON_FOLDER"/../../console
|
||||
|
||||
FILENAME_TOKEN_CONTENT=`$PHP_BIN $PIWIK_TOKEN_GENERATOR`
|
||||
TOKEN_AUTH=`cat $FILENAME_TOKEN_CONTENT | cut -f2`
|
||||
CONSOLE_CMD="$PHP_BIN -q $PIWIK_PATH core:archive --url=http://example.org"
|
||||
|
||||
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`
|
||||
MESSAGE="\n\n WARNING: this script archive.sh is DEPRECATED! \n\nPlease update your cron as explained in the documentation: http://piwik.org/docs/setup-auto-archiving/ \n\n"
|
||||
|
||||
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 $MESSAGE;
|
||||
|
||||
echo ""
|
||||
echo "Archiving for idsite = $idsite done!"
|
||||
fi
|
||||
done
|
||||
$CONSOLE_CMD
|
||||
|
||||
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 ""
|
||||
echo $MESSAGE;
|
||||
|
||||
exit 1
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/**
|
||||
* Piwik - Open source web analytics
|
||||
* Piwik - free/libre analytics platform
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
||||
|
|
@ -11,6 +11,10 @@
|
|||
|
||||
namespace Piwik;
|
||||
|
||||
use Piwik\Application\Environment;
|
||||
use Piwik\Tests\Framework\TestingEnvironmentManipulator;
|
||||
use Piwik\Tests\Framework\TestingEnvironmentVariables;
|
||||
|
||||
if (!defined('PIWIK_INCLUDE_PATH')) {
|
||||
define('PIWIK_INCLUDE_PATH', realpath(dirname(__FILE__) . "/../.."));
|
||||
}
|
||||
|
|
@ -31,9 +35,28 @@ if (!Common::isPhpCliMode()) {
|
|||
|
||||
$testmode = in_array('--testmode', $_SERVER['argv']);
|
||||
if ($testmode) {
|
||||
require_once PIWIK_INCLUDE_PATH . "/tests/PHPUnit/TestingEnvironment.php";
|
||||
define('PIWIK_TEST_MODE', true);
|
||||
|
||||
\Piwik_TestingEnvironment::addHooks();
|
||||
Environment::setGlobalEnvironmentManipulator(new TestingEnvironmentManipulator(new TestingEnvironmentVariables()));
|
||||
}
|
||||
|
||||
function getPiwikDomain()
|
||||
{
|
||||
foreach($_SERVER['argv'] as $param) {
|
||||
$pattern = '--piwik-domain=';
|
||||
if(false !== strpos($param, $pattern)) {
|
||||
return substr($param, strlen($pattern));
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
$environment = new Environment('cli');
|
||||
$environment->init();
|
||||
|
||||
$piwikDomain = getPiwikDomain();
|
||||
if($piwikDomain) {
|
||||
Url::setHost($piwikDomain);
|
||||
}
|
||||
|
||||
$token = Db::get()->fetchOne("SELECT token_auth
|
||||
|
|
@ -41,7 +64,8 @@ $token = Db::get()->fetchOne("SELECT token_auth
|
|||
WHERE superuser_access = 1
|
||||
ORDER BY date_registered ASC");
|
||||
|
||||
$filename = PIWIK_INCLUDE_PATH . '/tmp/cache/token.php';
|
||||
$filename = $environment->getContainer()->get('path.tmp') . '/cache/token.php';
|
||||
|
||||
$content = "<?php exit; //\t" . $token;
|
||||
file_put_contents($filename, $content);
|
||||
echo $filename;
|
||||
Loading…
Add table
Add a link
Reference in a new issue