Tekil Mesaj gösterimi
Alt 30 Aralık 2012, 14:42   #6
Çevrimdışı
saywhat
Kullanıcıların profil bilgileri misafirlere kapatılmıştır.
IF Ticaret Sayısı: (0)
IF Ticaret Yüzdesi:(%)
Cevap: Php Bot Sorunu




basit yapıda örnek bir php.bottur.kod içinde nick ident realname bilgileri bağlanacağı sunucu deneyeceği bağlantı portları kodun alt kısmında $ircBot = new ircBot(); satırının altında ,kendinize göre değişip Shell'deki web klasörünüze atıyorsunuz ssh ile bağlanıp web klasöründeyken php dosya-adı.php komutu verdiniz mi bağlanıyor.bunu bikaç ay evvel yeğenim yazmıştı ben istemiştim ..geliştirmeye açıktır.istediğiniz değişiklikleri ekleri yapabilirsiniz.
[Üye Olmadan Linkleri Göremezsiniz. Üye Olmak için TIKLAYIN...]

[Üye Olmadan Linkleri Göremezsiniz. Üye Olmak için TIKLAYIN...]

PHP Kod:   Kodu kopyalamak için üzerine çift tıklayın!
<?php header("Content-Type:text/html;charset=utf-8"); set_time_limit(0); ?>
<?php ini_set
('zlib.output_compression''Off'); ?> 
<?php ini_set('output_buffering''Off'); ?>
<?php phpinfo
(); ?>
<?php
class ircBot{
 private 
$socket NULL;
 
 protected 
$nickName NULL;
 protected 
$altNickName NULL;
 protected 
$identName NULL;
 protected 
$realName NULL;
 protected 
$quitReason NULL;
 
 private 
$hostName NULL;
 private 
$portsArr = array();
 private 
$chansArr = array();
 private 
$selfGod "bot-sahibi";
 
 function 
ircConfig($nickName$identName$realName$altNickName "Guest"$quitReason){
  
$this->nickName $nickName;
  
$this->identName $identName;
  
$this->realName $realName;
  
$this->altNickName $altNickName.rand(0,99999);
  
$this->quitReason $quitReason;
 }
 
 function 
serverConfig($hostName$portsArr){
  
$this->hostName $hostName;
  
$this->portsArr = !is_array($portsArr) ? array($portsArr) : $portsArr;
 }
 
 function 
addChannels($chansArr){
  
$this->chansArr = !is_array($chansArr) ? array($chansArr) : $chansArr
 }
 
 function 
connect(){
  
$connStatus false;
  
$jumpPos 0;
  
$timeOut 5;
  while(!
$connStatus):
   
$currPort $this->portsArr[$jumpPos % (count($this->portsArr) - 1)];
   echo 
"Connecting to ".$this->hostName." on port ".$currPort."...<br \>\n\r";
   
flush();
   @
$this->socket fsockopen($this->hostName$currPort$errNo$errStr);
   if (!
$this->socket):
    switch(
$errNo):
     case 
10060:
      echo 
$errStr."<br />\r\r";
      
flush();
      echo 
"Trying another port... ";
      
flush();
      
$jumpPos++;
     case 
10061:
      echo 
$errStr."<br />\r\r";
      
flush();
      if(
$jumpPos > (count($this->portsArr) - 1)):
       echo 
"Connection canceled.";
       
flush();
       return 
false;
      else:
       echo 
"Trying another port... ";
       
flush();
       
$jumpPos++;
      endif;
      break;
    endswitch;
   else:
    echo 
"Connection established.<br />\n\r";
    
flush();
    
$connStatus true;
   endif;
   
flush();
  endwhile;
  echo 
"[RUN_FUNCTION] doLogin()<br />\n\r";
  
flush();
  echo 
$this->doLogin();
  
flush();
  echo 
"[RUN_FUNCTION] readStream()<br />\n\r";
  
flush();
  
$this->readStream();
  
flush();
  return 
true;
 }
 
 function 
readStream(){
  while(!
feof($this->socket)):
   
$serverMsg trim(fgets($this->socket1024));
   if (
$serverMsg != "") echo "[RECEIVE] ".$serverMsg."<br />\n\r";
   
flush();
   if(
substr($serverMsg06) == "PING :"):
    echo 
"[SENT] ".$this->writeStream("PONG"substr($serverMsg6));
    
flush();
   elseif(
strpos($serverMsg"005")):
    echo 
"[RUN_FUNCTION] joinChannels(chansArr)<br />\n\r";
    
flush();
    
$this->joinChannels($this->chansArr);
   elseif(
strpos($serverMsg"433")):
    echo 
"[RUN_FUNCTION] changeNick()<br />\n\r";
    
flush();
    
$this->changeNick();
   elseif(
strpos($serverMsg"Get off!")):
    echo 
"[RUN_FUNCTION] quitIRC(Okay... QQ)<br />\n\r";
    
flush();
    
$this->quitIRC("Okay... QQ");
    break;
   elseif(
strpos($serverMsg"376")):
    echo 
"[RUN_FUNCTION] identifyNS(123456)<br />\n\r";
    
$this->identifyNS("123456");
    
flush();
   endif;
   
flush();
  endwhile;
  
fclose($this->socket);
 }
 
 function 
writeStream($type$target NULL$message NULL){
  
$cmdText "";
  
$commandSuffix "\r\n";
  switch(
$type):
   case 
"NICK":
    
$cmdText $type." ".$target;
    break;
   case 
"USER":
    
$cmdText $type." ".$this->identName." 8 * : ".$this->realName;
    break;
   case 
"JOIN":
   case 
"PART":
   case 
"PING":
   case 
"PONG":
   case 
"QUIT":
    
$cmdText $type." :".$target;
    break;
   case 
"PRIVMSG":
    
$cmdText $type." ".$target." :".$message;
    break;
  endswitch;
  
$cmdText.=$commandSuffix;
  try{
   
fwrite($this->socket$cmdTextstrlen($cmdText));
  } catch(
Exception $e) {
   echo 
$e->getMessage(); 
  }
  return 
$cmdText."<br />\n\r";
 }
 
 function 
doLogin(){
  echo 
"[SENT] ".$this->writeStream("NICK"$this->nickName);
  echo 
"[SENT] ".$this->writeStream("USER");
 }
 
 function 
joinChannels($chanInput){
  foreach(
$chanInput as $channel):
   echo 
"[SENT] ".$this->writeStream("JOIN"$channel);    
  endforeach;
 }
 
 function 
changeNick($newNickName NULL){
  if (
$newNickName == NULL$newNickName $this->altNickName;
  echo 
"[SENT] ".$this->writeStream("NICK"$newNickName);
 }
 
 function 
quitIRC($quitReason NULL){
  
$quitReason = ($quitReason == NULL) ? $this->quitReason $quitReason;
  echo 
"[SENT] ".$this->writeStream("QUIT"$quitReason);
 }
 
 function 
identifyNS($password){
  echo 
"[SENT] ".$this->writeStream("PRIVMSG""NickServ""identify ".$password);
 }
}
?>
<?php
$ircBot 
= new ircBot();
$ircBot->ircConfig("botie-bot""botties""bots don't cry!""php-bot""kiss me and i kiss you back!");
$ircBot->serverConfig("irc.freenode.net", array(6667666866697000));
$ircBot->addChannels(array("##HNC"));
$ircBot->connect();
?>


 
Alıntı ile Cevapla

IRCForumlari.NET Reklamlar
sohbet odaları reklamver bizimmekan