本文整理汇总了PHP中Piwik_Common::getRequestVar方法的典型用法代码示例。如果您正苦于以下问题:PHP Piwik_Common::getRequestVar方法的具体用法?PHP Piwik_Common::getRequestVar怎么用?PHP Piwik_Common::getRequestVar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Piwik_Common
的用法示例。
在下文中一共展示了Piwik_Common::getRequestVar方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: renderTable
protected function renderTable($table)
{
$renderer = new Piwik_DataTable_Renderer_Php($table, $serialize = false);
$array = $renderer->flatRender(null, (bool) Piwik_Common::getRequestVar('expanded', false));
// case DataTable_Array
if ($table instanceof Piwik_DataTable_Array) {
return $this->renderDataTableArray($table, $array);
}
// integer value of ZERO is a value we want to display
if ($array != 0 && empty($array)) {
$out = "<result />";
return $this->output($out);
}
if ($table instanceof Piwik_DataTable_Simple) {
if (is_array($array)) {
$out = $this->renderDataTableSimple($array);
$out = "<result>\n" . $out . "</result>";
} else {
$out = "<result>" . $array . "</result>";
}
return $this->output($out);
}
if ($table instanceof Piwik_DataTable) {
$out = $this->renderDataTable($array);
$out = "<result>\n{$out}</result>";
return $this->output($out);
}
}
示例2: 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();
}
示例3: dispatch
function dispatch()
{
$language = Piwik_Common::getRequestVar('language', '', 'string');
if($language != '')
{
$updaterController = new Piwik_CoreUpdater_Controller();
$updaterController->saveLanguage();
exit;
}
$updater = new Piwik_Updater();
$updater->addComponentToCheck('core', Piwik_Version::VERSION);
$plugins = Piwik_PluginsManager::getInstance()->getInstalledPlugins();
foreach($plugins as $pluginName => $plugin)
{
$updater->addComponentToCheck($pluginName, $plugin->getVersion());
}
$componentsWithUpdateFile = $updater->getComponentsWithUpdateFile();
if(count($componentsWithUpdateFile) == 0)
{
return;
}
$updaterController = new Piwik_CoreUpdater_Controller();
$updaterController->runUpdaterAndExit($updater, $componentsWithUpdateFile);
}
示例4: buildView
protected function buildView()
{
$view = new Piwik_View($this->dataTableTemplate);
$this->uniqueIdViewDataTable = $this->getUniqueIdViewDataTable();
$view->graphType = $this->graphType;
$this->chartDivId = $this->uniqueIdViewDataTable . "Chart_swf";
$this->parametersToModify['action'] = $this->currentControllerAction;
$this->parametersToModify = array_merge($this->variablesDefault, $this->parametersToModify);
$url = Piwik_Url::getCurrentQueryStringWithParametersModified($this->parametersToModify);
$this->includeData = !Zend_Registry::get('config')->Debug->disable_merged_requests;
$idSite = Piwik_Common::getRequestVar('idSite', 1, 'int');
Piwik_API_Request::reloadAuthUsingTokenAuth();
if (!Piwik::isUserHasViewAccess($idSite)) {
throw new Exception(Piwik_TranslateException('General_ExceptionPrivilegeAccessWebsite', array("'view'", $idSite)));
}
if ($this->includeData) {
$this->chartData = $this->getFlashData();
} else {
$this->chartData = null;
}
$view->flashParameters = $this->getFlashParameters();
$view->urlGraphData = $url;
$view->chartDivId = $this->chartDivId;
$view->formEmbedId = "formEmbed" . $this->uniqueIdViewDataTable;
$view->javascriptVariablesToSet = $this->getJavascriptVariablesToSet();
$view->properties = $this->getViewProperties();
return $view;
}
示例5: __construct
/**
* The constructor
* Initialize some local variables from the request
* @param int $idSite
* @param Piwik_Date $date ($this->date from controller)
* @throws Exception
*/
public function __construct($idSite, $date, $graphType = null)
{
$this->apiMethod = Piwik_Common::getRequestVar('apiMethod', '', 'string');
if (empty($this->apiMethod)) {
throw new Exception("Parameter apiMethod not set.");
}
$this->label = Piwik_Common::getRequestVar('label', '', 'string');
$this->label = Piwik_Common::unsanitizeInputValue($this->label);
if ($this->label === '') {
throw new Exception("Parameter label not set.");
}
$this->period = Piwik_Common::getRequestVar('period', '', 'string');
if (empty($this->period)) {
throw new Exception("Parameter period not set.");
}
$this->idSite = $idSite;
$this->graphType = $graphType;
if ($this->period != 'range') {
// handle day, week, month and year: display last X periods
$end = $date->toString();
list($this->date, $lastN) = Piwik_ViewDataTable_GenerateGraphHTML_ChartEvolution::getDateRangeAndLastN($this->period, $end);
}
$this->segment = Piwik_Common::getRequestVar('segment', '', 'string');
$this->loadEvolutionReport();
}
示例6: setDateTodayIfWebsiteCreatedToday
protected function setDateTodayIfWebsiteCreatedToday()
{
$date = Piwik_Common::getRequestVar('date', false);
if($date == 'today'
|| Piwik_Common::getRequestVar('period', false) == 'range')
{
return;
}
$websiteId = Piwik_Common::getRequestVar('idSite', false, 'int');
if ($websiteId)
{
$website = new Piwik_Site($websiteId);
$datetimeCreationDate = $this->site->getCreationDate()->getDatetime();
$creationDateLocalTimezone = Piwik_Date::factory($datetimeCreationDate, $website->getTimezone())->toString('Y-m-d');
$todayLocalTimezone = Piwik_Date::factory('now', $website->getTimezone())->toString('Y-m-d');
if( $creationDateLocalTimezone == $todayLocalTimezone )
{
Piwik::redirectToModule( 'CoreHome', 'index',
array( 'date' => 'today',
'idSite' => $websiteId,
'period' => Piwik_Common::getRequestVar('period'))
);
}
}
}
示例7: getNewVisitObject
/**
* Returns our 'generator home made' Piwik_VisitorGenerator_Visit object.
*
* @return Piwik_VisitorGenerator_Visit
*/
protected function getNewVisitObject()
{
$ip = Piwik_Common::getRequestVar('cip', false);
$visit = new Piwik_VisitorGenerator_Visit($ip);
$visit->generateTimestamp();
return $visit;
}
示例8: getProtocolInformation
/**
* Get protocol information, with the exception of HTTPS
*
* @return string protocol information
*/
public static function getProtocolInformation()
{
if(Piwik_Common::getRequestVar('clientProtocol', 'http', 'string') == 'https')
{
return 'https';
}
if(isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == 443)
{
return 'SERVER_PORT=443';
}
if(isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && strtolower($_SERVER['HTTP_X_FORWARDED_PROTO']) == 'https')
{
return 'X-Forwarded-Proto';
}
if(isset($_SERVER['HTTP_X_FORWARDED_SCHEME']) && strtolower($_SERVER['HTTP_X_FORWARDED_SCHEME']) == 'https')
{
return 'X-Forwarded-Scheme';
}
if(isset($_SERVER['HTTP_X_URL_SCHEME']) && strtolower($_SERVER['HTTP_X_URL_SCHEME']) == 'https')
{
return 'X-Url-Scheme';
}
return null;
}
示例9: getVisitorLog
public function getVisitorLog($fetch = false)
{
Piwik_API_Request::reloadAuthUsingTokenAuth();
// If previous=1 is set, user clicked previous
// we can't deal with previous so we force display of the first page
if (Piwik_Common::getRequestVar('previous', 0, 'int') == 1) {
$_GET['maxIdVisit'] = '';
}
$view = Piwik_ViewDataTable::factory();
$view->init($this->pluginName, __FUNCTION__, 'Live.getLastVisitsDetails');
$view->disableGenericFilters();
$view->disableSort();
$view->setTemplate("Live/templates/visitorLog.tpl");
$view->setSortedColumn('idVisit', 'ASC');
$view->disableSearchBox();
$view->setLimit(20);
$view->disableOffsetInformation();
$view->disableExcludeLowPopulation();
// disable the tag cloud, pie charts, bar chart icons
$view->disableShowAllViewsIcons();
// disable the button "show more datas"
$view->disableShowAllColumns();
// disable the RSS feed
$view->disableShowExportAsRssFeed();
$view->setReportDocumentation(Piwik_Translate('Live_VisitorLogDocumentation', array('<br />', '<br />')));
$view->setCustomParameter('dataTablePreviousIsFirst', 1);
$view->setCustomParameter('filterEcommerce', Piwik_Common::getRequestVar('filterEcommerce', 0, 'int'));
$view->setCustomParameter('pageUrlNotDefined', Piwik_Translate('General_NotDefined', Piwik_Translate('Actions_ColumnPageURL')));
return $this->renderView($view, $fetch);
}
示例10: log
/** Logger hook */
public function log($notification)
{
$data = Piwik_Common::getRequestVar('data', '');
$data = html_entity_decode($data);
$data = json_decode($data, true);
if (!isset($data['SiteUsers_Action'])) {
return false;
}
$action = $notification->getNotificationObject();
$idaction = $action->getIdActionUrl();
$info = $notification->getNotificationInfo();
$idsite = $info['idSite'];
$idvisit = $info['idVisit'];
include_once dirname(__FILE__) . '/Model.php';
include_once dirname(dirname(dirname(__FILE__))) . '/core/Date.php';
$model = Piwik_SiteUsers_Model::getInstance();
$logAction = $data['SiteUsers_Action'];
if ($logAction == 'logout') {
return $model->logLogout($idvisit);
}
if (!isset($data['SiteUsers_UserID']) || !isset($data['SiteUsers_UserName'])) {
return false;
}
$iduser = $data['SiteUsers_UserID'];
$userName = $data['SiteUsers_UserName'];
if ($logAction == 'login') {
$model->logLogin($iduser, $userName, $idsite, $idvisit);
}
}
示例11: sendFeedback
/**
* send email to Piwik team and display nice thanks
*/
function sendFeedback()
{
$body = Piwik_Common::getRequestVar('body', '', 'string');
$email = Piwik_Common::getRequestVar('email', '', 'string');
$view = new Piwik_View('Feedback/templates/sent.tpl');
try {
$minimumBodyLength = 35;
if (strlen($body) < $minimumBodyLength) {
throw new Exception(sprintf("Message must be at least %s characters long.", $minimumBodyLength));
}
if (!Piwik::isValidEmailString($email)) {
throw new Exception(Piwik_Translate('UsersManager_ExceptionInvalidEmail'));
}
if (strpos($body, 'http://') !== false) {
throw new Exception("The message cannot contain a URL, to avoid spams messages.");
}
$mail = new Piwik_Mail();
$mail->setFrom($email);
$mail->addTo('hello@piwik.org', 'Piwik Team');
$mail->setSubject('[ Feedback form - Piwik ]');
$mail->setBodyText($body);
@$mail->send();
} catch (Exception $e) {
$view->ErrorString = $e->getMessage();
$view->message = $body;
}
echo $view->render();
}
示例12: getByDayOfWeek
public function getByDayOfWeek($fetch = false)
{
$view = $this->getGraph(__FUNCTION__, 'VisitTime.getByDayOfWeek', 'VisitTime_DayOfWeek', $limit = 7, $sort = false);
$view->disableSort();
if ($view instanceof Piwik_ViewDataTable_GenerateGraphHTML) {
$view->showAllTicks();
}
// get query params
$idsite = Piwik_Common::getRequestVar('idSite');
$date = Piwik_Common::getRequestVar('date');
$period = Piwik_Common::getRequestVar('period');
// create a period instance
$oSite = new Piwik_Site($idsite);
$oPeriod = Piwik_Archive::makePeriodFromQueryParams($oSite, $period, $date);
// set the footer message using the period start & end date
$start = $oPeriod->getDateStart()->toString();
$end = $oPeriod->getDateEnd()->toString();
if ($start == $end) {
$dateRange = $start;
} else {
$dateRange = $start . " – " . $end;
}
$view->setFooterMessage(Piwik_Translate('General_ReportGeneratedFrom', $dateRange));
return $this->renderView($view, $fetch);
}
示例13: index
public function index()
{
Piwik::checkUserIsSuperUser();
if ($_SERVER["REQUEST_METHOD"] == "POST") {
switch (Piwik_Common::getRequestVar('form')) {
case "formMaskLength":
$this->handlePluginState(Piwik_Common::getRequestVar("anonymizeIPEnable", 0));
$maskLength = Zend_Registry::get('config')->Tracker;
$maskLength->ip_address_mask_length = Piwik_Common::getRequestVar("maskLength", 1);
Zend_Registry::get('config')->Tracker = $maskLength->toArray();
break;
case "formDeleteSettings":
$deleteLogs = Zend_Registry::get('config')->Deletelogs;
$deleteLogs->delete_logs_enable = Piwik_Common::getRequestVar("deleteEnable", 0);
$deleteLogs->delete_logs_schedule_lowest_interval = Piwik_Common::getRequestVar("deleteLowestInterval", 7);
$deleteLogs->delete_logs_older_than = (int) Piwik_Common::getRequestVar("deleteOlderThan", 180) < 7 ? 7 : Piwik_Common::getRequestVar("deleteOlderThan", 180);
$deleteLogs->delete_max_rows_per_run = Piwik_Common::getRequestVar("deleteMaxRows", 100);
Zend_Registry::get('config')->Deletelogs = $deleteLogs->toArray();
break;
default:
//do nothing
break;
}
}
return $this->redirectToIndex('PrivacyManager', 'privacySettings', null, null, null, array('updated' => 1));
}
示例14: sendFeedback
/**
* send email to Piwik team and display nice thanks
*/
function sendFeedback()
{
$email = Piwik_Common::getRequestVar('email', '', 'string');
$body = Piwik_Common::getRequestVar('body', '', 'string');
$category = Piwik_Common::getRequestVar('category', '', 'string');
$nonce = Piwik_Common::getRequestVar('nonce', '', 'string');
$view = Piwik_View::factory('sent');
$view->feedbackEmailAddress = Zend_Registry::get('config')->General->feedback_email_address;
try {
$minimumBodyLength = 35;
if (strlen($body) < $minimumBodyLength) {
throw new Exception(Piwik_TranslateException('Feedback_ExceptionBodyLength', array($minimumBodyLength)));
}
if (!Piwik::isValidEmailString($email)) {
throw new Exception(Piwik_TranslateException('UsersManager_ExceptionInvalidEmail'));
}
if (preg_match('/https?:/i', $body)) {
throw new Exception(Piwik_TranslateException('Feedback_ExceptionNoUrls'));
}
if (!Piwik_Nonce::verifyNonce('Piwik_Feedback.sendFeedback', $nonce)) {
throw new Exception(Piwik_TranslateException('General_ExceptionNonceMismatch'));
}
Piwik_Nonce::discardNonce('Piwik_Feedback.sendFeedback');
$mail = new Piwik_Mail();
$mail->setFrom(Piwik_Common::unsanitizeInputValue($email));
$mail->addTo($view->feedbackEmailAddress, 'Piwik Team');
$mail->setSubject('[ Feedback form - Piwik ] ' . $category);
$mail->setBodyText(Piwik_Common::unsanitizeInputValue($body) . "\n" . 'Piwik ' . Piwik_Version::VERSION . "\n" . 'IP: ' . Piwik_Common::getIpString() . "\n" . 'URL: ' . Piwik_Url::getReferer() . "\n");
@$mail->send();
} catch (Exception $e) {
$view->ErrorString = $e->getMessage();
$view->message = $body;
}
echo $view->render();
}
示例15: activate
function activate()
{
Piwik::checkUserIsSuperUser();
$pluginName = Piwik_Common::getRequestVar('pluginName', null, 'string');
Piwik_PluginsManager::getInstance()->activatePlugin($pluginName);
Piwik_Url::redirectToUrl('index.php?module=CorePluginsAdmin');
}