@@ -391,7 +391,7 @@ public function switchAction($action, $httpVars, $fileVars)
391
391
header ("Content-type:application/json " );
392
392
if ($ selection ->isUnique ()){
393
393
$ stat = @stat ($ this ->urlBase .$ selection ->getUniqueFile ());
394
- if (!$ stat ) {
394
+ if (!$ stat || ! is_readable ( $ selection -> getUniqueNode ()-> getUrl ()) ) {
395
395
print '{} ' ;
396
396
} else {
397
397
print json_encode ($ stat );
@@ -401,7 +401,7 @@ public function switchAction($action, $httpVars, $fileVars)
401
401
print '{ ' ;
402
402
foreach ($ files as $ index => $ path ){
403
403
$ stat = @stat ($ this ->urlBase .$ path );
404
- if (!$ stat ) $ stat = '{} ' ;
404
+ if (!$ stat || ! is_readable ( $ this -> urlBase . $ path ) ) $ stat = '{} ' ;
405
405
else $ stat = json_encode ($ stat );
406
406
print json_encode ($ path ).': ' .$ stat . (($ index < count ($ files ) -1 ) ? ", " : "" );
407
407
}
@@ -854,6 +854,9 @@ public function switchAction($action, $httpVars, $fileVars)
854
854
if (AJXP_MetaStreamWrapper::actualRepositoryWrapperClass ($ this ->repository ->getId ()) == "fsAccessWrapper " ) {
855
855
$ nonPatchedPath = fsAccessWrapper::unPatchPathForBaseDir ($ path );
856
856
}
857
+ if (!is_readable ($ path ) && !is_writeable ($ path )){
858
+ throw new Exception ("You are not allowed to access folder " . $ path );
859
+ }
857
860
// Backward compat
858
861
if ($ selection ->isUnique () && strpos ($ selection ->getUniqueFile (), "/ " ) !== 0 ){
859
862
$ selection ->setFiles (array ($ dir . "/ " . $ selection ->getUniqueFile ()));
@@ -892,7 +895,7 @@ public function switchAction($action, $httpVars, $fileVars)
892
895
AJXP_XMLWriter::renderAjxpHeaderNode ($ parentAjxpNode );
893
896
}
894
897
foreach ($ uniqueNodes as $ node ){
895
- if (!file_exists ($ node ->getUrl ())) continue ;
898
+ if (!file_exists ($ node ->getUrl ()) || (! is_readable ( $ node -> getUrl ()) && ! is_writable ( $ node -> getUrl ())) ) continue ;
896
899
$ nodeName = $ node ->getLabel ();
897
900
if (!$ this ->filterNodeName ($ node ->getPath (), $ nodeName , $ isLeaf , $ lsOptions )) {
898
901
continue ;
@@ -1212,6 +1215,7 @@ public function loadNodeInfo(&$ajxpNode, $parentNode = false, $details = false)
1212
1215
$ metaData ["file_owner " ] = @fileowner ($ ajxpNode ->getUrl ()) || "unknown " ;
1213
1216
$ crtPath = $ ajxpNode ->getPath ();
1214
1217
$ vRoots = $ this ->repository ->listVirtualRoots ();
1218
+ $ metaData ["ajxp_readonly " ] = "false " ;
1215
1219
if (!empty ($ crtPath )) {
1216
1220
if (!@$ this ->isWriteable ($ ajxpNode ->getUrl ())) {
1217
1221
$ metaData ["ajxp_readonly " ] = "true " ;
@@ -1655,7 +1659,7 @@ public function rename($filePath, $filename_new, $dest = null)
1655
1659
$ mess = ConfService::getMessages ();
1656
1660
$ filename_new =AJXP_Utils::sanitize (SystemTextEncoding::magicDequote ($ filename_new ), AJXP_SANITIZE_FILENAME );
1657
1661
$ filename_new = substr ($ filename_new , 0 , ConfService::getCoreConf ("NODENAME_MAX_LENGTH " ));
1658
- $ old =$ this ->urlBase ." / $ filePath" ;
1662
+ $ old =$ this ->urlBase .$ filePath ;
1659
1663
if (!$ this ->isWriteable ($ old )) {
1660
1664
throw new AJXP_Exception ($ mess [34 ]." " .$ nom_fic ." " .$ mess [99 ]);
1661
1665
}
0 commit comments