public static function update($id)
 {
     $params = $_POST;
     $attributes = array('id' => $id, 'name' => $params['name'], 'password' => $params['password']);
     $Player = new Player($attributes);
     $errors = $Player->errors();
     if (count($errors) != 0) {
         View::make('/Player/edit.html', array('errors' => $errors, 'attributes' => $attributes));
     } else {
         $Player->update();
         Redirect::to('/player/' . $Player->id, array('message' => 'Pelaajaa on muokattu onnistuneesti!'));
     }
 }
Exemple #2
0
$origplayer->Email = $email;
$origplayer->OKemail = $okem;
$origplayer->Trivia = $trivia;
$origplayer->Phone = $phone;
$origplayer->Notes = $notes;
$origplayer->Latestcall = $latest == "None" ? "" : $latest;
if ($origplayer->ILdiv == 0) {
    if (isset($_POST["join"])) {
        $origplayer->ILdiv = assign_ildiv($rank);
    }
} else {
    if (!$origplayer->ILpaid && !isset($_POST["stayin"])) {
        $origplayer->ILdiv = 0;
    }
}
$origplayer->update();
if (strlen($passw) != 0 && $passw != $origplayer->get_passwd()) {
    $origplayer->set_passwd($passw);
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<?php 
$Title = "Player details updated OK";
include 'php/head.php';
print <<<EOT
<body>
<script language="javascript" src="webfn.js"></script>

EOT;
include 'php/nav.php';
        break;
    case 'join':
        // Join an already created game
        // Create new player object
        $player = new Player($gameId, $playerName);
        // joingame() returns player object as JSON to be returned to js
        $response = joinGame($player, $gameId);
        break;
    case 'u':
        // Update settings for player
        // Create new player object
        $player = new Player($gameId, $playerName, $score, $playerId);
        // The update() method returns the gameStatus.
        // If more than one player is still active, player object is returned as JSON.
        // If only one player has lives left, the game is over, and JSON with gameStatus: finished is returned
        $u = $player->update($gameId, $playerId, $score);
        if ($u == 'updated' || $u == 'ongoing') {
            $response = json_encode($player, JSON_UNESCAPED_UNICODE);
        } else {
            if ($u == 'finished') {
                $s = $player->gameStatus;
                $response = "{ 'gameStatus': {$s} }";
            }
        }
    default:
        //
        break;
}
//**
//		Actions
//**
    exit;
}
?>
            <!-- MAIN SECTION -->
            <section class="main-section">
                <div class="small-12 columns">
                    <div class="row">
                        <h4>joueur - <?php 
$player = new Player();
if (isset($_POST["id"])) {
    $player->initProperty($_POST["id"], $_POST["firstName"], $_POST["lastName"], $_POST["teamId"]);
    $player->PageMode = $_POST["pageMode"];
    $player->validate($mySql);
    if (!$player->getHasError()) {
        if ($player->PageMode == Constants::PAGE_MODE_EDIT) {
            $player->update($mySql);
        } else {
            $player->addNew($mySql);
        }
        header('Location: player.php');
        exit;
    }
    echo $player->getFullName();
} else {
    if (isset($_GET["id"])) {
        $player->initDB($_GET["id"], $mySql);
        echo $player->getFullName();
        $player->PageMode = Constants::PAGE_MODE_EDIT;
    } else {
        echo "[Nouveau]";
        $player->PageMode = Constants::PAGE_MODE_ADD;
Exemple #5
0
 /**
  * Removes a member from the team
  *
  * @param  int  $id The id of the player to remove
  * @return void
  */
 public function removeMember($id)
 {
     if (!$this->isMember($id)) {
         throw new Exception("The player is not a member of that team");
     }
     $player = new Player($id);
     $player->update("team", null, "s");
     $this->update('members', --$this->members, "i");
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     $players = Player::findOrFail($id);
     $data = Input::all();
     $validator = Validator::make($data, Player::$rules);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     // Helper: File Upload in Player Model
     $data['id_copy'] = Player::uploadFile(Input::file('id_copy'), 'id_copy');
     $data['photo'] = Player::uploadFile(Input::file('photo'), 'photo');
     $players = new Player($data);
     $players->update($data);
     return View::make('players.index')->with('message', 'file update was successful');
 }
 /**
  * test updating a Player that already exists
  *
  * @expectedException PDOException
  **/
 public function testUpdateInvalidPlayer()
 {
     // Create a Player with a non null player id and watch it fail
     $player = new Player(null, $this->Player->getPlayerId());
     $player->update($this->getPDO());
 }
Exemple #8
0
 /**
  * Log in - show the login form or handle a login request
  * 
  * @todo Implement real authentication
  */
 public function loginAction()
 {
     if ($this->getRequest()->getMethod() != 'POST') {
         // Not a POST request, show log-in form
         $view = $this->initView();
         $this->render();
     } else {
         // Handle log-in form
         $username = $this->getRequest()->getParam('user');
         if ($username) {
             $password = $this->getRequest()->getParam('password');
         } else {
             $username = $this->getRequest()->getParam('suser');
             $password = $this->getRequest()->getParam('spassword');
         }
         // setup Zend_Auth adapter for a database table
         $dbAdapters = Zend_Registry::get('dbAdapters');
         $authAdapter = new Zend_Auth_Adapter_DbTable($dbAdapters['user'], 'nukevo_users', 'username', 'user_password', 'MD5(?)');
         // Set the input credential values to authenticate against
         $authAdapter->setIdentity($username);
         $authAdapter->setCredential($password);
         // do the authentication
         $auth = Zend_Auth::getInstance();
         $result = $auth->authenticate($authAdapter);
         if ($result->isValid()) {
             // success: store database row to auth's storage
             // system. (Not the password though!)
             $data = $authAdapter->getResultRowObject(null, 'password');
             $auth->getStorage()->write($data);
             Zend_Session::regenerateId();
             $this->session->logged_in = true;
             $this->session->username = $username;
             $player_table = new Player();
             $player = $player_table->getPlayerForUsername($username);
             if ($player) {
                 $this->session->steamid = $player->steamid;
             } else {
                 $member_table = new Members();
                 $member = $member_table->getMember($user);
                 if ($member) {
                     $this->session->steamid = 'STEAM_' . $member->steamid;
                     // Update player record's username
                     $player = $player_table->getPlayerForSteamid($this->session->steamid);
                     if ($player) {
                         $where = $table->getAdapter()->quoteInto('steamid = ?', $this->session->steamid);
                         $player_table->update(array('username' => $username), $where);
                     }
                 }
             }
             //$this->_forward('profile');
             $this->_redirect('/sc/player/show/user/' . $username);
         } else {
             $view = $this->initView();
             $view->user = $username;
             $view->error = 'Wrong user name or password, please try again';
             $this->render();
         }
     }
 }
Exemple #9
0
 /**
  * Checks players password.
  *
  * @param String $username Username of user attempting to authenticate.
  * @param String $password Password of user attempting to authenticate.
  *
  * @return Player Returns player if authentication was successful. Otherwise returns null.
  */
 public static function authenticate($username, $password)
 {
     $query = DB::connection()->prepare('SELECT * FROM Player WHERE username = :username LIMIT 1');
     $query->execute(array('username' => $username));
     $row = $query->fetch();
     ##    if($row && password_verify($password, $row['password'])) { ## Usersin php-versio ei tuekaan tätä.. :(
     if ($row && $password == $row['password']) {
         $player = new Player(array('id' => $row['id'], 'name' => $row['name'], 'courseId' => $row['courseid'], 'username' => $row['username'], 'password' => $row['password'], 'admin' => $row['admin'], 'joined' => $row['joined']));
         $player->update();
         return $player;
     } else {
         return null;
     }
 }