Forced Ads On ISPConfig With Debian Etch

Want to support HowtoForge? Become a subscriber!
 
Submitted by webcave (Contact Author) (Forums) on Wed, 2008-08-20 19:36. :: Debian | ISPConfig | Control Panels

Forced Ads On ISPConfig With Debian Etch 

This howto forces ads on every single site that you have and cannot be deleted by users from the .htaccess - it does not even use .htaccess.

I am using Debian Etch and ISPConfig 2.2.24.

Steps that will be done:

- Edit apache config.
- Edit master vhost file.
- Create ads.
- Edit files so you can disable ads on certain pages.

PHP must be enabled server wide for this to work, not to much of a biggie - you should offer PHP by default anyway, it's so common nowadays.

 

Step 1

Enable PHP system wide:

vi /etc/mime.types

Uncomment these 4 lines of code:

[...]
#application/x-httpd-php phtml pht php
#application/x-httpd-php-source phps
#application/x-httpd-php3 php3
#application/x-httpd-php3-preprocessed php3p
#application/x-httpd-php4 php4
[...]

vi /etc/apache2/mods-enabled/php5.conf

Uncomment these 2 lines of code:

<IfModule mod_php5.c>
# AddType application/x-httpd-php .php .phtml .php3 # AddType application/x-httpd-php-source .phps </IfModule>

 

Step 2

Editing Apache files:

vi /etc/apache2/apache2.conf

Towards the bottom of the apache2.conf you will find:

<Directory /var/www/sharedip>
Options +Includes -Indexes
AllowOverride None
AllowOverride Indexes AuthConfig Limit FileInfo
Order allow,deny
Allow from all
<Files ~ "^\.ht">
Deny from all
</Files>
</Directory>

Right after this add:

<Directory /var/www>
Options +Includes -Indexes
AllowOverride None
AllowOverride Indexes AuthConfig Limit FileInfo Options
Order allow,deny
Allow from all
<Files ~ "^\.ht">
Deny from all
</Files>
</Directory>

Under that you will find:

<Directory /var/www/*/web>
Options +Includes -Indexes
AllowOverride None
AllowOverride Indexes AuthConfig Limit FileInfo
Order allow,deny
Allow from all
<Files ~ "^\.ht">
Deny from all
</Files>
</Directory>

Change that to:

<Directory /var/www/*/web>
Options +Includes -Indexes
AllowOverride None
AllowOverride Indexes AuthConfig Limit FileInfo Options
Order allow,deny
Allow from all
<Files ~ "^\.ht">
Allow from root
Deny from all
</Files>
</Directory>

Save and close.

Now let's restart Apache:

/etc/init.d/apache2 restart

 

Step 3

Creating a directory for ads:

mkdir /var/www/ads

 

Step 4

We are going to create one file. We will make header.php:

vi /var/www/ads/header.php

Now we must enter the info for the header ad file:

<?
$adfrees = '/var/www/web1/web'; //Change this to the web you want without ads
$dir = getcwd();
if ($dir == $adfrees) {
echo '';
} else {
echo '
AD CODE HERE
'; }
?>

The first highlight is the directory name of the file you want without ads. The second highlight is where you would put your ad code from Google and such.

 

Step 5

We must now edit the master vhost file so it will automatically put ads in every single site forcefully.

vi /root/ispconfig/isp/conf/vhost.conf.master

Towards the bottom you will see:

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK)
RewriteRule .* - [F]
</IfModule>

Right below it add:

php_value output_buffering 4098
php_value auto_prepend_file '/var/www/ads/header.php'
AddType application/x-httpd-php htm
AddType application/x-httpd-php html

That code is if you want your ad on the top of the page if you want it on the bottom instead use this code:

php_value output_buffering 4098
php_value auto_append_file '/var/www/ads/footer.php'
AddType application/x-httpd-php htm
AddType application/x-httpd-php html

The highlighted part is where you would put your file name if you changed it.

Save and close this file then restart ISPConfig:

/etc/init.d/ispconfig_server restart

 

Done

That's it - you now have real forced ads that cannot come off of the page at all!

Written by: Joey C. (web-cave.net)
Help from: grandpagenocide (rhwebhosting.com) and Jcink (jcink.com)


Please do not use the comment function to ask for help! If you need help, please use our forum.
Comments will be published after administrator approval.
Submitted by Anonymous (not registered) on Sat, 2009-03-28 08:06.

how to fix open_basedir restriction problem  :

Warning: Unknown: open_basedir restriction in effect. File(/var/www/ads/footer.php) is not within the allowed path(s): (/var/www/web9/) in Unknown on line 0

Warning: Unknown: failed to open stream: Operation not permitted in Unknown on line 0

Fatal error: Unknown: Failed opening required '/var/www/ads/footer.php' (include_path='.:/usr/share/php:/usr/share/pear') in Unknown on line 0