コード例 #1
0
ファイル: Rss.php プロジェクト: Doluci/tomatocart
 protected function renderTable($table)
 {
     if (!$table instanceof Piwik_DataTable_Array) {
         throw new Exception("RSS Feed only used on DataTable_Array");
     }
     $idSite = Piwik_Common::getRequestVar('idSite', 1);
     $period = Piwik_Common::getRequestVar('period');
     $currentUrl = Piwik_Url::getCurrentUrlWithoutFileName();
     $piwikUrl = $currentUrl . "?module=Home&action=index&idSite=" . $idSite . "&period=" . $period;
     $out = "";
     $moreRecentFirst = array_reverse($table->getArray(), true);
     foreach ($moreRecentFirst as $date => $subtable) {
         $timestamp = $table->metaData[$date]['timestamp'];
         $site = $table->metaData[$date]['site'];
         $pudDate = date('r', $timestamp);
         $dateUrl = date('Y-m-d', $timestamp);
         $thisPiwikUrl = htmlentities($piwikUrl . "&date={$dateUrl}");
         $siteName = $site->getName();
         $title = $siteName . " on " . $date;
         $out .= "\t<item>\n\t\t<pubDate>{$pudDate}</pubDate>\n\t\t<guid>{$thisPiwikUrl}</guid>\n\t\t<link>{$thisPiwikUrl}</link>\n\t\t<title>{$title}</title>\n\t\t<author>http://piwik.org</author>\n\t\t<description>";
         $out .= htmlspecialchars($this->renderDataTable($subtable));
         $out .= "</description>\n\t</item>\n";
     }
     $header = $this->getRssHeader();
     $footer = $this->getRssFooter();
     return $this->output($header . $out . $footer);
 }
コード例 #2
0
 function init($currentControllerName, $currentControllerAction, $apiMethodToRequestDataTable)
 {
     parent::init($currentControllerName, $currentControllerAction, $apiMethodToRequestDataTable);
     $this->setParametersToModify(array('date' => Piwik_Common::getRequestVar('date', 'last30', 'string')));
     $this->disableShowAllViewsIcons();
     $this->disableShowTable();
 }
コード例 #3
0
ファイル: Controller.php プロジェクト: neolf/PIWIK4MOBILE
 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));
 }
コード例 #4
0
ファイル: Controller.php プロジェクト: neolf/PIWIK4MOBILE
 public function index()
 {
     Piwik::checkUserIsNotAnonymous();
     $view = Piwik_View::factory('index');
     $this->setGeneralVariablesView($view);
     $view->currentUserEmail = Piwik::getCurrentUserEmail();
     $availableReports = Piwik_API_API::getInstance()->getReportMetadata($this->idSite);
     $reportsByCategory = array();
     foreach ($availableReports as $report) {
         $reportsByCategory[$report['category']][] = $report;
     }
     unset($reportsByCategory['API']);
     $reports = Piwik_PDFReports_API::getInstance()->getReports($this->idSite, $period = false, $idReport = false, $ifSuperUserReturnOnlySuperUserReports = true);
     $reportsById = array();
     foreach ($reports as &$report) {
         $report['additional_emails'] = str_replace(',', "\n", $report['additional_emails']);
         $report['reports'] = explode(',', str_replace('.', '_', $report['reports']));
         $reportsById[$report['idreport']] = $report;
     }
     $view->downloadOutputType = Piwik_PDFReports_API::OUTPUT_DOWNLOAD;
     $columnsCount = 2;
     $view->newColumnAfter = ceil(count($reportsByCategory) / $columnsCount);
     $view->reportsByCategory = $reportsByCategory;
     $view->reportsJSON = Piwik_Common::json_encode($reportsById);
     $view->periods = array_merge(array('never' => Piwik_Translate('General_Never')), Piwik_PDFReports_API::getPeriodToFrequency());
     $view->defaultFormat = Piwik_PDFReports::DEFAULT_FORMAT;
     $view->formats = Piwik_ReportRenderer::$availableReportRenderers;
     $view->aggregateReportsFormats = Piwik_PDFReports_API::getAggregateReportsFormats();
     $view->reports = $reports;
     $view->language = Piwik_LanguagesManager::getLanguageCodeForCurrentUser();
     echo $view->render();
 }
コード例 #5
0
 function activate()
 {
     Piwik::checkUserIsSuperUser();
     $pluginName = Piwik_Common::getRequestVar('pluginName', null, 'string');
     Piwik_PluginsManager::getInstance()->activatePlugin($pluginName);
     Piwik_Url::redirectToUrl('index.php?module=CorePluginsAdmin');
 }
コード例 #6
0
ファイル: Goals.php プロジェクト: nnnnathann/piwik
 public function main()
 {
     $this->idSite = Piwik_Common::getRequestVar('idSite', null, 'int');
     $this->processOnlyIdGoal = Piwik_Common::getRequestVar('idGoal', 0, 'string');
     $this->isEcommerce = $this->processOnlyIdGoal == Piwik_Archive::LABEL_ECOMMERCE_ORDER;
     $this->viewProperties['show_exclude_low_population'] = true;
     $this->viewProperties['show_goals'] = true;
     if (Piwik_Common::getRequestVar('documentationForGoalsPage', 0, 'int') == 1) {
         $this->setReportDocumentation(Piwik_Translate('Goals_ConversionByTypeReportDocumentation', array('<br />', '<br />', '<a href="http://piwik.org/docs/tracking-goals-web-analytics/" target="_blank">', '</a>')));
     }
     $this->setMetricDocumentation('nb_visits', Piwik_Translate('Goals_ColumnVisits'));
     if ($this->isEcommerce) {
         $this->setMetricDocumentation('revenue_per_visit', Piwik_Translate('Goals_ColumnRevenuePerVisitDocumentation', Piwik_Translate('General_EcommerceOrders')));
         $this->setColumnsTranslations(array('goal_%s_conversion_rate' => Piwik_Translate('Goals_ConversionRate'), 'goal_%s_nb_conversions' => Piwik_Translate('General_EcommerceOrders'), 'goal_%s_revenue' => Piwik_Translate('General_TotalRevenue'), 'goal_%s_revenue_per_visit' => Piwik_Translate('General_ColumnValuePerVisit'), 'goal_%s_avg_order_revenue' => Piwik_Translate('General_AverageOrderValue'), 'goal_%s_items' => Piwik_Translate('General_PurchasedProducts')));
         $this->setColumnsToDisplay(array('label', 'nb_visits', 'goal_%s_nb_conversions', 'goal_%s_revenue', 'goal_%s_conversion_rate', 'goal_%s_avg_order_revenue', 'goal_%s_items', 'goal_%s_revenue_per_visit'));
         // Default sort column
         $this->setSortedColumn('goal_ecommerceOrder_revenue', 'desc');
     } else {
         $this->setMetricDocumentation('revenue_per_visit', Piwik_Translate('Goals_ColumnRevenuePerVisitDocumentation', Piwik_Translate('Goals_EcommerceAndGoalsMenu')));
         $this->setColumnsTranslations(array('goal_%s_conversion_rate' => Piwik_Translate('Goals_ConversionRate'), 'goal_%s_nb_conversions' => Piwik_Translate('Goals_Conversions'), 'goal_%s_revenue' => '%s ' . Piwik_Translate('Goals_ColumnRevenue'), 'goal_%s_revenue_per_visit' => '%s ' . Piwik_Translate('General_ColumnValuePerVisit'), 'nb_conversions' => Piwik_Translate('Goals_ColumnConversions'), 'conversion_rate' => Piwik_Translate('General_ColumnConversionRate'), 'revenue' => Piwik_Translate('Goals_ColumnRevenue'), 'revenue_per_visit' => Piwik_Translate('General_ColumnValuePerVisit')));
         $this->setColumnsToDisplay(array('label', 'nb_visits', 'goal_%s_nb_conversions', 'goal_%s_conversion_rate', 'goal_%s_revenue', 'goal_%s_revenue_per_visit', 'revenue_per_visit'));
         // Default sort column
         $columnsToDisplay = $this->getColumnsToDisplay();
         $columnNbConversionsCurrentGoal = $columnsToDisplay[2];
         if ($this->processOnlyIdGoal > 0 && strpos($columnNbConversionsCurrentGoal, '_nb_conversions') !== false) {
             $this->setSortedColumn($columnNbConversionsCurrentGoal, 'desc');
         }
     }
     parent::main();
 }
コード例 #7
0
ファイル: 0.9.1.php プロジェクト: BackupTheBerlios/oos-svn
	static function getSql($schema = 'Myisam')
	{
		if(!Piwik::isTimezoneSupportEnabled())
		{
			return array();
		}
		// @see http://bugs.php.net/46111
		$timezones = timezone_identifiers_list();
		$brokenTZ = array();

		foreach ($timezones as $timezone) {
			$testDate = "2008-08-19 13:00:00 " . $timezone;
	
			if (!strtotime($testDate)) {
				$brokenTZ[] = $timezone;
			}
		}
		$timezoneList = '"'. implode('","', $brokenTZ) . '"';

		return array(
			'UPDATE '. Piwik_Common::prefixTable('site') .'
				SET timezone = "UTC" 
				WHERE timezone IN ('. $timezoneList .')' => false,

			'UPDATE `'. Piwik_Common::prefixTable('option') .'`
				SET option_value = "UTC" 
			WHERE option_name = "SitesManager_DefaultTimezone" 
				AND option_value IN ('. $timezoneList .')' => false,
		);
	}
コード例 #8
0
ファイル: 0.5.2.php プロジェクト: BackupTheBerlios/oos-svn
	static function update()
	{
		$config = Zend_Registry::get('config');
		$salt = Piwik_Common::generateUniqId();
		try {
			if(isset($config->superuser->salt))
			{
				return;
			}

			if(is_writable( Piwik_Config::getDefaultUserConfigPath() ))
			{
				$superuser_info = $config->superuser->toArray();
				$superuser_info['salt'] = $salt;
				$config->superuser = $superuser_info;
				$config->__destruct();

				Piwik::createConfigObject();

				return;
			}
		} catch(Exception $e) { }

		throw new Piwik_Updater_UpdateErrorException("Edit config.ini.php and add below <code>[superuser]</code> the following line <br/><code>salt = $salt</code>");
	}
コード例 #9
0
ファイル: 0.6.2.php プロジェクト: BackupTheBerlios/oos-svn
	static function update()
	{
		$obsoleteFiles = array(
			PIWIK_INCLUDE_PATH . '/core/Db/Mysqli.php',
		);
		foreach($obsoleteFiles as $obsoleteFile)
		{
			if(file_exists($obsoleteFile))
			{
				@unlink($obsoleteFile);
			}
		}

		$obsoleteDirectories = array(
			PIWIK_INCLUDE_PATH . '/core/Db/Pdo',
		);
		foreach($obsoleteDirectories as $dir)
		{
			if(file_exists($dir))
			{
				Piwik::unlinkRecursive($dir, true);
			}
		}

		// force regeneration of cache files
		Piwik::setUserIsSuperUser();
		$allSiteIds = Piwik_SitesManager_API::getInstance()->getAllSitesId();
		Piwik_Common::regenerateCacheWebsiteAttributes($allSiteIds);
	}
コード例 #10
0
 /**
  * Convert segment expression to an action ID or an SQL expression.
  * 
  * This method is used as a sqlFilter-callback for the segments of this plugin.
  * Usually, these callbacks only return a value that should be compared to the
  * column in the database. In this case, that doesn't work since multiple IDs
  * can match an expression (e.g. "pageUrl=@foo").
  */
 function getIdActionFromSegment($string, $sqlField, $matchType = '==')
 {
     // Field is visit_*_idaction_url or visit_*_idaction_name
     $actionType = strpos($sqlField, '_name') === false ? Piwik_Tracker_Action::TYPE_ACTION_URL : Piwik_Tracker_Action::TYPE_ACTION_NAME;
     // exact matches work by returning the id directly
     if ($matchType == Piwik_SegmentExpression::MATCH_EQUAL || $matchType == Piwik_SegmentExpression::MATCH_NOT_EQUAL) {
         $sql = Piwik_Tracker_Action::getSqlSelectActionId();
         $bind = array($string, $string, $actionType);
         $idAction = Piwik_FetchOne($sql, $bind);
         // if the action is not found, we hack -100 to ensure it tries to match against an integer
         // otherwise binding idaction_name to "false" returns some rows for some reasons (in case &segment=pageTitle==Větrnásssssss)
         if (empty($idAction)) {
             $idAction = -100;
         }
         return $idAction;
     }
     // now, we handle the cases =@ (contains) and !@ (does not contain)
     // build the expression based on the match type
     $sql = 'SELECT idaction FROM ' . Piwik_Common::prefixTable('log_action') . ' WHERE ';
     switch ($matchType) {
         case '=@':
             // use concat to make sure, no %s occurs because some plugins use %s in their sql
             $sql .= '( name LIKE CONCAT("%", ?, "%") AND type = ' . $actionType . ' )';
             break;
         case '!@':
             $sql .= '( name NOT LIKE CONCAT("%", ?, "%") AND type = ' . $actionType . ' )';
             break;
         default:
             throw new Exception("This match type is not available for action-segments.");
             break;
     }
     return array('SQL' => $sql, 'bind' => $string);
 }
コード例 #11
0
	function dispatch($notification = null)
	{
		if($notification)
		{
			$exception = $notification->getNotificationObject();
			$message = $exception->getMessage();
		}
		else
		{
			$message = '';
		}

		Piwik_Translate::getInstance()->loadCoreTranslation();

		Piwik_PostEvent('Installation.startInstallation', $this);

		$step = Piwik_Common::getRequestVar('action', 'welcome', 'string');
		$controller = $this->getInstallationController();
		if(in_array($step, array_keys($controller->getInstallationSteps())) || $step == 'saveLanguage')
		{
			$controller->$step($message);
		}
		else
		{
			Piwik::exitWithErrorMessage(Piwik_Translate('Installation_NoConfigFound'));
		}

		exit;
	}	
コード例 #12
0
ファイル: 0.2.10.php プロジェクト: BackupTheBerlios/oos-svn
	static function getSql($schema = 'Myisam')
	{
		return array(
			'CREATE TABLE `'. Piwik_Common::prefixTable('option') .'` (
				idoption BIGINT NOT NULL AUTO_INCREMENT ,
				option_name VARCHAR( 64 ) NOT NULL ,
				option_value LONGTEXT NOT NULL ,
				PRIMARY KEY ( idoption , option_name )
			)' => false,

			// 0.1.7 [463]
			'ALTER IGNORE TABLE `'. Piwik_Common::prefixTable('log_visit') .'`
				 CHANGE `location_provider` `location_provider` VARCHAR( 100 ) DEFAULT NULL' => '1054',

			// 0.1.7 [470]
			'ALTER TABLE `'. Piwik_Common::prefixTable('logger_api_call') .'`
				CHANGE `parameter_names_default_values` `parameter_names_default_values` TEXT,
				CHANGE `parameter_values` `parameter_values` TEXT,
				CHANGE `returned_value` `returned_value` TEXT' => false,
			'ALTER TABLE `'. Piwik_Common::prefixTable('logger_error') .'`
				CHANGE `message` `message` TEXT' => false,
			'ALTER TABLE `'. Piwik_Common::prefixTable('logger_exception') .'`
				CHANGE `message` `message` TEXT' => false,
			'ALTER TABLE `'. Piwik_Common::prefixTable('logger_message') .'`
				CHANGE `message` `message` TEXT' => false,

			// 0.2.2 [489]
			'ALTER IGNORE TABLE `'. Piwik_Common::prefixTable('site') .'`
				 CHANGE `feedburnerName` `feedburnerName` VARCHAR( 100 ) DEFAULT NULL' => '1054',
		);
	}
コード例 #13
0
	function init()
	{
		$resetToken = Piwik_Common::getRequestVar('token', '', 'string');

		$formElements = array(
			array('text', 'form_login'),
			array('password', 'form_password'),
			array('password', 'form_password_bis'),
			array('text', 'form_token'),
		);
		$this->addElements( $formElements );

		$defaults = array(
			'form_token' => $resetToken,
		);
		$this->setDefaults($defaults);

		$formRules = array(
			array('form_login', sprintf(Piwik_Translate('General_Required'), Piwik_Translate('General_Username')), 'required'),
			array('form_password', sprintf(Piwik_Translate('General_Required'), Piwik_Translate('Login_Password')), 'required'),
			array('form_password_bis', sprintf(Piwik_Translate('General_Required'), Piwik_Translate('Login_PasswordRepeat')), 'required'),
			array('form_token', sprintf(Piwik_Translate('General_Required'), Piwik_Translate('Login_PasswordResetToken')), 'required'),
			array('form_password', Piwik_Translate( 'Login_PasswordsDoNotMatch'), 'fieldHaveSameValue', 'form_password_bis'),
		);
		$this->addRules( $formRules );

		$this->addElement('submit', 'submit');
	}
コード例 #14
0
 public function render()
 {
     $this->shuffleCloud();
     $return = array();
     if (empty($this->wordsArray)) {
         return array();
     }
     $maxValue = max($this->wordsArray);
     foreach ($this->wordsArray as $word => $popularity) {
         $wordTruncated = $word;
         if (Piwik_Common::mb_strlen($word) > $this->truncatingLimit) {
             $wordTruncated = Piwik_Common::mb_substr($word, 0, $this->truncatingLimit - 3) . '...';
         }
         // case hideFutureHoursWhenToday=1 shows hours with no visits
         if ($maxValue == 0) {
             $percent = 0;
         } else {
             $percent = $popularity / $maxValue * 100;
         }
         // CSS style value
         $sizeRange = $this->getClassFromPercent($percent);
         $return[$word] = array('word' => $word, 'wordTruncated' => $wordTruncated, 'value' => $popularity, 'size' => $sizeRange, 'percent' => $percent);
     }
     return $return;
 }
コード例 #15
0
ファイル: Auth.php プロジェクト: nnnnathann/piwik
    /**
     * Authenticates user
     *
     * @return Piwik_Auth_Result
     */
    public function authenticate()
    {
        $rootLogin = Piwik_Config::getInstance()->superuser['login'];
        $rootPassword = Piwik_Config::getInstance()->superuser['password'];
        $rootToken = Piwik_UsersManager_API::getInstance()->getTokenAuth($rootLogin, $rootPassword);
        if (is_null($this->login)) {
            if ($this->token_auth === $rootToken) {
                return new Piwik_Auth_Result(Piwik_Auth_Result::SUCCESS_SUPERUSER_AUTH_CODE, $rootLogin, $this->token_auth);
            }
            $login = Piwik_FetchOne('SELECT login
					FROM ' . Piwik_Common::prefixTable('user') . ' 
					WHERE token_auth = ?', array($this->token_auth));
            if (!empty($login)) {
                return new Piwik_Auth_Result(Piwik_Auth_Result::SUCCESS, $login, $this->token_auth);
            }
        } else {
            if (!empty($this->login)) {
                if ($this->login === $rootLogin && $this->getHashTokenAuth($rootLogin, $rootToken) === $this->token_auth || $rootToken === $this->token_auth) {
                    $this->setTokenAuth($rootToken);
                    return new Piwik_Auth_Result(Piwik_Auth_Result::SUCCESS_SUPERUSER_AUTH_CODE, $rootLogin, $this->token_auth);
                }
                $login = $this->login;
                $userToken = Piwik_FetchOne('SELECT token_auth
					FROM ' . Piwik_Common::prefixTable('user') . ' 
					WHERE login = ?', array($login));
                if (!empty($userToken) && ($this->getHashTokenAuth($login, $userToken) === $this->token_auth || $userToken === $this->token_auth)) {
                    $this->setTokenAuth($userToken);
                    return new Piwik_Auth_Result(Piwik_Auth_Result::SUCCESS, $login, $userToken);
                }
            }
        }
        return new Piwik_Auth_Result(Piwik_Auth_Result::FAILURE, $this->login, $this->token_auth);
    }
コード例 #16
0
	public function getEvolutionGraph( $fetch = false, $columns = false)
	{
		$view = $this->getLastUnitGraph($this->pluginName, __FUNCTION__, "VisitFrequency.get");
		if(empty($columns))
		{
			$columns = Piwik_Common::getRequestVar('columns');
		}
		$columns = !is_array($columns) ? array($columns) : $columns;
		$view->setColumnsToDisplay($columns);
		$view->setColumnsTranslations(array(
			'nb_visits_returning' => Piwik_Translate('VisitFrequency_ColumnReturningVisits'),
			'nb_actions_returning' => Piwik_Translate('VisitFrequency_ColumnActionsByReturningVisits'),
			'avg_time_on_site_returning' => Piwik_Translate('VisitFrequency_ColumnAverageVisitDurationForReturningVisitors'),
			'bounce_rate_returning' => Piwik_Translate('VisitFrequency_ColumnBounceRateForReturningVisits'),
			'nb_actions_per_visit_returning' => Piwik_Translate('VisitFrequency_ColumnAvgActionsPerReturningVisit'),
		));
		
		$doc = Piwik_Translate('VisitFrequency_ReturningVisitsDocumentation').'<br />'
		     . Piwik_Translate('General_BrokenDownReportDocumentation').'<br />'
		     . Piwik_Translate('VisitFrequency_ReturningVisitDocumentation');
		
		$view->setReportDocumentation($doc);
		
		return $this->renderView($view, $fetch);
	}
コード例 #17
0
	/**
	 * Check for a newer version
	 */
	public static function check()
	{
		$lastTimeChecked = Piwik_GetOption(self::LAST_TIME_CHECKED);
		if($lastTimeChecked === false
			|| time() - self::CHECK_INTERVAL > $lastTimeChecked )
		{
			$parameters = array(
				'piwik_version' => Piwik_Version::VERSION,
				'php_version' => phpversion(),
				'url' => Piwik_Url::getCurrentUrlWithoutQueryString(),
				'trigger' => Piwik_Common::getRequestVar('module','','string'),
			);

			$url = self::PIWIK_HOST . "?" . http_build_query($parameters, '', '&');
			$timeout = self::SOCKET_TIMEOUT;
			try {
				$latestVersion = Piwik::sendHttpRequest($url, $timeout);
				Piwik_SetOption(self::LATEST_VERSION, $latestVersion);
			} catch(Exception $e) {
				// e.g., disable_functions = fsockopen; allow_url_open = Off
				Piwik_SetOption(self::LATEST_VERSION, '');
			}
			Piwik_SetOption(self::LAST_TIME_CHECKED, time(), $autoload = 1);
		}
	}
コード例 #18
0
ファイル: Log.php プロジェクト: BackupTheBerlios/oos-svn
 function addWriteToFile()
 {
     Piwik_Common::mkdir(dirname($this->logToFileFilename));
     $writerFile = new Zend_Log_Writer_Stream($this->logToFileFilename);
     $writerFile->setFormatter($this->fileFormatter);
     $this->addWriter($writerFile);
 }
コード例 #19
0
 /**
  * @see Piwik_ViewDataTable::main()
  */
 public function main()
 {
     if ($this->mainAlreadyExecuted) {
         return;
     }
     $this->mainAlreadyExecuted = true;
     // If period=range, we force the sparkline to draw daily data points
     $period = Piwik_Common::getRequestVar('period');
     if ($period == 'range') {
         $_GET['period'] = 'day';
     }
     $this->loadDataTableFromAPI();
     // then revert the hack for potentially subsequent getRequestVar
     $_GET['period'] = $period;
     $values = $this->getValuesFromDataTable($this->dataTable);
     $this->isDataAvailable = true;
     if (empty($values)) {
         $values = array_fill(0, 30, 0);
         $this->isDataAvailable = false;
     }
     $graph = new Piwik_Visualization_Sparkline();
     $graph->setValues($values);
     $graph->main();
     $this->view = $graph;
 }
コード例 #20
0
 protected function buildView()
 {
     // access control
     $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)));
     }
     // collect data
     $this->parametersToModify['action'] = $this->currentControllerAction;
     $this->parametersToModify = array_merge($this->variablesDefault, $this->parametersToModify);
     $this->graphData = $this->getGraphData();
     // build view
     $view = new Piwik_View($this->dataTableTemplate);
     $view->width = $this->width;
     $view->height = $this->height;
     $view->chartDivId = $this->getUniqueIdViewDataTable() . "Chart";
     $view->graphType = $this->graphType;
     $view->data = $this->graphData;
     $view->isDataAvailable = strpos($this->graphData, '"series":[]') === false;
     $view->javascriptVariablesToSet = $this->getJavascriptVariablesToSet();
     $view->properties = $this->getViewProperties();
     $view->reportDocumentation = $this->getReportDocumentation();
     return $view;
 }
コード例 #21
0
ファイル: Controller.php プロジェクト: Gninety/Microweber
 /**
  * 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();
 }
コード例 #22
0
ファイル: 0.2.27.php プロジェクト: nnnnathann/piwik
    static function getSql($schema = 'Myisam')
    {
        $sqlarray = array('ALTER TABLE `' . Piwik_Common::prefixTable('log_visit') . '`
				ADD `visit_goal_converted` VARCHAR( 1 ) NOT NULL AFTER `visit_total_time`' => false, 'ALTER IGNORE TABLE `' . Piwik_Common::prefixTable('log_visit') . '`
				CHANGE `visit_goal_converted` `visit_goal_converted` TINYINT(1) NOT NULL' => false, 'CREATE TABLE `' . Piwik_Common::prefixTable('goal') . "` (\n\t\t\t\t`idsite` int(11) NOT NULL,\n\t\t\t\t`idgoal` int(11) NOT NULL,\n\t\t\t\t`name` varchar(50) NOT NULL,\n\t\t\t\t`match_attribute` varchar(20) NOT NULL,\n\t\t\t\t`pattern` varchar(255) NOT NULL,\n\t\t\t\t`pattern_type` varchar(10) NOT NULL,\n\t\t\t\t`case_sensitive` tinyint(4) NOT NULL,\n\t\t\t\t`revenue` float NOT NULL,\n\t\t\t\t`deleted` tinyint(4) NOT NULL default '0',\n\t\t\t\tPRIMARY KEY  (`idsite`,`idgoal`)\n\t\t\t)" => false, 'CREATE TABLE `' . Piwik_Common::prefixTable('log_conversion') . '` (
				`idvisit` int(10) unsigned NOT NULL,
				`idsite` int(10) unsigned NOT NULL,
				`visitor_idcookie` char(32) NOT NULL,
				`server_time` datetime NOT NULL,
				`visit_server_date` date NOT NULL,
				`idaction` int(11) NOT NULL,
				`idlink_va` int(11) NOT NULL,
				`referer_idvisit` int(10) unsigned default NULL,
				`referer_visit_server_date` date default NULL,
				`referer_type` int(10) unsigned default NULL,
				`referer_name` varchar(70) default NULL,
				`referer_keyword` varchar(255) default NULL,
				`visitor_returning` tinyint(1) NOT NULL,
				`location_country` char(3) NOT NULL,
				`location_continent` char(3) NOT NULL,
				`url` text NOT NULL,
				`idgoal` int(10) unsigned NOT NULL,
				`revenue` float default NULL,
				PRIMARY KEY  (`idvisit`,`idgoal`),
				KEY `index_idsite_date` (`idsite`,`visit_server_date`)
			)' => false);
        $tables = Piwik::getTablesInstalled();
        foreach ($tables as $tableName) {
            if (preg_match('/archive_/', $tableName) == 1) {
                $sqlarray['CREATE INDEX index_all ON ' . $tableName . ' (`idsite`,`date1`,`date2`,`name`,`ts_archived`)'] = false;
            }
        }
        return $sqlarray;
    }
コード例 #23
0
ファイル: Url.php プロジェクト: Doluci/tomatocart
 static function getArrayFromCurrentQueryString()
 {
     $queryString = Piwik_Url::getCurrentQueryString();
     $queryString = htmlspecialchars($queryString);
     $urlValues = Piwik_Common::getArrayFromQueryString($queryString);
     return $urlValues;
 }
コード例 #24
0
ファイル: Controller.php プロジェクト: Gninety/Microweber
 public function getVisitorLog($fetch = false)
 {
     // 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->setCustomParameter('pageUrlNotDefined', Zend_Registry::get('config')->General->action_default_url_when_not_defined);
     return $this->renderView($view, $fetch);
 }
コード例 #25
0
ファイル: 0.5.4.php プロジェクト: nnnnathann/piwik
 static function update()
 {
     $salt = Piwik_Common::generateUniqId();
     if (!isset(Piwik_Config::getInstance()->superuser['salt'])) {
         try {
             if (is_writable(Piwik_Config::getLocalConfigPath())) {
                 Piwik_Config::getInstance()->setConfigOption('superuser', 'salt', $salt);
                 Piwik_Config::getInstance()->forceSave();
             } else {
                 throw new Exception('mandatory update failed');
             }
         } catch (Exception $e) {
             throw new Piwik_Updater_UpdateErrorException("Please edit your config/config.ini.php file and add below <code>[superuser]</code> the following line: <br /><code>salt = {$salt}</code>");
         }
     }
     $plugins = Piwik_Config::getInstance()->Plugins;
     if (!in_array('MultiSites', $plugins)) {
         try {
             if (is_writable(Piwik_Config::getLocalConfigPath())) {
                 $plugins[] = 'MultiSites';
                 Piwik_Config::getInstance()->setConfigSection('Plugins', $plugins);
                 Piwik_Config::getInstance()->forceSave();
             } else {
                 throw new Exception('optional update failed');
             }
         } catch (Exception $e) {
             throw new Exception("You can now enable the new MultiSites plugin in the Plugins screen in the Piwik admin!");
         }
     }
     Piwik_Updater::updateDatabase(__FILE__, self::getSql());
 }
コード例 #26
0
 /**
  * Get translation file path
  *
  * @param string $lang ISO 639-1 alpha-2 language code
  * @param string $base Optional base directory (either 'lang' or 'tmp')
  * @throws Exception
  * @return string path
  */
 public static function getTranslationPath($lang, $base = 'lang')
 {
     if (!Piwik_Common::isValidFilename($lang) || $base !== 'lang' && $base !== 'tmp') {
         throw new Exception(Piwik_TranslateException('General_ExceptionLanguageFileNotFound', array($lang)));
     }
     return PIWIK_INCLUDE_PATH . '/' . $base . '/' . $lang . '.php';
 }
コード例 #27
0
ファイル: 0.2.34.php プロジェクト: BackupTheBerlios/oos-svn
 static function update()
 {
     // force regeneration of cache files following #648
     Piwik::setUserIsSuperUser();
     $allSiteIds = Piwik_SitesManager_API::getAllSitesId();
     Piwik_Common::regenerateCacheWebsiteAttributes($allSiteIds);
 }
コード例 #28
0
ファイル: CacheFile.php プロジェクト: klando/pgpiwik
 /**
  * A function to store content a cache entry.
  *
  * @param string $id The filename where cache entry is stored
  * @param array $content  The cache content
  * @return bool True if the entry was succesfully stored
  */
 function set($id, $content)
 {
     if (!is_dir($this->cachePath)) {
         Piwik_Common::mkdir($this->cachePath);
     }
     if (!is_writable($this->cachePath)) {
         return false;
     }
     $id = $this->cachePath . $id . ".php";
     $cache_literal = "<" . "?php\n\n";
     $cache_literal .= "\$" . "content   = " . var_export($content, true) . ";\n\n";
     $cache_literal .= "\$" . "cache_complete   = true;\n\n";
     $cache_literal .= "?" . ">";
     // Write cache to a temp file, then rename it, overwritng the old cache
     // On *nix systems this should guarantee atomicity
     $tmp_filename = tempnam($this->cachePath, 'tmp_');
     if ($fp = @fopen($tmp_filename, 'wb')) {
         @fwrite($fp, $cache_literal, strlen($cache_literal));
         @fclose($fp);
         if (!@rename($tmp_filename, $id)) {
             // On some systems rename() doesn't overwrite destination
             @unlink($id);
             if (!@rename($tmp_filename, $id)) {
                 // Make sure that no temporary file is left over
                 // if the destination is not writable
                 @unlink($tmp_filename);
             }
         }
         return true;
     }
     return false;
 }
コード例 #29
0
ファイル: 1.5-b4.php プロジェクト: BackupTheBerlios/oos-svn
	static function getSql($schema = 'Myisam')
	{
		return array(
			'ALTER TABLE `'. Piwik_Common::prefixTable('site') .'`
				 ADD ecommerce TINYINT DEFAULT 0' => false,
		);
	}
コード例 #30
0
ファイル: Rss.php プロジェクト: nnnnathann/piwik
 /**
  * Computes the output for the given data table
  *
  * @param Piwik_DataTable  $table
  * @return string
  * @throws Exception
  */
 protected function renderTable($table)
 {
     if (!$table instanceof Piwik_DataTable_Array || $table->getKeyName() != 'date') {
         throw new Exception("RSS feeds can be generated for one specific website &idSite=X." . "\nPlease specify only one idSite or consider using &format=XML instead.");
     }
     $idSite = Piwik_Common::getRequestVar('idSite', 1, 'int');
     $period = Piwik_Common::getRequestVar('period');
     $piwikUrl = Piwik_Url::getCurrentUrlWithoutFileName() . "?module=CoreHome&action=index&idSite=" . $idSite . "&period=" . $period;
     $out = "";
     $moreRecentFirst = array_reverse($table->getArray(), true);
     foreach ($moreRecentFirst as $date => $subtable) {
         $timestamp = $table->metadata[$date]['timestamp'];
         $site = $table->metadata[$date]['site'];
         $pudDate = date('r', $timestamp);
         $dateInSiteTimezone = Piwik_Date::factory($timestamp)->setTimezone($site->getTimezone())->toString('Y-m-d');
         $thisPiwikUrl = Piwik_Common::sanitizeInputValue($piwikUrl . "&date={$dateInSiteTimezone}");
         $siteName = $site->getName();
         $title = $siteName . " on " . $date;
         $out .= "\t<item>\n\t\t<pubDate>{$pudDate}</pubDate>\n\t\t<guid>{$thisPiwikUrl}</guid>\n\t\t<link>{$thisPiwikUrl}</link>\n\t\t<title>{$title}</title>\n\t\t<author>http://piwik.org</author>\n\t\t<description>";
         $out .= Piwik_Common::sanitizeInputValue($this->renderDataTable($subtable));
         $out .= "</description>\n\t</item>\n";
     }
     $header = $this->getRssHeader();
     $footer = $this->getRssFooter();
     return $header . $out . $footer;
 }