public function filedepot::createStorageFolder in filedepot 6
Same name and namespace in other branches
- 7 filedepot.class.php \filedepot::createStorageFolder()
1 call to filedepot::createStorageFolder()
File
- ./
filedepot.class.php, line 538 - filedepot.class.php Main class for the Filedepot module
Class
- filedepot
- @file filedepot.class.php Main class for the Filedepot module
Code
public function createStorageFolder($cid) {
if (@is_dir($this->root_storage_path) === FALSE) {
watchdog('filedepot', "Storage Directory does not exist ({$this->root_storage_path}), attempting to create now");
$res = @mkdir($this->root_storage_path, FILEDEPOT_CHMOD_DIRS);
if ($res === FALSE) {
watchdog('fildepot', "Failed - check the folder path is correct and valid");
}
else {
watchdog('filedepot', "Success, Root Storage director created");
}
}
$path = $this->root_storage_path . $cid;
if (@is_dir($path)) {
@chmod($path, FILEDEPOT_CHMOD_DIRS);
if ($fh = fopen($path . '/.htaccess', 'w')) {
fwrite($fh, "deny from all\n");
fclose($fh);
}
if ($fh = fopen("{$path}/submissions" . '/.htaccess', 'w')) {
fwrite($fh, "deny from all\n");
fclose($fh);
}
return TRUE;
}
else {
$oldumask = umask(0);
$res1 = @mkdir($path, FILEDEPOT_CHMOD_DIRS);
$res2 = @mkdir("{$path}/submissions", FILEDEPOT_CHMOD_DIRS);
umask($oldumask);
if ($res1 === FALSE or $res2 === FALSE) {
watchdog('fildepot', "Failed to create server directory {$path} or {$path}/submissions");
return FALSE;
}
else {
if ($fh = fopen($path . '/.htaccess', 'w')) {
fwrite($fh, "deny from all\n");
fclose($fh);
}
if ($fh = fopen("{$path}/submissions" . '/.htaccess', 'w')) {
fwrite($fh, "deny from all\n");
fclose($fh);
}
return TRUE;
}
}
}