<?php

  # =======================================================================
  # Luciana Serra Website
  # Main page building script
  #
  # Last modification: 15-Apr-2007
  # =======================================================================

  # Set the date & time formatting parameters to it_CH
  # (Version for FreeBSD 4.x)
  setlocale(LC_TIME, "it_CH.ISO8859-1");

  # Load the global configuration parameters
  require_once("inc/config.inc");
  # Load the Smarty setup
  require_once("inc/smarty.inc");
  # Include the code to identify the user's language
  require_once("inc/lang.inc");

  # Base dir
  $MODULES_DIR = "modules";

  # -----------------------------------------------------------------------  
  
  # Start the session
  session_name("LSERRA");
  session_start();

  # Set the language to be used
  $lang = set_lang();  
  # Propagate the language
  $smarty->assign('lang', $lang);
  
  # Which module is to be loaded?
  if (isset($_GET['module'])) {
    $module_name = trim($_GET['module']);
  } else {
    $module_name = "homepage";
  }
  $module = $MODULES_DIR . "/" . $module_name . ".module";  
  # Check whether the chosen module really exists
  if (!file_exists($module)) {
    $module_name = "empty";
    $module = $MODULES_DIR . "/empty.module";
  }
  
  # Propagate the module's name
  $smarty->assign('module', $module_name);
  
  # Authenticate the user
  # require_once("inc/auth.inc");
  
  # Load the wanted PHP module
  require($module);
  
  # Display the page!
  $smarty->display($template);  

?>