Should be the final commit

Took 36 minutes
This commit is contained in:
2020-10-03 20:35:44 +02:00
parent f6d2e3a62a
commit 7a6688a4a6
4 changed files with 25 additions and 16 deletions

View File

@ -31,11 +31,13 @@ class DefaultModel
public function createRoom(string $room_name)
{
$room_owner = session_id();
$stmnt = Database::getConnection()->prepare( 'INSERT INTO rooms ( name, owner_sid, code ) VALUES ( :name, :owner, :code )' );
$stmnt->execute( array( 'name' => $room_name, 'owner' => $room_owner, 'code' => $this->generateRandomStr( CODE_LENGTH ) ) );
$secret = $this->generateRandomStr( 15 );
$stmnt = Database::getConnection()->prepare( 'INSERT INTO rooms ( name, owner_sid, code ) VALUES ( :name, :owner_sid, :code )' );
$stmnt->execute( array( 'name' => $room_name, 'owner_sid' => $secret, 'code' => $this->generateRandomStr( CODE_LENGTH ) ) );
$id = Database::getConnection()->lastInsertId( );
setcookie( 'owner_room_' . $id, $secret, time()+60*60*24*365 );
if( empty( $id ) )
{
return false;

View File

@ -89,7 +89,8 @@ class FaqModel
{
return false;
}
if( $result['owner_sid'] === session_id() )
$secret = empty( $_COOKIE['owner_room_' . $a_room['id'] ] ) ? null : $_COOKIE['owner_room_' . $a_room['id'] ];
if( $result['owner_sid'] === $secret )
{
return true;
}