Simple File Lister дублирует имя подкаталога при скачивании

Этот форум предназначен для общих вопросов относительно расширений Joomla! 3.x

Moderator: AlexSmirnov

Forum rules
Post Reply
Deir
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Thu Feb 18, 2021 3:57 pm

Simple File Lister дублирует имя подкаталога при скачивании

Post by Deir » Thu Feb 18, 2021 4:13 pm

Здравствуйте! В общем использую компонент Simple File Lister для вывода файлов из директории в материал, устраивает своей простотой, но столкнулся с такой проблемой при скачивании файла из подкаталога, дублируется имя этого подкаталога в пути, что разумеется приводит к ошибке "404 Page Not Found", если вручную убрать дубль в адресной строке, то файл скачивается. В родительском каталоге файлы скачиваются без проблем.

Возможно нужно что то поправить в mod_simplefilelisterv1.0.php (но вот что :) )

Code: Select all

<?php
/**
 * Simple File Lister Module Entry Point
 * 
 * @package    Joomla
 * @subpackage Modules
 * @author Anders Wasén
 * @link http://wasen.net/
 * @license		GNU/GPL, see LICENSE.php
 * mod_simplefileupload is free software. This version may have been modified pursuant
 * to the GNU General Public License, and as distributed it includes or
 * is derivative of works licensed under the GNU General Public License or
 * other free or open source software licenses.
 */
 
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );

$session =& JFactory::getSession();
$baseurl = "";

$sfl_version = "1.0";
$sfl_basepath = "modules/mod_simplefilelisterv".$sfl_version."/";

$sfl_dirlocation = $params->get( 'sfl_dirlocation', '.'.DIRECTORY_SEPARATOR.'images' );

$sfl_maxfiles = $params->get( 'sfl_maxfiles', '20' );
$sfl_bgcolor = $params->get( 'sfl_bgcolor', '#e8edf1' );
if ( substr( $sfl_bgcolor, 0, 1 ) !== "#" ) {
	$sfl_bgcolor = "#" . $sfl_bgcolor;
}
$sfl_maxheight = $params->get( 'sfl_maxheight', '0' );
$sfl_useusernameddir = $params->get( 'sfl_useusernameddir', '0' );
$sfl_usernameddirdefault = $params->get( 'sfl_usernameddirdefault', '0' );
$sfl_userlocation = $params->get( 'sfl_userlocation', '' );
if ( substr( $sfl_userlocation , strlen($sfl_userlocation) - 1) !== DIRECTORY_SEPARATOR ) {
  $sfl_userlocation .= DIRECTORY_SEPARATOR;
}
$sfl_boxleft = $params->get( 'sfl_boxleft', '-16' );
$sfl_allowdelete = $params->get( 'sfl_allowdelete', '0' );
$sfl_jquery = $params->get( 'sfl_jquery', '0' );
$sfl_jqueryinclude = $params->get( 'sfl_jqueryinclude', '0' );

// Get current logged in user
$user =& JFactory::getUser();
$usr_id = $user->get('id');
$usr_name = $user->get('username');
if(stripos($usr_name, "/") !== false) {
	$usr_name = "";
}
if(stripos($usr_name, "\\") !== false) {
	$usr_name = "";
}
if(stripos($usr_name, "..") !== false) {
	$usr_name = "";
}

if ($sfl_maxfiles > 0) {
	// Check if this is a new login
	if ($session->get( 'sfl_usrid', 0) !== $usr_id) {
		$session->set( 'sfl_nextindex', 0);
		$session->set( 'sfl_stopindex', $sfl_maxfiles);
	} else {

		if (isset($_GET["sflPrevious"])) {
			if (strlen($_GET["sflPrevious"]) > 0) {

				$idx_startat = $session->get( 'sfl_nextindex', 0);
				$idx_endat = $session->get( 'sfl_stopindex', $sfl_maxfiles);
				
				if ($idx_startat > 0 && $idx_endat > $sfl_maxfiles) {
					$idx_startat = $_GET["sflPrevious"] - $sfl_maxfiles;
					$idx_endat = $idx_startat + $sfl_maxfiles;
					
					$session->set( 'sfl_nextindex', $idx_startat);
					$session->set( 'sfl_stopindex', $idx_endat);
				}
			}
		}

	}

	$session->set( 'sfl_usrid', $usr_id);
}

if (!isset($_GET["sflPrevious"]) && !isset($_GET["sflNext"])) {
	
	// Neither next nor previous, must be reload from other link
	$session->set( 'sfl_nextindex', 0);
	$session->set( 'sfl_stopindex', $sfl_maxfiles);
	
}


if ($sfl_useusernameddir == 1) {

	// If only list users files clear default path
	if ($sfl_usernameddirdefault === '1' && strlen($sfl_userlocation) > 0) $sfl_dirlocation = '';

	if ($usr_id > 0 && strlen($sfl_userlocation) > 0) {	
		// Set user path, it already has the DIRECTORY_SEPARATOR at the end, don't add after usr_name.
		$sfl_userlocation .= $usr_name;
	} else {
		$sfl_userlocation = '';
	}
} else {
	$sfl_userlocation = '';
}
// Make ready for Ajax calls and avoid any whitespace
if (isset($_GET["sflaction"])) {
if(!class_exists('SFLAjaxServlet')) JLoader::register('SFLAjaxServlet' , dirname(__FILE__).DIRECTORY_SEPARATOR.'helper.php');
//Security check
if (isset($_GET["sflDir"])) {
	if (strlen($sfl_userlocation) == 0) $sfl_userlocation = "-";
	// Check that either default dir or user dir is present in the given dir. If not set it to default
	if (strpos($_GET["sflDir"], $sfl_dirlocation) === false && strpos($_GET["sflDir"], $sfl_userlocation) === false) {
		// Add warning txt?
	} else {
		$sfl_dirlocation = $_GET["sflDir"];
	}
}
if (strpos($sfl_dirlocation, "../") !== false) $sfl_dirlocation = $params->get( 'sfl_dirlocation', '.'.DIRECTORY_SEPARATOR.'images' );
if (strlen($sfl_dirlocation) == 0) $sfl_dirlocation = $sfl_userlocation;
$sfl_file = "";
$session->set( 'sfl_currentdir', $sfl_dirlocation);
if ($_GET["sflaction"] === "delete") $sfl_file = $_GET["sflDelete"];
if ($_GET["sflaction"] === "sort" && isset($_GET["sflSort"])) $session->set( 'sfl_sort', $_GET["sflSort"]);
echo SFLAjaxServlet::getContent($_GET["sflaction"], $params, $sfl_dirlocation, $sfl_basepath, $sfl_maxfiles, $sfl_userlocation, $sfl_file);
} else {

	// include the helper file
	require_once(dirname(__FILE__).DIRECTORY_SEPARATOR.'helper.php');
	$results = '';
	$results .= ModSimpleFileListerHelperv10::getFileList($params, $sfl_dirlocation, $sfl_basepath, $sfl_maxfiles, $sfl_userlocation);

	// include the template for display
	require(JModuleHelper::getLayoutPath('mod_simplefilelisterv'.$sfl_version));

}
?>
ЛИБО ЗДЕСЬ mod_simplefilelisterv1.0.xml

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<extension
	type="module"
	version="3.0.1"
	client="site"
	method="upgrade">
	<name>Simple File Lister v1.0 (for Joomla 3)</name>
	<author>Anders Wasen</author>
	<creationDate>January 2011</creationDate>
	<copyright>Copyright (C) 2011-2012 Anders Wasén. All rights reserved.</copyright>
	<license>http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL</license>
	<authorEmail>awasen@gmail.com</authorEmail>
	<authorUrl>wasen.net</authorUrl>
	<version>1.0</version>
	<description>A simple module that will list files from a directory set in the settings. Will allow a user to list the given directory fetched from the parameter settings.</description>
	<files>
		<filename module="mod_simplefilelisterv1.0">mod_simplefilelisterv1.0.php</filename>
		<filename>index.html</filename>
		<filename>helper.php</filename>
		<filename>mod_simplefilelister.css</filename>
		<filename>tmpl/index.html</filename>
		<filename>tmpl/default.php</filename>
		<filename>elements/donate.php</filename>
		<filename>elements/index.html</filename>
		<filename>images/index.html</filename>
		<filename>images/directory.png</filename>
		<filename>images/file.png</filename>
		<filename>images/ajax-loader.gif</filename>
		<filename>images/sort_down.png</filename>
		<filename>images/sort_up.png</filename>
		<filename>images/delete.png</filename>
	</files>
	<languages>
		<language tag="en-GB">en-GB.mod_simplefilelisterv1.0.ini</language>
		<language tag="sv-SV">sv-SV.mod_simplefilelisterv1.0.ini</language>
		<language tag="fr-FR">fr-FR.mod_simplefilelisterv1.0.ini</language>
		<language tag="pt-PT">pt-PT.mod_simplefilelisterv1.0.ini</language>
	</languages>
	<config>
		<fields name="params">
			<fieldset name="basic">
				<field name="sfl_dirlocation" type="text" default="./images/" label="Default Directory" description="This is a default directory that will be listed."/>
				<field name="sfl_basepath" type="text" default="" label="Web server base path (http://xyz...)" description="You need to add the baseurl for teh above directory, inluding the directory to use for creating the web-links. It must start with http/https or ftp. E.g. if your directory to list is ./images in your Joomla root this should be http://www.mysamplesite.com/images/"/>
				<field name="sfl_maxfiles" type="text" default="20" label="Max. files to list" description="This is the maximum allowed files to list. Set it to zero for no limit."/>
				<field name="sfl_next" type="radio" default="0" label="Use Next button" description="Add Next/Previous buttons if list exceeds Max. files to list.">
					<option value="0">No</option>
					<option value="1">Yes</option>
				</field>
				<field name="sfl_showfilesize" type="radio" default="0" label="Show file size" description="Will add teh filesize after the file name.">
					<option value="0">No</option>
					<option value="1">Yes</option>
				</field>
				<field name="sfl_maxheight" type="text" default="0" label="Max. box height (in pixels)" description="This is the maximum allowed height for the file list box in pixels. Set it to zero to let it grow."/>
				<field name="sfl_bgcolor" type="text" default="#e8edf1" label="Background color" description="The background color of the file list box."/>
				<field name="spacer01" type="spacer" default="" label="" description=""/>
				<field name="sfl_onlyimg" type="radio" default="0" label="List only images" description="List only images or all files in directory.">
					<option value="0">All</option>
					<option value="1">Images</option>
				</field>
				<field name="sfl_imgthumbs" type="radio" default="0" label="Use thumbnails" description="Use thumbnails for images. Select Only to not show file-name, only thumb-nail image.">
					<option value="0">No</option>
					<option value="1">Yes</option>
					<option value="2">Only</option>
				</field>
				<field name="sfl_thumbheight" type="text" default="30" label="Max. thumbnail height (in pixels)" description="This is the maximum allowed height for a thumbnail."/>
				<!--field name="sfl_thumbwidth" type="text" default="30" label="Max. thumbnail width (in pixels)" description="This is the maximum allowed width for a thumbnail."/-->
				<field name="sfl_thumbkeepaspect" type="radio" default="1" label="Keep aspect ratio of thumbnail" description="Use thumbnails in correct aspect ratio, else they will be resized into max. height/width.">
					<option value="0">No</option>
					<option value="1">Yes</option>
				</field>
				<field name="sfl_listdir" type="radio" default="0" label="List directories" description="Also list sub-directories ontop of the files.">
					<option value="0">No</option>
					<option value="1">Yes</option>
				</field>
				<field name="sfl_browsedir" type="radio" default="0" label="Browse sub-directory" description="Allow the user to enter sub-directories.">
					<option value="0">No</option>
					<option value="1">Yes</option>
				</field>
				<field name="spacer02" type="spacer" default="" label="" description=""/>
				<field name="sfl_useusernameddir" type="radio" default="0" label="Use user named directory" description="This will show the logged on users files instead of the default path given above.">
					<option value="0">No</option>
					<option value="1">Yes</option>
				</field>
				<field name="sfl_usernameddirdefault" type="radio" default="0" label="ONLY show user named directory" description="Will omit the default directory from directory list. Directory list will only contain the users own files, i.e. Default Directory above will never be used!.">
					<option value="0">No</option>
					<option value="1">Yes</option>
				</field>
				<field name="sfl_userlocation" type="text" default="./users/" label="User named directories root path" description="This is the directory where uploaded files for user specific files are placed (NB! Server path, not web URL). E.g. the user Anders files would be under ./users/Anders/."/>
				<field name="sfl_basepathusr" type="text" default="" label="Web server users path (http://xyz...)" description="If your Default User Directory lies outside of the Joomla web-root or you are using sub-domains you need to add the baseurl, inluding the directory to use for creating the web-links. It must start with http/https or ftp"/>
				<field name="spacer03" type="spacer" default="" label="" description=""/>
				<field name="" type="donate" default="" label="Do you like it?" description="Feel like showing your appreciation? Build: 1.0.2.0" addfieldpath="/modules/mod_simplefilelisterv1.0/elements"/>
			</fieldset>
		</fields>
		<fields name="params">
			<fieldset name="advanced">
				<field name="sfl_allowupdir" type="radio" default="0" label="Allow moving up in directories" description="This is NOT recommended! This will allow a user to add a path for moving backwards in directorystructure, beyond your Default Directory, using the AJAX query URL.">
					<option value="0">No</option>
					<option value="1">Yes</option>
				</field>
				<field name="sfl_allowdelete" type="radio" default="0" label="Allow delete files" description="This is NOT recommended! To allow delete of files you must enable this first.">
					<option value="0">No</option>
					<option value="1">Yes</option>
				</field>
				<field name="sfl_allowdeleteall" type="radio" default="0" label="Allow delete files for all" description="This is NOT recommended! It will allow any user (even not logged in) to delete files from the list.">
					<option value="0">No</option>
					<option value="1">Yes</option>
				</field>
				<field name="sfl_allowdeletereg" type="radio" default="0" label="Allow delete files for registered" description="This is NOT recommended! It will allow any registered user to delete files from the list.">
					<option value="0">No</option>
					<option value="1">Yes</option>
				</field>
				<field name="sfl_allowdeleteedt" type="radio" default="0" label="Allow delete files for editors" description="It will allow any user registered as editor to delete files from the list.">
					<option value="0">No</option>
					<option value="1">Yes</option>
				</field>
				<field name="sfl_movedeleted" type="radio" default="0" label="Move instead of delete" description="If you want to move files instead of deleting them to the directory below.">
					<option value="0">No</option>
					<option value="1">Yes</option>
				</field>
				<field name="sfl_movedeletedpath" type="text" default="./sfl_deletedfiles" label="Move to directory for deleted" description="If you want to move files instead of delete they will end up in this directory. If the directory does not exist it will be created. Files will get a unique file extension to not overwrite existing files."/>				
				<field name="sfl_disablegdthreshold" type="text" default="0" label="GD library size limit" description="This is the threshold (max size in bytes) for where GD library should not be used. Set to zero for no threshold."/>
				<field name="spacer04" type="spacer" default="" label="Cache handling" description=""/>
				<field name="cache" type="list" default="1" label="Joomla Cache" description="Here you can enable/disable Joomla caching">
					<option value="1">Use global</option>
					<option	value="0">No caching</option>
				</field>
				<field name="cache_time" type="text" default="900" label="Cache time" description="Cache time" />
				<field name="cachemode" type="hidden" default="itemid">
					<option value="itemid"></option>
				</field>
			</fieldset>
		</fields>
		<fields name="params">
			<fieldset name="other" label="Other Settings">
				<field name="sfl_showdir" type="radio" default="1" label="Show directory label" description="Show the path of the directory listed.">
					<option value="0">No</option>
					<option value="1">Yes</option>
					<option value="2">Hide all</option>
				</field>
				<field name="sfl_showicon" type="radio" default="1" label="Show icons" description="Show an icon in front of the directory or file.">
					<option value="0">No</option>
					<option value="1">Yes</option>
				</field>
				<field name="sfl_sortorder" type="radio" default="asc" label="Default sort order" description="Default sort order of files.">
					<option value="asc">Ascending</option>
					<option value="desc">Descending</option>
					<option value="none">Server</option>
				</field>
				<field name="sfl_showsort" type="radio" default="0" label="Show user sort option" description="Show arrows for sorting Asc/Desc to user.">
					<option value="0">No</option>
					<option value="1">Yes</option>
				</field>
				<field name="spacer05" type="spacer" default="" label="" description=""/>
				<field name="sfl_boxleft" type="text" default="0" label="Lister box left position" description="In some templates the box with the list is pushed too far to the left. Change this value to move the box to the left (reduce value) or to the right (increase value)."/>
				<field name="sfl_listleft" type="text" default="0" label="List left position" description="In some templates the list is pushed too far to the left. Change this value to move the list inside the box to the left (reduce value) or to the right (increase value)."/>
				<field name="spacer06" type="spacer" default="" label="" description=""/>
				<field name="moduleclass_sfx" type="text" default="" label="Module Class Suffix" description="Module Class Suffix"/>
			</fieldset>
		</fields>
	</config>
</extension>
Last edited by toivo on Thu Feb 18, 2021 5:32 pm, edited 1 time in total.
Reason: mod note: added CODE tags

Post Reply

Return to “Расширения для Joomla! 3.x”