예제 #1
0
 /**
  * Returns SEO statistics for a URL.
  *
  * @param string $url URL to request SEO stats for
  * @return DataTable
  */
 public function getRank($url)
 {
     Piwik::checkUserHasSomeViewAccess();
     $metricProvider = new ProviderCache(new Aggregator());
     $domain = Url::getHostFromUrl($url);
     $metrics = $metricProvider->getMetrics($domain);
     return $this->toDataTable($metrics);
 }
예제 #2
0
 /**
  * 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\Map, 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 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
  * @param bool|string $pattern If specified, only the website which names (or site ID) match the pattern will be returned using SitesManager.getPatternMatchSites
  * @return DataTable
  */
 public function getAll($period, $date, $segment = false, $_restrictSitesToLogin = false, $enhanced = false, $pattern = false)
 {
     Piwik::checkUserHasSomeViewAccess();
     $idSites = $this->getSitesIdFromPattern($pattern);
     if (empty($idSites)) {
         return new DataTable();
     }
     return $this->buildDataTable($idSites, $period, $date, $segment, $_restrictSitesToLogin, $enhanced, $multipleWebsitesRequested = true);
 }
예제 #3
0
 public function renderWidget($widgetModule = null, $widgetAction = null)
 {
     Piwik::checkUserHasSomeViewAccess();
     $widget = PluginWidgets::factory($widgetModule, $widgetAction);
     if (!empty($widget)) {
         return $widget->{$widgetAction}();
     }
     throw new Exception(Piwik::translate('General_ExceptionWidgetNotFound'));
 }
예제 #4
0
파일: API.php 프로젝트: bossrabbit/piwik
 /**
  * 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\Map, 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 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
  * @param bool|string $pattern If specified, only the website which names (or site ID) match the pattern will be returned using SitesManager.getPatternMatchSites
  * @param array $showColumns If specified, only the requested columns will be fetched
  * @return DataTable
  */
 public function getAll($period, $date, $segment = false, $_restrictSitesToLogin = false, $enhanced = false, $pattern = false, $showColumns = array())
 {
     Piwik::checkUserHasSomeViewAccess();
     $sites = $this->getSitesIdFromPattern($pattern, $_restrictSitesToLogin);
     if (!empty($showColumns) && !is_array($showColumns)) {
         $showColumns = explode(',', $showColumns);
     }
     if (empty($sites)) {
         return new DataTable();
     }
     return $this->buildDataTable($sites, $period, $date, $segment, $_restrictSitesToLogin, $enhanced, $multipleWebsitesRequested = true, $showColumns);
 }
예제 #5
0
파일: API.php 프로젝트: piwik/piwik
 /**
  * Detects whether insights can be generated for this date/period combination or not.
  * @param string $date     eg 'today', '2012-12-12'
  * @param string $period   eg 'day' or 'week'
  *
  * @return bool
  */
 public function canGenerateInsights($date, $period)
 {
     Piwik::checkUserHasSomeViewAccess();
     try {
         $lastDate = $this->model->getLastDate($date, $period, 1);
     } catch (\Exception $e) {
         return false;
     }
     if (empty($lastDate)) {
         return false;
     }
     return true;
 }
예제 #6
0
 /**
  * Returns SEO statistics for a URL.
  *
  * @param string $url URL to request SEO stats for
  * @return DataTable
  */
 public function getRank($url)
 {
     Piwik::checkUserHasSomeViewAccess();
     $rank = new RankChecker($url);
     $linkToMajestic = MajesticClient::getLinkForUrl($url);
     $data = array('Google PageRank' => array('rank' => $rank->getPageRank(), 'logo' => \Piwik\Plugins\Referrers\getSearchEngineLogoFromUrl('http://google.com'), 'id' => 'pagerank'), Piwik::translate('SEO_Google_IndexedPages') => array('rank' => $rank->getIndexedPagesGoogle(), 'logo' => \Piwik\Plugins\Referrers\getSearchEngineLogoFromUrl('http://google.com'), 'id' => 'google-index'), Piwik::translate('SEO_Bing_IndexedPages') => array('rank' => $rank->getIndexedPagesBing(), 'logo' => \Piwik\Plugins\Referrers\getSearchEngineLogoFromUrl('http://bing.com'), 'id' => 'bing-index'), Piwik::translate('SEO_AlexaRank') => array('rank' => $rank->getAlexaRank(), 'logo' => \Piwik\Plugins\Referrers\getSearchEngineLogoFromUrl('http://alexa.com'), 'id' => 'alexa'), Piwik::translate('SEO_DomainAge') => array('rank' => $rank->getAge(), 'logo' => 'plugins/SEO/images/whois.png', 'id' => 'domain-age'), Piwik::translate('SEO_ExternalBacklinks') => array('rank' => $rank->getExternalBacklinkCount(), 'logo' => 'plugins/SEO/images/majesticseo.png', 'logo_link' => $linkToMajestic, 'logo_tooltip' => Piwik::translate('SEO_ViewBacklinksOnMajesticSEO'), 'id' => 'external-backlinks'), Piwik::translate('SEO_ReferrerDomains') => array('rank' => $rank->getReferrerDomainCount(), 'logo' => 'plugins/SEO/images/majesticseo.png', 'logo_link' => $linkToMajestic, 'logo_tooltip' => Piwik::translate('SEO_ViewBacklinksOnMajesticSEO'), 'id' => 'referrer-domains'));
     // Add DMOZ only if > 0 entries found
     $dmozRank = array('rank' => $rank->getDmoz(), 'logo' => \Piwik\Plugins\Referrers\getSearchEngineLogoFromUrl('http://dmoz.org'), 'id' => 'dmoz');
     if ($dmozRank['rank'] > 0) {
         $data[Piwik::translate('SEO_Dmoz')] = $dmozRank;
     }
     return DataTable::makeFromIndexedArray($data);
 }
예제 #7
0
 public function getGlobalSettings()
 {
     Piwik::checkUserHasSomeViewAccess();
     $response = new ResponseBuilder(Common::getRequestVar('format'));
     $globalSettings = array();
     $globalSettings['keepURLFragmentsGlobal'] = API::getInstance()->getKeepURLFragmentsGlobal();
     $globalSettings['siteSpecificUserAgentExcludeEnabled'] = API::getInstance()->isSiteSpecificUserAgentExcludeEnabled();
     $globalSettings['defaultCurrency'] = API::getInstance()->getDefaultCurrency();
     $globalSettings['searchKeywordParametersGlobal'] = API::getInstance()->getSearchKeywordParametersGlobal();
     $globalSettings['searchCategoryParametersGlobal'] = API::getInstance()->getSearchCategoryParametersGlobal();
     $globalSettings['defaultTimezone'] = API::getInstance()->getDefaultTimezone();
     $globalSettings['excludedIpsGlobal'] = API::getInstance()->getExcludedIpsGlobal();
     $globalSettings['excludedQueryParametersGlobal'] = API::getInstance()->getExcludedQueryParametersGlobal();
     $globalSettings['excludedUserAgentsGlobal'] = API::getInstance()->getExcludedUserAgentsGlobal();
     return $response->getResponse($globalSettings);
 }
예제 #8
0
파일: API.php 프로젝트: brienomatty/elmsln
 /**
  * Sends feedback for a specific feature to the Piwik team or alternatively to the email address configured in the
  * config: "feedback_email_address".
  *
  * @param string      $featureName  The name of a feature you want to give feedback to.
  * @param bool|int    $like         Whether you like the feature or not
  * @param string|bool $message      A message containing the actual feedback
  */
 public function sendFeedbackForFeature($featureName, $like, $message = false)
 {
     Piwik::checkUserIsNotAnonymous();
     Piwik::checkUserHasSomeViewAccess();
     $featureName = $this->getEnglishTranslationForFeatureName($featureName);
     $likeText = 'Yes';
     if (empty($like)) {
         $likeText = 'No';
     }
     $body = sprintf("Feature: %s\nLike: %s\n", $featureName, $likeText, $message);
     $feedbackMessage = "";
     if (!empty($message) && $message != 'undefined') {
         $feedbackMessage = sprintf("Feedback:\n%s\n", trim($message));
     }
     $body .= $feedbackMessage ? $feedbackMessage : " \n";
     $subject = sprintf("%s for %s %s", empty($like) ? "-1" : "+1", $featureName, empty($feedbackMessage) ? "" : "(w/ feedback)");
     $this->sendMail($subject, $body);
 }
예제 #9
0
파일: Controller.php 프로젝트: piwik/piwik
 /**
  * @param Widget $widget
  * @return mixed
  * @throws Exception
  */
 public function renderWidget($widget)
 {
     Piwik::checkUserHasSomeViewAccess();
     $config = new WidgetConfig();
     $widget::configure($config);
     $content = $widget->render();
     if ($config->getName() && Common::getRequestVar('showtitle', '', 'string') === '1') {
         if (strpos($content, '<h2') !== false || strpos($content, ' content-title=') !== false || strpos($content, ' piwik-enriched-headline') !== false || strpos($content, '<h1') !== false) {
             // already includes title
             return $content;
         }
         if (strpos($content, 'piwik-content-block') === false && strpos($content, 'class="card"') === false && strpos($content, "class='card'") === false && strpos($content, 'class="card-content"') === false && strpos($content, "class='card-content'") === false) {
             $view = new View('@CoreHome/_singleWidget');
             $view->title = $config->getName();
             $view->content = $content;
             return $view->render();
         }
     }
     return $content;
 }
예제 #10
0
 public function getSitesInfo($isWidgetized = false)
 {
     Piwik::checkUserHasSomeViewAccess();
     $date = Common::getRequestVar('date', 'today');
     $period = Common::getRequestVar('period', 'day');
     $view = new View("@MultiSites/getSitesInfo");
     $view->isWidgetized = $isWidgetized;
     $view->displayRevenueColumn = Common::isGoalPluginEnabled();
     $view->limit = Config::getInstance()->General['all_websites_website_per_page'];
     $view->show_sparklines = Config::getInstance()->General['show_multisites_sparklines'];
     $view->autoRefreshTodayReport = 0;
     // 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', Date::factory('yesterday')->toString('Y-m-d'), Date::factory('now', 'UTC+14')->toString('Y-m-d')))) {
         $view->autoRefreshTodayReport = Config::getInstance()->General['multisites_refresh_after_seconds'];
     }
     $params = $this->getGraphParamsModified();
     $view->dateSparkline = $period == 'range' ? $date : $params['date'];
     $this->setGeneralVariablesView($view);
     return $view->render();
 }
예제 #11
0
 public function getSitesInfo($isWidgetized = false)
 {
     Piwik::checkUserHasSomeViewAccess();
     $displayRevenueColumn = Common::isGoalPluginEnabled();
     $date = Common::getRequestVar('date', 'today');
     $period = Common::getRequestVar('period', 'day');
     $siteIds = APISitesManager::getInstance()->getSitesIdWithAtLeastViewAccess();
     list($minDate, $maxDate) = Site::getMinMaxDateAcrossWebsites($siteIds);
     // 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 = APISitesManager::getInstance()->getDefaultTimezone();
     if ($period != 'range') {
         $date = $this->getDateParameterInTimezone($date, $piwikDefaultTimezone);
         $this->setDate($date);
         $date = $date->toString();
     }
     $dataTable = APIMultiSites::getInstance()->getAll($period, $date, $segment = false);
     // put data into a form the template will understand better
     $digestableData = array();
     foreach ($siteIds as $idSite) {
         $isEcommerceEnabled = Site::isEcommerceEnabledFor($idSite);
         $digestableData[$idSite] = array('idsite' => $idSite, 'main_url' => Site::getMainUrlFor($idSite), 'name' => Site::getNameFor($idSite), 'visits' => 0, 'pageviews' => 0);
         if ($period != 'range') {
             $digestableData[$idSite]['visits_evolution'] = 0;
             $digestableData[$idSite]['pageviews_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');
         $site['pageviews'] = (int) $row->getColumn('nb_pageviews');
         if ($displayRevenueColumn) {
             if ($row->getColumn('revenue') !== false) {
                 $site['revenue'] = $row->getColumn('revenue');
             }
         }
         if ($period != 'range') {
             $site['visits_evolution'] = $row->getColumn('visits_evolution');
             $site['pageviews_evolution'] = $row->getColumn('pageviews_evolution');
             if ($displayRevenueColumn) {
                 $site['revenue_evolution'] = $row->getColumn('revenue_evolution');
             }
         }
     }
     $this->applyPrettyMoney($digestableData);
     $view = new View("@MultiSites/getSitesInfo");
     $view->isWidgetized = $isWidgetized;
     $view->sitesData = array_values($digestableData);
     $view->evolutionBy = $this->evolutionBy;
     $view->period = $period;
     $view->page = $this->page;
     $view->limit = $this->limit;
     $view->orderBy = $this->orderBy;
     $view->order = $this->order;
     $view->totalVisits = $dataTable->getMetadata('total_nb_visits');
     $view->totalRevenue = $dataTable->getMetadata('total_revenue');
     $view->displayRevenueColumn = $displayRevenueColumn;
     $view->totalPageviews = $dataTable->getMetadata('total_nb_pageviews');
     $view->pastTotalVisits = $dataTable->getMetadata('last_period_total_nb_visits');
     $view->totalVisitsEvolution = $dataTable->getMetadata('total_visits_evolution');
     if ($view->totalVisitsEvolution > 0) {
         $view->totalVisitsEvolution = '+' . $view->totalVisitsEvolution;
     }
     if ($period != 'range') {
         $lastPeriod = Period::factory($period, $dataTable->getMetadata('last_period_date'));
         $view->pastPeriodPretty = self::getCalendarPrettyDate($lastPeriod);
     }
     $params = $this->getGraphParamsModified();
     $view->dateSparkline = $period == 'range' ? $date : $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', Date::factory('yesterday')->toString('Y-m-d'), Date::factory('now', 'UTC+14')->toString('Y-m-d')))) {
         $view->autoRefreshTodayReport = Config::getInstance()->General['multisites_refresh_after_seconds'];
     }
     $this->setGeneralVariablesView($view);
     $this->setMinDateView($minDate, $view);
     $this->setMaxDateView($maxDate, $view);
     $view->show_sparklines = Config::getInstance()->General['show_multisites_sparklines'];
     return $view->render();
 }
예제 #12
0
파일: API.php 프로젝트: diosmosis/piwik
 /**
  * Returns all stored segments.
  *
  * @param bool|int $idSite Whether to return stored segments for a specific idSite, or all of them. If supplied, must be a valid site ID.
  * @return array
  */
 public function getAll($idSite = false)
 {
     if (!empty($idSite)) {
         Piwik::checkUserHasViewAccess($idSite);
     } else {
         Piwik::checkUserHasSomeViewAccess();
     }
     $userLogin = Piwik::getCurrentUserLogin();
     $model = $this->getModel();
     if (Piwik::hasUserSuperUserAccess()) {
         $segments = $model->getAllSegmentsForAllUsers($idSite);
     } else {
         if (empty($idSite)) {
             $segments = $model->getAllSegments($userLogin);
         } else {
             $segments = $model->getAllSegmentsForSite($idSite, $userLogin);
         }
     }
     $segments = $this->sortSegmentsCreatedByUserFirst($segments);
     return $segments;
 }
예제 #13
0
 /**
  * Get Piwik version
  * @return string
  */
 public function getPiwikVersion()
 {
     Piwik::checkUserHasSomeViewAccess();
     return Version::VERSION;
 }
예제 #14
0
파일: API.php 프로젝트: JoeHorn/piwik
 /**
  * Returns true if user with given email (userEmail) is known in the database, or the Super User
  *
  * @param string $userEmail
  * @return bool true if the user is known
  */
 public function userEmailExists($userEmail)
 {
     Piwik::checkUserIsNotAnonymous();
     Piwik::checkUserHasSomeViewAccess();
     return $this->model->userEmailExists($userEmail);
 }
예제 #15
0
 /**
  * Returns true if the given userLogin is known in the database
  *
  * @param string $userLogin
  * @return bool true if the user is known
  */
 public function userExists($userLogin)
 {
     if ($userLogin == 'anonymous') {
         return true;
     }
     Piwik::checkUserIsNotAnonymous();
     Piwik::checkUserHasSomeViewAccess();
     $count = Db::fetchOne("SELECT count(*)\n\t\t\t\t\t\t\t\t\t\t\t\t\tFROM " . Common::prefixTable("user") . "\n\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE login = ?", $userLogin);
     return $count != 0;
 }
예제 #16
0
 public function glossary()
 {
     Piwik::checkUserHasSomeViewAccess();
     return $this->renderTemplate('glossary', array('reports' => Request::processRequest('API', array('method' => 'API.getGlossaryReports')), 'metrics' => Request::processRequest('API', array('method' => 'API.getGlossaryMetrics'))));
 }
예제 #17
0
파일: API.php 프로젝트: carriercomm/piwik
 /**
  * Returns the list of reports matching the passed parameters
  *
  * @param bool|int $idSite If specified, will filter reports that belong to a specific idsite
  * @param bool|string $period If specified, will filter reports that are scheduled for this period (day,week,month)
  * @param bool|int $idReport If specified, will filter the report that has the given idReport
  * @param bool $ifSuperUserReturnOnlySuperUserReports
  * @param bool|int $idSegment If specified, will filter the report that has the given idSegment
  * @throws Exception
  * @return array
  */
 public function getReports($idSite = false, $period = false, $idReport = false, $ifSuperUserReturnOnlySuperUserReports = false, $idSegment = false)
 {
     Piwik::checkUserHasSomeViewAccess();
     $cacheKey = (int) $idSite . '.' . (string) $period . '.' . (int) $idReport . '.' . (int) $ifSuperUserReturnOnlySuperUserReports;
     if (isset(self::$cache[$cacheKey])) {
         return self::$cache[$cacheKey];
     }
     $sqlWhere = '';
     $bind = array();
     // Super user gets all reports back, other users only their own
     if (!Piwik::hasUserSuperUserAccess() || $ifSuperUserReturnOnlySuperUserReports) {
         $sqlWhere .= "AND login = ?";
         $bind[] = Piwik::getCurrentUserLogin();
     }
     if (!empty($period)) {
         $this->validateReportPeriod($period);
         $sqlWhere .= " AND period = ? ";
         $bind[] = $period;
     }
     if (!empty($idSite)) {
         Piwik::checkUserHasViewAccess($idSite);
         $sqlWhere .= " AND " . Common::prefixTable('site') . ".idsite = ?";
         $bind[] = $idSite;
     }
     if (!empty($idReport)) {
         $sqlWhere .= " AND idreport = ?";
         $bind[] = $idReport;
     }
     if (!empty($idSegment)) {
         $sqlWhere .= " AND idsegment = ?";
         $bind[] = $idSegment;
     }
     // Joining with the site table to work around pre-1.3 where reports could still be linked to a deleted site
     $reports = Db::fetchAll("SELECT report.*\n\t\t\t\t\t\t\t\tFROM " . Common::prefixTable('report') . " AS `report`\n\t\t\t\t\t\t\t\t\tJOIN " . Common::prefixTable('site') . "\n\t\t\t\t\t\t\t\t\tUSING (idsite)\n\t\t\t\t\t\t\t\tWHERE deleted = 0\n\t\t\t\t\t\t\t\t\t{$sqlWhere}", $bind);
     // When a specific report was requested and not found, throw an error
     if ($idReport !== false && empty($reports)) {
         throw new Exception("Requested report couldn't be found.");
     }
     foreach ($reports as &$report) {
         // decode report parameters
         $report['parameters'] = Common::json_decode($report['parameters'], true);
         // decode report list
         $report['reports'] = Common::json_decode($report['reports'], true);
     }
     // static cache
     self::$cache[$cacheKey] = $reports;
     return $reports;
 }
예제 #18
0
파일: API.php 프로젝트: carriercomm/piwik
 /**
  * Determine if normal users can manage their own SMS API credential
  *
  * @return bool false if SMS API credential only manageable by super admin, true otherwise
  */
 public function getDelegatedManagement()
 {
     Piwik::checkUserHasSomeViewAccess();
     return Option::get(MobileMessaging::DELEGATED_MANAGEMENT_OPTION) == 'true';
 }
예제 #19
0
파일: API.php 프로젝트: a4tunado/piwik
 /**
  * Return true if Timezone support is enabled on server
  *
  * @return bool
  */
 public function isTimezoneSupportEnabled()
 {
     Piwik::checkUserHasSomeViewAccess();
     return SettingsServer::isTimezoneSupportEnabled();
 }
예제 #20
0
 /**
  * Renders and echo's an admin page that lets users generate custom JavaScript
  * tracking code and custom image tracker links.
  */
 public function trackingCodeGenerator()
 {
     Piwik::checkUserHasSomeViewAccess();
     $view = new View('@CoreAdminHome/trackingCodeGenerator');
     $this->setBasicVariablesView($view);
     $view->topMenu = MenuTop::getInstance()->getMenu();
     $view->userMenu = MenuUser::getInstance()->getMenu();
     $viewableIdSites = APISitesManager::getInstance()->getSitesIdWithAtLeastViewAccess();
     $defaultIdSite = reset($viewableIdSites);
     $view->idSite = Common::getRequestVar('idSite', $defaultIdSite, 'int');
     $view->defaultReportSiteName = Site::getNameFor($view->idSite);
     $view->defaultSiteRevenue = \Piwik\Metrics\Formatter::getCurrencySymbol($view->idSite);
     $view->maxCustomVariables = CustomVariables::getNumUsableCustomVariables();
     $allUrls = APISitesManager::getInstance()->getSiteUrlsFromId($view->idSite);
     if (isset($allUrls[1])) {
         $aliasUrl = $allUrls[1];
     } else {
         $aliasUrl = 'x.domain.com';
     }
     $view->defaultReportSiteAlias = $aliasUrl;
     $mainUrl = Site::getMainUrlFor($view->idSite);
     $view->defaultReportSiteDomain = @parse_url($mainUrl, PHP_URL_HOST);
     // get currencies for each viewable site
     $view->currencySymbols = APISitesManager::getInstance()->getCurrencySymbols();
     $dntChecker = new DoNotTrackHeaderChecker();
     $view->serverSideDoNotTrackEnabled = $dntChecker->isActive();
     return $view->render();
 }
예제 #21
0
 public function renderWidget(PluginWidgets $widget, $method)
 {
     Piwik::checkUserHasSomeViewAccess();
     return $widget->{$method}();
 }
예제 #22
0
 /**
  * Returns true if the given userLogin is known in the database
  *
  * @param string $userLogin
  * @return bool true if the user is known
  */
 public function userExists($userLogin)
 {
     if ($userLogin == 'anonymous') {
         return true;
     }
     Piwik::checkUserIsNotAnonymous();
     Piwik::checkUserHasSomeViewAccess();
     if ($userLogin == Piwik::getCurrentUserLogin()) {
         return true;
     }
     return $this->model->userExists($userLogin);
 }
예제 #23
0
파일: API.php 프로젝트: carriercomm/piwik
 /**
  * Returns true if the default behavior is to keep URL fragments when tracking,
  * false if otherwise.
  *
  * @return bool
  */
 public function getKeepURLFragmentsGlobal()
 {
     Piwik::checkUserHasSomeViewAccess();
     return (bool) Option::get(self::OPTION_KEEP_URL_FRAGMENTS_GLOBAL);
 }
예제 #24
0
파일: API.php 프로젝트: KingNoosh/Teknik
 /**
  * Returns the most accurate IP address availble for the current user, in
  * IPv4 format. This could be the proxy client's IP address.
  *
  * @return string IP address in presentation format.
  */
 public function getIpFromHeader()
 {
     Piwik::checkUserHasSomeViewAccess();
     return IP::getIpFromHeader();
 }
예제 #25
0
    /**
     * Output redirection page instead of linking directly to avoid
     * exposing the referrer on the Piwik demo.
     *
     * @internal param string $url (via $_GET)
     */
    public function redirect()
    {
        $url = Common::getRequestVar('url', '', 'string', $_GET);
        // validate referrer
        $referrer = Url::getReferrer();
        if (empty($referrer) || !Url::isLocalUrl($referrer)) {
            die('Invalid Referrer detected - This means that your web browser is not sending the "Referrer URL" which is
				required to proceed with the redirect. Verify your browser settings and add-ons, to check why your browser
				 is not sending this referrer.

				<br/><br/>You can access the page at: ' . $url);
        }
        // mask visits to *.piwik.org
        if (!self::isPiwikUrl($url)) {
            Piwik::checkUserHasSomeViewAccess();
        }
        if (!UrlHelper::isLookLikeUrl($url)) {
            die('Please check the &url= parameter: it should to be a valid URL');
        }
        @header('Content-Type: text/html; charset=utf-8');
        echo '<html><head><meta http-equiv="refresh" content="0;url=' . $url . '" /></head></html>';
        exit;
    }
예제 #26
0
파일: API.php 프로젝트: brienomatty/elmsln
 /**
  * Returns all stored segments.
  *
  * @param bool|int $idSite Whether to return stored segments for a specific idSite, or all of them. If supplied, must be a valid site ID.
  * @return array
  */
 public function getAll($idSite = false)
 {
     if (!empty($idSite)) {
         Piwik::checkUserHasViewAccess($idSite);
     } else {
         Piwik::checkUserHasSomeViewAccess();
     }
     $userLogin = Piwik::getCurrentUserLogin();
     $model = new Model();
     if (empty($idSite)) {
         $segments = $model->getAllSegments($userLogin);
     } else {
         $segments = $model->getAllSegmentsForSite($idSite, $userLogin);
     }
     return $segments;
 }
예제 #27
0
 public function setIgnoreCookie()
 {
     Piwik::checkUserHasSomeViewAccess();
     Piwik::checkUserIsNotAnonymous();
     $salt = Common::getRequestVar('ignoreSalt', false, 'string');
     if ($salt !== $this->getIgnoreCookieSalt()) {
         throw new Exception("Not authorized");
     }
     IgnoreCookie::setIgnoreCookie();
     Piwik::redirectToModule('UsersManager', 'userSettings', array('token_auth' => false));
 }
예제 #28
0
파일: API.php 프로젝트: mgou-net/piwik
 /**
  * Return true if plugin is activated, false otherwise
  *
  * @param string $pluginName
  * @return bool
  */
 public function isPluginActivated($pluginName)
 {
     Piwik::checkUserHasSomeViewAccess();
     return \Piwik\Plugin\Manager::getInstance()->isPluginActivated($pluginName);
 }
예제 #29
0
파일: API.php 프로젝트: piwik/piwik
 /**
  * Uses a location provider to find/guess the location of an IP address.
  *
  * See LocationProvider::getLocation to see the details
  * of the result of this function.
  *
  * @param string $ip The IP address.
  * @param bool|string $provider The ID of the provider to use or false to use the
  *                               currently configured one.
  * @throws Exception
  * @return array|false
  */
 public function getLocationFromIP($ip, $provider = false)
 {
     Piwik::checkUserHasSomeViewAccess();
     if (empty($provider)) {
         $provider = LocationProvider::getCurrentProviderId();
     }
     $oProvider = LocationProvider::getProviderById($provider);
     if (empty($oProvider)) {
         throw new Exception("Cannot find the '{$provider}' provider. It is either an invalid provider " . "ID or the ID of a provider that is not working.");
     }
     $location = $oProvider->getLocation(array('ip' => $ip));
     if (empty($location)) {
         throw new Exception("Could not geolocate '{$ip}'!");
     }
     $location['ip'] = $ip;
     return $location;
 }
예제 #30
0
파일: API.php 프로젝트: annaduraig/piwik
 /**
  * Returns the number of websites to display per page.
  *
  * For example this is used in the All Websites Dashboard, in the Website Selector etc. If multiple websites are
  * shown somewhere, one should request this method to detect how many websites should be shown per page when
  * using paging. To use paging is always recommended since some installations have thousands of websites.
  *
  * @return int
  */
 public function getNumWebsitesToDisplayPerPage()
 {
     Piwik::checkUserHasSomeViewAccess();
     return SettingsPiwik::getWebsitesCountToDisplay();
 }