本文整理汇总了PHP中Piwik::setMaxExecutionTime方法的典型用法代码示例。如果您正苦于以下问题:PHP Piwik::setMaxExecutionTime方法的具体用法?PHP Piwik::setMaxExecutionTime怎么用?PHP Piwik::setMaxExecutionTime使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Piwik
的用法示例。
在下文中一共展示了Piwik::setMaxExecutionTime方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
public function init()
{
require_once "config_test.php";
require_once SIMPLE_TEST . 'unit_tester.php';
require_once SIMPLE_TEST . 'reporter.php';
flush();
Piwik::createConfigObject();
Piwik_Config::getInstance()->setTestEnvironment();
Piwik::setMaxExecutionTime(300);
}
示例2: generate
public function generate()
{
Piwik::checkUserIsSuperUser();
$nonce = Piwik_Common::getRequestVar('form_nonce', '', 'string', $_POST);
if(Piwik_Common::getRequestVar('choice', 'no') != 'yes' ||
!Piwik_Nonce::verifyNonce('Piwik_VisitorGenerator.generate', $nonce))
{
Piwik::redirectToModule('VisitorGenerator', 'index');
}
Piwik_Nonce::discardNonce('Piwik_VisitorGenerator.generate');
$daysToCompute = Piwik_Common::getRequestVar('daysToCompute', 1, 'int');
// get idSite from POST with fallback to GET
$idSite = Piwik_Common::getRequestVar('idSite', false, 'int', $_GET);
$idSite = Piwik_Common::getRequestVar('idSite', $idSite, 'int', $_POST);
Piwik::setMaxExecutionTime(0);
$timer = new Piwik_Timer;
$time = time() - ($daysToCompute-1)*86400;
// Update site.ts_created if we generate visits on days before the website was created
$site = new Piwik_Site($idSite);
$minGeneratedDate = Piwik_Date::factory($time);
if($minGeneratedDate->isEarlier($site->getCreationDate()))
{
// direct access to the website table (bad practise but this is a debug / dev plugin)
Zend_Registry::get('db')->update(Piwik_Common::prefixTable("site"),
array('ts_created' => $minGeneratedDate->getDatetime()),
"idsite = $idSite");
}
$nbActionsTotal = 0;
while($time <= time())
{
$nbActionsTotalThisDay = $this->generateVisits($time, $idSite);
$time += 86400;
$nbActionsTotal += $nbActionsTotalThisDay;
}
// Init view
$view = Piwik_View::factory('generate');
$this->setBasicVariablesView($view);
$view->menu = Piwik_GetAdminMenu();
$view->assign('timer', $timer);
$view->assign('days', $daysToCompute);
$view->assign('nbActionsTotal', $nbActionsTotal);
$view->assign('nbRequestsPerSec', round($nbActionsTotal / $timer->getTime(),0));
echo $view->render();
}
示例3: fetchRemoteFile
/**
* Fetch the file at $url in the destination $destinationPath
*
* @param string $url
* @param string $destinationPath
* @param int $tries
* @throws Exception
* @return bool true on success, throws Exception on failure
*/
public static function fetchRemoteFile($url, $destinationPath = null, $tries = 0)
{
@ignore_user_abort(true);
Piwik::setMaxExecutionTime(0);
return self::sendHttpRequest($url, 10, 'Update', $destinationPath, $tries);
}
示例4: define
if (!defined('PIWIK_INCLUDE_PATH')) {
define('PIWIK_INCLUDE_PATH', '..');
}
ignore_user_abort(true);
if (!defined('PIWIK_INCLUDE_SEARCH_PATH')) {
define('PIWIK_INCLUDE_SEARCH_PATH', PIWIK_INCLUDE_PATH . '/core' . PATH_SEPARATOR . PIWIK_INCLUDE_PATH . '/libs' . PATH_SEPARATOR . PIWIK_INCLUDE_PATH . '/plugins');
@ini_set('include_path', PIWIK_INCLUDE_SEARCH_PATH);
@set_include_path(PIWIK_INCLUDE_SEARCH_PATH);
}
$GLOBALS['PIWIK_TRACKER_DEBUG'] = false;
ob_start();
// first check that user has privileges to create some random data in the DB -> he must be super user
define('PIWIK_ENABLE_DISPATCH', false);
require_once PIWIK_INCLUDE_PATH . "/index.php";
require_once "FrontController.php";
Piwik::setMaxExecutionTime(0);
$idSite = Piwik_Common::getRequestVar('idSite', 1, 'int');
try {
Piwik_FrontController::getInstance()->init();
} catch (Exception $e) {
echo $e->getMessage();
exit;
}
Piwik::checkUserIsSuperUser();
require_once "PluginsManager.php";
require_once "Tracker.php";
//Piwik_PluginsManager::getInstance()->unloadPlugins();
// we have to unload the Provider plugin otherwise it tries to lookup the IP for ahostname, and there is no dns server here
if (Piwik_PluginsManager::getInstance()->isPluginActivated('Provider')) {
Piwik_PluginsManager::getInstance()->unloadPlugin('Provider');
}
示例5: runUpdaterAndExit
public function runUpdaterAndExit($updater, $componentsWithUpdateFile)
{
if (empty($componentsWithUpdateFile)) {
return;
}
if (Piwik::isPhpCliMode()) {
Piwik::setMaxExecutionTime(0);
$view = Piwik_View::factory('update_welcome');
$this->doWelcomeUpdates($view, $componentsWithUpdateFile);
if (!$this->coreError) {
$view = Piwik_View::factory('update_database_done');
$this->doExecuteUpdates($view, $updater, $componentsWithUpdateFile);
}
} else {
if (Piwik_Common::getRequestVar('updateCorePlugins', 0, 'integer') == 1) {
$view = Piwik_View::factory('update_database_done');
$this->doExecuteUpdates($view, $updater, $componentsWithUpdateFile);
} else {
$view = Piwik_View::factory('update_welcome');
$this->doWelcomeUpdates($view, $componentsWithUpdateFile);
}
}
exit;
}
示例6: generate
public function generate()
{
// Only admin is allowed to do this!
Piwik::checkUserIsSuperUser();
$GET = $_GET;
$POST = $_POST;
$COOKIE = $_COOKIE;
$REQUEST = $_REQUEST;
$nonce = Piwik_Common::getRequestVar('form_nonce', '', 'string', $_POST);
if (Piwik_Common::getRequestVar('choice', 'no') != 'yes' || !Piwik_Nonce::verifyNonce('Piwik_VisitorGenerator.generate', $nonce)) {
Piwik::redirectToModule('VisitorGenerator', 'index');
}
Piwik_Nonce::discardNonce('Piwik_VisitorGenerator.generate');
$minVisitors = Piwik_Common::getRequestVar('minVisitors', 20, 'int');
$maxVisitors = Piwik_Common::getRequestVar('maxVisitors', 100, 'int');
$nbActions = Piwik_Common::getRequestVar('nbActions', 10, 'int');
$daysToCompute = Piwik_Common::getRequestVar('daysToCompute', 1, 'int');
// get idSite from POST with fallback to GET
$idSite = Piwik_Common::getRequestVar('idSite', false, 'int', $_GET);
$idSite = Piwik_Common::getRequestVar('idSite', $idSite, 'int', $_POST);
Piwik::setMaxExecutionTime(0);
$loadedPlugins = Piwik_PluginsManager::getInstance()->getLoadedPlugins();
$loadedPlugins = array_keys($loadedPlugins);
// we have to unload the Provider plugin otherwise it tries to lookup the IP for a hostname, and there is no dns server here
if (Piwik_PluginsManager::getInstance()->isPluginActivated('Provider')) {
Piwik_PluginsManager::getInstance()->unloadPlugin('Provider');
}
// we set the DO NOT load plugins so that the Tracker generator doesn't load the plugins we've just disabled.
// if for some reasons you want to load the plugins, comment this line, and disable the plugin Provider in the plugins interface
Piwik_PluginsManager::getInstance()->doNotLoadPlugins();
$generator = new Piwik_VisitorGenerator_Generator();
$generator->setMaximumUrlDepth(3);
//$generator->disableProfiler();
$generator->setIdSite($idSite);
$nbActionsTotal = 0;
//$generator->emptyAllLogTables();
$generator->init();
$timer = new Piwik_Timer();
$startTime = time() - ($daysToCompute - 1) * 86400;
// Update site.ts_created if we generate visits on days before the website was created
$site = new Piwik_Site($idSite);
$minGeneratedDate = Piwik_Date::factory($startTime);
if ($minGeneratedDate->isEarlier($site->getCreationDate())) {
// direct access to the website table (bad practise but this is a debug / dev plugin)
Zend_Registry::get('db')->update(Piwik_Common::prefixTable("site"), array('ts_created' => $minGeneratedDate->getDatetime()), "idsite = {$idSite}");
}
$dates = array();
while ($startTime <= time()) {
$visitors = rand($minVisitors, $maxVisitors);
$actions = $nbActions;
$generator->setTimestampToUse($startTime);
$nbActionsTotalThisDay = $generator->generate($visitors, $actions);
$actionsPerVisit = round($nbActionsTotalThisDay / $visitors);
$date = array();
$date['visitors'] = $visitors;
$date['actionsPerVisit'] = $actionsPerVisit;
$date['startTime'] = $startTime;
$dates[] = $date;
$startTime += 86400;
$nbActionsTotal += $nbActionsTotalThisDay;
//sleep(1);
}
$generator->end();
// Recover all super globals
$_GET = $GET;
$_POST = $POST;
$_COOKIE = $COOKIE;
$_REQUEST = $REQUEST;
// Reload plugins
Piwik_PluginsManager::getInstance()->loadPlugins($loadedPlugins);
// Init view
$view = Piwik_View::factory('generate');
$this->setBasicVariablesView($view);
$view->menu = Piwik_GetAdminMenu();
$view->assign('dates', $dates);
$view->assign('timer', $timer);
$view->assign('nbActionsTotal', $nbActionsTotal);
$view->assign('nbRequestsPerSec', round($nbActionsTotal / $timer->getTime(), 0));
echo $view->render();
}
示例7: runUpdaterAndExit
protected function runUpdaterAndExit()
{
$updater = new Piwik_Updater();
$componentsWithUpdateFile = Piwik_CoreUpdater::getComponentUpdates($updater);
if (empty($componentsWithUpdateFile)) {
Piwik::redirectToModule('CoreHome');
}
Piwik::setMaxExecutionTime(0);
$sqlQueries = $updater->getSqlQueriesToExecute();
if (Piwik_Common::isPhpCliMode()) {
$view = Piwik_View::factory('update_welcome');
$this->doWelcomeUpdates($view, $componentsWithUpdateFile);
if (!$this->coreError) {
$view = Piwik_View::factory('update_database_done');
$this->doExecuteUpdates($view, $updater, $componentsWithUpdateFile);
}
} else {
if (Piwik_Common::getRequestVar('updateCorePlugins', 0, 'integer') == 1 || count($sqlQueries) == 1) {
$this->warningMessages = array();
$view = Piwik_View::factory('update_database_done');
$this->doExecuteUpdates($view, $updater, $componentsWithUpdateFile);
} else {
$view = Piwik_View::factory('update_welcome');
$view->queries = $sqlQueries;
$this->doWelcomeUpdates($view, $componentsWithUpdateFile);
}
}
exit;
}