Annotation of /mambo/branches/4.6/modules/mod_random_image.php
Parent Directory
|
Revision Log
Revision 941 - (view) (download)
| 1 : | root | 1 | <?php |
| 2 : | /** | ||
| 3 : | csouza | 297 | * @package Mambo Open Source |
| 4 : | cauld | 941 | * @copyright (C) 2005 - 2007 Mambo Foundation Inc. |
| 5 : | root | 1 | * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL |
| 6 : | csouza | 297 | * |
| 7 : | * Mambo was originally developed by Miro (www.miro.com.au) in 2000. Miro assigned the copyright in Mambo to The Mambo Foundation in 2005 to ensure | ||
| 8 : | * that Mambo remained free Open Source software owned and managed by the community. | ||
| 9 : | root | 1 | * Mambo is Free Software |
| 10 : | */ | ||
| 11 : | |||
| 12 : | /** ensure this file is being included by a parent file */ | ||
| 13 : | defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' ); | ||
| 14 : | |||
| 15 : | global $mosConfig_absolute_path, $mosConfig_live_site; | ||
| 16 : | |||
| 17 : | $type = $params->get( 'type', 'jpg' ); | ||
| 18 : | $folder = $params->get( 'folder' ); | ||
| 19 : | $link = $params->get( 'link' ); | ||
| 20 : | $width = $params->get( 'width' ); | ||
| 21 : | $height = $params->get( 'height' ); | ||
| 22 : | $moduleclass_sfx = $params->get( 'moduleclass_sfx' ); | ||
| 23 : | |||
| 24 : | $abspath_folder = $mosConfig_absolute_path .'/'. $folder; | ||
| 25 : | $the_array = array(); | ||
| 26 : | $the_image = array(); | ||
| 27 : | |||
| 28 : | if (is_dir($abspath_folder)) { | ||
| 29 : | if ($handle = opendir($abspath_folder)) { | ||
| 30 : | while (false !== ($file = readdir($handle))) { | ||
| 31 : | if ($file != '.' && $file != '..' && $file != 'CVS' && $file != 'index.html' ) { | ||
| 32 : | $the_array[] = $file; | ||
| 33 : | } | ||
| 34 : | } | ||
| 35 : | } | ||
| 36 : | closedir($handle); | ||
| 37 : | |||
| 38 : | foreach ($the_array as $img) { | ||
| 39 : | if (!is_dir($abspath_folder .'/'. $img)) { | ||
| 40 : | if (eregi($type, $img)) { | ||
| 41 : | $the_image[] = $img; | ||
| 42 : | } | ||
| 43 : | } | ||
| 44 : | } | ||
| 45 : | |||
| 46 : | if (!$the_image) { | ||
| 47 : | echo 'No images'; | ||
| 48 : | } else { | ||
| 49 : | |||
| 50 : | $i = count($the_image); | ||
| 51 : | $random = mt_rand(0, $i - 1); | ||
| 52 : | $image_name = $the_image[$random]; | ||
| 53 : | |||
| 54 : | $i = $abspath_folder . '/'. $image_name; | ||
| 55 : | $size = getimagesize ($i); | ||
| 56 : | |||
| 57 : | if ($width == '') { | ||
| 58 : | $width = 100; | ||
| 59 : | } | ||
| 60 : | if ($height == '') { | ||
| 61 : | $coeff = $size[0]/$size[1]; | ||
| 62 : | $height = (int) ($width/$coeff); | ||
| 63 : | } | ||
| 64 : | |||
| 65 : | $image = $mosConfig_live_site .'/'. $folder .'/'. $image_name; | ||
| 66 : | |||
| 67 : | if ($link) { | ||
| 68 : | echo "<a href=\"" . $link . "\" target=\"_self\">\n"; | ||
| 69 : | } | ||
| 70 : | |||
| 71 : | } | ||
| 72 : | ?> | ||
| 73 : | <div align="center"> | ||
| 74 : | <?php | ||
| 75 : | if ($link) { | ||
| 76 : | ?> | ||
| 77 : | <a href="<?php echo $link; ?>" target="_self"> | ||
| 78 : | <?php | ||
| 79 : | } | ||
| 80 : | ?> | ||
| 81 : | <img src="<?php echo $image; ?>" border="0" width="<?php echo $width; ?>" height="<?php echo $height; ?>" alt="<?php echo $image_name; ?>" /><br /> | ||
| 82 : | <?php | ||
| 83 : | if ($link) { | ||
| 84 : | ?> | ||
| 85 : | </a> | ||
| 86 : | <?php | ||
| 87 : | } | ||
| 88 : | ?> | ||
| 89 : | </div> | ||
| 90 : | <?php | ||
| 91 : | } | ||
| 92 : | ?> |
| ViewVC Help | |
| Powered by ViewVC 1.0.0 |
Web Hosting provided by Network Redux.

