// Include the common auth system files (including the OAuth2 Server object).
require_once(__DIR__.'/authsystem.inc.php');
+if ($settings['piwik_enabled']) {
+ // We do not send out an HTML file, so we need to do the Piwik tracking ourselves.
+ // Init is done here, actual tracking before exit.
+ require_once($settings['piwik_tracker_path'].'PiwikTracker.php');
+ PiwikTracker::$URL = ((strpos($settings['piwik_url'], '://') === false) ? 'http://localhost' : '' ).$settings['piwik_url'];
+ $piwikTracker = new PiwikTracker($idSite = $settings['piwik_site_id']);
+}
$errors = $utils->checkForSecureConnection();
$utils->sendSecurityHeaders();
$token_OK = $server->verifyResourceRequest(OAuth2\Request::createFromGlobals());
if (!$token_OK) {
$server->getResponse()->send();
+ if ($settings['piwik_enabled']) { $piwikTracker->doTrackPageView('API Request: Bad Token'); }
exit();
}
$token = $server->getAccessTokenData(OAuth2\Request::createFromGlobals());
print(json_encode(array('error' => 'insecure_connection',
'error_description' => 'Your connection is insecure. The API can only be accessed on secure connections.')));
}
+if ($settings['piwik_enabled']) {
+ $piwikTracker->doTrackPageView('API Request'.(strlen($token['scope'])?': '.$token['scope']:''));
+}
?>
$session = $utils->getLoginSession($user['id'], $session);
}
}
+ if ($settings['piwik_enabled']) {
+ // If we do not send out an HTML file, we need to do the Piwik tracking ourselves.
+ require_once($settings['piwik_tracker_path'].'PiwikTracker.php');
+ PiwikTracker::$URL = ((strpos($settings['piwik_url'], '://') === false) ? 'http://localhost' : '' ).$settings['piwik_url'];
+ $piwikTracker = new PiwikTracker($idSite = $settings['piwik_site_id']);
+ $piwikTracker->doTrackPageView('Handle Authorize Request');
+ }
// Handle authorize request, forwarding code in GET parameters if the user has authorized your client.
$server->handleAuthorizeRequest($request, $response, $is_authorized, $user['id']);
/* For testing only
// Sanitize settings.
$settings['piwik_enabled'] = (@$settings['piwik_enabled']) ? true : false;
$settings['piwik_site_id'] = intval(@$settings['piwik_site_id']);
-$settings['piwik_url'] = strlen($settings['piwik_url']) ? $settings['piwik_url'] : '/piwik/';
+$settings['piwik_url'] = strlen(@$settings['piwik_url']) ? $settings['piwik_url'] : '/piwik/';
+$settings['piwik_tracker_path'] = strlen(@$settings['piwik_tracker_path']) ? $settings['piwik_tracker_path'] : '../vendor/piwik/piwik-php-tracker/';
/* Creating the DB tables:
CREATE TABLE `auth_sessions` (