Programming Tools
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingProgramming Tools

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old February 16th, 2003, 02:53 PM
dispatcher dispatcher is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Posts: 9 dispatcher User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Unsert Banner automaticly ???

I'm trying to figure out how to insert a banner (or header/footer) in every page viewed in a directory, without individualy inerting code in each page. Sort of what they do at various host services where they add an advertising banner.

Running a virtual host, with Apache.

Something along the idea of a redirect for all files, feeding them into a CGI or PHP file for processing before being sent to the browser.

How is it done ? (Can it be done?)

Bob

Reply With Quote
  #2  
Old February 16th, 2003, 04:56 PM
Ben Rowe
Guest
Dev Articles Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
maybe you should look into php includes. You can set a header/footer files with them

for example

top.php code
PHP Code:
<html><head><title>Test</title></head><body


bottom.php code
PHP Code:
</body></html


index.php

PHP Code:
<?php include("top.php"); ?>

Your html code goes here

<?php include("bottom.php"); ?>


Lets say you want a banner add at the bottom of each page, you would add the img tag to the bottom.php file.

Reply With Quote
  #3  
Old February 16th, 2003, 05:41 PM
dispatcher dispatcher is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Posts: 9 dispatcher User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Problem is that PHP, SSI, Javascript can all be used, if a line of code is in the file. But I need to let users upload their files, without any extra text added, and somehow get the banner on it when displayed.

What is used on free hosts like NetFirms etc to insert it???

Bob

Reply With Quote
  #4  
Old February 17th, 2003, 03:18 AM
digitallysmooth digitallysmooth is offline
you know how we do
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jun 2002
Posts: 785 digitallysmooth User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 34 m 21 sec
Reputation Power: 17
Quote:
Originally posted by dispatcher
Problem is that PHP, SSI, Javascript can all be used, if a line of code is in the file. But I need to let users upload their files, without any extra text added, and somehow get the banner on it when displayed.

What is used on free hosts like NetFirms etc to insert it???

Bob



I have your answer, however there are a couple ways to do this:
If you examine the php.ini file, you will notice the following config lines:

; Automatically add files before or after any PHP document.
auto_prepend_file =
auto_append_file =


If you do not have access to your php.ini and your host is running the asapi / mod_php version, then you should use your .htaccess file and include this following line:


php_value auto_prepend_file /real/path/to/your/file

That line adds something to the top of your files.


--
Wil Moore III
www.wilmoore.com
__________________
__________________________________________________ _
Wil Moore III, MCP | Integrations Specialist | Senior Consultant
Are You Listed...? | DigitallySmooth Inc.

Reply With Quote
  #5  
Old February 17th, 2003, 03:22 AM
dispatcher dispatcher is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Posts: 9 dispatcher User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
That sounds like it willl work with PHP files, but what about .html ??

Bob

Reply With Quote
  #6  
Old February 17th, 2003, 03:41 AM
digitallysmooth digitallysmooth is offline
you know how we do
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jun 2002
Posts: 785 digitallysmooth User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 34 m 21 sec
Reputation Power: 17
Smile

Anything that is run through the php parser can be appended to.
If you need .html or .htm files to be worked on as well, then add this to your .htaccess file or php.ini:


AddType application/x-httpd-php html htm

Reply With Quote
  #7  
Old February 17th, 2003, 03:43 AM
dispatcher dispatcher is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Posts: 9 dispatcher User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I was just thinking of that...

trying to get this working with my hosts CGI Wrapper - itt gets a bit picky

Reply With Quote
  #8  
Old February 17th, 2003, 03:58 AM
digitallysmooth digitallysmooth is offline
you know how we do
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jun 2002
Posts: 785 digitallysmooth User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 34 m 21 sec
Reputation Power: 17
If my bag-o-tricks is correct, if you are running the php cgi version you can use your own local copy of the php.ini and modify your settings there.

Reply With Quote
  #9  
Old February 17th, 2003, 04:00 AM
dispatcher dispatcher is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Posts: 9 dispatcher User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
that's next - find the copy of it

Reply With Quote
  #10  
Old February 17th, 2003, 04:25 AM
dispatcher dispatcher is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Posts: 9 dispatcher User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Almost!!!

The php.ini setting worked !!!
( could find some neat uses for this!!!)

It doesn't seem to like the attempot to treat .html as .php though

when I try, it downloads the file and opens it localy in a new window!!!

Reply With Quote
  #11  
Old February 17th, 2003, 04:43 AM
digitallysmooth digitallysmooth is offline
you know how we do
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jun 2002
Posts: 785 digitallysmooth User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 34 m 21 sec
Reputation Power: 17
You may not be overriding the default mime type for the .html or .htm extension depending on where you are setting it.

If you are setting this from the .htaccess file you should be getting the desired results.

I'd check there first.

Reply With Quote
  #12  
Old February 17th, 2003, 04:48 AM
dispatcher dispatcher is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Posts: 9 dispatcher User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Quote:
.htaccess
AddType application/x-httpd-php .php .php3 .htm .html


?????
it just downloads and opens any .htm files localy

Reply With Quote
  #13  
Old February 17th, 2003, 10:03 AM
dispatcher dispatcher is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Posts: 9 dispatcher User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
OK - The php.ini file took care of the append & prepend files

Tried AddType etc in the .htacess file, for that directory,
it works properly with .php files
and I can even make it work with .bob files (for a test)
but it refuses to work with .htm or .html files
it just downloads the file and opens in in a new window
from a local temp directory!!!!


Reply With Quote
  #14  
Old February 17th, 2003, 11:21 AM
dispatcher dispatcher is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Posts: 9 dispatcher User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I've got it!!! (sort of)

Took out the code for server-parsing html/htm files in the sites's root directory - they aren't compatible!

Reply With Quote
  #15  
Old December 2nd, 2003, 04:34 PM
Mike_r Mike_r is offline
ExoCrew
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 68 Mike_r User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 15
What about perl ? It worked alright for php and html, but how to add them in cgi ?

Reply With Quote
  #16  
Old December 3rd, 2003, 07:42 AM
dhouston's Avatar
dhouston dhouston is offline
Contributing User
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: May 2003
Location: Tennessee
Posts: 1,355 dhouston User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 17
Send a message via ICQ to dhouston
For perl, you could just add a handler and have the server route any .pl or .cgi requests through it. The handler would execute the perl code and then add whatever extra output you want added before printing the results. In fact, you could do this for any file type.

Or you could probably associate .pl and .cgi with PHP and write in a special condition that executes "/usr/bin/perl filename.cgi" and returns the output, though there are potential security risks there and I'm not positive it would work anyway.

Reply With Quote
  #17  
Old December 3rd, 2003, 02:57 PM
Mike_r Mike_r is offline
ExoCrew
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 68 Mike_r User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 15
Couldn't quite get a it, what is a handler?

thanks for any help...

Reply With Quote
  #18  
Old December 4th, 2003, 09:57 AM
dhouston's Avatar
dhouston dhouston is offline
Contributing User
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: May 2003
Location: Tennessee
Posts: 1,355 dhouston User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 17
Send a message via ICQ to dhouston
Take a gander at http://httpd.apache.org/docs-2.0/handler.html for more info. Basically, a handler allows you to say "take files of type x and filter them through program y that does my special custom stuff and then returns the results to apache to output." An example: I once wrote a handler that treated .html files as cgi. The program I specified as the handler looked at the path info for the page requested and was able to determine what navigation template to use based on where in the file system the file was located. Each html page contained only the main content, and my handler wrapped the appropriate template around it, handled printable versions, etc., but the site didn't appear outwardly to be served up through CGI -- it looked like a bunch of static HTML pages. I imagine you could pretty easily write a little handler that would read in the contents of the file requested and add the banner code before sending the output back to apache to display.

Reply With Quote
  #19  
Old December 14th, 2003, 03:19 PM
Mike_r Mike_r is offline
ExoCrew
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 68 Mike_r User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 15
Well, I can't get that apache Handler to work wheneve i use that and restart apache.

service httpd status shows:

httpd dead but subsys locked

Dunno, whats wrong out there.

Well, the very first solution inserts the file two times i mean if a banner, its inserted two times under phpBB as it includes some files in the index.php file.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingProgramming Tools > Unsert Banner automaticly ???


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap