@php session_name('ChessRoom-'.$roomCode); session_start(); if(isset($_GET['logout'])){ //Simple exit message $logout_message = "
".date("Y-m-d | H:i:s")." User ". $_SESSION['name'] ." has left the chat session.
"; file_put_contents(public_path().'/roomChatLog/'.$roomCode.'-roomchatlog.html', $logout_message, FILE_APPEND | LOCK_EX); session_destroy(); header("Location: ".url()->current() ); //Redirect the user } if(isset($_POST['enter'])){ if($_POST['name'] != ""){ $_SESSION['name'] = stripslashes(htmlspecialchars($_POST['name'])); setcookie('chessroom_name', $_SESSION['name']); $login_message = "
".date("Y-m-d | H:i:s")." User ". $_SESSION['name'] ." has entered the chat session.
"; file_put_contents(public_path().'/roomChatLog/'.$roomCode.'-roomchatlog.html', $login_message, FILE_APPEND | LOCK_EX); } else{ echo 'Please type in a name'; } } function loginForm(){ @endphp

Please enter your name to Chat!

@csrf
@php } @endphp @php if(!isset($_SESSION['name'])){ @endphp
@php loginForm(); @endphp
@php if(file_exists("{{ url('/') }}/roomChatLog/{{ $roomCode }}-roomchatlog.html") && filesize("{{ url('/') }}/roomChatLog/{{ $roomCode }}-roomchatlog.html") > 0){ $contents = file_get_contents("{{ url('/') }}/roomChatLog/{{ $roomCode }}-roomchatlog.html"); echo $contents; } @endphp
@php } else { @endphp
@php if(file_exists("{{ url('/') }}/roomChatLog/{{ $roomCode }}-roomchatlog.html") && filesize("{{ url('/') }}/roomChatLog/{{ $roomCode }}-roomchatlog.html") > 0){ $contents = file_get_contents("{{ url('/') }}/roomChatLog/{{ $roomCode }}-roomchatlog.html"); echo $contents; } @endphp
@php } @endphp