![sonrisota](http://static.forosdelweb.com/fdwtheme/images/smilies/xD.png)
Gracias
![Adios](http://static.forosdelweb.com/fdwtheme/images/smilies/adios.gif)
| |||
hay una clase que lo hace n phpclasses yo lo descargue.... Archivo de la clase: CIMStatus.php <?php /* * This script was writed by Setec Astronomy - [email protected] * * This class allows to check the online status of an IM account. * It connects to one of the many onlinestatus servers and request * the IM status * * This script is distributed under the GPL License * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * http://www.gnu.org/licenses/gpl.txt * */ define ("IM_ONLINE", 1); define ("IM_OFFLINE", 2); define ("IM_UNKNOWN", 3); define ("IM_ICQ", "icq"); define ("IM_AIM", "aim"); define ("IM_JABBER", "jabber"); define ("IM_MSN", "msn"); define ("IM_YAHOO", "yahoo"); // Configuration section // $GLOBALS["IM_SERVERS"][] = "http://www.the-server.net:8000/"; $GLOBALS["IM_SERVERS"][] = "http://www.the-server.net:8000/"; $GLOBALS["IM_SERVERS"][] = "http://www.the-server.net:8001/"; $GLOBALS["IM_SERVERS"][] = "http://www.the-server.net:8002/"; $GLOBALS["IM_SERVERS"][] = "http://www.the-server.net:8003/"; /* $GLOBALS["IM_SERVERS"][] = "http://turdinc.kicks-ass.net:6969/"; $GLOBALS["IM_SERVERS"][] = "http://status.galaxyradioaustria.com:8080/"; $GLOBALS["IM_SERVERS"][] = "http://osi.hshh.org:8088/"; $GLOBALS["IM_SERVERS"][] = "http://snind.gotdns.com:8080/"; $GLOBALS["IM_SERVERS"][] = "http://www.eliott-ness.com:2324/"; $GLOBALS["IM_SERVERS"][] = "http://mightymichelob.tcworks.net:8080/"; $GLOBALS["IM_SERVERS"][] = "http://www.electrocity.ca:81/"; $GLOBALS["IM_SERVERS"][] = "http://4.11.204.17/"; $GLOBALS["IM_SERVERS"][] = "http://www.nextstepcomputers.ath.cx:8080/"; */ // End configuration section // class CIMStatus { var $timeout = 20; var $medium; var $account = ""; function CIMStatus ($account = "", $medium = IM_ICQ) { $this->medium = $medium; $this->account = $account; } // Begin private functions // function _safe_set (&$var_true, $var_false = "") { if (!isset ($var_true)) { $var_true = $var_false; } } // End private functions // function execute (&$errno, &$errstr) { $errno = ""; $errstr = ""; $raw_headers = ""; if (empty ($this->account)) { $errno = "-1"; $errstr = "Account ID not specified!"; return false; } srand((float) microtime() * 10000000); $server = $GLOBALS["IM_SERVERS"][array_rand ($GLOBALS["IM_SERVERS"])]; $url = parse_url ($server); $this->_safe_set ($url["host"], "localhost"); $this->_safe_set ($url["port"], "80"); $this->_safe_set ($url["path"], "/"); $url["path"] = trim ($url["path"]); if (substr ($url["path"], -1) != "/") { $url["path"] .= "/"; } $url["path"] .= $this->medium . "/" . $this->account . "/onurl=online/offurl=offline"; if (!function_exists ("fsockopen")) { $errno = "-1"; $errstr = "Function fsockopen not founded!"; return false; } else { $fp = fsockopen ($url["host"], $url["port"], $errno, $errstr, $this->timeout); if (!$fp) { return false; } else { fputs ($fp,"GET " . $url["path"] . " HTTP/1.1\r\n"); fputs ($fp,"HOST: " . $url["host"] . ":" . $url["port"] . "\r\n"); fputs ($fp,"User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)\r\n"); fputs ($fp,"Connection: close\r\n\r\n"); while (!feof ($fp)) { $raw_headers .= fgets ($fp, 128); } } fclose ($fp); $headers = array (); $tmp_headers = explode ("\n", $raw_headers); foreach ($tmp_headers as $header) { $tokens = explode (":", $header, 2); if (isset ($tokens[0]) && (trim($tokens[0]) != "")) { if (!isset ($tokens[1])) { $tokens[1] = ""; } $headers[] = array ($tokens[0] => trim($tokens[1])); } } $location = ""; foreach ($headers as $header) { if (isset ($header["Location"])) { $location = $header["Location"]; break; } } $parse_location = parse_url ($location); $this->_safe_set ($parse_location["host"], "unknown"); switch ($parse_location["host"]) { case "online": return IM_ONLINE; break; case "offline": return IM_OFFLINE; break; default: return IM_UNKNOWN; break; } } } } ?> Archivo de ejemplo para probarlo: test.php <?php /* * This script was writed by Setec Astronomy - [email protected] * * This script is distributed under the GPL License * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * http://www.gnu.org/licenses/gpl.txt * */ ?> <html> <head> <title>CIMStatus Class Test</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <form action="" method="get" name="CIMStatus"> Medium : <select name="medium" size="1"> <option value="aim">AIM</option> <option value="icq">ICQ</option> <option value="jabber">Jabber</option> <option value="msn">MSN</option> <option value="yahoo">Yahoo</option> </select> <br /> Account <input name="account" type="text" value="<?php if (isset ($_GET["account"])) { print ($_GET["account"]); }?>"> <input name="submit" type="submit" value="Query"> </form> <?php include ("CIMStatus.php"); if (isset ($_GET["account"]) && isset ($_GET["medium"])) { $imstatus = new CIMStatus ($_GET["account"], $_GET["medium"]); $status = $imstatus->execute ($errno, $errstr); if ($status) { switch ($status) { case IM_ONLINE: print (ucfirst ($_GET["medium"]) . " " . $_GET["account"] . " is online!"); break; case IM_OFFLINE: print (ucfirst ($_GET["medium"]) . " " . $_GET["account"] . " is offline!"); break; case IM_UNKNOWN: print (ucfirst ($_GET["medium"]) . " " . $_GET["account"] . " is in an unknown status!"); break; } } else // if ($status) { print ("An error occurred during CIMStatus query: <br />"); print ("Error n. " . $errno . ": " . $errstr); } } ?> </body> </html> Un saludo, DJ-Dom
__________________ Soporte y Creaciones PHP-Nuke: NukeProjects.Net if($Necesitas=="Ayuda"){ echo "No dudes en pedirla"; } |
| ||||
Hola DJ-Dom, estaba revisando y encontre que sobre la configuracion del IM_SERVER no la entiendo muy bien ![]() de elije a ramdom un el mismo servidor consiferentes puertos, como debe ser la configuracion de estos: $GLOBALS["IM_SERVERS"][] = "http://www.the-server.net:8000/"; $GLOBALS["IM_SERVERS"][] = "http://www.the-server.net:8000/"; $GLOBALS["IM_SERVERS"][] = "http://www.the-server.net:8001/"; $GLOBALS["IM_SERVERS"][] = "http://www.the-server.net:8002/"; $GLOBALS["IM_SERVERS"][] = "http://www.the-server.net:8003/"; Por favor ![]() Gracias ![]()
__________________ .: Gildus :. |
| |||
¿lo resolviste?
__________________ Soporte y Creaciones PHP-Nuke: NukeProjects.Net if($Necesitas=="Ayuda"){ echo "No dudes en pedirla"; } |