作者:piwi
项目:piwi
public function dispatch()
{
$module = Common::getRequestVar('module', '', 'string');
$action = Common::getRequestVar('action', '', 'string');
if ($module == 'CoreUpdater' || $module == 'Proxy' || $module == 'Installation' || $module == 'LanguagesManager' && $action == 'saveLanguage') {
return;
}
$updater = new PiwikCoreUpdater();
$updates = $updater->getComponentsWithNewVersion(array('core' => Version::VERSION));
if (!empty($updates)) {
Filesystem::deleteAllCacheOnUpdate();
}
if ($updater->getComponentUpdates() !== null) {
if (FrontController::shouldRethrowException()) {
throw new Exception("Piwik and/or some plugins have been upgraded to a new version. \n" . "--> Please run the update process first. See documentation: http://piwik.org/docs/update/ \n");
} elseif ($module === 'API') {
$outputFormat = strtolower(Common::getRequestVar('format', 'xml', 'string', $_GET + $_POST));
$response = new ResponseBuilder($outputFormat);
$e = new Exception('Database Upgrade Required. Your Piwik database is out-of-date, and must be upgraded before you can continue.');
echo $response->getResponseException($e);
Common::sendResponseCode(503);
exit;
} else {
Piwik::redirectToModule('CoreUpdater');
}
}
}
作者:pombredann
项目:ArcherSy
public static function footerUserCountry(&$out)
{
$out = '<div>
<h2>' . Piwik::translate('Provider_WidgetProviders') . '</h2>';
$out .= FrontController::getInstance()->fetchDispatch('Provider', 'getProvider');
$out .= '</div>';
}
作者:bossrabbi
项目:piwi
/**
* Execute command like: ./console core:run-scheduled-tasks
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->forceRunAllTasksIfRequested($input);
FrontController::getInstance()->init();
API::getInstance()->runScheduledTasks();
$this->writeSuccessMessage($output, array('Scheduled Tasks executed'));
}
作者:brienomatt
项目:elmsl
public static function footerVisitsFrequency(&$out)
{
$out = '</div>
<div id="rightcolumn">
';
$out .= FrontController::getInstance()->fetchDispatch('VisitorInterest', 'index');
$out .= '</div>';
}
作者:FluentDevelopmen
项目:piwi
public function getEcommerceLog($fetch = false)
{
$saveGET = $_GET;
$_GET['segment'] = urlencode('visitEcommerceStatus!=none');
$_GET['widget'] = 1;
$output = FrontController::getInstance()->dispatch('Live', 'getVisitorLog', array($fetch));
$_GET = $saveGET;
return $output;
}
作者:CaptainShar
项目:SSAD_Projec
/**
* Redirects to Login form with error message.
* Listens to User.isNotAuthorized hook.
*/
public function noAccess(Exception $exception)
{
$frontController = FrontController::getInstance();
if (Common::isXmlHttpRequest()) {
echo $frontController->dispatch('Login', 'ajaxNoAccess', array($exception->getMessage()));
return;
}
echo $frontController->dispatch('Login', 'login', array($exception->getMessage()));
}
作者:diosmosi
项目:piwi
/**
* Testing that getOne does not error out when format=rss, #10407
*
* @group Plugins
*/
public function testWhenRssFormatGetOneDoesNotError()
{
$_GET = array('method' => 'MultiSites.getOne', 'idSite' => $this->idSiteAccess, 'period' => 'month', 'date' => 'last10', 'format' => 'rss');
$output = FrontController::getInstance()->fetchDispatch('API');
$this->assertContains('<item>', $output);
$this->assertContains('</rss>', $output);
$this->assertNotContains('error', $output);
$_GET = array();
}
作者:dorelljame
项目:piwi
private function requestGetAllWithGroups($params)
{
$oldGet = $_GET;
$params['period'] = 'day';
$params['date'] = '2013-01-23';
$_GET = $params;
$sites = FrontController::getInstance()->dispatch('MultiSites', 'getAllWithGroups');
$_GET = $oldGet;
return $sites;
}
作者:TensorWrenchOS
项目:piwi
/**
* Execute command like: ./console core:run-scheduled-tasks
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->forceRunAllTasksIfRequested($input);
FrontController::getInstance()->init();
$scheduledTasksResults = API::getInstance()->runScheduledTasks();
foreach ($scheduledTasksResults as $scheduledTasksResult) {
$output->writeln(sprintf('<comment>%s</comment> - %s', $scheduledTasksResult['task'], $scheduledTasksResult['output']));
}
$this->writeSuccessMessage($output, array('Scheduled Tasks executed'));
}
作者:bossrabbi
项目:piwi
private function init()
{
$this->handleFatalErrors();
\Piwik\FrontController::createConfigObject();
if ($this->isDebugModeEnabled()) {
ErrorHandler::registerErrorHandler();
ExceptionHandler::setUp();
Common::printDebug("Debug enabled - Input parameters: ");
Common::printDebug(var_export($_GET, true));
}
}
作者:carriercom
项目:piwi
public function showInContext()
{
$controllerName = Common::getRequestVar('moduleToLoad');
$actionName = Common::getRequestVar('actionToLoad', 'index');
if ($actionName == 'showInContext') {
throw new Exception("Preventing infinite recursion...");
}
$view = $this->getDefaultIndexView();
$view->content = FrontController::getInstance()->fetchDispatch($controllerName, $actionName);
return $view->render();
}
作者:a4tunad
项目:piwi
protected function _getDashboardView($template)
{
$view = new View($template);
$this->setGeneralVariablesView($view);
$view->availableWidgets = Common::json_encode(WidgetsList::get());
$view->availableLayouts = $this->getAvailableLayouts();
$view->dashboardId = Common::getRequestVar('idDashboard', 1, 'int');
// get the layout via FrontController so controller events are posted
$view->dashboardLayout = FrontController::getInstance()->dispatch('Dashboard', 'getDashboardLayout', array($checkToken = false));
return $view;
}
作者:diosmosi
项目:piwi
/**
* @param $lastError
* @return mixed|void
* @throws AuthenticationFailedException
* @throws Exception
*/
private static function generateSafeModeOutput($lastError)
{
Common::sendResponseCode(500);
$controller = FrontController::getInstance();
try {
$controller->init();
$message = $controller->dispatch('CorePluginsAdmin', 'safemode', array($lastError));
} catch (Exception $e) {
// may fail in safe mode (eg. global.ini.php not found)
$message = sprintf("Piwik encoutered an error: %s (which lead to: %s)", $lastError['message'], $e->getMessage());
}
return $message;
}
作者:cem
项目:piwi
/**
* @param \Exception|null $exception
*/
public function dispatch($exception = null)
{
if ($exception) {
$message = $exception->getMessage();
} else {
$message = '';
}
$action = Common::getRequestVar('action', 'welcome', 'string');
if ($this->isAllowedAction($action)) {
echo FrontController::getInstance()->dispatch('Installation', $action, array($message));
} else {
Piwik::exitWithErrorMessage(Piwik::translate('Installation_NoConfigFound'));
}
exit;
}
作者:FluentDevelopmen
项目:piwi
/**
* Execute command like: ./console core:run-scheduled-tasks
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->forceRunAllTasksIfRequested($input);
FrontController::getInstance()->init();
// TODO use dependency injection
/** @var Scheduler $scheduler */
$scheduler = StaticContainer::get('Piwik\\Scheduler\\Scheduler');
$task = $input->getArgument('task');
if ($task) {
$this->runSingleTask($scheduler, $task, $output);
} else {
$scheduler->run();
}
$this->writeSuccessMessage($output, array('Scheduled Tasks executed'));
}
作者:a4tunad
项目:piwi
public function iframe()
{
Request::reloadAuthUsingTokenAuth();
$this->init();
$controllerName = Common::getRequestVar('moduleToWidgetize');
$actionName = Common::getRequestVar('actionToWidgetize');
if ($controllerName == 'Dashboard' && $actionName == 'index') {
$view = new View('@Widgetize/iframe_empty');
} else {
$view = new View('@Widgetize/iframe');
}
$this->setGeneralVariablesView($view);
$view->setXFrameOptions('allow');
$view->content = FrontController::getInstance()->fetchDispatch($controllerName, $actionName);
return $view->render();
}
作者:CaptainShar
项目:SSAD_Projec
public function dispatch()
{
$module = Common::getRequestVar('module', '', 'string');
$action = Common::getRequestVar('action', '', 'string');
$updater = new PiwikCoreUpdater();
$updates = $updater->getComponentsWithNewVersion(array('core' => Version::VERSION));
if (!empty($updates)) {
Filesystem::deleteAllCacheOnUpdate();
}
if ($updater->getComponentUpdates() !== null && $module != 'CoreUpdater' && $module != 'Proxy' && $module != 'Installation' && !($module == 'LanguagesManager' && $action == 'saveLanguage')) {
if (FrontController::shouldRethrowException()) {
throw new Exception("Piwik and/or some plugins have been upgraded to a new version. \n" . "--> Please run the update process first. See documentation: http://piwik.org/docs/update/ \n");
} else {
Piwik::redirectToModule('CoreUpdater');
}
}
}
作者:KiwiJuice
项目:handball-dacha
/**
* @param \Exception|null $exception
*/
public function dispatch($exception = null)
{
if ($exception) {
$message = $exception->getMessage();
} else {
$message = '';
}
Translate::loadCoreTranslation();
$step = Common::getRequestVar('action', 'welcome', 'string');
$controller = $this->getInstallationController();
$isActionWhiteListed = in_array($step, array('saveLanguage', 'getBaseCss'));
if (in_array($step, array_keys($controller->getInstallationSteps())) || $isActionWhiteListed) {
echo FrontController::getInstance()->dispatch('Installation', $step, array($message));
} else {
Piwik::exitWithErrorMessage(Piwik::translate('Installation_NoConfigFound'));
}
exit;
}
作者:FluentDevelopmen
项目:piwi
public function iframe()
{
Request::reloadAuthUsingTokenAuth();
$this->init();
$controllerName = Common::getRequestVar('moduleToWidgetize');
$actionName = Common::getRequestVar('actionToWidgetize');
if ($controllerName == 'API') {
throw new \Exception("Widgetizing API requests is not supported for security reasons. Please change query parameter 'moduleToWidgetize'.");
}
if ($controllerName == 'Dashboard' && $actionName == 'index') {
$view = new View('@Widgetize/iframe_empty');
} else {
$view = new View('@Widgetize/iframe');
}
$this->setGeneralVariablesView($view);
$view->setXFrameOptions('allow');
$view->content = FrontController::getInstance()->fetchDispatch($controllerName, $actionName);
return $view->render();
}
作者:DenisMalofeye
项目:WP-Piwi
private function call($id, $url, $params)
{
if (!defined('PIWIK_INCLUDE_PATH')) {
return false;
}
if (PIWIK_INCLUDE_PATH === FALSE) {
return array('result' => 'error', 'message' => __('Could not resolve', 'wp-piwik') . ' "' . htmlentities(self::$settings->getGlobalOption('piwik_path')) . '": ' . __('realpath() returns false', 'wp-piwik') . '.');
}
if (file_exists(PIWIK_INCLUDE_PATH . "/index.php")) {
require_once PIWIK_INCLUDE_PATH . "/index.php";
}
if (file_exists(PIWIK_INCLUDE_PATH . "/core/API/Request.php")) {
require_once PIWIK_INCLUDE_PATH . "/core/API/Request.php";
}
if (class_exists('\\Piwik\\Application\\Environment') && !self::$piwikEnvironment) {
// Piwik 2.14.* compatibility fix
self::$piwikEnvironment = new \Piwik\Application\Environment(null);
self::$piwikEnvironment->init();
}
if (class_exists('Piwik\\FrontController')) {
\Piwik\FrontController::getInstance()->init();
} else {
return array('result' => 'error', 'message' => __('Class Piwik\\FrontController does not exists.', 'wp-piwik'));
}
if (class_exists('Piwik\\API\\Request')) {
$request = new \Piwik\API\Request($params . '&token_auth=' . self::$settings->getGlobalOption('piwik_token'));
} else {
return array('result' => 'error', 'message' => __('Class Piwik\\API\\Request does not exists.', 'wp-piwik'));
}
if (isset($request)) {
$result = $request->process();
} else {
$result = null;
}
if (!headers_sent()) {
header("Content-Type: text/html", true);
}
$result = $this->unserialize($result);
if ($GLOBALS['wp-piwik_debug']) {
self::$debug[$id] = array($params . '&token_auth=...');
}
return $result;
}