The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
Random Image with Date/Time Support Details »» | |||||||||||||||||||||||||
Well it is about time I got around to contributing something back to the vb.org modification library. So here is a simple start and a simple mod. In fact it is not really a mod at all and could be used on any site however this was written to manage logos in my vBulletin header.
What we have here is a randomimage script.... Now hold your horses, this isn't any ordinary random image script. This one allows you to specify dates/times that an should be displayed at. The script can be configured with as many images as you like, then when called it returns back as an image type (similar to how vBulletins attachment.php) works. Anybody who is familiar with cron will see the influence behind the image display scheduling, however you do not need to know anything about cron to use this script. What will help though is at least a basic knowledge of PHP. The chances are if you are into modding your forum, you will know enough. To use the script all you need to do is:
While that is all fairly simple configuration does need a little explanation: Each image is configured (at the top of the script) as follows: Code:
//path to the image from web root $image[0]["FilePath"] = "SkunkWorks/randomimage/0.jpg"; //The content type for the image, typical this //will be "image/[extension]" for example "image/jpg", //"image/gif", "image/png" $image[0]["ContentType"] = "image/jpg"; //The minute at which this image can be displayed, for example "1,5,10". You can //also merge ranges as well, for example "1,5,10-15" is equivalent to //"1,5,10,11,12,13,14,15". Anything outside 0 to 59 is ignored. $image[0]["DisplayMinute"] = "*"; //The hours at which this image can be display, the rule logic is the same as //DisplayMinute (anything outside 0 to 23 is ignored) $image[0]["DisplayHour"] = "*"; //The months days in which this image can be display, the rule logic is the same as //DisplayMinute (anything outside 1 to 31 is ignored) $image[0]["DisplayMonthDay"] = "*"; //The months in which this image can be display, the rule logic is the same as //DisplayMinute (anything outside 1 to 31 is ignored) $image[0]["DisplayMonth"] = "*"; //The weekdays in which this image can be display, the rule logic is the same as //DisplayMinute (anything outside 1 to 7 is ignored (1 is monday)) $image[0]["DisplayWeekDay"] = "*"; The same applies to all other time control rules. So to give a few real examples: Code:
$image[1]["DisplayMinute"] = "12"; $image[1]["DisplayHour"] = "*"; $image[1]["DisplayMonthDay"] = "*"; $image[1]["DisplayMonth"] = "*"; $image[1]["DisplayWeekDay"] = "*"; Code:
$image[1]["DisplayMinute"] = "*"; $image[1]["DisplayHour"] = "*"; $image[1]["DisplayMonthDay"] = "*"; $image[1]["DisplayMonth"] = "*"; $image[1]["DisplayWeekDay"] = "1"; Code:
$image[1]["DisplayMinute"] = "*"; $image[1]["DisplayHour"] = "20-23"; $image[1]["DisplayMonthDay"] = "*"; $image[1]["DisplayMonth"] = "1"; $image[1]["DisplayWeekDay"] = "1,2"; Code:
$image[1]["DisplayMinute"] = "*"; $image[1]["DisplayHour"] = "*"; $image[1]["DisplayMonthDay"] = "25"; $image[1]["DisplayMonth"] = "12"; $image[1]["DisplayWeekDay"] = "*"; In addition to these configuration options you can also set a script based time offset (just incase your server is hosted in a different timezone to your users). However this script variable can be overidden by passing a query string parameter, "tos=-5" for example. http://mydomain/somewhere/randomimage.php?tos=-5 You can also tell the script to only use certain images from your configuration (still dependent on date/times unless you pass the no date check query string parameter (see below)). For example http://mydomain/somewhere/randomimage.php?iid=1 http://mydomain/somewhere/randomimage.php?iid=1,2,3 http://mydomain/somewhere/randomimage.php?iid=1,5 http://mydomain/somewhere/randomimage.php?iid=1,5&nod The last url will display image 1 or 5 regardless of date/time configuration There is also a "default" image option, if after checking all your configured images the script has not been able to find an image that meets date/time requirements the default image will be displayed instead. There is nothing to stop you from using the default image as one of the configured timed images as well. You can also run the script in debug mode. This is useful to find out exactly what the script is doing. Obviously do not run in debug mode while this is emdedded in your page. To do this simple pass the debug key: http://mydomain/somewhere/randomimage.php?debug=1234 The debug key is part of the configuration, I would recommend changing this to something else, as this will prevent people from running your script in debug mode and finding images/logos that you would rather they didn't see. Finally and probably most importantly you need to be careful with paths. Each configured image has "FilePath" value this should be the path from your web servers root directory. You then have the "$pathToWebRoot" configuration item which is the path from the server root to the web root. If you have any problems with it, please try running in debug mode. If the problem is obvious from that then copy the debug output into a post here. You can see all this running on the following URL: http://4d52.net/SkunkWorks/randomimage/randomimage.php Image number 3 is configured with the following display rule: Code:
$image[3]["DisplayMinute"] = "1-10,20-30,40-50"; $image[3]["DisplayHour"] = "*"; $image[3]["DisplayMonthDay"] = "*"; $image[3]["DisplayMonth"] = "*"; $image[3]["DisplayWeekDay"] = "*"; http://4d52.net/SkunkWorks/randomima...mimage.php?nod You will randomly see one of all the images as no date checks will be performed. If you use the following querystring that specifies and image id that doesn't exist you will see the default image http://4d52.net/SkunkWorks/randomima...age.php?iid=42 Or if you use the following query string to display image ID 1: http://4d52.net/SkunkWorks/randomima...mage.php?iid=1 However unless you run this at 12 minutes past the hour you will get the default image as image 1 is configured to only display at this minute for every day. You could of course bypass the date/time check with this querystring http://4d52.net/SkunkWorks/randomima....php?iid=1&nod Debug output can be seen here: http://4d52.net/SkunkWorks/randomima...php?debug=1234 or by adding "debug=1234" to any of the other URLs above The attached file contains the script and also a few test images for you to play with. p.s. feel free to rip this mod to pieces and use wherever you like, however it would be nice to know where it is being used p.p.s. This has been added to 3.7 however it is not version dependant, it will work anywhere p.p.p.s If there is sufficient interest (which is unlikely) I might convert this into a "real" mod that can be controlled through ACP Show Your Support
|
Comments |
#12
|
|||
|
|||
Hello,
How can i put pictures of this mod in cache ? They are reloaded every clic. Sorry for my english. Thank you. |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|