<?php session_start(); ?>
<html>
<link rel="stylesheet" type="text/css" href="../../stylesheet.css"/>
<head>
<title>chatbox</title>
</head>
<body>
<h1>chat-pagina</h1>
<?
if (!isset($_SESSION["username"])){
$tekst = "<h3>U hebt geen toegang meer tot deze pagina, u kunt <a href=\"../login.php\">hier</a> inloggen.</h3>";
echo($tekst);
}else{
?>
<script language="javascript">
var xmlhttp=false;
/*
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
xmlhttp = false;
}
}
*/
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
xmlhttp = new XMLHttpRequest();
}
timer = 6000; //iedere 5 seconden refreshen
function say(value)
{
name = document.getElementById('name').value;
xmlhttp.open("GET", "chat.php?text="+value+"&name="+name,true);//method, target, async (set always true!)
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4) {
document.getElementById('chatwindow').innerHTML = xmlhttp.responseText;
}
}
xmlhttp.send(null);
timer = 6000;
counter();
}
function update()
{
xmlhttp.open("GET", "chat.php",true);//method, target, async (set always true!)
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4) {
document.getElementById('chatwindow').innerHTML = xmlhttp.responseText;
}
}
xmlhttp.send(null);
timer = 6000;
counter();
}
function counter()
{
if(timer == 0)
{
update();
}
else
{
timer = timer - 1000;
setTimeout("counter()", 1000);
}
}
function hasvalue(value)
{
if(value != "")
{
document.getElementById('submitbutton').disabled = false;
}
else
{
document.getElementById('submitbutton').disabled = true;
}
}
</script>
<form name="ourform">
<input type="hidden" id="name" name="name" style="width: 600px;" maxlength="256" value="Annoniem"/>
<div id="chatwindow" style="display:block; width: 600px; height: 250px; overflow: noscroll;">
</div><br/><br/>
<input type="text" id="chattext" name="chattext" onKeyPress="hasvalue(this.value);" maxlength="256" style="width: 450px; "/>
<input type="submit" id="submitbutton" onMouseDown="javascript: say(document.getElementById('chattext').value);document.getElementById('chattext').value = '';" value="Toevoegen" style="width:100px; " disabled />
</form>
<script>
update()
</script>
<?
}
echo "<br/><br/>Klik <a href=\"../beveiligd.php\">hier</a> om terug te keren";
?>
<h5><a href="http://www.phphulp.nl/php/scripts/5/326/" target="blanc">Origineel script</a> bewerkt door Irtimid2001</h5>
</body>
</html>