Progress = Good

I spent some time today screwing around with headers and footers. I’m pleased to say that they’re both working excellently! Actually, the main page is now running with the new header and footer without issue.

I had to spend some time futzing around with it though. Here’s the deal for the programming types: PHP has a function called virtual() that allows you to run scripts through it. Sorta like an include() statement that will execute a script and then include the script’s output where it’s called. Overall, pretty snazzy.

Well, it turns out that the virtual() function calls scripts relative to the current working directory and not from their absolute paths. So, in my home directory, I can call the script similar to this: virtual(“cgi-bin/perl_script.pl”); without issue from the header. But – when I use the header on a page that’s not in the home directory (such as my webcam page, the file that was being looked for was http://www.crazyted.com/webcam/cgi-bin/perl_scipt.pl – obviously the wrong one.

So what I had to do was fancy little programming to assertain the current working directory, figure out how many levels it was from the home directory, and then pad ‘cgi-bin/perl_script.pl’ with the corresponding amount of ‘../’s needed to point to the cgi-bin directory.

It seems like a shitload of work for a little Perl script (actually the “Countdown To…” script on the left that you see), but I came up with an elegant way to do it in about 10 – 15 lines of code that will work from any directory on my site, no matter how many levels it might be away from my home directory. I’m quite pleased with it and it’s portability. Oh, and for referance, my webcam page is working with the header & footer as well. I used it to test it out.

Now don’t you feel enlightened? :-)

Jan 10th, 2002 | Posted in Archive
No comments yet.

Leave a comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>