示例#1
0
 public function init()
 {
     $this->bootstrap = $this->getInvokeArg('bootstrap');
     $this->options = $this->bootstrap->getOptions();
     $this->_host = $this->_request->getServer('HTTP_HOST');
     if (Zend_Session::sessionExists()) {
         if (!$this->session) {
             $singleton = !empty($this->options['unittest']) ? false : true;
             $this->session = new Zend_Session_Namespace(self::SESSION_NAMESPACE, $singleton);
         }
         $this->_sessionId = Zend_Session::getId();
         do {
             // 登陆信息验证
             $names = $this->options['cookies'];
             if (!isset($this->session->auth) || !$this->_request->getCookie($names['username'])) {
                 break;
             }
             //var_dump($this->_request->getCookie($names['email']));exit();
             if ($this->session->auth['username'] != $this->_request->getCookie($names['username'])) {
                 break;
             }
             $this->session->auth['lasttime'] = time();
             $this->_user = Tudu_User::getInstance();
             $this->_user->init($this->session->auth);
         } while (false);
     } else {
         $authId = $this->_request->getCookie($this->options['cookies']['auth']);
         if (!empty($authId)) {
             $referer = PROTOCOL . '//' . $this->_request->getServer('HTTP_HOST') . '/frame';
             return $this->_redirect($this->options['sites']['www'] . '/login/auto?referer=' . urlencode($referer));
         }
     }
 }
 /**
  *Upload File
  *
  */
 public function uploadAction()
 {
     $this->_loadParams();
     $dir = $this->_fields[$this->_request->getParam('field_id')]['params']['dir'];
     if (!Zend_Session::sessionExists() || !Zend_Session::isStarted()) {
         Zend_Session::start();
     }
     $uniqueName = Zend_Session::getId();
     $this->_genericFileHelper->createFieldDir($dir . DIRECTORY_SEPARATOR . stripcslashes($uniqueName), true);
     $destination = $dir . DIRECTORY_SEPARATOR . stripcslashes($uniqueName);
     $uploadSettings = $this->getParams($this->_request->getParam('field_id'));
     if (!isset($uploadSettings)) {
         //do something bcs there is no file types
     }
     $uploadSettings = array_merge($uploadSettings, array('dir' => $destination, 'field' => $this->_request->getParam('field_id')));
     $result = $this->_genericFileHelper->upload($uploadSettings);
     if ($result === false) {
         $result = array('success' => false, 'files' => array());
         $lastError = $this->_genericFileHelper->getLastErrorMessage();
         if ($lastError != '') {
             $result['error'] = $this->translate($lastError);
         }
         echo json_encode($result);
     } else {
         $result = array('success' => true, 'files' => array($result), 'path' => $result['path']);
         $lastError = $this->_genericFileHelper->getLastErrorMessage();
         if ($lastError != '') {
             $result['error'] = $this->translate($lastError);
         }
         echo json_encode($result);
     }
     die;
 }
示例#3
0
 /**
  * Defined by Zend_Auth_Storage_Interface
  *
  * @return mixed
  */
 public function read()
 {
     if (!Zend_Session::isStarted() && !Zend_Session::sessionExists()) {
         return array();
     }
     return $this->_getSession()->{$this->_member};
 }
 public function indexAction()
 {
     if ($this->getRequest()->getParam('garbage')) {
         $this->redirect('');
     }
     $translator = Zend_Registry::get('Zend_Translate');
     if (!$this->getRequest()->isPost()) {
         if (Zend_Session::sessionExists()) {
             $namespace = $this->_session->getNamespace();
             if (isset($_SESSION[$namespace])) {
                 unset($_SESSION[$namespace]);
             }
             $translator->setLocale('en');
             Zend_Registry::set('Zend_Translate', $translator);
             Zend_Session::regenerateId();
         }
     } else {
         $lang = $this->getRequest()->getParam('lang');
         if ($lang && Zend_Locale::isLocale($lang)) {
             $this->_session->locale->setLocale($lang);
             if ($translator->getLocale() !== $lang) {
                 $translator->setLocale($lang);
                 Zend_Registry::set('Zend_Translate', $translator);
             }
             $this->_session->nextStep = 1;
         }
         if ($this->_session->nextStep !== null) {
             return $this->forward('step' . $this->_session->nextStep);
         }
     }
     $this->forward('step1');
 }
 /**
  * logout
  */
 public function logoutAction()
 {
     if (Zend_Session::sessionExists()) {
         Zend_Session::destroy(true, true);
         $this->_redirect('/index/login');
     }
 }
示例#6
0
 public function _getTypeConnected($type)
 {
     $isconnected = false;
     $defaultNamespace = new Zend_Session_Namespace();
     if (Zend_Session::sessionExists() && $defaultNamespace->type == $type) {
         $isconnected = true;
     }
     return $isconnected;
 }
示例#7
0
 /**
  * Sets session storage options and initializes session namespace object
  *
  * @param  mixed  $namespace
  * @param  mixed  $member
  * @param  string $sessionId
  * @return void
  */
 public function __construct($namespace = self::NAMESPACE_DEFAULT, $member = self::MEMBER_DEFAULT, $sessionId = null)
 {
     $this->_namespace = $namespace;
     $this->_member = $member;
     if (null !== $sessionId && !Zend_Session::sessionExists()) {
         Zend_Session::setId($sessionId);
     }
     $this->_session = new Zend_Session_Namespace($this->_namespace);
 }
 public function loginAction()
 {
     $this->view->translate()->setLocale(isset($_GET['locale']) ? $_GET['locale'] : 'ru');
     $this->view->resource = $this->_request->getParam('resource');
     $this->view->headTitle($this->view->translate('Login page'));
     $this->view->headLink()->appendStylesheet(array('rel' => 'shortcut icon', 'type' => 'image/x-icon', 'href' => '/img/favicon.ico'));
     $this->view->headLink()->appendStylesheet('/modules/auth/css/login.css');
     if ($this->_request->isPost()) {
         //			file_put_contents('d:\\temp\\auth.txt', var_export($this->_request->getParams(), true));
         $filter = new Zend_Filter_StripTags();
         $username = $filter->filter($this->_request->getParam('username'));
         $password = $filter->filter($this->_request->getParam('password'));
         $woredir = $this->_request->getParam('woredir');
         if ($woredir) {
             $this->getHelper('viewRenderer')->setNoRender();
             $this->getHelper('layout')->disableLayout();
         }
         if (empty($username)) {
             $this->_response->setHttpResponseCode(401);
             // Unauthorized
             if ($woredir) {
                 echo 'Please, provide a username.';
             } else {
                 $this->view->message = 'Please, provide a username.';
             }
             //$this->view->translate('Please provide a username.');
         } else {
             Zend_Session::start();
             if (Uman_Auth::login($username, $password)) {
                 Zend_Session::rememberMe();
                 $auth = Zend_Auth::getInstance();
                 $identity = $auth->getIdentity();
                 $ns = new Zend_Session_Namespace('acl');
                 $ns->acl = new Uman_Acl($identity->NODEID, $identity->PATH);
                 if ($woredir) {
                     echo 'OK';
                 } else {
                     $this->_redirect($this->_request->getParam('resource', '/'));
                 }
             } else {
                 $this->_response->setHttpResponseCode(401);
                 // Unauthorized
                 Zend_Session::destroy();
                 if ($woredir) {
                     echo 'Authorization error. Please, try again.';
                 } else {
                     $this->view->message = $this->view->translate('Authorization error. Please, try again.');
                 }
             }
         }
     } else {
         if (Zend_Session::sessionExists()) {
             Zend_Session::start();
             Zend_Session::destroy();
         }
     }
 }
示例#9
0
 protected function _initSession()
 {
     Zend_Session::start(true);
     if (Zend_Session::sessionExists()) {
         $phpSettings = $this->getOption('phpSettings');
         $sessionConfig = $phpSettings['session'];
         // Prorrogando o tempo de vida do cookie ;)
         setcookie($sessionConfig['name'], Zend_Session::getId(), $sessionConfig['cookie_lifetime'] + time(), $sessionConfig['cookie_path'], $sessionConfig['cookie_domain'], $sessionConfig['cookie_secure'], $sessionConfig['cookie_httponly']);
     }
 }
示例#10
0
 /**
  * Initialization session namespace
  *
  * @param string $namespace
  */
 public function init($namespace)
 {
     if (!Zend_Session::sessionExists()) {
         $this->start();
     }
     Varien_Profiler::start(__METHOD__ . '/init');
     $this->_namespace = new Zend_Session_Namespace($namespace, Zend_Session_Namespace::SINGLE_INSTANCE);
     Varien_Profiler::stop(__METHOD__ . '/init');
     return $this;
 }
示例#11
0
 public function sendContent($includeMaster)
 {
     $benchmarkEnabled = Kwf_Benchmark::isEnabled();
     if (Kwf_Util_Https::supportsHttps()) {
         $foundRequestHttps = Kwf_Util_Https::doesComponentRequestHttps($this->_data);
         if (isset($_SERVER['HTTPS'])) {
             //we are on https
             if (!$foundRequestHttps && isset($_COOKIE['kwcAutoHttps']) && !Zend_Session::sessionExists() && !Zend_Session::isStarted()) {
                 //we where auto-redirected to https but don't need https anymore
                 setcookie('kwcAutoHttps', '', 0, '/');
                 //delete cookie
                 Kwf_Util_Https::ensureHttp();
             }
         } else {
             //we are on http
             if ($foundRequestHttps) {
                 setcookie('kwcAutoHttps', '1', 0, '/');
                 Kwf_Util_Https::ensureHttps();
             }
         }
         if ($benchmarkEnabled) {
             Kwf_Benchmark::checkpoint('check requestHttps');
         }
     }
     if ($benchmarkEnabled) {
         $startTime = microtime(true);
     }
     $process = $this->_getProcessInputComponents($includeMaster);
     if ($benchmarkEnabled) {
         Kwf_Benchmark::subCheckpoint('getProcessInputComponents', microtime(true) - $startTime);
     }
     self::_callProcessInput($process);
     if ($benchmarkEnabled) {
         Kwf_Benchmark::checkpoint('processInput');
     }
     $hasDynamicParts = false;
     $out = $this->_render($includeMaster, $hasDynamicParts);
     if ($benchmarkEnabled) {
         Kwf_Benchmark::checkpoint('render');
     }
     header('Content-Type: text/html; charset=utf-8');
     if (!$hasDynamicParts) {
         $lifetime = 60 * 60;
         header('Cache-Control: public, max-age=' . $lifetime);
         header('Expires: ' . gmdate("D, d M Y H:i:s \\G\\M\\T", time() + $lifetime));
         header('Pragma: public');
     }
     echo $out;
     self::_callPostProcessInput($process);
     if ($benchmarkEnabled) {
         Kwf_Benchmark::checkpoint('postProcessInput');
     }
 }
示例#12
0
 public function dispatchLoopShutdown()
 {
     if (Zend_Session::sessionExists() && Zend_Auth::getInstance()->hasIdentity()) {
         $ident = Zend_Auth::getInstance()->getIdentity();
         $isVaporLogin = in_array($ident['authType'], array(App_Controller_Plugin_Auth::AUTH_TYPE_LOST_PASSWORD, App_Controller_Plugin_Auth::AUTH_TYPE_ASYNC, App_Controller_Plugin_Auth::AUTH_TYPE_EXTERNAL, App_Controller_Plugin_Auth::AUTH_TYPE_THIRD_PARTY, App_Controller_Plugin_Auth::AUTH_TYPE_DOWNLOAD_TOKEN));
         if (!$isVaporLogin) {
             Zend_Session::writeClose(true);
         } else {
             Zend_Session::destroy(false);
             $_SESSION = array();
         }
     }
 }
示例#13
0
 function start()
 {
     $saveHandlerManager = new Kutu_Session_SaveHandler_Manager();
     $saveHandlerManager->setSaveHandler();
     $flagSessionIdSent = false;
     if (Zend_Session::sessionExists()) {
         Zend_Session::start();
     } else {
         echo "session has not been started";
         $sReturn = "http://" . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
         $sReturn = urlencode($sReturn);
         header(KUTU_ROOT_URL . '/helper/sso/syncsession/?returnTo=' . $sReturn);
     }
 }
 /**
  * The errorAction handles errors and exceptions.
  *
  * @return null
  */
 public function errorAction()
 {
     $this->getResponse()->clearBody();
     $errors = $this->_getParam('error_handler');
     switch ($errors->type) {
         case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ROUTE:
         case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER:
         case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION:
             // 404 error -- controller or action not found
             $this->getResponse()->setHttpResponseCode(404);
             $this->view->message = 'The page requested was not found.';
             break;
         default:
             // Log exceptions. EnterpriseSecurityException were automagically logged
             // so they are not logged here.
             if ($errors->exception instanceof EnterpriseSecurityException === false) {
                 ESAPI::getIntrusionDetector()->addException($errors->exception);
             }
             // application error - if display_errors is off then the client
             // is redirected to the index controller error action where a
             // generic error message will be rendered.
             $bootstrap = $this->getInvokeArg('bootstrap');
             if ($bootstrap->hasOption('phpsettings')) {
                 $o = $bootstrap->getOption('phpsettings');
                 if (array_key_exists('display_errors', $o) && $o['display_errors'] !== '1') {
                     if (Zend_Session::sessionExists()) {
                         $ns = new Zend_Session_Namespace('Contact');
                         $ns->error = true;
                     }
                     $this->_helper->getHelper('redirector')->setCode(303)->gotoSimple('error', 'index', null, $this->_request->getParams());
                     return;
                 }
             }
             $this->getResponse()->setHttpResponseCode(500);
             $this->view->message = 'Application error';
     }
     // conditionally display exceptions
     if ($this->getInvokeArg('displayExceptions') == true) {
         $this->view->exception = $errors->exception;
     }
     $this->view->request = $errors->request;
 }
 public function inscriptionAction()
 {
     $log = new SessionLAG();
     if ($log->_getTypeConnected('joueur')) {
         return $this->_helper->redirector('inscriptionlan', 'inscription');
     } else {
         $smarty = Zend_Registry::get('view');
         $request = $this->getRequest();
         $smarty->assign('title', 'Connexion');
         $defaultNamespace = new Zend_Session_Namespace();
         if (Zend_Session::sessionExists() && empty($defaultNamespace->userid)) {
             $form = $this->_getLogForm();
             $model = $this->_getModelCompte();
             $modelFonctionCompte = $this->_getModelFonctionCompte();
             if ($this->getRequest()->isPost()) {
                 if ($form->isValid($request->getPost())) {
                     $dataform = $form->getValues();
                     $dataform['password'] = sha1('l@g8?' . $dataform['password'] . 'pe6r!e8');
                     $existlog = $model->existLog($dataform);
                     if ($existlog != NULL) {
                         $userid = 'idCompte';
                         $fonction = $modelFonctionCompte->fetchFonction($existlog[$userid]);
                         $min = 200;
                         foreach ($fonction as $f) {
                             if ($f['ordre'] < $min) {
                                 $min = $f['ordre'];
                                 $nom = $f['nom'];
                             }
                         }
                         $this->connexion($existlog[$userid], $nom);
                         return $this->_redirect('/inscription/inscriptionlan');
                     } else {
                         $form = "Erreur de connexion : votre login ou mot de passe n'est pas valide. Votre compte n'est peut �tre pas encore activ� par un administrateur.";
                     }
                 }
             }
             $smarty->assign('creer_compte', $request->getBaseUrl() . '/inscription/inscriptionmembre');
             $smarty->assign('form', $form);
             $smarty->display('inscription/inscription.tpl');
         }
     }
 }
示例#16
0
 public function loginAction()
 {
     $this->_helper->layout->disableLayout();
     $req = $this->getRequest();
     $returnTo = $req->getParam('returnTo') ? $req->getParam('returnTo') : KUTU_ROOT_URL;
     setcookie('returnMeTo', urldecode($returnTo), null, '/');
     $flagSessionIdSent = false;
     if (isset($_GET['PHPSESSID']) && !empty($_GET['PHPSESSID'])) {
         if (Zend_Session::sessionExists()) {
             if (!($_COOKIE['PHPSESSID'] == $_GET['PHPSESSID'])) {
                 //Zend_Session::destroy(true);
                 $sessid = $_GET['PHPSESSID'];
                 Zend_Session::setId($sessid);
                 $saveHandlerManager = new Kutu_Session_SaveHandler_Manager();
                 $saveHandlerManager->setSaveHandler();
                 Zend_Session::start();
             }
         } else {
             $saveHandlerManager = new Kutu_Session_SaveHandler_Manager();
             $saveHandlerManager->setSaveHandler();
             Zend_Session::start();
         }
         $flagSessionIdSent = true;
     }
     if ($flagSessionIdSent) {
         if (isset($_COOKIE['returnMeTo']) && !empty($_COOKIE['returnMeTo'])) {
             header("location: " . $_COOKIE['returnMeTo']);
             exit;
         }
     } else {
         $registry = Zend_Registry::getInstance();
         $config = $registry->get('config');
         $url = $config->identity->login->url;
         $sReturn = KUTU_ROOT_URL . '/helper/sso/login';
         $sReturn = urlencode($sReturn);
         header("location: {$url}/?returnTo=" . $sReturn);
         exit;
     }
 }
示例#17
0
 /**
  * Sets up view
  * Alters response content type headers
  * Starts session
  *
  * @param Zend_Controller_Request_Abstract $request
  */
 public function dispatchLoopStartup(Zend_Controller_Request_Abstract $request)
 {
     $this->setupView();
     parent::dispatchLoopStartup($request);
     // Since we're not using the cli sapi, instanciate the http protocol items
     if (!Zend_Session::isStarted() && !Zend_Session::sessionExists()) {
         if ($config = Zoo::getConfig('session', 'plugin')) {
             $options = $config->toArray();
             if (isset($options['save_path'])) {
                 $options['save_path'] = ZfApplication::$_data_path . $options['save_path'];
                 if (!file_exists($options['save_path'])) {
                     mkdir($options['save_path']);
                 }
             }
             Zend_Session::setOptions($options);
             if ($config->save_handler) {
                 $savehandlerClass = $config->save_handler;
                 Zend_Session::setSaveHandler(new $savehandlerClass());
                 // Not ready yet
             }
         }
         Zend_Session::start();
     }
 }
 /**
  * Zend_Session::sessionExists encapsulation
  *
  * @return boolean
  */
 public static function sessionExists()
 {
     return Zend_Session::sessionExists();
 }
示例#19
0
文件: Dci.php 项目: hukumonline/admin
 public function __construct($catalogGuid, $folderGuid, $start = 0, $end = 0)
 {
     $this->view = new Zend_View();
     $this->view->setScriptPath(dirname(__FILE__));
     $this->catalogGuid = $catalogGuid;
     $this->view->addHelperPath(ROOT_DIR . '/library/Pandamp/Controller/Action/Helper', 'Pandamp_Controller_Action_Helper');
     $settings['allowed_extensions'] = array();
     $settings['allowed_extensions'][] = 'jpg';
     $settings['allowed_extensions'][] = 'jpeg';
     $settings['allowed_extensions'][] = 'png';
     $settings['allowed_extensions'][] = 'gif';
     $settings['hidden_files'] = array();
     $settings['hidden_files'][] = 'Thumbs.db';
     $settings['hidden_files'][] = '.DS_Store';
     $registry = Zend_Registry::getInstance();
     $config = $registry->get(Pandamp_Keys::REGISTRY_APP_OBJECT);
     $cdn = $config->getOption('cdn');
     $dir = $cdn['static']['dir']['images'] . DIRECTORY_SEPARATOR . $catalogGuid;
     $dirUrl = $cdn['static']['url']['images'] . DIRECTORY_SEPARATOR . $catalogGuid;
     $this->view->sdir = $dirUrl;
     //$dir = ROOT_DIR."/uploads/images/$catalogGuid";
     if (is_dir($dir)) {
         // open directory and parse file list
         if ($dh = opendir($dir)) {
             // iterate over file list & output all filenames
             while (($filename = readdir($dh)) !== false) {
                 $pinfo = pathinfo($filename);
                 if (strpos($filename, "_") !== 0 && strpos($filename, ".") !== 0 && strpos($filename, "lt") !== 0 && !in_array($filename, $settings['hidden_files']) && in_array(strToLower($pinfo["extension"]), $settings['allowed_extensions'])) {
                     $all_thumbs[] = $filename;
                 }
             }
             // close directory
             closedir($dh);
         }
         Zend_Session::sessionExists('cfg') ? Zend_Session::namespaceUnset('cfg') : '';
         $configGallery = new Zend_Session_Namespace("cfg");
         $configGallery->allThumbs = isset($all_thumbs) ? $all_thumbs : '';
         $configGallery->perPage = $start;
         $this->view->allThumbs = isset($all_thumbs) ? $all_thumbs : '';
         $this->view->page = $end;
         $this->view->perPage = $start;
     }
     //        $bpm = new Pandamp_Core_Hol_Relation();
     //        $fileImage = $bpm->getFilesImg($catalogGuid);
     //
     //        Zend_Controller_Action_HelperBroker::addPrefix('Pandamp_Controller_Action_Helper');
     //        $docType = $this->view->getHelper('GetCatalogDocType');
     //        $catalogTitle = $this->view->getHelper('getCatalogTitle');
     //        $docSize = $this->view->getHelper('GetCatalogDocSize');
     //
     //        $columns = 4;
     //        $content = 0;
     //        $data = array();
     //
     //        foreach ($fileImage as $img)
     //        {
     //            $data[$content][0] = $docType->GetCatalogDocType($img->itemGuid, $img->relatedGuid);
     //            $data[$content][1] = $catalogTitle->getCatalogTitle($img->itemGuid,'fixedTitle');
     //            $data[$content][2] = $docSize->GetCatalogDocSize($img->itemGuid);
     //            $data[$content][3] = $img->itemGuid;
     //            $data[$content][4] = $img->relatedGuid;
     //            $content++;
     //        }
     //
     //        $num_rows = count($fileImage);
     //        $rows = ceil($num_rows/$columns);
     //
     //        if ($num_rows < 2) {
     //            $columns = $num_rows;
     //        }
     //        if ($num_rows == 0) {}
     //
     //        $this->view->numberOfRows = $num_rows;
     //        $this->view->aData = $data;
     //        $this->view->columns = $columns;
     //        $this->view->rows = $rows;
     $this->view->catalogGuid = $catalogGuid;
     $this->view->folderGuid = $folderGuid;
 }
示例#20
0
 public function crearCabecera($navigation = null, $header1 = null, $header2 = null, $header3 = null, $header4 = null)
 {
     //Inicio del Div Wrapper y ul Navigation
     print '
         <div id="wrapper">
             <ul id="navigation">';
     if (!$navigation == null) {
         print $navigation;
     } else {
         //            print '
         //                    <li class="report">
         //                            <a href="#" target="_blank">
         //                            <img src="/main/img/chat.png" style="vertical-align: middle;" alt="Comunicar un error" title="Dejar un Mensaje">
         //                              <a>1 Tello</a>
         //                              <a>2 Tello</a>
         //                            </a>
         //                    </li>';
         if (Zend_Session::sessionExists()) {
             print '
                 <li class="report">
                         <img src="/main/img/chat.png" style="vertical-align: middle;" alt="Comunicar un error" title="Dejar un Mensaje">
                         <div id="chatdiv">';
             $chat = new Application_Model_Chat();
             $result = $chat->usuariosconectados();
             $arratemp = "";
             if ($result == 0) {
             } else {
                 foreach ($result as $aux) {
                     $nombre = $aux['vUsuNombre'] . ' ' . $aux['vUsuApellidoPat'];
                     $nombre = substr($nombre, 0, 10) . '...';
                     print '
                             <div>
                                 <a onclick="javascript:chatWith(\'' . strtoupper($aux['vUsuUsuario']) . '\')" href="javascript:void(0)">
                                     <img src="/' . ($aux['tFoto'] == NULL ? "main/img/unknown.jpg" : $aux['tFoto']) . '" width="28" height="28" class="pic">
                                     <span class="name">' . $nombre . '</span>
                                 </a>
                             </div>';
                 }
             }
             print '          
                             
                         </div>
                 </li>';
         }
     }
     //Fin de Div Navigation
     print '</ul>';
     //Inicio del div Header
     print '<div id="header">';
     //Inicio del div header1
     print '<div id="header1">';
     if (!$header1 == null) {
         print $header1;
     } else {
         print '
                 <div id="top_corner">
                 </div>
                 <div id="logo">
                     <a href="/"/>
                         <img title="INE Los Pinos - Los Pinos" src="/main/css/tesis/images/header-logo.png" alt="INE Los Pinos - Los Pinos">
                     </a>
                 </div>
                 <div id="plugin-header">
                 </div>';
     }
     //Fin del Div header1
     print '</div>';
     //Inicio del div header2
     print '<div id="header2">';
     if (!$header2 == null) {
         print $header2;
     } else {
         print '
                 <div id="Header2Right">
                     <ul>
                         <li>
                         </li>
                         <li>
                             <a href="" target="_top" title="Usuarios en línea">
                                 <img width="13px" src="/main/img/members.gif" title="Usuarios en línea"> 1
                             </a>
                         </li>
                     </ul>
                 </div>';
     }
     //Fin del Div header2
     print '</div>';
     if (!$header3 == null) {
         //Inicio del div header3
         print '<div id="header3">';
         print $header3;
         //Fin del Div header3
         print '</div>';
     }
     //Inicio del div header4
     print '<div id="header4">';
     if (!$header4 == null) {
         print $header4;
     }
     /*
                 else{
                     print '';                
                 }*/
     //Fin del Div header4
     print '</div>';
     //Inicio del Div Clear
     print '
             <div class="clear">
             </div>';
     //Fin del Div Clear
     //Fin del Div Header
     print '</div>';
 }
示例#21
0
文件: Sso.php 项目: EvanDotPro/cosmos
    public static function initiate($namespace)
    {
        $request = new Zend_Controller_Request_Http();
        $sso = false;
        if ($request->getPathInfo() == '/sso') {
            $sso = true;
            if (isset($_GET['sid'])) {
                Zend_Session::setId($_GET['sid']);
                $referer = $request->getHeader('Referer');
            } elseif (isset($_GET['csid']) && !Zend_Session::sessionExists()) {
                Zend_Session::setId($_GET['csid']);
                $dieGotIt = true;
            }
        }
        Zend_Registry::set('csession', new Zend_Session_Namespace('cosmosclient'));
        Zend_Registry::set('cartsess', new Zend_Session_Namespace($namespace));
        $sessionID = Zend_Session::getId();
        if (isset($dieGotIt) && $dieGotIt == true) {
            die("// Got it: {$sessionID}");
        }
        // Invalid session ID somehow.... Give them one.
        if (Zend_Session::sessionExists() && !Zend_Registry::get('csession')->sessionExists) {
            unset($_COOKIE[session_name()]);
            Zend_Session::regenerateId();
            Zend_Registry::get('csession')->sessionExists = true;
        }
        if (Zend_Session::sessionExists()) {
            if (isset($referer)) {
                header("Location: {$referer}");
                die;
            } elseif ($sso == true && isset($_GET['csid'])) {
                if ($sessionID == $_GET['csid']) {
                    die('// No SID update needed.');
                }
                $cookieName = session_name();
                $js = <<<js
window.stop();
function setCookie(c_name,value,expiredays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate()+expiredays);
document.cookie=c_name+ "=" +escape(value)+
((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}
function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    {
    c_start=c_start + c_name.length+1;
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));
    }
  }
return "";
}
setCookie("{$cookieName}","{$sessionID}");
cookieValue = getCookie("{$cookieName}");
if(cookieValue == "{$sessionID}"){
location.reload(true);
} else {
window.location = '/sso?sid={$sessionID}';
}
js;
                die($js);
            }
        } else {
            Zend_Registry::get('csession')->sessionExists = true;
        }
    }
 /**
  * The error controller will redirect the client here and a generic message will
  * be displayed. Direct requests for this page will result in a redirect to
  * index action.
  *
  * @return null
  */
 public function errorAction()
 {
     if (Zend_Session::sessionExists()) {
         $ns = new Zend_Session_Namespace('Contact');
         if ($ns->error === true) {
             // Just show this view. Simples!
             unset($ns->error);
             return;
         }
     }
     $this->_helper->getHelper('redirector')->setCode(303)->gotoSimple('index', null, null, $this->_request->getParams());
 }
示例#23
0
 /**
  * Check if user is logged in (faster than directly calling user model)
  *
  * Only asks user model (expensive) when there is something stored in the session
  *
  * @return boolean if user is logged in
  */
 public static function hasAuthedUser()
 {
     static $benchmarkEnabled;
     if (!isset($benchmarkEnabled)) {
         $benchmarkEnabled = Kwf_Benchmark::isEnabled();
     }
     if ($benchmarkEnabled) {
         $t = microtime(true);
     }
     if (!Zend_Session::isStarted() && !Zend_Session::sessionExists() && !Kwf_Config::getValue('autologin')) {
         if ($benchmarkEnabled) {
             Kwf_Benchmark::subCheckpoint('hasAuthedUser: no session', microtime(true) - $t);
         }
         return false;
     }
     if (!Kwf_Auth::getInstance()->getStorage()->read()) {
         if ($benchmarkEnabled) {
             Kwf_Benchmark::subCheckpoint('hasAuthedUser: storage empty', microtime(true) - $t);
         }
         return false;
     }
     $m = Kwf_Registry::get('userModel');
     if (!$m) {
         return false;
     }
     $ret = $m->hasAuthedUser();
     if ($benchmarkEnabled) {
         Kwf_Benchmark::subCheckpoint('hasAuthedUser: asked model', microtime(true) - $t);
     }
     return $ret;
 }
示例#24
0
 protected function destroySession()
 {
     $integrations = new Application_Model_Integrations();
     $integrations->onDestroySession();
     if (Zend_Session::sessionExists()) {
         Zend_Session::destroy(true, true);
     }
 }
示例#25
0
 /**
  * Called before Zend_Controller_Front exits its dispatch loop.
  *
  * @return void
  */
 public function dispatchLoopShutdown()
 {
     if (!Zend_Session::sessionExists() || !Zend_Auth::getInstance()->hasIdentity()) {
         return;
     }
     $ident = Zend_Auth::getInstance()->getIdentity();
     // Session management by auth type
     $isTemporalLogin = in_array($ident['authType'], array(self::AUTH_TYPE_REGULAR, self::AUTH_TYPE_CORE, self::AUTH_TYPE_ACTIVATION_TOKEN, self::AUTH_TYPE_LOST_PASSWORD_TOKEN, self::AUTH_TYPE_PASSWORD_EXPIRED_TOKEN));
     $isVaporLogin = in_array($ident['authType'], array(self::AUTH_TYPE_LOST_PASSWORD, self::AUTH_TYPE_ASYNC, self::AUTH_TYPE_EXTERNAL, self::AUTH_TYPE_DOWNLOAD_TOKEN, self::AUTH_TYPE_THIRD_PARTY));
     /*
      * When request has used a vapor login or a failed temporal login we regenerate session.
      * But if request is a success temporal login we add auth token header
      */
     if ($isVaporLogin) {
         // Destroy the session
         Zend_Session::destroy();
         $this->getResponse()->clearHeader('X-Csrf-Token');
         $_SESSION = array();
     } else {
         if ($isTemporalLogin) {
             if ($this->getResponse()->isException()) {
                 // Destroy the identity
                 Zend_Auth::getInstance()->clearIdentity();
                 // Regenerate a new session
                 if (!Zend_Session::isRegenerated()) {
                     Zend_Session::regenerateId();
                 }
             } else {
                 if (!empty($ident['id'])) {
                     // Regenerate session
                     $this->getResponse()->setHeader('X-M2M-AuthToken', $ident['token'], true);
                     // Save last user access
                     $user = UserService::getInstance()->load($ident['id']);
                     $user->setLastLogin(time());
                     $user->save();
                     // Add user language (UX requirement)
                     $this->getResponse()->setHeader('X-M2M-UserLanguage', $user->getLanguage(), true);
                 }
             }
         }
     }
 }
示例#26
0
 /**
  * Execute all the default method.
  * This is the quick mode to make the bootstrapper work.
  */
 public function run()
 {
     // Common initialisation
     $this->registry = Zend_Registry::getInstance();
     $this->_setConfigToRegistry(getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'general');
     $this->_setPaths();
     $this->frontController = Zend_Controller_Front::getInstance();
     if (!Zend_Session::sessionExists()) {
         Zend_Session::start();
     }
     $this->auth = Sydney_Auth::getInstance();
     // set default timezone (could be useful)
     date_default_timezone_set($this->config->general->defaulttimezone);
     // set this in the registry so we can change the translations according to the page content if needed
     $this->registry->set('bootstrapper', $this);
     $this->setRoutes();
     $this->setErrorMode($this->config->general->env);
     $this->setDebugMode();
     $this->setCacheGlobalParams();
     $this->setLanguageSettings();
     $this->setTranslationObject();
     $this->setLocalization();
     $this->_setRegistredHelpersToRegistry();
     try {
         $this->setDatabaseConnection();
     } catch (Exception $e) {
         header('Location: ' . Sydney_Tools_Paths::getRootUrlCdn() . '/install/index.php');
         exit;
     }
     try {
         $this->initCustomModules();
     } catch (Exception $e) {
         echo 'ERROR initCustomModules', '<br>';
         echo $e->getMessage();
         header('Location: ' . Sydney_Tools_Paths::getRootUrlCdn() . '/install/index.php');
     }
     try {
         $this->registerAuthPlugin();
     } catch (Exception $e) {
         echo 'ERROR registerAuthPlugin', '<br>';
     }
     try {
         $this->initModules();
     } catch (Exception $e) {
         echo 'ERROR initModules', '<br>';
     }
     $this->setLayout();
     // set frontController plugins
     $this->registerFriendlyurlsPlugin();
     $this->registerCachePlugin();
     $this->dispatch();
 }
示例#27
0
文件: Base.php 项目: bjtenao/tudu-web
 /**
  * 初始化
  */
 public function init()
 {
     $this->bootstrap = $this->getInvokeArg('bootstrap');
     $this->multidb = $this->bootstrap->getResource('multidb');
     $this->cache = $this->bootstrap->getResource('memcache');
     $this->options = $this->bootstrap->getOptions();
     $this->_user = Tudu_User::getInstance();
     $this->_timestamp = time();
     if (Zend_Session::sessionExists() || !empty($this->_sessionId)) {
         if (!$this->session) {
             $this->session = new Zend_Session_Namespace(self::SESSION_NAMESPACE, false);
         }
         $this->_sessionId = Zend_Session::getId();
         do {
             // 登陆信息验证
             $names = $this->options['cookies'];
             if (!isset($this->session->auth) || !$this->_request->getCookie($names['username'])) {
                 $this->_destroySession();
                 break;
             }
             if (isset($this->session->auth['referer'])) {
                 $this->_refererUrl = $this->session->auth['referer'];
             }
             if ($this->session->auth['username'] != $this->_request->getCookie($names['username'])) {
                 $this->_destroySession();
                 break;
             }
             $this->session->auth['lasttime'] = $this->_timestamp;
             $this->_user->init($this->session->auth);
             if (!$this->_user->isLogined()) {
                 $this->_destroySession();
             }
             // 体验帐号
             if (in_array($this->_user->orgId, array('win', 'tuduoffice'))) {
                 $this->session->isdemo = true;
             }
             if ($this->_user->orgId == 'online-app') {
                 header('P3P: CP=”CURa ADMa DEVa PSAo PSDo OUR BUS UNI PUR INT DEM STA PRE COM NAV OTC NOI DSP COR”');
             }
             $this->org = $this->getOrg($this->_user->orgId);
             $this->_user->setOptions(array('timezone' => !empty($this->org['timezone']) ? $this->org['timezone'] : 'Etc/GMT-8', 'dateformat' => !empty($this->org['dateformat']) ? $this->org['dateformat'] : '%Y-%m-%d %H:%M:%S', 'passwordlevel' => $this->org['passwordlevel'], 'skin' => $this->org['skin']));
             if (!empty($this->_user->option['language'])) {
                 Tudu_Lang::getInstance()->setLanguage($this->_user->option['language']);
             }
             // 禁止访问
             if (Dao_Md_Org_Org::STATUS_FORBID == $this->org['status']) {
                 $controllerName = $this->_request->getControllerName();
                 if ($controllerName != 'forbid') {
                     $this->jump('/forbid');
                 }
             }
             // 设置默认时区
             if (!empty($this->_user->option['timezone'])) {
                 date_default_timezone_set($this->_user->option['timezone']);
             }
             // 注册TS数据库
             Tudu_Dao_Manager::setDb(Tudu_Dao_Manager::DB_TS, $this->multidb->getDb('ts' . $this->org['tsid']), true);
         } while (false);
     } else {
         $authId = $this->_request->getCookie($this->options['cookies']['auth']);
         if (!empty($authId)) {
             $query = $this->_request->getServer('HTTP_QUERY_STRING');
             return $this->jump($this->options['sites']['www'] . '/login/auto?referer=%referer', array(), array('referer' => true));
         }
     }
     $this->view->version = self::TUDU_VERSION;
     $this->view->user = $this->_user->toArray();
     $this->view->options = array('sites' => $this->options['sites'], 'tudu' => $this->options['tudu']);
 }
示例#28
0
 public function likelyHasState()
 {
     return \Zend_Session::sessionExists();
 }
 public function init()
 {
     if (Zend_Session::sessionExists()) {
         $this->verificarInactividad();
     }
 }
示例#30
0
 /**
  * 現在のリクエストに対応するセッションが既に存在するかチェック
  *
  * @static
  * @access public
  */
 public static function sessionExists()
 {
     return parent::sessionExists();
 }