当前位置: 首页>>代码示例>>PHP>>正文


PHP Session::singleton方法代码示例

本文整理汇总了PHP中Session::singleton方法的典型用法代码示例。如果您正苦于以下问题:PHP Session::singleton方法的具体用法?PHP Session::singleton怎么用?PHP Session::singleton使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Session的用法示例。


在下文中一共展示了Session::singleton方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: login

 public function login() {
     if (empty($_POST)) {
         HttpHandler::redirect('/'+MODULE+'/login/form');
     } else {
         BM::singleton()->getObject('db')->newConnection(HOST, USER, PASSWORD, DATABASE);
         $usuario = BM::singleton()->getObject('db')->sanitizeData($_POST['usuario']);
         $clave = cifrar_RIJNDAEL_256($_POST['clave']);
         $query = "SELECT * FROM empleado WHERE usuario='{$usuario}' AND clave='{$clave}' AND modulo='terceros';";
         BM::singleton()->getObject('db')->executeQuery($query);
         if (BM::singleton()->getObject('db')->getNumRows() > 0) {
             $level = 1;
             while ($data = BM::singleton()->getObject('db')->getResult()->fetch_assoc()) {
                 $level = $data['permiso'];
             }
             Session::singleton()->NewSession($usuario, $level);
             if(!isset($_GET['url'])||empty($_GET['url'])){
                 HttpHandler::redirect('/'.MODULE.'/login/form');
             }else{
                 HttpHandler::redirect($_GET['url']);
             }
         } else {
             HttpHandler::redirect('/'.MODULE.'/login/form?error_id=2');
         }
     }
 }
开发者ID:suavid,项目名称:terceros,代码行数:25,代码来源:login.php

示例2: post

 /**
  * @url POST import
  */
 public function post()
 {
     try {
         $session = Session::singleton();
         $allowedRoles = (array) Config::get('allowedRolesForExcelImport', 'excelImport');
         if (Config::get('loginEnabled') && !is_null($allowedRoles)) {
             $ok = false;
             $sessionRoles = Role::getAllSessionRoles();
             foreach ($sessionRoles as $role) {
                 if (in_array($role->label, $allowedRoles)) {
                     $ok = true;
                 }
             }
             if (!$ok) {
                 throw new Exception("You do not have access to import excel files", 401);
             }
         }
         if (is_uploaded_file($_FILES['file']['tmp_name'])) {
             // Parse:
             $parser = new ImportExcel($_FILES['file']['tmp_name']);
             $result = $parser->ParseFile();
             unlink($_FILES['file']['tmp_name']);
         } else {
             Notifications::addError('No file uploaded');
         }
         $result = array('notifications' => $result, 'files' => $_FILES);
         return $result;
     } catch (Exception $e) {
         throw new RestException($e->getCode(), $e->getMessage());
     }
 }
开发者ID:4ZP6Capstone2015,项目名称:Capstone,代码行数:34,代码来源:ExcelImportApi.php

示例3: bloqueo_pantalla

function bloqueo_pantalla() {
    $usuario = Session::singleton()->getUser();
    $query = "SELECT activo FROM empleado WHERE usuario = '{$usuario}'";
    data_model()->executeQuery($query);
    $ret = data_model()->getResult()->fetch_assoc();
    echo json_encode($ret);
    /*
      if($ret['activo'] == 0 && !empty($usuario)){
      echo "
      <div style=\"position:fixed;width:100%;height:100%;background:#000;top:0px;text-align:center;opacity:0.6\" class=\"metro\">
      <br/>
      <br/>
      <br/>
      <br/>
      <h1 style=\"color:#fff;\">Bloqueado</h1>
      <br/>
      <br/>
      <img src=\"../static/img/candado.png\" />
      <br/>
      <br/>
      <div class=\"input-control text\" style=\"background:#000;\">
      <input style=\"width:300px;border:#D3D3D3;padding:10px;\" type=\"password\" placeholder=\" Password\" />
      <button type=\"button\" class=\"large primary\">Desbloquear</button>
      </div>
      </div>
      ";
      }
     */
}
开发者ID:suavid,项目名称:terceros,代码行数:29,代码来源:init_setup.php

示例4: __get

 public final function __get($index)
 {
     switch ($index) {
         case 'config':
             $this->config = Config::singleton();
             return $this->config;
         case 'cache':
             $this->cache = new Cache($this->config->read('framework/cache/driver', Cache::DISABLED), array('host' => $this->config->read('framework/cache/host', null), 'port' => $this->config->read('framework/cache/port', null)));
             return $this->cache;
         case 'sql':
             $this->config->load('db');
             $this->sql = new SQL($this->config->read('db/dsn', ''), $this->config->read('db/user', ''), $this->config->read('db/pass', ''), $this->config->read('db/pool', false));
             $this->config->unload('db');
             return $this->sql;
         case 'secure':
             $this->secure = new Secure($this->config->read('framework/secure/seed', 'sampa-framework'));
             return $this->secure;
         case 'log':
             $logfile = __SP_LOG__ . date('Ymd') . '-' . str_replace('_', '-', strtolower(get_class($this))) . '.log';
             $this->log = new Log($logfile, $this->config->read('framework/log/level', Log::DISABLED), $this->config->read('framework/log/buffered', true));
             return $this->log;
         case 'session':
             $this->session = Session::singleton($this->config);
             return $this->session;
         default:
             return null;
     }
 }
开发者ID:appdeck,项目名称:sampa,代码行数:28,代码来源:Plugin.php

示例5: run

 /**
  * @url GET run
  */
 public function run()
 {
     try {
         $session = Session::singleton();
         $db = Database::singleton();
         $allowedRoles = (array) Config::get('allowedRolesForRunFunction', 'execEngine');
         if (Config::get('loginEnabled') && !is_null($allowedRoles)) {
             $ok = false;
             $sessionRoles = Role::getAllSessionRoles();
             foreach ($sessionRoles as $role) {
                 if (in_array($role->label, $allowedRoles)) {
                     $ok = true;
                 }
             }
             if (!$ok) {
                 throw new Exception("You do not have access to run the exec engine", 401);
             }
         }
         $session->setRole();
         ExecEngine::runAllRules();
         $db->closeTransaction('Run completed', false, true, false);
         $result = array('notifications' => Notifications::getAll());
         return $result;
     } catch (Exception $e) {
         throw new RestException($e->getCode(), $e->getMessage());
     }
 }
开发者ID:4ZP6Capstone2015,项目名称:Capstone,代码行数:30,代码来源:ExecEngineApi.php

示例6: imprimir_ticket_cambio

	public function imprimir_ticket_cambio($id_cambio){
		$queryCambioCabecera = "SELECT caja, fecha, cliente, devolucion.factura FROM devolucion INNER JOIN cambio ON cambio=cambio.id WHERE cambio=$id_cambio";
		$cache = array();
		data_model()->executeQuery($queryCambioCabecera);
        if(data_model()->getNumRows()>0){
            $res = data_model()->getResult()->fetch_assoc();
            $cliente = $res['cliente'];
            $empresa = $this->model->get_child('system');
            $empresa->get(1);
            list($tieneCaja, $data) = $this->model->get_sibling('factura')->tieneCaja(Session::singleton()->getUser());
            $caja     =   $data['id'];
            $fecha    =   $res['fecha'];
            $empleado = $this->model->get_child('empleado');
            $empleado->get(Session::singleton()->getUser());
            $id_datos = $empleado->id_datos;
            $clienteObj = $this->model->get_sibling('cliente');
            $clienteObj->get($id_datos);
            $nombre_empleado = $clienteObj->primer_nombre ." ". $clienteObj->primer_apellido;
            $queryNombreCliente = "SELECT CONCAT(primer_nombre,' ', segundo_nombre,' ', primer_apellido, ' ', segundo_apellido) as nombre FROM cliente WHERE codigo_afiliado=$cliente";
            data_model()->executeQuery($queryNombreCliente);
            $res = data_model()->getResult()->fetch_assoc();
            $nombre_cliente = $res['nombre'];
            $queryDetalleCambio = "SELECT linea, estilo, color, talla, cantidad, precio FROM devolucion WHERE cambio=$id_cambio";
            $detalle = data_model()->cacheQuery($queryDetalleCambio);
            $this->view->imprimir_ticket_cambio($id_cambio,$caja, $cliente, $fecha, $nombre_cliente, $detalle, $empresa, $nombre_empleado);
        }else{
            echo "Este ticket de cambio est&aacute; vac&iacute;o o anulado";   
        }
	}
开发者ID:suavid,项目名称:terceros,代码行数:29,代码来源:report.php

示例7: run

 /**
  * @url GET run
  * @param array $roleIds
  */
 public function run($roleIds = null)
 {
     try {
         $session = Session::singleton();
         $session->activateRoles($roleIds);
         // Check sessionRoles if allowedRolesForRunFunction is specified
         $allowedRoles = Config::get('allowedRolesForRunFunction', 'execEngine');
         if (!is_null($allowedRoles)) {
             $ok = false;
             foreach ($session->getSessionRoles() as $role) {
                 if (in_array($role->label, $allowedRoles)) {
                     $ok = true;
                 }
             }
             if (!$ok) {
                 throw new Exception("You do not have access to run the exec engine", 401);
             }
         }
         ExecEngine::run(true);
         $db = Database::singleton();
         $db->closeTransaction('Run completed', false, true, false);
         $result = array('notifications' => Notifications::getAll());
         return $result;
     } catch (Exception $e) {
         throw new RestException($e->getCode(), $e->getMessage());
     }
 }
开发者ID:4ZP6Capstone2015,项目名称:ampersand,代码行数:31,代码来源:ExecEngineApi.php

示例8: View

		public function View(){
			if (!Session::singleton()->ValidateSession()) {
				HttpHandler::redirect('/warbook/login/form');
			} else {
				$this->view->View();
			}
			
		}
开发者ID:suavid,项目名称:warbook,代码行数:8,代码来源:Home.php

示例9: updateModules

function updateModules($id = '') {
    if ($id == '')
        $str = F_updateModules(Session::singleton()->getUser());
    else
        $str = F_updateModules($id, true);
    if ($str != "") {
        $MODULES = unserialize(base64_decode($str));
    }
}
开发者ID:suavid,项目名称:terceros,代码行数:9,代码来源:modules.php

示例10: e403

 public function e403() {
     BM::singleton()->getObject('temp')->buildFromTemplates('template_nofixed.html');
     template()->addTemplateBit('content', 'e403.html');
     BM::singleton()->getObject('temp')->getPage()->setTitle("Acceso restringido");
     BM::singleton()->getObject('temp')->getPage()->addEstigma("username", Session::singleton()->getUser());
     BM::singleton()->getObject('temp')->getPage()->addEstigma("TITULO", "Error 403");
     BM::singleton()->getObject('temp')->parseExtras();
     BM::singleton()->getObject('temp')->parseOutput();
     print BM::singleton()->getObject('temp')->getPage()->getContent();
 }
开发者ID:suavid,项目名称:warbook,代码行数:10,代码来源:error.php

示例11: terceros

 public function terceros(){
     template()->buildFromTemplates('template_nofixed.html');
     page()->setTitle('Registrar proveedor');
     template()->addTemplateBit('content', 'terceros/terceros.html');
     page()->addEstigma("username", Session::singleton()->getUser());
     page()->addEstigma("TITULO", "Mantenimiento a terceros");
     page()->addEstigma("back_url", '/'.MODULE.'/terceros/principal');
     template()->parseOutput();
     template()->parseExtras();
     print page()->getContent();
 }
开发者ID:suavid,项目名称:terceros,代码行数:11,代码来源:terceros.php

示例12: login

 public function login() {
     if (empty($_POST)) {
         HttpHandler::redirect('/warbook/login/form');
     } else {
         BM::singleton()->getObject('db')->newConnection(HOST, USER, PASSWORD, DATABASE);
         $usuario = BM::singleton()->getObject('db')->sanitizeData($_POST['usuario']);
         $clave = md5($_POST['clave']);
         $query = "SELECT * FROM User WHERE EmailAddress='{$usuario}' AND AccessPassword='{$clave}'";
         //echo $query;
         BM::singleton()->getObject('db')->executeQuery($query);
         if (BM::singleton()->getObject('db')->getNumRows() > 0) {
             $level = 1;
             Session::singleton()->NewSession($usuario, $level);
             HttpHandler::redirect('/warbook/login/form');
         } else {
             HttpHandler::redirect('/warbook/login/form?error_id=2');
         }
     }
 }
开发者ID:suavid,项目名称:warbook,代码行数:19,代码来源:login.php

示例13: addViolation

 public static function addViolation($rule, $srcAtom, $tgtAtom)
 {
     $session = Session::singleton();
     $ruleHash = hash('md5', $rule['name']);
     $ruleMessage = $rule['message'] ? $rule['message'] : "Violation of rule '" . $rule['name'] . "'";
     $pairView = RuleEngine::getPairView($srcAtom, $rule['srcConcept'], $tgtAtom, $rule['tgtConcept'], $rule['pairView']);
     self::$violations[$ruleHash]['ruleMessage'] = $ruleMessage;
     self::$violations[$ruleHash]['interfaceIds'] = $pairView['interfaceIds'];
     $violationMessage = empty($pairView['violationMessage']) ? $srcAtom . " - " . $tgtAtom : $pairView['violationMessage'];
     // Make links to interfaces
     $links = array();
     foreach ($session->getInterfacesToReadConcept($rule['srcConcept']) as $interface) {
         $links[] = '#/' . $interface->id . '/' . $srcAtom;
     }
     foreach ($session->getInterfacesToReadConcept($rule['tgtConcept']) as $interface) {
         $links[] = '#/' . $interface->id . '/' . $tgtAtom;
     }
     $links = array_unique($links);
     self::$violations[$ruleHash]['tuples'][] = array('violationMessage' => $violationMessage, 'links' => $links);
     self::addLog($violationMessage . ' - ' . $violationMessage, 'VIOLATION');
 }
开发者ID:4ZP6Capstone2015,项目名称:ampersand,代码行数:21,代码来源:Notifications.php

示例14: handleauthresponse

 /**
  * Handle an authorization request response received from the configured OP.
  *
  * @param array $authparams Received parameters.
  */
 protected function handleauthresponse(array $authparams)
 {
     global $CFG, $SESSION, $STATEADDITIONALDATA, $USER, $THEME;
     $is_loggedin = $USER->is_logged_in();
     if (!isset($authparams['code'])) {
         throw new \AuthInstanceException(get_string('errorauthnoauthcode', 'auth.oidc'));
     }
     // Validate and expire state.
     $staterec = get_record('auth_oidc_state', 'state', $authparams['state']);
     if (empty($staterec)) {
         throw new \AuthInstanceException(get_string('errorauthunknownstate', 'auth.oidc'));
     }
     $orignonce = $staterec->nonce;
     $additionaldata = array();
     if (!empty($staterec->additionaldata)) {
         $additionaldata = @unserialize($staterec->additionaldata);
         if (!is_array($additionaldata)) {
             $additionaldata = array();
         }
     }
     $STATEADDITIONALDATA = $additionaldata;
     delete_records('auth_oidc_state', 'id', $staterec->id);
     // Get token from auth code.
     $client = $this->get_oidcclient();
     $tokenparams = $client->tokenrequest($authparams['code']);
     if (!isset($tokenparams['id_token'])) {
         throw new \AuthInstanceException(get_string('errorauthnoidtoken', 'auth.oidc'));
     }
     // Decode and verify idtoken.
     list($oidcuniqid, $idtoken) = $this->process_idtoken($tokenparams['id_token'], $orignonce);
     require_once $CFG->docroot . '/auth/lib.php';
     $SESSION = \Session::singleton();
     $USER = new \LiveUser();
     $THEME = new \Theme($USER);
     $instanceid = $this->detect_auth_instance($idtoken);
     // Can't continue if we didn't find an auth instance.
     if (empty($instanceid)) {
         throw new \UserNotFoundException(get_string('errorbadinstitution', 'auth.oidc'));
     }
     $auth = new \AuthOidc($instanceid);
     $can_login = $auth->request_user_authorise($oidcuniqid, $tokenparams, $idtoken);
     if ($can_login === true) {
         redirect('/');
     } else {
         // Office 365 uses "upn".
         $oidcusername = $oidcuniqid;
         $upn = $idtoken->claim('upn');
         if (!empty($upn)) {
             $oidcusername = $upn;
         }
         $SESSION->set('auth_oidc_linkdata', array('authinstance' => $instanceid, 'oidcusername' => $oidcusername));
         redirect('/auth/oidc/link.php');
     }
 }
开发者ID:remotelearner,项目名称:mahara-auth_oidc,代码行数:59,代码来源:authcode.php

示例15: closeTransaction

 public function closeTransaction($succesMessage = 'Updated', $checkAllConjucts = true, $databaseCommit = false, $setNewContent = true)
 {
     $session = Session::singleton();
     Hooks::callHooks('preDatabaseCloseTransaction', get_defined_vars());
     Notifications::addLog('========================= CLOSING TRANSACTION =========================', 'DATABASE');
     if ($checkAllConjucts) {
         Notifications::addLog("Check all conjuncts", 'DATABASE');
         // Evaluate all invariant conjuncts. Conjuncts are cached.
         $invariantRulesHold = RuleEngine::checkInvariantRules();
         // Evaluate all signal conjuncts. Conjuncts are cached
         RuleEngine::checkProcessRules();
     } else {
         Notifications::addLog("Check all affected conjuncts", 'DATABASE');
         // Evaluate all affected invariant conjuncts. Conjuncts are cached.
         $invariantRulesHold = RuleEngine::checkInvariantRules(RuleEngine::getAffectedInvConjuncts($this->affectedConcepts, $this->affectedRelations), true);
         // Evaluate all affected signal conjuncts. Conjuncts are cached
         RuleEngine::checkConjuncts(RuleEngine::getAffectedSigConjuncts($this->affectedConcepts, $this->affectedRelations), true);
         // Check only those process rules that are relevant for the activate roles
         RuleEngine::checkProcessRules($session);
     }
     unset($this->affectedConcepts, $this->affectedRelations);
     $this->affectedConcepts = array();
     $this->affectedRelations = array();
     if ($setNewContent && isset($session->atom)) {
         $session->atom->setNewContent($session->interface);
     }
     // e.g. not needed in Atom::delete() function
     if ($invariantRulesHold && $databaseCommit) {
         $this->commitTransaction();
         // commit database transaction
         Notifications::addSuccess($succesMessage);
     } elseif (Config::get('ignoreInvariantViolations', 'transactions') && COMMIT_INV_VIOLATIONS) {
         $this->commitTransaction();
         Notifications::addError("Transaction committed with invariant violations");
     } elseif ($invariantRulesHold) {
         $this->rollbackTransaction();
         // rollback database transaction
         Notifications::addInfo($succesMessage);
     } else {
         $this->rollbackTransaction();
         // rollback database transaction
     }
     Hooks::callHooks('postDatabaseCloseTransaction', get_defined_vars());
     return $invariantRulesHold;
 }
开发者ID:4ZP6Capstone2015,项目名称:ampersand,代码行数:45,代码来源:Database.php


注:本文中的Session::singleton方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。