ob_start();
ini_set('display_errors', 'On');error_reporting(E_ALL);
require_once '../class/config.php';
session_start();
if(isset($_POST['username'])){
$username = $db->escape($_POST['username']);
$password = $db->escape($_POST['password']);
$auth = new auth();
$login = $auth->login($username,$password);
if($login == true){
header("Location: $_SERVER[REQUEST_URI]");
}else{
$erro = $auth->errormsg[0];
}
}
if(isset($_COOKIE['auth_session'])){
$hash = $_COOKIE['auth_session'];
$auth = new auth();
$sessione = $auth->checksession($hash);
}
if(isset($_GET['logout'])){
$db->escape($_GET['logout']);
$auth->deletesession($hash);
header('Location: index.php');
}
?>
Jarvis v.2.0
if(!isset($_COOKIE['auth_session'])){
if(isset($_POST['username'])){
echo ''.$erro = $auth->errormsg[0].' ';
}
?>
}else{
if($sessione == false) {
//$auth->deletesession($hash);
header("Location: index.php");
} else {
$username = $array = $auth->sessioninfo($hash)->username;
$user = $db->get_row("select * from users where username = '$username'");
$_SESSION['userlevel'] = $user->level;
header('Location: main.php');
/*
$username = $array = $auth->sessioninfo($hash)->username;
echo 'Ciao '.$username.' ';
$user_id =$db->get_var("SELECT id FROM users WHERE username='$username'");
$websites = $db->get_results("SELECT * FROM websites where owner = '$user_id'");
$number_of_records = $db->num_rows;
if($number_of_records == "0"){
echo 'You not have any website to manage';
}else{
echo 'You have '.$number_of_records.' domain/s ';
foreach($websites as $k=>$v){
echo '
';
}
}
*/
}
}
?>