Example #1
0
 public static function getInstance($handler, $options)
 {
     if (!is_object(self::$instance)) {
         self::$instance = new MSession($handler, $options);
     }
     return self::$instance;
 }
Example #2
0
 protected function getOptions()
 {
     // Initialize variables.
     $options = array();
     // Get the options from MSession.
     foreach (MSession::getStores() as $store) {
         $options[] = MHtml::_('select.option', $store, MText::_('MLIB_FORM_VALUE_SESSION_' . $store), 'value', 'text');
     }
     // Merge any additional options in the XML definition.
     $options = array_merge(parent::getOptions(), $options);
     return $options;
 }
Example #3
0
 function init()
 {
     $env = getEnvAS();
     $this->main = $main = (require dirname(__FILE__) . DS . 'config' . DS . $env . DS . 'main.php');
     $param = array();
     if (isset($main['param'])) {
         $param = $main['param'];
     }
     $this->param = $param;
     require_once MONC . 'autoload.php';
     $this->import(array('monc.util.*', 'monc.lib.*', 'monc.lib.exception.*', 'monc.comp.*', 'monc.controller.*', 'monc.model.*', 'monc.view.*', 'monc.lib.validator.*'));
     $this->import(array());
     $this->session = new MSession();
     $this->session->open();
     $this->user = new MWebUser();
     $this->user->init();
     $this->formatter = new MFormatter();
     $this->cms = new Cms();
 }
Example #4
0
 function getState($key)
 {
     return $this->session->get($key);
 }
Example #5
0
 protected static function createSession($options = array())
 {
     // Get the editor configuration setting
     $conf = self::getConfig();
     $handler = $conf->get('session_handler', 'none');
     // Config time is in minutes
     //$options['id']      = 'miwisoft';
     $options['name'] = '_miwisoft';
     $options['expire'] = $conf->get('lifetime') ? $conf->get('lifetime') * 60 : 900;
     $session = MSession::getInstance($handler, $options);
     if ($session->getState() == 'expired') {
         $session->restart();
     }
     return $session;
 }
Example #6
0
 public static function checkToken($method = 'post')
 {
     $token = MSession::getFormToken();
     if (!self::getVar($token, '', $method, 'alnum')) {
         $session = MFactory::getSession();
         if ($session->isNew()) {
             // Redirect to login screen.
             $app = MFactory::getApplication();
             $return = MRoute::_('index.php');
             $app->redirect($return, MText::_('MLIB_ENVIRONMENT_SESSION_EXPIRED'));
             $app->close();
         } else {
             return false;
         }
     } else {
         return true;
     }
 }
 /**
  * This property holds the name of the organization that wrote this 
  * application.<br />
  * The value is used by the MSettings class when it is constructed using the 
  * empty constructor. This saves having to repeat this information each time 
  * a MSettings object is created.
  * 
  * @param string $orgName
  */
 public static function setOrganizationName($orgName)
 {
     MSession::set(MCoreApplication::ORGANIZATION_NAME, $orgName);
 }
Example #8
0
 public static function getWorkarounds($data, $options = array())
 {
     $app = MFactory::getApplication();
     $document = MFactory::getDocument();
     $body = null;
     if (isset($options['mergehead']) && $options['mergehead'] == 1 && isset($data['head']) && !empty($data['head'])) {
         $document->mergeHeadData($data['head']);
     } elseif (isset($data['head']) && method_exists($document, 'setHeadData')) {
         $document->setHeadData($data['head']);
     }
     if (isset($data['pathway']) && is_array($data['pathway'])) {
         $pathway = $app->getPathWay();
         $pathway->setPathway($data['pathway']);
     }
     if (isset($data['module']) && is_array($data['module'])) {
         foreach ($data['module'] as $name => $contents) {
             $document->setBuffer($contents, 'module', $name);
         }
     }
     if (isset($data['body'])) {
         $token = MSession::getFormToken();
         $search = '#<input type="hidden" name="[0-9a-f]{32}" value="1" />#';
         $replacement = '<input type="hidden" name="' . $token . '" value="1" />';
         $data['body'] = preg_replace($search, $replacement, $data['body']);
         $body = $data['body'];
     }
     return $body;
 }
Example #9
0
 public static function token()
 {
     return '<input type="hidden" name="' . MSession::getFormToken() . '" value="1" />';
 }