How to fix overall_header?

galaxyAbstractor

Community Advocate
Community Support
Messages
5,508
Reaction score
35
Points
48
Ok, I should put the x10 ad on top of some 20+ pages in the same directory. Now I ask you, how to make a overall_header like in phpBB 3 without editing 20+ files. Is that possible? All template files is written in php.
Edit:
Plz help! You are getting me suspended if you don't tell me
 
Last edited:

Thewinator

New Member
Messages
256
Reaction score
0
Points
0
Well you could write a piece of code that inserts the code in all files in a folder or something.
But the best way is to use a new php file to load the contents of the other files.
This is realy basic but comes down to this:
PHP:
echo "the x10 ad here";
include('your_content.php');
 

GamingX

Executive Team
Messages
6,355
Reaction score
3
Points
38
Read the tutorials for ads by clicking the link in the signature. You will find a tutorial for inserting ads for PHBB 3.
 

galaxyAbstractor

Community Advocate
Community Support
Messages
5,508
Reaction score
35
Points
48
I have managed to insert in phpBB 3 but I will insert it here: http://jagf.pcriot.com/dk and here: http://jagf.pcriot.com/phaos . All template files is php. In phaos there isn't even template files. There are over ~100 php files that the public can see and I want to insert the add making changes to just 1 or 2 files. I have no energy to paste code in over 120 php files and if some error occours idk where the problem are.
 

Slothie

New Member
Messages
1,429
Reaction score
0
Points
0
There should be a header.tpl somewhere. I haven't used phpBB for quite some time, if you'd paste out the directory structure for the template files I'm sure I could figure out something.
 

galaxyAbstractor

Community Advocate
Community Support
Messages
5,508
Reaction score
35
Points
48
BUT FOR **** SAKE!!! I'm not want help with phpBB!!! I am already done with phpBB. Now I want to add the banner at the pages that still needs it! I have over 100 pages I don't know how to insert the ad without editing them all!!! And no!! There aren't any .tpl files. Only php and css! Not even html!
 

Thewinator

New Member
Messages
256
Reaction score
0
Points
0
Well you could write a piece of code that inserts the code in all files in a folder or something.
But the best way is to use a new php file to load the contents of the other files.
This is realy basic but comes down to this:
PHP:
echo "the x10 ad here";
include('your_content.php');

Have you considered this?
 

Slothie

New Member
Messages
1,429
Reaction score
0
Points
0
Okay this might work and it might not for you. But here's a way to add a php header to ALL files in the directory

Add this in the .htaccess file of the directory
Code:
AddHandler application/x-httpd-php .php
php_value auto_prepend_file overall_header.php
php_value auto_append_file overall_footer.php
This code, tells Apache to automatically run the overall_header.php before the requested php file and to run the file overall_footer.php after the conclusion of the requested file.

It’s a powerful way to create common headers and footers to pages or files, but be aware that it comes at a cost,


Then create a new file called overall_header.php and put the following text in it:
PHP:
<?php
function callback($buffer)
{
$adtext = <<<EOF
<BODY>
SOME ADS HERE
EOF;
  $x = (str_replace("<body>", $adtext, $buffer));
  return $x;
}
ob_start("callback");
?>

You probably want to change the body text to whatever tag you want the ads to show under, that's just an example.

Finally you need to flush the file, so make a new file called overall_footer.php and put this inside

PHP:
<?php
ob_end_flush();
?>

Final notes: The handler MAY be different according to which version of PHP you have. I haven't logged into my x10 account for awhile so I forgot the handler name but you can find it in cPanel.
 
Last edited:

galaxyAbstractor

Community Advocate
Community Support
Messages
5,508
Reaction score
35
Points
48
Okay this might work and it might not for you. But here's a way to add a php header to ALL files in the directory

Add
Code:
AddHandler application/x-httpd-php .php
php_value auto_prepend_file overall_header.php
php_value auto_append_file overall_footer.php

Do I add this in the apache handler in the cPanel??? And will the overall_header.php only show up in the directory overall_header.php is in?
 

Slothie

New Member
Messages
1,429
Reaction score
0
Points
0
Add that in the htaccess file of the directory, bear in mind that a htaccess file is recursive so is better if the file is NOT in the root of your hosting directory.
 

galaxyAbstractor

Community Advocate
Community Support
Messages
5,508
Reaction score
35
Points
48
I get 500 internal server error after the .htaccess changes. I have all files and all code you have written. It isn't your fault, it is the apaches fault. Every single time I add a handler I get 500 internal server error if the apache handler exsist. If the apache handler doesen't exsist I get prompted to download the file... So I'm 99% sure it is the apache.
 

Slothie

New Member
Messages
1,429
Reaction score
0
Points
0
Ask Corey about it. I've done the same thing before on other shared hosting
 

Slothie

New Member
Messages
1,429
Reaction score
0
Points
0
Alternatively you could always use a text editor on all those files and just put in an include statement.

Too bad x10 doesn't have shell access or you could just sed all of 'em :p
 

galaxyAbstractor

Community Advocate
Community Support
Messages
5,508
Reaction score
35
Points
48
I started an support thread about it... I haven't got any energy to paste the include thing in over 100 files.
 
Top