Jump to content

excluding a directory+ftp


jakebur01

Recommended Posts

How could I get the following function to exclude the directory named "car" when it is listing them out?

function ShowFiles() 
{ 
$conn = DoConn(); 
$currDir = ""; 

// Get the name of the current directory 
if(isset($_GET["currDir"])) 
$currDir = $_GET["currDir"]; 
else 
$currDir = ftp_pwd($conn); 
// Retrieve a list of files and directories 
// and display the appropriate icon for each 
$fList = @ftp_nlist($conn, $currDir); 
// We will work out the parent directory 
$parentDir = strrev($currDir); 
$parentDir = ereg_replace("^[a-zA-Z0-9\-]*/", "", $parentDir); 
$parentDir = strrev($parentDir); 
?> 
<a href="javascript:history.go(-1)">
<img src='http://www.orosandrei.ro/images/back.gif'> 
</a> 
<br>
<?php

for($i = 0; $i < sizeof($fList); $i++) 
{ 
// We will remove the parent directory (if any) 
// from the name of the file that gets displayed 
$trimFile = ereg_replace("^$currDir", "", $fList[$i]); 

// Remove any forward slash at front of name 
$trimFile = ereg_replace("^/", "", $trimFile); 

if(@ftp_chdir($conn, $fList[$i])) 
{ 
@ftp_cdup($conn); 
?> 
<img src='http://www.orosandrei.ro/images/folder.gif'> 
<a href='scan.php?command=listFiles&currDir=<?php echo $fList[$i]; ?>'> 
<?php echo $trimFile; ?> 
</a> 
<br> 
<?php 
} 
else 
{ 
?> 
<img src='http://www.orosandrei.ro/images/file.gif'> 
<a href='scan.php?command=getFile&currFile=<?php echo $fList[$i]; ?>&currDir=<?php echo $currDir; ?>'> 
<?php echo $trimFile; ?> 
</a> 
<br> 
<?php 
} 
} 
} 

 

Link to comment
https://forums.phpfreaks.com/topic/139920-excluding-a-directoryftp/
Share on other sites

I was hoping it would be easy. Something I could stick in the code where if $fList[$1]==car then it will not display that directory.

if(@ftp_chdir($conn, $fList[$i])) 
{ 
@ftp_cdup($conn); 
?> 
<img src='http://www.orosandrei.ro/images/folder.gif'> 
<a href='scan.php?command=listFiles&currDir=<?php echo $fList[$i]; ?>'> 
<?php echo $trimFile; ?> 
</a> 
<br> 
<?php 
} 
else 
{ 
?> 
<img src='http://www.orosandrei.ro/images/file.gif'> 
<a href='scan.php?command=getFile&currFile=<?php echo $fList[$i]; ?>&currDir=<?php echo $currDir; ?>'> 
<?php echo $trimFile; ?> 
</a> 
<br> 
<?php 
} 

 

Thanks,

 

Jake

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.