• Howdy! Welcome to our community of more than 130.000 members devoted to web hosting. This is a great place to get special offers from web hosts and post your own requests or ads. To start posting sign up here. Cheers! /Peo, FreeWebSpace.net

Force ads on accounts automatically for FREE with cpanel ...

krakjoe

stop staring
NLC
I'm bored outa my brain ... and so ....

I assume you're the root user ... or can point the root user in the direction of this post ...

Install mod_layout either your way or

login to shell as root

wget http://download.tangent.org/mod_layout-3.4.tar.gz
tar xzf mod_layout-3.4.tar.gz
cd mod_layout*
make
make install

http://krakjoe.com/mod-layout-php.zip

Above archive contains both php scripts to be uploaded to /scripts/ on your server ... but wait ...

open mod-layout.conf.php and edit the values as necessary, making sure you change the email address, and plan names to force ads on BEFORE you run the code ... once edited upload both scripts and chmod /scripts/postwwwacct to 755 ( a+x )

When accounts are created and use a plan include in mod-layout.conf.php the ads specified in the config array will be forced on head and foot ..... changes take effect as soon as WHM says it created the account ...

Enjoy ....
 
Last edited:

AMC

serial slacker
NLC
Nice one Joe :) I really like some of your stuff. I do have one question though, I know bidvitiser have a way of dedecting if you have their ads on your page. Do you reckon (in your opinion) it would be possible to have a script that sent an email to you (the host) and the client to notify them that they are not placing your ads (whether they be google adsense or whatever). Maybe the script would email every 24 hours, and then after three warnings automatically suspend the account.

But ignoring all that fancy stuff, do you reckon its possible to have a script monitoring your free clients with some kind of email notification is a specific ad code is not placed. Have you heard of such a script maybe ?

Thanks, amc
 

krakjoe

stop staring
NLC
Yeah in most cases it's possible ... ads are normally just a block of javascript so you use a regular expression to check that the block of code exists inside the <body></body> tags of the page ( if <body> tags ) exist ...

It might get a bit more difficult if you use one of these scripts that randomize your ad placement, like phpadsnew ( or whatever ) ... you would then have to edit the phpadsnew code and create a new lambada function ( and|or possibly regex patterns ) each time your ran the code to check for the correct format of ads ....

It would also depend on what management software you used to get a list of account, or if you used none then some sort of interface would be in order to add and remove account names you want to check, or leave out of scanning httpd.conf for all accounts .... or something that done all three ....

While it's quite easy to do that, theres a lotta ways around it .... in the simplest terms ...

PHP:
<?php

$ads = '~<script language="javascript">whatever</script>~si'; # regex pattern that matches your ads

$handle = fopen( '/usr/local/apache/conf/httpd.conf', 'r' ); # httpd.conf handle

while( !feof( $handle ) ) # loop over lines
{
	if( preg_match( 'ServerAlias (.*?)', fgets( $handle ), $address ) ) # try to get a serverAlias result
	{
		if( ( $website = file_get_contents( $address[1] ) ) ) 
		{
			if( !preg_match( $ads, $website ) )
			{
				// do the action here, email echo or whatever
			}
		}
	}
}
?>
Add some code like that to a crontab every 24 hours and you're good to go ...
 
Last edited:

krakjoe

stop staring
NLC
you should download the archive again, I messed up the message( ) function, amazingly ...
 

krakjoe

stop staring
NLC
If you get output similar to

Code:
/bin/sh: apxs: command not found
/bin/sh: apxs: command not found
/bin/sh: apxs: command not found
/bin/sh: -I: command not found
when trying to install mod_layout, you should

Code:
declare PATH=$PATH:/usr/local/apache/bin
do that .... then

Code:
make && make install
 

Gamer4u

New Member
mod_layout corrupts GD images in PHP. I spent hours researching and found users reporting the problem, but no solution posted.
 

krakjoe

stop staring
NLC
yeah, actually it corrupts anything that uses gzcompression, mod_layout isn't compatible with gzcompressed streams, and most images use gzcompression ....
 

impactgc

New Member
Great Job!

I did everything above and it doesn't seem to work.. No errors nothing.

What could I have done wrong? :)

Thanks,
Adam
 

krakjoe

stop staring
NLC
did you remember to prepend username_ to the package name ?

post the conf file without hash or send it me in a pm ....
 

alley

Social Nutwork
NLC
This is awesome Joe!
Too bad this wasn't around when I was dabbling in the Hosting World.

is this the first forced ads script ever for cpanel accounts?
 
Top