Revision 1651
Added by darkviper over 12 years ago
functions.php | ||
---|---|---|
414 | 414 |
return $retVal; |
415 | 415 |
} |
416 | 416 |
|
417 |
// Function to chmod files and directories |
|
418 |
function change_mode($name) |
|
417 |
/** |
|
418 |
* Function to chmod files and/or directories |
|
419 |
* @param string $sName |
|
420 |
* @param int rights in dec-value. 0= use wb-defaults |
|
421 |
* @return bool |
|
422 |
*/ |
|
423 |
function change_mode($sName, $iMode = 0) |
|
419 | 424 |
{ |
420 |
if(OPERATING_SYSTEM != 'windows') |
|
421 |
{ |
|
422 |
// Only chmod if os is not windows |
|
423 |
if(is_dir($name)) { |
|
424 |
$mode = OCTAL_DIR_MODE; |
|
425 |
}else { |
|
426 |
$mode = OCTAL_FILE_MODE; |
|
425 |
$bRetval = true; |
|
426 |
if((substr(__FILE__, 0, 1)) == '/') |
|
427 |
{ // Only chmod if os is not windows |
|
428 |
$bRetval = false; |
|
429 |
if(!$iMode) { |
|
430 |
$iMode = (is_file($sName) ? octdec(STRING_FILE_MODE) : octdec(STRING_DIR_MODE)); |
|
427 | 431 |
} |
428 |
if(file_exists($name)) { |
|
429 |
$umask = umask(0); |
|
430 |
chmod($name, $mode); |
|
431 |
umask($umask); |
|
432 |
return true; |
|
433 |
}else { |
|
434 |
return false; |
|
432 |
if(is_writable($sName)) { |
|
433 |
$bRetval = chmod($sName, $iMode); |
|
435 | 434 |
} |
436 |
}else { |
|
437 |
return true; |
|
438 | 435 |
} |
436 |
return $bRetval; |
|
439 | 437 |
} |
440 | 438 |
|
441 | 439 |
// Function to figure out if a parent exists |
Also available in: Unified diff
fixed a little problem with chmod()