Source for file mod_random_image.php

Documentation is available at mod_random_image.php

  1. <?php
  2. /**
  3. @package Mambo
  4. @author Mambo Foundation Inc see README.php
  5. @copyright Mambo Foundation Inc.
  6. *  See COPYRIGHT.php for copyright notices and details.
  7. @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see
  8. *  LICENSE.php
  9. *  Mambo is free software; you can redistribute it and/or
  10. *  modify it under the terms of the GNU General Public License
  11. *  as published by the Free Software Foundation; version 2 of the
  12. *  License.
  13. */
  14.  
  15. /** ensure this file is being included by a parent file */
  16. defined'_VALID_MOS' or die'Direct Access to this location is not allowed.' );
  17.  
  18. global $mosConfig_absolute_path$mosConfig_live_site;
  19.  
  20. $type     $params->get'type''jpg' );
  21. $folder $params->get'folder' );
  22. $link     $params->get'link' );
  23. $width     $params->get'width' );
  24. $height $params->get'height' );
  25. $moduleclass_sfx $params->get'moduleclass_sfx' );
  26.  
  27. $abspath_folder $mosConfig_absolute_path .'/'$folder;
  28. $the_array array();
  29. $the_image array();
  30.  
  31. if (is_dir($abspath_folder)) {
  32.     if ($handle opendir($abspath_folder)) {
  33.         while (false !== ($file readdir($handle))) {
  34.             if ($file != '.' && $file != '..' && $file != 'CVS' && $file != 'index.html' {
  35.                 $the_array[$file;
  36.             }
  37.         }
  38.     }
  39.     closedir($handle);
  40.  
  41.     foreach ($the_array as $img{
  42.         if (!is_dir($abspath_folder .'/'$img)) {
  43.             if (eregi($type$img)) {
  44.                 $the_image[$img;
  45.             }
  46.         }
  47.     }
  48.  
  49.     if (!$the_image{
  50.         echo 'No images';
  51.     else {
  52.  
  53.       $i count($the_image);
  54.       $random mt_rand(0$i 1);
  55.       $image_name $the_image[$random];
  56.  
  57.       $i $abspath_folder '/'$image_name;
  58.       $size getimagesize ($i);
  59.  
  60.       if ($width == ''{
  61.           $width 100;
  62.       }
  63.       if ($height == ''{
  64.           $coeff $size[0]/$size[1];
  65.           $height = (int) ($width/$coeff);
  66.       }
  67.  
  68.       $image $mosConfig_live_site .'/'$folder .'/'$image_name;
  69.      
  70.        if ($link{
  71.           echo "<a href=\"" $link "\" target=\"_self\">\n";
  72.       }
  73.  
  74.     }
  75.       ?>
  76.      <div align="center">     
  77.      <?php 
  78.       if ($link{
  79.           ?>
  80.           <a href="<?php echo $link?>" target="_self">
  81.           <?php
  82.       }
  83.       ?>
  84.      <img src="<?php echo $image?>" border="0" width="<?php echo $width?>" height="<?php echo $height?>" alt="<?php echo $image_name?>" /><br />
  85.      <?php 
  86.       if ($link{
  87.           ?>
  88.           </a>
  89.           <?php
  90.       }
  91.       ?>
  92.      </div>
  93.       <?php
  94. }
  95. ?>

Documentation generated on Mon, 05 May 2008 16:21:22 +0400 by phpDocumentor 1.4.0