I have developed the following PHP code in order to read a specific directory called /dados/capture
:
tst2.php
<html>
<body>
<?php
echo "whoami: " . shell_exec('whoami')."<br>\n";
exec('ls /dados/capture/',$base);
echo "/dados/capture content ...<br>\n";
foreach ( $base as $dir )
{
print $dir ."<br>\n";
}
?>
Executing the code through linux command line "[root$mysite]# sudo -u apache php tst2.php" returns the following:
<html>
<body>
whoami: apache
<br>
/dados/capture content ...<br>
120130312115149.jpg<br>
120130312115149.swf<br>
120130312115658.jpg<br>
120130312115658.swf<br>
</body>
</html>
Calling tst2.php
from web browser results in:
whoami: apache
/dados/capture content ...
I have tried changing the permission for the folder(s) and creating directive <directory><directory>
in httpd.conf
, without any change to the result.
I have tested the code with different directory it was a surprise, because it also doesn't work for /boot
, /mnt
and /opt
directories.
Using glob
or readdir
result the same, but consumes much more processor.
I'm using CentOs 2.6.32-279.22.1.el6.i686, Apache/2.2.15 and PHP 5.4.12.
Did someone have a similar problem?