public function authenticate()
 {
     $container = \Innomatic\Core\InnomaticContainer::instance('\\Innomatic\\Core\\InnomaticContainer');
     $login_disp = new \Innomatic\Wui\Dispatch\WuiDispatcher('login');
     $login_disp->addEvent('login', '\\Innomatic\\Desktop\\Auth\\login_login');
     $login_disp->addEvent('logout', '\\Innomatic\\Desktop\\Auth\\login_logout');
     $login_disp->Dispatch();
     if ($container->getConfig()->Value('SecurityOnlyHttpsRootAccessAllowed') == '1') {
         if (!isset($_SERVER['HTTPS']) or $_SERVER['HTTPS'] != 'on') {
             self::doAuth(true, 'only_https_allowed');
         }
     }
     $session = \Innomatic\Desktop\Controller\DesktopFrontController::instance('\\Innomatic\\Desktop\\Controller\\DesktopFrontController')->session;
     if (!$session->isValid('INNOMATIC_ROOT_AUTH_USER')) {
         self::doAuth();
     }
     if ($session->isValid('root_login_attempts')) {
         $session->remove('root_login_attempts');
     }
     $container->startRoot($session->get('INNOMATIC_ROOT_AUTH_USER'));
     return true;
 }
 public static function doAuth($wrong = false, $reason = '')
 {
     $innomatic = \Innomatic\Core\InnomaticContainer::instance('\\Innomatic\\Core\\InnomaticContainer');
     $innomaticLocale = new \Innomatic\Locale\LocaleCatalog('innomatic::authentication', $innomatic->getLanguage());
     $wui = \Innomatic\Wui\Wui::instance('\\Innomatic\\Wui\\Wui');
     $wui->loadWidget('button');
     $wui->loadWidget('formarg');
     $wui->loadWidget('form');
     $wui->loadWidget('grid');
     $wui->loadWidget('horizbar');
     $wui->loadWidget('horizframe');
     $wui->loadWidget('horizgroup');
     $wui->loadWidget('image');
     $wui->loadWidget('label');
     $wui->loadWidget('link');
     $wui->loadWidget('page');
     $wui->loadWidget('sessionkey');
     $wui->loadWidget('statusbar');
     $wui->loadWidget('string');
     $wui->loadWidget('submit');
     $wui->loadWidget('titlebar');
     $wui->loadWidget('vertframe');
     $wui->loadWidget('vertgroup');
     $wuiPage = new WuiPage('loginpage', array('title' => $innomaticLocale->getStr('desktoplogin'), 'border' => 'false', 'align' => 'center', 'valign' => 'middle'));
     $wuiTopGroup = new WuiVertgroup('topgroup', array('align' => 'center', 'groupalign' => 'center', 'groupvalign' => 'middle', 'height' => '189px', 'width' => '350px'));
     $wuiMainGroup = new WuiVertgroup('maingroup', array('align' => 'center'));
     $wuiTitleBar = new WuiTitleBar('titlebar', array('title' => $innomaticLocale->getStr('desktoplogin')));
     $wuiMainBFrame = new WuiVertframe('vframe', array('align' => 'center'));
     $wuiMainFrame = new WuiHorizgroup('horizframe');
     $wuiMainStatus = new WuiStatusBar('mainstatusbar', array('width' => '350px'));
     // Main frame
     //
     $wuiGrid = new WuiGrid('grid', array('rows' => '2', 'cols' => '2'));
     $wuiGrid->addChild(new WuiLabel('usernamelabel', array('label' => $innomaticLocale->getStr('username'))), 0, 0);
     $wuiGrid->addChild(new WuiString('username', array('disp' => 'login')), 0, 1);
     $wuiGrid->addChild(new WuiLabel('passwordlabel', array('label' => $innomaticLocale->getStr('password'))), 1, 0);
     $wuiGrid->addChild(new WuiString('password', array('disp' => 'login', 'password' => 'true')), 1, 1);
     $wuiVGroup = new WuiVertgroup('vertgroup', array('align' => 'center'));
     // $wui_vgroup->addChild( new WuiLabel( 'titlelabel', array( 'label' => $innomatic_locale->getStr( 'rootlogin' ) ) ) );
     $wuiVGroup->addChild($wuiGrid);
     $wuiVGroup->addChild(new WuiSubmit('submit', array('caption' => $innomaticLocale->getStr('enter'))));
     $formEventsCall = new \Innomatic\Wui\Dispatch\WuiEventsCall();
     $formEventsCall->addEvent(new \Innomatic\Wui\Dispatch\WuiEvent('login', 'login', ''));
     $formEventsCall->addEvent(new \Innomatic\Wui\Dispatch\WuiEvent('view', 'default', ''));
     $wuiForm = new WuiForm('form', array('action' => $formEventsCall->getEventsCallString()));
     $wuiHGroup = new WuiHorizgroup('horizgroup', array('align' => 'middle'));
     $wuiHGroup->addChild(new WuiButton('password', array('themeimage' => 'keyhole', 'themeimagetype' => 'big', 'action' => $innomatic->getBaseUrl() . '/', 'highlight' => false)));
     $wuiHGroup->addChild($wuiVGroup);
     $wuiForm->addChild($wuiHGroup);
     $wuiMainFrame->addChild($wuiForm);
     // Wrong account check
     //
     $session = \Innomatic\Desktop\Controller\DesktopFrontController::instance('\\Innomatic\\Desktop\\Controller\\DesktopFrontController')->session;
     if ($wrong) {
         if ($innomatic->getConfig()->value('SecurityAlertOnWrongLocalUserLogin') == '1') {
             $loginDispatcher = new \Innomatic\Wui\Dispatch\WuiDispatcher('login');
             $eventData = $loginDispatcher->getEventData();
             $innomaticSecurity = new \Innomatic\Security\SecurityManager();
             $innomaticSecurity->sendAlert('Wrong user local login for user ' . $eventData['username'] . ' from remote address ' . $_SERVER['REMOTE_ADDR']);
             $innomaticSecurity->logFailedAccess($eventData['username'], false, $_SERVER['REMOTE_ADDR']);
             unset($innomaticSecurity);
         }
         $sleepTime = $innomatic->getConfig()->value('WrongLoginDelay');
         if (!strlen($sleepTime)) {
             $sleepTime = 1;
         }
         $maxAttempts = $innomatic->getConfig()->value('MaxWrongLogins');
         if (!strlen($maxAttempts)) {
             $maxAttempts = 3;
         }
         sleep($sleepTime);
         if ($session->isValid('domain_login_attempts')) {
             $session->put('domain_login_attempts', $session->get('domain_login_attempts') + 1);
             if ($session->get('domain_login_attempts') >= $maxAttempts) {
                 $innomatic->abort($innomaticLocale->getStr('wrongpwd'));
             }
         } else {
             $session->put('domain_login_attempts', 1);
         }
         if ($reason) {
             $wuiMainStatus->mArgs['status'] = $innomaticLocale->getStr($reason);
         } else {
             $wuiMainStatus->mArgs['status'] = $innomaticLocale->getStr('wrongpwd');
         }
     } else {
         $session->put('domain_login_attempts', 0);
     }
     // Page render
     //
     $wuiMainGroup->addChild($wuiTitleBar);
     // $wui_maingroup->addChild( new WuiButton( 'innomaticlogo', array( 'image' => $innomatic->getBaseUrl(false).'/shared/styles/cleantheme/innomatic_big_asp.png', 'action' => $innomatic->getBaseUrl().'/' ) ) );
     $wuiMainBFrame->addChild($wuiMainFrame);
     $wuiMainGroup->addChild($wuiMainBFrame);
     // $wuiMainGroup->addChild($wuiMainStatus);
     $wuiTopGroup->addChild($wuiMainGroup);
     $wuiPage->addChild($wuiTopGroup);
     $wuiPage->addChild($wuiMainStatus);
     $wui->addChild($wuiPage);
     $wui->render();
     $innomatic->halt();
 }
Esempio n. 3
0
}
$actionDispatcher->addEvent('editname', 'pass_editname');
function pass_editname($eventData)
{
    global $wuiPage, $wuiMainStatus, $innomaticLocale;
    $log = \Innomatic\Core\InnomaticContainer::instance('\\Innomatic\\Core\\InnomaticContainer')->getLogger();
    $innomaticcfg = new \Innomatic\Config\ConfigFile(\Innomatic\Core\InnomaticContainer::instance('\\Innomatic\\Core\\InnomaticContainer')->getConfigurationFile());
    $innomaticcfg->setValue('PlatformName', $eventData['name']);
    $innomaticcfg->setValue('PlatformGroup', $eventData['domain']);
    $log->logEvent('Innomatic', 'Changed Innomatic network settings', \Innomatic\Logging\Logger::NOTICE);
    $wuiMainStatus->mArgs['status'] = $innomaticLocale->getStr('datachanged');
}
$actionDispatcher->Dispatch();
// Main dispatcher
//
$viewDispatcher = new \Innomatic\Wui\Dispatch\WuiDispatcher('view');
function interface_tab_action_builder($tab)
{
    return \Innomatic\Wui\Dispatch\WuiEventsCall::buildEventsCallString('', array(array('view', 'default', array('activetab' => $tab))));
}
$viewDispatcher->addEvent('default', 'main_default');
function main_default($eventData)
{
    global $wuiMainFrame, $wuiTitleBar, $innomaticLocale, $actionDispatcher, $wuiMainStatus, $wuiComments, $compressedOb;
    $appCfg = new \Innomatic\Application\ApplicationSettings('innomatic');
    $themesQuery = \Innomatic\Core\InnomaticContainer::instance('\\Innomatic\\Core\\InnomaticContainer')->getDataAccess()->execute('SELECT name,catalog FROM wui_themes ');
    while (!$themesQuery->eof) {
        $tmpLocale = new \Innomatic\Locale\LocaleCatalog($themesQuery->getFields('catalog'), \Innomatic\Core\InnomaticContainer::instance('\\Innomatic\\Core\\InnomaticContainer')->getLanguage());
        $elements[$themesQuery->getFields('name')] = $tmpLocale->getStr($themesQuery->getFields('name'));
        $themesQuery->moveNext();
    }
 public function __construct($mode, $application)
 {
     $container = \Innomatic\Core\InnomaticContainer::instance('\\Innomatic\\Core\\InnomaticContainer');
     // Builds the application home path
     $home = $container->getHome();
     switch ($mode) {
         case \Innomatic\Core\InnomaticContainer::MODE_ROOT:
             $home .= 'root/';
             break;
         case \Innomatic\Core\InnomaticContainer::MODE_DOMAIN:
             $home .= 'domain/';
             break;
     }
     $home .= $application . '-panel/';
     // Checks if the application exists and is valid
     if (file_exists($home)) {
         $this->mode = $mode;
         $this->applicationHome = $home;
         $this->application = $application;
     } else {
         throw new \Innomatic\Wui\WuiException(\Innomatic\Wui\WuiException::INVALID_APPLICATION);
     }
     // TODO Verificare, dopo questa impostazione, quanto ancora sia utile di WuiDispatcher
     $view = null;
     $action = null;
     // View initialization
     $viewDispatcher = new \Innomatic\Wui\Dispatch\WuiDispatcher('view');
     $viewEvent = $viewDispatcher->getEventName();
     if (!strlen($viewEvent)) {
         $viewEvent = 'default';
     }
     $viewClassName = ucfirst($this->application) . 'PanelViews';
     // Checks if view file and definition exist
     // @todo update to new namespaces model
     if (!(include_once $this->applicationHome . $viewClassName . '.php')) {
         throw new \Innomatic\Wui\WuiException(\Innomatic\Wui\WuiException::MISSING_VIEWS_FILE);
     }
     if (!class_exists($viewClassName, true)) {
         throw new \Innomatic\Wui\WuiException(\Innomatic\Wui\WuiException::MISSING_VIEWS_CLASS);
     }
     // Instantiate views class
     $this->view = new $viewClassName($this);
     $this->_view = $this->view;
     $this->view->beginHelper();
     // Action initialization
     $actionClassName = ucfirst($this->application) . 'PanelActions';
     // Checks if class file and definition exist
     if (!(include_once $this->applicationHome . $actionClassName . '.php')) {
         throw new \Innomatic\Wui\WuiException(\Innomatic\Wui\WuiException::MISSING_ACTIONS_FILE);
     }
     if (!class_exists($actionClassName, true)) {
         throw new \Innomatic\Wui\WuiException(\Innomatic\Wui\WuiException::MISSING_ACTIONS_CLASS);
     }
     // AJAX
     $ajax_request_uri = $_SERVER['REQUEST_URI'];
     if (strpos($ajax_request_uri, '?')) {
         $ajax_request_uri = substr($ajax_request_uri, 0, strpos($ajax_request_uri, '?'));
     }
     $this->ajax = \Innomatic\Ajax\Xajax::instance('Xajax', $ajax_request_uri);
     // Set debug mode
     if ($container->getState() == \Innomatic\Core\InnomaticContainer::STATE_DEBUG) {
         $this->ajax->debugOn();
     }
     $this->ajax->setLogFile($container->getHome() . 'core/log/ajax.log');
     // Register action ajax calls
     $this->registerClassAjaxCalls($actionClassName, $this->applicationHome . $actionClassName . '.php');
     // Register WUI widgets ajax calls
     $wui = \Innomatic\Wui\Wui::instance('\\Innomatic\\Wui\\Wui');
     $wui->loadAllWidgets();
     foreach ($wui->mLoadedWidgets as $widget) {
         $this->registerClassAjaxCalls('\\Shared\\Wui\\Wui' . ucfirst($widget), $container->getHome() . 'core/classes/shared/wui/Wui' . ucfirst($widget) . '.php', 'Wui' . ucfirst($widget));
     }
     // Process ajax requests, if any (if so, then it exits)
     $this->ajax->processRequests();
     // Action execution, if set
     $actionDispatcher = new \Innomatic\Wui\Dispatch\WuiDispatcher('action');
     $actionEvent = $actionDispatcher->getEventName();
     if (strlen($actionEvent)) {
         $this->action = new $actionClassName($this);
         $this->_action = $this->action;
         $this->action->addObserver($this);
         if (is_object($this->view)) {
             $this->action->addObserver($this->view);
         }
         $this->action->beginHelper();
         // Executes the action
         $actionResult = $this->action->execute($actionEvent, $actionDispatcher->getEventData());
         $this->action->endHelper();
     }
     // Displays the view result
     if (is_object($this->view)) {
         $this->view->execute($viewEvent, $viewDispatcher->getEventData());
         $this->view->endHelper();
         $this->view->display();
     } else {
         throw new \Innomatic\Wui\WuiException(\Innomatic\Wui\WuiException::NO_VIEW_DEFINED);
     }
 }