开发者

Folder permission and submit button

I want to create a simple installation script. Below are simple code.

<ul>
<?php 
function check_perms($path,$perm)
{
    clearstatcache();
    $configmod = substr(sprintf('%o', fileperms($path)), -4); 
    $css = (($configmod != $perm) ? " class='error'" : " class='none'");
    echo "<li".$css.">\n"; 
    echo '<span style="float:left; padding-right:20px;">'.$path.'</span>'; 
    echo '<span style="float:right; width:100px; text-align:right;">  <strong>'.$perm.'</strong></span>'; 
    echo '<span style="float:right; padding-right:100px;"><strong>'.$configmod.'</st开发者_运维百科rong></span>'; 
    echo '<div class="clear"></div>'; 
    echo "</li>";

}  
    check_perms("config.php","0777");
    check_perms("themes","0777");
    check_perms("themes/images","0777");
    check_perms("useruploads","0777");
?>
</ul>

How to make if all file and folder is valid permission to 777 will appear Submit button.

<input type='submit' name='submit' value='Submit' />

If there still have incorrect permission do not show the Submit button

Let me know.


Uh, this is going to be a bit dirty, but:

<?php

$error=0; 
function check_perms($path,$perm)
{
    global $error;
    clearstatcache();
    $configmod = substr(sprintf('%o', fileperms($path)), -4); 
    $css = (($configmod != $perm) ? " class='error'" : " class='none'");
    if($configmod != $perm) $error++;
    echo "<li".$css.">\n"; 
    echo '<span style="float:left; padding-right:20px;">'.$path.'</span>'; 
    echo '<span style="float:right; width:100px; text-align:right;">  <strong>'.$perm.'</strong></span>'; 
    echo '<span style="float:right; padding-right:100px;"><strong>'.$configmod.'</strong></span>'; 
    echo '<div class="clear"></div>'; 
    echo "</li>";

}  
    check_perms("config.php","0777");
    check_perms("themes","0777");
    check_perms("themes/images","0777");
    check_perms("useruploads","0777");

   if($error > 0) echo 'Dude, fix the permissions!';
   else echo '<input type="submit">';
   ?>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜