/**
  * Register Form
  */
 public function actionRegister()
 {
     $register = new RegisterForm(ControllerCore::REQUIRE_CAPTCHA_SCENARIO);
     if (isset($_POST[CHtml::modelName($register)])) {
         $register->attributes = $_POST[CHtml::modelName($register)];
         if ($register->save()) {
             $form = new LoginUser();
             $form->username = $register->email;
             $form->password = $_POST[CHtml::modelName($register)]['password'];
             $form->rememberMe = 0;
             /**
              * Generate random Assignment for newly registered user
              */
             $user = $register->user;
             $criteria = new CDbCriteria();
             $criteria->with = ['corpusParseTreeConsensus'];
             $criteria->order = 'rand()';
             $ratio = ['definitive' => 5, 'challenge' => ['limit' => 15, 'range' => [1000, 2000]], 'corpus' => ['Tutorial' => 5]];
             $criteriaGolden = new CDbCriteria();
             $criteriaGolden->mergeWith($criteria);
             $criteriaGolden->addCondition('corpusParseTreeConsensus.corpusParseTreeStringID is not null');
             $criteriaGolden->limit = $ratio['definitive'];
             $stringsGolden = CorpusParseTreeString::model()->findAll($criteriaGolden);
             $criteriaChallenge = new CDbCriteria();
             $criteriaChallenge->mergeWith($criteria);
             $criteriaChallenge->addCondition('corpusParseTreeConsensus.corpusParseTreeStringID is null');
             $criteriaChallenge->addCondition('ID >= :min and ID <= :max');
             $criteriaChallenge->params = [':min' => $ratio['challenge']['range'][0], ':max' => $ratio['challenge']['range'][1]];
             $criteriaChallenge->limit = $ratio['challenge']['limit'];
             $stringsChallenge = CorpusParseTreeString::model()->findAll($criteriaChallenge);
             $stringsTutorial = [];
             foreach ($ratio['corpus'] as $corpusName => $limit) {
                 $criteriaTutorial = new CDbCriteria();
                 $criteriaTutorial->mergeWith($criteria);
                 $criteriaTutorial->with[] = 'corpusParseTree';
                 $criteriaTutorial->limit = $limit;
                 $criteriaTutorial->compare('corpusParseTree.name', $corpusName);
                 $stringsTutorial = array_merge($stringsTutorial, CorpusParseTreeString::model()->findAll($criteriaTutorial));
             }
             foreach ([$stringsTutorial, $stringsGolden, $stringsChallenge] as $parts) {
                 foreach ($parts as $string) {
                     /* @var $string CorpusParseTreeString */
                     $assigned = new StringAssigned();
                     $assigned->userID = $user->ID;
                     $assigned->corpusParseTreeStringID = $string->ID;
                     $assigned->save();
                 }
             }
             /**
              * End Generate random Assignment
              */
             if ($form->validate() && $form->login()) {
                 $this->emailVerify($register->user);
                 $this->redirect(['/parser']);
             }
         }
     }
     $this->render('register', ['register' => $register]);
 }
Пример #2
0
<?php 
include "model/LoginModel.php";
include "User_Controller.php";
if (isset($_POST['btnlogin'])) {
    $userController = new UserController();
    $username = $_POST['username'];
    $password = $_POST['password'];
    if ($username == "" || $password == "") {
        $userController->missingInputs();
    } else {
        $loginuser = new LoginUser($username, $password, "tblclientuser");
        $array = $loginuser->GetData();
        if ($array[1] != $username || $array[2] != $password) {
            $userController->wrongInputs();
        } else {
            $_SESSION['id'] = $array[0];
            $_SESSION['level'] = $array[4];
            echo '<script type="text/javascript">window.location="index.php"</script>';
        }
    }
}
Пример #3
0
<?php

$root = realpath($_SERVER["DOCUMENT_ROOT"]);
$self = $_SERVER["PHP_SELF"];
require_once "{$root}/shared/defaults.php";
require_once 'class/LoginUser.class.php';
require_once 'class/LoginApp.class.php';
if (!isset($user)) {
    $user = new LoginUser();
}
$referring_page = strtok($_SERVER["REQUEST_URI"], '?');
$app = new LoginApp(array("appurl" => $referring_page));
// If you're not logged in, redirect to signin page
if (!$user->userSet()) {
    if ($referring_page != '/shared/login/sorry.php') {
        $_SESSION["referring_page"] = $referring_page;
    }
    header("Location: /shared/login/signin.php");
}
// If you're pending, redirect to sign in with pending message
if ($user->pending == 1) {
    header("Location: /shared/login/signin.php?status=pending");
}
// If you don't have permission, redirect to sorry page
if (!$app->allow_all) {
    if (!$user->isUserPermitted($app->id) && $referring_page != '/shared/login/sorry.php') {
        $_SESSION["referring_page"] = $referring_page;
        header("Location: /shared/login/sorry.php");
    }
}
Пример #4
0
<?php

ini_set("displayerrors", 1);
//require_once 'databaseConnect.php';
function __autoload($class_name)
{
    include $class_name . '.php';
}
$obj = new LoginUser($_POST);
if (isset($_POST['submit'])) {
    $validate = $obj->validate();
}
$db = new databaseConnect();
?>
 
<!DOCTYPE html>
<html>
    <head>
    <title>login page</title>
    <link rel="stylesheet" type="text/css" href="../css/style.css"/>
     <h3 align = "center">loginpage</h3>
    
    </head>
    
      <body>
       <p> <?php 
if (isset($validate[errorFlag]) == false) {
    echo $validate['errorMessage'];
}
?>
</p>
Пример #5
0
 public function actionLogout()
 {
     if (isset(Yii::app()->user->id)) {
         LoginUser::model()->updateAll(array('status' => 0, 'log_out_time' => new CDbExpression('NOW()')), 'user_id=' . Yii::app()->user->id . ' AND status = 1');
     }
     //Yii::app()->session->destroy();
     if (Yii::app()->user->getState('parent_id')) {
         Yii::app()->user->logout();
         $this->redirect(array('parentlogin'));
     } else {
         Yii::app()->user->logout();
         $this->redirect('login');
     }
 }
Пример #6
0
<?php

ini_set("displayerrors", 1);
require_once 'databaseConnect.php';
function __autoload($class_name)
{
    include $class_name . '.php';
}
$obj = new LoginUser();
if (isset($_POST['submit'])) {
    $this->userName = $_POST['userName'];
    $this->password = $_POST['password'];
    $this->confirmPassword = $_POST['confirmPassword'];
    $this->mobileNo = $_POST['mobileNo'];
    $this->email = $_POST['email'];
    $this->day = $_POST['day'];
    $this->month = $_POST['month'];
    $this->year = $_POST['year'];
    $obj->validate($input);
}
?>
 
<!DOCTYPE html>
<html>
    <head>
    <title>login page</title>
    <link rel="stylesheet" type="text/css" href="../css/style.css"/>
     <h3 align = "center">loginpage</h3>
     <script type="text/javascript" src="../js/signupValidation.js"></script>
      <script type="text/javascript" src="../js/common.js"></script>
    </head>
Пример #7
0
    } else {
        if (!empty($emailmatches[1])) {
            $field = 'email';
        } else {
            $form->errors[] = "No user found with username or email <strong>" . $unvalue . "</strong>";
            $form->valid = false;
        }
    }
    if (isset($field)) {
        $userrow = db_get("SELECT * FROM login_user WHERE upper({$field}) = upper('{$unvalue}')", 'row');
        $passhashvalue = $userrow[0]['PASS'];
        $bcrypt = new Bcrypt(15);
        $isGood = $bcrypt->verify($_REQUEST['password'], $passhashvalue);
        if ($isGood) {
            $form->successMessage = "Successfully logged on! If you are not redirected, please <a href='welcome.php'>click here</a>";
            $user = new LoginUser();
            $user->setFromArray($userrow[0]);
            $user->sessionSet();
            $redirect = "welcome.php";
            if (isset($_SESSION["referring_page"]) && $_SESSION["referring_page"] != $_SERVER['REQUEST_URI']) {
                $redirect = $_SESSION["referring_page"];
            }
            header("Location: {$redirect}");
        } else {
            $form->errors[] = "Wrong password";
            $form->valid = false;
        }
    }
}
?>
<!DOCTYPE html>
Пример #8
0
<?php

$root = realpath($_SERVER["DOCUMENT_ROOT"]);
require_once "{$root}/shared/defaults.php";
require_once 'class/LoginUser.class.php';
$user = new LoginUser();
$form = $user->settingsForm(true);
if ($form->valid()) {
    // Basic form validation
    if ($_REQUEST['password1'] != $_REQUEST['password2']) {
        // Check if passwords are the same
        $form->errors[] = "Passwords are not the same.";
        $form->valid = false;
    }
    $email = $form->getElement("email");
    $emailvalue = $email->value;
    $emailmatches = db_get("SELECT 1 FROM login_user WHERE upper(email) = upper('{$emailvalue}')", 'column');
    if (!empty($emailmatches[1])) {
        // Check if username is taken
        $form->errors[] = "Email already taken.";
        $form->valid = false;
    }
    $username = $form->getElement("username");
    $unvalue = $username->value;
    $unmatches = db_get("SELECT 1 FROM login_user WHERE upper(username) = upper('{$unvalue}')", 'column');
    if (!empty($unmatches[1])) {
        // Check if email is taken
        $form->errors[] = "Username already taken.";
        $form->valid = false;
    }
    if ($form->valid == true) {
Пример #9
0
<?php

$root = realpath($_SERVER["DOCUMENT_ROOT"]);
require_once "{$root}/shared/defaults.php";
require_once 'class/LoginUser.class.php';
// Initialize the json object
$rjo = new API();
// Save user settings
if (isset($_REQUEST["action"]) && $_REQUEST["action"] == "updateUserSettings") {
    $updates = array();
    if (!isset($_REQUEST["userid"])) {
        error_out("No user id set.");
    }
    $user = new LoginUser();
    $user->id = intval(trim($_REQUEST["userid"]));
    $update = new SQLUpdate("login_user");
    $update->selectors = array("id" => $_REQUEST["userid"]);
    foreach (array("firstname", "lastname", "email") as $field) {
        if (isset($_REQUEST[$field])) {
            $update->add_value($field, $_REQUEST[$field]);
        }
    }
    if (isset($_REQUEST["password1"]) && $_REQUEST["password1"] != "") {
        if (!isset($_REQUEST["password2"]) && $_REQUEST["password2"] != "") {
            error_out("Please retype password.");
        } else {
            if ($_REQUEST["password1"] != $_REQUEST["password2"]) {
                error_out("Passwords do not match.");
            } else {
                $hash = db_hash_password($_REQUEST['password1']);
                if ($hash) {
Пример #10
0
 public function actionLogout()
 {
     if (isset(Yii::app()->user->id)) {
         LoginUser::model()->updateAll(array('status' => 0, 'log_out_time' => new CDbExpression('NOW()')), 'user_id=' . Yii::app()->user->id . ' AND status = 1');
         Yii::app()->user->logout();
         $this->redirect(array('login'));
     }
     $this->redirect(array('login'));
 }