Jump to content

PHP Timer

Mornincupofhate

Is there any way to make a timer (countdown) with php and keep counting down or maybe execute a function even if the user has exited the page?

Link to comment
Share on other sites

Link to post
Share on other sites

what are you counting down for? It would likely be more appropriate to do at the client-browser side in javascript

             ☼

ψ ︿_____︿_ψ_   

Link to comment
Share on other sites

Link to post
Share on other sites

5 minutes ago, SCHISCHKA said:

what are you counting down for? It would likely be more appropriate to do at the client-browser side in javascript

I need to do something over SSH2 and like 5 minutes after the user presses the button, I need it to execute another script which reverses what the previous command did. if I do this with javascript and the user disconnects, it wont happen at all.

Link to comment
Share on other sites

Link to post
Share on other sites

1 minute ago, Mornincupofhate said:

I need to do something over SSH2 and like 5 minutes after the user presses the button, I need it to execute another script which reverses what the previous command did. if I do this with javascript and the user disconnects, it wont happen at all.

There is a session timeout variable but AFAIK there is no callback loop and I can't find anything on google using the keywords session timeout callback or hook. If you are using something like silver stripe for content management they should have an appropriate hook to do what you want. Im thinking you could log activity into a database and then have a script running on the server that checks the database. I dont think reversing actions is safe and reliable when you could instead store whatever it is you are doing in a temporary place before committing. Is this a database related command?

             ☼

ψ ︿_____︿_ψ_   

Link to comment
Share on other sites

Link to post
Share on other sites

2 minutes ago, SCHISCHKA said:

There is a session timeout variable but AFAIK there is no callback loop and I can't find anything on google using the keywords session timeout callback or hook. If you are using something like silver stripe for content management they should have an appropriate hook to do what you want. Im thinking you could log activity into a database and then have a script running on the server that checks the database. I dont think reversing actions is safe and reliable when you could instead store whatever it is you are doing in a temporary place before committing. Is this a database related command?

The application I'm working on is designed for DDoS scrubbing and re-routing. It's either going to A: Check each server's incoming traffic load individually and if it's reached a certain threshold, establish an SSH connection to the edge router and divert all incoming traffic for that IP address. or B: A user is going to be able to login to the panel and manually divert traffic themselves.

 

Would storing dates in a database and then having a cron check it every few seconds be more reliable?

Link to comment
Share on other sites

Link to post
Share on other sites

1 hour ago, Mornincupofhate said:

The application I'm working on is designed for DDoS scrubbing and re-routing. It's either going to A: Check each server's incoming traffic load individually and if it's reached a certain threshold, establish an SSH connection to the edge router and divert all incoming traffic for that IP address. or B: A user is going to be able to login to the panel and manually divert traffic themselves.

ok so why PHP? Are you using apache server coz that has load balancing, you could prob find a hook into its builtin monitoring

             ☼

ψ ︿_____︿_ψ_   

Link to comment
Share on other sites

Link to post
Share on other sites

  1. start a session to check if the timer has every been started
  2. if not then set it
  3. set another session with a time expire
  4. use php headers to redirect until session expires
  5. profit.

a better option would be create a session at the start then use JavaScript to call a php function, pass the current time to it then php works out if the timer is up and returns true or false.

 

 

                     ¸„»°'´¸„»°'´ Vorticalbox `'°«„¸`'°«„¸
`'°«„¸¸„»°'´¸„»°'´`'°«„¸Scientia Potentia est  ¸„»°'´`'°«„¸`'°«„¸¸„»°'´

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×