public function submit() { $this->usuario = Request::getPost('usuario'); $this->contrasena = md5(Request::getPost('contrasena')); $this->recordar = Request::getPost('recordar', 0); list($this->validationFlag, $this->validation) = Validation::check(array('usuario' => 'required', 'contrasena' => 'required')); if ($this->validationFlag) { $idPersonas = Db::one("SELECT personas.id_personas\n FROM personas\n WHERE personas.usuario = '{$this->usuario}'\n AND personas.contrasena = '{$this->contrasena}'\n LIMIT 1"); if ($idPersonas) { Session::unregister(); Session::register($this->usuario, $this->contrasena, $this->recordar == 1); Response::setRedirect('/'); } $this->validationFlag = false; } }
$session->checkSession('client'); $client = $session->get('client'); $pdo = PDOConnection::getInstance(); /* Atualiza tempo cliente */ $stmt = $pdo->prepare('UPDATE client SET time = :time WHERE client_id = :client_id LIMIT 1'); $stmt->bindValue('client_id', $client['client_id']); $stmt->bindValue('time', $lifeTimeClient); $stmt->execute(); /* Total da fila de espera */ $stmt = $pdo->prepare('SELECT COUNT(*) FROM client WHERE client_id < :client_id AND status = :status AND time > :time'); $stmt->bindValue('client_id', $client['client_id']); $stmt->bindValue('time', $lifeTime); $stmt->bindValue('status', 1); $stmt->execute(); $total = $stmt->fetchColumn(); /* Busca status do cliente */ $stmt = $pdo->prepare('SELECT * FROM client WHERE client_id = :client_id'); $stmt->bindValue('client_id', $client['client_id']); $stmt->execute(); $client_status = $stmt->fetch(); /* Inicia atendimento */ $user = NULL; if ($client_status['status'] == 2) { $stmt = $pdo->prepare('SELECT * FROM user WHERE user_id = :user_id'); $stmt->bindValue('user_id', $client_status['user_id']); $stmt->execute(); $user = $stmt->fetch(); $session->register('client_user', $user); } $json = array('total' => $total, 'status' => $client_status['status'], 'user' => $user); print json_encode($json);
/** * Initialise the SiteNavigation * @access public * @static */ public static function init($handler_tree) { $nav = new SiteNavigation($handler_tree); Session::register('site_navigation', $nav); }
function setIDField($class, $name) { Session::register('relIDField_' . $class, $name); }
/** * Set the user of the application * @param SystemUser - a class that implements the SystemUser interface * @access public * @static */ public static function setUser($user) { if ($user instanceof SystemUser) { $app = Application::current(); $app->user = $user; Session::register('application_user', $user); } else { throw new Exception('The user passed to Application::setUser must implement the SystemUser interface, or inherit from a class which does'); } }
$CORE->register_Module('character', 'SERVER', $server_config['CORE']); $CORE->register_Module('sendmail', 'SERVER', $server_config['CORE']); } catch (Exception $e) { echo 'Caught exception: ', $e->getMessage(), "\n"; } //open database connection $DB = $CORE->DatabaseConnection(); //Open database connection to auth $AUTH_DB = $CORE->AuthDatabaseConnection(); //Load necessary server modules $CORE->load_ServerModule('columns'); $CORE->load_ServerModule('account'); //starting the session class and defining it $SESSION = new Session(); //setting up session handlers from our PHP Class sessions $SESSION->register(); //setup the security class $SECURITY = new Security(); //Unregistring globals for security $SECURITY->unregisterGlobals(); //filter the request methods $SECURITY->RestrictHttpMethods(array('POST', 'GET')); //check if the session has expired $SECURITY->CheckSessionLife(); //setup Current User class $CURUSER = new CURUSER(); //setup the Cache $CACHE = new Cache(array('repo' => $config['RootPath'] . '/cache')); ############################################## ## Make an User Check server_Account::userCheck(true);
user_id, status, typing, name, email, ip_address, call_date , start_call_date , time ) VALUES ( :user_id, :status, :typing, :name, :email, :ip_address, NOW(), NULL, :time )')->execute($client_insert); $client_insert['client_id'] = $pdo->lastInsertId(); /* Hitórico */ $pdo->prepare('INSERT INTO client_history ( client_id, user_id, status, typing, name, email, ip_address, call_date , start_call_date , time ) VALUES ( :client_id, :user_id, :status, :typing, :name, :email, :ip_address, NOW(), NULL, :time )')->execute($client_insert); /* Sessão */ $client_insert['name'] = $name; $user = array('user_id' => 0, 'name' => NULL); $session = new Session(); $session->register('client', $client_insert); $session->register('client_user', $user); header('Location: main.php'); exit; } else { $vld->addError('Já existe um cliente com o e-mail informado'); } } } $tpl->assign('error', $vld->getErrorsAsHtml()); $stmt = $pdo->prepare('SELECT COUNT(*) FROM user WHERE time > :time AND status = :status'); $stmt->bindValue('time', $lifeTime); $stmt->bindValue('status', 1); $stmt->execute(); if ($stmt->fetchColumn() == 0) { $tpl->block('info');
$stmt->bindParam('user', $user); $stmt->bindParam('password', sha1($password . $systemPasswordSalt)); $stmt->bindValue('status', 1); $stmt->execute(); if ($stmt->fetchColumn() > 0) { $stmt = $pdo->prepare('SELECT COUNT(*) FROM user WHERE user = :user AND time > :time AND status = :status'); $stmt->bindParam('user', $user); $stmt->bindValue('time', $lifeTime); $stmt->bindValue('status', 1); $stmt->execute(); if ($stmt->fetchColumn() == 0) { $stmt = $pdo->prepare('SELECT * FROM user WHERE user = :user AND password = :password AND status = :status LIMIT 1'); $stmt->bindParam('user', $user); $stmt->bindParam('password', sha1($password . $systemPasswordSalt)); $stmt->bindValue('status', 1); $stmt->execute(); $user = $stmt->fetch(PDO::FETCH_ASSOC); $session = new Session(); $session->register('user', $user); header('Location: main.php'); exit; } else { $vld->addError('Já existe um usuário logado com os dados informados'); } } else { $vld->addError('Usuário ou senha inválido'); } } } $tpl->assign('error', $vld->getErrorsAsHtml()); $tpl->show();
public function impersonateUser($user) { Session::register('not_impersonated_user', Application::user()); Application::setUser($user); SiteNavigation::init($user->getHandlerTree()); }
} $title = __('SignInTitle'); $error = array(); if (isset($_GET['email']) && isEmail($_GET['email'])) { $email = $_GET['email']; } if (!empty($_POST)) { $email = $_POST['email']; $password = $_POST['password']; if (!isEmail($email)) { $error['email'] = true; } if (strlen($password) < 6) { $error['password'] = true; } if (empty($error)) { $data = Db::fetchRow("SELECT uid, email, password\n FROM users\n WHERE email = '{$email}'\n AND password = MD5('{$password}')"); if (empty($data)) { $error['signin'] = true; } } if (empty($error) && $data) { Session::register($data); if (isset($_POST['next'])) { header("Location: {$_POST['next']}"); } else { header("Location: {$config['root']}dd/"); } } } require_once "{$root}/themes/{$theme}/signin.php";