home *** CD-ROM | disk | FTP | other *** search
/ Internet Magazine 2003 May / INTERNET103.ISO / pc / software / windows / building / php_nuke / html / blocks / block-who_is_online.php < prev    next >
Encoding:
PHP Script  |  2002-09-16  |  2.8 KB  |  68 lines

  1. <?php
  2.  
  3. ########################################################################
  4. # PHP-Nuke Block: Total Hits v0.1                                      #
  5. #                                                                      #
  6. # Copyright (c) 2001 by C. Verhoef (cverhoef@gmx.net)                  #
  7. #                                                                      #
  8. ########################################################################
  9. # This program is free software. You can redistribute it and/or modify #
  10. # it under the terms of the GNU General Public License as published by #
  11. # the Free Software Foundation; either version 2 of the License.       # 
  12. ######################################################################## 
  13.  
  14. if (eregi("block-Who_is_Online.php", $PHP_SELF)) {
  15.     Header("Location: index.php");
  16.     die();
  17. }
  18.  
  19. global $user, $cookie, $prefix, $dbi, $user_prefix;
  20.  
  21. cookiedecode($user);
  22. $ip = getenv("REMOTE_ADDR");
  23. $username = $cookie[1];
  24. if (!isset($username)) {
  25.     $username = "$ip";
  26.     $guest = 1;
  27. }
  28.  
  29. $result = sql_query("SELECT username FROM ".$prefix."_session where guest='1'", $dbi);
  30. $guest_online_num = sql_num_rows($result, $dbi);
  31.  
  32. $result = sql_query("SELECT username FROM ".$prefix."_session where guest='0'", $dbi);
  33. $member_online_num = sql_num_rows($result, $dbi);
  34.  
  35. $who_online_num = $guest_online_num + $member_online_num;
  36. $who_online = "<center><font class=\"content\">"._CURRENTLY." $guest_online_num "._GUESTS." $member_online_num "._MEMBERS."<br>";
  37.  
  38. $content = "$who_online";
  39.  
  40. if (is_user($user)) {
  41.     if (is_active("Private_Messages")) {
  42.     $result = sql_query("select uid from ".$user_prefix."_users where uname='$username'", $dbi);
  43.     list($uid) = sql_fetch_row($result, $dbi);
  44.     $newpm = sql_num_rows(sql_query("select * from ".$prefix."_priv_msgs where to_userid='$uid' and read_msg='0'", $dbi), $dbi);
  45.     if ($newpm != 0) {
  46.         $content .= "<br><center><a href='modules.php?name=Private_Messages'><img src=\"images/pm.gif\" border='0' alt=''></a></center>";
  47.     }
  48.     }
  49. }
  50.  
  51. $result = sql_query("select title from ".$prefix."_blocks where bkey='online'", $dbi);
  52. list($title) = sql_fetch_row($result, $dbi);
  53.  
  54. if (is_user($user)) {
  55.     $content .= "<br>"._YOUARELOGGED." <b>$username</b>.<br>";
  56.     if (is_active("Private_Messages")) {
  57.     $result = sql_query("select uid from ".$user_prefix."_users where uname='$username'", $dbi);
  58.     list($uid) = sql_fetch_row($result, $dbi);
  59.     $result2 = sql_query("select to_userid from ".$prefix."_priv_msgs where to_userid='$uid'", $dbi);
  60.     $numrow = sql_num_rows($result2, $dbi);
  61.     $content .= ""._YOUHAVE." <a href=\"modules.php?name=Private_Messages\"><b>$numrow</b></a> "._PRIVATEMSG."";
  62.     }
  63.     $content .= "</font></center>";
  64. } else {
  65.     $content .= "<br>"._YOUAREANON."</font></center>";
  66. }
  67.  
  68. ?>