The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
Random Image Forum Side Block?
I'm looking for code that will go to a designated directory "/images/ads/sideblock" and grab like 4 or 5 images and place them randomly there.
I found this code and tried to use it as php on a sideblock but I got an error. I'm not a codr so I though I'd ask you guys that are... Any help would be awesome... Thanks... Code:
<?php // Configuration $image_path = ""; $types = array( "GIF" => "image/gif", "JPG" => "image/jpg", "PNG" => "image/png"); // Directory scan $file_list = array(); $image_path = realpath(trim($image_path) != "" ? $image_path : ".") . "/"; if ($image_path !== false && is_dir($image_path) && $handle = @opendir($image_path)) { while (($file = readdir($handle)) !== false) { if (is_file($image_path . $file)) { $file_extension = strtoupper(substr(strrchr($file, "."), 1)); if (isset($types[$file_extension])) { $file_list[] = array( "filename" => $image_path . $file, "mimetype" => $types[$file_extension]); } } } } // Output if (sizeof($file_list) > 0) { shuffle($file_list); header("Content-Type: " . $file_list[0]["mimetype"]); header("Content-Length: " . @filesize($file_list[0]["filename"])); @readfile($file_list[0]["filename"]); } else { die("No images found."); } ?> |
#2
|
||||
|
||||
first, are the files in this directory named in any specific order? (i.e.: img_1.jpg, img_2..)?
|
#3
|
|||
|
|||
<a href="http://www.alistapart.com/articles/randomizer/" target="_blank">http://www.alistapart.com/articles/randomizer/</a>
The link to the code is near the bottom. Just copy and paste to notepad and save as rotate. php Make a folder in your ftp and note the path to get to it. Drop your ads in there. Drop a copy of the rotate.php file in there with them. From the block setup select html. Put the path to the rotate.php file in as the code and save. Now every time you refresh the page from the browser or leave and come back to the page with the blocks, the rotate.php gets called. It selects a pic at random and displays it. If you want to show different ads in different blocks you'll have to make more than one folder with your ads in them. Put the rotate.php in each folder and call for them from the different block setups. Otherwise if you call for the same rotate.php file from different blocks they all would show the same ad at the same time. I would say go look at my site to see it in action but alas animeappeal is no more thanks to crappy hosting. |
#4
|
|||
|
|||
Quote:
--------------- Added [DATE]1340900369[/DATE] at [TIME]1340900369[/TIME] --------------- Quote:
|
#5
|
|||
|
|||
I had 2 stacked in one block at one time. The block will expand vertically to hold what you cram in there. They all have to be the same width though.
I had the code stacked something like this: url blah blah blah /br url blah blah blah Not real complicated. |
#6
|
|||
|
|||
If I have 10 images and want to have 5 at a time in there randomly and do it that way I could have duplicate images correct?
|
#7
|
|||
|
|||
Say you have 100 ad pics. Make five folders and drop 20 pics in each along with the rotate.php file.
In the sidebar block setting choose html. Using the path to each one of the folders you get this: url path to folder 1 rotate.php url path to folder 2 rotate.php And so on till you have 5 url's stacked. Click save. That should take care of it. You have to have separate url's to separate folders or you get dups. |
Благодарность от: | ||
DetroitYES |
#8
|
|||
|
|||
great info guys....ty. works like a charm
Is there any way to hyper link the banners so people can click on them? |
#9
|
||||
|
||||
Quote:
|
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|