PHP - Creating A Chat's Waiting Monitor
Hi all,
I have a tool currently in place that pulls information from one server and displays it. Currently in the setup, whenever the status of a chat has "Waiting". It's grouped with all other's as $num_waiting. The problem I am having is do to the server it pulls the information from, 1 session would equal 11 if there are 11 reps answering chats. The issue with divising by the number of active agents is on occasion the server reports more or less than the number of agents which in turn generates responses like 3.3333 and so on. And no the number with that status has never actually equaled to a single instance. As such you can see my dilemma here, I need to find a way of taking all sessions with that status and most likely cross-referencing another attribute such as $customername to prevent the doubles and finally provide only a single instance for each of these sessions. I am including the bulk of the current code below. Any help is much appreciated. Code: [Select] <?php $num_waiting = 0; foreach($loginParams as $login){ $soapclient = new soapclient("https://secure.logmeinrescue.com/API/API.asmx?WSDL"); $loginResult = $soapclient->login($login); if($login[sEmail] == "lmitnifron@telenetwork.com"){ } $hierparams = array(""=>""); $hierarchyResult = $soapclient->getHierarchy($hierparams); $hierarchy = $hierarchyResult->aHierarchy; $nodes = $hierarchy->HIERARCHY; $numberofnodes = count($nodes); $eNodeRef = "NODE"; echo "<table border =\"5\" cellspacing = \"5\">"; $totalsessioncount = 0; $numberoftechs = 0; for ($iNodes = 0; $iNodes < $numberofnodes; $iNodes += 1) { if($nodes[$iNodes]->eStatus == "Online" && $nodes[$iNodes]->eType == "Technician"){ if($nodes[$iNodes]->iParentID == 000000 || $nodes[$iNodes]->iParentID == 00000000){ print_r("<tr>"); $techname = $nodes[$iNodes]->sName; $emailaddress = findaddress($techname); echo '<td><a href="xmpp:' . $emailaddress . '?message&subject=chat">' . $techname .'</a><br /></td>'; $iNodeID = $nodes[$iNodes]->iNodeID; $sessionparams = array( 'iNodeID' => $iNodeID, 'eNodeRef' => $eNodeRef ); $sessionresult = $soapclient->getSession($sessionparams); $session = $sessionresult->aSessions; $sessionnodes = $session->SESSION; $numberofsessionnodes = count($sessionnodes); $totalsessioncount = $totalsessioncount + $numberofsessionnodes; $numberoftechs = $numberoftechs + 1; if($numberofsessionnodes >= 2) { for ($isessionNodes = 0; $isessionNodes < $numberofsessionnodes; $isessionNodes += 1) { $session_status = $sessionnodes[$isessionNodes]->sStatus; $session_customername = $sessionnodes[$isessionNodes]->sCustomField0; $isdouble = check_doubles($session_customername); if(!$isdouble && ($session_status != "Waiting")) { if(isset($session_status)){postsessioninfo($session_status, $session_customername);} }else{ $num_waiting++; } } } unset($session_customername); unset($session_starttime); print_r("</td>"); } } } print_r("</table>"); $soapclient->logout(); clear_table(); } $session_que = $num_waiting; echo "Sessions Waiting -- " . $session_que . "<br><br>"; ?> MOD EDIT: [code] . . . [/code] BBCode tags added. Similar TutorialsHi I'm currently investigating how much it will cost me approximately for someone to code me a basic chat script.
The script should be very basic (old school) PHP without any javascript or fancy options. must use Mysql as database.
Must use automatic login if the user match to certain HTTP header otherwise they must specify a username to register
Should not use css stylesheets must be inline styles
No cookies
Moderating
time ban(kick) for 1h, 12h, 24h, 7days, 1 month and 1 year and Permanent
Option to unkick/ban
Option to edit messages and delete messages.
The moderator should be able to type under hes real username and by using a prefix like a ? infront of hes message it must be able to post a message under the name Moderator in a different color.
Each time a person has been banned a message should appear saying something like user1 has been kicked for 7 days.
Display the amount of times being kicked within the last 30 days...
Admin Panel
time ban(kick) for 1h, 12h, 24h, 7days, 1 month and 1 year and Permanent
Option to unkick/ban
Option to edit messages and delete messages.
The Admin should be able to type under hes real username and by using a prefix like a ! infront of hes message it must be able to post a message under the name Admin in a different color.
Each time a person has been banned a message should appear saying something like user1 has been kicked for 7 days.
Display the amount of times being kicked within the last 30 days...
Option to rename Users usernames
Word filter with an option to specify the replacement word
Auto mute for specific time frame if a user used a word on the word filter
Option to make users moderators and remove them and option to specify text colors of the moderator and Admin and normal user using span and div styles
Option to remove messages older then a specified time.
Should be able to select how many messages must be displayed per page
Chat window
Should show the time posted in brackets in grey, name: and message
Should make use of pagination
should have a text link to page to show users currently active and chatting
Refresh option and highlight the font of the usernames in another color for new messages appearing after each refresh.
If a user is a moderator/admin he should get [x] option next to each message he can select to be able to do all the moderation / admin options of regarding the specific message/user.
The Admin should have another admin page regarding the setup of the chat like user/ moderation/admin text colors etc... witch he can access via a link to the specific page.
Note:
This is just for interest sake no real job offering yet.
I want this script to be able to be implemented via a .mobi portal on a IM application for mobiles named Mxit. It has many limitations...
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. Haven't done much in PHP for a while, and as a refresher and a bit of a challenge to myself I have decided to write up a simple game of sorts. Basically in the game I have townships, every play has their own town. And I want these towns to have events every 3-10 hours, and have these events have results such as births/deaths/fires/flooding/etc. At the moment I'm looking at this kind of setup: A database table with the city information.. city_id, city_owner_id, city_name, etc. I figure I can make another field such as city_nextevent and fill it with a timestamp plus a random number of seconds. then when the user views their city if city_nextevent is older than current time then run the event function and set the next event time. In my head this idea seems to work well, until I realised that if the user doesn't log on for 20+ hours the events will not stack, they will only get the one event when they next view their town when several events should have passed. I realise I could use a cronjob to check all events across all towns, but is there a better way of doing it. I had also though about adding several fields to the database containing say the next five event times, then updating each field after time had passed. Which gives more events if the user has been offline for 20+ hours. So if the play was offline for say a week, their town would pretty much dry up until they returned. Basically, I want their town to run while they're offline. But was trying to avoid using a cronjob. Anyone have any thoughts on how this could be done? I am in the process of creating a waiting list that I want to work automatically. When a new member registers for membership, the member must be on a waiting list for a while before the member gets permanent membership. When the membership is activated by me, I want this to work like when I delete the person who is number 1 in the list, and number 2 will be number 1. the remaining numbers in the list will automatically move a number up, just now . 5 will be number 4 and so on. PErson number one is the person that allways will be deleted from the waiting list. An idea would be that this persons name ande rest of data connected to hes membership number will be moved automaticaly to the permanent members list when hi is deleted from the waiting list. Only the name will be displayed in the member list, but the form that the new member submits will have several fields. There are t12 fields to be filled in in the MySQL database, but only the name and surname to be displayed in the list. The numbers will be generated automatically in front of the name. I have tried to do this by myself. I have tried to do this myself, but I do not succeed. I am very new when it comes to PHP and programming in general. Hope someone here can help me with this. I can not find out. Edited February 26 by LeonLatexHello all. I have a php script which will insert csv data into database using PDO. But it's slow even with just few thousands records. So how can I prevent client from waiting for it when they want to upload data? I tried INSERT DELAYED but it's not working... Thank you. Hello; I know there is a way but I just can't get it out of my head. I have my code that i want to show to the user and then i have code i want to execute but not show anything to user. I no am not making my self clear which i am sorry for so ill give you an example. <? show_my_site(true); // Now i have code which will never output anything but the webbrowser will always wait for it to complete my_function_that_takes_time(true, 'Very Long'); ?> So what i want is some code to tell the browser thats it! You have everything. I cant use die; or exit; because i want to execute the code. Thank-you Paul Hey guys. I'll be doing a frontend for some router testing scripts and I'll need to launch some shell scripts in php. The user will be allowed to check some checkboxes - choose which tests to run and run them using a button. I want to show them some kind of "Testing in progress" string and then show them the result when it's done. What do you think is the best solution ? I was thinking the shell script should create the whole output in some sensible form and then I would just parse it. Should I use a database for storing the error strings, or do you think they should be a part of the script ? Also, I would like to do it with AJAX (I never did it before and I could use some experience). So I need some advice on this. I want the form to disappear after the button was pressed, replace it with the "testing in progress" string (or maybe a temporary popup window would be better) and then if the script is done, display the result. I guess I need to use the Code: [Select] shell_exec command. What would you suggest ? btw I guess there is no way to run a script on a different server than one which runs the webpage, is there ? My provider says that my display_errors is set to off ( in an email, also I have a new provider and I can't see how to get to php.ini yet) I always thought that if display_errors is set to off that when a php error would occur that the screen would go blank from that spot and beyound. However when I put in the wrong connect info by mistake I got Warning: require( PATH TO connect.php (I changed this)) [function.require]: failed to open stream: No such file or directory in /this directory (I changed this) on line 10 Should this stuff be showing with display_errors set to off ? Hi, Is it possible to make some kind of network/web traffic sniffer than can give you stats on how much p2p, mail etc etc traffic is going out your router? If so, does anyone know of any tutorials on the subject? This topic has been moved to CSS Help. http://www.phpfreaks.com/forums/index.php?topic=347531.0 I am currently working on an application to schedule conferences. I have everything completed to create a conference including start time and duration. The problem I have now though is how do I monitor MySQL for the conferences that are created and perform actions when the duration of the conference is up? I was looking into MySQL events but those seem to be only internal events and are not able to execute anything outside of that. I was thinking about a infinite loop that queries MySQL and sleeps for one second but thought that this might be a lot of load on the server. Any thoughts I really appreciate it. Hi all im trying to build a chat like chathotel.http://chathotel.nl can someone help me out what the best way is to start ? I know php just trying to get it like this doesn’t get me on a start thanks would be great Edited May 29, 2019 by requinixunlinking Hi Guys Somehow I can't make this chat work... maybe you've got an idea what the problem is? main.php <?php session_start(); ?> <html> <head> <title>Chat</title> <script language="JavaScript"> msg = new Array(); function showchat() { for (i = 0; i < msg.length; i++) { show.document.write(msg[i]; show.document.write("<br />"); } show.document.write("<a name='end'></a>"); } </script> </head> <frameset rows="0,*,45" border="0"> <frame name="main" src="main.php"> <frame name="show" src="show.php"> <frame name="send" src="send.php" scrolling="no"> </frameset> </html> <?php session_start(); $time = $_SESSION['time']; if (!isset($time)) $time = 0; $hdlDB = mysql_connect('localhost', 'root', ''); $strSQL = "SELECT * FROM chat WHERE time > '$curTime'"; $dhlRS = mysql_db_query('chat', $strSQL, $hdlDB); while ($arrRS = mysql_fetch_assoc($hdlRS)) { $arrMsg[] = '<b>' . $arrRS['sender'] . '</b>: ' . $arrRS['data']; $time = max($arrRS['time'], $time); } session_register('time'); ?> <html> <head> <title>Chat</title> <script language="JavaScript"> <?php if (is_array($arrMsg)) { $i = 0; foreach($arrMsg as $strLine) { echo "top.msg[$i] = '$strLine';\n"; $I++; } } ?> top.show.location.reload(); </script> </head> <body onload="window.setInterval('location.reload()', 4000)"> </body> </html> send.php <?php session_start(); if (!isset($time)) $time = 0; if (strlen($_POST['newmsg'] > 2) { $hdlDB = mysql_connect('localhost', 'root'; ''); $curTime = time(); $strSQL = "INSERT INTO chat (time, data, sender) VALUES ('$curTime', $newmsg', '$sender')"; mysql_db_query('chat', $strSQL, $hdlDB); session_register('time'); } /* end if */ ?> <html> <head> <title>Chat</title> <script language="JavaScript"> <?php if (is_array($arrMsg)) { foreach($arrMsg as $strLine) echo "top.msg[top.msg.length]=\"$strLine\""; } ?> top.show.location.reload(); </script> </head> <body bgcolor="white"> <form action="<?php echo $PHP_SELF; ?>" method="post"> <select name="sender" size="1"> <option value="Admin" <?php $sender == 'Admin' ? print 'selected' : print ''; ?>>Admin <option value="Client" <?php $sender == 'Client' ? print 'selected' : print ''; ?>>Client </select> 's Beitrag: <input type="Text" name="newmsg" size="40"> <input type="Submit" value="Send"> </form> </body> </html> show.php <html> <head> <title>Chat</title> </head> <body> <script language="JavaScript"> top.showchat(); </script> </body> </html> Database (chat) CREATE TABLE chat ( id bigint(20) NOT NULL auto_increment, time varchar(10) NOT NULL, data text, sender varchar(32) DEFAULT '1' NOT NULL, PRIMARY KEY (id), KEY id (id) ); cheers, ozzo Hi All... I am facing some problem while coding chat system.....my problem is that whenever i refresh the chat page the last message stored in the url by the current user displays again....its showing messages from the other users also but its keep on repeating the messages of the current user logged in,in the browser.....i am using post for all....do i need to try something else or any new way etc....if anybody have suggestions and solutions for the above mentioned problem then please do help me out...thank you... Hi i would like a simple chat page on my site for my members. i already have a site login database and want to know how i can let people chat and have their names entered with thier message without them having to login in to something else or typing their name with each message, for example - tom says: hello Hi, I need to develop a module called chat with doctor. User can able to chat with the doctor for that he has to pay some amount to website. Say example user got purchase the Package worth : 2$ =>5min. After 5 min chat will be closed , timer should be shown while chatting. How can we do this? I need free php chat module or script. Please tell me any known or good script. thanks Hi, I'm trying to make an area where people can post stuff, status updates etc... I have a small layout done, but something has confused me. I'm trying to get it so when somebody is logged in, and posts something in the chat area, it displays: [Name] [Comment] I know how to read from the database, but for some reason, when I press the 'submit' button, the text in the 'comment' box isn't inserting into my 'comment' column in my database... But I want it so it inserts in the users column. Is this possible? Code: [Select] <?php if($submit) { $comment = $_POST['comment']; $submit = $_POST['submit']; $connect = mysql_connect("****","****","****") or die("Could not connect to database."); mysql_select_db("****") or die ("Could not find database!"); $query("INSERT INTO login ('comment') VALUES('$comment')"); $result = mysql_query($query) or die(mysql_error()); } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <form method="POST"> Comment: <input type="text" name="comment" /><br /> <input type="submit" name="submit" value="Submit" /><br /> </form> </body> </html> Can anyone suggest some good php Script(or Weburl) to do chat part in my php system please... Thanks in advance |