Ok i made a php irc bot for my irc and here is the code
<?php
//Get Host, Port, Nick, Room And Nickserv here.
if ($_POST[nick] == "")
if ($_POST[pass] == "")
if ($_POST[host] == "")
if ($_POST[room] == "")
if ($_POST[port] ==""){
header("Location: wesbot.html");
exit;
}
//Set Nick, Host, Room, Port, and Pass here.
$nick = "$_POST[nick]";
$host = "$_POST[host]";
$room = "$_POST[room]";
$port = "$_POST[port]";
$pass = "$_POST[pass]";
//Set time limit as 0
set_time_limit (0);
//Open a connection to the Irc Server
$socket = fsockopen("$host", "$port") or die ('Could not open a connection to the irc server');
//Set User, Nick and Nickserv Password
fputs($socket, "USER wesircbot http://blankedoutforprivacy.net PHP :phphelpsite\n");
fputs($socket, "NICK $nick\n");
fputs($socket,"IDENTIFY $pass\n");
// Set endless loop until exit
while(1)
{
//Continue script here
while ($data = fgets($socket, 128))
{
echo nl2br($data);
flush();
//Seperate all of the data
$ex = explode(' ', $data);
//Respond to the Ping with a Pong
if($ex[0] == "PING")
{
fputs($socket, "PONG".$ex[1]."\n");
}
// Join a room
fputs($socket,"JOIN $room\n");
// Say something in a channel
$command = str_replace(array(chr(10), chr(13)), '', $ex[3]);
switch($command)
{
//i left out most command because they were unnecessary for my problem
case ':!end':
fputs($socket,"PRIVMSG ".$ex[2]." No Please dont! (O_0)\n");
die('Session ended.');
break;
default:
}
echo '<pre>';
print_r($ex);
echo '</pre>';
}
usleep(100000);
}
?>
But i get this error
Warning: fsockopen() [function.fsockopen]: unable to connect to wes.dnsdojo.com:6667 (A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. ) in C:\wamp\www\wesbot2.php on line 7
Could not connect to the server
can someone help me???