2010-05-09 3 views
2

간단한 설치 스크립트를 만들고 싶습니다. 다음은 간단한 코드입니다.폴더 권한 및 제출 버튼

<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.'</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"); 
?> 
</ul> 

모든 파일 및 폴더의 유효 사용 권한이 777 일 경우 만드는 방법은 Submit button이 표시됩니다. 여전히

을 알려주세요 제출 버튼을 표시하지 않습니다 잘못된 권한이있는 경우

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

.

답변

1

어, 이건 조금 더러운 될 것입니다,하지만 :

<?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

하지만했다! Robus에게 감사드립니다. 더러운거야? – wow