<?php

  /*

      index.php

      Main page, with login form. [Commented]

      Changelog:
        2006-01-14 dave: Cleaned up code for v1.0 release
        2005-07-09 arne_sf: Added version constant, and code for redirecting
          to upgrade page when an old database version is detected
        
      ----

      Copyright (C) 2003  Central Manchester CLC
      Copyright (C) 2003  David Thorne (davethorne@gmail.com)

      This program is free software; you can redistribute it and/or
      modify it under the terms of the GNU General Public License
      as published by the Free Software Foundation version 2.

      This program is distributed in the hope that it will be useful,
      but WITHOUT ANY WARRANTY; without even the implied warranty of
      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      GNU General Public License for more details.

      You should have received a copy of the GNU General Public License
      along with this program; if not, write to the Free Software
      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

  */
  
  // Destroy any session that might exist effectively logging off
  session_start();
  session_destroy();

  // Version number of this release (also defined in upgrade.php)
  define(SCRIPTVERSION, '0.9.9');
      
  // Global configuration
  require_once 'system/db.php';
  require_once 'system/lang.php';
  require_once 'system/global_preferences.php';
  // require_once 'system/language_tools.php';  //Not completed d.chouinard
  
  // Check if database upgrade is necessary, if so redirect to upgrade page
  if ($global_prefs['version'] != SCRIPTVERSION) {
    header("location: upgrade.php");
  }

  // Page title
  $ptitle = 'Home';

  // Includes
  require 'header.php';

  // Language selection
  set_text_domain("index");

?>

  <script language="javascript" type="text/javascript" src="system/forms.js"></script>

  <h1><?php printf(gettext("Helpdesk Issue Manager v%s"), $global_prefs['version']);?></h1>
  <h2><?php printf(gettext("Welcome to version %s of the HelpMeICT issue management system."), $global_prefs['version']);?></h2>

  <div class="block">
    <form id="login" method="post" class="login" action="login.php">
      <input name="redirect" type="hidden" value="<?php echo $redirect?>" />
      <div class="labelfieldpair">
        <div class="name"><label for="user"><?php echo gettext("Username");?></label></div>
        <div class="value"><input name="user" id="user" type="text" size="15" maxlength="20" value="[username]" onfocus="focusElement(this)" onblur="blurElement(this)" /></div>
      </div>
      <div class="labelfieldpair">
        <div class="name"><label for="pass"><?php echo gettext("Password");?></label></div>
        <div class="value"><input type="password" name="password" id="pass" size="15" maxlength="20" /></div>
      </div>
      <div class="labelfieldpair">
        <div class="name">&nbsp;</div>
        <div class="value"><input type="submit" value="<?php echo gettext("Login"); ?>" /></div>
      </div>
    </form>
  </div>

<script language="javascript" type="text/javascript">
//<![CDATA[
<!--

  document.forms.login.user.focus();

//-->
//]]>
</script>

<?php

  // Include
  require 'footer.php';
?>
