Need a simple script

Status
Not open for further replies.

SecurePay

Registered Member
Joined
Dec 15, 2010
Messages
80
Reaction score
10
Hey.

I need a simple script. I need script which makes my advertisement scripts to show up ramdomly.

So that my ads doesn't show up all the time, like that advertisement script shows up in every 50 page views, from that same computer or something like that.

Ill pay 15$ for that, someone who is familiar with scripts should know how to make something like that in few minutes.

Thanks.
 
I can do it but without the "from that computer" part
So you add your adds and everytime the site is loaded there is a 1:xxx chance of one of the adds showing.
Do you want there to be a chance of no Add at all, or just randomize the adds?
 
Use the PHP rand() function to create a random number between 0 and X. Next, use 'if statement to show banner code only when random number is 3 ;)
 
I can do it but without the "from that computer" part
So you add your adds and everytime the site is loaded there is a 1:xxx chance of one of the adds showing.
Do you want there to be a chance of no Add at all, or just randomize the adds?

Set a cookie and increment the value by one on every page load. When it gets to $x, show the ad and reset the cookie value to zero.
 
Code:
<?php
$num=rand(1,5);
if ($num==1)
{
?>
ADD CODE HERE
<?php
}
if ($num==2)
{
?>
ADD CODE HERE
<?php
}
if ($num==3)
{
?>
ADD CODE HERE
<?php
}
if ($num==4)
{
?>
ADD CODE HERE
<?php
}
if ($num==5)
{
?>
ADD CODE HERE
<?php
}
?>

Replace "ADD CODE HERE" with you add code, or just leave it blank (then no add will be shown.)
this is a 1:5 chance for each offer, but you can modify it to fit your needs
 
I can do it but without the "from that computer" part
So you add your adds and everytime the site is loaded there is a 1:xxx chance of one of the adds showing.
Do you want there to be a chance of no Add at all, or just randomize the adds?


Well i have this advertisiment script.

<script>
var adfly_id = 236329;
var adfly_advert = 'banner';
var exclude_domains =
</script>
<script src="LINKlink..asf.asdas></script>


I would like that it would work that it shows up that randomly, that it doesnt show up all the time. Like 5 times/hour for one visitor.
 
Tell me the ratio:

1 Add impression for every X hits (average)

What do you want X to be?
 
Tell me the ratio:

1 Add impression for every X hits (average)

What do you want X to be?

Well, i have like 1000 pageviews/5 minutes, and i wan't that every visitor would see like 5 ads/hour, so what would you suggest?
 
Just test it out.
use this script:
Code:
<?php
$num=rand(1,[COLOR="Red"]1000[/COLOR]);
if ($num==10)
{
?>
ADD 1 CODE HERE
<?php
}
?>

Thats a chance of 1:1000 of the add showing.
To increase / decrease the chance, just change the red number.
Higher means less chances of add showing

This will get you 1 Impression of the add per 5 minutes around all your visitors..
so you might want to lower the number to 100 or similar..
 
Last edited:
5 times an hour per visitor.
PHP:
<?
$curMin = date("i");
if (($curMin == "00") || ($curMin == "12") || ($curMin == "24") || ($curMin == "36") || ($curMin == "48")) {
?>
Copy paste the above portion.
Then copy and paste your script.
Then copy and paste the below portion.

PHP:
<? } ?>
 
PHP:
<?
$curMin = date("i");
if (($curMin == "00") || ($curMin == "12") || ($curMin == "24") || ($curMin == "36") || ($curMin == "48")) {
?>
[color=white]Paste your script here.[/color]
<? } ?>
This will only show adds at xx:12, xx:24, xx:36 and xx:48....
Not the best solution i think...
But depends on the OPs taste
 
This will only show adds at xx:12, xx:24, xx:36 and xx:48....
Not the best solution i think...
But depends on the OPs taste
Also at 00. So every 12 minutes, 5 times an hour. I don't think the proximity of ad display would really matter...I mean you could do all 5 in 5 minutes and never see them again for 55 minutes, or once every 12 minutes...
 
Just test it out.
use this script:
Code:
<?php
$num=rand(1,[COLOR=Red]1000[/COLOR]);
if ($num==10)
{
?>
ADD 1 CODE HERE
<?php
}
?>
Thats a chance of 1:1000 of the add showing.
To increase / decrease the chance, just change the red number.
Higher means less chances of add showing

This will get you 1 Impression of the add per 5 minutes around all your visitors..
so you might want to lower the number to 100 or similar..

Well, this doesn't work. It shows the add all the time :0? I edited this into footer of my Vbulletin forums, (in styles)
 
That is strange
It works for me
Had to hit "F5" a million times till it finally showed up...(Having the number set to 100)
 
That is strange
It works for me
Had to hit "F5" a million times till it finally showed up...(Having the number set to 100)

Well anyway, now its working, please give me details of your paypal account and ill send you 15 dollars in 1 week, (after i get my payment from work ill pay ya)

Thanks!
 
This script shows an ad on the first page load and every 10th page load after that. You can configure how often to show an ad and your ad text at the top of the script. No dodgy randomization required.

Code:
<?php

// Show an ad every x impressions
$show_ad_every = 10;
// Html of your ad
$ad_html       = 'Here is the fucking ad';

// Set / increment the cookie value
if(isset($_COOKIE['views'])) {
	$views = $_COOKIE['views'];
	$views++;
	setcookie('views', $views);
} else {
	setcookie('views', 1);
}

// Decide whether to show an ad or not
if(!$_COOKIE['views'] || ($_COOKIE['views'] % $show_ad_every) == 0) {
	$show_ad = 1;
} else {
	$show_ad = 0;
}

?>
<html>
<head>
<title>Blah blah</title>
</head>
<body>
<?php
	// echo "Cookie value: ". $_COOKIE['views'] ."<br>";
	if($show_ad == 1) {
		echo "$ad_html<br>";
	}
?>
Blah blah blah
</body>
</html>
 
This script shows an ad on the first page load and every 10th page load after that. You can configure how often to show an ad and your ad text at the top of the script. No dodgy randomization required.

Code:
<?php

// Show an ad every x impressions
$show_ad_every = 10;
// Html of your ad
$ad_html       = 'Here is the fucking ad';

// Set / increment the cookie value
if(isset($_COOKIE['views'])) {
	$views = $_COOKIE['views'];
	$views++;
	setcookie('views', $views);
} else {
	setcookie('views', 1);
}

// Decide whether to show an ad or not
if(!$_COOKIE['views'] || ($_COOKIE['views'] % $show_ad_every) == 0) {
	$show_ad = 1;
} else {
	$show_ad = 0;
}

?>
<html>
<head>
<title>Blah blah</title>
</head>
<body>
<?php
	// echo "Cookie value: ". $_COOKIE['views'] ."<br>";
	if($show_ad == 1) {
		echo "$ad_html<br>";
	}
?>
Blah blah blah
</body>
</html>

You overcame my lazyness:D

Props to you!
 
This script shows an ad on the first page load and every 10th page load after that. You can configure how often to show an ad and your ad text at the top of the script. No dodgy randomization required.

Code:
<?php

// Show an ad every x impressions
$show_ad_every = 10;
// Html of your ad
$ad_html       = 'Here is the fucking ad';

// Set / increment the cookie value
if(isset($_COOKIE['views'])) {
    $views = $_COOKIE['views'];
    $views++;
    setcookie('views', $views);
} else {
    setcookie('views', 1);
}

// Decide whether to show an ad or not
if(!$_COOKIE['views'] || ($_COOKIE['views'] % $show_ad_every) == 0) {
    $show_ad = 1;
} else {
    $show_ad = 0;
}

?>
<html>
<head>
<title>Blah blah</title>
</head>
<body>
<?php
    // echo "Cookie value: ". $_COOKIE['views'] ."<br>";
    if($show_ad == 1) {
        echo "$ad_html<br>";
    }
?>
Blah blah blah
</body>
</html>

Welll i can't even add this into my forums, becouse example my add is a script. and it gives this error:

"
The following error occurred when attempting to evaluate this template:
%1$s
This is likely caused by a malformed conditional statement. It is highly recommended that you fix this error before continuing, but you may continue as-is if you wish."

Warning: Invalid argument supplied for foreach() in [path]/includes/functions.php on line 3416
 
Status
Not open for further replies.
This thread has been auto closed due to the forum's thread age policy. Read more.
Back
Top