本文整理汇总了PHP中Piwik类的典型用法代码示例。如果您正苦于以下问题:PHP Piwik类的具体用法?PHP Piwik怎么用?PHP Piwik使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Piwik类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: 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('[email protected]', '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();
}
开发者ID:BackupTheBerlios,项目名称:oos-svn,代码行数:31,代码来源:Controller.php
示例2: activate
function activate()
{
Piwik::checkUserIsSuperUser();
$pluginName = Piwik_Common::getRequestVar('pluginName', null, 'string');
Piwik_PluginsManager::getInstance()->activatePlugin($pluginName);
Piwik_Url::redirectToUrl('index.php?module=CorePluginsAdmin');
}
开发者ID:BackupTheBerlios,项目名称:oos-svn,代码行数:7,代码来源:Controller.php
示例3: authenticate
public function authenticate()
{
$rootLogin = Zend_Registry::get('config')->superuser->login;
$rootPassword = Zend_Registry::get('config')->superuser->password;
$rootToken = Piwik_UsersManager_API::getTokenAuth($rootLogin, $rootPassword);
if($this->login == $rootLogin
&& $this->token_auth == $rootToken)
{
return new Piwik_Auth_Result(Piwik_Auth_Result::SUCCESS_SUPERUSER_AUTH_CODE, $this->login, $this->token_auth );
}
if($this->token_auth === $rootToken)
{
return new Piwik_Auth_Result(Piwik_Auth_Result::SUCCESS_SUPERUSER_AUTH_CODE, $rootLogin, $rootToken );
}
$login = Piwik_FetchOne(
'SELECT login FROM '.Piwik::prefixTable('user').' WHERE token_auth = ?',
array($this->token_auth)
);
if($login !== false)
{
if(is_null($this->login)
|| $this->login == $login)
{
return new Piwik_Auth_Result(Piwik_Auth_Result::SUCCESS, $login, $this->token_auth );
}
}
return new Piwik_Auth_Result( Piwik_Auth_Result::FAILURE, $this->login, $this->token_auth );
}
开发者ID:BackupTheBerlios,项目名称:oos-svn,代码行数:31,代码来源:Auth.php
示例4: addMenu
function addMenu()
{
Piwik_AddAdminMenu('SitesManager_MenuSites',
array('module' => 'SitesManager', 'action' => 'index'),
Piwik::isUserHasSomeAdminAccess(),
$order = 5);
}
开发者ID:BackupTheBerlios,项目名称:oos-svn,代码行数:7,代码来源:SitesManager.php
示例5: initAuthenticationObject
function initAuthenticationObject($notification)
{
$auth = new Piwik_Login_Auth();
Zend_Registry::set('auth', $auth);
$action = Piwik::getAction();
if(Piwik::getModule() === 'API'
&& (empty($action) || $action == 'index'))
{
return;
}
$authCookieName = Zend_Registry::get('config')->General->login_cookie_name;
$authCookieExpiry = time() + Zend_Registry::get('config')->General->login_cookie_expire;
$authCookie = new Piwik_Cookie($authCookieName, $authCookieExpiry);
$defaultLogin = 'anonymous';
$defaultTokenAuth = 'anonymous';
if($authCookie->isCookieFound())
{
$defaultLogin = $authCookie->get('login');
$defaultTokenAuth = $authCookie->get('token_auth');
}
$auth->setLogin($defaultLogin);
$auth->setTokenAuth($defaultTokenAuth);
}
开发者ID:BackupTheBerlios,项目名称:oos-svn,代码行数:25,代码来源:Login.php
示例6: checkTableExists
protected function checkTableExists()
{
if(is_null(self::$tablesAlreadyInstalled))
{
self::$tablesAlreadyInstalled = Piwik::getTablesInstalled($forceReload = false);
}
if(!in_array($this->generatedTableName, self::$tablesAlreadyInstalled))
{
$db = Zend_Registry::get('db');
$sql = Piwik::getTableCreateSql($this->tableName);
$config = Zend_Registry::get('config');
$prefixTables = $config->database->tables_prefix;
$sql = str_replace( $prefixTables . $this->tableName, $this->generatedTableName, $sql);
try {
$db->query( $sql );
} catch(Exception $e) {
// mysql error 1050: table already exists
if(! $db->isErrNo($e, '1050'))
{
// failed for some other reason
throw $e;
}
}
self::$tablesAlreadyInstalled[] = $this->generatedTableName;
}
}
开发者ID:BackupTheBerlios,项目名称:oos-svn,代码行数:29,代码来源:TablePartitioning.php
示例7: check
/**
* 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);
}
}
开发者ID:BackupTheBerlios,项目名称:oos-svn,代码行数:28,代码来源:UpdateCheck.php
示例8: setGeneralSettings
public function setGeneralSettings()
{
Piwik::checkUserIsSuperUser();
$response = new Piwik_API_ResponseBuilder(Piwik_Common::getRequestVar('format'));
try {
$this->checkTokenInUrl();
$enableBrowserTriggerArchiving = Piwik_Common::getRequestVar('enableBrowserTriggerArchiving');
$todayArchiveTimeToLive = Piwik_Common::getRequestVar('todayArchiveTimeToLive');
Piwik_ArchiveProcessing::setBrowserTriggerArchiving((bool) $enableBrowserTriggerArchiving);
Piwik_ArchiveProcessing::setTodayArchiveTimeToLive($todayArchiveTimeToLive);
// Update email settings
$mail = Zend_Registry::get('config')->mail;
$mail->transport = Piwik_Common::getRequestVar('mailUseSmtp') == '1' ? 'smtp' : '';
$mail->port = Piwik_Common::getRequestVar('mailPort', '');
$mail->host = Piwik_Common::getRequestVar('mailHost', '');
$mail->type = Piwik_Common::getRequestVar('mailType', '');
$mail->username = Piwik_Common::getRequestVar('mailUsername', '');
$mail->password = Piwik_Common::getRequestVar('mailPassword', '');
$mail->encryption = Piwik_Common::getRequestVar('mailEncryption', '');
Zend_Registry::get('config')->mail = $mail->toArray();
$toReturn = $response->getResponse();
} catch (Exception $e) {
$toReturn = $response->getResponseException($e);
}
echo $toReturn;
}
开发者ID:Gninety,项目名称:Microweber,代码行数:26,代码来源:Controller.php
示例9: Piwik_ExitWithMessage
/**
* Displays info/warning/error message in a friendly UI and exits.
*
* @param string $message Main message
* @param string|false $optionalTrace Backtrace; will be displayed in lighter color
* @param bool $optionalLinks If true, will show links to the Piwik website for help
*/
function Piwik_ExitWithMessage($message, $optionalTrace = false, $optionalLinks = false)
{
@header('Content-Type: text/html; charset=utf-8');
if ($optionalTrace) {
$optionalTrace = '<font color="#888888">Backtrace:<br /><pre>' . $optionalTrace . '</pre></font>';
}
if ($optionalLinks) {
$optionalLinks = '<ul>
<li><a target="_blank" href="?module=Proxy&action=redirect&url=http://piwik.org">Piwik.org homepage</a></li>
<li><a target="_blank" href="?module=Proxy&action=redirect&url=http://piwik.org/faq/">Piwik Frequently Asked Questions</a></li>
<li><a target="_blank" href="?module=Proxy&action=redirect&url=http://piwik.org/docs/">Piwik Documentation</a></li>
<li><a target="_blank" href="?module=Proxy&action=redirect&url=http://forum.piwik.org/">Piwik Forums</a></li>
<li><a target="_blank" href="?module=Proxy&action=redirect&url=http://demo.piwik.org">Piwik Online Demo</a></li>
</ul>';
}
$headerPage = file_get_contents(PIWIK_INCLUDE_PATH . '/themes/default/simple_structure_header.tpl');
$footerPage = file_get_contents(PIWIK_INCLUDE_PATH . '/themes/default/simple_structure_footer.tpl');
try {
// This can fail
$loginName = Piwik::getLoginPluginName();
} catch (Exception $e) {
$loginName = 'Login';
}
$headerPage = str_replace('{$HTML_TITLE}', 'Piwik › Error', $headerPage);
$content = '<p>' . $message . '</p>
<p><a href="index.php">Go to Piwik</a><br/>
<a href="index.php?module=' . $loginName . '">Login</a></p>
' . $optionalTrace . ' ' . $optionalLinks;
echo $headerPage . $content . $footerPage;
exit;
}
开发者ID:Gninety,项目名称:Microweber,代码行数:38,代码来源:testMinimumPhpVersion.php
示例10: addMenu
function addMenu()
{
Piwik_AddAdminMenu('CorePluginsAdmin_MenuPlugins',
array('module' => 'CorePluginsAdmin', 'action' => 'index'),
Piwik::isUserIsSuperUser(),
$order = 7);
}
开发者ID:BackupTheBerlios,项目名称:oos-svn,代码行数:7,代码来源:CorePluginsAdmin.php
示例11: update
static function update()
{
$config = Zend_Registry::get('config');
$dbInfos = $config->database->toArray();
if(!isset($dbInfos['schema']))
{
try {
if(is_writable( Piwik_Config::getDefaultUserConfigPath() ))
{
$dbInfos['schema'] = 'Myisam';
$config->database = $dbInfos;
$config->__destruct();
Piwik::createConfigObject();
}
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>[database]</code> the following line: <br /><code>schema = Myisam</code>");
}
}
Piwik_Updater::updateDatabase(__FILE__, self::getSql());
}
开发者ID:BackupTheBerlios,项目名称:oos-svn,代码行数:26,代码来源:0.6.3.php
示例12: get
/**
* Returns the list of metrics (pages, downloads, outlinks)
*
* @param int $idSite
* @param string $period
* @param string $date
* @param string $segment
*/
public function get($idSite, $period, $date, $segment = false, $columns = false)
{
Piwik::checkUserHasViewAccess($idSite);
$archive = Piwik_Archive::build($idSite, $period, $date, $segment);
$metrics = array('Actions_nb_pageviews' => 'nb_pageviews', 'Actions_nb_uniq_pageviews' => 'nb_uniq_pageviews', 'Actions_nb_downloads' => 'nb_downloads', 'Actions_nb_uniq_downloads' => 'nb_uniq_downloads', 'Actions_nb_outlinks' => 'nb_outlinks', 'Actions_nb_uniq_outlinks' => 'nb_uniq_outlinks');
// get requested columns
$columns = Piwik::getArrayFromApiParameter($columns);
if (!empty($columns)) {
// get the columns that are available and requested
$columns = array_intersect($columns, array_values($metrics));
$columns = array_values($columns);
// make sure indexes are right
$nameReplace = array();
foreach ($columns as $i => $column) {
$fullColumn = array_search($column, $metrics);
$columns[$i] = $fullColumn;
$nameReplace[$fullColumn] = $column;
}
} else {
// get all columns
$columns = array_keys($metrics);
$nameReplace =& $metrics;
}
$table = $archive->getDataTableFromNumeric($columns);
// replace labels (remove Actions_)
$table->filter('ReplaceColumnNames', array($nameReplace));
return $table;
}
开发者ID:0h546f6f78696342756e4e59,项目名称:piwik,代码行数:36,代码来源:API.php
示例13: getNumeric
protected function getNumeric( $idSite, $period, $date, $toFetch )
{
Piwik::checkUserHasViewAccess( $idSite );
$archive = Piwik_Archive::build($idSite, $period, $date );
$dataTable = $archive->getNumeric($toFetch);
return $dataTable;
}
开发者ID:BackupTheBerlios,项目名称:oos-svn,代码行数:7,代码来源:API.php
示例14: authenticate
public function authenticate()
{
// we first try if the user is the super user
$rootLogin = Zend_Registry::get('config')->superuser->login;
$rootPassword = Zend_Registry::get('config')->superuser->password;
$rootToken = Piwik_UsersManager_API::getTokenAuth($rootLogin, $rootPassword);
// echo $rootToken;
// echo "<br>". $this->_credential;exit;
if ($this->_identity == $rootLogin && $this->_credential == $rootToken) {
return new Piwik_Auth_Result(Piwik_Auth::SUCCESS_SUPERUSER_AUTH_CODE, $this->_identity, array());
}
// we then look if the user is API authenticated
// API authentication works without login name, but only with the token
// TODO the logic (sql select) should be in the Login plugin, not here
// this class should stay simple. Another Login plugin should only have to create an auth entry
// of this class in the zend_registry and it should work
if (is_null($this->_identity)) {
$authenticated = false;
if ($this->_credential === $rootToken) {
return new Piwik_Auth_Result(Piwik_Auth::SUCCESS_SUPERUSER_AUTH_CODE, $rootLogin, array());
}
$login = Zend_Registry::get('db')->fetchOne('SELECT login FROM ' . Piwik::prefixTable('user') . ' WHERE token_auth = ?', array($this->_credential));
if ($login !== false) {
return new Piwik_Auth_Result(Zend_Auth_Result::SUCCESS, $login, array());
} else {
return new Piwik_Auth_Result(Zend_Auth_Result::FAILURE, $this->_identity, array());
}
}
// if not then we return the result of the database authentification provided by zend
return parent::authenticate();
}
开发者ID:Doluci,项目名称:tomatocart,代码行数:31,代码来源:Auth.php
示例15: getDataTable
/** Get data table from archive
* @return Piwik_DataTable */
public static function getDataTable($name, $idsite, $period, $date, $numeric = false)
{
Piwik::checkUserHasViewAccess($idsite);
if (is_array($name)) {
foreach ($name as &$col) {
$col = 'SiteSearch_' . $col;
}
} else {
$name = 'SiteSearch_' . $name;
}
if (!is_string($period) && get_class($period) != 'Piwik_Period_Range') {
$periodMap = array('Piwik_Period_Day' => 'day', 'Piwik_Period_Week' => 'week', 'Piwik_Period_Month' => 'month', 'Piwik_Period_Year' => 'year');
$period = $periodMap[get_class($period)];
}
$archive = Piwik_Archive::build($idsite, $period, $date);
if ($numeric) {
// numeric archives are only used for search evolution
$dataTable = $archive->getDataTableFromNumeric($name);
$dataTable->queueFilter('ReplaceColumnNames', array(array('SiteSearch_totalSearches' => self::HITS, 'SiteSearch_visitsWithSearches' => self::UNIQUE_HITS)));
$dataTable->applyQueuedFilters();
} else {
$dataTable = $archive->getDataTable($name);
}
return $dataTable;
}
开发者ID:BeezyT,项目名称:piwik-sitesearch,代码行数:27,代码来源:Archive.php
示例16: setUp
public function setUp()
{
parent::setUp();
Piwik::createConfigObject();
Piwik_Config::getInstance()->setTestEnvironment();
Piwik_DataTable_Manager::getInstance()->deleteAll();
}
开发者ID:nnnnathann,项目名称:piwik,代码行数:7,代码来源:Array.test.php
示例17: getSql
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;
}
开发者ID:nnnnathann,项目名称:piwik,代码行数:34,代码来源:0.2.27.php
示例18: getAllTablesStatus
public static function getAllTablesStatus()
{
Piwik::checkUserIsSuperUser();
$db = Zend_Registry::get('db');
// http://dev.mysql.com/doc/refman/5.1/en/show-table-status.html
$tablesPiwik = Piwik::getTablesInstalled();
$total = array('Name' => 'Total', 'Data_length' => 0, 'Index_length' => 0, 'Rows' => 0);
$table = array();
foreach ($tablesPiwik as $tableName) {
$t = self::getTableStatus($tableName);
$total['Data_length'] += $t['Data_length'];
$total['Index_length'] += $t['Index_length'];
$total['Rows'] += $t['Rows'];
$t['Total_length'] = Piwik::getPrettySizeFromBytes($t['Index_length'] + $t['Data_length']);
$t['Data_length'] = Piwik::getPrettySizeFromBytes($t['Data_length']);
$t['Index_length'] = Piwik::getPrettySizeFromBytes($t['Index_length']);
$t['Rows'] = Piwik::getPrettySizeFromBytes($t['Rows']);
$table[] = $t;
}
$total['Total_length'] = Piwik::getPrettySizeFromBytes($total['Data_length'] + $total['Index_length']);
$total['Data_length'] = Piwik::getPrettySizeFromBytes($total['Data_length']);
$total['Index_length'] = Piwik::getPrettySizeFromBytes($total['Index_length']);
$total['TotalRows'] = Piwik::getPrettySizeFromBytes($total['Rows']);
$table['Total'] = $total;
return $table;
}
开发者ID:BackupTheBerlios,项目名称:oos-svn,代码行数:26,代码来源:API.php
示例19: getCacheWebsiteAttributes
/**
* Returns array containing data about the website: goals, URLs, etc.
*
* @param int $idSite
* @return array
*/
static function getCacheWebsiteAttributes($idSite)
{
require_once PIWIK_INCLUDE_PATH . '/core/Loader.php';
static $cache = null;
if (is_null($cache)) {
$cache = new Piwik_CacheFile('tracker');
}
$filename = $idSite;
$cacheContent = $cache->get($filename);
if ($cacheContent !== false) {
return $cacheContent;
}
if (defined('PIWIK_TRACKER_MODE') && PIWIK_TRACKER_MODE) {
require_once PIWIK_INCLUDE_PATH . '/core/PluginsManager.php';
require_once PIWIK_INCLUDE_PATH . '/core/Translate.php';
require_once PIWIK_INCLUDE_PATH . '/core/Option.php';
Zend_Registry::set('db', Piwik_Tracker::getDatabase());
Piwik::createAccessObject();
Piwik::createConfigObject();
Piwik::setUserIsSuperUser();
$pluginsManager = Piwik_PluginsManager::getInstance();
$pluginsManager->setPluginsToLoad(Zend_Registry::get('config')->Plugins->Plugins->toArray());
}
$content = array();
Piwik_PostEvent('Common.fetchWebsiteAttributes', $content, $idSite);
// if nothing is returned from the plugins, we don't save the content
// this is not expected: all websites are expected to have at least one URL
if (!empty($content)) {
$cache->set($filename, $content);
}
return $content;
}
开发者ID:BackupTheBerlios,项目名称:oos-svn,代码行数:38,代码来源:Common.php
示例20: dispatch
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;
}
开发者ID:BackupTheBerlios,项目名称:oos-svn,代码行数:29,代码来源:Installation.php
注:本文中的Piwik类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论