Ok, I do not know which error is the lesser of 2 evils to fix, but I have 2 codes that insert the resolution, but each have a different error in some other place.
The first code:
ob_start()
<?
session_start();
if(isset($HTTP_COOKIE_VARS["users_resolution"]))
$screen_res = $HTTP_COOKIE_VARS["users_resolution"];
else //means cookie is not found set it using Javascript
{
?>
<script language="javascript">
<!--
writeCookie();
function writeCookie()
{
var today = new Date();
var the_date = new Date("December 31, 2023");
var the_cookie_date = the_date.toGMTString();
var the_cookie = "users_resolution="+ screen.width +"x"+ screen.height;
var the_cookie = the_cookie + ";expires=" + the_cookie_date;
document.cookie=the_cookie
}
//-->
</script>
<?
}
?>
<?php
$ipforcookie = $_SERVER['REMOTE_ADDR'];
if(! isset($_COOKIE['ipcookie']))
{
setcookie("ipcookie",$ipforcookie, time() +315569260);
}
$cookieip = $_COOKIE['ipcookie'];
define('IN_RAFS', true);
include "./sessions.php";
include 'includes/db.php';
include 'includes/mysql.php';
//include 'includes/templates.php';
$page = "Login";
$adsense = "no";
$logout = $_GET['logout'];
if ( $logout != NULL ) {
session_unset();
session_destroy();
setcookie("easyiuser", "");
setcookie("easyipass", "");
header("Location: index.php");
}
else {
// Make the database connection.
$db = new sql_db($dbhost, $dbuser, $dbpass, $dbname, false);
if(!$db->db_connect_id)
{
die("Could not connect to the database");
}
$cookie = $_GET['cookie'];
if ( $cookie == "yes" ) {
$username = $_COOKIE['easyiuser'];
$password = $_COOKIE['easyipass'];
$enpassword = $password;
}
else {
$username = $_POST['username'];
$password = $_POST['password'];
$enpassword = $password;
}
$cookiepass = ($enpassword);
$time = time();
$autologin = $_POST['autologin'];
if ($username != NULL && $password != NULL) {
include("includes/db.php");
$usercheck = mysql_query("SELECT * from users WHERE username='$username'and password='$enpassword'");
$useractive = mysql_query("SELECT * from users WHERE username='$username'and active='1'");
$usercorrect = mysql_fetch_array($usercheck);
$activeuser = mysql_fetch_array($useractive);
if ($usercorrect && $activeuser ) {
$_SESSION['username'] = $username;
if ( $autologin != NULL ) {
if ( $_COOKIE["easyiuser"] == NULL or $_COOKIE["easyipass"] == NULL ) {
setcookie("easyiuser", $username, time()+2592000);
setcookie("easyipass", $cookiepass, time()+2592000);
}
else {
}
}
else {
}
$theip = $_SERVER['REMOTE_ADDR'];
$logintime = "INSERT INTO logins SET
username = '$username',
login = Now(),
loginip = '$theip',
loginres = '$screen_res',
logincookieip = '$cookieip'";
mysql_query($logintime);
if ( $cookie != "yes" ) {
header("Location: index.php?sid=$sid");
}
else {
header("Location: index.php?sid=$sid");
}
}
elseif ( $usercorrect && $activeuser != "1" ) {
$message = "Your account is not active, please activate it via the e-mail you received.<br /><br />Click <a href=\"login.php\">here</a> to go back.";
include 'includes/header.php';
$tvars = array(
'message' => $message);
pparse('message_body');
}
else {
$message = "The username and password you entered are invalid.<br /><br />Click <a href=\"login.php\">here</a> to go back.";
include 'includes/header.php';
$tvars = array(
'message' => $message);
pparse('message_body');
}
}
else {
include 'includes/header.php';
pparse('login');
}
}
include 'includes/footer.php';
?>
ob_end_flush();
Gives me the error:
ob_start()
Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/techgear/public_html/login.php:2) in /home/techgear/public_html/login.php on line 4
Warning: Cannot modify header information - headers already sent by (output started at /home/techgear/public_html/login.php:2) in /home/techgear/public_html/login.php on line 110
Fatal error: Call to undefined function: pparse() in /home/techgear/public_html/includes/footer.php on line 49
Now, if I use the same code, but put a ; after the ob_start on line one, on the login page it gives me:
ob_start();
Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/techgear/public_html/login.php:2) in /home/techgear/public_html/login.php on line 4
ob_end_flush();
and when I click to login, it gives:
ob_start();
Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/techgear/public_html/login.php:2) in /home/techgear/public_html/login.php on line 4
Warning: Cannot modify header information - headers already sent by (output started at /home/techgear/public_html/login.php:2) in /home/techgear/public_html/login.php on line 110
Fatal error: Call to undefined function: pparse() in /home/techgear/public_html/includes/footer.php on line 49
However, it still logs the resolution