PDA

View Full Version : CRON Job - Auto upload a file to template


Michael Morris
10-20-2004, 10:00 PM
This cron job simply loads a text, php or rss file into a template. You use the inbuilt Scheduled Task manager to control exactly when it does this. To set this up download the attached file, open it and set the name of the template to make and the remote url to access, then save it and upload it to your server in the /includes/cron/ directory. If you want to handle multiple remote files, create multiple cron jobs and change the name of the cron job for each one (for instance, file1_uploader.php, file2_uploader.php and so on).

Exactly what you do with this job is up to you of course, as it's applications are fairly open ended. You can use it to import xml files from other sites into your pages, port data between the forums, and so on. I use it to pull up a menu of new products from an affiliated store at another site - using the cron job saves bandwidth for the other machine and allows me to retain style control over the appearance of that data since variables parse when loaded from a template.

I'm sure you guys can come up with other things - and I'd like to hear about them. Have fun.

memobug
10-21-2004, 08:09 PM
I will click install so I don't forget to install this VERY USEFUL hack. Now I need to let my mind wander to wrap around the potential.

Q1 - will it (can it) overwrite an existing template?
Q2 - does it put the template in ALL styles?
Q3 - You say "load a php file" does that mean it could execute the file and load its output, or will it just load in the raw php code?
Q4 - Screenshots? (of course I am just pulling your leg!)

Thanks!

Matt

Michael Morris
10-21-2004, 09:13 PM
I will click install so I don't forget to install this VERY USEFUL hack. Now I need to let my mind wander to wrap around the potential.

Q1 - will it (can it) overwrite an existing template?

I don't *think* so (I haven't tried). EDIT: It does over-write itself (each time it runs it "updates" the template it points to.

Q2 - does it put the template in ALL styles?

Yes.

Q3 - You say "load a php file" does that mean it could execute the file and load its output, or will it just load in the raw php code?

I'm fairly sure you could evaluate it from the phpinclude_start template with

eval(fetch_template('TEMPLATE NAME', -1, 0));

Where TEMPLATE_NAME is the template you loaded in.


Q4 - Screenshots? (of course I am just pulling your leg!)

http://www.enworld.org/forums/news.php executes code pulled in this way - specifically the ENWorld store on the right.