/** * Check recursively to see if a directory exists, if it doesn't attempt to create it * * @param string $dir The directory path * @param bool $index Whether or not to add an index.hmtl file in the directory * @return bool True on success */ public static function CheckDir($dir, $index = true) { global $config; if (!file_exists($dir)) { $parent = common::DirName($dir); gpFiles::CheckDir($parent, $index); //ftp mkdir if (isset($config['useftp'])) { if (!gpFiles::FTP_CheckDir($dir)) { return false; } } else { if (!@mkdir($dir, gp_chmod_dir)) { return false; } @chmod($dir, gp_chmod_dir); //some systems need more than just the 0755 in the mkdir() function } // make sure there's an index.html file // only check if we just created the directory, we don't want to keep creating an index.html file if a user deletes it if ($index && gp_dir_index) { $indexFile = $dir . '/index.html'; if (!file_exists($indexFile)) { //not using gpFiles::Save() so we can avoid infinite looping (it's safe since we already know the directory exists and we're not concerned about the content) file_put_contents($indexFile, '<html></html>'); @chmod($indexFile, gp_chmod_file); } } } return true; }
/** * Check recursively to see if a directory exists, if it doesn't attempt to create it * * @param string $dir The directory path * @param bool $index Whether or not to add an index.hmtl file in the directory * @return bool True on success */ function CheckDir($dir, $index = true) { global $config, $checkFileIndex; if (!file_exists($dir)) { $parent = dirname($dir); gpFiles::CheckDir($parent, $index); //ftp mkdir if (isset($config['useftp'])) { if (!gpFiles::FTP_CheckDir($dir)) { return false; } } else { if (!@mkdir($dir, gp_chmod_dir)) { return false; } @chmod($dir, gp_chmod_dir); //some systems need more than just the 0755 in the mkdir() function } } //make sure there's an index.html file if ($index && $checkFileIndex) { $indexFile = $dir . '/index.html'; if (!file_exists($indexFile)) { gpFiles::Save($indexFile, '<html></html>', false); } } return true; }