Foros del Web » Programando para Internet » PHP »

Usuarios de Mensajeria en Linea

Estas en el tema de Usuarios de Mensajeria en Linea en el foro de PHP en Foros del Web. Holas, ,como puedo saber el numero de usuarios conectados a un sistema de mensajeria, es decir a un usuario con cuenta por supuesto, pues yo ...
  #1 (permalink)  
Antiguo 29/03/2004, 14:26
Avatar de gildus  
Fecha de Ingreso: agosto-2003
Mensajes: 1.495
Antigüedad: 20 años, 7 meses
Puntos: 105
Usuarios de Mensajeria en Linea

Holas, ,como puedo saber el numero de usuarios conectados a un sistema de mensajeria, es decir a un usuario con cuenta por supuesto, pues yo quiero sabes cuantos usuarios estan conectados al usuario que tiene la cuanta en el sistema de mensajeria (por ejemplo Windows Messenger, Yahoo Messenger)..

Gracias
__________________
.: Gildus :.
  #2 (permalink)  
Antiguo 29/03/2004, 21:06
 
Fecha de Ingreso: noviembre-2003
Mensajes: 114
Antigüedad: 20 años, 4 meses
Puntos: 0
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";
}
  #3 (permalink)  
Antiguo 30/03/2004, 11:07
Avatar de gildus  
Fecha de Ingreso: agosto-2003
Mensajes: 1.495
Antigüedad: 20 años, 7 meses
Puntos: 105
Gracias DJ-Dom, Lo pruebare

__________________
.: Gildus :.
  #4 (permalink)  
Antiguo 01/04/2004, 08:59
Avatar de gildus  
Fecha de Ingreso: agosto-2003
Mensajes: 1.495
Antigüedad: 20 años, 7 meses
Puntos: 105
Hola DJ-Dom, estaba revisando y encontre que sobre la configuracion del IM_SERVER no la entiendo muy bien , y es que sera que se debe de tener una cuenta algo asi?, pues
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 :.
  #5 (permalink)  
Antiguo 11/04/2004, 02:24
 
Fecha de Ingreso: noviembre-2003
Mensajes: 114
Antigüedad: 20 años, 4 meses
Puntos: 0
¿lo resolviste?
__________________
Soporte y Creaciones PHP-Nuke:
NukeProjects.Net

if($Necesitas=="Ayuda"){
echo "No dudes en pedirla";
}
  #6 (permalink)  
Antiguo 11/04/2004, 17:28
Avatar de gildus  
Fecha de Ingreso: agosto-2003
Mensajes: 1.495
Antigüedad: 20 años, 7 meses
Puntos: 105
No, pues hasta ahora no logro acertar.
Haber si puedes porfavor ayudarme
__________________
.: Gildus :.
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 00:07.