Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > ISPConfig 2 > Tips/Tricks/Mods

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Reply
 
Thread Tools Display Modes
  #1  
Old 9th March 2008, 23:06
grandpagenocide grandpagenocide is offline
Senior Member
 
Join Date: Jun 2007
Location: Brooklyn, NY
Posts: 308
Thanks: 13
Thanked 43 Times in 29 Posts
Send a message via AIM to grandpagenocide Send a message via MSN to grandpagenocide
Default Forced ads on ISPConfig server

Forced ads for ISPConfig with .htaccess .
I wrote this “how to” for those who want to place forced ads on their ISPConfig server.
Probably you can setup forced ads in different ways but I found the way descibed here.

I am using Debian Etch and ISPConfig 2.2.19 in this example.
What needs to be done:
- edit apache config
- create .htaccess files
- create header and footer with ads
- disable the ads on accounts that upgrade

I had to enable php server wide for this to work, and since i give all my clients php, it is not a big deal, but if anyone can update this with a meathod to only allow php in the /var/www and /var/www/ads that would be appreciated

Let’s show where our ISPConfig server is capable of, here we go:

STEP 1
Enable php system wide

vi /etc/mime.types

uncomment out the following:

Quote:
[...]
#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
Quote:
<IfModule mod_php5.c>
# AddType application/x-httpd-php .php .phtml .php3
# AddType application/x-httpd-php-source .phps
</IfModule>
STEP 2
First lets edit apache.conf

vi /etc/apache2/apache2.conf

Towards the bottom of the apache2.conf you will find
Quote:
<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>
immeidately after add
Quote:
<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>
Below that you will find
Quote:
<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 this to

Quote:
<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

/etc/init.d/apache2 restart

STEP 3

Now lets create a directory

mkdir /var/www/ads

STEP 4

we are going to create two php files now
lets make footer.php with your footer ad
and lets make blank.php that is actually blank

STEP 5
Creating .htaccess file
use any text editor you like most of them will give you another extention, but rename the file to .htaccess and have it contain the following:

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

And thats it, now every site on the server will have your forced footer, the same goes if you want a header.

TO DISABLE ADS ON AN INDIVIDUAL SITE
Create another .htaccess file with the following


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

and place it in the /web directory of that site

And thats it guys, you now have forced ads. I am going to try to write a module that will allow this to be controled from ispconfig cp.

Last edited by grandpagenocide; 9th March 2008 at 23:11.
Reply With Quote
The Following 4 Users Say Thank You to grandpagenocide For This Useful Post:
edge (10th March 2008), falko (10th March 2008), Gimly (11th March 2008), gjcomputer (11th March 2008)
Sponsored Links
  #2  
Old 10th March 2008, 18:40
grandpagenocide grandpagenocide is offline
Senior Member
 
Join Date: Jun 2007
Location: Brooklyn, NY
Posts: 308
Thanks: 13
Thanked 43 Times in 29 Posts
Send a message via AIM to grandpagenocide Send a message via MSN to grandpagenocide
Default Trying to replicate it

ok i am trying to replicate it on another server, and for some reason I am getting this error, it is working fine on one server, how do I remove the basedir restriction?
Quote:
Warning: Unknown: open_basedir restriction in effect. File(/var/www/ads/inc_footer.php) is not within the allowed path(s): (/var/www/web3/) 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 '/ads/inc_footer.php' (include_path='.:/usr/share/php:/usr/share/pear') in Unknown on line 0
Reply With Quote
  #3  
Old 11th March 2008, 02:12
grandpagenocide grandpagenocide is offline
Senior Member
 
Join Date: Jun 2007
Location: Brooklyn, NY
Posts: 308
Thanks: 13
Thanked 43 Times in 29 Posts
Send a message via AIM to grandpagenocide Send a message via MSN to grandpagenocide
Default

It works fine the clients site i was viewing had an htaccess in it for chinese encoding and muffed it up

Last edited by grandpagenocide; 11th March 2008 at 02:48.
Reply With Quote
  #4  
Old 11th March 2008, 16:20
gjcomputer gjcomputer is offline
Member
 
Join Date: Jan 2006
Location: missouri, USA
Posts: 91
Thanks: 15
Thanked 2 Times in 2 Posts
Default

many thanks, this looks like something i would really like to do...
__________________
6r36.com
Reply With Quote
  #5  
Old 11th March 2008, 18:22
grandpagenocide grandpagenocide is offline
Senior Member
 
Join Date: Jun 2007
Location: Brooklyn, NY
Posts: 308
Thanks: 13
Thanked 43 Times in 29 Posts
Send a message via AIM to grandpagenocide Send a message via MSN to grandpagenocide
Default

No problem if you need any help PM me
Reply With Quote
  #6  
Old 28th July 2008, 19:10
3StrikesDesign 3StrikesDesign is offline
Junior Member
 
Join Date: Jul 2008
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Great post, thanks for providing it to us
Reply With Quote
  #7  
Old 14th August 2008, 00:48
webcave webcave is offline
Junior Member
 
Join Date: Jul 2008
Posts: 22
Thanks: 6
Thanked 1 Time in 1 Post
Default

I worked on this code some so here i have some good stuff for you

Ok first code i will give you is to not auto add it to every account but FORCE it on every account no matter what before they could just edit out the ad's part of the .htaccess file so.

Go to: /root/ispconfig/isp/conf/
Edit File: vhost.conf.master

Go to the bottom
you will see this
Quote:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK)
RewriteRule .* - [F]
</IfModule>
Right Below that add
Quote:
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 is the code for your ad replace header.php with your ad file name
Also if you want your ad on the top or the bottom of the page

Top of page: php_value auto_prepend_file '/var/www/ads/header.php'
Bottom of page: php_value auto_append_file '/var/www/ads/header.php'

This code can not be removed from any site so i made a mod for the ad file you will not need blank.php anymore so you can delete it.

So in your ad file right now you have your ad code thats it, Change your file so its like this.
Quote:
<?
$adfrees = '/var/www/web1/web'; //Change this to the web you want without ad's
$dir = getcwd();
if ($dir == $adfrees) {
echo '';
} else {
echo '
AD CODE HERE
'; }
?>
It works great!
Reply With Quote
The Following User Says Thank You to webcave For This Useful Post:
grandpagenocide (14th August 2008)
  #8  
Old 27th August 2008, 23:35
Ballistic509 Ballistic509 is offline
Member
 
Join Date: May 2007
Posts: 31
Thanks: 1
Thanked 1 Time in 1 Post
Default

Hmmm...What if I only want this on certain accounts? Say like, not server wide, but on free hosting that I offer. If those accounts ONLY get ads, and not the paid hosts? If there is a way, other than adding each paid account to the ad file.
Reply With Quote
  #9  
Old 28th August 2008, 02:08
grandpagenocide grandpagenocide is offline
Senior Member
 
Join Date: Jun 2007
Location: Brooklyn, NY
Posts: 308
Thanks: 13
Thanked 43 Times in 29 Posts
Send a message via AIM to grandpagenocide Send a message via MSN to grandpagenocide
Default

Ballistic, if you use the htaccess meathod i layed out, you can control it through the htaccess files, who has ads and who doesnt.
__________________
Hosting for the Masses
http://rhwebhosting.com
Reply With Quote
  #10  
Old 28th August 2008, 02:56
Ballistic509 Ballistic509 is offline
Member
 
Join Date: May 2007
Posts: 31
Thanks: 1
Thanked 1 Time in 1 Post
 
Default

but if i do that then i risk the chance that the user deletes the htaccess file or ad line correct?

ISPConfig should include a module for this to select which plans have forced ads.

OR can I add code to something to select which plans do have ads?
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
ISPconfig after installation cannot reach www.xyz.de:81 Figth4Linux Installation/Configuration 23 6th March 2008 22:38
Problem with keeping Apache alive bobeq Server Operation 3 29th November 2007 16:11
ispconfig - server migration best way sygram Installation/Configuration 3 26th October 2007 11:37
[Multiple ISPConfig servers] Howto select best server for remoting account creation? krakoukas Installation/Configuration 4 8th July 2007 19:01
Rejecting outbound mail tristanlee85 General 11 20th May 2007 17:04


All times are GMT +2. The time now is 06:42.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.