public function testAllSizes() { Piwik::checkUserIsSuperUser(); $view = new View('@ImageGraph/testAllSizes'); $this->setGeneralVariablesView($view); $period = Common::getRequestVar('period', 'day', 'string'); $date = Common::getRequestVar('date', 'today', 'string'); $_GET['token_auth'] = Piwik::getCurrentUserTokenAuth(); $availableReports = APIPlugins::getInstance()->getReportMetadata($this->idSite, $period, $date); $view->availableReports = $availableReports; $view->graphTypes = array(''); $view->graphSizes = array(array(null, null), array(460, 150), array(300, 150), array(240, 150), array(800, 150), array(600, 300, $fontSize = 18, 300, 150)); return $view->render(); }
/** * Shows a datatable that displays the amount of space each 'admin' table takes * up in the MySQL database. * * An 'admin' table is a table that is not central to analytics functionality. * So any table that isn't an archive table or a log table is an 'admin' table. * * @return string|void */ public function getAdminDataSummary() { Piwik::checkUserIsSuperUser(); return $this->renderReport(__FUNCTION__); }
public function oneClickResults() { Request::reloadAuthUsingTokenAuth($_POST); Piwik::checkUserIsSuperUser(); $view = new View('@CoreUpdater/oneClickResults'); $view->coreError = Common::getRequestVar('error', '', 'string', $_POST); $view->feedbackMessages = safe_unserialize(Common::unsanitizeInputValue(Common::getRequestVar('messages', '', 'string', $_POST))); return $view->render(); }
/** * Delete a user and all its access, given its login. * * @param string $userLogin the user login. * * @throws Exception if the user doesn't exist * * @return bool true on success */ public function deleteUser($userLogin) { Piwik::checkUserIsSuperUser(); $this->checkUserIsNotAnonymous($userLogin); $this->checkUserIsNotSuperUser($userLogin); if (!$this->userExists($userLogin)) { throw new Exception(Piwik::translate("UsersManager_ExceptionDeleteDoesNotExist", $userLogin)); } $this->deleteUserOnly($userLogin); $this->deleteUserAccess($userLogin); Cache::deleteTrackerCache(); }
protected function initPluginModification($nonceName) { Piwik::checkUserIsSuperUser(); $nonce = Common::getRequestVar('nonce', null, 'string'); if (!Nonce::verifyNonce($nonceName, $nonce)) { throw new \Exception(Piwik::translate('General_ExceptionNonceMismatch')); } Nonce::discardNonce($nonceName); $pluginName = Common::getRequestVar('pluginName', null, 'string'); return $pluginName; }
public function activateDoNotTrack() { Piwik::checkUserIsSuperUser(); Nonce::checkNonce(self::ACTIVATE_DNT_NONCE); DoNotTrackHeaderChecker::activate(); $this->redirectToIndex('PrivacyManager', 'privacySettings'); }
public function uploadCustomLogo() { Piwik::checkUserIsSuperUser(); $logo = new CustomLogo(); $success = $logo->copyUploadedLogoToFilesystem(); if ($success) { return '1'; } return '0'; }
/** * Specify if normal users can manage their own SMS API credential * * @param bool $delegatedManagement false if SMS API credential only manageable by super admin, true otherwise */ public function setDelegatedManagement($delegatedManagement) { Piwik::checkUserIsSuperUser(); Option::set(MobileMessaging::DELEGATED_MANAGEMENT_OPTION, $delegatedManagement); }
/** * This controller action renders an admin tab that runs the installation * system check, so people can see if there are any issues w/ their running * Piwik installation. * * This admin tab is only viewable by the super user. */ public function systemCheckPage() { Piwik::checkUserIsSuperUser(); $view = new View('@Installation/systemCheckPage', $this->getInstallationSteps(), __FUNCTION__); $this->setBasicVariablesView($view); $view->duringInstall = false; $this->setupSystemCheckView($view); $infos = $view->infos; $infos['extra'] = self::performAdminPageOnlySystemCheck(); $view->infos = $infos; return $view->render(); }
/** * Returns the list of unique timezones from all configured sites. * * @return array ( string ) */ public function getUniqueSiteTimezones() { Piwik::checkUserIsSuperUser(); $results = Db::fetchAll("SELECT distinct timezone FROM " . Common::prefixTable('site')); $timezones = array(); foreach ($results as $result) { $timezones[] = $result['timezone']; } return $timezones; }
/** * Records settings for the anonymous users (default report, default date) */ public function recordAnonymousUserSettings() { $response = new ResponseBuilder(Common::getRequestVar('format')); try { Piwik::checkUserIsSuperUser(); $this->checkTokenInUrl(); $anonymousDefaultReport = Common::getRequestVar('anonymousDefaultReport'); $anonymousDefaultDate = Common::getRequestVar('anonymousDefaultDate'); $userLogin = '******'; APIUsersManager::getInstance()->setUserPreference($userLogin, APIUsersManager::PREFERENCE_DEFAULT_REPORT, $anonymousDefaultReport); APIUsersManager::getInstance()->setUserPreference($userLogin, APIUsersManager::PREFERENCE_DEFAULT_REPORT_DATE, $anonymousDefaultDate); $toReturn = $response->getResponse(); } catch (Exception $e) { $toReturn = $response->getResponseException($e); } return $toReturn; }
/** * Removes all settings for this plugin from the database. Useful when uninstalling * a plugin. */ public function removeAllPluginSettings() { Piwik::checkUserIsSuperUser(); Option::delete($this->getOptionKey()); $this->settingsValues = array(); }
/** * Sets the current LocationProvider type. * * Input: * Requires the 'id' query parameter to be set to the desired LocationProvider's ID. * * Output: * Nothing. */ public function setCurrentLocationProvider() { $this->dieIfGeolocationAdminIsDisabled(); Piwik::checkUserIsSuperUser(); if ($_SERVER["REQUEST_METHOD"] == "POST") { $this->checkTokenInUrl(); $providerId = Common::getRequestVar('id'); $provider = LocationProvider::setCurrentProvider($providerId); if ($provider === false) { throw new Exception("Invalid provider ID: '{$providerId}'."); } return 1; } }
/** * Returns a datatable describing how much total space is taken up by each * individual metric type. * * Goal metrics, metrics of the format .*_[0-9]+ and 'done...' metrics are grouped together. * * @param bool $forceCache false to use the cached result, true to run the queries again and * cache the result. * @return DataTable A datatable with three columns: 'data_size', 'index_size', 'row_count'. */ public function getIndividualMetricsSummary($forceCache = false) { Piwik::checkUserIsSuperUser(); return $this->metadataProvider->getRowCountsAndSizeByMetricName($forceCache); }
set_time_limit(0); @date_default_timezone_set('UTC'); require_once PIWIK_INCLUDE_PATH . '/libs/upgradephp/upgrade.php'; require_once PIWIK_INCLUDE_PATH . '/core/testMinimumPhpVersion.php'; require_once PIWIK_INCLUDE_PATH . '/core/Loader.php'; $GLOBALS['PIWIK_TRACKER_DEBUG'] = false; define('PIWIK_ENABLE_DISPATCH', false); Config::getInstance()->log['log_writers'][] = 'screen'; Config::getInstance()->log['log_level'] = 'VERBOSE'; FrontController::getInstance()->init(); $query = "SELECT count(*) FROM " . Common::prefixTable('log_visit'); $count = Db::fetchOne($query); // when script run via browser, check for Super User & output html page to do conversion via AJAX if (!Common::isPhpCliMode()) { try { Piwik::checkUserIsSuperUser(); } catch (Exception $e) { Log::error('[error] You must be logged in as Super User to run this script. Please login in to Piwik and refresh this page.'); exit; } // the 'start' query param will be supplied by the AJAX requests, so if it's not there, the // user is viewing the page in the browser. if (Common::getRequestVar('start', false) === false) { // output HTML page that runs update via AJAX ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <script type="text/javascript" src="../../libs/jquery/jquery.js"></script> <script type="text/javascript"> (function ($) {
/** * Check that the current user is either the specified user or the superuser. * * @param string $theUser A username. * @throws NoAccessException If the user is neither the super user nor the user `$theUser`. * @api */ public static function checkUserIsSuperUserOrTheUser($theUser) { try { if (Piwik::getCurrentUserLogin() !== $theUser) { // or to the super user Piwik::checkUserIsSuperUser(); } } catch (NoAccessException $e) { throw new NoAccessException(Piwik::translate('General_ExceptionCheckUserIsSuperUserOrTheUser', array($theUser))); } }