| Pookie -
 
 
 Joined: 05 Jan 2005
 Posts: 60
 Location: Citrus Heights, CA
 
 | 
			
				|  Posted: Fri Mar 03, 2006 1:41 pm    Post subject: Whats wrong with this script? |   |  
				| 
 |  
				| This script repeats itself twice for some reason. heres tthe code in bold: 
 <?php
 
 /*******************************/
 /***   Simple Simple Chat    ***/
 /***          v 1.0          ***/
 /***   www.phpclub.site.ir   ***/
 /*******************************/
 
 // Warning : This chat exposes chatters IP addresses
 
 // Config : [ You can change these options ]
 $refresh = 6 ; // Page refresh time in seconds
 $max = 20 ; // Max. saved messages
 $remain = 400 ; // Messages remaining time in seconds
 $file = "msg.txt" ; // Message storing file
 /*
 You may need to make an empty file (use notepad) and name it "msg.txt"
 ($file), and send it to your server. Then CHMOD this file to 777 - e.g :
 ftp> SITE CHMOD 777 msg.txt
 */
 // End of config //
 
 $user = $HTTP_SERVER_VARS['REMOTE_ADDR'] ;
 $f = file($file) ;
 $users = array($user) ;
 header ("Content-Type: text/html; charset=utf-8") ;
 $fp = fopen($file, "w") ;
 if (!$fp) { die ('Can not write to file .') ; }
 for ($i=0; isset($f[$i])||$i==0; $i++)
 {
 $e=explode('||', $f[$i]) ;
 if ($e[2]=="\r\n" && !in_array($e[0], $users) && ( time() - $e[1] < $refresh*2 ) ) $users[]=$e[0] ;
 if ($i==0) { fputs($fp, $user."||".time()."||\r\n") ;
 if ( isset($HTTP_POST_VARS['msg']) ) fputs ($fp, $user."||".time()."||".str_replace("||", "", str_replace("\n", "", htmlspecialchars(stripslashes($HTTP_POST_VARS['msg']))))."\r\n") ;	}
 if ( ($e[0]!=$user && $e[2]=="\r\n") || ( $i<$max && ($e[1]+$remain)>time() && $e[2]!="\r\n") ) fputs($fp, $f[$i]) ;
 }
 fclose($fp) ;
 
 if (isset($HTTP_GET_VARS['f1']))
 {
 $f2 = file($file) ;
 echo("<html><head><title></title><meta http-equiv='Content-Type' content='text/html; charset=utf-8'></head>") ;
 echo("<body text=#0000cc><meta http-equiv='refresh' content='{$refresh}; url={$HTTP_SERVER_VARS['REQUEST_URI']}'>") ;
 echo("<font color=#e22200>Online Users: ") ;
 foreach($users as $u) echo "<font color=#ee0099>".$u."</font> - " ;
 echo "</font><hr>" ;
 for($i=0; isset($f2[$i]) && $i<$max; $i++) {
 $e=explode("||", $f2[$i]) ;
 if ($e[2]!="\r\n") echo "<font color=green>{$e[0]}</font> <font color=red>:</font> {$e[2]}<br>\r\n" ;
 }
 die("</body></html>") ;
 }
 
 else
 {
 die("
 <html><head><title>Chat</title><meta http-equiv='Content-Type' content='text/html; charset=utf-8'>
 <script><!--
 function msg(){ document.m.msg.focus(); } // --></script>
 </head>
 <body align='center' onLoad='msg()'> <center>
 <iframe src='?f1=1' width='95%' height='85%'></iframe><br>
 <table width='95%'><tr><td align='center' width='100%'>
 <form action='' method='post' name='m'>
 Message : <input name='msg' size=60> <input type='submit' name='send' value='Send'>
 <br />
 </form>
 </td></tr></table>
 </body></html>
 ") ;
 }
 ?>
 
 heres the site addy where you can see exactly what its doing.
 http://67.172.183.110:5190/browse.html
 _________________
 ~TRU~
 |  |