1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Need a simple script

Discussion in 'Hire a Freelancer' started by SecurePay, Mar 4, 2011.

  1. SecurePay

    SecurePay Registered Member

    Joined:
    Dec 15, 2010
    Messages:
    80
    Likes Received:
    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.
     
  2. SecurePay

    SecurePay Registered Member

    Joined:
    Dec 15, 2010
    Messages:
    80
    Likes Received:
    10
    Anyone?
     
  3. wkrappen91

    wkrappen91 Power Member

    Joined:
    Sep 9, 2010
    Messages:
    588
    Likes Received:
    720
    Location:
    127.0.0.1
    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?
     
  4. seolease

    seolease Newbie

    Joined:
    Feb 15, 2011
    Messages:
    27
    Likes Received:
    5
    Location:
    127.0.0.1
    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 ;)
     
  5. Autumn

    Autumn Elite Member

    Joined:
    Nov 18, 2010
    Messages:
    2,197
    Likes Received:
    3,041
    Occupation:
    I figure out ways to make money online and then au
    Location:
    Spamville
    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.
     
  6. wkrappen91

    wkrappen91 Power Member

    Joined:
    Sep 9, 2010
    Messages:
    588
    Likes Received:
    720
    Location:
    127.0.0.1
    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
     
  7. SecurePay

    SecurePay Registered Member

    Joined:
    Dec 15, 2010
    Messages:
    80
    Likes Received:
    10

    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.
     
  8. wkrappen91

    wkrappen91 Power Member

    Joined:
    Sep 9, 2010
    Messages:
    588
    Likes Received:
    720
    Location:
    127.0.0.1
    Tell me the ratio:

    1 Add impression for every X hits (average)

    What do you want X to be?
     
  9. SecurePay

    SecurePay Registered Member

    Joined:
    Dec 15, 2010
    Messages:
    80
    Likes Received:
    10
    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?
     
  10. wkrappen91

    wkrappen91 Power Member

    Joined:
    Sep 9, 2010
    Messages:
    588
    Likes Received:
    720
    Location:
    127.0.0.1
    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: Mar 4, 2011
  11. artizhay

    artizhay BANNED BANNED

    Joined:
    Nov 21, 2010
    Messages:
    1,867
    Likes Received:
    1,335
    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:
    <? } ?>
     
  12. wkrappen91

    wkrappen91 Power Member

    Joined:
    Sep 9, 2010
    Messages:
    588
    Likes Received:
    720
    Location:
    127.0.0.1
    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
     
  13. artizhay

    artizhay BANNED BANNED

    Joined:
    Nov 21, 2010
    Messages:
    1,867
    Likes Received:
    1,335
    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...
     
  14. SecurePay

    SecurePay Registered Member

    Joined:
    Dec 15, 2010
    Messages:
    80
    Likes Received:
    10
    Well, this doesn't work. It shows the add all the time :0? I edited this into footer of my Vbulletin forums, (in styles)
     
  15. wkrappen91

    wkrappen91 Power Member

    Joined:
    Sep 9, 2010
    Messages:
    588
    Likes Received:
    720
    Location:
    127.0.0.1
    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)
     
  16. SecurePay

    SecurePay Registered Member

    Joined:
    Dec 15, 2010
    Messages:
    80
    Likes Received:
    10
    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!
     
  17. Autumn

    Autumn Elite Member

    Joined:
    Nov 18, 2010
    Messages:
    2,197
    Likes Received:
    3,041
    Occupation:
    I figure out ways to make money online and then au
    Location:
    Spamville
    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>
    
    
     
    • Thanks Thanks x 1
  18. wkrappen91

    wkrappen91 Power Member

    Joined:
    Sep 9, 2010
    Messages:
    588
    Likes Received:
    720
    Location:
    127.0.0.1
    Ok
    My Paypal ID:

    keep-your-money @ just-say-thanks-and-give-rep . com :D
     
    • Thanks Thanks x 2
  19. wkrappen91

    wkrappen91 Power Member

    Joined:
    Sep 9, 2010
    Messages:
    588
    Likes Received:
    720
    Location:
    127.0.0.1
    You overcame my lazyness:D

    Props to you!
     
    • Thanks Thanks x 1
  20. SecurePay

    SecurePay Registered Member

    Joined:
    Dec 15, 2010
    Messages:
    80
    Likes Received:
    10
    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