rendered paste body<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>PHP - Irc</title>
</head>
<body>
<?php
# - Variables
$bot = array();
$bot['nickname'] = "B_real1";
$bot['realname'] = "B_real1";
$bot['identity'] = "php";
$bot['hostname'] = "php.bot.at.jd.net";
$bot['server'] = "irc.freenode.net";
$bot['port'] = "6667";
$bot['channel'] = "#test"
# - Socket
if(!$bot['socket']=socket_create(AF_INET,SOCK_STREAM,SOLTCP)) {
die("Socket can not be made");
}
if(!@socket_bind($bot['socket'],$bot['hostname'])){
die("Can't bind to: <b>".$bot['hostname']."</b>");
}
if(!@socket_connect($bot['socket'],$bot['server'],$bot['port'])){
die("Can't connect to: <b>".$bot['server']."</b>");
}
function sockwrite($data){
global $bot;
socket_write($bot['socket'],$data."\r\n");
}
sockwrite("USER ".$bot['identity']." ".$bot['hostname']." ".$bot['server']." :".$bot['realname']);
sockwrite("NICK ".$bot['nickname']);
$channel = 0;
while($data=@socket_read($bot['socket'],65000,PHP_NORMAL_READ)){
if($data == "\n"){
continue;
}
$edata = explode(" ",$data);
for($i=0; isset($edata[$i]); $i++){
$edata[$i] = trim($edata[$i]);
}
if($channel == "0"){
sockwrite("JOIN ".$bot['channel']);
$channel = 1;
}
if($edata[0] == "PING"){
sockwrite("PONG ".$edata[1]);
}
}
?>
</body>
</html>