PDA

View Full Version : PHP Wont output anything to Chat.txt


MickyG
06-01-2005, 10:20 AM
Ok, my code is below... For some reason i can't figure out why this wont output anything to chat.txt. Can someone help me please?

<?php
//CHAT SCRIPT BY MICKYG
//TO USE THIS SCRIPT YOU MUST KEEP THIS HERE
//YOU MUST ALSO PUT A LINK ON YOUR CHAT TO WWW.MICKYG.CO.UK
//THIS CHAT SCRIPT IS FREE AS LONG AS YOU ABIDE BY THE ABOVE CONDITIONS
//TO REMOVE THE LINK TO WWW.MICKYG.CO.UK AND TO REMOVE THIS INFORMATION EMAIL ME AT [email protected]
//--------------------------
//Variables
$name = $_POST['myName'];;
$tosave = $_POST['myChat'];;
$closeit = ("0");
$openit = ("1");
$closed = ("thechat=Chat is Closed, Sorry.");
$reset = ("thechat=");
$opened = ("thechat=Chat is open again");
$file = file_get_contents ("chat.txt");
$working = file_get_contents ("online.txt");
$save = ("$file<br>
<b>$name</b>:<i>$tosave</i><br>");


//Name commands
if($name == "FCC5000" ) {
$name = ("<font color=\"#FF0000\">ADMIN</font>");
} else {
$name = str_replace(" ","-", $name);
}

//output Commands
switch ($tosave) {
case "/close":
$fpclose = fopen("online.txt", "w");
if(fwrite($fpclose, $closeit)) ;
fclose($fpclose);
break;

case "/open":
$fpopen = fopen("online.txt", "w");
if(fwrite($fpopen, $openit)) ;
fclose($fpopen);

$fpo = fopen("chat.txt", "w");
if(fwrite($fpo, $opened)) ;
fclose($fpo);
break;

case "/signinad":
$fpadon = fopen("adon.txt", "w");
if(fwrite($fpadon, $openit)) ;
fclose($fpadon);
break;

case "/signoutad":
$fpadoff = fopen("adon.txt", "w");
if(fwrite($fpadoff, $closeit)) ;
fclose($fpadoff);
break;


case "XREPORTX":
$to = '[email protected]';
$subject = 'REPORT IN CHAT. REPORT IN CHAT';
$message = 'REOPRT IN CHAT. GO NOW';
$headers = 'From: [email protected]' . "\r\n" .
'Reply-To: [email protected]' . "\r\n" .
'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers);
break;


default:
if($working == "0"){


$fpa = fopen("chat.txt", "w");
if(fwrite($fpa, $closed)) ;
fclose($fpa);
} else {
$replaced = str_replace("xxREDxx","<font color=\"#FF0000\">", $save);
$replaced2 = str_replace("xx:CLRxx","</font>", $replaced);

$replaced3 = str_replace("xxGRNxx","<font color=\"#00FF00\">", $replaced2);


$replaced5 = str_replace("xx:)xx","<img src='http://users.pandora.be/eforum/emoticons4u/happy/1016.gif'>", $replaced3);

$replaced6 = str_replace("xUx","</i>", $replaced5);
$replaced7 = str_replace("x:Ux","<i>", $replaced6);

$replaced8 = str_replace("x_x","<u>", $replaced7);
$replaced9 = str_replace("x:_x","</u>", $replaced8);

$replaced10 = str_replace("Xx","<b>", $replaced9);
$replaced11 = str_replace("xX","</b>", $replaced10);

$replaced12 = str_replace("xxPNKxx","<font color=\"#FF33CC\">", $replaced11);

$replaced14 = str_replace("xxGRYxx","<font color=\"#999999\">", $replaced12);

$replaced16 = str_replace("xxBLUxx","<font color=\"#0000FF\">", $replaced14);

$replaced17 = str_replace("xxYELxx","<font color=\"#FFFF00\">", $replaced16);

$replaced18 = str_replace("xxBLAxx","<font color=\"#000000\">", $replaced17);

$replaced19 = str_replace("xxIMGxx","<img src='", $replaced18);
$replaced20 = str_replace("xx:IMGxx",">", $replaced19);

$fp = fopen("chat.txt", "w");

if(fwrite($fp, $replaced20)) ;
fclose($fp);
}
}


?>

madgett
06-04-2005, 06:49 PM
Do you have write permissions on your server?