Sunday, November 06, 2011

IRC - Get the user count of a channel in plain text with Denora/PHPDenora/

You need to have Denora and PHPDenora installed and running on your IRCd for this to work.

define("_VALID_PARENT", 1);
require ("libs/phpdenora/init.php");  //You have to provide the proper path to the file here
$link = sql_db_connect();
$channelcount = sql_fetch_array(sql_query("SELECT currentusers FROM ".$denora_chan_db." WHERE channel LIKE \"".mysql_real_escape_string(trim($_GET["channel"], '"'))."\";"));
if ($channelcount[0] == "") {
    $channelcount[0] = 0;
header("Content-type: text/plain");
echo $channelcount[0];

It works like this :

In PHP, you will probably want to use something like this :
$usercount = file_get_contents("");

The great thing with this is that you can now use some PHP to serve your users a user count badge for their channel.

See also :

No comments:

Post a Comment