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

