Welcome to our website. Our hours of operation are 2:00pm to 2:05pm.
January 23, 2008 1:35 PM   Subscribe

In the movie Paprika by Satoshi Kon one of the tropes was a website that would show specific content at a specific time. While I'm sure this is possible, is it easily implementable? Better yet, is there an downloadable script or somesuch that I can use on my website? Can a page be time-locked?
posted by lekvar to Computers & Internet (13 answers total) 6 users marked this as a favorite
Loading page content (or entirely different pages) is quite easy with just a little bit of Javascript. Minor modifications from this should do what you want.
posted by Nelsormensch at 1:39 PM on January 23, 2008

I do something like that on my Linux server. I do it with a shell script run by cron once an hour. (It changes the picture displayed on top of my blog.)
posted by Steven C. Den Beste at 1:43 PM on January 23, 2008

PHP could do it...

The way I would do it would be to use the time function

Get it formatted the way you wanted and then use an include for the thing you want to load...

If ($formatted_time >= $lower_limit || $formatted_time <> include (something.html);
//or whatever

posted by drezdn at 1:50 PM on January 23, 2008

It actually looks like there might be better functions than time() for doing this in php...(I'm used to just loading content depending on the date).
posted by drezdn at 1:52 PM on January 23, 2008

If you're worried about time, allow for a large enough window so that people with clocks that are slightly off from yours won't be disappointed when they arrive "on the exact hour."

Doing it in javascript means you're trusting the client's clock to be correct. A user could tamper with their own clock to see the content after the window has passed (people already exploit this to get around the misfeature of downloading movies they're only able to see for 24 hours (hello, AppleTV!)). Worse yet, people can just "view source" and see the unlocked content.

Server-side parsed code, like PHP or ASP or CGI or mod_perl or Ruby On Rails would be your bet for content that is hosted at a cheapo web service. The best and most resilient solution would be to have three sets of files -- before, during, after -- and swap each set of files at the appropriate times. You can do this with a Scheduled Task (Windows) or crontab/atjob (everybody else).
posted by Mozai at 1:57 PM on January 23, 2008

I do this for longer stretches of time (a scholarship that can only be applied for Jan - Mar, for example), and the date functions of PHP work pretty well for me, similar to what drezdn suggests.
posted by epersonae at 2:14 PM on January 23, 2008

Also, if you use javascript, and someone goes to the page with javascript turned off in their browser, the content will appear normally.

The php solution drezdn recommends would probably be the easiest, providing your server runs php.

It would still be possible for industrious folks to access your content at the incorrect times, but I doubt most people would bother. Certainly most people wouldn't bother with the javascript solution either, but doing it with .php seems like a nice tradeoff between ease of implementation and absolute secrecy.
posted by kpmcguire at 2:21 PM on January 23, 2008

Hackjob in php5 (timezone set requires php5 [sad trumpet]):



Not really ideal to cast an int from the date function and do comparisons, because, well, technically the integer 1700 is very different than the time 1700, but it works. I didn't really feel like dicking around with create time and the conversion to seconds, which would be the proper way to do it.

But yeah, this should be easy in any language.
posted by fishfucker at 5:01 PM on January 23, 2008

For Apache, if you can use .htaccess files you can quickly do something like

RewriteCond %{TIME_HOUR}%{TIME_MIN} > 1359
RewriteCond %{TIME_HOUR}%{TIME_MIN} <> RewriteRule ^yourpage\.html$ yourpage.allowed.html
RewriteRule ^yourpage\.html$ yourpage.denied.html
posted by handybitesize at 5:09 AM on January 24, 2008

Oh not sure what happened then

RewriteCond %{TIME_HOUR}%{TIME_MIN} < 1 4 0 6 (no spaces)


RewriteRule ^yourpage\.html$ yourpage.allowed.html

should replace the middle line mess
posted by handybitesize at 5:12 AM on January 24, 2008

Most freebie blogging sites have this function. Wordpress, for instance, allows you to make a post but date it forward so it will be posted at a later date and time to the minute.
posted by vanoakenfold at 7:55 AM on January 24, 2008

Response by poster: Thanks for all the good info here, and for raising points I hadn't considered.

so much to digest! there goes my free time...
posted by lekvar at 2:34 PM on January 24, 2008

how would you fool a server-side scripting language into divulging information that it isn't programmed to?

I'm sure you could program a more secure solution, but I was specifically referring to this method, in which someone could download the .php file, see the reference to the include, and just type something.html into the browser.
posted by kpmcguire at 1:29 PM on January 29, 2008

« Older To question is human; to declare, divine   |   How do you avoid staring at cleavage? Newer »
This thread is closed to new comments.