P.Z. Low Cost CPanel Web Hosting  

Go Back   P.Z. Low Cost CPanel Web Hosting > Page-Zone Web Hosting Main Forum > Tips & Tricks

Tips & Tricks Throw us a bone here. Post your best known tips & tricks.

Reply
 
LinkBack Thread Tools Rate Thread Display Modes
Amazon Ad Rotater
Old
  (#1 (permalink))
midwest
blink and it's over
midwest will become famous soon enough
 
midwest's Avatar
 
Status: Offline
Posts: 803
Join Date: Oct 2002
Location: Big Sky, MT
Rep Power: 76
Amazon Ad Rotater - 06-29-2008, 11:00 PM

I cobbled up a little PHP script to rotate amazon ads. The ads are each kept in a separate file in the same folder. It does not matter whether the ad code is on one line or multiple, the script reads it into a single string.

amazon_puller.php
PHP Code:
<?php

$ads 
= array();
    
    if (
$handle opendir("$path_ads/$folder")) 
{
    while (
false !== ($file readdir($handle))) 
    {
       if (
$file != "." && $file != ".."
       { 
       
//echo "$file<br>";
        
array_push($ads"$file");
        }
    }
    
closedir($handle);
}
srand((float) microtime() * 10000000);
//print_r($ads);

$rand_keys array_rand($ads2);

$ad_show $ads[$rand_keys[0]];
echo 
file_get_contents("$path_ads/$folder/$ad_show");
echo 
'<br>';
?>
The ads is called like so:
PHP Code:
<?php
$folder
='amazon_books';
include(
"$path_includes/amazon_puller.php");a?>
this is the CSS used to center that ads, just ad it to your css file. If you use iframes elsewhere in your site just turn the code into a pseudo class(iframe.ads) and use it as class=ads inside the iframe.

Code:
iframe {
    display: block;
    margin-left: auto;
    margin-right: auto 
}

Of course you will have to pull paths from your own config file or hard code them into the script. The nice thing is by using the $folder var in the call you can use the same script to serve whatever ad(s) you want on whatever page(s). It is also trivial to hack it so it displays more than one ads.

If you try using it and run into problems just yell and I'll point you in the right direction.

Enjoy,

.


Ronnie Gauthier
www.instaguide.com

======================
for official page-zone support please visit
www.page-zone.com/support.shtml
   
Reply With Quote
Old
  (#2 (permalink))
Jim
of Page-Zone
Jim will become famous soon enoughJim will become famous soon enough
 
Status: Offline
Posts: 1,130
Join Date: Jun 2002
Location: Wauseon, Ohio
Rep Power: 96
My location
06-29-2008, 11:37 PM

Thanks for that, hopefully it comes in handy for someone.


--
Thank You,
Jim Snape
Page-Zone
--
   
Reply With Quote
Old
  (#3 (permalink))
midwest
blink and it's over
midwest will become famous soon enough
 
midwest's Avatar
 
Status: Offline
Posts: 803
Join Date: Oct 2002
Location: Big Sky, MT
Rep Power: 76
06-30-2008, 02:33 PM

You're welcome!

Maybe it will make someone a few bucks.

I have all sorts of little mini-scripts I've made. Things like menu generators and image rotating.

.


Ronnie Gauthier
www.instaguide.com

======================
for official page-zone support please visit
www.page-zone.com/support.shtml
   
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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
Trackbacks are On
Pingbacks are On
Refbacks are On


Live Help



Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC6
vBulletin Skin developed by: vBStyles.com
Copyright © 2002 Page-Zone Web Hosting. All rights reserved.
Smilies provided by Crack's Smilies http://www.mysmilies.com