Stunden ende, einiges fertig, fehlt nicht mehr viel

Took 2 hours 31 minutes
This commit is contained in:
2020-10-02 10:41:09 +02:00
parent 1fd648bc4a
commit c37ad92dbc
51 changed files with 26430 additions and 17 deletions

40
model/DefaultModel.class.inc.php Normal file → Executable file
View 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';
}
}