3 ob_implicit_flush(false);
8 $socket = fsockopen("127.0.0.1","5038", $errornum, $errorstr);
12 $better_status = array( 'AGENT_UNKNOWN' => 'Unknown',
13 'AGENT_IDLE' => 'Idle',
14 'AGENT_ONCALL' => 'On Call',
15 'AGENT_LOGGEDOFF' => 'Not Logged In' );
18 print "Couldn't open socket. Error #" . $errornum . ": " . $errorstr;
20 fputs($socket, "Action: Login\r\n");
21 fputs($socket, "UserName: $username\r\n");
22 fputs($socket, "Secret: $secret\r\n\r\n");
23 fputs($socket, "Action: Agents\r\n\r\n");
24 fputs($socket, "Action: Logoff\r\n\r\n");
26 while(!feof($socket)) {
27 $info = fscanf($socket, "%s\t%s\r\n");
30 $curr_agent = $info[1];
31 $agents[$curr_agent] = array();
34 $agents[$curr_agent]['Name'] = $info[1];
37 $agents[$curr_agent]['Status'] = $better_status[$info[1]];
40 $agents[$curr_agent]['LoggedInChan'] = $info[1];
44 $agents[$curr_agent]['LoggedInTime'] = date("D, M d Y g:ia", $info[1]);
46 $agents[$curr_agent]['LoggedInTime'] = "n/a";
50 $agents[$curr_agent]['TalkingTo'] = $info[1];
58 print "<html><head><title>Agents Status</title></head>\n<body>\n";
59 print "<table width=\"800px\" border=\"1\">\n";
60 print " <tr><th>Agent #</th><th>Agent Name</th><th>Agent Location</th><th>Agent Status</th><th>Agent Talking To</th><th>Agent Login Time</th></tr>\n";
62 foreach( $agents as $agent=>$curr ) {
63 print " <tr>\n <td>" . $agent . "</td>\n";
64 print " <td>" . $curr['Name'] . "</td>\n";
65 print " <td>" . $curr['LoggedInChan'] . "</td>\n";
66 print " <td>" . $curr['Status'] . "</td>\n";
67 print " <td>" . $curr['TalkingTo'] . "</td>\n";
68 print " <td>" . $curr['LoggedInTime'] . "</td>\n </tr>\n";
71 print "</table>\n</body>\n</html>\n";