Code: Select all
if ( !isset($user) ) {
die('there is no $user');
}
else if( !is_object($user) ) {
die('gettype(user): '.gettype($user));
}
if ($user->_checkLogin($processed['username'], $processed['password'], $remember)) {Moderator: General Moderators
Code: Select all
if ( !isset($user) ) {
die('there is no $user');
}
else if( !is_object($user) ) {
die('gettype(user): '.gettype($user));
}
if ($user->_checkLogin($processed['username'], $processed['password'], $remember)) {Code: Select all
$user->membersOnly();Code: Select all
function membersOnly() {
error_reporting(E_ALL);
ini_set('display_errors', true);
if (!$_SESSION['logged']) {
$_SESSION['log_to'] = $_SERVER['REQUEST_URI'];
session_write_close();
session_start();
$_SESSION['file'] = "login.php";
include 'message.php';
die();
}
}Code: Select all
<? include $_SESSION['file']; ?>Code: Select all
if ($form->valid()) {
$processed = $form->getProcessed();
$remember = $form->getValue('remember');
if (!isset($_SESSION['login'])) {
$_SESSION['login'] = 3;
} else {
if ($_SESSION['login'] <= 1) {
die('You cannot log in.');
}
}
if ( !isset($user) ) {
die('there is no $user');
}
else if( !is_object($user) ) {
die('gettype(user): '.gettype($user));
}
if ($user->_checkLogin($processed['username'], $processed['password'], $remember)) {
if (isset($_SESSION['log_to'])) {
redirect($_SESSION['log_to']);
} else {
redirect('account.php/');
}
} else {
failed($form);
}
} else {
begin_html();
$form->display();
}
function failed(&$form) {
begin_html();
echo "<p>You could not be logged in, $_SESSION[login] attempts left.</p>
<p>Possible reasons for this are:</p>
<ul>
<li>Your username and/or password is not correct.
Check your username and password and then try again.</li>
<li>You haven't " .
'<a href="signup.php" title="Sign up for an account, it is free">registered</a> yet</li>
<li>Your account is temporarily disabled.</li>
<li>You are trying to login simultaneously from two different computers or
two browsers on the same computer.</li>
</ul>';
$form->display();
}
?>Code: Select all
$db = db_connect();
echo '<div>Debug $user = new User<pre>', __FILE__, '@', __LINE__, ' [', __FUNCTION__, "]\n";
print_r(debug_backtrace());
echo "</div>\n";
$user = new User($db);Code: Select all
if ( !isset($user) ) {
echo '<div>!isset($user)<pre>', __FILE__, '@', __LINE__, ' [', __FUNCTION__, "]\n";
print_r(debug_backtrace()); echo "</pre>\n";
echo '<pre>included files: ', print_r(get_included_files()); echo "</pre>\n";
echo "</div>\n";
die();
}
else if( !is_object($user) ) {
die('gettype(user): '.gettype($user));
}Code: Select all
Debug $user = new User
g:\programs(2)\easyphp1-8\www\ha\previous\new folder\htdocs\message.php@71 []
Array
(
[0] => Array
(
[file] => g:\programs(2)\easyphp1-8\www\ha\previous\new folder\htdocs\lib\user.php
[line] => 240
[function] => include
)
[1] => Array
(
[file] => g:\programs(2)\easyphp1-8\www\ha\previous\new folder\htdocs\account.php
[line] => 7
[function] => membersonly
[class] => user
[type] => ->
[args] => Array
(
)
)
)Code: Select all
!isset($user)
g:\programs(2)\easyphp1-8\www\ha\previous\new folder\htdocs\message.php@72 []
Array
(
[0] => Array
(
[file] => g:\programs(2)\easyphp1-8\www\ha\previous\new folder\htdocs\lib\user.php
[line] => 240
[function] => include
)
[1] => Array
(
[file] => g:\programs(2)\easyphp1-8\www\ha\previous\new folder\htdocs\account.php
[line] => 7
[function] => membersonly
[class] => user
[type] => ->
[args] => Array
(
)
)
)
included files: Array
(
[0] => g:\programs(2)\easyphp1-8\www\ha\previous\new folder\htdocs\account.php
[1] => g:\programs(2)\easyphp1-8\www\ha\previous\new folder\htdocs\global.php
[2] => g:\programs(2)\easyphp1-8\www\ha\previous\new folder\htdocs\functions.php
[3] => g:\programs(2)\easyphp1-8\www\ha\previous\new folder\config.php
[4] => g:\programs(2)\easyphp1-8\www\ha\previous\new folder\htdocs\session_defaults.php
[5] => g:\programs(2)\easyphp1-8\www\ha\previous\new folder\htdocs\lib\user.php
[6] => g:\programs(2)\easyphp1-8\www\ha\previous\new folder\htdocs\DB.php
[7] => g:\programs(2)\easyphp1-8\www\ha\previous\new folder\htdocs\PEAR.php
[8] => g:\programs(2)\easyphp1-8\www\ha\previous\new folder\htdocs\DB\mysql.php
[9] => g:\programs(2)\easyphp1-8\www\ha\previous\new folder\htdocs\DB\common.php
[10] => g:\programs(2)\easyphp1-8\www\ha\previous\new folder\htdocs\message.php
[11] => g:\programs(2)\easyphp1-8\www\ha\previous\new folder\htdocs\includeright.php
[12] => g:\programs(2)\easyphp1-8\www\ha\previous\new folder\htdocs\includeleft.php
[13] => g:\programs(2)\easyphp1-8\www\ha\previous\new folder\htdocs\login.php
[14] => g:\programs(2)\easyphp1-8\www\ha\previous\new folder\htdocs\html_form.php
[15] => g:\programs(2)\easyphp1-8\www\ha\previous\new folder\htdocs\HTML\Table.php
[16] => g:\programs(2)\easyphp1-8\www\ha\previous\new folder\htdocs\HTML\Common.php
)
1The first code snippet was supposed to be inserted there.m2babaey wrote:here:Code: Select all
$db = db_connect(); $user = new User($db);
And the second code snippet should replace (or extend) the old debug codevolka wrote:$db = db_connect();
echo '<div>Debug $user = new User<pre>', __FILE__, '@', __LINE__, ' [', __FUNCTION__, "]\n";
print_r(debug_backtrace());
echo "</div>\n";
$user = new User($db);
if ( !isset($user) ) {
die('there is no $user');
}
else if( !is_object($user) ) {
die('gettype(user): '.gettype($user));
}
volka wrote:if ( !isset($user) ) {
echo '<div>!isset($user)<pre>', __FILE__, '@', __LINE__, ' [', __FUNCTION__, "]\n";
print_r(debug_backtrace()); echo "</pre>\n";
echo '<pre>included files: ', print_r(get_included_files()); echo "</pre>\n";
echo "</div>\n";
die();
}
else if( !is_object($user) ) {
die('gettype(user): '.gettype($user));
}
Code: Select all
Debug $user = new User
g:\programs(2)\easyphp1-8\www\ha\previous\new folder\htdocs\global.php@11 []
Array
(
[0] => Array
(
[file] => g:\programs(2)\easyphp1-8\www\ha\previous\new folder\htdocs\account.php
[line] => 4
[function] => require_once
)
)
Warning: session_start(): Cannot send session cookie - headers already sent by (output started at g:\programs(2)\easyphp1-8\www\ha\previous\new folder\htdocs\global.php:11) in g:\programs(2)\easyphp1-8\www\ha\previous\new folder\htdocs\lib\user.php on line 238
Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at g:\programs(2)\easyphp1-8\www\ha\previous\new folder\htdocs\global.php:11) in g:\programs(2)\easyphp1-8\www\ha\previous\new folder\htdocs\lib\user.php on line 238Code: Select all
!isset($user)
g:\programs(2)\easyphp1-8\www\ha\previous\new folder\htdocs\login.php@36 []
Array
(
[0] => Array
(
[file] => g:\programs(2)\easyphp1-8\www\ha\previous\new folder\htdocs\message.php
[line] => 70
[function] => include
)
[1] => Array
(
[file] => g:\programs(2)\easyphp1-8\www\ha\previous\new folder\htdocs\lib\user.php
[line] => 240
[args] => Array
(
[0] => g:\programs(2)\easyphp1-8\www\ha\previous\new folder\htdocs\message.php
)
[function] => include
)
[2] => Array
(
[file] => g:\programs(2)\easyphp1-8\www\ha\previous\new folder\htdocs\account.php
[line] => 7
[function] => membersonly
[class] => user
[type] => ->
[args] => Array
(
)
)
)
included files: Array
(
[0] => g:\programs(2)\easyphp1-8\www\ha\previous\new folder\htdocs\account.php
[1] => g:\programs(2)\easyphp1-8\www\ha\previous\new folder\htdocs\global.php
[2] => g:\programs(2)\easyphp1-8\www\ha\previous\new folder\htdocs\functions.php
[3] => g:\programs(2)\easyphp1-8\www\ha\previous\new folder\config.php
[4] => g:\programs(2)\easyphp1-8\www\ha\previous\new folder\htdocs\session_defaults.php
[5] => g:\programs(2)\easyphp1-8\www\ha\previous\new folder\htdocs\lib\user.php
[6] => g:\programs(2)\easyphp1-8\www\ha\previous\new folder\htdocs\DB.php
[7] => g:\programs(2)\easyphp1-8\www\ha\previous\new folder\htdocs\PEAR.php
[8] => g:\programs(2)\easyphp1-8\www\ha\previous\new folder\htdocs\DB\mysql.php
[9] => g:\programs(2)\easyphp1-8\www\ha\previous\new folder\htdocs\DB\common.php
[10] => g:\programs(2)\easyphp1-8\www\ha\previous\new folder\htdocs\message.php
[11] => g:\programs(2)\easyphp1-8\www\ha\previous\new folder\htdocs\includeright.php
[12] => g:\programs(2)\easyphp1-8\www\ha\previous\new folder\htdocs\includeleft.php
[13] => g:\programs(2)\easyphp1-8\www\ha\previous\new folder\htdocs\login.php
[14] => g:\programs(2)\easyphp1-8\www\ha\previous\new folder\htdocs\html_form.php
[15] => g:\programs(2)\easyphp1-8\www\ha\previous\new folder\htdocs\lib\filter.php
)
1Code: Select all
<?php
$globalvar = 'xyz';
function foo() {
// echo $globalvar; <- notice undefined variable
include 'bar.php';
}Code: Select all
function foo() {
global $globalvar;$_SESSION['$file']? I only seem2babaey wrote:but I'm trying to manage to have only one page message.php and show all other messages in other parts of the site there by only changing the value of $_SESSION['$file']
And why does message.php include login.php on line 70 ?m2babaey wrote:$file="login.php";