0

This is where the code begins to fail (fun.php): It also seems that the text file isn't being written to, it doesn't even create the file

<?php 
    session_start();

    if($_SESSION['LoggedIn'] == False)
    {
        header("Location: /login.php");
        return ;
    }
    include ('/home/manseld/public_html/scripts/config.php');

    if(($_SESSION['Banned'] == True && (!file_exists("/home/manseld/public_html/accounts/banned/". $_SESSION['CurrentUser'] .".txt"))))
    {
        $_SESSION['Banned'] = False;
    }

    if(file_exists("/home/manseld/public_html/accounts/banned/". $_SESSION['CurrentUser'] .".txt"))
    {
        header("Location: /error.php?e=banned&img=fuuu");
        return ;
    }
// Log User(s) IP 

    if(($_SESSION['LoggedIn'] == True) && (!$_SESSION['CurrentUser'] == "ManselD"))
    {
        ini_set('date.timezone', 'Europe/London');
        $ip = $_SERVER['REMOTE_ADDR'];
        $user = $_SESSION['CurrentUser'];
        $txt = date("h:i") ." | ". $user ." | ". $ip ."\n";
        $url = "accounts/logs/". trim(date(F) ."-". date(d) ."-". date(Y) .".txt");
        $file = fopen($url, "a");
        fwrite($file, $txt);
        fclose($file);
    }
?>

Now, this is where $_SESSION['CurrentUser']; Is set (In login.php) Or in this case, not set >.>

session_start();
$user = stripslashes($_POST['user']);
$pass = stripslashes($_POST['pass']);
$banned = "/home/manseld/public_html/accounts/banned/$user.txt";
$normal = "/home/manseld/public_html/accounts/$user.txt";
$_SESSION['CurrentUser'] = "$user";

if($_SESSION['LoggedIn'] == True){
header("Location: /fun.php");
return;
}else{
$_SESSION['LoggedIn'] = False;
}

if(isset($_POST['submit'])){
// Banned Users
if(($_SESSION['Banned'] == True && (!file_exists("/home/manseld/public_html/accounts/banned/".$_SESSION['CurrentUser'].".txt")))){
$_SESSION['Banned'] = False;
}
if(file_exists("/home/manseld/public_html/accounts/banned/".$_SESSION['CurrentUser'].".txt")){
$_SESSION['Banned'] = True;
header("Location: /error.php?e=banned&img=fuuu");
return;
}else{
$_SESSION['Banned'] = False;
}

I don't really think that it should be happening, it's pretty odd. Any ideas?

4

1 回答 1

0

我不太明白你的问题(哪个会话变量不起作用?)但是

$_SESSION['CurrentUser'] = "$user";

应该

$_SESSION['CurrentUser'] = $user;

于 2013-02-23T19:31:57.313 回答