yah i had a choice to use sql or use php time stamps and finally decided to use php.
I couldnt figure out how to do this using sql so i gave up and went with php 🙁
if ($get1['time'] < strtotime('-24 hours')) {
yah i should choose better names
im still confused on a few things since im a noob and been doing this for about 3 weeks now.
I have a script that is able to read a sql query that is out side of the brackets and I thought i knew why because the query was at the very top of the page and before the first if statment "cause its outside of the brackets". So yesterday i tried doing that on another script and it didnt work
I posted the code and cant figure out how this is able to read the query at the top of the page
if ($safe1['state'] == 1){
<?php
include_once("connect.php");
//checks to make sure the user has signup ip address
$safe3 = "SELECT name,goauld,state,vacation FROM users WHERE id = '".mysql_real_escape_string($_SESSION['user_id'])."'";
$safe2 = mysql_query($safe3) or die(mysql_error());
$safe1 = mysql_fetch_array($safe2);
//if user doesnt have a signup ip address they die
if (empty($safe1['goauld'])) { // if user has a goauld name then die
header("Location: signup.php"); // redirects you to dominion.php
exit();
}
// checks to make sure login_time was set and if its not blank. mainly this keeps people out that hasnt loged in
if (!(isset($_SESSION['login_time']) && $_SESSION['login_time'] != '')) {
header ("Location: signup.php");
session_destroy();
exit();
} else {
// logs user out after 60 minutes and redirects to login and ends session .login_time is the future
if ($_SESSION['login_time'] < strtotime('-500 minutes')) {
header("Location: signup.php");
session_destroy();
exit();
} else {
// checks and updates last activity of user
$safe4 = "UPDATE users SET lastactive = NOW() WHERE id='".mysql_real_escape_string($_SESSION['user_id'])."'";
mysql_query($safe4);
// updates the login_time each time ingame pages are loaded. this keeps players loged in as long as they are flipping webpages
$_SESSION['login_time'] = time();
}
}
$get3 = "SELECT time,date,name,reason FROM banned WHERE id = '".mysql_real_escape_string($_SESSION['user_id'])."'";
$get2 = mysql_query($get3) or die(mysql_error());
$get1 = mysql_fetch_array($get2);
$get = $get1['reason'];
$get5 = $get1['name'];
if ($safe1['state'] == 1){
if($get1['time'] < strtotime('-24 hours')) {
mysql_query("DELETE FROM `banned` WHERE `id`= '".mysql_real_escape_string($_SESSION['user_id'])."'");
mysql_query("UPDATE users SET state='' WHERE id = '".mysql_real_escape_string($_SESSION['user_id'])."'");
}else{
header("Location: signup.php?reason=$get&name=$get5");
session_destroy();
exit();
}
}
?>