note 22081 modified in function.ircg-pconnect by torben
| From: | torben@php.net | Date: | Thu, 06 Jun 2002 04:55:27 +0000 |
| Subject: | note 22081 modified in function.ircg-pconnect by torben | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-31520@lists.php.net to get a copy of this message | ||
As this is poorly documented, and I had trouble deciphering the example java code due to the lack of
descriptive names, I am placing this tiny bit of advice to help you figure it out:
You will need to create an html or php index file that sets up the following:
a main dialog window(where all user text goes)
a user input window (where all user input to main window comes from)
a box to inform you of who your users are.
Although there are many ways to create these boxes, I personally chose to use an IFRAME tag for the
main window, an IFRAME for the user input, and DIV box for the users.
<html>
<body>
<iframe src=mainwindow.php id=ircwindow class=ircwindow></iframe>
<iframe src=input.php id=inputbox class=inputbox></iframe>
<div id=userbox class=userbox></div>
</body>
</html>
you then need to set the current connection for output in mainwindow.php
-- mainwindow.php --
<?
$ircfd = ircg_pconnect( "MyNick","127.0.0.1","6667");
ircg_join ($ircfd,"#MyChan");
$_SESSION[ircfd] = $ircfd;
if (! ircg_set_current($ircfd)) {
die ("some error message");
}
?>
-- end of file --
-- input.php --
<?
/*
filter the user input like they did in the example, just make sure that you set $id to the handle
that mainwindow.php has created. You can do that with the session variable from above:
*/
echo <<<DONE
<html>
<body>
<form action="?" method="post" name=msginput>
<input name=msg id=msg type=text />
</form>
</body>
</html>
DONE;
$id = $_SESSION[ircfd];
$msg = $_POST[msg];
$msg = rtrim($msg," \t\n\r\0\x0B");
if ($msg != "") {
if (substr($msg,0,1) == "/") {
$args=explode(" ",$msg);
$esc = chr(1);
switch ($args[0]) {
case "/whois":
ircg_whois($id, $args[1]);
break;
}
} else {
ircg_msg ($id, "#MyChan",$msg);
}
exit;
}
-- end of file --
if you want to customize the interface, you are going to have to set it up in the
ircg_register_format_messages function. I ended up learning Jscript for the task, but how you do it
is up to you.
I hope this helps, I know it took me a few days to even get enough information to make a beginning
attempt.
Scott
--was--
As this is poorly documented, and I had trouble deciphering the example java code due to the lack of
descriptive names, I am placing this tiny bit of advice to help you figure it out:
You will need to create an html or php index file that sets up the following:
a main dialog window(where all user text goes)
a user input window (where all user input to main window comes from)
a box to inform you of who your users are.
Although there are many ways to create these boxes, I personally chose to use an IFRAME tag for the
main window, an IFRAME for the user input, and DIV box for the users.
<html>
<body>
<iframe src=mainwindow.php id=ircwindow class=ircwindow></iframe>
<iframe src=input.php id=inputbox class=inputbox></iframe>
<div id=userbox class=userbox></div>
</body>
</html>
you then need to set the current connection for output in mainwindow.php
-- mainwindow.php --
<?
$ircfd = ircg_pconnect( "MyNick","127.0.0.1","6667");
ircg_join ($ircfd,"#MyChan");
$_SESSION[ircfd] = $ircfd;
if (! ircg_set_current($ircfd)) {
die ("some error message");
}
?>
-- end of file --
-- input.php --
<?
/*
filter the user input like they did in the example, just make sure that you set $id to the handle
that mainwindow.php has created. You can do that with the session variable from above:
*/
echo <<<DONE
<html>
<body>
<form action="?" method="post" name=msginput>
<input name=msg id=msg type=text />
</form>
</body>
</html>
DONE;
$id = $_SESSION[ircfd];
$msg = $_POST[msg];
$msg = rtrim($msg," \t\n\r\0\x0B");
if ($msg != "") {
if (substr($msg,0,1) == "/") {
$args=explode(" ",$msg);
$esc = chr(1);
switch ($args[0]) {
case "/whois":
ircg_whois($id, $args[1]);
break;
}
} else {
ircg_msg ($id, "#MyChan",$msg);
}
exit;
}
-- end of file --
if you want to customize the interface, you are going to have to set it up in the
ircg_register_format_messages function. I ended up learning Jscript for the task, but how you do it
is up to you.
I hope this helps, I know it took me a few days to even get enough information to make a beginning
attempt.
Scott
http://www.php.net/manual/en/function.ircg-pconnect.php