1
Bug reports / Re: File Listing
« on: October 27, 2009, 10:02:28 AM »
Yes, I confirm, you have to add a blank line 
Attached is the tpl file I use
Note : this tpl file permits a distant webserver to "ask" for a Directory listing (from a php code for instance) :

Code: [Select]
%files%
[files]
%folder%
%number-folders%
%number-files%
%list%
[file]
%item-name%
[folder]
%item-name%/
(note the two blank lines)Attached is the tpl file I use
Note : this tpl file permits a distant webserver to "ask" for a Directory listing (from a php code for instance) :
Code: [Select]
<?php
$httpServer = "http://WWW.XXX.YYY.ZZZ/RootFolder/"; //HFS server address + root folder to "view"
$dir_icon='<img style="border: none;vertical-align: middle;" src="'.CHEMIN.'inc/img/general/dir.gif" alt=" " />';
$up_icon='<img style="border: none;vertical-align: middle;" src="./img/top.gif" alt=" " />';
$file_icons='<img style="border: none;vertical-align: middle;" src="./img/{FileType}.gif" alt=" " />';
$excel_img="excel";
$word_img="word";
$zip_img="zip";
$pdf_img="acrobat";
$txt_img="text";
$uknw_im="unknown";
set_time_limit(160);
function MessageErreur($message){
echo "Error, blabla, Thank you !";
}
$workingDir = $httpServer;
$dossier_agent='';
$path="./";
if (isset($_GET['to']) && $_GET['to'] != '') {
$AFolder=stripslashes(urldecode($_GET['to']));
$path=$workingDir.rawurlencode($_GET['to']).'/';
echo "<b>Dossier de : </b>".ucwords(strtolower($AFolder)).'<hr />';
$lines=array();
$lines=file($path.'~files.lst');
$cfolder=$lines[0];
$n_folders=$lines[1];
$n_files=$lines[2];
$flist=array();
if($n_files!=0) {
$flist=array_slice($lines, 3+$n_folders);
sort($flist);
foreach($flist as $fname){
$ext = substr($fname, strrpos($fname, '.') + 1);
if ($ext=="xls"){$FileType="excel";}
elseif ($ext=="doc"){$FileType="word";}
elseif ($ext=="zip"){$FileType="zip";}
elseif ($ext=="pdf"){$FileType="acrobat";}
elseif ($ext=="txt"){$FileType="text";}
else{$FileType="unknown";}
$in = array ('{FileType}');
$out = array ($FileType);
$img = str_replace ($in, $out, $file_icons);
echo '<a href="'.$httpServer.$AFolder.'/'.basename($fname).'" target="_blank">'.$img.' '.ucwords(strtolower(basename($fname))).'</a><br />';
}
}
else {
echo "Folder empty !";
}
echo '<br /><center><div style="text-align: center;"><button onclick="self.location.href=\'javascript:history.go(-1)\'" type="button">Back to folder list</button></div></center>';
}
else {
echo "<b>List of folders :</b><hr />\n";
$nav="";
for ($i="A"; $i != "AA"; $i++){
$nav.=' <a href="#letter'.$i.'">'.$i.'</a> '."\n";
}
echo $nav.'<br />';
$oldfirst=" ";
$lines=file($workingDir.'~files.lst');
$cfolder=$lines[0];
$n_folders=$lines[1];
$n_files=$lines[2];
$flist=array();
if($n_folders!=0){
$flist=array_slice($lines, 3, $n_folders);
for($i=0;$i<$n_folders;$i++){
$s=trim($flist[$i]);
$flist[$i]=substr($s,0,-1);
}
foreach($flist as $fname){
//$fname=substr(
$first = $fname[0];
/* Alpha Separator */
if($first!=$oldfirst){
echo '<br /><b><span style="width: 100%; font-size: 18px;">';
echo '<a name="letter'.$first.'" href="#top" title="Back to Top of page">'.$up_icon.'</a>'.$first;
echo '</span></b><hr width="100" />'."\n";
}
$oldfirst=$first;
echo '<a href="pcu.php?to='.urlencode($fname).'">'.$dir_icon.' '.ucwords(strtolower($fname)).'</a><br />'."\n";
}
}
else {
echo "Empty Folder !";
}
}
?>