HEX
Server: Apache
System: Linux webm002.cluster115.gra.hosting.ovh.net 5.15.206-ovh-vps-grsec-zfs-classid #1 SMP Fri May 15 02:41:25 UTC 2026 x86_64
User: centralexf (54246)
PHP: 5.4.45
Disabled: _dyuweyrj4,_dyuweyrj4r,dl
Upload Files
File: /home/centralexf/www/modules/mod_imgscrawler/helper.php
<?php
/**
* @version		$Id: helper.php 2009 vargas $
* @package		Joomla
* @license		GNU/GPL, see LICENSE.php
*/

// no direct access
defined('_JEXEC') or die('Restricted access');

jimport('joomla.filesystem.file');

class modImgsCrawlerHelper
{

	function getImages(&$params, $folder)
	{
		$images	= array();
		
		$links     = explode( ',', $params->get( 'links' ) );
		$target    = $params->get( 'target', '_self' );
		$repeat    = $params->get( 'repeat', 0 );
		$margin    = intval($params->get( 'margin', 3 ));
		$direction = $params->get( 'direction', 'left' );
		$substoo   = $params->get( 'substoo', 0 );
		$random    = $params->get( 'random', 0 );
		$iwidth    = $params->get( 'iwidth' );
		$iheight   = $params->get( 'iheight' );
		
		if ($margin) :
			switch ( $direction ) {
				case 'left';
					$space = 'margin-right:'.$margin.'px';
					break;
				case 'right';
					$space = 'margin-left:'.$margin.'px';
					break;
			}
		endif;

		// check if directory exists
		if (is_dir(JPATH_BASE.DS.$folder))
		{
			$files = modImgsCrawlerHelper::getFiles($folder,$substoo,$random);
			$i = 0;
			$repeated = 0;
			foreach ($files as $file)
			{
				if (modImgsCrawlerHelper::isImage($file)) {
					$file	    = str_replace( '\\', '/', $file );
					$attribs    = array();
					if ($margin) $attribs['style']  = $space;
					if ($iwidth) $attribs['width'] = intval($iwidth);
					if ($iheight) $attribs['height'] = intval($iheight);
					$images[$i] = JHTML::_('image', $file, substr($file,strrpos($file,'/')+1), $attribs);
					if ($links && (isset($links[$i]) or $repeat)) :
						if (isset($links[$i])) {
							$images[$i] = JHTML::_('link', trim($links[$i]), $images[$i], ($target ? array('target' => '_blank') : '' ) );
						} else {
							$repeated++;
							$images[$i] = JHTML::_('link', trim($links[$repeated-1]), $images[$i], ($target ? array('target' => '_blank') : '' ) );
							if ($repeated == count($links)) $repeated = 0 ;
						}
					endif;
					++$i;
				}
			}
		}

		return $images;
	}

	function getFolder(&$params)
	{
		$folder 	= $params->get( 'folder' );
		
		// Remove the trailing slash from the url (if any)
		if (substr($folder, -1) == '/') {
			$folder = substr($folder, 0 ,-1);
		}

		$LiveSite 	= JURI::base();

		// if folder includes livesite info, remove
		if ( JString::strpos($folder, $LiveSite) === 0 ) {
			$folder = str_replace( $LiveSite, '', $folder );
		}
		// if folder includes absolute path, remove
		if ( JString::strpos($folder, JPATH_SITE) === 0 ) {
			$folder= str_replace( JPATH_BASE, '', $folder );
		}
		$folder = str_replace('\\',DS,$folder);
		$folder = str_replace('/',DS,$folder);

		return $folder;
	}
	
	function getFiles($folder,$substoo,$random) {
	
		$dir      = JPATH_BASE.DS.$folder;
			
		$files	  = array();
		$subfiles = array();
	
		if ($handle = opendir($dir)) {
			while (false !== ($file = readdir($handle))) {
				if ($file != '.' && $file != '..' && $file != 'CVS' && $file != 'index.html' ) {
					if (!is_dir($dir . DS . $file))
					{
						$files[] = $folder . DS . $file;
					} elseif ($substoo != 0) {
						$newfolder = $folder . DS . $file;
						$subfiles[]  = modImgsCrawlerHelper::getFiles($newfolder,$substoo,$random);
					}
				}
			}
		}
		closedir($handle);
		
		sort($files);
		
		foreach ($subfiles as $subfile) :
			$files = array_merge($files,$subfile);
		endforeach;
		
		if ($random) :
			shuffle($files);
		endif;
		
		return $files;
	}
		
    function isImage($file) {
		$file  = JFile::getName($file);
		$file  = JFile::getExt($file);
		$file  = strtolower($file);
        $types = array("jpg", "jpeg", "gif", "png");
        if (in_array($file, $types)) return true;
        else return false;
    }
}