Hey guys, I am trying to create a redirect timeout using values from DB.
The javascript is something I have used before, think I actualy got it from here somewhere, now I am trying to replace the domain name and timeout values with those obtained from the database. This is what I have so far, the two database variables are in place and have tried a few options here, including:
<?php echo json_encode("$domain"); ?> and <?=$domain?> Both of which display the $domain/$timeout variables instead of the actual domain name or timeout value retrieved from DB. Hoping somebody can help with this as my javascript sucks Thanks in advance!
Script:
// Check for record
$check_sql = “SELECT sett_domain, sett_timeout”
. " FROM plat_settings"
. " WHERE sett_ID = ‘1’";
sc_lookup(rs, $check_sql);
if (isset({rs[0][0]})) // Row found
{
$domain = {rs[0][0]};
$timeout= {rs[0][1]};
}
else // No row found
{
$domain = $_SERVER[‘SERVER_NAME’];
$timeout = ‘1800000’; //Default 30min
}
[idle]= '<script type="text/javascript">
var inactivityTime = function () {
var t;
window.onload = resetTimer;
document.onmousemove = resetTimer;
document.onkeypress = resetTimer;
function logout() {
alert("Your session has ended, please login again.")
location.href = "$domain"; // EDIT THIS LINE
}
function resetTimer() {
clearTimeout(t);
t = setTimeout(logout, $timeout) // EDIT THIS LINE
// 1000 = 1 second
// 60000= 1 minute
// 3600000= 1 hour
}
};
inactivityTime();
</script>';