<?php
session_start();
require_once "../class/mysql.class.php";
require_once "../class/utils.class.php";
require_once "../config.php";
require_once "../include/auth.lib.php";
$db = &new MySQL($_CONFIG['host'],$_CONFIG['user'],$_CONFIG['pass'],$_CONFIG['dbname'],null) or die('Unable to establish connection ');
$utils = new Utils($db,null);
list($status, $user) = auth_get_status();
if($status == AUTH_NOT_LOGGED){
$uname = strtolower(trim($_POST['uname']));
$passw = strtolower(trim($_POST['passw']));
$lang = $_POST['lang'];
$utils->setLang($lang);
if($uname == "" or $passw == ""){
$status = AUTH_INVALID_PARAMS;
}else{
list($status, $user) = auth_login($uname, $passw);
if(!is_null($user)){
list($status, $uid) = auth_register_session($user);
}
}
//set language
if ($utils->isIssetLang()) {
include "lang/".$utils->getLang();
} else {
include "lang/english.php";
}
}
echo '<div style="background: #FFFFFF; text-align: center;">
<img alt="EZPhotoPress" src="../images/logo.png" />
</div>';
switch($status){
case AUTH_LOGGED:
@header("Refresh: 5;URL=home.php");
echo '<style type="text/css">
@import url(css/style.css);
</style>';
echo '<br><br>';
echo '<center>';
echo '<img src="../images/loading.gif">';
echo '</center>';
echo '<br><br>';
echo '<div align="center">'.LOGIN_ALREADY_CONNECTED.'</div>';
break;
case AUTH_INVALID_PARAMS:
@header("Refresh: 5;URL=home.php");
echo '<style type="text/css">
@import url(css/style.css);
</style>';
echo '<br><br>';
echo '<center>';
echo '<img src="../images/loading.gif">';
echo '</center>';
echo '<br><br>';
echo '<div align="center">'.LOGIN_ENTERED_INCORRECT_DATA.'</div>';
break;
case AUTH_LOGEDD_IN:
switch(auth_get_option("TRANSICTION METHOD")){
case AUTH_USE_LINK:
@header("Refresh: 5;URL=home.php?uid=".$uid);
break;
case AUTH_USE_COOKIE:
@header("Refresh: 5;URL=home.php");
setcookie('uid', $uid, time()+3600*365);
break;
case AUTH_USE_SESSION:
@header("Refresh: 5;URL=home.php");
$_SESSION['uid'] = $uid;
break;
}
echo '<style type="text/css">
@import url(css/style.css);
</style>';
echo '<br><br>';
echo '<center>';
echo '<img src="../images/loading.gif">';
echo '</center>';
echo '<br><br>';
echo '<div align="center">'.LOGIN_SUCCESS_1.@$user['username'].LOGIN_SUCCESS_2.'</div>';
break;
case AUTH_FAILED:
@header("Refresh: 5;URL=home.php");
echo '<style type="text/css">
@import url(css/style.css);
</style>';
echo '<br><br>';
echo '<center>';
echo '<img src="../images/loading.gif">';
echo '</center>';
echo '<br><br>';
echo '<div align="center">'.LOGIN_BANKRUPTCY.'</div>';
break;
}
unset($db);
echo "<br><br><br>";
echo "<center>";
echo "<br><br><br>";
echo '<a href="home.php" style="color: #0000FF; text-decoration: none;">'.LOGIN_REFRESH_LINK.'</a>'.LOGIN_REFRESH;
echo "</centrer>";
?>