Thread Rating:
  • 1 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Connect IRC using php on linux systems
#1
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
Reply
#2
Hey man thanks I've been looking for ways to do this, this is helpful!
Did you write this?
Reply
#3
(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
Reply
#4
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
Reply
#5
(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
Reply
#6
Check out PHP-iRC
[Completely Honest. Seriously.]

Protip: Anonymous Reputation Points are for Pussies
Reply
#7
(10-20-2009, 09:44 PM)iintens Wrote: Check out PHP-iRC

hmm , whats that, any link will be appreciated Smile
Reply
#8
http://www.phpbots.org/
FREE PSN CARDS, XBOX LIVE, GAMES + MORE VIEW THREAD Here Yeye
Reply
#9
(10-23-2009, 10:23 AM)Codine Wrote: http://www.phpbots.org/

Thanks, I will take a leap to this.
Reply
#10
You're welcome, i think that's the site your looking for, if not then i'll have another look for you.
FREE PSN CARDS, XBOX LIVE, GAMES + MORE VIEW THREAD Here Yeye
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  PHP Framework List: An Ultimate Guide to 102 PHP Frameworks for Web Developers tk-hassan 0 777 07-27-2020, 11:26 PM
Last Post: tk-hassan
  PHP Video Tutorials (PHP For Beginners) Eleqtriq 4 3,272 10-10-2011, 01:00 PM
Last Post: Greyersting
  Could not connect: Access denied for user 'root'@'localhost' nevets04 5 4,091 02-03-2011, 04:52 PM
Last Post: Gaijin

Forum Jump:


Users browsing this thread: 4 Guest(s)