Hard-coding a page...

XML, Perl, Python, and other languages can be discussed here, even if it isn't PHP (We might forgive you).

Moderator: General Moderators

Post Reply
theda
Forum Contributor
Posts: 332
Joined: Sat Feb 19, 2005 8:35 am
Location: USA

Hard-coding a page...

Post 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...
User avatar
hawleyjr
BeerMod
Posts: 2170
Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA

Post by hawleyjr »

You can always use include() to include the same file over and over again :)
theda
Forum Contributor
Posts: 332
Joined: Sat Feb 19, 2005 8:35 am
Location: USA

Post 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...
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post 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
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

theda
Forum Contributor
Posts: 332
Joined: Sat Feb 19, 2005 8:35 am
Location: USA

Post 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.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post 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:
theda
Forum Contributor
Posts: 332
Joined: Sat Feb 19, 2005 8:35 am
Location: USA

Post 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.
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

Actually my solution doesn't need php source editing...

just php configuration editing (php.ini) or trough .htaccess php_value
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Post 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.
User avatar
phpdevuk
Forum Contributor
Posts: 220
Joined: Mon Jul 04, 2005 5:31 am
Location: UK
Contact:

Post by phpdevuk »

might want to take a look at the apache ssi guide at http://httpd.apache.org/docs/howto/ssi. ... dardfooter
theda
Forum Contributor
Posts: 332
Joined: Sat Feb 19, 2005 8:35 am
Location: USA

Post 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...
User avatar
wwwapu
Forum Contributor
Posts: 197
Joined: Wed Apr 07, 2004 11:57 am
Location: Turku, Finland

Post 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?
theda
Forum Contributor
Posts: 332
Joined: Sat Feb 19, 2005 8:35 am
Location: USA

Post 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.
Post Reply