0
votes

I'm hoping someone can help me with this.... I'm using a script called phpircchat....

I have it connecting to the server, displaying usernames and there's message coming from the server to the chat page (via mIRC)...

I've managed to get the message input to the php file to send to IRC "PRIVMSG" however i'm having difficulty in getting this to work and i'm hoping someone could possibly show me where i'm going wrong as i've spent nearly two weeks getting to this point...

//IRC Functions
function irc_write($socket, $msg) {
global $mode;
if ($mode == 1) {
return @fputs($socket, $msg);
} elseif ($mode == 2) {
return socket_write($socket, $msg);
}
}

function irc_nb($socket) {
global $mode;
if ($mode == 1) {
return socket_set_blocking($socket, false);
} elseif ($mode == 2) {
socket_set_nonblock($socket);
}
}

function irc_open($serv_addr, $serv_port, $errno, $errstr) {
global $mode;
if ($mode == 1) {
return fsockopen($serv_addr, $serv_port, $errno, $errstr);
} elseif ($mode == 2) {
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
socket_connect($socket, $serv_addr, $serv_port);
return $socket;
}
}

// POSTED FROM CHAT INPUT TO PHP FILE
$channel = $_POST['channel'];
$channel = '#'.$channel.'';
$cmd = $_POST['cmnd'];
set_time_limit(0);
$socket = irc_open($serv_addr, $serv_port, $errno, $errstr);
irc_nb($socket);
$command = "PRIVMSG $channel :$cmd\n";
irc_write($socket, $command);

I'd be very greatful to anyone who can help please, would really like to have this functioning

1
What is the definition of "working"? What do you expect the above to do? What is it actually doing? What debugging have you already done? Provide some sample inputs and related desired and actual outputs. - Patrick Q
Its not sending the PRIVMSG to the IRC server... I've been looking at other scripts to try and figure out why it's not sending , trying different methods, but completely stuck... - Steve

1 Answers

0
votes

Don't know if this is of any help but been working on something similar myself

if(strpos($server['READ_BUFFER'], "hiya")) 
{
    $chunk = $server['READ_BUFFER'];
    SendCommand('PRIVMSG #chan : hello how are you'. "\n\r");   
}