diff options
| author | Horus3 | 2014-03-17 18:03:21 +0100 |
|---|---|---|
| committer | Horus3 | 2014-03-17 18:03:21 +0100 |
| commit | 889f10a8bea7105853ca505223dea1a1df07e0b9 (patch) | |
| tree | e7b85a68bc4239184e47a492a1e0ac0a00b088d6 /www/functions/func_folder.php | |
| parent | 1c8afbfabc15a35f84290ca7320da0e9e373747e (diff) | |
| download | files.iamfabulous.de-889f10a8bea7105853ca505223dea1a1df07e0b9.tar.gz | |
func mkdir
Diffstat (limited to 'www/functions/func_folder.php')
| -rw-r--r-- | www/functions/func_folder.php | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/www/functions/func_folder.php b/www/functions/func_folder.php new file mode 100644 index 0000000..8b1ed12 --- /dev/null +++ b/www/functions/func_folder.php @@ -0,0 +1,29 @@ +<?php + +function mkdir($path, $new_folder_name, $share){ + + $db = $GLOBALS["db"]; + + if(!$_SESSION["login"]){ + return MKDIR_LOGIN; + } + + $file_id = select_file_id($db, $_SESSION["userid"], $path); + + $owner_db = $db->query("SELECT owner FROM files WHERE id=" . SQLite3::escapeString('$file_id') . ";"); + $owner_ar = $owner_db->fetchArray(SQLITE3_NUM); + + if($owner_ar[0] != $_SESSION["userid"]){ + return MKDIR_OWNER; + } + + if($db->exec(" + BEGIN TRANSACTION; + INSERT INTO files (id, parent, owner, name, folder, size, share, hash) VALUES (Null, " . $file_id . ", " . $_SESSION['userid'] . ", " . SQLite3::escapeString('$new_folder_name') . ", 'DIRECTORY', 0, " . SQLite3::escapeString('$share') . ", ''); + COMMIT; + ")){ + return MKDIR_SUCCESS; + } else { + return MKDIR_DATABASE; + } +} |
