コード例 #1
0
ファイル: SiteController.php プロジェクト: mjrao/BugFree
 /**
  * Displays the login page
  */
 public function actionLogin()
 {
     $this->layout = '//layouts/blank';
     $model = new LoginForm();
     if (isset($_GET['language'])) {
         $model->language = $_GET['language'];
     } else {
         $cookies = Yii::app()->request->getCookies();
         if (!empty($cookies['language'])) {
             $model->language = $cookies['language']->value;
         }
     }
     // collect user input data
     if (isset($_POST['LoginForm'])) {
         $model->attributes = $_POST['LoginForm'];
         $result = LoginService::login($_POST['LoginForm']);
         if ($result['status'] == 'success') {
             $returnUrl = Yii::app()->user->returnUrl;
             $this->redirect($returnUrl);
         } else {
             $model->addErrors($result['detail']);
         }
     }
     $this->render('login', array('model' => $model));
 }
コード例 #2
0
<?php

require '../base/Config.php';
Config::init();
$service = new LoginService();
$service->init();
if (isset($_POST["username"]) === false || isset($_POST["password"]) === false || isset($_POST["game"]) === false) {
    $service->error("login", 1);
}
$username = $_POST["username"];
$password = $_POST["password"];
$game = $_POST["game"];
if (!is_numeric($game)) {
    $service->error("login", 2);
}
error_log($username . "-" . $password . "-" . $game);
if ($service->login($username, $password, $game)) {
    $token_service = new TokenService();
    $token_service->init();
    $length = 16;
    $token = Common::createToken($length);
    $account = $username . "_enjoymi";
    $token_service->writeToken($account, $game, $token);
    $service->error("login", "0," . $account . "," . $token);
} else {
    $service->error("login", 4);
}