foreach ($active as $handle) { $read_socket = array($handle); $write = null; $except = null; $changed = socket_select($read_socket, $write, $except, 0, 0); if ($changed > 0) { // Let's see what it has to say $data = socket_read($handle, 2048); // should be more than 512 to prevent empty pages and repeated messages!! if (empty($data)) { continue; } if (strlen($data) == 2048) { // socket_read has more data, ignore all data $DAEMON->trace('UFO with ' . $handle . ': Data too long; connection closed', E_USER_WARNING); $DAEMON->dismiss_ufo($handle, true, 'Data too long; connection closed'); continue; } if (!preg_match('/win=(chat|users|message|beep).*&chat_sid=([a-zA-Z0-9]*) HTTP/', $data, $info)) { // Malformed data $DAEMON->trace('UFO with ' . $handle . ': Request with malformed data; connection closed', E_USER_WARNING); $DAEMON->dismiss_ufo($handle, true, 'Request with malformed data; connection closed'); continue; } $type = $info[1]; $sessionid = $info[2]; $customdata = array(); switch ($type) { case 'chat': $type = CHAT_CONNECTION_CHANNEL; $customdata['quirks'] = 0;