public static function checkPiwikServerWorking($piwikServerUrl, $acceptInvalidSSLCertificates = false)
{
// Now testing if the webserver is running
try {
$fetched = Http::sendHttpRequestBy('curl', $piwikServerUrl, $timeout = 45, $userAgent = null, $destinationPath = null, $file = null, $followDepth = 0, $acceptLanguage = false, $acceptInvalidSSLCertificates);
} catch (Exception $e) {
$fetched = "ERROR fetching: " . $e->getMessage();
}
// this will match when Piwik not installed yet, or favicon not customised
$expectedStringAlt = 'plugins/CoreHome/images/favicon.png';
// this will match when Piwik is installed and favicon has been customised
$expectedString = 'misc/user/';
// see checkPiwikIsNotInstalled()
$expectedStringAlreadyInstalled = 'piwik-is-already-installed';
$expectedStringNotFound = strpos($fetched, $expectedString) === false && strpos($fetched, $expectedStringAlt) === false && strpos($fetched, $expectedStringAlreadyInstalled) === false;
$hasError = false !== strpos($fetched, PAGE_TITLE_WHEN_ERROR);
if ($hasError || $expectedStringNotFound) {
throw new Exception("\nPiwik should be running at: " . $piwikServerUrl . " but this URL returned an unexpected response: '" . $fetched . "'\n\n");
}
}