[eluser]err403_love[/eluser]
Hi,
I've been brainstorming on how best to implement a "Scheduled Task" system for my first CI project.
First, I want to run it using AJAX at the bottom of all my pages. I don't need any help with this part exactly, other than knowing if there are any issues with running a CI controller over an XHR.
Second is security. I was thinking I will need some method to encode a string and then decode it on the other side, and if it doesn't match the controller will exit. I think this is necessary because I can't have a static URL for the task script, otherwise sketchy people would be able to do a sort of "attack" on my server by running the URL continuously.
This method certainly doesn't have to be foolproof, though. What my task involves is updating local XML files with external ones, which I then store a serialized array in the database based off of the local XML file.
So I was thinking I could encode something that changes often enough, like the Unix timestamp, but have it rounding up to the nearest minute and then do the encode, so by the next second later when it decodes in another script it will still match. I realize there will be a second or so out of each minute (during the change to the next minute) where the script won't run when it's supposed to, but if a visitor visits the next page soon after, the script should run fine, and I don't have a problem with this.
Is this too complicated? Is there some better way to pass a random string through the URL that will
change and will not
work repeatedly (opening up to attacks)?
Third, the actual reason I need to do this is because when it is time to update the XML files, the page will stall badly until that part is finished. The data that is being displayed most of the time, though, is being taken right out of the database, so I can offload the actual file updates into a task that runs LAST and with AJAX so that it doesn't affect the page load so greatly.
Any ideas or suggestions would be appreciated.