public function doGet(\Innomatic\Webapp\WebAppRequest $req, \Innomatic\Webapp\WebAppResponse $res)
 {
     // identify the requested resource path
     $resource = substr(\Innomatic\Webapp\WebAppContainer::instance('\\Innomatic\\Webapp\\WebAppContainer')->getCurrentWebApp()->getHome(), 0, -1) . '/root' . $req->getPathInfo();
     $ignore_lock = false;
     // make sure that this path exists on disk
     switch (substr($resource, strrpos($resource, '/') + 1)) {
         /*
                     case 'main':
                     case 'menu':
                     case 'logo':
         break;
         */
         case 'unlock':
             $ignore_lock = true;
             break;
         default:
             if (substr($resource, -1, 1) != '/' and !file_exists($resource . '.php') and !is_dir($resource . '-panel')) {
                 $res->sendError(\Innomatic\Webapp\WebAppResponse::SC_NOT_FOUND, $req->getRequestURI());
                 return;
             }
     }
     // Bootstraps Innomatic
     $innomatic = \Innomatic\Core\InnomaticContainer::instance('\\Innomatic\\Core\\InnomaticContainer');
     if ($ignore_lock) {
         $innomatic->setLockOverride(true);
     }
     // Sets Innomatic base URL
     $baseUrl = '';
     $webAppPath = $req->getUrlPath();
     if (!is_null($webAppPath) && $webAppPath != '/') {
         $baseUrl = $req->generateControllerPath($webAppPath, true);
     }
     $innomatic->setBaseUrl($baseUrl);
     $innomatic->setInterface(\Innomatic\Core\InnomaticContainer::INTERFACE_WEB);
     $home = \Innomatic\Webapp\WebAppContainer::instance('\\Innomatic\\Webapp\\WebAppContainer')->getCurrentWebApp()->getHome();
     $innomatic->bootstrap($home, $home . 'core/conf/innomatic.ini');
     if ($innomatic->getState() == \Innomatic\Core\InnomaticContainer::STATE_SETUP) {
         $innomatic->abort('Setup phase');
     }
     if (!headers_sent()) {
         // Starts output compression.
         if ($innomatic->getConfig()->value('CompressedOutputBuffering') == '1') {
             ini_set('zlib.output_compression', 'on');
             ini_set('zlib.output_compression_level', 6);
         }
     }
     \Innomatic\Desktop\Controller\DesktopFrontController::instance('\\Innomatic\\Desktop\\Controller\\DesktopFrontController')->execute(\Innomatic\Core\InnomaticContainer::MODE_ROOT, $resource);
 }
Example #2
0
 /**
  * Get current languae by scope
  * @param  string $scope scope language
  * @return string        current language
  */
 public static function getCurrentLanguage($scope = 'frontend')
 {
     $lang = self::getDefaultLanguage();
     // @TODO use WuiSessonKey when in backoffice context
     if ($scope == 'backend') {
         $key = 'innomedia_lang_for_edit_context';
     } elseif ($scope == 'frontend') {
         $key = 'innomedia_locale';
     } else {
         return $lang;
     }
     // @TODO use WebAppSession when in frontend context
     // $session = \Innomedia\Context::instance('\Innomedia\Context')->getSession();
     $session = \Innomatic\Desktop\Controller\DesktopFrontController::instance('\\Innomatic\\Desktop\\Controller\\DesktopFrontController')->session;
     if ($session->isValid($key)) {
         $lang = ($key == 'innomedia_locale' ? '__' : '') . $session->get($key);
     }
     return $lang;
 }
 public static function doAuth($wrong = false, $reason = '')
 {
     $container = \Innomatic\Core\InnomaticContainer::instance('\\Innomatic\\Core\\InnomaticContainer');
     $innomatic_locale = new \Innomatic\Locale\LocaleCatalog('innomatic::authentication', $container->getLanguage());
     $innomatic = \Innomatic\Core\InnomaticContainer::instance('\\Innomatic\\Core\\InnomaticContainer');
     $wui = \Innomatic\Wui\Wui::instance('\\Innomatic\\Wui\\Wui');
     $wui->loadWidget('button');
     $wui->loadWidget('empty');
     $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');
     $wui_page = new WuiPage('loginpage', array('title' => $innomatic_locale->getStr('rootlogin'), 'border' => 'false', 'align' => 'center', 'valign' => 'middle'));
     $wui_topgroup = new WuiVertgroup('topgroup', array('align' => 'center', 'groupalign' => 'center', 'groupvalign' => 'middle', 'height' => '100%', 'width' => '0%'));
     $wui_maingroup = new WuiVertgroup('maingroup', array('align' => 'center'));
     $wui_titlebar = new WuiTitleBar('titlebar', array('title' => $innomatic_locale->getStr('rootlogin')));
     $wui_mainbframe = new WuiVertframe('vframe', array('align' => 'center'));
     $wui_mainframe = new WuiHorizgroup('horizframe');
     $wui_mainstatus = new WuiStatusBar('mainstatusbar');
     // Main frame
     //
     $wui_grid = new WuiGrid('grid', array('rows' => '2', 'cols' => '2'));
     $wui_grid->addChild(new WuiLabel('usernamelabel', array('label' => $innomatic_locale->getStr('username'))), 0, 0);
     $wui_grid->addChild(new WuiString('username', array('disp' => 'login')), 0, 1);
     $wui_grid->addChild(new WuiLabel('passwordlabel', array('label' => $innomatic_locale->getStr('password'))), 1, 0);
     $wui_grid->addChild(new WuiString('password', array('disp' => 'login', 'password' => 'true')), 1, 1);
     $wui_vgroup = new WuiVertgroup('vertgroup', array('align' => 'center'));
     // $wui_vgroup->addChild( new WuiLabel( 'titlelabel', array( 'label' => $innomatic_locale->getStr( 'rootlogin' ) ) ) );
     $wui_vgroup->addChild($wui_grid);
     $wui_vgroup->addChild(new WuiSubmit('submit', array('caption' => $innomatic_locale->getStr('enter'))));
     $form_events_call = new \Innomatic\Wui\Dispatch\WuiEventsCall();
     $form_events_call->addEvent(new \Innomatic\Wui\Dispatch\WuiEvent('login', 'login', ''));
     $form_events_call->addEvent(new \Innomatic\Wui\Dispatch\WuiEvent('view', 'default', ''));
     $wui_form = new WuiForm('form', array('action' => $form_events_call->getEventsCallString()));
     $wui_hgroup = new WuiHorizgroup('horizgroup', array('align' => 'middle'));
     $wui_hgroup->addChild(new WuiButton('password', array('themeimage' => 'keyhole', 'themeimagetype' => 'big', 'action' => $innomatic->getBaseUrl() . '/', 'highlight' => false)));
     $wui_hgroup->addChild($wui_vgroup);
     $wui_form->addChild($wui_hgroup);
     $wui_mainframe->addChild($wui_form);
     // Wrong account check
     //
     $session = \Innomatic\Desktop\Controller\DesktopFrontController::instance('\\Innomatic\\Desktop\\Controller\\DesktopFrontController')->session;
     if ($wrong) {
         if ($innomatic->getConfig()->Value('SecurityAlertOnWrongLocalRootLogin') == '1') {
             $innomatic_security = new \Innomatic\Security\SecurityManager();
             $innomatic_security->sendAlert('Wrong root local login from remote address ' . $_SERVER['REMOTE_ADDR']);
             $innomatic_security->logFailedAccess('', true, $_SERVER['REMOTE_ADDR']);
             unset($innomatic_security);
         }
         $sleep_time = $innomatic->getConfig()->Value('WrongLoginDelay');
         if (!strlen($sleep_time)) {
             $sleep_time = 1;
         }
         $max_attempts = $innomatic->getConfig()->Value('MaxWrongLogins');
         if (!strlen($max_attempts)) {
             $max_attempts = 3;
         }
         sleep($sleep_time);
         if ($session->isValid('root_login_attempts')) {
             $session->put('root_login_attempts', $session->get('root_login_attempts') + 1);
             if ($session->get('root_login_attempts') >= $max_attempts) {
                 $innomatic->abort($innomatic_locale->getStr('wrongpwd'));
             }
         } else {
             $session->put('root_login_attempts', 1);
         }
         if ($reason) {
             $wui_mainstatus->mArgs['status'] = $innomatic_locale->getStr($reason);
         } else {
             $wui_mainstatus->mArgs['status'] = $innomatic_locale->getStr('wrongpwd');
         }
     } else {
         $session->put('domain_login_attempts', 0);
     }
     // Page render
     //
     $wui_maingroup->addChild($wui_titlebar);
     // $wui_maingroup->addChild( new WuiButton( 'innomaticlogo', array( 'image' => $innomatic->getBaseUrl(false).'/shared/styles/cleantheme/innomatic_big_asp.png', 'action' => $innomatic->getBaseUrl().'/' ) ) );
     $wui_mainbframe->addChild($wui_mainframe);
     $wui_mainbframe->addChild(new WuiHorizBar('hb'));
     $wui_mainbframe->addChild(new WuiLink('copyright', array('label' => $innomatic_locale->getStr('auth_copyright.label'), 'link' => 'http://www.innomatic.io/', 'target' => '_blank')));
     $wui_maingroup->addChild($wui_mainbframe);
     $wui_maingroup->addChild($wui_mainstatus);
     $wui_topgroup->addChild($wui_maingroup);
     $wui_page->addChild($wui_topgroup);
     $wui->addChild($wui_page);
     $wui->render();
     $innomatic->halt();
 }
Example #4
0
 /**
  * Gets the widget parameters stored in the session.
  *
  * @access public
  * @return array Widget parameters in session.
  */
 public function retrieveSession()
 {
     if ($this->mUseSession == 'true' and \Innomatic\Desktop\Controller\DesktopFrontController::instance('\\Innomatic\\Desktop\\Controller\\DesktopFrontController')->session->isValid($this->mSessionObjectName)) {
         return unserialize(\Innomatic\Desktop\Controller\DesktopFrontController::instance('\\Innomatic\\Desktop\\Controller\\DesktopFrontController')->session->get($this->mSessionObjectName));
     } else {
         return false;
     }
 }