Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Creating Folders With Proper CHMOD
Old 04-21-2006, 11:06 AM Creating Folders With Proper CHMOD
portkey's Avatar
Skilled Talker

Posts: 55
Name: Erica Dion
Trades: 0
I've set up a login script that creates a couple of folders everytime a new user is registered. The folders have been created successfully, but they are CHMOD to 315 each time, and I dont know how to fix this. I would prefer that they were CHMOD to 773 instead.

PHP Code:
$dir "users/{$val['username']}/images";
$mode 0733;
$stack = array(basename($dir));
$path null;
while ( (
$d dirname($dir) ) ) {
    if ( !
is_dir($d) ) {
        
$stack[] = basename($d);
        
$dir $d;
    } else {
        
$path $d;
        break;
    }
}
if ( ( 
$path realpath($path) ) === false 
    return 
false;
             
$created = array();
for ( 
$n count($stack) - 1$n >= 0$n-- ) {
    
$s $path '/'$stack[$n];                                      
    if ( !
mkdir($s$mode) ) {
        for ( 
$m count($created) - 1$m >= 0$m-- ) 
            
rmdir($created[$m]);
        return 
false;
    }
    
$created[] = $s;      
    
$path $s;

portkey is offline
Reply With Quote
View Public Profile Visit portkey's homepage!
 
 
Register now for full access!
Old 04-21-2006, 06:03 PM Re: Creating Folders With Proper CHMOD
Defies a Status

Posts: 1,606
Trades: 0
PHP Code:
!mkdir($s$mode
picks up the server default settings. And those vary from server to server.

Just add a chmod $newdir statement after the creation and set it for what you want.

I can't recall the exact syntax but I can look it up. I spent a whole darn weekend figuring this one out and am happy to save you the time.
__________________
Colbyt

Please login or register to view this content. Registration is FREE
colbyt is offline
Reply With Quote
View Public Profile
 
Old 04-21-2006, 07:38 PM Re: Creating Folders With Proper CHMOD
TrentonD's Avatar
Ultra Talker

Posts: 253
Location: Calgary, Alberta, Canada
Trades: 0
Hi portkey, I stumbled upon your code you have there, and I was wondering if I could have permission to use that on something I have been trying to figure out lately? If not, that's no problem at all
__________________
Signature Coming Soon! :)
Please login or register to view this content. Registration is FREE
TrentonD is offline
Reply With Quote
View Public Profile Visit TrentonD's homepage!
 
Old 04-23-2006, 12:08 AM Re: Creating Folders With Proper CHMOD
portkey's Avatar
Skilled Talker

Posts: 55
Name: Erica Dion
Trades: 0
Quote:
Originally Posted by TrentonD
Hi portkey, I stumbled upon your code you have there, and I was wondering if I could have permission to use that on something I have been trying to figure out lately? If not, that's no problem at all
sure, absolutely!

and colbyt, thanks a million! the help is greatly appreciated!
portkey is offline
Reply With Quote
View Public Profile Visit portkey's homepage!
 
Old 04-23-2006, 12:25 PM Re: Creating Folders With Proper CHMOD
Defies a Status

Posts: 1,606
Trades: 0
Quote:
Originally Posted by portkey
sure, absolutely!

and colbyt, thanks a million! the help is greatly appreciated!
Here is the cut from a message I posted elsewhere when I solved the problem with the script I was working with at the time.

Quote:
// create the target directory name
$newdir = siteframe_userdir($uid);
if (!is_dir($newdir)) {
if (!mkdir($newdir,0770)) {
$this->add_error(_ERR_BADDIR,$newdir);
}
}

Chmod is never mentioned. I should think their would be a routine to determine chmod based on site config.
I did a work-around by adding to the above and making it look like this:
else {
// create the target directory name $newdir = siteframe_userdir($uid); if (!is_dir($newdir)) { if (!mkdir($newdir,0770)) { $this->add_error(_ERR_BADDIR,$newdir); } {chmod($newdir, 0755); } }
Note that since I just did a cut and paste on the above that the php syntax may be broken as it is displayed. To read the thread in its entirety just type my user name and Glenn into Google it should be the first link.
__________________
Colbyt

Please login or register to view this content. Registration is FREE
colbyt is offline
Reply With Quote
View Public Profile
 
Old 04-23-2006, 01:47 PM Re: Creating Folders With Proper CHMOD
TrentonD's Avatar
Ultra Talker

Posts: 253
Location: Calgary, Alberta, Canada
Trades: 0
Quote:
Originally Posted by portkey
sure, absolutely!

and colbyt, thanks a million! the help is greatly appreciated!
Awesome! Thank you very much.
__________________
Signature Coming Soon! :)
Please login or register to view this content. Registration is FREE
TrentonD is offline
Reply With Quote
View Public Profile Visit TrentonD's homepage!
 
Reply     « Reply to Creating Folders With Proper CHMOD
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.23710 seconds with 12 queries