I guess you'll check if 2 minutes elapsed from some previous activity and if yes, you'll update the credits. Then it ends.Ĭonditions when it should update the credits are up to you. This script goes through all active users and updates credits of each user. Schedule the execution of this script for example every 1 minute using Cron. I would air on the side of using an implementation you find easy and are most comfortable with given your security needs, costs, consequences of hackery.Ĭreate a PHP script, which will update user's credits. However, this is a more complex to setup then the other proposed methods if you are unfamiliar with video streaming services. The correct way to implement this using strictly server side only, given the context of your new edit, would be to use a video streaming service that upon successfully streaming the entire video (without the user dropping out early or pausing), runs a post operation script that credits the user. If you don't need query results on your page, see Run PHP Task Asynchronously If the call is interrupted by a signal, sleep () function returns a non-zero value. The sleep ( ) function accepts seconds as a parameter and returns TRUE on success or FALSE on failure. However, this is dependent on what your application does. The sleep () function in PHP is an inbuilt function which is used to delay the execution of the current script for a specified number of seconds. Let the page load, wait two minutes in javascript, then use ajax to hit your php server and pull the query results.Īlso depending on your app and what the query is, consider caching the query results for next time. Assuming you need the query results returned to the page, Why not make an async call.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |