Skip to content
Snippets Groups Projects
Commit 8c270570 authored by Laurent Destailleur's avatar Laurent Destailleur
Browse files

Fix: Use preg functions

parent 49e701c6
No related branches found
No related tags found
No related merge requests found
...@@ -168,7 +168,7 @@ if ($_REQUEST['action'] == 'confirm_deletefile' && $_REQUEST['confirm'] == 'yes' ...@@ -168,7 +168,7 @@ if ($_REQUEST['action'] == 'confirm_deletefile' && $_REQUEST['confirm'] == 'yes'
{ {
// Remote file // Remote file
$filename=$file; $filename=$file;
$remotefile=$section.(eregi('[\\\/]$',$section)?'':'/').$file; $remotefile=$section.(preg_match('@[\\\/]$@',$section)?'':'/').$file;
$newremotefileiso=utf8_decode($remotefile); $newremotefileiso=utf8_decode($remotefile);
//print "x".$newremotefileiso; //print "x".$newremotefileiso;
...@@ -209,7 +209,7 @@ if ($_REQUEST['action'] == 'confirm_deletesection' && $_REQUEST['confirm'] == 'y ...@@ -209,7 +209,7 @@ if ($_REQUEST['action'] == 'confirm_deletesection' && $_REQUEST['confirm'] == 'y
{ {
// Remote file // Remote file
$filename=$file; $filename=$file;
$remotefile=$section.(eregi('[\\\/]$',$section)?'':'/').$file; $remotefile=$section.(preg_match('@[\\\/]$@',$section)?'':'/').$file;
$newremotefileiso=utf8_decode($remotefile); $newremotefileiso=utf8_decode($remotefile);
$result=ftp_rmdir($conn_id, $newremotefileiso); $result=ftp_rmdir($conn_id, $newremotefileiso);
...@@ -252,7 +252,7 @@ if ($_REQUEST['action'] == 'download') ...@@ -252,7 +252,7 @@ if ($_REQUEST['action'] == 'download')
// Remote file // Remote file
$filename=$file; $filename=$file;
$remotefile=$section.(eregi('[\\\/]$',$section)?'':'/').$file; $remotefile=$section.(preg_match('@[\\\/]$@',$section)?'':'/').$file;
$newremotefileiso=utf8_decode($remotefile); $newremotefileiso=utf8_decode($remotefile);
$result=ftp_get($conn_id,$localfile,$newremotefileiso,FTP_BINARY); $result=ftp_get($conn_id,$localfile,$newremotefileiso,FTP_BINARY);
...@@ -395,8 +395,9 @@ else ...@@ -395,8 +395,9 @@ else
$i=0; $i=0;
while ($i < $nboflines && $i < 1000) while ($i < $nboflines && $i < 1000)
{ {
$vals=explode(' +',utf8_encode($buff[$i]),9); $vals=preg_split('@ +@',utf8_encode($buff[$i]),9);
//$vals=preg_split('@ +@','drwxr-xr-x 2 root root 4096 Aug 30 2008 backup_apollon1',9);
//var_dump($vals);
$file=$vals[8]; $file=$vals[8];
if (empty($file)) if (empty($file))
{ {
...@@ -415,15 +416,20 @@ else ...@@ -415,15 +416,20 @@ else
if ($file == '..') $is_directory=1; if ($file == '..') $is_directory=1;
else if (! $rawlisthasfailed) else if (! $rawlisthasfailed)
{ {
if (eregi('^d',$vals[0])) $is_directory=1; if (preg_match('/^d/',$vals[0])) $is_directory=1;
if (eregi('^l',$vals[0])) $is_link=1; if (preg_match('/^l/',$vals[0])) $is_link=1;
} }
else else
{ {
// Remote file // Remote file
$filename=$file; $filename=$file;
$remotefile=$section.(eregi('[\\\/]$',$section)?'':'/').$file; //print "section=".$section.' file='.$file.'X';
//print preg_match('@[\/]$@','aaa/').'Y';
//print preg_match('@[\\\/]$@',"aaa\\").'Y';
$remotefile=$section.(preg_match('@[\\\/]$@',$section)?'':'/').preg_replace('@^[\\\/]@','',$file);
//print 'A'.$remotefile.'A';
$newremotefileiso=utf8_decode($remotefile); $newremotefileiso=utf8_decode($remotefile);
//print 'Z'.$newremotefileiso.'Z';
$is_directory=ftp_isdir($conn_id, $newremotefileiso); $is_directory=ftp_isdir($conn_id, $newremotefileiso);
} }
...@@ -431,8 +437,8 @@ else ...@@ -431,8 +437,8 @@ else
print '<tr '.$bc[$var].'>'; print '<tr '.$bc[$var].'>';
// Name // Name
print '<td>'; print '<td>';
$newsection=$section.(eregi('[\\\/]$',$section)?'':'/').$file; $newsection=$section.(preg_match('@[\\\/]$@',$section)?'':'/').$file;
$newsection=eregi_replace('[\\\/][^\\\/]+[\\\/]\.\.$','/',$newsection); // Change aaa/xxx/.. to new aaa $newsection=preg_replace('@[\\\/][^\\\/]+[\\\/]\.\.$@','/',$newsection); // Change aaa/xxx/.. to new aaa
if ($is_directory) print '<a href="'.$_SERVER["PHP_SELF"].'?section='.urlencode($newsection).'">'; if ($is_directory) print '<a href="'.$_SERVER["PHP_SELF"].'?section='.urlencode($newsection).'">';
print $file; print $file;
if ($is_directory) print '</a>'; if ($is_directory) print '</a>';
...@@ -580,7 +586,7 @@ function dol_ftp_connect($ftp_server, $ftp_port, $ftp_user, $ftp_password, $sect ...@@ -580,7 +586,7 @@ function dol_ftp_connect($ftp_server, $ftp_port, $ftp_user, $ftp_password, $sect
*/ */
function ftp_isdir($connect_id,$dir) function ftp_isdir($connect_id,$dir)
{ {
if(ftp_chdir($connect_id,$dir)) if (@ftp_chdir($connect_id,$dir))
{ {
ftp_cdup($connect_id); ftp_cdup($connect_id);
return 1; return 1;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment