<?php
/**
 * Login file of PHPGEN system.
 *
 * PHPGEN 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; either version 2 of the License, or
 * (at your option) any later version.
 *
 * PHPGEN 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 PHPGEN; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 * @copyright   EasySoft R&D Team (C) 2006
 * @author      Chunsheng Wang <wwccss@263.net>
 * @link        http://www.phpgen.com
 * @package     Member
 * @version     $Id: Login.php,v 1.6 2006/08/15 15:49:19 wangcs Exp $
 */
require_once("../Include/Init.php");

/* If the user submit username and password, check him and registe session. */
if(!empty($_REQUEST["UserName"]) and !empty($_REQUEST["Password"]) and $_REQUEST["ActionMode"] != "UserLang" and $_REQUEST["ActionMode"] != "UserStyle")
{
    if(genJudgeUser($_REQUEST["UserName"],$_REQUEST["Password"]))
    {
        $_SESSION["Projects"] = prjGetList($_SESSION["UserName"]);
        $MyJS->goto("../index.php");
        exit;
    }
}
/* If the user changed language or style, change them. */
elseif(!empty($_POST["UserLang"]) or !empty($_POST["UserStyle"]))
{
    setcookie("UserLang",  $_POST["UserLang"],  time()+360000, $_CFG["CookieDomain"]);
    setcookie("UserStyle", $_POST["UserStyle"], time()+360000, $_CFG["CookieDomain"]);
    $MyJS->goto("Login.php");
    exit;
}
/* Assign variables, display the login form. */
else
{
    $MyTPL->assign("LangList",  htmlSelect($_CFG["Lang"],     "UserLang",  "Reverse", $_CFG["UserLang"],  "onchange=submitForm('UserLang')"));
    $MyTPL->assign("StyleList", htmlSelect($_CFG["CssStyle"], "UserStyle", "Reverse", $_CFG["UserStyle"], "onchange=submitForm('UserStyle')"));
    $MyTPL->display($_TPL["TplFile"]);
}
?>