function ExitApplication($token)
 {
     if (!empty($token)) {
         $session = new Sessions();
         $session->ClearSession($token);
     }
     return;
 }
 function isAdminSess()
 {
     $sessId = session_id();
     $session = new Sessions();
     $dbSessId = $session->sessionValid($sessId);
     $myUser = null;
     if (($dbData = $session->dataField($sessId)) != null) {
         $myUser = $session->isAdmin($dbData);
     }
     if (!isset($dbSessId) || !isset($sessId) || !isset($myUser) || $sessId != $dbSessId) {
         print "forwarded to the logout.php <br>";
         header("Location: logout.php");
     }
 }
示例#3
0
 /**
  * Check token submitted
  * @param $token
  * @return bool
  */
 public static function checkCRF($token)
 {
     if (!$token) {
         return false;
     }
     return Sessions::get('current_token') != trim($token) ? false : true;
 }
示例#4
0
 public static function getHandler()
 {
     if (self::$handler === false) {
         self::$handler = new Sessions();
     }
     return self::$handler;
 }
示例#5
0
 public function authenticate()
 {
     $nick = strtolower($this->username);
     $user = Users::model()->find('LOWER(email)=?', array($nick));
     if ($user === null) {
         $this->errorCode = self::ERROR_USERNAME_INVALID;
     } elseif (!$user->validatePassword($this->password, $user->salt)) {
         $this->errorCode = self::ERROR_PASSWORD_INVALID;
     } elseif ($user->status == 0) {
         $this->errorCode = self::ERROR_PASSWORD_INVALID;
         return 2;
     } elseif ($user->status == 4) {
         // user is banned
         $this->errorCode = self::ERROR_PASSWORD_INVALID;
         return 3;
     } else {
         $this->_id = $user->id;
         $this->username = $user->email;
         $this->setState('isAdmin', $user->status == 3);
         $this->setState('permissions', $user->status);
         $this->setState('nick', $user->nick);
         $this->setState('session_key', md5($user->email . time() . uniqid() . $user->salt));
         $this->setState('user_ip', Yii::app()->request->userHostAddress);
         Sessions::model()->deleteAllByAttributes(array('user_id' => $user->id));
         $this->errorCode = self::ERROR_NONE;
     }
     return $this->errorCode == self::ERROR_NONE;
 }
示例#6
0
 public function Session($Name, $Value = null)
 {
     $SESSIONS = new Sessions();
     if ($Value) {
         $SESSIONS->{$Name} = $Value;
         $SESSIONS->Update();
     } else {
         $Value = $SESSIONS->Get($Name);
         if ($Value) {
             $SESSIONS->{$Name} = $Value;
             $SESSIONS->Update();
         }
     }
     unset($SESSIONS);
     return $Value;
 }
示例#7
0
 /**
  * 检查用户是否已经登录
  * @param unknown_type $username
  */
 public function checkLoginState($username)
 {
     $string = 's:' . strlen($username) . ':"' . $username . '"';
     $criteria = new CDbCriteria();
     $criteria->addSearchCondition('data', $string);
     $model = Sessions::model()->find($criteria);
     return $model;
 }
示例#8
0
 public function __construct()
 {
     parent::__construct();
     if ($this->config['cache_dir'][0] != '/') {
         $this->config['cache_dir'] = '/' . $this->config['cache_dir'];
     }
     $this->cache_directory = $this->config['cache_dir'];
 }
示例#9
0
 public function destroy($id)
 {
     apc_delete($this->prefix . $id);
     if (!empty($this->db_link)) {
         parent::destroy($id);
     }
     return true;
 }
示例#10
0
 public function logout()
 {
     /*
      * compares session token against get method to see if it's the actual user
      */
     if (Sessions::get('token') == Requests::get('token')) {
         Sessions::destroy();
     }
 }
示例#11
0
 public static function getOnlineUsers()
 {
     $sessions = Sessions::model()->findAll();
     $temp = array();
     foreach ($sessions as $session) {
         $temp[] = $session->user;
     }
     return $temp;
 }
示例#12
0
function adminLoginNow()
{
    $username = $_REQUEST['login_user'];
    $password = $_REQUEST['login_password'];
    $admin = new administrator();
    $admin->setUsername($username);
    $data = $admin->getAdminFromUsername();
    if (count($data) > 0) {
        $admin->extractor($data);
        if ($admin->password() == md5($password)) {
            $session = new Sessions();
            $session->setAdminLoginSessions($admin->id(), $admin->name(), $admin->email());
            Common::jsonSuccess("Success");
        } else {
            Common::jsonError("Login Error");
        }
    } else {
        Common::jsonError("Login Error");
    }
}
示例#13
0
function updateMainCityImages()
{
    $maincity = new MainCity();
    $session = new Sessions();
    $maincity->setMainCityId($session->getLastMainCityId());
    $data = $maincity->getMainCityFromId();
    $maincity->extractor($data);
    $imgs = $maincity->mainCityImage();
    if ($imgs != "") {
        $imgs = $imgs . ',' . $_REQUEST['images'];
    } else {
        $imgs = $_REQUEST['images'];
    }
    $maincity->setMainCityImage($imgs);
    if ($maincity->updateMainCityImages()) {
        Common::jsonSuccess("Main City Update Successfully!");
    } else {
        Common::jsonError("Error");
    }
}
示例#14
0
 function __isAuthenticated()
 {
     return true;
     if (array_key_exists('HTTP_AUTH_KEY', $_SERVER)) {
         $authKey = $_SERVER['HTTP_AUTH_KEY'];
     } elseif (array_key_exists('auth_key', $_GET)) {
         $authKey = $_GET['auth_key'];
     } else {
         throw new RestException(401, 'Authentication Required');
     }
     $sessions = new Sessions();
     $session = $sessions->verifySession($authKey);
     if (is_array($session)) {
         $sesInfo = $sessions->getSessionUser($authKey);
         self::$userId = $sesInfo['USR_UID'];
         self::$authKey = $authKey;
         return true;
     }
     throw new RestException(401, 'Wrong Credentials!');
 }
示例#15
0
文件: Cams.php 项目: mrtos/OpenNVR
 public function afterDelete()
 {
     parent::afterDelete();
     $shared = Shared::model()->findAllByAttributes(array('cam_id' => $this->id));
     foreach ($shared as $s) {
         Notifications::model()->deleteAllByAttributes(array('shared_id' => $s->id, 'status' => 1));
         $s->delete();
     }
     Sessions::model()->deleteAllByAttributes(array('real_id' => $this->id));
     Sessions::model()->deleteAllByAttributes(array('real_id' => $this->id . '_low'));
     return true;
 }
示例#16
0
 public function add()
 {
     $name = $_POST["name"];
     $lastname = $_POST["lastname"];
     $email = $_POST["email"];
     $pass = $_POST["pass"];
     $conf = $_POST["conf"];
     if ($name == null or $lastname == null or $email == null or $pass == null or $conf == null) {
         header("location: Unirse.php?error=1");
     } else {
         if ($pass != $conf) {
             header("location: Unirse.php?error=2");
         } else {
             $sql = "select * from usuario where Email='" . $email . "'";
             $result = $this->cone->procedure($sql);
             if ($result) {
                 if (!$result->fetch_assoc()) {
                     $sql = "select (count(idUsuario)+1) as 'newId' from usuario";
                     $result = $this->cone->procedure($sql);
                     if ($result) {
                         if ($row = $result->fetch_assoc()) {
                             $sql = "insert into Usuario values (" . $row['newId'] . ",'" . $name . "','" . $lastname . "','" . $email . "','" . $pass . "',null)";
                             $rs = $this->cone->procedure($sql);
                             if ($rs) {
                                 $ses = new Sessions();
                                 $ses->init();
                                 $ses->set("user", $email);
                                 header("location: ../User/index.php");
                             } else {
                                 header("location: Unirse.php?error=3");
                             }
                         }
                     }
                 } else {
                     header("location: Unirse.php?error=4");
                 }
             }
         }
     }
 }
示例#17
0
 public static function loginCheck()
 {
     global $db;
     if (Sessions::get("login")) {
         $username = Session::get("login")['username'];
         if ($username) {
             $kontrol = $db->query("SELECT username FROM username = '******'")->rowCount();
             return $kontrol ? true : false;
         }
     } else {
         return false;
     }
 }
示例#18
0
 function run()
 {
     /**
      * only run cron if delay time has expired
      */
     if (time() - $_SESSION['cron']['time'] > $_SESSION['cron']['delay'] || $_SESSION['inactive']['start']) {
         /**
          * stuff to run
          */
         $s = new Sessions();
         $p = new Patient();
         foreach ($s->logoutInactiveUsers() as $user) {
             $p->patientChartInByUserId($user['uid']);
         }
         /**
          * set cron start to false reset cron time to current time
          */
         $_SESSION['inactive']['start'] = false;
         $_SESSION['cron']['time'] = time();
         return array('success' => true, 'ran' => true);
     }
     return array('success' => true, 'ran' => false);
 }
示例#19
0
 public function login_in2($datos = FALSE)
 {
     $objdata = new Database();
     $sth = $objdata->prepare('SELECT * FROM users U inner join profiles P ' . 'ON U.idProf = P.idProfile ' . 'WHERE U.idUser = :id');
     $sth->execute(array(':id' => $datos));
     $data = $sth->fetch();
     $count = $sth->rowCount();
     if ($count > 0) {
         require 'sessions.php';
         $objSess = new Sessions();
         $objSess->init();
         $objSess->set('login', $data['logUser']);
         $objSess->set('idpro', $data['idProf']);
         $objSess->set('profi', $data['profName']);
         switch ($data['profName']) {
             case 'Admin':
                 header('location: ' . URL . 'admin/');
                 break;
             case 'Standard':
                 header('location: ' . URL . 'dashboard/');
                 break;
         }
     }
 }
示例#20
0
 public function actionCheck($id = '', $clientAddr = '')
 {
     if (!$id && !$clientAddr && isset($_POST['data'])) {
         $data = json_decode($_POST['data'], 1);
         $id = $data['id'];
         $clientAddr = $data['clientAddr'];
     }
     $response = array('result' => 'fail', 'id' => '');
     if (empty($id) && $this->validateRequest('id', $id)) {
         $response['id'] = 'empty or invalid id';
         $this->renderJSON($response);
     }
     if (empty($clientAddr) && $this->validateRequest('ip', $clientAddr)) {
         $response['id'] = 'empty or invalid ip';
         $this->renderJSON($response);
     }
     $session_id = Sessions::model()->findByAttributes(array('session_id' => $id), array('select' => 'real_id, ip'));
     if ($session_id) {
         $cam = Cams::model()->findByPK($session_id->real_id);
         if ($cam->is_public) {
             $response['result'] = 'success';
             $response['id'] = $session_id->real_id;
         } elseif ($session_id->ip == $clientAddr) {
             $response['result'] = 'success';
             $response['id'] = $session_id->real_id;
         } else {
             $response['id'] = 'huge fail';
         }
     } else {
         $cam = Cams::model()->findByPK($id);
         if ($cam && $cam->is_public) {
             $response['result'] = 'success';
             $response['id'] = $id;
         } else {
             $response['id'] = 'huge fail';
         }
     }
     $this->renderJSON($response);
 }
<?php

include "../../../../bdConnection.php";
require '../extras/class/sessions.php';
$objses = new Sessions();
$objses->init();
$user = isset($_SESSION['user']) ? $_SESSION['user'] : null;
$sql = "SELECT Type FROM user, role WHERE user.Name = '{$user}' AND user.Role = role.Type";
$cs = mysql_query($sql, $cn);
while ($resul = mysql_fetch_array($cs)) {
    $consul1 = $resul[0];
}
$sql1 = "SELECT lab.id_lab FROM user,lab WHERE user.Name ='{$user}' AND user.lab=lab.id_lab";
$cs1 = mysql_query($sql1, $cn);
while ($resul = mysql_fetch_array($cs1)) {
    $consul2 = $resul[0];
}
?>

<script type="text/javascript">
    
 
 
 <!--
function mostrarReferencia(){
//Si la opcion con id Conocido_1 (dentro del documento > formulario con name fcontacto >     y a la vez dentro del array de Conocido) esta activada
if (document.frm_per.nom_per[4].checked == true) {
//muestra (cambiando la propiedad display del estilo) el div con id 'desdeotro'
document.getElementById('desdeotro').style.display='block';
//por el contrario, si no esta seleccionada
} else {
示例#22
0
function loginClient()
{
    $username = $_REQUEST['client_username_log'];
    $password = $_REQUEST['client_password_log'];
    $client = new Clients();
    $session = new Sessions();
    $client->setClientUsername($username);
    $data = $client->getClientFromUsername();
    //echo count($data);
    if (count($data) > 0) {
        $client->extractor($data);
        if (strcmp($client->clientPassword(), md5($password)) == 0) {
            $session->setClientLoginSessions($client->clientId(), $client->clientTitle(), $client->clientFirstName(), $client->clientLastName());
            if ($_SESSION['booked'] != '') {
                echo 'booked';
                //die('booked');
            } else {
                echo 2;
                //die('accounts');
            }
        } else {
            echo 3;
        }
    } else {
        Common::jsonError("Login Error");
    }
}
示例#23
0
 /**
  * Return the System defined constants and Application variables
  *   Constants: SYS_*
  *   Sessions : USER_* , URS_*
  */
 public function getSystemConstants($params = null)
 {
     $t1 = G::microtime_float();
     $sysCon = array();
     if (defined("SYS_LANG")) {
         $sysCon["SYS_LANG"] = SYS_LANG;
     }
     if (defined("SYS_SKIN")) {
         $sysCon["SYS_SKIN"] = SYS_SKIN;
     }
     if (defined("SYS_SYS")) {
         $sysCon["SYS_SYS"] = SYS_SYS;
     }
     $sysCon["APPLICATION"] = isset($_SESSION["APPLICATION"]) ? $_SESSION["APPLICATION"] : "";
     $sysCon["PROCESS"] = isset($_SESSION["PROCESS"]) ? $_SESSION["PROCESS"] : "";
     $sysCon["TASK"] = isset($_SESSION["TASK"]) ? $_SESSION["TASK"] : "";
     $sysCon["INDEX"] = isset($_SESSION["INDEX"]) ? $_SESSION["INDEX"] : "";
     $sysCon["USER_LOGGED"] = isset($_SESSION["USER_LOGGED"]) ? $_SESSION["USER_LOGGED"] : "";
     $sysCon["USR_USERNAME"] = isset($_SESSION["USR_USERNAME"]) ? $_SESSION["USR_USERNAME"] : "";
     //###############################################################################################
     // Added for compatibility betweek aplication called from web Entry that uses just WS functions
     //###############################################################################################
     if ($params != null) {
         if (isset($params->option)) {
             switch ($params->option) {
                 case "STORED SESSION":
                     if (isset($params->SID)) {
                         G::LoadClass("sessions");
                         $oSessions = new Sessions($params->SID);
                         $sysCon = array_merge($sysCon, $oSessions->getGlobals());
                     }
                     break;
             }
         }
         if (isset($params->appData) && is_array($params->appData)) {
             $sysCon["APPLICATION"] = $params->appData["APPLICATION"];
             $sysCon["PROCESS"] = $params->appData["PROCESS"];
             $sysCon["TASK"] = $params->appData["TASK"];
             $sysCon["INDEX"] = $params->appData["INDEX"];
             if (empty($sysCon["USER_LOGGED"])) {
                 $sysCon["USER_LOGGED"] = $params->appData["USER_LOGGED"];
                 $sysCon["USR_USERNAME"] = $params->appData["USR_USERNAME"];
             }
         }
     }
     return $sysCon;
 }
示例#24
0
<?php

require "Sessions.php";
$ses = new Sessions();
$ses->init();
$user = isset($_SESSION['user']) ? $_SESSION['user'] : null;
if ($user != null) {
    $ses->destroy();
    header("location: ../Index.php");
}
示例#25
0
 $noLoginFiles[] = 'autoinstallPlugins';
 $noLoginFiles[] = 'heartbeatStatus';
 $noLoginFiles[] = 'showLogoFile';
 $noLoginFiles[] = 'forgotPassword';
 $noLoginFiles[] = 'retrivePassword';
 $noLoginFiles[] = 'defaultAjaxDynaform';
 $noLoginFiles[] = 'dynaforms_checkDependentFields';
 $noLoginFolders[] = 'services';
 $noLoginFolders[] = 'tracker';
 $noLoginFolders[] = 'installer';
 // This sentence is used when you lost the Session
 if (!in_array(SYS_TARGET, $noLoginFiles) && !in_array(SYS_COLLECTION, $noLoginFolders) && $bWE != true && $collectionPlugin != 'services') {
     $bRedirect = true;
     if (isset($_GET['sid'])) {
         G::LoadClass('sessions');
         $oSessions = new Sessions();
         if ($aSession = $oSessions->verifySession($_GET['sid'])) {
             require_once 'classes/model/Users.php';
             $oUser = new Users();
             $aUser = $oUser->load($aSession['USR_UID']);
             $_SESSION['USER_LOGGED'] = $aUser['USR_UID'];
             $_SESSION['USR_USERNAME'] = $aUser['USR_USERNAME'];
             $bRedirect = false;
             $RBAC->initRBAC();
             $RBAC->loadUserRolePermission($RBAC->sSystem, $_SESSION['USER_LOGGED']);
             $memKey = 'rbacSession' . session_id();
             $memcache->set($memKey, $RBAC->aUserInfo, PMmemcached::EIGHT_HOURS);
         }
     }
     if ($bRedirect) {
         if (substr(SYS_SKIN, 0, 2) == 'ux' && SYS_SKIN != 'uxs') {
示例#26
0
<?php

$pagetitle = "My Sessions";
require_once 'includes/header.php';
echo '<h3 class="text-center">My Sessions</h3><br>';
$s = new Sessions();
?>

<div class="row">
	<div class="col-md-10 col-md-offset-1">
		<div class="panel panel-primary">
			<div class="panel-heading">
				<h3 class="panel-title">Forthcoming Sessions</h3>
			</div>
			<div class="panel-body">
				<?php 
try {
    $sessions = $s->get(array('student' => $user->data()->id, 'future' => 1));
    if (!empty($sessions)) {
        ?>
					<table class="table table-condensed table-striped">
						<tr>
							<td>
								<strong>Mentor</strong>
							</td>
							<td>
								<strong>Program</strong>
							</td>
							<td>
								<strong>Position</strong>
							</td>
示例#27
0
<?php
    define('_MEXEC', 'OK');
    require_once("../system/load.php");
    include("upload_class.php"); //classes is the map where the class file is stored

    $session = new Sessions();
    $upload = new file_upload();

    $upload->upload_dir = '../uploads/hotel-gal/';
    $upload->extensions = array('.png', '.jpg'); // specify the allowed extensions here
    $upload->rename_file = true;

    $image_list = array();

    $hotel_file_id = $_REQUEST['hotel_file_id'];

    if (!empty($_FILES) && $hotel_file_id != '') {
        $upload->the_temp_file = $_FILES['userfile']['tmp_name'];
        $upload->the_file = $_FILES['userfile']['name'];
        $upload->http_error = $_FILES['userfile']['error'];
        $upload->do_filename_check = 'y'; // use this boolean to check for a valid filename
        $upload->hotel_image_id = $hotel_file_id . '_' . $_FILES['userfile']['name'];

        if ($upload->upload()) {
            echo '<div id="status">success</div>';
            echo '<div id="message">' . $upload->file_copy . ' Successfully Uploaded</div>';
            //return the upload file
            echo '<div id="uploadedfile">' . $upload->file_copy . '</div>';
            //---------------thumbanail-------------------
            $src = "../uploads/hotel-gal/" . $upload->file_copy;
            $dest = "../uploads/hotels/thumbnails/" . $upload->file_copy;
示例#28
0
 /**
  * This function checks if the XML-RPC session key is valid. If yes returns true, otherwise false and sends an error message with error code 1
  *
  * @access protected
  * @param string $sSessionKey Auth credentials
  * @return bool
  */
 protected function _checkSessionKey($sSessionKey)
 {
     $criteria = new CDbCriteria();
     $criteria->condition = 'expire < ' . time();
     Sessions::model()->deleteAll($criteria);
     $oResult = Sessions::model()->findByPk($sSessionKey);
     if (is_null($oResult)) {
         return false;
     } else {
         $this->_jumpStartSession($oResult->data);
         return true;
     }
 }
示例#29
0
文件: login.php 项目: VSG24/ccms
<?php

require_once '../c_config.php';
$session = new Sessions();
$i = null;
// just a helper for error checking
if (isset($_POST["submit"])) {
    $username = $_POST["username"];
    $password = $_POST["password"];
    if (verifyUser($username, $password)) {
        $id = Users::getIdByUsername($username);
        Cookies::setLoginCookies($id, 30);
        // remember for 30 dayz!
        $session->setSession($id, $username);
        $i = false;
    } else {
        $i = true;
    }
}
?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <script src="js/jquery.min.js"></script>
    <link href="css/login.css" rel='stylesheet' type='text/css' />
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <script type="application/x-javascript"> addEventListener("load", function() { setTimeout(hideURLbar, 0); }, false); function hideURLbar(){ window.scrollTo(0,1); } </script>
    <title>ccms Admin Login</title>
</head>
示例#30
0
 /**
  * 检查登录状态
  */
 public function actionCheckLoginState()
 {
     $username = $_GET['username'];
     $string = 's:' . strlen($username) . ':"' . $username . '"';
     $criteria = new CDbCriteria();
     $criteria->addSearchCondition('data', $string);
     $model = Sessions::model()->find($criteria);
     if ($model) {
         $session = UtilSession::parseSession(Yii::app()->session->readSession($model->id));
         $ip = $session['loginIp'];
         //			$ip = '125.68.51.203';
         $region = UtilNet::getIPLoc($ip);
         $result = array('id' => $model->id, 'msg' => "<b>检测到您的帐号当前已经在" . $region->province . '.' . $region->city . '.' . $region->district . "登录</b><br />是否要注销,重新登录");
         echo json_encode($result);
     } else {
         $result = array('msg' => 'false');
         echo json_encode($result);
     }
 }