PHP - Moved: Php Group Chat Script
This topic has been moved to Miscellaneous.
http://www.phpfreaks.com/forums/index.php?topic=342897.0 Similar TutorialsThis topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=316029.0 Can anyone suggest some good php Script(or Weburl) to do chat part in my php system please... Thanks in advance This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=306114.0 This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=353968.0 Hi, I was trying to build a chat room and tried the code given he http://www.codingmix.com/2010/12/privat ... mment-form but when i try to go to chat , sending is disabled and I cant chat Can anyone help? Also I want to create a room for chat like: based on a topic some more features like Adding a topic........and while chat choose the category like speaking for the topic, against or neutral and with option to post a point while chatting please help pooja_dubey12 Forum Newbie Posts: 3 Joined: Fri Jul 03, 2009 8:29 am Hello everyone, im new here. so to begin with i wanted to ask you about my realtime chat script im creating. You can check it out here http://madnet.us.lt/chat.php. Please! i repeat PLEASE, dont use any tags or sumtin in input fields, the chat is still unsafe! It only works in some versions of Opera, Mozila(best) and i think it should work on Chrome, but god no ,dont use IE This is my first project i created so dont judge me if the code sounds stupid to you:D I made this using php/html/jquery and css . My first problem is that i used timeout function for chat div refresh, i dont think its the best way to get data from mysql, couse if like 500 or more people will get refreshes every 1 second, i think the server would crash, maybe you could get me through this with an alternative. Another problem is as i mentioned before that this chat is not capable with all explorers people use today. Third problem is that i cant figure it out how to make the public and clan buttons work (i only manage to get one of them work, if i make another one work then they conflict(nevermind you will see in the code)). I got a lot of more questions about security and stuff. but for now i would like to get the answers how to fix these things. Now il share you the code. I will accept all you advices so be free to say anything you think would be better for my real time chat. Im attaching the chat files.You will find the mysql tables in the zip Many thanks! [attachment deleted by admin] This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=331465.0 This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=342675.0 This topic has been moved to Microsoft SQL - MSSQL. http://www.phpfreaks.com/forums/index.php?topic=347695.0 This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=321530.0 This topic has been moved to Ajax Help. http://www.phpfreaks.com/forums/index.php?topic=349338.0 I am looking for help on guiding me to a way for a user to upload a group of pictures for a slide show. can some one help? I have a news page that a user is able to upload new stories or edit and upload one photo, but now i want that user to upload a group of pictures for a slideshow. hope all this makes sense. Hi I'm currently having a problem with my chat script each time I'm trying to insert " or brackets etc... I get the error
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/u471530368/public_html/chat/page.php on line 201
Here is the lines at line 201
// check to see if a duplicate exists $sql = "SELECT * FROM StringyChat WHERE StringyChat_ip=\"$ip\" AND StringyChat_message=\"$msg\" AND StringyChat_time>($post_time - 30 )"; $result = mysql_query($sql); $myrow = mysql_fetch_array($result); if($myrow["StringyChat_message"] == "") { // Checks if record not matching in db // Save the record $sql = "INSERT INTO StringyChat (StringyChat_ip,StringyChat_name,StringyChat_message,StringyChat_time) VALUES (\"$ip\",\"$name\",\"$msg\",$post_time)"; $result = mysql_query($sql); $theTo = $email_notification_to; $theSubject = "New StringyChat post at ".$domain_installed; $theMessage = "A new StringyChat post has been made.\n\n"; $theMessage .= $name . "\n"; $theMessage .= date("H:i - d/m/y", $post_time) . "\n"; $theMessage .= $message_emailable . "\n\n"; $theMessage .= "Visit ".$domain_installed." to view StringyChat and much more!"; $theHeaders = "From: StringyChat at ".$domain_installed." <".$email_notification_to.">\r\n"; mail($theTo,$theSubject,$theMessage,$theHeaders); } else { echo "<span style='color:#10ce59'>Duplicate post detected!</span><p>"; } } else { echo "<span style='color:#10ce59'>You can't send blanks!</span><br><br>"; }My full script is <?php define('TIMEZONE', 'Africa/Harare'); date_default_timezone_set(TIMEZONE); ?> <html><br> <b><u>Chat Beta:</u></b> <span style="color:#ff0000"><br>Errors may apply please send feedback with contact us regarding problems!</span> <br><a href="page.php">Reload</a> </html> <? // database connection info $conn = mysql_connect('*******','********','*****') or trigger_error("SQL", E_USER_ERROR); $db = mysql_select_db('*******',$conn) or trigger_error("SQL", E_USER_ERROR); // find out how many rows are in the table $sql = "SELECT COUNT(*) FROM StringyChat"; $result = mysql_query($sql, $conn) or trigger_error("SQL", E_USER_ERROR); $r = mysql_fetch_row($result); $numrows = $r[0]; // number of rows to show per page $rowsperpage = 20; // find out total pages $totalpages = ceil($numrows / $rowsperpage); // get the current page or set a default if (isset($_GET['currentpage']) && is_numeric($_GET['currentpage'])) { // cast var as int $currentpage = (int) $_GET['currentpage']; } else { // default page num $currentpage = 1; } // end if // if current page is greater than total pages... if ($currentpage > $totalpages) { // set current page to last page $currentpage = $totalpages; } // end if // if current page is less than first page... if ($currentpage < 1) { // set current page to first page $currentpage = 1; } // end if // the offset of the list, based on current page $offset = ($currentpage - 1) * $rowsperpage; /* * StringyChat * * Please refer to readme.txt supplied with the StringyChat distribution for information on * installing and configuring. * */ define('TIMEZONE', 'Africa/Harare'); date_default_timezone_set(TIMEZONE); include("chat_code_header.php"); $result = mysql_query("SELECT * FROM ".$ConfigTable, $db); $myrow = mysql_fetch_array($result); $domain_installed = $myrow["domain_installed"]; // The domain StringyChat is installed on $install_url = $myrow["install_url"]; // URL to install dir of StringyChat $name_size = $myrow["name_size"]; // Maximum size of the name $message_size = $myrow["message_size"]; // Maximum message size. Do not exceed 250 as this is the database limit. $line_length = $myrow["line_length"]; // Maximum length of words in a line. Anything above this value will be split. $ShowPostNum = $myrow["show_posts"]; // The number of historic posts to load and display. $email_notification = $myrow["email_notification"]; // Send email to administrator when new posts are made. 0 = No, 1 = Yes $email_notification_to = $myrow["email_notification_to"]; // The email address to send notifications to if ($_SERVER['REQUEST_METHOD'] == "POST" && !empty($_POST['StringyChat_name'])) { $StringyChat_name = $_POST['StringyChat_name']; $StringyChat_message = $_POST['StringyChat_message']; } ?> <div id="StringyChat"> <? // Check if visitor's IP is banned. If so, do not display the form, // show a banned IP message instead. $name = $_SERVER["HTTP_X_MXIT_NICK"]; if(!isset($name)) { $name = "SYSOP"; } $ip = $_SERVER["REMOTE_ADDR"]; $sql = "SELECT * FROM StringyChat_IPBan WHERE ip=\"$ip\""; $result = mysql_query($sql); $myrow = mysql_fetch_array($result); if($myrow["ip"] == "") { // Checks if IP not found in banned list ?> <html><form name="StringyChat_form" method="POST" action="<? echo $_SERVER['REQUEST_URI']; ?>"> <input type="hidden" name="StringyChat_name" class="StringyChatFrm" value="<?php echo $name ?>" size="20"> <textarea name="StringyChat_message" class="StringyChatFrm" cols="20" rows="1"></textarea> <br> <input name="StringyChat_submit" class="StringyChatFrm" type="submit" value="Post Message"> </form> </html> <? } else { echo "<span style='color:#10ce59'><u>Dear User, you have been banned from the Chat due to not following the rules. You will need to come back regularly to see if you were unbanned. Until then, goodbye!</u></span>"; } // Should we try to create a post? if (isset($StringyChat_name) && isset($StringyChat_message)) { // Remove whitespaces and slashes. $name = trim(stripslashes($StringyChat_name)); $message = trim(stripslashes($StringyChat_message)); // Check name and message have been entered. if (strlen($name) > 0 && strlen($message) > 0) { // Limit the size of the fields as per variable defnitions. if (strlen($name) > $name_size) { $name = substr($name, 0, $name_size); } if (strlen($message) > $message_size) { $message = substr($message, 0, $message_size); } // Remove new lines from name. $name = str_replace("\n", " ", $name); // Stripping out \r's so email formattnig appears correctly. $message = str_replace("\r", "", $message); // Create an email-friendly version of the message. $message_emailable = str_replace("<br>", "\n", $message); $result_wordswap = mysql_query("SELECT * FROM ".$WordBanTable,$db); while ($myrow_wordswap = mysql_fetch_array($result_wordswap)) { $the_word = $myrow_wordswap["word"]; $message_emailable = ereg_replace($the_word, "!*#$%",$message_emailable); } // Replace the new lines with encoded line breaks for HTML (thanks milahu). $message = str_replace("\n", "c#lb", $message); // Use HTML encoding on ame and message so database doesn't misinterpret data. $name = htmlentities($name); $message = htmlentities($message, ENT_COMPAT); // IP address of submitter and time of post. $ip = $_SERVER["REMOTE_ADDR"]; $name = $_SERVER["HTTP_X_MXIT_NICK"]; $msg = $_POST['StringyChat_message']; $post_time = date("U"); $mxitid = $_SERVER["HTTP_X_MXIT_LOGIN"]; if(!isset($mxitid)) { $mxitid = "DEFAULT"; } if(!isset($name)) { $name = "SYSOP"; } // check to see if a duplicate exists $sql = "SELECT * FROM StringyChat WHERE StringyChat_ip=\"$ip\" AND StringyChat_message=\"$msg\" AND StringyChat_time>($post_time - 30 )"; $result = mysql_query($sql); $myrow = mysql_fetch_array($result); if($myrow["StringyChat_message"] == "") { // Checks if record not matching in db // Save the record $sql = "INSERT INTO StringyChat (StringyChat_ip,StringyChat_name,StringyChat_message,StringyChat_time) VALUES (\"$ip\",\"$name\",\"$msg\",$post_time)"; $result = mysql_query($sql); $theTo = $email_notification_to; $theSubject = "New StringyChat post at ".$domain_installed; $theMessage = "A new StringyChat post has been made.\n\n"; $theMessage .= $name . "\n"; $theMessage .= date("H:i - d/m/y", $post_time) . "\n"; $theMessage .= $message_emailable . "\n\n"; $theMessage .= "Visit ".$domain_installed." to view StringyChat and much more!"; $theHeaders = "From: StringyChat at ".$domain_installed." <".$email_notification_to.">\r\n"; mail($theTo,$theSubject,$theMessage,$theHeaders); } else { echo "<span style='color:#10ce59'>Duplicate post detected!</span><p>"; } } else { echo "<span style='color:#10ce59'>You can't send blanks!</span><br><br>"; } unset($_POST["StringyChat_name"]); unset($_POST["StringyChat_message"]); unset($StringyChat_ip); unset($StringyChat_name); unset($StringyChat_message); unset($StringyChat_time); unset($mxit_id); } // get the info from the db $sql = "SELECT StringyChat_time, StringyChat_name, StringyChat_message FROM StringyChat ORDER BY id DESC LIMIT $offset, $rowsperpage"; $result = mysql_query($sql, $conn) or trigger_error("SQL", E_USER_ERROR); function filterBadWords($str) { $result1 = mysql_query("SELECT word FROM StringyChat_WordBan") or die(mysql_error()); $replacements = ":-x"; while($row = mysql_fetch_assoc($result1)) { $str = eregi_replace($row['word'], str_repeat(':-x', strlen($row['word'])), $str); } return $str; } // while there are rows to be fetched... while ($list = mysql_fetch_assoc($result)) //while (($pmsg = $list['StringyChat_message'] == $bwords) ? ":-x" : $list['StringyChat_message']) { // echo data //echo ($pmsg = ($list['StringyChat_message'] == $bwords) ? ":-x" : $list['StringyChat_message']) $admin = array('cobusbo','Admin+TT'); if (in_array($list['StringyChat_name'], $admin)) { print '<span style="color:#828282">' . '(' . date( 'D H:i:s', $list['StringyChat_time'] ) . ') ' . '</span>' . '<span style="color:red">' . '<b>' . $list['StringyChat_name'] . '</b>' . ' : ' . filterBadWords($list['StringyChat_message']) . '</span>' . '<br />' . '<p>'; } else { print '<span style="color:#828282">' . '(' . date( 'D H:i:s', $list['StringyChat_time'] ) . ') ' . '</span>' . '<b>' . $list['StringyChat_name'] . '</b>' . ' : ' . filterBadWords($list['StringyChat_message']) . '<br />' . '<p>'; } } // Load up the last few posts. The number to load is defined by the "ShowPostNum" variable. $result = mysql_query("SELECT * FROM ".$dbTable." ORDER BY StringyChat_time DESC LIMIT " . $ShowPostNum,$db); include("sort_widths.php"); while ($myrow = mysql_fetch_array($result)) { $msg = $myrow["StringyChat_message"]; // Convert the encoded line break into an actual <br> tag (thanks milahu) $msg = str_replace("c#lb", "<br>", $msg); // Convert the encoded image tag into a html tag $msg = eregi_replace("im#([a-z]{3})", "<img src=\"http://".$install_url."images/\\1.gif\" alt=\"emoticon\">",$msg); // split the lines $msg = htmlwrap($msg, $line_length); $result_wordswap = mysql_query("SELECT * FROM ".$WordBanTable,$db); while ($myrow_wordswap = mysql_fetch_array($result_wordswap)) { $the_word = $myrow_wordswap["word"]; $msg = ereg_replace($the_word, ":-x",$msg); } } ?> <? // end while /****** build the pagination links ******/ // range of num links to show $range = 3; // if not on page 1, don't show back links if ($currentpage > 1) { // show << link to go back to page 1 echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=1'><<</a> "; // get previous page num $prevpage = $currentpage - 1; // show < link to go back to 1 page echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$prevpage'><</a> "; } // end if // loop to show links to range of pages around current page for ($x = ($currentpage - $range); $x < (($currentpage + $range) + 1); $x++) { // if it's a valid page number... if (($x > 0) && ($x <= $totalpages)) { // if we're on current page... if ($x == $currentpage) { // 'highlight' it but don't make a link echo " [<b>$x</b>] "; // if not current page... } else { // make it a link echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$x'>$x</a> "; } // end else } // end if } // end for // if not on last page, show forward and last page links if ($currentpage != $totalpages) { // get next page $nextpage = $currentpage + 1; // echo forward link for next page echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$nextpage'>></a> "; // echo forward link for lastpage echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$totalpages'>>></a> "; } // end if /****** end build pagination links ******/ ?><br> <html> <span style="color:grey"><i>Type Your Message NOW!</i></span> <p><a href="page.php">Reload</a> | <a href="http://tt.2fh.co">Home</a><br></html>Any help please... If I send normal messages I don't get any errors... i am new with web socket
and in same time
I try to make server and client communication for soccer manager application, and for this purpose, i need to create closed "chat rooms" or "games" where two users can watch (read game event) and menage (create) game event (make substitution, formation ... or if you want, to send message to server, that they make changes in formation)
this game (room) mast bi secret, and only this two player can use this game for "read" and "write" events in game
for example: Game no: 200001 between user A and user B in 14.05.
when User A, and User B click on game no. 200001 they can read and write game event.
PS: for now, i create basic chat aplication with PHP, jQuery and webSocket and in this app, all user see wath all other user do (public chat) and i want to make secret chat for specific user (already automate subscribed from server) All work with no problem (i work on this example http://www.sanwebe.c...ket-php-socket)
How i can create chat room(s) and subscribe user to specific chat room?
Thanks
Edited by laponac84, 30 November 2014 - 09:09 AM. This topic has been moved to PHP Freelancing. http://www.phpfreaks.com/forums/index.php?topic=348869.0 This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=313684.0 This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=319561.0 This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=310049.0 This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=314681.0 This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=343070.0 |