php - How to limit the times a script can be run to some time on a particular ip address -


Im counting for a certain amount of time when any script that chooses a song from that table goes away , But I want to increase within once, maybe say 5 hours. So this means that a user will play a song and it will only be counted as a play for the first time and then waiting for 5 hours before allowing another enhancement.

PHP

I do not know how to do it.

  $ _ session ['play_id'] = $ _SERVER ["REMOTE_ADDR"]; $ _SESSION ['play_time'] = time (); $ Then = $ _SESSION ['play_time']; $ Now = time (); $ Diff = $ now-> Different ($ again); If ($ diff> 2 * 1000) {$ query = mysql_query ("Update Setup Set = plays = 1 where sid = '$ id'") or die (mysql_error ()); } Else {echo 'not yet'; }   

Thanks.

  $ ip = 0 if (empty! ($ _ Server ['HTTP_CLIENT_IP']) ) {$ Ip = $ _SERVER ['HTTP_CLIENT_IP']; } And {$ ip = $ _SERVER ['REMOTE_ADDR']; }   

security issue elseif (! ($ _ Server ['HTTP_X_FORWARDED_FOR'])) {$ ip = $ _SERVER ['HTTP_X_FORWARDED_FOR']; }

  $ _ session ['play_id'] = $ ip; $ _SESSION ['play_time'] = time (); $ Then = $ _SESSION ['play_time']; $ Now = time (); $ Diff = $ now-> Different ($ again); If ($ diff> 2 * 1000) {$ query = mysql_query ("Update Setup Set = plays = 1 where sid = '$ id'") or die (mysql_error ()); } Else {echo 'not yet'; }    

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -