My page has the code:
<?
$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 'browser_detection.php';
//include 'includes/templates.php';
$page = "Login";
$adsense = "no";
$logout = $_GET['logout'];
$os = browser_detection('os');
$osnumber = browser_detection('os_number');
$browser = browser_detection('browser');
$number = browser_detection('number');
$ieversion = browser_detection('ie_version');
if ( $logout != NULL ) {
session_unset();
session_destroy();
setcookie("easyiuser", "");
setcookie("easyipass", "");
header("Location: index.php");
}
else {
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>
<?
}
// 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 {
}
$sql = "SELECT * FROM users WHERE username = '$username'";
$result = mysql_query($sql);
$row = mysql_fetch_array($result);
$userid = $row['id'];
$theip = $_SERVER['REMOTE_ADDR'];
$logintime = "INSERT INTO logins SET
username = '$username',
login = Now(),
loginip = '$theip',
userid = '$userid',
logincookieip = '$cookieip',
os = '$os',
osnumber = '$osnumber',
browser = '$browser',
number = '$number',
loginres = '$screen_res',
ieversion = '$ieversion'";
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';
?>
The area that messes it up is:
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>
<?
}
Every where I put that it will load correctly if the cookie has already been set, but if it has to set the cookie, the banner on the page shifts to the right, and some of the text is large.
You can try it out www.techgearfree.com Just click existing member login.
Thanks