Log in

View Full Version : Automatic FTP transfers



MrH2o
10-16-2006, 03:15 PM
Hey

I wonder if there are some way (program, script, babyslave) to tell a certain file to be "active" on a certain date?

Let's say I want to give my visitors a special message or pictures the 24th dec and I know I won't be able to upload it myself that day.

Are there any alternative that let me upload the file but let it "go active" on a certain date? so I dont have to upload it myself and can have my computer shut down?

Very greatfull for answers

djr33
10-16-2006, 04:16 PM
Not sure about this, exactly.

There might be some type of ftp tool where you could schedule updates, but you'd need your computer on for this, and not sure how/what would work.

<?php
if ((date(n) < 12 || date(j) < 24) && date(y) < 07) {
die('No input file specified.')
}
?>

If you add the above php code to your page (and rename the page .php and have php enabled on your server) then that will work great.
If it's before the date you said (the if statement checks that, specifcally), it will die (stop execution of the script, including sending any html after that point) and output "No input file specified." which is the default for a non-existant php script. (Unlike a 404, you get that, I think because the php-processor tries to run something, but can't find the php script to run, so gives the error.)
With that, no one would know there's a page there until it's the 24th.

Aside from this, I would suggest using php.
PHP isn't running all the time, but rather just processes pages when a browser requests them.
As such, you would need to request the page.
You could choose either to do this based on simply the index page, where it checks if it's the 24th yet EACH time it loads (which would slow things down), or add a special page that you could choose to access on the 24th, from, perhaps, your cell phone.
Code the page so that, when it's the 24th (or when accessed if it's a page only you would know about, if you'd rather have more control if you happened to want it up before the 24th), you visit the page and the script runs and "enables" your files....
You would upload them before, but have php do something to enable them, like change the original random names (wjwjeiojqfioajflks.jpg) to the real names, or do something along those lines.
PHP is serverside and can change files/filenames/etc etc on the server, so that would be a good route to take.

Might be more options, but not too much if you don't have a computer in front of you when you need it to become active.

Twey
10-16-2006, 04:24 PM
Upload it to the server then move it into place with a cron job. No interaction required.

MrH2o
10-16-2006, 05:05 PM
Thanks both of you, I will try it later but cronjob sounds really good