Go Back   CodingForums.com > :: Server side development > PHP > Post a PHP snippet

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-22-2006, 09:13 PM   PM User | #1
thesavior
Senior Coder

 
Join Date: Aug 2005
Posts: 1,119
Thanks: 2
Thanked 1 Time in 1 Post
thesavior has a little shameless behaviour in the past
Check file permissions

This is great for installers. It checks the file you provided in the first statment, against the octal you want it to have. If it has incorrect permissions, the row is red, if correct permissions, it makes a green row.

Function
PHP Code:
function check_perms($path,$perm)
{
    
clearstatcache();
    
$configmod substr(sprintf('%o'fileperms($path)), -4); 
    
$trcss = (($configmod != $perm) ? "background-color:#fd7a7a;" "background-color:#91f587;");
    echo 
"<tr style=".$trcss.">"
    echo 
"<td style=\"border:0px;\">"$path ."</td>"
    echo 
"<td style=\"border:0px;\">$perm</td>"
    echo 
"<td style=\"border:0px;\">$configmod</td>"
    echo 
"</tr>";  

Usage
PHP Code:
<table width=\"100%\"  border=\"0\" cellspacing=\"0\" cellpadding=\"3\" style=\"text-align:center;\">
         <tr>
        <th style="border:0px;"><b>File Name</b></th>
        <th style="border:0px;"><b>Needed Chmod</b></th>
        <th style="border:0px;"><b>Current Chmod</b></th>
    </tr>
    <?php 
            check_perms
("cache","0777");
        
check_perms("include/keys","0777");
        
check_perms("backup","0777");
        
check_perms("uploads","0777");
        
check_perms("include/template","0777");
        
check_perms("include/user","0777");
        
check_perms("img","0777");
        
check_perms("img/avatars","0777");
    
?>
</table>
thesavior is offline   Reply With Quote
Old 08-09-2009, 03:30 PM   PM User | #2
sith717
Banned

 
Join Date: Oct 2008
Posts: 136
Thanks: 4
Thanked 0 Times in 0 Posts
sith717 can only hope to improve
Hey, thanks a lot for this, can you add a button, so that when they are all green, you can proceed with the installation.
sith717 is offline   Reply With Quote
Old 08-09-2009, 03:47 PM   PM User | #3
abduraooft
Supreme Master coder!

 
abduraooft's Avatar
 
Join Date: Mar 2007
Location: N/A
Posts: 14,680
Thanks: 158
Thanked 2,182 Times in 2,169 Posts
abduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really nice
Quote:
Originally Posted by sith717 View Post
Hey, thanks a lot for this, can you add a button, so that when they are all green, you can proceed with the installation.
How about trying it yourself, and asking for help on specific issues, rather than re instantiating a 3.5 year old thread?
__________________
Quote:
The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)
abduraooft is offline   Reply With Quote
Old 08-09-2009, 03:55 PM   PM User | #4
sith717
Banned

 
Join Date: Oct 2008
Posts: 136
Thanks: 4
Thanked 0 Times in 0 Posts
sith717 can only hope to improve
Oh I didnt know it was old.

Anyways, I am not good at coding php myself. So what would be some steps to doing it?

this is exactly what I need for my installation.
sith717 is offline   Reply With Quote
Old 08-09-2009, 03:56 PM   PM User | #5
sith717
Banned

 
Join Date: Oct 2008
Posts: 136
Thanks: 4
Thanked 0 Times in 0 Posts
sith717 can only hope to improve
Basicly if all files are green, means permissions are what they are supposed to be, you can procceed with installation, which a button shows up to go to the next page of installation.
sith717 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:42 AM.


Advertisement
Log in to turn off these ads.