PDA

View Full Version : Error during Admin log-in


cferrero
11th of February 2005 (Fri), 14:53
I've just installed EE 1.5RC4 to a new server. It all works fine, bar one thing.
When I go to the admin login page (http://myserver/myinputdir) I get the following error:

Warning: Cannot modify header information - headers already sent by (output started at /home/[myusername]/public_html/gallery/add/connect.php:71) in /home/[myusername]/public_html/gallery/[myinputdir]/SECURITY_check_authorization.php on line 25

LOGGED OUT
Please log in again from here.

When I click the suggested link, I can log in OK.
The only thing that may be relevant that I can think of is that I changed the input directory from the default 'input' to a different name (as suggested in the install instructions).

Any ideas what's going on?
I have PHP 4.3.9, Perl 5.8.4, MySQL 4.0.22-standard and Apache 1.3.33

Pekka
11th of February 2005 (Fri), 15:12
It is a bug of printing anything on page before setcookie() function was called. Here are the fixed files, let me know if these helped in your case:

EDITOR_loginpage.php



<?php
$is_editor = "1";
header("Expires: Mon, 15 Apr 2002 05:00:00 GMT"); // Date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // always modified
header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache"); // HTTP/1.0
ob_start ("ob_gzhandler");
include ("toroot.php");
include ($toroot . "add/connect.php");
include ($toroot . "language.php");
include ($toroot . "slashwork.php");


include ("SCRIPT_get_first_e.php");
include ($toroot . "fetchsettings.php");
include ("SCRIPT_editor_functions.php");



$currentpage = "adminlogin";

$getlang = $toroot . "languages/" . $lang . "/global.php";
include($getlang);



function ee_log_in ($username="", $password="") {

if ($username == "") return false;
if ($password == "") return false;

global $currentpage;

$admindata = mysql_query("
SELECT
ee_admin.ee_admin_name,
ee_admin.ee_admin_pass
FROM
ee_admin
WHERE
ee_admin.ee_admin_name = '$username'
");
ee_error ($admindata,"admindata",$currentpage);

while ($row = mysql_fetch_array($admindata)) {
$ee_username = $row["ee_admin_name"];
$ee_password = $row["ee_admin_pass"];
}
if ((@$ee_username == $username) && (@$ee_password == md5($password))) {
return true;
} else {
return false;
}
}


if (!ee_log_in(@$HTTP_POST_VARS['username'], @$HTTP_POST_VARS['password'])) {
$admindata = mysql_query("
SELECT
ee_admin.ee_admin_session_ip,
ee_admin.ee_admin_session_browser,
UNIX_TIMESTAMP(ee_admin.ee_admin_login) as logindate
FROM
ee_admin
");
ee_error ($admindata,"admindata",$currentpage);

while ($row = mysql_fetch_array($admindata)) {
$ee_ip = $row["ee_admin_session_ip"];
$ee_agent = ee_stripslashes($row["ee_admin_session_browser"]);
$ee_login = date("r", ee_stripslashes($row["logindate"]));
}

?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
<title>EE login</title>
</head>

<body>
<p style="font-size: 12px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;"><img src="graphs/ee_logo.jpg" width="90" height="72" alt="" border="0"></p>
<form action="EDITOR_loginpage.php" method="post">
<table><tr><td><p style="font-size: 12px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;"><b>Username:</b></p></td><td><input type="text" name="username" id="username"></td></tr>
<tr><td><p style="font-size: 12px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;"><b>Password:</b></p></td><td><input type="password" name="password" id="password"><br>
<tr><td></td><td><input type="submit" value="Log in">

</td></tr></table>
<BR>

</FORM>
<?php
print "<p style=\"font-size: 10px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;\">Last successful login was <b>{$ee_login}</b> from IP <b>{$ee_ip}</b> using browser <b>{$ee_agent}</b>";

exit;
}


$value = ee_make_suffix (256);
$value = md5($value);
$ip = ee_user_ip();
$agent = ee_addslashes($HTTP_SERVER_VARS['HTTP_USER_AGENT']);

$user = $HTTP_POST_VARS['username'];

$start_adminsession = mysql_query(
"
UPDATE
ee_admin
SET
ee_admin.ee_admin_session_id = '$value',
ee_admin.ee_admin_session_ip = '$ip',
ee_admin.ee_admin_session_browser = '$agent',
ee_admin.ee_admin_login = NOW()
WHERE
ee_admin.ee_admin_name = '$user'
"
);
ee_error ($start_adminsession,"start_adminsession",$currentpage);

setcookie ("user", $value, time()+3600*24*30*12*10,'/');
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>EE login</title>
</head>
<body>
<script language="JavaScript" type="text/javascript">
<!--
window.location="index.php";
// -->
</script>
<noscript><p><a href="index.php">Click here to continue.</a></noscript>
</body>
</html>



EDITOR_logout.php




<?php
$is_editor = "1";
header("Expires: Mon, 15 Apr 2002 05:00:00 GMT"); // Date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // always modified
header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache"); // HTTP/1.0
ob_start ("ob_gzhandler");
include ("toroot.php");
include ($toroot . "add/connect.php");
include ($toroot . "language.php");
include ($toroot . "slashwork.php");


include ("SCRIPT_get_first_e.php");
include ($toroot . "fetchsettings.php");
include ("SCRIPT_editor_functions.php");



$currentpage = "adminlogout";

$getlang = $toroot . "languages/" . $lang . "/global.php";
include($getlang);

$stored_session_id = @$HTTP_COOKIE_VARS['user'];
$stop_adminsession = mysql_query(
"
UPDATE
ee_admin
SET
ee_admin.ee_admin_logout = NOW(),
ee_admin.ee_admin_session_id = 0
WHERE
ee_admin_session_id = '$stored_session_id'
"
);
ee_error ($stop_adminsession,"stop_adminsession",$currentpage);

setcookie ("user", "", time() -9999999);

$delete_messages = mysql_query(
"
DELETE FROM
ee_message
WHERE
ee_message.ee_message_originator <> 'ftp'
"
);
if (!$delete_messages) {
print "<P>Error in performing query delete_messages: <br>" .
mysql_error();
exit();
}
$optimize = mysql_query(
"
OPTIMIZE TABLE ee_message
"
);


$delete_messages_ftp = mysql_query(
"
DELETE FROM
ee_message
WHERE
ee_message.ee_message_originator = 'ftp'
"
);
if (!$delete_messages_ftp) {
print "<P>Error in performing query delete_messages_ftp: <br>" .
mysql_error();
exit();
}
$optimize = mysql_query(
"
OPTIMIZE TABLE ee_message
"
);

$delete_messages_internal_ftp = mysql_query(
"
DELETE FROM
ee_message
WHERE
(ee_message.ee_message_originator = 'database action' OR ee_message.ee_message_originator = 'internal ftp' OR ee_message.ee_message_originator = 'imagemagick' OR ee_message.ee_message_originator = 'exif')
"
);
if (!$delete_messages_internal_ftp) {
print "<P>Error in performing query delete_messages_internal_ftp: <br>" .
mysql_error();
exit();
}
$optimize = mysql_query(
"
OPTIMIZE TABLE ee_message
"
);

$delete_messages_export_ftp = mysql_query(
"
DELETE FROM
ee_message
WHERE
ee_message.ee_message_originator = 'export - ftp'
"
);
if (!$delete_messages_export_ftp) {
print "<P>Error in performing query delete_messages_export_ftp: <br>" .
mysql_error();
exit();
}

?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>EE logout</title>
</head>
<body>
<script language="JavaScript" type="text/javascript">
<!--
window.location="<?php print $toroot . "index.php"; ?>";
// -->
</script>
<noscript><p><a href="EDITOR_loginpage.php">Click here to log in again.</a>
<br><a href="<?php print $toroot . "index.php"; ?>">Click here for gallery index.</a>
</noscript>
</body>
</html>

cferrero
13th of February 2005 (Sun), 13:06
Unfortunately, those new files have no effect. I still get the initial error when I try to log in.

Pekka
13th of February 2005 (Sun), 13:35
Is the error message same as before?

If so, please check that your add/connect.php is exactly like in EE zip (except for the passes of course). If there are any extra characters or linefeeds after last line...

?>

...then remove them and save the file again.

cferrero
14th of February 2005 (Mon), 09:00
That's the monkey! Thanks. :)
There was an extra linefeed at the end of connect.php.
How did it get there?

Pekka
14th of February 2005 (Mon), 09:39
Good! How did it get there - don't really know, perhaps added by ftp program? S**t happens :)