本文整理汇总了PHP中Piwik\Tracker\Request::authenticateSuperUserOrAdmin方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::authenticateSuperUserOrAdmin方法的具体用法?PHP Request::authenticateSuperUserOrAdmin怎么用?PHP Request::authenticateSuperUserOrAdmin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Piwik\Tracker\Request
的用法示例。
在下文中一共展示了Request::authenticateSuperUserOrAdmin方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_authenticateSuperUserOrAdmin_ShouldAlwaysWorkForSuperUser
public function test_authenticateSuperUserOrAdmin_ShouldAlwaysWorkForSuperUser()
{
Fixture::createSuperUser(false);
$token = Fixture::getTokenAuth();
$isAuthenticated = Request::authenticateSuperUserOrAdmin($token, 1);
$this->assertTrue($isAuthenticated);
$isAuthenticated = Request::authenticateSuperUserOrAdmin($token, 2);
$this->assertTrue($isAuthenticated);
}
示例2: authenticateBulkTrackingRequests
private function authenticateBulkTrackingRequests($rawData)
{
$rawData = trim($rawData);
$rawData = Common::sanitizeLineBreaks($rawData);
// POST data can be array of string URLs or array of arrays w/ visit info
$jsonData = json_decode($rawData, $assoc = true);
if (isset($jsonData['requests'])) {
$this->requests = $jsonData['requests'];
}
$tokenAuth = Common::getRequestVar('token_auth', false, 'string', $jsonData);
if (empty($tokenAuth)) {
throw new Exception("token_auth must be specified when using Bulk Tracking Import. See <a href='http://developer.piwik.org/api-reference/tracking-api'>Tracking Doc</a>");
}
if (!empty($this->requests)) {
$idSitesForAuthentication = array();
foreach ($this->requests as &$request) {
// if a string is sent, we assume its a URL and try to parse it
if (is_string($request)) {
$params = array();
$url = @parse_url($request);
if (!empty($url)) {
@parse_str($url['query'], $params);
$request = $params;
}
}
// We need to check access for each single request
if (isset($request['idsite']) && !in_array($request['idsite'], $idSitesForAuthentication)) {
$idSitesForAuthentication[] = $request['idsite'];
}
}
foreach ($idSitesForAuthentication as $idSiteForAuthentication) {
// a Bulk Tracking request that is not authenticated should fail
if (!Request::authenticateSuperUserOrAdmin($tokenAuth, $idSiteForAuthentication)) {
throw new Exception("token_auth specified does not have Admin permission for site " . intval($idSiteForAuthentication));
}
}
}
return $tokenAuth;
}