我相信一切都是正確的。一直在扼殺我的脖子。調用成員函數LoggedIn()null
這裏是index.php。我只是包含這些文件,並從functions.php調用函數
我不知道發生了什麼。 這是一個properlly書面
<?php
if(basename($_SERVER['SCRIPT_FILENAME']) == basename(__FILE__)) die("Access denied");
ob_start();
require_once 'includes/app/config.php';
require_once 'includes/app/init.php';
if (!(empty($maintaince))) {
header('Location: maintenance.php');
exit;
}
if (!($user -> LoggedIn()) || !($user -> notBanned($odb))){
header('location: relogin.php');
die();
}
?>
這裏是functions.php的
<?php
class user {
function realIP(){
switch(true){
case (!empty($_SERVER['HTTP_X_REAL_IP'])) : return $_SERVER['HTTP_X_REAL_IP'];
case (!empty($_SERVER['HTTP_CLIENT_IP'])) : return $_SERVER['HTTP_CLIENT_IP'];
case (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) : return $_SERVER['HTTP_X_FORWARDED_FOR'];
default : return $_SERVER['REMOTE_ADDR'];
}
}
//Kijkt of de gebruiker zijn account geblockeerd is
function isBanned($odb){
$SQL = $odb -> prepare("SELECT `status` FROM `users` WHERE `ID` = ?");
$SQL -> execute(array($_SESSION['ID']));
$status = $SQL -> fetchColumn(0);
if ($status == 0){
return true;
} else {
//Blockeert de gebruiker, En logt hem uit
session_destroy();
return false;
}
}
//Kijkt of de gebruiker admin is
function isadmin(){
$SQL = $odb -> prepare("SELECT `rank` FROM `users` WHERE `ID` = ?");
$SQL -> execute(array($_SESSION['ID']));
$rank = $SQL -> fetchColumn(0);
if ($rank == 0){
return true;
} else {
return false;
}
}
//de login functie (bewaart cookies en http header data door middel van @session_start();)
function LoggedIN(){
@session_start();
if (isset($_SESSION['username'], $_SESSION['ID'])){
return true;
} else {
return false;
}
}
}
?>
這是什麼問題?這並不清楚。 – Carcigenicate
*「我確定一切都是正確的。」* ...我敢肯定這不是你的'$ user'對象是'null' – CD001
你在哪裏定義'$ user'變量? – aynber