Fejl i mir php
jeg har fået fat i det her men når jeg viser det i browseren viser den fejl på linie . eller der siger den.her er koden:
<?
if($mode ==""){
?>
<html>
<head>
<link type="text/css" href="gfx/stylesheets.css" rel="stylesheet">
</head>
<body bgcolor="#FFFFFF">
<form action="superchat.php?mode=chat" method="POST">
Chatnavn: <input type="text" name="chatnavn"><br>
Password: <input type="password" name="password"><br>
<input type="submit" value="Login"><br><br>
<u>Brugere Online</u>:<br>
<?
$opendir = opendir("bruger/");
while($read = readdir($opendir)){
if (eregi("^([^>]+).bruger$", $read, $regs)) {
echo $regs[1].", ";
}
}
if($regs == ""){
echo "Ingen brugere online ;(";
}
?>
</form>
</body>
</html>
<?
}elseIf($mode == "chat"){
$chatnavn = htmlentities($chatnavn);
$chatnavn = StripSlashes($chatnavn);
$fil = fopen("bruger/$chatnavn.bruger", "w+");
fwrite($fil, "#000000");
fclose($fil);
copy("bruger/txtbeskeder.txt", "bruger/txt$chatnavn.beskeder");
$handle = opendir("bruger/");
while ($file = readdir($handle)) {
if (eregi("^txt",$file)) {
$linier = file("./bruger/".$file);
$chatfile = fopen("./bruger/".$file,"w");
fputs($chatfile, "<font color=\"blue\">SuperChat v1.0: $chatnavn kiggede forbi....</font><br>\n");
for($i=0;$i<40;$i++){
fputs($chatfile, $linier[$i]);
}
fclose($chatfile);
}
}
closedir($handle);
?>
<html>
<head>
<title>
<?=$chatnavn?> - SuperChat v1.0
</title>
</head>
<body topmargin="0" leftmargin="0" bgcolor="#FFFFFF" onUnLoad="top.location.href='superchat.php?mode=logaf&chatnavn=<?=$chatnavn?>'">
<iframe name="topic" src="superchat.php?mode=topic" frameborder="0" height="8%" width="100%"></iframe>
<table cellpadding="0" cellspacing="0" height="75%" width="100%">
<tr>
<td bgcolor="#FFFFFF" width="3%">
<table cellpadding="0" cellspacing="0" height="101%" width="100%">
<tr>
<td valign="top" height="1">
<img src="gfx/top.gif">
</td>
</tr>
<tr>
<td height="100%">
<b><font face="Tahoma" size="5">
<u>S</u><br>
U<br>
P<br>
E<br>
R<br>
<u>C</u><br>
H<br>
A<br>
T<br>
</td>
</tr>
<tr>
<td>
<br><img src="gfx/bund.gif">
</td>
</tr>
</table>
</td>
<td>
<iframe name="main" src="superchat.php?mode=main&chatnavn=<?=$chatnavn?>" frameborder="0" height="100%" width="100%"></iframe>
</td>
<td width="3%">
<table cellpadding="0" cellspacing="0" height="101%" width="3%">
<tr>
<td valign="top" height="1" valign="right">
<img src="gfx/top2.gif">
</td>
</tr>
<tr>
<td height="200%">
<b><font face="Tahoma" size="5">
</td>
</tr>
<tr>
<td>
<img src="gfx/bund2.gif" valign="right">
</td>
</tr>
</table>
</td>
</table>
<iframe name="panel" src="superchat.php?mode=panel&chatnavn=<?=$chatnavn?>" frameborder="0" height="17%" width="100%"></iframe>
</body>
</html>
<?
}elseIf($mode == "main"){
?>
<html>
<head>
<META HTTP-EQUIV="Refresh" CONTENT="4; URL=superchat.php?mode=main&chatnavn=<?=$chatnavn?>">
<link type="text/css" href="gfx/stylesheets.css" rel="stylesheet">
</head>
<body background="gfx/white.gif" bgcolor="#FFFFFF">
<?
if(!$besked){
if(file_exists("bruger/$chatnavn.bruger")){
$fil = file("bruger/txt$chatnavn.beskeder","a+");
for($i=0;$i<40;$i++){
print $fil[$i];
}
}else{
?>
<script language="JAVASCRIPT">
top.location.href = "superchat.php?mode=logaf&chatnavn=<?=$chatnavn?>";
</script>
<?
}
}elseIf($besked && $chatnavn){
If(substr($besked,0,6) == "/kick "){
$besked = ereg_replace("/kick ", "", $besked);
unlink("bruger/$besked.bruger");
$fil = file("bruger/txt$chatnavn.beskeder","a+");
for($i=0;$i<40;$i++){
print $fil[$i];}
}elseIf(substr($besked,0,8) == "/nulstil"){
$besked = ereg_replace("/nulstil", "", $besked);
$fil = fopen("bruger/txt$chatnavn.beskeder", "w+");
fwrite($fil, "");
fclose($fil);
$fil = file("bruger/txt$chatnavn.beskeder","a+");
for($i=0;$i<40;$i++){
print $fil[$i];}
}elseif(file_exists("bruger/txt$til.beskeder")){
//Private beskeder
$besked = htmlentities($besked);
$besked = StripSlashes($besked);
$chatnavn = htmlentities($chatnavn);
$chatnavn = StripSlashes($chatnavn);
$usermessages = file("./bruger/txt$til.beskeder");
$file = fopen("./bruger/txt$til.beskeder","w");
fputs($file,"<font color=\"darkblue\">$chatnavn: (Privat) $besked</font><br>\n");
for($i=0;$i<34;$i++){
fputs($file,$usermessages[$i]);
}
fclose($file);
$usermessages = file("./bruger/txt$chatnavn.beskeder");
$file = fopen("./bruger/txt$chatnavn.beskeder","w");
fputs($file,"<font color=\"red\">$chatnavn: (Privat) $besked</font><br>\n");
for($i=0;$i<34;$i++){
fputs($file,$usermessages[$i]);
}
fclose($file);
$fil = file("bruger/txt$chatnavn.beskeder","a+");
for($i=0;$i<40;$i++){
print $fil[$i];}
//Private beskeder slut
}else{
//Public beskeder
$besked = htmlentities($besked);
$besked = StripSlashes($besked);
$chatnavn = htmlentities($chatnavn);
$chatnavn = StripSlashes($chatnavn);
$besked = ereg_replace("fuck", "****", $besked);
$fil = fopen("bruger/$chatnavn.bruger", "r");
$nfarve = fgets($fil, 4096);
fclose($fil);
$fil = fopen("bruger/$chatnavn.bruger", "r");
$nfarve = fgets($fil, 4096);
fclose($fil);
}
$handle = opendir("./bruger");
while ($file = readdir($handle)) {
if (eregi("^txt",$file)) {
$linier = file("./bruger/".$file);
$chatfile = fopen("./bruger/".$file,"w");
fputs($chatfile, "<font color=\"$nfarve\">$chatnavn: $besked</font><br>\n");
for($i=0;$i<40;$i++){
fputs($chatfile, $linier[$i]);
}
fclose($chatfile);
}
}
closedir($handle);
$fil = file("bruger/txt$chatnavn.beskeder","a+");
for($i=0;$i<40;$i++){
print $fil[$i];}
//Public beskeder slut
}
?>
</body>
</html>
<?
}elseIf($mode == "panel"){
?>
<html>
<head>
<style>
BODY {
font-family: Tahoma;
font-weight: bold;
font-size: 7pt;
color: #FFFFFF;
}
TD, INPUT {
border: 1px solid #000000;
font-family: Tahoma;
font-weight: bold;
font-size: 7pt;
color: #000000;
}
INPUT {
background: #FFFFFF;
}
SELECT {
border: 1px solid #000000;
font-family: Tahoma;
font-size: 7pt;
font-weight: bold;
color: #000000;
}
</style>
<script language="JAVASCRIPT">
function sutNeger(){
document.bageForm.besked.value = document.bageForm.spasserBox.value;
document.bageForm.spasserBox.value='';
document.bageForm.spasserBox.focus();
}
</script>
</head>
<body bgcolor="darkblue" topmargin="0" leftmargin="0">
<table cellpadding="0" cellspacing="0" height="1" width="100%">
<tr>
<td bgcolor="darkblue">
<font color="#FFFFFF">
Hejsa, <u><font color="yellow"><?=$chatnavn?></font></u> velkommen til SuperChat v1.0. Din status er, <u><font color="yellow">Normal</font></u>.
</font>
</td>
</tr>
</table>
<form action="superchat.php?mode=main" name="bageForm" method="POST" target="main" onSubmit="sutNeger()">
<input type="hidden" name="besked" value="">
<input type="hidden" name="chatnavn" value="<?=$chatnavn?>">
<font color="#ffffff">
Send til:
<?
echo "<select name=\"til\">\n";
echo "<option selected>Alle brugere</option>\n";
$opendir = opendir("bruger/");
while($read = readdir($opendir)){
if (eregi("^([^>]+).bruger$", $read, $regs)) {
if($regs[1] == "$chatnavn"){
$regs[1] = "";
}else{
echo "<option value=$regs[1]>\n";
echo "$regs[1]\n";
echo "</option>\n";
}
}
}
echo "</select>\n";
?>
<input type="button" value="Opdater" onClick="top.panel.location.href='superchat.php?mode=panel&chatnavn=<?=$chatnavn?>'">
<br>
Besked: <input type="text" name="spasserBox" size="30" autocomplete="OFF">
</font>
<input type="submit" value="Send">
<input type="button" value="Logaf" onClick="top.location.href='superchat.php?mode=logaf&chatnavn=<?=$chatnavn?>'">
<br>
Kontrol:
<input type="button" value="Nulstil" onClick="top.main.location.href='superchat.php?mode=main&chatnavn=<?=$chatnavn?>&besked=/nulstil'" style="background: yellow;">
<input type="button" value="Hjælp" onCLick="top.main.location='help.php'" style="background: yellow;">
</form>
</body>
</html>
<?
}elseIf($mode == "logaf"){
if(file_exists("bruger/txt$chatnavn.beskeder")){
unlink("bruger/txt$chatnavn.beskeder");
}
if(file_exists("bruger/$chatnavn.bruger")){
unlink("bruger/$chatnavn.bruger");
}
$handle = opendir("./bruger");
while ($file = readdir($handle)) {
if (eregi("^txt",$file)) {
$linier = file("./bruger/".$file);
$chatfile = fopen("./bruger/".$file,"w");
fputs($chatfile, "<font color=\"blue\">SuperChat v1.0: $chatnavn væltede ud....</font><br>\n");
for($i=0;$i<40;$i++){
fputs($chatfile, $linier[$i]);
}
fclose($chatfile);
}
}
closedir($handle);
?>
<script language="JAVASCRIPT">
top.location.href = "superchat.php";
</script>
<?
}elseIf($mode == "topic"){
?>
<html>
<head>
<link type="text/css" href="gfx/stylesheets.css" rel="stylesheet">
</head>
<body bgcolor="darkblue" topmargin="0" leftmargin="0">
<table cellpadding="0" cellspacing="0" height="1" width="100%">
<td height="1" bgcolor="darkblue">
<center>
<font color="yellow">
T O P I C : ( <font color="#FFFFFF">SuperChat v1.0 ©Carsten S. Rasmussen</font> )
</font>
</center>
</tr>
</table>
<font color="FFFFFF" size="1">
</body>
</html>
<?
}else{
echo "Denne side findes ikke!";
}
?>
