@@ -684,7 +684,7 @@ public function downloadAction(ServerRequestInterface &$request, ResponseInterfa
684
684
685
685
$ node = $ selection ->getUniqueNode ();
686
686
$ dlFile = $ node ->getUrl ();
687
- if (!is_readable ( $ dlFile )){
687
+ if (!$ this -> isReadable ( $ node )){
688
688
throw new \Exception ("Cannot access file! " );
689
689
}
690
690
$ this ->logInfo ("Get_content " , ["files " =>$ this ->addSlugToPath ($ selection )]);
@@ -834,14 +834,14 @@ public function switchAction(ServerRequestInterface &$request, ResponseInterface
834
834
$ jsonData = new \stdClass ;
835
835
if ($ selection ->isUnique ()){
836
836
$ stat = @stat ($ selection ->getUniqueNode ()->getUrl ());
837
- if ($ stat !== false && is_readable ( $ selection -> getUniqueNode ()-> getUrl ())) {
837
+ if ($ stat !== false && ! $ this -> isReadable ( $ selection -> getUniqueNode ())) {
838
838
$ jsonData = $ stat ;
839
839
}
840
840
}else {
841
841
$ nodes = $ selection ->buildNodes ();
842
842
foreach ($ nodes as $ node ){
843
843
$ stat = @stat ($ node ->getUrl ());
844
- if (!$ stat || !is_readable ( $ node -> getUrl () )) {
844
+ if (!$ stat || !$ this -> isReadable ( $ node )) {
845
845
$ stat = new \stdClass ();
846
846
}
847
847
$ path = $ node ->getPath ();
@@ -1275,7 +1275,8 @@ public function switchAction(ServerRequestInterface &$request, ResponseInterface
1275
1275
$ lsOptions = $ this ->parseLsOptions ((isSet ($ httpVars ["options " ])?$ httpVars ["options " ]:"a " ));
1276
1276
1277
1277
$ startTime = microtime ();
1278
- $ path = $ selection ->nodeForPath (($ dir != "" ?($ dir [0 ]=="/ " ?"" :"/ " ).$ dir :"" ))->getUrl ();
1278
+ $ dirNode = $ selection ->nodeForPath (($ dir != "" ?($ dir [0 ]=="/ " ?"" :"/ " ).$ dir :"" ));
1279
+ $ path = $ dirNode ->getUrl ();
1279
1280
$ nonPatchedPath = $ path ;
1280
1281
if ($ patch ) {
1281
1282
$ nonPatchedPath = PathUtils::unPatchPathForBaseDir ($ path );
@@ -1284,7 +1285,7 @@ public function switchAction(ServerRequestInterface &$request, ResponseInterface
1284
1285
if ($ testPath === null || $ testPath === false ){
1285
1286
throw new \Exception ("There was a problem trying to open folder " . $ path . ", please check your Administrator " );
1286
1287
}
1287
- if (!is_readable ( $ path ) && !is_writeable ( $ path )){
1288
+ if (!$ this -> isReadable ( $ dirNode ) && !$ this -> isWriteable ( $ dirNode )){
1288
1289
throw new \Exception ("You are not allowed to access folder " . $ path );
1289
1290
}
1290
1291
// Backward compat
@@ -1317,7 +1318,7 @@ public function switchAction(ServerRequestInterface &$request, ResponseInterface
1317
1318
Controller::applyHook ("node.read " , [&$ parentAjxpNode ]);
1318
1319
$ nodesList ->setParentNode ($ parentAjxpNode );
1319
1320
foreach ($ uniqueNodes as $ node ){
1320
- if (!file_exists ($ node ->getUrl ()) || (!is_readable ( $ node -> getUrl ()) && !is_writable ( $ node -> getUrl () ))) continue ;
1321
+ if (!file_exists ($ node ->getUrl ()) || (!$ this -> isReadable ( $ node ) && !$ this -> isWriteable ( $ node ))) continue ;
1321
1322
$ nodeName = $ node ->getLabel ();
1322
1323
if (!$ this ->filterNodeName ($ ctx , $ node ->getPath (), $ nodeName , $ isLeaf , $ lsOptions )) {
1323
1324
continue ;
@@ -2266,10 +2267,22 @@ public function isWriteable(AJXP_Node $node)
2266
2267
$ real = $ node ->getRealFile ();
2267
2268
return posix_access ($ real , POSIX_W_OK );
2268
2269
}
2269
- //clearstatcache();
2270
2270
return is_writable ($ node ->getUrl ());
2271
2271
}
2272
2272
2273
+ /**
2274
+ * @param AJXP_Node $node
2275
+ * @return bool
2276
+ */
2277
+ public function isReadable (AJXP_Node $ node )
2278
+ {
2279
+ if ( $ this ->getContextualOption ($ node ->getContext (), "USE_POSIX " ) == true && extension_loaded ('posix ' )) {
2280
+ $ real = $ node ->getRealFile ();
2281
+ return posix_access ($ real , POSIX_R_OK );
2282
+ }
2283
+ return is_readable ($ node ->getUrl ());
2284
+ }
2285
+
2273
2286
/**
2274
2287
* Change file permissions
2275
2288
*
0 commit comments