Vous êtes ici Codes PHP et MySQL > Classes > ICQ class

 

ICQ class

Classe ICQ simple pour vérifié si un utilisateur est en ligne ou non .

$ICQ = new ICQ();
echo $ICQ->checkStatus(123456789);
 
Eric Potvin
Site de l'auteur voir
[4] sources en PHP voir
Code vu 5299 fois
Enregistré le 11 Oct 2005
  • Digg ce code sur digg.com
  • Bookmark ce code sur del.icio.us
  • Bookmark ce code sur Google
  • Bookmark ce code sur Yahoo
  • Ajoute ICQ class
  • Partage ce code sur Facebook
 
 
 
 

Code Source


01.
02.
03.
04.
05.
06.
07.
08.
09.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
69.
70.
71.
72.
73.
74.
75.
76.
77.
78.
79.
80.
 
<?php
/******************************************************************************/
/*                                                                            */
/*                       __        ____                                       */
/*                 ___  / /  ___  / __/__  __ _____________ ___               */
/*                / _ \/ _ \/ _ \_\ \/ _ \/ // / __/ __/ -_|_-<               */
/*               / .__/_//_/ .__/___/\___/\_,_/_/  \__/\__/___/               */
/*              /_/       /_/                                                 */
/*                                                                            */
/*                                                                            */
/******************************************************************************/
/*                                                                            */
/* Titre          : ICQ class                                                 */
/*                                                                            */
/* URL            : http://www.phpsources.org/scripts143-PHP.htm              */
/* Auteur         : Eric Potvin                                               */
/* Date édition   : 11 Oct 2005                                               */
/* Website auteur : http://www.zendphp.com                                    */
/*                                                                            */
/******************************************************************************/


class icq {
  var $timeout 0;
  var $error 0;
  var $errorString '';


        //vérifie le statu
  function checkStatus($icq '') {
    $raw_headers '';

    $icq init::toInteger($icq);
    $host 'status.icq.com';
    $path '/online.gif?icq='.$icq;
    
    $fp = @fsockopen ($host80$errno$errstr$this->timeout); 
    $this->errno $errno;
    $this->errstr $errstr;
    if (!$fp) {
      return false;
    } 
    else { 
      fputs ($fp,"GET ".$path." HTTP/1.1\r\n"); 
      fputs ($fp,"HOST: ".$host."\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 ($fp128);
      }
    }
    fclose ($fp);

    ereg("/0/(.*)Content-Length"$raw_headers$keywords);
    $filename basename ($keywords[1]);
    switch (trim($filename)) { 
      case 'online1.gif': 
        return 'online';    
        break; 
      case 'online0.gif': 
        return 'offline';
        break; 
      default: 
        return 'disable';
        break; 
    }
  }
  
  function getErrno() {
    return $this->error;
  }
  
  function getErrstr() {
    return $this->errorString;
  }

}
?>

 

Fonctions du code

: Ouvre une socket de connexion Internet ou Unix - (PHP 4, PHP 5)
: Alias de fwrite() - (PHP 4, PHP 5)
: Teste la fin du fichier - (PHP 4, PHP 5)
: Récupère la ligne courante sur laquelle se trouve le pointeur du fichier - (PHP 4,...
: Ferme un fichier - (PHP 4, PHP 5)
: Expression rationnelle standard - (PHP 4, PHP 5)
: Sépare le nom du fichier et le nom du dossier - (PHP 4, PHP 5)
: - (PHP 4, PHP 5)
Commentaire
Très pratique ces 60 lignes ! Merciwink
 
Ajouter un commentaire
Code de sécurité

Attention: Les champs marqués d'une étoile * sont obligatoires
 
Librairie PHP

Connexion

 
 

Classes

 
 

PHP

 
 
 
 
    Offres d'emploi

Plus de 500 offres d'emploi PHP/MySQL

Offres d'emploi
 
    Editeur PHP
 
        Publicité