Support Forums
Connect IRC using php on linux systems - Printable Version

+- Support Forums (https://www.supportforums.net)
+-- Forum: Categories (https://www.supportforums.net/forumdisplay.php?fid=87)
+--- Forum: Coding Support Forums (https://www.supportforums.net/forumdisplay.php?fid=18)
+---- Forum: PHP The Hypertext Preprocessor (https://www.supportforums.net/forumdisplay.php?fid=21)
+---- Thread: Connect IRC using php on linux systems (/showthread.php?tid=1380)

Pages: 1 2


Connect IRC using php on linux systems - immi - 10-13-2009

Hello SF Victoire

This script is created to be used for connecting to IRC clients using PHP on a linux system.

PHP Code:
<?
function phpbot($server$port$user$nick$realname$channel) {
  
$sockname fsockopen($server$port$errno$errstr) or exit("$errno $errstr");
  
$repeat "0";
  while (
$sockread fgets($sockname512)) {
    
$sockread explode(" "$sockread);
    if (!
$repeat) {
      
fputs($sockname"USER $user x x :$realname\n");
      
fputs($sockname"NICK $nick\n");
    }
    if (
$sockread[0] == "PING") {
      
fputs($sockname"PONG :$sockread[1]\n");
    }
    if (
$sockread[1] == "001") {
      
fputs($sockname"JOIN $channel\n");
    }
    if (
fnmatch("43?"$sockread[1])) {
      
fputs($sockname"NICK $nick".str_repeat(mt_rand(09), 3)."\n");
    }
    
$repeat++;
  }
}
?>
<html>
<center>
<input type="button" onclick="<?=phpbot("irc.kingskrown.com","6667","phpbot","phpbot","phpbot","#kingskrown");?>" value="Connect"/>
</center>
</html> 

That's it Smile Enjoy


RE: Connect IRC using php on linux systems - Gaijin - 10-13-2009

Hey man thanks I've been looking for ways to do this, this is helpful!
Did you write this?


RE: Connect IRC using php on linux systems - immi - 10-13-2009

(10-13-2009, 02:29 AM)NinjaGeek Wrote: Hey man thanks I've been looking for ways to do this, this is helpful!

Thankyou Ninja Yeye


RE: Connect IRC using php on linux systems - Spl3en - 10-13-2009

I'm posting what i'm using for windows for connecting IRC using php :
PHP Code:
<html><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<
style type="text/css">html{background:#000;color:#0F0;font:Verdana, Geneva, sans-serif;font-size:12px;}</style>
</head>
<
body>
<?
php
    
//Configuration
    
$nick "Spl3enBot";
    
$user "Spl3en";
    
$channel "#whatever";
    
$server "irc.server.net";

    
//Begin of the script
    
$socket socket_create(AF_INETSOCK_STREAMSOL_TCP);
    
$result socket_connect($socketgethostbyname($server), 6667);
    
$in "NICK ".$nick."\r\n";
    
$in .= "USER  ".$user." 8 *  : ".$user."\r\n";
    
$in .= "USERHOST Userhost\r\n";
    
$in .= "JOIN :".$server."\r\n";
    
socket_write($socket$instrlen($in));
    while (
$out socket_read($socket1024)){
        if (
preg_match("/PING/i",$out)) socket_write($socket,"PONG ",strlen("PONG "));
        echo 
"<font color=blue>Socket_read = <i>".$out."</i></font><br>";
    }
    
socket_close($socket);
?>
</body></html> 

Hope it helps Smile


RE: Connect IRC using php on linux systems - immi - 10-14-2009

(10-13-2009, 06:12 PM)Spl3en Wrote: I'm posting what i'm using for windows for connecting IRC using php :
PHP Code:
<html><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<
style type="text/css">html{background:#000;color:#0F0;font:Verdana, Geneva, sans-serif;font-size:12px;}</style>
</head>
<
body>
<?
php
    
//Configuration
    
$nick "Spl3enBot";
    
$user "Spl3en";
    
$channel "#whatever";
    
$server "irc.server.net";

    
//Begin of the script
    
$socket socket_create(AF_INETSOCK_STREAMSOL_TCP);
    
$result socket_connect($socketgethostbyname($server), 6667);
    
$in "NICK ".$nick."\r\n";
    
$in .= "USER  ".$user." 8 *  : ".$user."\r\n";
    
$in .= "USERHOST Userhost\r\n";
    
$in .= "JOIN :".$server."\r\n";
    
socket_write($socket$instrlen($in));
    while (
$out socket_read($socket1024)){
        if (
preg_match("/PING/i",$out)) socket_write($socket,"PONG ",strlen("PONG "));
        echo 
"<font color=blue>Socket_read = <i>".$out."</i></font><br>";
    }
    
socket_close($socket);
?>
</body></html> 

Hope it helps Smile

I think thats very good. Thanks spleen


RE: Connect IRC using php on linux systems - manipulate - 10-20-2009

Check out PHP-iRC


RE: Connect IRC using php on linux systems - immi - 10-23-2009

(10-20-2009, 09:44 PM)iintens Wrote: Check out PHP-iRC

hmm , whats that, any link will be appreciated Smile


RE: Connect IRC using php on linux systems - Codine - 10-23-2009

http://www.phpbots.org/


RE: Connect IRC using php on linux systems - immi - 10-23-2009

(10-23-2009, 10:23 AM)Codine Wrote: http://www.phpbots.org/

Thanks, I will take a leap to this.


RE: Connect IRC using php on linux systems - Codine - 10-23-2009

You're welcome, i think that's the site your looking for, if not then i'll have another look for you.