Skip to content

Commit

Permalink
Fixes #4483 - thanks for the report that's really useful as loads of …
Browse files Browse the repository at this point in the history
…users are on cpanel and hostgator!

Also updated the doc at: http://piwik.org/docs/setup-auto-archiving/#cpanel-how-to-set-up-the-cron-script-using-cpanel
and removed http:// in the cpanel examples..
  • Loading branch information
mattab committed Jan 7, 2014
1 parent 899f7a5 commit 267b717
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions core/CronArchive.php
Expand Up @@ -840,7 +840,7 @@ private function initTokenAuth()

private function initPiwikHost()
{
// If archive.php run as a web cron, we use the current hostname
// If archive.php run as a web cron, we use the current hostname+path
if (!Common::isPhpCliMode()) {
// example.org/piwik/misc/cron/
$piwikUrl = Common::sanitizeInputValue(Url::getCurrentUrlWithoutFileName());
Expand All @@ -849,12 +849,19 @@ private function initPiwikHost()
} else {
// If archive.php run as CLI/shell we require the piwik url to be set
$piwikUrl = $this->isParameterSet("url", true);
if (!$piwikUrl
|| !\Piwik\UrlHelper::isLookLikeUrl($piwikUrl)
) {
$this->logFatalError("archive.php expects the argument --url to be set to your Piwik URL, for example: --url=http://example.org/piwik/ "
. "\n--help for more information", $backtrace = false);

if (!$piwikUrl) {
$this->logFatalErrorUrlExpected();
}

if(!\Piwik\UrlHelper::isLookLikeUrl($piwikUrl)) {
// try adding http:// in case it's missing
$piwikUrl = "http://" . $piwikUrl;
}
if(!\Piwik\UrlHelper::isLookLikeUrl($piwikUrl)) {
$this->logFatalErrorUrlExpected();
}

// ensure there is a trailing slash
if ($piwikUrl[strlen($piwikUrl) - 1] != '/') {
$piwikUrl .= '/';
Expand Down Expand Up @@ -1086,5 +1093,11 @@ protected function setSiteIsArchived($idsite)
}
}
}

private function logFatalErrorUrlExpected()
{
$this->logFatalError("archive.php expects the argument --url to be set to your Piwik URL, for example: --url=http://example.org/piwik/ "
. "\n--help for more information", $backtrace = false);
}
}

0 comments on commit 267b717

Please sign in to comment.