Public paste
Connecting part of my irc service
By: Arie | Date: Aug 25 2006 00:06 | Format: PHP | Expires: never | Size: 1.84 KB | Hits: 1763

  1.        
  2.         printf("PID: %sn",posix_getpid());
  3.         $this->Socket = @fsockopen($this->config['server'],$this->config['port'],$ErrNr,$ErrStr);
  4.         if (!$this->Socket) {
  5.                 $tmp = sprintf("nnProblems with connecting to %s:%snErrorNr.: %snErrStr.: %snn",$this->config['server'],$this->config['port'],$ErrNr,$ErrStr);
  6.                 die ($tmp);
  7.         }
  8.        
  9.         $Time = time();
  10.         $tmp = sprintf('PASS :%s',$this->config['password']);
  11.         $this->SendRaw($tmp,1);
  12.         $tmp = sprintf('SERVER %s 1 %s %s J10 %s]]] +s :%s',$this->config['cline'],$Time,$Time,$this->config['numeric'],$this->config['servicename']);
  13.         $this->SendRaw($tmp,1);
  14.             $this->loadCommands();
  15.                 $this->getAuths();
  16.                 $this->getChanlevs();
  17.         $tmp = sprintf('%s EB',$this->config['numeric']);
  18.         $this->SendRaw($tmp,1);
  19.         $this->Counter =0;
  20.        
  21.                 if ($this->config['debug']) {
  22.             printf("Bot sended his own information to the server, waiting for respond.n");
  23.             @ob_flush();
  24.         }
  25.        
  26.         $this->Idle();
  27.  
  28. // --------
  29.  
  30.                 while (!feof($this->Socket)) {
  31.                         $this->Get = fgets($this->Socket,512);
  32.                         if (!empty($this->Get)) {
  33.                                 $Args = explode(" ",$this->Get);
  34.                                
  35.                                 //$this->SendRaw($this->config['numeric'].' P '.$this->config['debug_channel'].' :'.$this->Get, 1);
  36.                                
  37.                                 if ($Args[0] == 'SERVER') $this->saveMainServer($Args);
  38.                                 $Cmd = trim($Args[1]);
  39.                                 switch ($Cmd) {
  40.                                         case "EB": /* End of Burst */
  41.                                                 $this->EA();
  42.                                                 $this->serverEndB($Args);
  43.                                                 break;
  44.                                         case "SQ":
  45.                                                 $this->squitServer($Args);
  46.                                                 break;
  47.                                         case "G": /* Ping .. Pong :) */
  48.                                                 $this->Pong($Args);
  49.