?? jabber.class
字號:
$this->logfile[] = "<strong>message</strong> (type groupchat) from $from"; } function Handler_message_headline($packet) { $from = $packet["message"]["@"]["from"]; $this->logfile[] = "<strong>message</strong> (type headline) from $from"; } function Handler_message_error($packet) { $from = $packet["message"]["@"]["from"]; $this->logfile[] = "<strong>message</strong> (type error) from $from"; } // ====================================================================== // <iq/> handlers // ====================================================================== // application version updates function Handler_iq_jabber_iq_autoupdate($packet) { $from = $this->GetInfoFromIqFrom($packet); $id = $this->GetInfoFromIqId($packet); $this->SendError($from, $id, 501); $this->logfile[] = "<strong>jabber:iq:autoupdate</strong> from $from"; } // interactive server component properties function Handler_iq_jabber_iq_agent($packet) { $from = $this->GetInfoFromIqFrom($packet); $id = $this->GetInfoFromIqId($packet); $this->SendError($from, $id, 501); $this->logfile[] = "<strong>jabber:iq:agent</strong> from $from"; } // method to query interactive server components function Handler_iq_jabber_iq_agents($packet) { $from = $this->GetInfoFromIqFrom($packet); $id = $this->GetInfoFromIqId($packet); $this->SendError($from, $id, 501); $this->logfile[] = "<strong>jabber:iq:agents</strong> from $from"; } // simple client authentication function Handler_iq_jabber_iq_auth($packet) { $from = $this->GetInfoFromIqFrom($packet); $id = $this->GetInfoFromIqId($packet); $this->SendError($from, $id, 501); $this->logfile[] = "<strong>jabber:iq:auth</strong> from $from"; } // out of band data function Handler_iq_jabber_iq_oob($packet) { $from = $this->GetInfoFromIqFrom($packet); $id = $this->GetInfoFromIqId($packet); $this->SendError($from, $id, 501); $this->logfile[] = "<strong>jabber:iq:oob</strong> from $from"; } // method to store private data on the server function Handler_iq_jabber_iq_private($packet) { $from = $this->GetInfoFromIqFrom($packet); $id = $this->GetInfoFromIqId($packet); $this->SendError($from, $id, 501); $this->logfile[] = "<strong>jabber:iq:private</strong> from $from"; } // method for interactive registration function Handler_iq_jabber_iq_register($packet) { $from = $this->GetInfoFromIqFrom($packet); $id = $this->GetInfoFromIqId($packet); $this->SendError($from, $id, 501); $this->logfile[] = "<strong>jabber:iq:register</strong> from $from"; } // client roster management function Handler_iq_jabber_iq_roster($packet) { $from = $this->GetInfoFromIqFrom($packet); $id = $this->GetInfoFromIqId($packet); $this->SendError($from, $id, 501); $this->logfile[] = "<strong>jabber:iq:roster</strong> from $from"; } // method for searching a user database function Handler_iq_jabber_iq_search($packet) { $from = $this->GetInfoFromIqFrom($packet); $id = $this->GetInfoFromIqId($packet); $this->SendError($from, $id, 501); $this->logfile[] = "<strong>jabber:iq:search</strong> from $from"; } // method for requesting the current time function Handler_iq_jabber_iq_time($packet) { $type = $this->GetInfoFromIqType($packet); $from = $this->GetInfoFromIqFrom($packet); $id = $this->GetInfoFromIqId($packet); $id = ($id != "") ? $id : "time_" . time(); if ($type == "get") { $payload = "<utc>" . gmdate("Ydm\TH:i:s") . "</utc> <tz>" . date("T") . "</tz> <display>" . date("Y/d/m h:i:s A") . "</display>"; $this->SendIq($from, "result", $id, "jabber:iq:time", $payload); } $this->logfile[] = "<strong>jabber:iq:time</strong> (type $type) from $from"; } // method for requesting version function Handler_iq_jabber_iq_version($packet) { $type = $this->GetInfoFromIqType($packet); $from = $this->GetInfoFromIqFrom($packet); $id = $this->GetInfoFromIqId($packet); $id = ($id != "") ? $id : "version_" . time(); if ($type == "get") { $payload = "<name>" . $this->iq_version_name . "</name> <os>" . $this->iq_version_os . "</os> <version>" . $this->iq_version_version . "</version>"; $this->SendIq($from, "result", $id, "jabber:iq:version", $payload); } $this->logfile[] = "<strong>jabber:iq:version</strong> (type $type) from $from"; } // ====================================================================== // <presence/> handlers // ====================================================================== function Handler_presence_available($packet) { $from = $this->GetInfoFromPresenceFrom($packet); $show_status = $this->GetInfoFromPresenceStatus($packet) . " / " . $this->GetInfoFromPresenceShow($packet); $show_status = ($show_status != " / ") ? " ($addendum)" : ""; $this->logfile[] = "<strong>Presence:</strong> (type: available) - $from is available $show_status"; } function Handler_presence_unavailable($packet) { $from = $this->GetInfoFromPresenceFrom($packet); $show_status = $this->GetInfoFromPresenceStatus($packet) . " / " . $this->GetInfoFromPresenceShow($packet); $show_status = ($show_status != " / ") ? " ($addendum)" : ""; $this->logfile[] = "<strong>Presence:</strong> (type: unavailable) - $from is unavailable $show_status"; } function Handler_presence_subscribe($packet) { $from = $this->GetInfoFromPresenceFrom($packet); $this->subscription_queue[] = $from; $this->RosterUpdate(); $this->logfile[] = "<strong>Presence:</strong> (type: subscribe) - Subscription request from $from, was added to \$this->subscription_queue, roster updated"; } function Handler_presence_subscribed($packet) { $from = $this->GetInfoFromPresenceFrom($packet); $this->RosterUpdate(); $this->logfile[] = "<strong>Presence:</strong> (type: subscribed) - Subscription allowed by $from, roster updated"; } function Handler_presence_unsubscribe($packet) { $from = $this->GetInfoFromPresenceFrom($packet); $this->SendPresence("unsubscribed", $from); $this->RosterUpdate(); $this->logfile[] = "<strong>Presence:</strong> (type: unsubscribe) - Request to unsubscribe from $from, was automatically approved, roster updated"; } function Handler_presence_unsubscribed($packet) { $from = $this->GetInfoFromPresenceFrom($packet); $this->RosterUpdate(); $this->logfile[] = "<strong>Presence:</strong> (type: unsubscribed) - Unsubscribed from $from's presence"; } // ====================================================================== // Generic handlers // ====================================================================== // Generic handler for unsupported requests function Handler_NOT_IMPLEMENTED($packet) { $packet_type = $this->_get_packet_type($packet); $from = call_user_func(array(&$this, "GetInfoFrom" . ucfirst($packet_type) . "From"), $packet); $id = call_user_func(array(&$this, "GetInfoFrom" . ucfirst($packet_type) . "Id"), $packet); $this->SendError($from, $id, 501); $this->logfile[] = "<strong>Unrecognized <$packet_type/></strong> from $from"; } // ====================================================================== // Third party code // m@d pr0ps to the coders ;) // ====================================================================== // xmlize() // (c) Hans Anderson / http://www.hansanderson.com/php/xml/ function xmlize($data) { $vals = $index = $array = array(); $parser = xml_parser_create(); xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0); xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1); xml_parse_into_struct($parser, $data, $vals, $index); xml_parser_free($parser); $i = 0; $tagname = $vals[$i]['tag']; $array[$tagname]["@"] = $vals[$i]["attributes"]; $array[$tagname]["#"] = $this->_xml_depth($vals, $i); return $array; } // _xml_depth() // (c) Hans Anderson / http://www.hansanderson.com/php/xml/ function _xml_depth($vals, &$i) { $children = array(); if ($vals[$i]['value']) { array_push($children, trim($vals[$i]['value'])); } while (++$i < count($vals)) { switch ($vals[$i]['type']) { case 'cdata': array_push($children, trim($vals[$i]['value'])); break; case 'complete': $tagname = $vals[$i]['tag']; $size = sizeof($children["$tagname"]); $children[$tagname][$size]["#"] = trim($vals[$i]['value']); if ($vals[$i]["attributes"]) { $children[$tagname][$size]["@"] = $vals[$i]["attributes"]; } break; case 'open': $tagname = $vals[$i]['tag']; $size = sizeof($children["$tagname"]); if ($vals[$i]["attributes"]) { $children["$tagname"][$size]["@"] = $vals[$i]["attributes"]; $children["$tagname"][$size]["#"] = $this->_xml_depth($vals, $i); } else { $children["$tagname"][$size]["#"] = $this->_xml_depth($vals, $i); } break; case 'close': return $children; break; } } return $children; } // TraverseXMLize() // (c) acebone@f2s.com, a HUGE help! function TraverseXMLize($array, $arrName = "array", $level = 0) { if ($level == 0) { echo "<pre>"; } while (list($key, $val) = @each($array)) { if (is_array($val)) { $this->TraverseXMLize($val, $arrName . "[" . $key . "]", $level + 1); } else { echo '$' . $arrName . '[' . $key . '] = "' . $val . "\"\n"; } } if ($level == 0) { echo "</pre>"; } }} class MakeXML extends Jabber{ var $nodes; function MakeXML() { $nodes = array(); } function AddPacketDetails($string, $value = NULL) { if (preg_match("/\(([0-9]*)\)$/i", $string)) { $string .= "/[\"#\"]"; } $temp = @explode("/", $string); for ($a = 0; $a < count($temp); $a++) { $temp[$a] = preg_replace("/^[@]{1}([a-z0-9_]*)$/i", "[\"@\"][\"\\1\"]", $temp[$a]); $temp[$a] = preg_replace("/^([a-z0-9_]*)\(([0-9]*)\)$/i", "[\"\\1\"][\\2]", $temp[$a]); $temp[$a] = preg_replace("/^([a-z0-9_]*)$/i", "[\"\\1\"]", $temp[$a]); } $node = implode("", $temp); // Yeahyeahyeah, I know it's ugly... get over it. ;) echo "\$this->nodes$node = \"" . htmlspecialchars($value) . "\";<br/>"; eval("\$this->nodes$node = \"" . htmlspecialchars($value) . "\";"); } function BuildPacket($array = NULL) { if (!$array) { $array = $this->nodes; } if (is_array($array)) { array_multisort($array, SORT_ASC, SORT_STRING); foreach ($array as $key => $value) { if (is_array($value) && $key == "@") { foreach ($value as $subkey => $subvalue) { $subvalue = htmlspecialchars($subvalue); $text .= " $subkey='$subvalue'"; } $text .= ">\n"; } elseif ($key == "#") { $text .= htmlspecialchars($value); } elseif (is_array($value)) { for ($a = 0; $a < count($value); $a++) { $text .= "<$key"; if (!$this->_preg_grep_keys("/^@/", $value[$a])) { $text .= ">"; } $text .= $this->BuildPacket($value[$a]); $text .= "</$key>\n"; } } else { $value = htmlspecialchars($value); $text .= "<$key>$value</$key>\n"; } } return $text; } } function _preg_grep_keys($pattern, $array) { while (list($key, $val) = each($array)) { if (preg_match($pattern, $key)) { $newarray[$key] = $val; } } return (is_array($newarray)) ? $newarray : FALSE; }}class CJP_StandardConnector{ function OpenSocket($server, $port) { return fsockopen($server, $port); } function CloseSocket($connection) { return fclose($connection); } function WriteToSocket($connection, $data) { return fwrite($connection, $data); } function ReadFromSocket($connection, $chunksize) { return fread($connection, $chunksize); }}?>
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -