function force_mkdir($path, $chmod = null) {
if(is_dir($path)) return true;
$real_path = str_replace('\\', '/', $path);
$parts = explode('/', $real_path);
$forced_path = '';
foreach($parts as $part) {
// Skip first on windows
if($forced_path == '') {
$start = substr(__FILE__, 0, 1) == '/' ? '/' : '';
$forced_path = $start . $part;
} else {
$forced_path .= '/' . $part;
} // if
if(!is_dir($forced_path)) {
if(!is_null($chmod)) {
if(!mkdir($forced_path)) return false;
} else {
if(!mkdir($forced_path, $chmod)) return false;
} // if
} // if
} // foreach
return true;
} // force_mkdirviceroy321:trac is down again...
function force_mkdir($path, $chmod = null) {
$real_path = str_replace(getcwd(), '', $path);
$real_path = str_replace('\\', '/', $real_path);
if(is_dir($real_path)) return true;
$parts = explode('/', $real_path);
$forced_path = '';
foreach($parts as $part) {
// Skip first on windows
if($forced_path == '') {
$start = substr(__FILE__, 0, 1) == '/' ? '/' : '';
$forced_path = $start . $part;
} else {
$forced_path .= '/' . $part;
} // if
if(strlen(trim($forced_path)) > 0 && !is_dir($forced_path)) {
if(!is_null($chmod)) {
if(!mkdir($forced_path)) return false;
} else {
if(!mkdir($forced_path, $chmod)) return false;
} // if
} // if
} // foreach
return true;
} // force_mkdir
apache 2, php 5, mysql 5 on centos 4