Should be the final commit
Took 36 minutes
This commit is contained in:
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user