The following code:
[php]<?php
function chmodr($path, $filemode)
{
if (!is_dir($path))
{
echo ‘
ERROR: ’ . $path . ’ IS NOT A DIRECTORY.
’;return false;
}
$dh = opendir($path);
while (($file = readdir($dh)) !== false)
{
if($file != ‘.’ && $file != ‘…’)
{
$fullpath = $path.’/’.$file;
if(is_link($fullpath))
{
echo ‘
’ . $fullpath . ’ IS A LINK.
’;}
elseif(!is_dir($fullpath) && !chmod($fullpath, $filemode))
{
echo ‘
’ . $fullpath . ’ Failed
’;}
elseif(!chmodr($fullpath, $filemode))
{
}
else
{
echo ‘
’ . $fullpath . ’ Success
’;}
}
}
closedir($dh);
if(!chmod($path, $filemode))
{
echo '<p>' . $path . ' <b>Failed</b></p>';
}
else
{
echo '<p>' . $path . ' <b> Success</b></p>';
}
return true;
}
if (isset($_GET[‘path’]))
{
chmodr($_GET[‘path’],octdec($_GET[‘perm’]));
}
else
{
echo ‘’;
echo ’
Path:
';echo ’
Octal Permissions:
‘;echo ’
Must have the leading 0. r = 4. w = 2. x = 1. Owner Group Others. EX: 0764 = Owner: rwx Group: rw- Others: r-- or rwxrw-r–
’;echo ’
';
echo ’ ';
echo ‘’;
}
?>[/php]
Outputs:
/home/ipprograms/www/language/en/common.php Failed/home/ipprograms/www/language/en/help_faq.php Failed
/home/ipprograms/www/language/en/captcha_recaptcha.php Failed
/home/ipprograms/www/language/en/email/post_approved.txt Failed
/home/ipprograms/www/language/en/email/user_resend_inactive.txt Failed
/home/ipprograms/www/language/en/email/user_activate_inactive.txt Failed
/home/ipprograms/www/language/en/email/user_welcome_inactive.txt Failed
ERROR: /home/ipprograms/www/language/en/email/admin_send_email_html.txt IS NOT A DIRECTORY.
…
Why is it running files as directories? (Most of my files are owned by ipprograms not www-data so they fail, further down there are ones that say success.)