本文整理汇总了PHP中Piwik::checkUserHasSomeViewAccess方法的典型用法代码示例。如果您正苦于以下问题:PHP Piwik::checkUserHasSomeViewAccess方法的具体用法?PHP Piwik::checkUserHasSomeViewAccess怎么用?PHP Piwik::checkUserHasSomeViewAccess使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Piwik
的用法示例。
在下文中一共展示了Piwik::checkUserHasSomeViewAccess方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: outputBinaryImage
/**
* Output binary image from base-64 encoded data.
*
* @deprecated 1.5.1
*
* @param string $imageData Base-64 encoded image data (via $_POST)
*/
public static function outputBinaryImage()
{
Piwik::checkUserHasSomeViewAccess();
$rawData = Piwik_Common::getRequestVar('imageData', '', 'string', $_POST);
// returns false if any illegal characters in input
$data = base64_decode($rawData);
if ($data !== false) {
// check for PNG header
if (Piwik_Common::substr($data, 0, 8) === "‰PNG\r\n\n") {
header('Content-Type: image/png');
// more robust validation (if available)
if (function_exists('imagecreatefromstring')) {
// validate image data
$imgResource = @imagecreatefromstring($data);
if ($imgResource !== false) {
// output image and clean-up
imagepng($imgResource);
imagedestroy($imgResource);
exit;
}
} else {
echo $data;
exit;
}
}
}
Piwik::setHttpStatus('400 Bad Request');
exit;
}
示例2: getRank
/**
* Get rank
*
* @param string $url URL to request Ranks for
* @return Piwik_DataTable
*/
public function getRank($url)
{
Piwik::checkUserHasSomeViewAccess();
$rank = new Piwik_SEO_RankChecker($url);
$data = array('Google PageRank' => array('rank' => $rank->getPageRank(), 'logo' => Piwik_getSearchEngineLogoFromUrl('http://google.com'), 'id' => 'pagerank'), Piwik_Translate('SEO_AlexaRank') => array('rank' => $rank->getAlexaRank(), 'logo' => Piwik_getSearchEngineLogoFromUrl('http://alexa.com'), 'id' => 'alexa'), Piwik_Translate('SEO_DomainAge') => array('rank' => $rank->getAge(), 'logo' => 'plugins/SEO/images/whois.png', 'id' => 'domain-age'));
$dataTable = new Piwik_DataTable();
$dataTable->addRowsFromArrayWithIndexLabel($data);
return $dataTable;
}
示例3: getAll
/**
* Returns a report displaying the total visits, actions and revenue, as
* well as the evolution of these values, of all existing sites over a
* specified period of time.
*
* If the specified period is not a 'range', this function will calculcate
* evolution metrics. Evolution metrics are metrics that display the
* percent increase/decrease of another metric since the last period.
*
* This function will merge the result of the archive query so each
* row in the result DataTable will correspond to the metrics of a single
* site. If a date range is specified, the result will be a
* DataTable_Array, but it will still be merged.
*
* @param string $period The period type to get data for.
* @param string $date The date(s) to get data for.
* @param string $segment The segments to get data for.
*/
public function getAll($period, $date, $segment = false)
{
Piwik::checkUserHasSomeViewAccess();
$isGoalPluginEnabled = Piwik_Common::isGoalPluginEnabled();
// get site data for every viewable site and cache them
if (Piwik::isUserIsSuperUser()) {
$sites = Piwik_SitesManager_API::getInstance()->getAllSites();
Piwik_Site::setSites($sites);
} else {
$sites = Piwik_SitesManager_API::getInstance()->getSitesWithAtLeastViewAccess();
Piwik_Site::setSitesFromArray($sites);
}
// build the archive type used to query archive data
$archive = Piwik_Archive::build('all', $period, $date, $segment);
// determine what data will be displayed
$fieldsToGet = array('nb_visits', 'nb_actions');
if ($isGoalPluginEnabled) {
$revenueMetric = Piwik_Goals::getRecordName('revenue');
$fieldsToGet[] = $revenueMetric;
}
// get the data
$dataTable = $archive->getDataTableFromNumeric($fieldsToGet);
// get rid of the DataTable_Array that is created by the IndexedBySite archive type
$dataTable = $dataTable->mergeChildren();
// if the period isn't a range & a lastN/previousN date isn't used, we get the same
// data for the last period to show the evolution of visits/actions/revenue
if ($period != 'range' && !preg_match('/(last|previous)([0-9]*)/', $date, $regs)) {
if (strpos($date, ',')) {
$rangePeriod = new Piwik_Period_Range($period, $date);
$lastStartDate = Piwik_Period_Range::removePeriod($period, $rangePeriod->getDateStart(), $n = 1);
$lastEndDate = Piwik_Period_Range::removePeriod($period, $rangePeriod->getDateEnd(), $n = 1);
$strLastDate = "{$lastStartDate},{$lastEndDate}";
} else {
$strLastDate = Piwik_Period_Range::removePeriod($period, Piwik_Date::factory($date), $n = 1)->toString();
}
$pastArchive = Piwik_Archive::build('all', $period, $strLastDate, $segment);
$pastData = $pastArchive->getDataTableFromNumeric($fieldsToGet);
$pastData = $pastData->mergeChildren();
// use past data to calculate evolution percentages
$this->calculateEvolutionPercentages($dataTable, $pastData, $fieldsToGet);
}
// move the site id to a metadata column
$dataTable->filter('ColumnCallbackAddMetadata', array('label', 'idsite'));
// set the label of each row to the site name
$getNameFor = array('Piwik_Site', 'getNameFor');
$dataTable->filter('ColumnCallbackReplace', array('label', $getNameFor));
// rename the revenue column from the metric name to 'revenue'
if ($isGoalPluginEnabled) {
$mapping = array($revenueMetric => 'revenue');
$dataTable->filter('ReplaceColumnNames', array($mapping));
}
// Ensures data set sorted, for Metadata output
$dataTable->filter('Sort', array('nb_visits', 'desc', $naturalSort = false));
return $dataTable;
}
示例4: getRank
/**
* Get rank
*
* @param string $url URL to request Ranks for
* @return Piwik_DataTable
*/
public function getRank($url)
{
Piwik::checkUserHasSomeViewAccess();
$rank = new Piwik_SEO_RankChecker($url);
$data = array('Google PageRank' => array('rank' => $rank->getPageRank(), 'logo' => Piwik_getSearchEngineLogoFromUrl('http://google.com'), 'id' => 'pagerank'), Piwik_Translate('SEO_Google_IndexedPages') => array('rank' => $rank->getIndexedPagesGoogle(), 'logo' => Piwik_getSearchEngineLogoFromUrl('http://google.com'), 'id' => 'google-index'), Piwik_Translate('SEO_Bing_IndexedPages') => array('rank' => $rank->getIndexedPagesBing(), 'logo' => Piwik_getSearchEngineLogoFromUrl('http://bing.com'), 'id' => 'bing-index'), Piwik_Translate('SEO_AlexaRank') => array('rank' => $rank->getAlexaRank(), 'logo' => Piwik_getSearchEngineLogoFromUrl('http://alexa.com'), 'id' => 'alexa'), Piwik_Translate('SEO_DomainAge') => array('rank' => $rank->getAge(), 'logo' => 'plugins/SEO/images/whois.png', 'id' => 'domain-age'));
// Add DMOZ only if > 0 entries found
$dmozRank = array('rank' => $rank->getDmoz(), 'logo' => Piwik_getSearchEngineLogoFromUrl('http://dmoz.org'), 'id' => 'dmoz');
if ($dmozRank['rank'] > 0) {
$data[Piwik_Translate('SEO_Dmoz')] = $dmozRank;
}
$dataTable = new Piwik_DataTable();
$dataTable->addRowsFromArrayWithIndexLabel($data);
return $dataTable;
}
示例5: outputBinaryImage
/**
* Output binary image from base-64 encoded data.
*
* @param string $imageData Base-64 encoded image data (via $_POST)
*/
public static function outputBinaryImage()
{
Piwik::checkUserHasSomeViewAccess();
header('Content-Type: image/png');
$data = base64_decode(Piwik_Common::getRequestVar('imageData', self::TRANSPARENT_PNG_PIXEL, 'string', $_POST));
if (function_exists('imagecreatefromstring')) {
// validate image data
$imgResource = @imagecreatefromstring($data);
if ($imgResource !== false) {
// output image and clean-up
imagepng($imgResource);
imagedestroy($imgResource);
}
} else {
echo $data;
}
exit;
}
示例6: getPiwikVersion
/**
* Get Piwik version
* @return string
*/
public function getPiwikVersion()
{
Piwik::checkUserHasSomeViewAccess();
return Piwik_Version::VERSION;
}
示例7: getSitesInfo
public function getSitesInfo($view)
{
Piwik::checkUserHasSomeViewAccess();
$displayRevenueColumn = Piwik_Common::isGoalPluginEnabled();
// overwrites the default Date set in the parent controller
// Instead of the default current website's local date,
// we set "today" or "yesterday" based on the default Piwik timezone
$piwikDefaultTimezone = Piwik_SitesManager_API::getInstance()->getDefaultTimezone();
$dateRequest = Piwik_Common::getRequestVar('date', 'today');
$period = Piwik_Common::getRequestVar('period', 'day');
$date = $dateRequest;
if ($period != 'range') {
$date = $this->getDateParameterInTimezone($dateRequest, $piwikDefaultTimezone);
$date = $date->toString();
}
$siteIds = Piwik_SitesManager_API::getInstance()->getSitesIdWithAtLeastViewAccess();
$dataTable = Piwik_MultiSites_API::getInstance()->getAll($period, $date, $segment = false);
list($minDate, $maxDate) = $this->getMinMaxDateAcrossWebsites($siteIds);
$totalVisits = $totalActions = $totalRevenue = 0;
// put data into a form the template will understand better
$digestableData = array();
foreach ($siteIds as $idSite) {
$isEcommerceEnabled = Piwik_Site::isEcommerceEnabledFor($idSite);
$digestableData[$idSite] = array('idsite' => $idSite, 'main_url' => Piwik_Site::getMainUrlFor($idSite), 'name' => Piwik_Site::getNameFor($idSite), 'visits' => 0, 'actions' => 0);
if ($period != 'range') {
$digestableData[$idSite]['visits_evolution'] = 0;
$digestableData[$idSite]['actions_evolution'] = 0;
}
if ($displayRevenueColumn) {
$revenueDefault = $isEcommerceEnabled ? 0 : "'-'";
if ($period != 'range') {
$digestableData[$idSite]['revenue_evolution'] = $revenueDefault;
}
}
}
foreach ($dataTable->getRows() as $row) {
$idsite = (int) $row->getMetadata('idsite');
$site =& $digestableData[$idsite];
$site['visits'] = (int) $row->getColumn('nb_visits');
$totalVisits += $site['visits'];
$site['actions'] = (int) $row->getColumn('nb_actions');
$totalActions += $site['actions'];
if ($displayRevenueColumn) {
if ($row->getColumn('revenue') !== false) {
$site['revenue'] = $row->getColumn('revenue');
$totalRevenue += $site['revenue'];
}
}
if ($period != 'range') {
$site['visits_evolution'] = $row->getColumn('visits_evolution');
$site['actions_evolution'] = $row->getColumn('actions_evolution');
if ($displayRevenueColumn) {
$site['revenue_evolution'] = $row->getColumn('revenue_evolution');
}
}
}
$this->applyPrettyMoney($digestableData);
$view->sitesData = array_values($digestableData);
$view->evolutionBy = $this->evolutionBy;
$view->period = $period;
$view->dateRequest = $dateRequest;
$view->page = $this->page;
$view->limit = $this->limit;
$view->orderBy = $this->orderBy;
$view->order = $this->order;
$view->totalVisits = $totalVisits;
$view->totalRevenue = $totalRevenue;
$view->displayRevenueColumn = $displayRevenueColumn;
$view->totalActions = $totalActions;
$params = $this->getGraphParamsModified();
$view->dateSparkline = $period == 'range' ? $dateRequest : $params['date'];
$view->autoRefreshTodayReport = false;
// if the current date is today, or yesterday,
// in case the website is set to UTC-12), or today in UTC+14, we refresh the page every 5min
if (in_array($date, array('today', date('Y-m-d'), 'yesterday', Piwik_Date::factory('yesterday')->toString('Y-m-d'), Piwik_Date::factory('now', 'UTC+14')->toString('Y-m-d')))) {
$view->autoRefreshTodayReport = Piwik_Config::getInstance()->General['multisites_refresh_after_seconds'];
}
$this->setGeneralVariablesView($view);
$this->setMinDateView($minDate, $view);
$this->setMaxDateView($maxDate, $view);
$view->show_sparklines = Piwik_Config::getInstance()->General['show_multisites_sparklines'];
echo $view->render();
}
示例8: getOne
/**
* Same as getAll but for a unique Piwik site
* @see Piwik_MultiSites_API::getAll()
*
* @param int $idSite Id of the Piwik site
* @param string $period The period type to get data for.
* @param string $date The date(s) to get data for.
* @param bool|string $segment The segments to get data for.
* @param bool|string $_restrictSitesToLogin Hack used to enforce we restrict the returned data to the specified username
* Only used when a scheduled task is running
* @param bool|string $enhanced When true, return additional goal & ecommerce metrics
* @return Piwik_DataTable
*/
public function getOne($idSite, $period, $date, $segment = false, $_restrictSitesToLogin = false, $enhanced = false)
{
Piwik::checkUserHasSomeViewAccess();
return $this->buildDataTable($idSite, $period, $date, $segment, $_restrictSitesToLogin, $enhanced);
}
示例9: setIgnoreCookie
public function setIgnoreCookie()
{
Piwik::checkUserHasSomeViewAccess();
Piwik::checkUserIsNotAnonymous();
$this->checkTokenInUrl();
Piwik_Tracker_IgnoreCookie::setIgnoreCookie();
Piwik::redirectToModule('UsersManager', 'userSettings');
}
示例10: getSitesInfo
public function getSitesInfo()
{
Piwik::checkUserHasSomeViewAccess();
// overwrites the default Date set in the parent controller
// Instead of the default current website's local date,
// we set "today" or "yesterday" based on the default Piwik timezone
$piwikDefaultTimezone = Piwik_SitesManager_API::getInstance()->getDefaultTimezone();
$dateRequest = Piwik_Common::getRequestVar('date', 'today');
$period = Piwik_Common::getRequestVar('period', 'day');
$date = $dateRequest;
if ($period != 'range') {
$date = $this->getDateParameterInTimezone($dateRequest, $piwikDefaultTimezone);
$date = $date->toString();
}
$mySites = Piwik_SitesManager_API::getInstance()->getSitesWithAtLeastViewAccess();
$ids = 'all';
$visits = Piwik_VisitsSummary_API::getInstance()->getVisits($ids, $period, $date);
$actions = Piwik_VisitsSummary_API::getInstance()->getActions($ids, $period, $date);
$uniqueUsers = Piwik_VisitsSummary_API::getInstance()->getUniqueVisitors($ids, $period, $date);
if ($period != 'range') {
$lastDate = Piwik_Period_Range::removePeriod($period, Piwik_Date::factory($date), $n = 1);
$lastVisits = Piwik_VisitsSummary_API::getInstance()->getVisits($ids, $period, $lastDate);
$lastActions = Piwik_VisitsSummary_API::getInstance()->getActions($ids, $period, $lastDate);
$lastUniqueUsers = Piwik_VisitsSummary_API::getInstance()->getUniqueVisitors($ids, $period, $lastDate);
$visitsSummary = $this->getSummary($lastVisits, $visits, $mySites, "visits");
$actionsSummary = $this->getSummary($lastActions, $actions, $mySites, "actions");
$uniqueSummary = $this->getSummary($lastUniqueUsers, $uniqueUsers, $mySites, "unique");
$lastVisitsArray = $lastVisits->getArray();
$lastActionsArray = $lastActions->getArray();
$lastUniqueUsersArray = $lastUniqueUsers->getArray();
}
$visitsArray = $visits->getArray();
$actionsArray = $actions->getArray();
$uniqueUsersArray = $uniqueUsers->getArray();
$totalVisits = $totalActions = 0;
foreach ($mySites as &$site) {
$idSite = $site['idsite'];
$tmp = $visitsArray[$idSite]->getColumn(0);
$site['visits'] = $tmp[0];
$totalVisits += $tmp[0];
$tmp = $actionsArray[$idSite]->getColumn(0);
$site['actions'] = $tmp[0];
$totalActions += $tmp[0];
$tmp = $uniqueUsersArray[$idSite]->getColumn(0);
$site['unique'] = $tmp[0];
if ($period != 'range') {
$tmp = $lastVisitsArray[$idSite]->getColumn(0);
$site['lastVisits'] = $tmp[0];
$tmp = $lastActionsArray[$idSite]->getColumn(0);
$site['lastActions'] = $tmp[0];
$tmp = $lastUniqueUsersArray[$idSite]->getColumn(0);
$site['lastUnique'] = $tmp[0];
}
$site['visitsSummaryValue'] = isset($visitsSummary[$idSite]) ? $visitsSummary[$idSite] : 0;
$site['actionsSummaryValue'] = isset($actionsSummary[$idSite]) ? $actionsSummary[$idSite] : 0;
$site['uniqueSummaryValue'] = isset($uniqueSummary[$idSite]) ? $uniqueSummary[$idSite] : 0;
}
$view = new Piwik_View("MultiSites/templates/index.tpl");
$view->mySites = $mySites;
$view->evolutionBy = $this->evolutionBy;
$view->period = $period;
$view->dateRequest = $dateRequest;
$view->page = $this->page;
$view->limit = $this->limit;
$view->orderBy = $this->orderBy;
$view->order = $this->order;
$view->totalVisits = $totalVisits;
$view->totalActions = $totalActions;
$params = $this->getGraphParamsModified();
$view->dateSparkline = $period == 'range' ? $dateRequest : $params['date'];
$view->autoRefreshTodayReport = false;
// if the current date is today, or yesterday,
// in case the website is set to UTC-12), or today in UTC+14, we refresh the page every 5min
if (in_array($date, array('today', date('Y-m-d'), 'yesterday', Piwik_Date::factory('yesterday')->toString('Y-m-d'), Piwik_Date::factory('now', 'UTC+14')->toString('Y-m-d')))) {
$view->autoRefreshTodayReport = true;
}
$this->setGeneralVariablesView($view);
$this->setMinMaxDateAcrossWebsites($mySites, $view);
$view->show_sparklines = Zend_Registry::get('config')->General->show_multisites_sparklines;
echo $view->render();
}
示例11: redirect
/**
* Output redirection page instead of linking directly to avoid
* exposing the referrer on the Piwik demo.
*
* @param string $url (via $_GET)
*/
public function redirect()
{
$url = Piwik_Common::getRequestVar('url', '', 'string', $_GET);
// validate referrer
$referrer = Piwik_Url::getReferer();
if (empty($referrer) || !Piwik_Url::isLocalUrl($referrer)) {
die('Invalid Referer detected - check that your browser sends the Referer header.
<br/>The link you would have been redirected to is: ' . $url);
}
// mask visits to *.piwik.org
if (!self::isPiwikUrl($url)) {
Piwik::checkUserHasSomeViewAccess();
}
echo '<html><head><meta http-equiv="refresh" content="0;url=' . $url . '" /></head></html>';
exit;
}
示例12: getExcludedQueryParametersGlobal
/**
* Returns the list of URL query parameters that are excluded from all websites
*
* @return string Comma separated list of URL parameters
*/
public function getExcludedQueryParametersGlobal()
{
Piwik::checkUserHasSomeViewAccess();
return Piwik_GetOption(self::OPTION_EXCLUDED_QUERY_PARAMETERS_GLOBAL);
}
示例13: getSitesInfo
public function getSitesInfo()
{
Piwik::checkUserHasSomeViewAccess();
$displayRevenueColumn = Piwik_Common::isGoalPluginEnabled();
// overwrites the default Date set in the parent controller
// Instead of the default current website's local date,
// we set "today" or "yesterday" based on the default Piwik timezone
$piwikDefaultTimezone = Piwik_SitesManager_API::getInstance()->getDefaultTimezone();
$dateRequest = Piwik_Common::getRequestVar('date', 'today');
$period = Piwik_Common::getRequestVar('period', 'day');
$date = $dateRequest;
if($period != 'range')
{
$date = $this->getDateParameterInTimezone($dateRequest, $piwikDefaultTimezone);
$date = $date->toString();
}
$mySites = Piwik_SitesManager_API::getInstance()->getSitesWithAtLeastViewAccess();
$ids = 'all';
// Current date - select metrics
$dataTableArray = Piwik_VisitsSummary_API::getInstance()->get($ids, $period, $date, $segment = false, $columns = array('nb_visits', 'nb_actions'));
$currentVisits = $this->getArrayFromAPI($dataTableArray, 'nb_visits');
$currentActions = $this->getArrayFromAPI($dataTableArray, 'nb_actions');
if($displayRevenueColumn)
{
$dataTableArray = Piwik_Goals_API::getInstance()->get($ids, $period, $date, $segment = false, $idGoal = false, $columns = array('revenue'));
$currentRevenue = $this->getArrayFromAPI($dataTableArray, 'revenue');
}
// Previous date
$lastVisits = $lastActions = $lastRevenue = array();
if($period != 'range')
{
$lastDate = Piwik_Period_Range::removePeriod($period, Piwik_Date::factory($date), $n = 1 );
$dataTableArray = Piwik_VisitsSummary_API::getInstance()->get($ids, $period, $lastDate, $segment = false, $columns = array('nb_visits', 'nb_actions'));
$lastVisits = $this->getArrayFromAPI($dataTableArray, 'nb_visits');
$lastActions = $this->getArrayFromAPI($dataTableArray, 'nb_actions');
if($displayRevenueColumn)
{
$dataTableArray = Piwik_Goals_API::getInstance()->get($ids, $period, $lastDate, $segment = false, $idGoal = false, $columns = array('revenue'));
$lastRevenue = $this->getArrayFromAPI($dataTableArray, 'revenue');
}
}
$visitsSummary = $this->getChangeCurrentVsLast($currentVisits, $lastVisits);
$actionsSummary = $this->getChangeCurrentVsLast($currentActions, $lastActions);
if($displayRevenueColumn)
{
$revenueSummary = $this->getChangeCurrentVsLast($currentRevenue, $lastRevenue);
}
$totalVisits = $totalActions = $totalRevenue = 0;
foreach($mySites as &$site)
{
$idSite = $site['idsite'];
if($period != 'range')
{
$site['lastVisits'] = $lastVisits[$idSite];
$site['lastActions'] = $lastActions[$idSite];
if($displayRevenueColumn)
{
$site['lastRevenue'] = $lastRevenue[$idSite];
}
}
$site['visits'] = $currentVisits[$idSite];
$site['actions'] = $currentActions[$idSite];
$totalVisits += $site['visits'];
$totalActions += $site['actions'];
$site['visitsSummaryValue'] = $visitsSummary[$idSite];
$site['actionsSummaryValue'] = $actionsSummary[$idSite];
$site['revenue'] = $site['revenueSummaryValue'] = 0;
if($displayRevenueColumn)
{
$site['revenue'] = $currentRevenue[$idSite];
$totalRevenue += $site['revenue'];
$site['revenueSummaryValue'] = $revenueSummary[$idSite];
}
}
$mySites = $this->applyPrettyMoney($mySites);
$view = new Piwik_View("MultiSites/templates/index.tpl");
$view->mySites = $mySites;
$view->evolutionBy = $this->evolutionBy;
$view->period = $period;
$view->dateRequest = $dateRequest;
$view->page = $this->page;
$view->limit = $this->limit;
$view->orderBy = $this->orderBy;
$view->order = $this->order;
$view->totalVisits = $totalVisits;
$view->totalRevenue = $totalRevenue;
$view->displayRevenueColumn = $displayRevenueColumn;
$view->totalActions = $totalActions;
$params = $this->getGraphParamsModified();
$view->dateSparkline = $period == 'range' ? $dateRequest : $params['date'];
//.........这里部分代码省略.........