当前位置: 首页>>代码示例>>PHP>>正文


PHP Request::authenticateSuperUserOrAdmin方法代码示例

本文整理汇总了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);
 }
开发者ID:dorelljames,项目名称:piwik,代码行数:9,代码来源:RequestTest.php

示例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;
 }
开发者ID:KiwiJuicer,项目名称:handball-dachau,代码行数:39,代码来源:Tracker.php


注:本文中的Piwik\Tracker\Request::authenticateSuperUserOrAdmin方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。