/** * 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('*****@*****.**', '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(); }
function activate() { Piwik::checkUserIsSuperUser(); $pluginName = Piwik_Common::getRequestVar('pluginName', null, 'string'); Piwik_PluginsManager::getInstance()->activatePlugin($pluginName); Piwik_Url::redirectToUrl('index.php?module=CorePluginsAdmin'); }
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 ); }
function addMenu() { Piwik_AddAdminMenu('SitesManager_MenuSites', array('module' => 'SitesManager', 'action' => 'index'), Piwik::isUserHasSomeAdminAccess(), $order = 5); }
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 = '******'; $defaultTokenAuth = 'anonymous'; if($authCookie->isCookieFound()) { $defaultLogin = $authCookie->get('login'); $defaultTokenAuth = $authCookie->get('token_auth'); } $auth->setLogin($defaultLogin); $auth->setTokenAuth($defaultTokenAuth); }
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; } }
/** * 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); } }
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; }
/** * 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; }
function addMenu() { Piwik_AddAdminMenu('CorePluginsAdmin_MenuPlugins', array('module' => 'CorePluginsAdmin', 'action' => 'index'), Piwik::isUserIsSuperUser(), $order = 7); }
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()); }
/** * 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; }
protected function getNumeric( $idSite, $period, $date, $toFetch ) { Piwik::checkUserHasViewAccess( $idSite ); $archive = Piwik_Archive::build($idSite, $period, $date ); $dataTable = $archive->getNumeric($toFetch); return $dataTable; }
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(); }
/** 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; }
public function setUp() { parent::setUp(); Piwik::createConfigObject(); Piwik_Config::getInstance()->setTestEnvironment(); Piwik_DataTable_Manager::getInstance()->deleteAll(); }
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; }
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; }
/** * 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; }
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; }
static function update() { if(Piwik::isTimezoneSupportEnabled()) { Piwik_Updater::updateDatabase(__FILE__, self::getSql()); } }
protected function setGeneralVariablesView($view) { // date $view->date = $this->strDate; $oDate = new Piwik_Date($this->strDate); $view->prettyDate = $oDate->getLocalized(Piwik_Translate('Home_LocalizedDateFormat')); // period $currentPeriod = Piwik_Common::getRequestVar('period'); $otherPeriodsAvailable = array('day', 'week', 'month', 'year'); $otherPeriodsNames = array('day' => Piwik_Translate('Home_PeriodDay'), 'week' => Piwik_Translate('Home_PeriodWeek'), 'month' => Piwik_Translate('Home_PeriodMonth'), 'year' => Piwik_Translate('Home_PeriodYear')); $found = array_search($currentPeriod, $otherPeriodsAvailable); if ($found !== false) { unset($otherPeriodsAvailable[$found]); } $view->period = $currentPeriod; $view->otherPeriods = $otherPeriodsAvailable; $view->periodsNames = $otherPeriodsNames; // other $view->idSite = Piwik_Common::getRequestVar('idSite'); $view->userLogin = Piwik::getCurrentUserLogin(); $view->sites = Piwik_SitesManager_API::getSitesWithAtLeastViewAccess(); $view->url = Piwik_Url::getCurrentUrl(); $view->menu = Piwik_GetMenu(); $view->menuJson = json_encode($view->menu); //var_dump($view->menuJson); }
/** * 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(); }
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>"); }
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(); }
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); }
static function update() { // force regeneration of cache files following #648 Piwik::setUserIsSuperUser(); $allSiteIds = Piwik_SitesManager_API::getAllSitesId(); Piwik_Common::regenerateCacheWebsiteAttributes($allSiteIds); }
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; }
static function update() { $sqlarray = array( 'ALTER TABLE `'. Piwik::prefixTable('log_visit') .'` ADD `visit_goal_converted` VARCHAR( 1 ) NOT NULL AFTER `visit_total_time`' => false, // 0.2.27 [826] 'ALTER IGNORE TABLE `'. Piwik::prefixTable('log_visit') .'` CHANGE `visit_goal_converted` `visit_goal_converted` TINYINT(1) NOT NULL' => false, ); $tables = Piwik::getTablesCreateSql(); $sqlarray[ $tables['log_conversion'] ] = false; $sqlarray[ $tables['goal'] ] = 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; } } Piwik_Updater::updateDatabase(__FILE__, $sqlarray); }
static function update() { Piwik_Updater::updateDatabase(__FILE__, array( 'ALTER TABLE `'. Piwik::prefixTable('user_dashboard') .'` CHANGE `layout` `layout` TEXT NOT NULL' => false, )); }