Dynadot โ€” .com Transfer

[TUTORIAL] Forced ads for resellers

SpaceshipSpaceship
Watch
Ok, well I finally found it... Forced ads with .htaccess file! Right now this works for .html & .htm extensions, but I'm working on getting it to .php as well, I will update as I figure that one out, it's a little more difficult for obvious reasons. (Quotes, syntax, etc. And above all, it parses through a PHP script)

MUST have the php_read function enabled! (Most webservers have this on by default)

YES! This is a free alternative to all the software out there

First, go into your cPanel account. (Reseller)

Now, not in WHM, but cPanel go into File Manager.

Find your cPanel skeleton directory.

In here... What we will do...

First create a new folder... Name it.. header...

In this folder create 3 text documents...

1 text document named: header.php
1 text document named: header.html
1 text document named: footer.html

In header.php insert the following code:
PHP:
<?php
$header = "header.html";
$footer = "footer.html";
$file = $_SERVER['SCRIPT_FILENAME'];

readfile($header);
readfile($file);
readfile($footer);
?>

In header.html insert your ad code you wish to be set in the header.

In footer.html insert your ad code you wish to be set in the footer.


Now go back up one directory... Edit your .htaccess file..

Add this somewhere:

Code:
AddHandler headered .html # Enable adds on HTML pages
AddHandler headered .htm # Enable adds on HTM pages
AddHandler headered .php # Enable adds on PHP pages
Action headered /header/header.php

==============================================
Ok, now that we have that finished, I have an iFrame code you can use!

Now, let's begin..

Open backup your header.html file.. Change it to this: (Footer will not be iFrame unless you do so doing the same process)
HTML:
<HTML>
<center><iframe src="http://yoursite.com/header/iframesrc.adsource" scrolling="no" width="48.2%" height="12%"></iframe></center>
</HTML>
<html>

Now, we need to create a new file... Create a new text document and name it: iframesrc.adsource (Be sure to place it in the "header" directory)

Insert you're ad code into that page...


But wait... Perplexed? That is correct, we still need to make the .adsource extension a valid one! So here is what we'll do.

Get out of the skeleton directory and go into the reseller account's /public_html folder. Open the .htaccess file..

In the .htaccess file add this somewhere:
Code:
AddHandler server-parsed adsource
AddType text/html adsource

Do this just in the reseller's .htaccess or wherever the ad code is being read from... This way the .adsource extension is not available for all users.

==============================================
At the current time it is not very secure for the user will be able to edit it, but I am working on it.. This is the basic concept and as I make changes I will create a changelog at the bottom of this post! Now creating an account will automatically ad your adcode to the site! Just make sure if needed you ad that domain to your publisher account with the ad company :)

-RageD
 
Last edited:
1
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
hey raged, have you found any complete solution which puts headers for php files as well??

thanks a lot
 
0
•••
Actually I have.. This seems to work on PHP 4.x and 5.x. I will update the original post but instead of:

PHP:
$_SERVER["PATH_TRANSLATED"]

it seems rather that:
PHP:
$_SERVER['SCRIPT_FILENAME']

is a better alternative!

Cheers,
-RageD
 
1
•••
yippie finally a php version as well... desperately waiting for that one dude :)
 
0
•••
champ_rock said:
yippie finally a php version as well... desperately waiting for that one dude :)
Just like me.

Thanks for sharing!
 
0
•••
Just felt I'd revive this one for anyone who is looking for such a solution again! :)

Also, I have not tested this but here is an idea. If you would like to keep the "header" directory untouchable by the user and have root access (many don't but that's alright. Maybe it would work with just SSH access on a reseller) try this:

cd /home/USER/public_html
chown root headers/
chown root headers/*

Again, I have not tried this. You may want to test that apache still allows the file to be executed in the browser but it should. After CHOWN'ing to root or another user (resellers try with chown YOURUSER) the user will be unable to edit the file.

-RageD
 
Last edited:
0
•••
well i owe this thread a lot of things. this was a the primary reason i got interested in Namepros and subsequently domains. i must agree that i do not regret that decision at all :)
 
0
•••
I am glad to see the post was of service :)

-RageD
 
0
•••
gr8 job ty :)
 
0
•••
asp100

็ฝ‘็ซ™ไผ˜ๅŒ–ๅฏไปฅไธบ็ฝ‘็ซ™่ฟ่ฅๅธฆๆฅๅ“ชไบ›ๆ•ˆๆžœ?็ฝ‘็ซ™ไผ˜ๅŒ–ไธŽๆœ็ดขๅผ•ๆ“Žไผ˜ๅŒ–ๆ˜ฏไป€ไนˆๅ…ณ็ณป?ไธบไป€ไนˆ่ฏด็ฝ‘็ซ™ไผ˜ๅŒ–ๆ˜ฏ่ฝๅŽ็š„ๆ–นๅผ?ๆไพ›ๆœ€ไธ“ไธš็š„็ฝ‘็ซ™ไผ˜ๅŒ–ๅˆ†ๆžไธŽ็ฝ‘็ซ™ไผ˜ๅŒ–่งฃๅ†ณ
 
0
•••
Namepros...
 
0
•••
Appraise.net
Escrow.com
Spaceship
Rexus Domain
CryptoExchange.com
Domain Recover
CatchDoms
DomDB
NameFit
  • The sidebar remains visible by scrolling at a speed relative to the pageโ€™s height.
Back