• Downloading from our site will require you to have a paid membership. Upgrade to a Premium Membership from 10$ a month today!

    Dont forget read our Rules! Also anyone caught Sharing this content will be banned. By using this site you are agreeing to our rules so read them. Saying I did not know is simply not an excuse! You have been warned.

Random Logo/Image Rotator

Admin

Well-Known Member
Staff member
Administrator
Something like this could already be here but I figured someone might have a use for it. A simple php file to randomly rotate images. I use it to rotate my logos. I've only uses it on 4.2.1 but it should work on all versions of VB as its worked on everything from nuke to wordpress so far.

INSTRUCTIONS
1. Modify the $folder setting in the configuration section.
2. Add image types if needed (most users can ignore that part).
3. Upload this file (rotate.php) to your webserver. I recommend uploading it to the same folder as the images you are going to use. images/rotate/rotate.php.
4.Edit your style by adding to where your logo image is called. In the default style its in
the header template <img src="http://examples.com/images/rotate/rotate.php" alt="{vb:rawphrase x_powered_by_vbulletin, {vb:raw vboptions.bbtitle}}" /> Other styles might be in a different template. One I have its in navbar.
5. You can also specify a single image to display like this:

<img src="http://example.com/rotate.php?img=gorilla.jpg">

This would specify that an image named "gorilla.jpg" located
in the image-rotation folder should be displayed.

PHP:
<?php

/*

AUTOMATIC IMAGE ROTATOR
Version 2.2 - December 4, 2003
	Copyright (c) 2002-2003 Dan P. Benjamin, Automatic, Ltd.
	All Rights Reserved.


/* ------------------------- CONFIGURATION -----------------------


	Set $folder to the full path to the location of your images.
	For example: $folder = '/user/me/example.com/images/';
	If the rotate.php file will be in the same folder as your
	images then you should leave it set to $folder = '.';

*/


	$folder = '.';


/*	

	Most users can safely ignore this part.  If you're a programmer,
	keep reading, if not, you're done.  Go get some coffee.

    If you'd like to enable additional image types other than
	gif, jpg, and png, add a duplicate line to the section below
	for the new image type.
	
	Add the new file-type, single-quoted, inside brackets.
	
	Add the mime-type to be sent to the browser, also single-quoted,
	after the equal sign.
	
	For example:
	
	PDF Files:

		$extList['pdf'] = 'application/pdf';
	
    CSS Files:

        $extList['css'] = 'text/css';

    You can even serve up random HTML files:

	    $extList['html'] = 'text/html';
	    $extList['htm'] = 'text/html';

    Just be sure your mime-type definition is correct!

*/

    $extList = array();
	$extList['gif'] = 'image/gif';
	$extList['jpg'] = 'image/jpeg';
	$extList['jpeg'] = 'image/jpeg';
	$extList['png'] = 'image/png';
	

// You don't need to edit anything after this point.


// --------------------- END CONFIGURATION -----------------------

$img = null;

if (substr($folder,-1) != '/') {
	$folder = $folder.'/';
}

if (isset($_GET['img'])) {
	$imageInfo = pathinfo($_GET['img']);
	if (
	    isset( $extList[ strtolower( $imageInfo['extension'] ) ] ) &&
        file_exists( $folder.$imageInfo['basename'] )
    ) {
		$img = $folder.$imageInfo['basename'];
	}
} else {
	$fileList = array();
	$handle = opendir($folder);
	while ( false !== ( $file = readdir($handle) ) ) {
		$file_info = pathinfo($file);
		if (
		    isset( $extList[ strtolower( $file_info['extension'] ) ] )
		) {
			$fileList[] = $file;
		}
	}
	closedir($handle);

	if (count($fileList) > 0) {
		$imageNumber = time() % count($fileList);
		$img = $folder.$fileList[$imageNumber];
	}
}

if ($img!=null) {
	$imageInfo = pathinfo($img);
	$contentType = 'Content-type: '.$extList[ $imageInfo['extension'] ];
	header ($contentType);
	readfile($img);
} else {
	if ( function_exists('imagecreate') ) {
		header ("Content-type: image/png");
		$im = @imagecreate (100, 100)
		    or die ("Cannot initialize new GD image stream");
		$background_color = imagecolorallocate ($im, 255, 255, 255);
		$text_color = imagecolorallocate ($im, 0,0,0);
		imagestring ($im, 2, 5, 5,  "IMAGE ERROR", $text_color);
		imagepng ($im);
		imagedestroy($im);
	}
}

?>

Name the php file whatever you want and change the call name to that file.
 

Facebook Comments

Similar threads
Thread starter Title Forum Replies Date
B Mod random logo Johncms 0
Admin Xenforo 2 - Random Ads Code Xenforo 0
Admin Yilmaz - Random Images in Header vB5 Add-ons 0
Admin Random Smilies by BOP5 (for VB 3.x & 4.x) Add-ons 0
Admin Tạo số ngẫu nhiên trong C# - Random Number in C#, Be careful of some of the samples you find C# / C++ 1
Admin Code php random quảng cáo PHP 0
Cuongkoj00 Share Code random Giao diện cho Johncms Johncms 0
V Random Side Banners Outside Main Body in FixedPosition Vbulletin 0
Admin Random Album Picture cho vbb4 Add-ons 0
Admin Script random hiển thị ảnh ngẫu nhiên Javascript/ajax 0
Admin Share code php random game hot Mã nguồn wap 0
S Share Script random image+link+text Mã nguồn wap 0
Q [Share] code random Mã nguồn wap 4
Lang Tu Sau [Share] code random ảnh Html khi load trang Wap builder, wapego, xtgem, wen.ru, wapka, wap4 4
Admin [Share] random ảnh sau khi reload trang Mã nguồn web 6
Admin Cách tạo logo Thiết kế đồ họa 0
V Hướng dẫn tạo logo giống Xenforo Xenforo 4
lancan Chia sẻ cách tải video tiktok không có logo Thảo luận chung 0
Admin [OzzModz] Text Logo Xenforo 0
C Hỏi Cần ae cho xin plugins tự chèn logo Wordpress 4
Admin Share psd logo upanh.tuoitreit.vn Thiết kế đồ họa 0
khanhsak3r [Nhờ]Thiết kế logo watermark như của upanh.tuoitreit.vn Thiết kế đồ họa 9
L chọn phông chữ viết có dấu trong window logo Tin tức CNTT 0
L Nhờ làm logo Thảo luận wap việt 1
Emvip Help ai giúp em làm logo xenforo với ạ Xenforo 5
congtukinhloai EximiousSoft Logo Designer 3.85 + Portable Phần mềm 0
S Nhận Làm Logo Có Demo Cho 8 Bạn Nhanh Thiết kế đồ họa 5
L0ngHackit Admin tạo giùm cái logo wap Thiết kế đồ họa 5
A Hỏi [Logo wap] Ai giúp em cái logo wap với ạ Thiết kế đồ họa 2
K Admin Tạo Giúp Cái Logo Với Máy tính 9
V Hỏi Ai có thể làm giúp em cái logo cho wap được không? Thiết kế đồ họa 6
N Ai biết photoshop giúp mình tạo logo , ảnh bìa , avatar chuyên về karaoke Thiết kế đồ họa 13
khanhsak3r Admin làm dùm cái logo wap ạ Thiết kế đồ họa 6
L0ngHackit Nhờ tạo giùm cái logo Thiết kế đồ họa 1
Lee_Jin Admin làm giúp em logo con dấu với ạ Thảo luận wap việt 4
L0ngHackit Admin tạo giùm logo với Thiết kế đồ họa 8
M Nhờ các bạn và anh Thắng tạo logo Thiết kế đồ họa 9
N Masstel M220 treo logo flash ok Thủ thuật ĐTDĐ 1
cuken [vote] logo android Hình ảnh 10
mày.hả.bưởi Share làm logo cho anh em trong 2 ngày All Shared Scripts 12
K Share psd logo lá cây Thiết kế đồ họa 1
tubotocdo Share Code đóng dấu bản quyền logo vào java online Ver2 Mã nguồn wap 0
Yeukodamnoi Giúp mình làm logo đóng dấu vào ảnh cho wap với Thiết kế đồ họa 3
Tuzoro Share Code PHP đóng dấu ảnh logo vào Java All Shared Scripts 0
tubotocdo Share code đóng dấu logo bản quyền vào java online Mã nguồn wap 3
Admin Hướng dẫn gõ tiếng việt trên AAA Logo Sử dụng, chia sẻ, hỏi đáp 0
Admin Site Logo Image re-size Vbb tutorial 0
Admin Ứng dụng Dropbox trên iOS có giao diện và logo mới, hỗ trợ chia sẻ link qua AirDrop Android, iOS 0
A Share Code PHP Tạo Logo "Angry Birds" By Nguyên Ary Mã nguồn wap 1
N Miễn phí đăng tin quảng cáo, rao vặt, đặt logo, mua bán bất động sản... Trò chuyện linh tinh 3

Similar threads

New posts New threads New resources

Back
Top