Re: AdRotator for PHP?

From: Date: Thu, 04 Jul 2002 16:37:28 +0000
Subject: Re: AdRotator for PHP?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-105470@lists.php.net to get a copy of this message
> I'm wondering if anyone has found or ended up > writing something similar to > the MSWC AdRotator object in ASP, but for PHP? Or > is there already a module > on apache.org that I missed? (Figre I should pull my weight on this list here.) Hmm. Not sure exactly what MSWC AdRotator is, but here's one I developed. Is it what you want? It checks a specific directory and grabs a random file from that directory, then displays it. if($file = GetRandomPicture($BannerAdsDirectory)) { $seriescode = substr($file, 0, 2); print(" <A HREF = \"URL.html\"><IMG SRC = \"$BannerDirectory/$file\" WIDTH = \"$banneradswidth\" HEIGHT = \"$banneradsheight\" BORDER = \"0\"></A>\n"); } function GetRandomPicture($sourcedirectory) { if($directory = @opendir($sourcedirectory)) { while($file = @readdir($directory)) { if(($file != ".") && ($file != "..")) $files[count($files)] = $file; } $randomfile = rand(0, count($files) - 1); $returnvalue = $files[$randomfile]; } else { $returnvalue = NULL; } return $returnvalue; } If anyone can improve on it, let me know. Thanks to the two guys who posted the links, though. I'll be sure to check them out once I get a couple of minutes of free time. Liam __________________________________________________ Do You Yahoo!? Sign up for SBC Yahoo! Dial - First Month Free http://sbc.yahoo.com

« previous php.general (#105470) next »