Stunden ende, einiges fertig, fehlt nicht mehr viel
Took 2 hours 31 minutes
This commit is contained in:
40
model/DefaultModel.class.inc.php
Normal file → Executable file
40
model/DefaultModel.class.inc.php
Normal file → Executable file
@ -3,8 +3,44 @@
|
||||
|
||||
class DefaultModel
|
||||
{
|
||||
public function getTestMessage()
|
||||
public function redirectToStart($string)
|
||||
{
|
||||
return "Rabbits can't fly without Red Bull.";
|
||||
header( "Location: ?c=default&a=index&rsn=$string" );
|
||||
exit();
|
||||
}
|
||||
|
||||
public function checkCode($room_code)
|
||||
{
|
||||
$stmnt = Database::getConnection()->prepare( 'SELECT id FROM rooms WHERE code = :code' );
|
||||
$stmnt->execute( array( 'code' => $room_code ) );
|
||||
|
||||
$result = $stmnt->fetch( PDO::FETCH_ASSOC );
|
||||
if( $result === false || empty( $result ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return $result['id'];
|
||||
}
|
||||
|
||||
public function joinRoom($room_id)
|
||||
{
|
||||
$_SESSION['room'] = $room_id;
|
||||
header( 'Location: ?c=faq' );
|
||||
return true;
|
||||
}
|
||||
|
||||
public function createRoom(string $room_name)
|
||||
{
|
||||
$room_owner = session_id();
|
||||
$stmnt = Database::getConnection()->prepare( 'INSERT INTO rooms ( name, owner, code ) VALUES ( :name, :owner, :code )' );
|
||||
$stmnt->execute( array( 'name' => $room_name, 'owner' => $room_owner, 'code' => $this->generateRandomStr() ) );
|
||||
|
||||
}
|
||||
|
||||
public function generateRandomStr( $length = 4 )
|
||||
{
|
||||
return 'U2HA';
|
||||
}
|
||||
|
||||
|
||||
}
|
Reference in New Issue
Block a user