In the case of making a connection using fsockopen PHP used a command that allows you to open a socket on the specified server and port, in addition to running the script is certainly no specific requirement that you use the server must support PHP scripts, then allow you to use the fsockopen command. Next create a new file named form.html and place the code below:
HTML Code:
<html> <head> <title> IRC bot by www.hdteam.net </ title> </ Head> <body> <form method= "post" action= "irc.lib.php"> Nick: <input type= "text" name= "nick"> <br> User name: <input type= "text" name= "user"> <br> Real name: <input type= "text" name= "nama"> <br> Server: <input type= "text" name= "server"> <br> Port: <input type= "text" name= "port"> <br> Channel: <input type= "text" name= "channel"> <br> <input type= "submit" value= "join" name= "submit"> </ Form> </ Body> </ Html>
PHP Code:
<?php
set_time_limit ( 0 ); define ( 'CRLF' , "\r\n" ); $nick = $_POST [ 'nick' ]; $user = $_POST [ 'user' ]; $localhost = '127.0.0.1 ';
$server = $_POST[' server '];
$port = $_POST[' port '];
$nama = $_POST[' nama '];
$channel = $_POST[' channel '];
$fp = fsockopen($server,$port, &$err_num, &$err_msg, 30);
if(!$fp) {
echo "Maaf, tidak bisa menghubungi server $server";
exit;
}
$data = ' NICK ' . $nick . CRLF;
$data .= ' USER ' . $user . ' ' . $localhost . ' ' . $server . ' : ' . $nama . CRLF;
fputs($fp, $data);
$response = '';
while (!feof($fp)) {
$response .= fgets($fp, 1024);
while (substr_count($response,CRLF) != 0) {
$offset = strpos($response, CRLF);
$data = substr($response,0,$offset);
$response = substr($response,$offset+2);
if ( substr($data,0,1) == ' : ' ) {
$offsetA = strpos($data, ' ');
$dFrom = substr($data,1,$offsetA-1);
$offsetB = strpos($data, ' : ');
$dCommand = substr($data,$offsetA+1,$offsetB-$offsetA-1);
$dText = substr($data,$offsetB+2);
if (substr($dCommand,0,3) == ' 004 ' ) {
fputs($fp,' JOIN ' . $channel . CRLF);
}
elseif ( substr($dCommand,0,7) == ' PRIVMSG ' ) {
if ( Ord(substr($dText,0,1)) == 1 ) {
if ( substr($dText,1,4) == ' PING ' ) {
fputs($fp,' : ' . $nick . ' NOTICE ' . $dFrom . ' : ' .
chr(1) . ' PING ' . substr($dText,6) . chr(1) . CRLF);
}
elseif ( substr($dText,1,7) == ' VERSION ' ) {
fputs($fp,' : ' . $nick . ' NOTICE ' . $dFrom . ' : ' .
chr(1) . ' VERSION PHPirc ' . chr(1) . CRLF);
}
}
else {
fputs($fp,$dText . CRLF);
}
}
}
elseif ( substr($data,0,4) == ' PING ' ) {
fputs($fp,' PONG . substr ( $data , 5 ) . CRLF );
}
}
} fclose ( $fp ); ?>
The author suggest that you try this script only on a free hosting server only, because it feared if you use a hosting server you buy, then your account can be removed unilaterally by the management server.
No comments:
Post a Comment