Пример #1
0
 public function Delete()
 {
     global $obj, $model, $param1;
     include_once 'Model/loginhistory.php';
     $model = new Loginhistory();
     $model->Id = $param1;
     if ($model->Delete()) {
         print '<span class="success">Loginhistory Updated</span>';
     } else {
         print '<span class="error">' . $model->Error . '</span>';
     }
     include_once 'View/Loginhistory/index.php';
 }
Пример #2
0
 public function saveLoginHistory($rtn)
 {
     $loginhistory = new Loginhistory;
     $loginhistory->login_id = $rtn->login->id;
     $loginhistory->role_id = $rtn->role->id;
     $loginhistory->login_time = date($this->datetimemysqlformatYMDHIS);
     $result = $loginhistory->save();
     return $result;
 }
/**
* Returns the data model based on the primary key given in the GET variable.
* If the data model is not found, an HTTP exception will be raised.
* @param integer the ID of the model to be loaded
*/
public function loadModel($id)
{
$model=Loginhistory::model()->findByPk($id);
if($model===null)
throw new CHttpException(404,'The requested page does not exist.');
return $model;
}
Пример #4
0
    public function doLogout()
    {
        $loginid = Yii::app()->user->login->id;
        $roleid = Yii::app()->user->role->id;
//        $count = Loginhistory::model()->update(
//                        Loginhistory::model()->tableName(), 
//                        array('logout_time' => date($this->datetimemysqlformatYMDHIS))
//                        ,'login_id = :loginid AND role_id=:roleid AND logout_time IS NULL'
//                        ,array(':loginid' => $loginid, ':roleid' => $roleid, )
//                );
        $criteria=new CDbCriteria;
        $criteria->addCondition('login_id = :loginid AND role_id=:roleid AND logout_time IS NULL');
        $criteria->params = array(':loginid' => $loginid, ':roleid' => $roleid, );
        $histories = Loginhistory::model()->findAll($criteria);
        foreach ($histories as $history)
        {
            $history->logout_time = date($this->datetimemysqlformatYMDHIS);
            $history->save();
        }
        Yii::app()->user->logout();
        if (!Yii::app()->request->isAjaxRequest) 
        {
            $this->redirect( Yii::app()->homeUrl );
        }
        else
        {
            Yii::app()->end();
        }
    }
Пример #5
0
if (strtolower($view) == "logout") {
    unset($_SESSION['username']);
    unset($_SESSION['usertype']);
    unset($_SESSION['userid']);
}
if (isset($_POST['btnLogin'])) {
    include_once 'Model/user.php';
    $model = new User();
    $model->Email = $_POST['Email'];
    $model->Password = $_POST['Password'];
    if ($model->Login()) {
        $_SESSION['username'] = $model->Name;
        $_SESSION['usertype'] = $model->Type;
        $_SESSION['userid'] = $model->Id;
        include_once 'Model/loginhistoty.php';
        $lh = new Loginhistory();
        $lh->UserId = $model->Id;
        if (!$lh->Insert()) {
        }
    }
}
?>

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Example of Twitter Bootstrap 3 Dropdowns within a Navbar</title>
<link rel="stylesheet" type="text/css" href="<?php 
print baseurl;
?>