<?php

/**
 *
 * INDEXU
 * Copyright(C), Nicecoder, 2000-2006, All Rights Reserved.
 *
 * INDEXU(tm) is protected by Indonesia and International copyright laws.
 * Unauthorized use or distribution of INDEXU(tm) is strictly prohibited,
 * violators will be prosecuted. To obtain a license for using INDEXU(tm),
 * please register at Nicecoder home page at http://www.nicecoder.com
 *
 * Author:
 *    Dody Rachmat Wicaksono (dody@nicecoder.com)
 *    M. Zuber (zubby@nicecoder.com)
 *
 */

  if (!defined('INDEXU')) {
    include "../application.php";
    block_whos_online();
  }

  function block_whos_online($params = array()) {
    global $theme_path, $active_theme;

    if (strpos($_SERVER['REQUEST_URI'], 'block.whos_online.php') === FALSE) {
      echo '<script language="javascript" type="text/javascript" src="blocks/block.whos_online.php"></script>';
      return;
    }

    $theme_path = $theme_path . $active_theme . "/";

    $tpl = new Template;

    $who = GetWhosOnline();
    $total_online = $who[0];
    $members_online = $who[1];
    $guest_online = $who[2];

    $i=3;
    $count_who = @count($who);
    while ($i < $count_who) {
      $un = $who[$i];
      $username_online .= "<a href=user_detail.php?u=$un>$un</a> ";
      $i++;
    }

    $tpl->assign("total_online", $total_online);
    $tpl->assign("members_online", $members_online);
    $tpl->assign("guest_online", $guest_online);
    $tpl->assign("username_online", $username_online);
    $content = $tpl->fetch('blocks/block.whos_online.html', 0);
    $content = explode("\n", $content);

    header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
    header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
    header("Cache-Control: no-store, no-cache, must-revalidate");
    header("Cache-Control: post-check=0, pre-check=0", false);
    header("Pragma: no-cache");
    header('Content-Type: application/x-javascript');

    while (list(, $v) = @each($content)) {
      $v = str_replace("\n", "", $v);
      $v = str_replace("\r", "", $v);
      $v = str_replace("\t", "", $v);
      echo "document.write(\"".addslashes($v)."\");";
    }
  }

?>
