<?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_login();
  }

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

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

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

    $tpl = new Template;

    if(!$_COOKIE['COOKIE_USER_AUTHENTICATED']) {
      $logged_in = false;
    }
    else {
      $logged_in = true;
      $tpl->assign('username',$_COOKIE['COOKIE_USERNAME']);
    }

    $tpl->assign('logged_in',$logged_in);
    $content = $tpl->fetch('blocks/block.login.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)."\");";
    }
  }


?>