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


PHP Piwik::getCurrentUserTokenAuth方法代码示例

本文整理汇总了PHP中Piwik::getCurrentUserTokenAuth方法的典型用法代码示例。如果您正苦于以下问题:PHP Piwik::getCurrentUserTokenAuth方法的具体用法?PHP Piwik::getCurrentUserTokenAuth怎么用?PHP Piwik::getCurrentUserTokenAuth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Piwik的用法示例。


在下文中一共展示了Piwik::getCurrentUserTokenAuth方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: worldMap

 function worldMap()
 {
     if (!Piwik_PluginsManager::getInstance()->isPluginActivated('UserCountry')) {
         return '';
     }
     $idSite = Piwik_Common::getRequestVar('idSite', 1, 'int');
     Piwik::checkUserHasViewAccess($idSite);
     $period = Piwik_Common::getRequestVar('period');
     $date = Piwik_Common::getRequestVar('date');
     $token_auth = Piwik::getCurrentUserTokenAuth();
     $view = Piwik_View::factory('worldmap');
     $view->dataUrl = "?module=API" . "&method=API.getProcessedReport&format=XML" . "&apiModule=UserCountry&apiAction=getCountry" . "&idSite=" . $idSite . "&period=" . $period . "&date=" . $date . "&token_auth=" . $token_auth . "&segment=" . Piwik_Common::unsanitizeInputValue(Piwik_Common::getRequestVar('segment', '')) . "&filter_limit=-1";
     // definition of the color scale
     $view->hueMin = 218;
     $view->hueMax = 216;
     $view->satMin = "0.285";
     $view->satMax = "0.9";
     $view->lgtMin = ".97";
     $view->lgtMax = ".44";
     $request = new Piwik_API_Request('method=API.getMetadata&format=PHP' . '&apiModule=UserCountry&apiAction=getCountry' . '&idSite=' . $idSite . '&period=' . $period . '&date=' . $date . '&token_auth=' . $token_auth . '&filter_limit=-1');
     $metaData = $request->process();
     $metrics = array();
     foreach ($metaData[0]['metrics'] as $id => $val) {
         if (Piwik_Common::getRequestVar('period') == 'day' || $id != 'nb_uniq_visitors') {
             $metrics[] = array($id, $val);
         }
     }
     foreach ($metaData[0]['processedMetrics'] as $id => $val) {
         $metrics[] = array($id, $val);
     }
     $view->metrics = $metrics;
     $view->defaultMetric = 'nb_visits';
     echo $view->render();
 }
开发者ID:nnnnathann,项目名称:piwik,代码行数:34,代码来源:Controller.php

示例2: render

 public function render()
 {
     try {
         $this->currentModule = Piwik::getModule();
         $this->currentPluginName = Piwik::getCurrentPlugin()->getName();
         $this->userLogin = Piwik::getCurrentUserLogin();
         $showWebsiteSelectorInUserInterface = Zend_Registry::get('config')->General->show_website_selector_in_user_interface;
         if ($showWebsiteSelectorInUserInterface) {
             $sites = Piwik_SitesManager_API::getSitesWithAtLeastViewAccess();
             usort($sites, create_function('$site1, $site2', 'return strcasecmp($site1["name"], $site2["name"]);'));
             $this->sites = $sites;
         }
         $this->showWebsiteSelectorInUserInterface = $showWebsiteSelectorInUserInterface;
         $this->url = Piwik_Url::getCurrentUrl();
         $this->token_auth = Piwik::getCurrentUserTokenAuth();
         $this->userHasSomeAdminAccess = Piwik::isUserHasSomeAdminAccess();
         $this->userIsSuperUser = Piwik::isUserIsSuperUser();
         $this->piwik_version = Piwik_Version::VERSION;
         $this->latest_version_available = Piwik_UpdateCheck::isNewestVersionAvailable();
         $this->loginModule = Zend_Registry::get('auth')->getName();
     } catch (Exception $e) {
         // can fail, for example at installation (no plugin loaded yet)
     }
     $this->totalTimeGeneration = Zend_Registry::get('timer')->getTime();
     try {
         $this->totalNumberOfQueries = Piwik::getQueryCount();
     } catch (Exception $e) {
         $this->totalNumberOfQueries = 0;
     }
     header('Content-Type: text/html; charset=utf-8');
     header("Pragma: ");
     header("Cache-Control: no-store, must-revalidate");
     return $this->smarty->fetch($this->template);
 }
开发者ID:klando,项目名称:pgpiwik,代码行数:34,代码来源:View.php

示例3: testClearspring

 function testClearspring()
 {
     $view = Piwik_View::factory('test_widget');
     $view->url1 = Piwik_Url::getCurrentUrlWithoutQueryString() . '?module=Widgetize&action=iframe&moduleToWidgetize=Referers&actionToWidgetize=getKeywords&idSite=1&period=day&date=yesterday&filter_limit=5&token_auth=' . Piwik::getCurrentUserTokenAuth();
     $view->url2 = Piwik_Url::getCurrentUrlWithoutQueryString() . '?module=Widgetize&action=iframe&moduleToWidgetize=VisitTime&actionToWidgetize=getVisitInformationPerServerTime&idSite=1&period=day&date=yesterday&viewDataTable=graphVerticalBar&show_footer=0&token_auth=' . Piwik::getCurrentUserTokenAuth();
     $view->url3 = Piwik_Url::getCurrentUrlWithoutQueryString() . '?module=Widgetize&action=iframe&moduleToWidgetize=Referers&actionToWidgetize=getKeywords&idSite=1&period=day&date=yesterday&viewDataTable=cloud&show_footer=1&filter_limit=15&show_search=false&token_auth=' . Piwik::getCurrentUserTokenAuth();
     echo $view->render();
 }
开发者ID:Doluci,项目名称:tomatocart,代码行数:8,代码来源:Controller.php

示例4: widget

 public function widget($fetch = false)
 {
     $view = Piwik_View::factory('index');
     $view->idSite = $this->idSite;
     $view = $this->setCounters($view);
     $view->liveRefreshAfterMs = (int) Piwik_Config::getInstance()->General['live_widget_refresh_after_seconds'] * 1000;
     $view->visitors = $this->getLastVisitsStart($fetchPlease = true);
     $view->liveTokenAuth = Piwik::getCurrentUserTokenAuth();
     return $this->render($view, $fetch);
 }
开发者ID:nomoto-ubicast,项目名称:piwik,代码行数:10,代码来源:Controller.php

示例5: widget

	public function widget($fetch = false)
	{
		Piwik_API_Request::reloadAuthUsingTokenAuth(); 
		$view = Piwik_View::factory('index');
		$view->idSite = $this->idSite;
		$view = $this->setCounters($view);
		$view->liveRefreshAfterMs = (int)Zend_Registry::get('config')->General->live_widget_refresh_after_seconds * 1000;
		$view->visitors = $this->getLastVisitsStart($fetchPlease = true);
		$view->liveTokenAuth = Piwik::getCurrentUserTokenAuth();
		return $this->render($view, $fetch);
	}
开发者ID:BackupTheBerlios,项目名称:oos-svn,代码行数:11,代码来源:Controller.php

示例6: testAllSizes

 public function testAllSizes()
 {
     Piwik::checkUserIsSuperUser();
     $view = Piwik_View::factory('debug_graphs_all_sizes');
     $this->setGeneralVariablesView($view);
     $period = Piwik_Common::getRequestVar('period', 'day', 'string');
     $date = Piwik_Common::getRequestVar('date', 'today', 'string');
     $_GET['token_auth'] = Piwik::getCurrentUserTokenAuth();
     $availableReports = Piwik_API_API::getInstance()->getReportMetadata($this->idSite, $period, $date);
     $view->availableReports = $availableReports;
     $view->graphTypes = array('');
     $view->graphSizes = array(array(null, null), array(Piwik_ReportRenderer::IMAGE_GRAPH_WIDTH, Piwik_ReportRenderer::IMAGE_GRAPH_HEIGHT), array(460, 150), array(300, 150), array(240, 150), array(800, 150), array(600, 300, $fontSize = 18, 300, 150));
     echo $view->render();
 }
开发者ID:neolf,项目名称:PIWIK4MOBILE,代码行数:14,代码来源:Controller.php

示例7: getAllInterfaceString

 /**
  * Returns a HTML page containing help for all the successfully loaded APIs.
  *  For each module it will return a mini help with the method names, parameters to give,
  * links to get the result in Xml/Csv/etc
  *
  * @param bool    $outputExampleUrls
  * @param string  $prefixUrls
  * @return string
  */
 public function getAllInterfaceString($outputExampleUrls = true, $prefixUrls = '')
 {
     if (!empty($prefixUrls)) {
         $prefixUrls = 'http://demo.piwik.org/';
     }
     $str = $toc = '';
     $token_auth = "&token_auth=" . Piwik::getCurrentUserTokenAuth();
     $parametersToSet = array('idSite' => Piwik_Common::getRequestVar('idSite', 1, 'int'), 'period' => Piwik_Common::getRequestVar('period', 'day', 'string'), 'date' => Piwik_Common::getRequestVar('date', 'today', 'string'));
     foreach (Piwik_API_Proxy::getInstance()->getMetadata() as $class => $info) {
         $moduleName = Piwik_API_Proxy::getInstance()->getModuleNameFromClassName($class);
         if (in_array($moduleName, $this->modulesToHide)) {
             continue;
         }
         $toc .= "<a href='#{$moduleName}'>{$moduleName}</a><br/>";
         $str .= "\n<h2 name='{$moduleName}' id='{$moduleName}'>Module " . $moduleName . "</h2>";
         $str .= "<div class='apiDescription'> " . $info['__documentation'] . " </div>";
         foreach ($info as $methodName => $infoMethod) {
             if ($methodName == '__documentation') {
                 continue;
             }
             $params = $this->getParametersString($class, $methodName);
             $str .= "\n <div class='apiMethod'>- <b>{$moduleName}.{$methodName} </b>" . $params . "";
             $str .= '<small>';
             if ($outputExampleUrls) {
                 // we prefix all URLs with $prefixUrls
                 // used when we include this output in the Piwik official documentation for example
                 $str .= "<span class=\"example\">";
                 $exampleUrl = $this->getExampleUrl($class, $methodName, $parametersToSet);
                 if ($exampleUrl !== false) {
                     $lastNUrls = '';
                     if (preg_match('/(&period)|(&date)/', $exampleUrl)) {
                         $exampleUrlRss1 = $prefixUrls . $this->getExampleUrl($class, $methodName, array('date' => 'last10', 'period' => 'day') + $parametersToSet);
                         $exampleUrlRss2 = $prefixUrls . $this->getExampleUrl($class, $methodName, array('date' => 'last5', 'period' => 'week') + $parametersToSet);
                         $lastNUrls = ",\tRSS of the last <a target=_blank href='{$exampleUrlRss1}&format=rss{$token_auth}&translateColumnNames=1'>10 days</a>";
                     }
                     $exampleUrl = $prefixUrls . $exampleUrl;
                     $str .= " [ Example in  \n\t\t\t\t\t\t\t\t\t<a target=_blank href='{$exampleUrl}&format=xml{$token_auth}'>XML</a>, \n\t\t\t\t\t\t\t\t\t<a target=_blank href='{$exampleUrl}&format=JSON{$token_auth}'>Json</a>, \n\t\t\t\t\t\t\t\t\t<a target=_blank href='{$exampleUrl}&format=Tsv{$token_auth}&translateColumnNames=1'>Tsv (Excel)</a> \n\t\t\t\t\t\t\t\t\t{$lastNUrls}\n\t\t\t\t\t\t\t\t\t]";
                 } else {
                     $str .= " [ No example available ]";
                 }
                 $str .= "</span>";
             }
             $str .= '</small>';
             $str .= "</div>\n";
         }
         $str .= '<div style="margin:15px;"><a href="#topApiRef" style="color:#95AECB">↑ Back to top</a></div>';
     }
     $str = "<h2 id='topApiRef' name='topApiRef'>Quick access to APIs</h2> \n\t\t\t\t{$toc} \n\t\t\t\t{$str}";
     return $str;
 }
开发者ID:nnnnathann,项目名称:piwik,代码行数:59,代码来源:DocumentationGenerator.php

示例8: saveLayout

 /**
  * Saves the layout for the current user
  * anonymous = in the session
  * authenticated user = in the DB
  */
 public function saveLayout()
 {
     $layout = Piwik_Common::getRequestVar('layout');
     $idDashboard = Piwik_Common::getRequestVar('idDashboard', 1, 'int');
     $currentUser = Piwik::getCurrentUserLogin();
     if (Piwik_Common::getRequestVar('token_auth', false) != Piwik::getCurrentUserTokenAuth()) {
         return;
     }
     if ($currentUser == 'anonymous') {
         $session = new Zend_Session_Namespace("Piwik_Dashboard");
         $session->dashboardLayout = $layout;
     } else {
         $this->saveLayoutForUser($currentUser, $idDashboard, $layout);
     }
 }
开发者ID:Doluci,项目名称:tomatocart,代码行数:20,代码来源:Controller.php

示例9: render

 /**
  * Renders the current view.
  *
  * @return string Generated template
  */
 public function render()
 {
     try {
         $this->currentModule = Piwik::getModule();
         $this->currentAction = Piwik::getAction();
         $userLogin = Piwik::getCurrentUserLogin();
         $this->userLogin = $userLogin;
         // workaround for #1331
         $count = method_exists('Piwik', 'getWebsitesCountToDisplay') ? Piwik::getWebsitesCountToDisplay() : 1;
         $sites = Piwik_SitesManager_API::getInstance()->getSitesWithAtLeastViewAccess($count);
         usort($sites, create_function('$site1, $site2', 'return strcasecmp($site1["name"], $site2["name"]);'));
         $this->sites = $sites;
         $this->url = Piwik_Common::sanitizeInputValue(Piwik_Url::getCurrentUrl());
         $this->token_auth = Piwik::getCurrentUserTokenAuth();
         $this->userHasSomeAdminAccess = Piwik::isUserHasSomeAdminAccess();
         $this->userIsSuperUser = Piwik::isUserIsSuperUser();
         $this->latest_version_available = Piwik_UpdateCheck::isNewestVersionAvailable();
         $this->disableLink = Piwik_Common::getRequestVar('disableLink', 0, 'int');
         $this->isWidget = Piwik_Common::getRequestVar('widget', 0, 'int');
         if (Zend_Registry::get('config')->General->autocomplete_min_sites <= count($sites)) {
             $this->show_autocompleter = true;
         } else {
             $this->show_autocompleter = false;
         }
         // workaround for #1331
         $this->loginModule = method_exists('Piwik', 'getLoginPluginName') ? Piwik::getLoginPluginName() : 'Login';
         $user = Piwik_UsersManager_API::getInstance()->getUser($userLogin);
         $this->userAlias = $user['alias'];
     } catch (Exception $e) {
         // can fail, for example at installation (no plugin loaded yet)
     }
     $this->totalTimeGeneration = Zend_Registry::get('timer')->getTime();
     try {
         $this->totalNumberOfQueries = Piwik::getQueryCount();
     } catch (Exception $e) {
         $this->totalNumberOfQueries = 0;
     }
     // workaround for #1331
     if (method_exists('Piwik', 'overrideCacheControlHeaders')) {
         Piwik::overrideCacheControlHeaders('no-store');
     }
     @header('Content-Type: ' . $this->contentType);
     if ($this->xFrameOptions) {
         @header('X-Frame-Options: ' . $this->xFrameOptions);
     }
     return $this->smarty->fetch($this->template);
 }
开发者ID:neolf,项目名称:PIWIK4MOBILE,代码行数:52,代码来源:View.php

示例10: getAllInterfaceString

 /**
  * Returns a HTML page containing help for all the successfully loaded APIs.
  *  For each module it will return a mini help with the method names, parameters to give, 
  * links to get the result in Xml/Csv/etc
  *
  * @return string
  */
 public function getAllInterfaceString($outputExampleUrls = true, $prefixUrls = '')
 {
     $str = '';
     $token_auth = "&token_auth=" . Piwik::getCurrentUserTokenAuth();
     $parametersToSet = array('idSite' => Piwik_Common::getRequestVar('idSite', 1, 'int'), 'period' => Piwik_Common::getRequestVar('period', 'day', 'string'), 'date' => Piwik_Common::getRequestVar('date', 'today', 'string'));
     foreach (Piwik_API_Proxy::getInstance()->getMetadata() as $class => $info) {
         $moduleName = Piwik_API_Proxy::getInstance()->getModuleNameFromClassName($class);
         $str .= "\n<h2 id='{$moduleName}'>Module " . $moduleName . "</h2>";
         foreach ($info as $methodName => $infoMethod) {
             $params = $this->getStrListParameters($class, $methodName);
             $str .= "\n" . "- <b>{$moduleName}.{$methodName} " . $params . "</b>";
             $str .= '<small>';
             if ($outputExampleUrls) {
                 // we prefix all URLs with $prefixUrls
                 // used when we include this output in the Piwik official documentation for example
                 $str .= "<span class=\"example\">";
                 $exampleUrl = $this->getExampleUrl($class, $methodName, $parametersToSet);
                 if ($exampleUrl !== false) {
                     $lastNUrls = '';
                     if (preg_match('/(&period)|(&date)/', $exampleUrl)) {
                         $exampleUrlRss1 = $prefixUrls . $this->getExampleUrl($class, $methodName, array('date' => 'last10') + $parametersToSet);
                         $exampleUrlRss2 = $prefixUrls . $this->getExampleUrl($class, $methodName, array('date' => 'last5', 'period' => 'week') + $parametersToSet);
                         $lastNUrls = ",\tRSS of the last <a target=_blank href='{$exampleUrlRss1}&format=rss{$token_auth}'>10 days</a>, <a target=_blank href='{$exampleUrlRss2}&format=Rss'>5 weeks</a>,\n\t\t\t\t\t\t\t\t\tXML of the <a target=_blank href='{$exampleUrlRss1}&format=xml{$token_auth}'>last 10 days</a>";
                     }
                     $exampleUrl = $prefixUrls . $exampleUrl;
                     $str .= " [ Example in  \n\t\t\t\t\t\t\t\t\t<a target=_blank href='{$exampleUrl}&format=xml{$token_auth}'>XML</a>, \n\t\t\t\t\t\t\t\t\t<a target=_blank href='{$exampleUrl}&format=PHP&prettyDisplay=true{$token_auth}'>PHP</a>, \n\t\t\t\t\t\t\t\t\t<a target=_blank href='{$exampleUrl}&format=JSON{$token_auth}'>Json</a>, \n\t\t\t\t\t\t\t\t\t<a target=_blank href='{$exampleUrl}&format=Csv{$token_auth}'>Csv</a>, \n\t\t\t\t\t\t\t\t\t<a target=_blank href='{$exampleUrl}&format=Html{$token_auth}'>Basic html</a> \n\t\t\t\t\t\t\t\t\t{$lastNUrls}\n\t\t\t\t\t\t\t\t\t]";
                 } else {
                     $str .= " [ No example available ]";
                 }
                 $str .= "</span>";
             }
             $str .= '</small>';
             $str .= "\n<br>";
         }
     }
     return $str;
 }
开发者ID:Doluci,项目名称:tomatocart,代码行数:44,代码来源:DocumentationGenerator.php

示例11: getKeywordsForPage

    function getKeywordsForPage()
    {
        Piwik::checkUserHasViewAccess($this->idSite);
        $requestUrl = '&date=previous1' . '&period=week' . '&idSite=' . $this->idSite;
        $topPageUrlRequest = $requestUrl . '&method=Actions.getPageUrls' . '&filter_limit=50' . '&format=original';
        $request = new Piwik_API_Request($topPageUrlRequest);
        $request = $request->process();
        $tables = $request->getArray();
        $topPageUrls = $tables[key($tables)];
        $topPageUrls = $topPageUrls->getRowsMetadata('url');
        $topPageUrl = current(array_values($topPageUrls));
        if (empty($topPageUrl)) {
            $topPageUrl = $this->site->getMainUrl();
        }
        $url = $topPageUrl;
        // HTML
        $api = Piwik_Url::getCurrentUrlWithoutFileName() . '?module=API&method=Referers.getKeywordsForPageUrl' . '&format=php' . '&filter_limit=10' . '&token_auth=' . Piwik::getCurrentUserTokenAuth();
        $api .= $requestUrl;
        $code = '
// This function will call the API to get best keyword for current URL.
// Then it writes the list of best keywords in a HTML list
function DisplayTopKeywords($url = "")
{
	// Do not spend more than 1 second fetching the data
	@ini_set("default_socket_timeout", $timeout = 1);
	// Get the Keywords data
	$url = empty($url) ? "http://". $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"] : $url;
	$api = "' . $api . '&url=" . urlencode($url);
	$keywords = @unserialize(file_get_contents($api));
	if($keywords === false || isset($keywords["result"])) {
		// DEBUG ONLY: uncomment for troubleshooting an empty output (the URL output reveals the token_auth)
		// echo "Error while fetching the <a href=\'$api\'>Top Keywords from Piwik</a>";
		return;
	}

	// Display the list in HTML
	$output = "<h2>Top Keywords for <a href=\'$url\'>$url</a></h2><ul>";
	foreach($keywords as $keyword) {
		$output .= "<li>". $keyword[0]. "</li>";
	}
	if(empty($keywords)) { $output .= "Nothing yet..."; }
	$output .= "</ul>";
	echo $output;
}
';
        $jsonRequest = str_replace('format=php', 'format=json', $api);
        echo "<p>This widget is designed to work in your website directly.\n\t\tThis widget makes it easy to use Piwik to <i>automatically display the list of Top Keywords</i>, for each of your website Page URLs.</p>\n\t\t<p>\n\t\t<b>Example API URL</b> - For example if you would like to get the top 10 keywords, used last week, to land on the page <a target='_blank' href='{$topPageUrl}'>{$topPageUrl}</a>,\n\t\tin format JSON: you would dynamically fetch the data using <a target='_blank' href='{$jsonRequest}&url=" . urlencode($topPageUrl) . "'>this API request URL</a>. Make sure you encode the 'url' parameter in the URL.</p>\n\t\t\n\t\t<p><b>PHP Function ready to use!</b> - If you use PHP on your website, we have prepared a small code snippet that you can copy paste in your Website PHP files. You can then simply call the function <code>DisplayTopKeywords();</code> anywhere in your template, at the bottom of the content or in your blog sidebar.\n\t\tIf you run this code in your page {$topPageUrl}, it would output the following:";
        echo "<div style='width:400px;margin-left:20px;padding:10px;border:1px solid black;'>";
        function DisplayTopKeywords($url = "", $api)
        {
            // Do not spend more than 1 second fetching the data
            @ini_set("default_socket_timeout", $timeout = 1);
            // Get the Keywords data
            $url = empty($url) ? "http://" . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"] : $url;
            $api = $api . "&url=" . urlencode($url);
            $keywords = @unserialize(file_get_contents($api));
            if ($keywords === false || isset($keywords["result"])) {
                // DEBUG ONLY: uncomment for troubleshooting an empty output (the URL output reveals the token_auth)
                //echo "Error while fetching the <a href=\'".$api."\'>Top Keywords from Piwik</a>";
                return;
            }
            // Display the list in HTML
            $output = "<h2>Top Keywords for <a href=\\'{$url}\\'>{$url}</a></h2><ul>";
            foreach ($keywords as $keyword) {
                $output .= "<li>" . $keyword[0] . "</li>";
            }
            if (empty($keywords)) {
                $output .= "Nothing yet...";
            }
            $output .= "</ul>";
            echo $output;
        }
        DisplayTopKeywords($topPageUrl, $api);
        echo "</div><br/>\n\t\t<p>Here is the PHP function that you can paste in your pages:</P>\n\t\t<textarea cols=60 rows=8>&lt;?php\n" . htmlspecialchars($code) . "\n DisplayTopKeywords();</textarea>\n\t\t";
        echo "\n\t\t<p><b>Notes</b>: You can for example edit the code to to make the Top search keywords link to your Website search result pages.\n\t\t<br/>On medium to large traffic websites, we recommend to cache this data, as to minimize the performance impact of calling the Piwik API on each page view.\n\t\t</p>\n\t\t";
    }
开发者ID:0h546f6f78696342756e4e59,项目名称:piwik,代码行数:76,代码来源:Controller.php

示例12: checkTokenInUrl

 /**
  * Checks that the specified token matches the current logged in user token.
  * Note: this protection against CSRF should be limited to controller
  * actions that are either invoked via AJAX or redirect to a page
  * within the site.  The token should never appear in the browser's
  * address bar.
  *
  * @throws Piwik_Access_NoAccessException  if token doesn't match
  * @return void
  */
 protected function checkTokenInUrl()
 {
     if (Piwik_Common::getRequestVar('token_auth', false) != Piwik::getCurrentUserTokenAuth()) {
         throw new Piwik_Access_NoAccessException(Piwik_TranslateException('General_ExceptionInvalidToken'));
     }
 }
开发者ID:nomoto-ubicast,项目名称:piwik,代码行数:16,代码来源:Controller.php

示例13: getAllInterfaceString

	/**
	 * Returns a HTML page containing help for all the successfully loaded APIs.
	 *  For each module it will return a mini help with the method names, parameters to give, 
	 * links to get the result in Xml/Csv/etc
	 *
	 * @return string
	 */
	public function getAllInterfaceString( $outputExampleUrls = true, $prefixUrls = '' )
	{
		$str = $toc = '';
		$token_auth = "&token_auth=" . Piwik::getCurrentUserTokenAuth();
		$parametersToSet = array(
								'idSite' 	=> Piwik_Common::getRequestVar('idSite', 1, 'int'),
								'period' 	=> Piwik_Common::getRequestVar('period', 'day', 'string'),
								'date'		=> Piwik_Common::getRequestVar('date', 'today', 'string')
							);
		
		
		foreach(Piwik_API_Proxy::getInstance()->getMetadata() as $class => $info)
		{
			$moduleName = Piwik_API_Proxy::getInstance()->getModuleNameFromClassName($class);
			if(in_array($moduleName, $this->modulesToHide))
			{
				continue;
			}
			$toc .= "<a href='#$moduleName'>$moduleName</a><br/>";
			$str .= "\n<h2 name='$moduleName' id='$moduleName'>Module ".$moduleName."</h2>";
			$str .= "<div class='apiDescription'> ".$info['__documentation'] . " </div>";
			foreach($info as $methodName => $infoMethod)
			{
				if($methodName=='__documentation')
				{
					continue;
				}
				$params = $this->getParametersString($class, $methodName);
				$str .= "\n <div class='apiMethod'>- <b>$moduleName.$methodName </b>" . $params . "";
				$str .= '<small>';
				
				if($outputExampleUrls)
				{
					// we prefix all URLs with $prefixUrls
					// used when we include this output in the Piwik official documentation for example
					$str .= "<span class=\"example\">";
					$exampleUrl = $this->getExampleUrl($class, $methodName, $parametersToSet);
					if($exampleUrl !== false)
					{
						$lastNUrls = '';
						if( preg_match('/(&period)|(&date)/',$exampleUrl))
						{
							$exampleUrlRss1 = $prefixUrls . $this->getExampleUrl($class, $methodName, array('date' => 'last10', 'period' => 'day') + $parametersToSet) ;
							$exampleUrlRss2 = $prefixUrls . $this->getExampleUrl($class, $methodName, array('date' => 'last5','period' => 'week',) + $parametersToSet );
							$lastNUrls = ",	RSS of the last <a target=_blank href='$exampleUrlRss1&format=rss$token_auth'>10 days</a>";
						}
						$exampleUrl = $prefixUrls . $exampleUrl ;
						$str .= " [ Example in  
									<a target=_blank href='$exampleUrl&format=xml$token_auth'>XML</a>, 
									<a target=_blank href='$exampleUrl&format=JSON$token_auth'>Json</a>, 
									<a target=_blank href='$exampleUrl&format=Tsv$token_auth'>Tsv (Excel)</a> 
									$lastNUrls
									]";
					}
					else
					{
						$str .= " [ No example available ]";
					}
					$str .= "</span>";
				}
				$str .= '</small>';
				$str .= "</div>\n";
			}
		}
		
		$str = "<h2>Quick access to APIs</h2> 
				$toc 
				$str";
		return $str;
	}
开发者ID:BackupTheBerlios,项目名称:oos-svn,代码行数:77,代码来源:DocumentationGenerator.php

示例14: factory

 /**
  * View factory method
  *
  * @param string $templateName Template name (e.g., 'index')
  * @param int $viewType     View type (e.g., Piwik_View::CLI)
  */
 public static function factory($templateName = null, $viewType = null)
 {
     if ($templateName == self::COREUPDATER_ONE_CLICK_DONE) {
         return new Piwik_View_OneClickDone(Piwik::getCurrentUserTokenAuth());
     }
     Piwik_PostEvent('View.getViewType', $viewType);
     // get caller
     $bt = @debug_backtrace();
     if ($bt === null || !isset($bt[0])) {
         throw new Exception("View factory cannot be invoked");
     }
     $path = dirname($bt[0]['file']);
     // determine best view type
     if ($viewType === null) {
         if (Piwik_Common::isPhpCliMode()) {
             $viewType = self::CLI;
         } else {
             $viewType = self::STANDARD;
         }
     }
     // get template filename
     if ($viewType == self::CLI) {
         $templateFile = $path . '/templates/cli_' . $templateName . '.tpl';
         if (file_exists($templateFile)) {
             return new Piwik_View($templateFile, array(), false);
         }
         $viewType = self::STANDARD;
     }
     if ($viewType == self::MOBILE) {
         $templateFile = $path . '/templates/mobile_' . $templateName . '.tpl';
         if (!file_exists($templateFile)) {
             $viewType = self::STANDARD;
         }
     }
     if ($viewType != self::MOBILE) {
         $templateFile = $path . '/templates/' . $templateName . '.tpl';
     }
     // Specified template not found
     // We allow for no specified template
     if (!empty($templateName) && !file_exists($templateFile)) {
         throw new Exception('Template not found: ' . $templateFile);
     }
     return new Piwik_View($templateFile);
 }
开发者ID:0h546f6f78696342756e4e59,项目名称:piwik,代码行数:50,代码来源:View.php

示例15: checkTokenInUrl

 private function checkTokenInUrl()
 {
     if (Piwik_Common::getRequestVar('token_auth', false) != Piwik::getCurrentUserTokenAuth()) {
         throw new Piwik_Access_NoAccessException('Token is not valid.');
     }
 }
开发者ID:Doluci,项目名称:tomatocart,代码行数:6,代码来源:Controller.php


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