PDA

View Full Version : Auto Log out timer help.



zerobeat
01-22-2011, 03:47 AM
Hello, I'm on a RPG game and they have a automatic logout timer to stop people from using bots to play, the only problem with it is, if someone lets the timer run out, it won't let the user log back in for a time (This time could be anywhere from 5 minutes to 3 hours from what other members have told me)

Now java isn't my strong point (But I'm learning ^_^) and I'm not 100% sure if this error is related to java or some other code format. Using the develop tool in Safari I was able to find the code, and its telling me thats its java, I'm sorry if this is in the wrong place if its not Java after all.

I'm wondering if looking over this code, someone might be able to find the problem or might have any tips to make it work better. (Note; I'm not the admin or owner of the RPG, but the owner hasnt done anything about it mainly cause they are to lazy I think?? or might not know how to fix it.



var c_reloadwidth3=200
var countDownTime3=countDownInterval3+1;

function countDown3(){
countDownTime3--;
if (countDownTime3 <=0){
countDownTime3=countDownInterval3;
clearTimeout(counter3)
window.location.reload()
return
}

if (document.all) //if IE 4+
document.all.countDownText3.innerText = Math.floor(countDownTime3 / 60)+":"+(countDownTime3 % 60)+" ";
else if (document.getElementById) //else if NS6+
document.getElementById("countDownText3").innerHTML= Math.floor(countDownTime3 / 60)+":"+(countDownTime3 % 60)+" "
else if (document.layers){
document.c_reload.document.c_reload3.document.write('<b id="countDownText3">'+countDownTime3+' </b>')
document.c_reload.document.c_reload3.document.close()
}
counter3=setTimeout("countDown3()", 1000);
}

function startit3(){
if (document.all||document.getElementById)
document.write('<b id="countDownText3">'+countDownTime3+' </b>')
countDown3()
}

For all I know it could be another script causing it to do it, but this is a start to help try and fix the problem.

Thank you to anyone who helps.

- zerobeat, Jack.

venegal
01-22-2011, 04:41 AM
You obviously know that you are talking about Javascript here, since you correctly posted in the Javascript forum. So, please don't say 'Java' it's something else entirely.

All, the code you posted does, is reload the page after a certain amount of time, so I'm guessing that on page load, a server side script checks when the last user interaction was, and logs the user out, if it has been too long ago.

If that's so, there's not much you can do on the client side. You can prevent that automatic reloading, but as soon as you request something from the server the next time, you will be logged out anyway.

Also, I don't get how that would prevent the use of bots. A human user is much more prone to idle and be logged out than a bot, that can be programmed to just do something every so often.

zerobeat
01-22-2011, 04:59 AM
You obviously know that you are talking about Javascript here, since you correctly posted in the Javascript forum. (A)So, please don't say 'Java' it's something else entirely.

All, the code you posted does, is reload the page after a certain amount of time, so I'm guessing that on page load, a server side script checks when the last user interaction was, (B) and logs the user out, if it has been too long ago.

If that's so, there's not much you can do on the client side.(C) You can prevent that automatic reloading, but as soon as you request something from the server the next time, you will be logged out anyway.

Also, I don't get how that would prevent the use of bots. A human user is much more prone to idle and be logged out than a bot, that can be programmed to just do something every so often.

(A)Ok, I wont say the start of Javascript alone anymore. :)

(B) The timer script doesn't log out someone due to inactivity, it just counts down from an hour once the hour is up (no matter what your doing) it will log you off. The only reason I could think of, for the point of the countdown is to stop bots.

(C) I'm guessing -again- that the reloading is to do with reloading a page to do with selecting something to do.

Any idea on how I would find the script for the auto logout?

Thank you for helping.

venegal
01-22-2011, 05:08 AM
(A) It's just that Java is not a cool abbreviation for Javascript, it's another language, that, apart from a few letters in its name, has absolutely nothing to do with Javascript.

(B) I guess I don't really understand then how the whole thing works. Is it a pure client side application without any page requests once you've started? Is it part of the game, that you have exactly one hour to beat it or something?

(C) I don't really understand what you're saying here. Try to rephrase that.

If there's a server side script logging you out and preventing you from logging in for a certain amount of time, you can't do anything about it, since it's on the server, and you don't have access to that.

zerobeat
01-22-2011, 05:17 AM
(A) It's just that Java is not a cool abbreviation for Javascript, it's another language, that, apart from a few letters in its name, has absolutely nothing to do with Javascript.

(B) I guess I don't really understand then how the whole thing works. Is it a pure client side application without any page requests once you've started? Is it part of the game, that you have exactly one hour to beat it or something?

(C) I don't really understand what you're saying here. Try to rephrase that.

If there's a server side script logging you out and preventing you from logging in for a certain amount of time, you can't do anything about it, since it's on the server, and you don't have access to that.

B. I'm not sure, I'm just a member sick of all the problems the place has so I'm trying to find a way to fix these and tell the owner. (Anyway I can tell just being a basic member?) I'll explain:

When someone logs on, the timer starts at 60:00 minutes. It will count down to 00:00 then log the user out. It isn't part of the game itself.

C. Yeah sorry I didn't really think about it while typing it.
Part of the game is when you click something to do e.g "Train Speed" a timer will start and will count down from 5:00 minutes:


var c_reloadwidth1=200
var countDownTime1=countDownInterval1+1;

function countDown1(){
countDownTime1--;
if (countDownTime1 <=0){
countDownTime1=countDownInterval1;
clearTimeout(counter1)
//window.location.reload()
document.getElementById("countDownText1").innerHTML = "Training Done";
return
}

if (document.all) //if IE 4+
document.all.countDownText1.innerText = Math.floor(countDownTime1 / 60)+":"+(countDownTime1 % 60)+" ";
else if (document.getElementById) //else if NS6+
document.getElementById("countDownText1").innerHTML= Math.floor(countDownTime1 / 60)+":"+(countDownTime1 % 60)+" "
else if (document.layers){
document.c_reload.document.c_reload2.document.write('<b id="countDownText1">'+countDownTime1+' </b>')
document.c_reload.document.c_reload2.document.close()
}
counter1=setTimeout("countDown1()", 1000);
}

function startit1(){
if (document.all||document.getElementById){
if( countDownTime1 <= 0 ){
document.write('<b id="countDownText1">Training Done</b>')
}
else{
document.write('<b id="countDownText1">'+countDownTime1+' </b>')
}
countDown1()
}
}
I think thats the code for it, if for whatever reason its important.

venegal
01-22-2011, 05:28 AM
It's possible to stall that 60 minutes timer indefinitely and prevent the page reload, but since for all I know that timer is an intentional feature, and deactivating it could be considered cheating, it would be against the rules for me to tell you any more.

zerobeat
01-22-2011, 05:34 AM
It's possible to stall that 60 minutes timer indefinitely and prevent the page reload, but since for all I know that timer is an intentional feature, and deactivating it could be considered cheating, it would be against the rules for me to tell you any more.

Yeah I understand that :) Mainly I was trying to find a way to fix, not to get around it. Maybe the owner might be able to explain how it works as he most likely did it. Thank you for your help venegal :D