flash chat room

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
surendra
Forum Newbie
Posts: 2
Joined: Sat Apr 15, 2006 11:50 am

flash chat room

Post by surendra »

hi i hav got sm prob, with chat room ,, its php + flash, english version is workin fine ,, but i need same thin in Arabic Language too,, im not that much good in php if any one can help me !!
http://www.karzansoft.com/dd/chat2/index.html hav a look at this link,, all i need is utf encoding i guess,, how do i do the encoding ? :oops:
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

surendra
Forum Newbie
Posts: 2
Joined: Sat Apr 15, 2006 11:50 am

Post by surendra »

thanx for thr reply :roll: !!! i hav gone through the examples but smthin greeek to me.. im not that much gud in php ,, this is my code , how do i do with it !!!

Code: Select all

<?php
header("Expires: ".gmdate("D, d M Y H:i:s")."GMT");
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
// If you are using an old version of php, remove the next set of lines.
// or use $HTTP_POST_VARS["..."] instead.
$Submit 	= $_POST["Submit"];
$Name 		= $_POST["name"];
$Comments 	= $_POST["commentaar"];
$NumLow 	= $_REQUEST["NumLow"];
$NumHigh 	= $_REQUEST["NumHigh"];


// Replace special characters - you can remove the next 2 lines if wanted.
$Name = ereg_replace("[^A-Za-z0-9 ]", "", $Name);
//$Comments = ereg_replace("[^A-Za-z0-9 \@\.\-\/\']", "", $Comments);
$Comments = ereg_replace("\r", "[br]", $Comments);
$Comments = ereg_replace("&", "and", $Comments);
$Comments = ereg_replace("<", "", $Comments);
$Comments = ereg_replace(">", "", $Comments);
$Comments = ereg_replace(".:::.", "", $Comments);
$Comments = str_replace("[","<",$Comments);
$Comments = str_replace("]",">",$Comments);



/*
Replace URL's and Emails with Links (Using Regular expressions
http://www.php.net/manual/en/function.preg-replace.php (for info)
All Http address to URL's
*/
$Comments = preg_replace("/([^\w\/])(www\.[a-z0-9\-]+\.[a-z0-9\-]+)/i", "$1http://$2", $Comments);

// All other URL's to URL's
$Comments = preg_replace("/([\w]+:\/\/[\w-?&;#~=\.\/\@]+[\w\/])/i", "<u><font color=\"#003399\"><A TARGET=\"_blank\" HREF=\"$1\">$1</A></font></u>", $Comments);

// All Email address's to Links.
$Comments = preg_replace("/([\w-?&;#~=\.\/]+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?))/i","<u><font color=\"#003399\"><A HREF=\"mailto:$1\">$1</A></font></u>",$Comments);

/* Vulgar language filter
just comment out to get rid of it as you
would in a multi-line comment in and as I have in this comment.
Or you can add more words to the list*/
/*
$Comments       = ereg_replace("<span style='color:blue' title='I&#39;m naughty, are you naughty?'>smurf</span>", "s**t", $Comments);
$Comments       = ereg_replace("<span style='color:blue' title='I&#39;m naughty, are you naughty?'>smurf</span>", "f**k", $Comments);
$Comments       = ereg_replace("nigger", "******", $Comments);
$Comments       = ereg_replace("<span style='color:blue' title='I'm naughty, are you naughty?'>smurf</span>", "****", $Comments);
$Comments       = ereg_replace("pussy", "****", $Comments);
$Comments       = ereg_replace("cock", "****", $Comments);
$Comments       = ereg_replace("dick", "****", $Comments);
*/
// Remove slashes.
$Name 		= stripslashes($Name);
$Comments 	= stripslashes($Comments);


// Reading and Writing the new data to the dog_chat text file

if ($Submit == "Yes") {
// Next line tells the script which Text file to open.
	$filename 	= "dog_chat.txt";

// Opens up the file declared above for reading 

	$fp 		= fopen( $filename,"r"); 
	$OldData 	= fread($fp, 8000000); 
	fclose( $fp ); 


// Gets the current Date of when the entry was submitted
	$Today 		= (date ("l dS of F Y ( h:i:s A )",time()));

/* Puts the recently added data into html format that can be read into the Flash Movie.
You can change this up and add additional html formating to this area.  For a complete listing of all html tags
you can use in flash - visit: http://www.macromedia.com/support/flash ... mltext.htm */

	$Input = " <b><font color=\"#003399\">$Name: </font></b><i><font color=\"#999999\" size=\"-1\"> $Today</font></i><br />$Comments<br /><br /><font color=\"#999999\">__________________________________________________________________________________________</font></i><br /><br />.:::.";

/* This Line adds the '&dog_chat=' part to the front of the data that is stored in the text file.  This is important because without this the Flash movie would not be able to assign the variable 'GuestBook' to the value that is located in this text file  */

	$New = "$Input$OldData";

// Opens and writes the file.

	$fp = fopen( $filename,"w"); 
	if(!$fp) die("&dog_chat=cannot write $filename ......&");
	fwrite($fp, $New, 8000000); 
	fclose( $fp ); 
}


// Formatting and Printing the Data from the dog_chat text file to the Flash Movie



// Next line tells the script which Text file to open.
	$filename = "dog_chat.txt";

// Opens up the file declared above for reading 

	$fp 	= fopen( $filename,"r"); 
	$Data 	= fread($fp, 8000000); 
	fclose( $fp );

// Splits the Old data into an array anytime it finds the pattern .:::.
	$DataArray = split (".:::.", $Data);

// Counts the Number of entries in the dog_chat
	$NumEntries = count($DataArray) - 1;

	print "&TotalEntries=$NumEntries&NumLow=$NumLow&NumHigh=$NumHigh&dog_chat=";
	for ($n = $NumLow; $n < $NumHigh; $n++) {
	print $DataArray[$n];
		if (!$DataArray[$n]) {
		Print "<br><br><b><font color=\"#003399\">No More entries</font></b>";
		exit;
		}
	}
// end of dog_chat php file
?>

hoping the best from u !!!
Post Reply