Page 1 of 1

Hard-coding a page...

Posted: Wed Jul 13, 2005 4:49 pm
by theda
This may sound weird, but I know it's possible.

I would like to implant a bit of code into every page loaded on my server, without actually editing those pages (like manually implanting the code). It's how my current free host implants their adverts on my website... I believe it has something to do with editing .htaccess...

Posted: Wed Jul 13, 2005 4:50 pm
by hawleyjr
You can always use include() to include the same file over and over again :)

Posted: Wed Jul 13, 2005 4:55 pm
by theda
No, I want to have the server implant coding (from a source page) into all files when they are loaded, as Yahoo! does with their free-sites...

Posted: Wed Jul 13, 2005 5:09 pm
by Chris Corbyn
Not sure if thats PHP or some sort of CNAME alias to a framed version of the site (or mod_rewrite)...

Using include(); and mod_rewrite it can be done.

Code: Select all

<?php
include('the_include_file.php');
include($_GETї'page']);
?>
Havent used mod_rewrite for ages so my syntax might be out...

Code: Select all

RewriteEngine On
RewriteRule ^(/.*)$ /frameholder.php?page=$1

Posted: Wed Jul 13, 2005 5:27 pm
by timvw

Posted: Wed Jul 13, 2005 7:34 pm
by theda
All your ideas are all following the same path: Having to edit each and every file to add some code. This isn't PHP. That's why I don't have it in PHP-Code. I have it in Misc. There's something to do with the server itself or .htaccess that would allow me to when a page is loaded, to embed code into a page when it loads.

Posted: Wed Jul 13, 2005 7:41 pm
by John Cartwright
d11's idea with htaccess only involves the creation of a single file, not every single one.
I wish I could contribute with furthur ideas but am stumped on this one. :cry:

Posted: Wed Jul 13, 2005 7:59 pm
by theda
Hmm, let me look at D11's, I think I overlooked it ^_^;;

Edit: I see what he's talking about. Now how do I do the mod_rewrite. I know of the file mod_rewrite.so in my XAMPP folder, but haven't a clue how to implement what you say.

Posted: Wed Jul 13, 2005 8:06 pm
by timvw
Actually my solution doesn't need php source editing...

just php configuration editing (php.ini) or trough .htaccess php_value

Posted: Thu Jul 14, 2005 2:54 am
by onion2k
In Yahoo's case they probably have a filter running on the server that adds code as the page data is requested by the user. Some sort of custom Apache mod perhaps.

Posted: Thu Jul 14, 2005 3:07 am
by phpdevuk
might want to take a look at the apache ssi guide at http://httpd.apache.org/docs/howto/ssi. ... dardfooter

Posted: Thu Jul 14, 2005 8:45 am
by theda
phpdevuk wrote:might want to take a look at the apache ssi guide at http://httpd.apache.org/docs/howto/ssi. ... dardfooter
I don't want to sound ungrateful or anything phpdevuk... But your help was the least helpful I've ever had. I know what SSI is, but it the point is that I don't WANT to edit into EVERY page. I've said it in almost all my posts now...

Posted: Thu Jul 14, 2005 9:03 am
by wwwapu

Code: Select all

php_flag auto-prepend-file &quote;path_to_your_file&quote;
php_flag auto-append-file &quote;path_to_your_file&quote;
What is wrong with this?

Posted: Thu Jul 14, 2005 2:53 pm
by theda
Nothing, those are both perfectly plausable ideas ^_^;; I, personally, already have my own script set up that redirects a page if viewed without the main layout being present (file.php instead of index.php?variable=file). I was mainly doing this to give a friend of mine an idea of his abilities to do this kind of thing. The funny part is eventually, he'll be making all his data database driven... So doing this is kind of useless, but still interesting to know.