[Phpfreechat-svn] SF.net SVN: phpfreechat: [636] trunk/src
Status: Beta
Brought to you by:
kerphi
From: <ke...@us...> - 2006-06-30 17:04:06
|
Revision: 636 Author: kerphi Date: 2006-06-30 10:02:35 -0700 (Fri, 30 Jun 2006) ViewCVS: http://svn.sourceforge.net/phpfreechat/?rev=636&view=rev Log Message: ----------- Work in progress: create an API to query from external scripts the chat data (who is online, last posted messages) Modified Paths: -------------- trunk/demo/demo31_show_who_is_online-whoisonline.php trunk/demo/demo32_show_last_messages-config.php trunk/demo/demo32_show_last_messages-showlastmsg.php trunk/demo/index.php trunk/src/pfcinfo.class.php Modified: trunk/demo/demo31_show_who_is_online-whoisonline.php =================================================================== --- trunk/demo/demo31_show_who_is_online-whoisonline.php 2006-06-30 16:28:03 UTC (rev 635) +++ trunk/demo/demo31_show_who_is_online-whoisonline.php 2006-06-30 17:02:35 UTC (rev 636) @@ -2,7 +2,9 @@ require_once dirname(__FILE__)."/../src/pfcinfo.class.php"; $info = new pfcInfo( md5("Whois online demo") ); -$users = $info->getOnlineNick(); +// NULL is used to get all the connected users, but you can specify +// a channel name to get only the connected user on a specific channel +$users = $info->getOnlineNick(NULL); echo "<h1>A demo which explains how to get the connected users list</h1>"; @@ -10,10 +12,10 @@ $info = ""; $nb_users = count($users); if ($nb_users <= 1) - $info = "<strong>%d</strong> user is connected to the <strong>'%s'</strong> channel !"; + $info = "<strong>%d</strong> user is connected to the server !"; else - $info = "<strong>%d</strong> users are connected to the <strong>'%s'</strong> channel !"; -echo "<p>".sprintf($info, $nb_users, "")."</p>"; + $info = "<strong>%d</strong> users are connected to the server !"; +echo "<p>".sprintf($info, $nb_users)."</p>"; echo "<p>Here is the nicknames' list:</p>"; echo "<ul>"; Modified: trunk/demo/demo32_show_last_messages-config.php =================================================================== --- trunk/demo/demo32_show_last_messages-config.php 2006-06-30 16:28:03 UTC (rev 635) +++ trunk/demo/demo32_show_last_messages-config.php 2006-06-30 17:02:35 UTC (rev 636) @@ -1,9 +1,10 @@ <?php require_once dirname(__FILE__)."/../src/phpfreechat.class.php"; -$params["serverid"] = md5(__FILE__); // calculate a unique id for this chat $params["title"] = "Show last posted messages channel"; -$params["max_msg"] = 1; +$params["serverid"] = md5($params["title"]); // calculate a unique id for this chat +$params["max_msg"] = 20; +$params["channels"] = "channel1"; $pfc_config =& pfcGlobalConfig::Instance( $params ); -?> +?> \ No newline at end of file Modified: trunk/demo/demo32_show_last_messages-showlastmsg.php =================================================================== --- trunk/demo/demo32_show_last_messages-showlastmsg.php 2006-06-30 16:28:03 UTC (rev 635) +++ trunk/demo/demo32_show_last_messages-showlastmsg.php 2006-06-30 17:02:35 UTC (rev 636) @@ -1,8 +1,9 @@ <?php require_once dirname(__FILE__)."/../src/pfcinfo.class.php"; -$info = new pfcInfo( md5("Show last messages demo") ); -$lastmsg_raw = $info->getLastMsg(10); +$info = new pfcInfo( md5("Show last posted messages channel") ); +$lastmsg_raw = $info->getLastMsg("channel1", 10); +print_r($lastmsg_raw); echo "<h1>A demo which explains how to get the last posted messages</h1>"; Modified: trunk/demo/index.php =================================================================== --- trunk/demo/index.php 2006-06-30 16:28:03 UTC (rev 635) +++ trunk/demo/index.php 2006-06-30 17:02:35 UTC (rev 636) @@ -95,12 +95,12 @@ <li><a href="demo21_with_hardcoded_urls.php">demo21 - with hardcoded url: data_public_url, client_script_url ... (interesting for strange server configuration)</a></li> <li><a href="demo27_customized_command.php">demo27 - a customized command (/roll)</a></li> <li><a href="demo34_add_a_link_on_nicknames.php">demo34 - Shows how to add a link on the nicknames list</a></li> -<!-- + <li><a href="demo31_show_who_is_online-chat.php">demo31 - demo which show how to get the connected users list (chat script)</a></li> <li><a href="demo31_show_who_is_online-whoisonline.php">demo31 - demo which show how to get the connected users list (whoisonline script)</a></li> <li><a href="demo32_show_last_messages-chat.php">demo32 - demo which show how to get the last posted messages (chat script)</a></li> <li><a href="demo32_show_last_messages-showlastmsg.php">demo32 - demo which show how to get the last posted messages (showlastmsg script)</a></li> ---> + <li><a href="demo35_shared_memory.php">demo35 - demo which show how to use the shared memory container</a></li> <li><a href="demo43_change_the_nicknames_colors.php">demo43 - demo which show how to change the nicknames automatic colors</a></li> </ul> Modified: trunk/src/pfcinfo.class.php =================================================================== --- trunk/src/pfcinfo.class.php 2006-06-30 16:28:03 UTC (rev 635) +++ trunk/src/pfcinfo.class.php 2006-06-30 17:02:35 UTC (rev 636) @@ -14,18 +14,27 @@ $this->$key = $val; } - function getOnlineNick() + /** + * @return array(string) a list of online nicknames + */ + function getOnlineNick($channel = NULL) { $container =& $this->getContainerInstance(); - $users = $container->getOnlineNick(); + $res = $container->getOnlineNick($channel); + $users = array(); + if (isset($res["nickid"])) + foreach($res["nickid"] as $nickid) + $users[] = $container->getNickname($nickid); return $users; } - function getLastMsg($nb) + function getLastMsg($channel, $nb) { $container =& $this->getContainerInstance(); - $lastmsg_id = $container->getLastMsgId(); - $lastmsg_raw = $container->readNewMsg($lastmsg_id-10); + $lastmsg_id = $container->getLastId($channel); + echo $lastmsg_id; + die(); + $lastmsg_raw = $container->read($channel, $lastmsg_id-10); return $lastmsg_raw; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |