18 include_once (
"VAULT/Class.VaultDiskStorage.php");
19 include_once (
"Class.Log.php");
20 define(
"VAULT_FMODE", 0600);
21 define(
"VAULT_DMODE", 0700);
29 if (!isset($chrono)) $this->chrono = FALSE;
30 else $this->chrono = $chrono;
33 $this->logger =
new Log(
"",
"vault", $this->name);
34 if ($this->chrono) $this->logger->warning(
"Running with chrono !!!!");
35 $this->dbaccess = $access;
42 $this->use_cache = TRUE;
43 switch ($this->
type) {
45 $this->use_cache = FALSE;
46 $this->logger->debug(
"Set Storage Type to FS");
56 function Show($id_file, &$infos, $teng_lname =
"")
59 if ($this->chrono) $this->logger->start(
"Show");
60 $msg = $this->storage->Show($id_file, $infos, $teng_lname);
61 if ($msg !=
'') $this->logger->error($msg);
62 if ($this->chrono) $this->logger->end(
"Show");
69 if ($this->chrono) $this->logger->start(
"Retrieve");
70 if (isset($info)) unset($infos);
71 if ($this->use_cache) {
72 $msg = $this->cache->Show($id_file, $infosC);
74 $msg = $this->storage->Show($id_file, $infosS);
76 $msg = $this->cache->StoreIn($id_file, $info[
"path"], $info[
"size"]);
78 $msg = $this->cache->Show($id_file, $infosC);
82 $this->logger->warning(
"Cache insertion failure [$msg].");
87 $this->logger->error($msg);
96 $infos =
new stdClass();
97 $msg = $this->storage->Show($id_file, $infos);
99 if ($msg !=
'') $this->logger->error($msg);
100 if ($this->chrono) $this->logger->end(
"Retrieve");
105 function Store($infile, $public_access, &
$id,
$fsname =
"", $te_name =
"", $te_id_file = 0)
108 if ($this->chrono) $this->logger->start(
"Store");
110 if (!file_exists($infile) || !is_readable($infile) || !is_file($infile)) {
111 $this->logger->error(
"Can't access file [" . $infile .
"].");
112 $msg = _(
"can't access file");
114 if (!is_bool($public_access)) {
115 $public_access = FALSE;
116 $this->logger->warning(
"Access mode forced to RESTRICTED for " . $infile .
"].");
118 $msg = $this->storage->Store($infile, $public_access,
$id,
$fsname, $te_name, $te_id_file);
119 if ($msg) $this->logger->error($msg);
121 if ($this->chrono) $this->logger->end(
"Store");
128 if ($this->chrono) $this->logger->start(
"Save");
130 if (!is_bool($public_access)) {
131 $public_access = FALSE;
132 $this->logger->warning(
"Access mode forced to RESTRICTED for " . $infile .
"].");
135 $msg = $this->storage->Save($infile, $public_access,
$id);
136 if ($msg) $this->logger->error($msg);
139 $this->storage->mime_s =
getSysMimeFile($infile, $this->storage->name);
140 $msg = $this->storage->Modify();
141 if ($this->chrono) $this->logger->end(
"Save");
150 if ($this->chrono) $this->logger->start(
"Rename");
152 if ($newname !=
"") {
153 $nn = str_replace(array(
160 if ($nn != $newname) {
161 addWarningMsg(sprintf(_(
"Some characters are not authorized for file name %s. They are replaced by -") , $nn));
165 include_once (
"WHAT/Lib.FileMime.php");
166 $infile = $this->storage->getPath();
167 $oldname = $this->storage->name;
168 $msg = $this->storage->Show($id_file, $infos);
169 $this->storage->name = $newname;
170 $this->storage->mime_t =
getTextMimeFile($infile, $this->storage->name);
171 $this->storage->mime_s =
getSysMimeFile($infile, $this->storage->name);
172 $msg = $this->storage->Modify();
174 $pio = pathinfo($oldname);
175 $pin = pathinfo($newname);
176 $epio = $pio[
'extension'];
177 if ($epio ==
"") $epio =
"nop";
178 $epin = $pin[
'extension'];
179 if ($epin ==
"") $epin =
"nop";
180 if ($epio != $epin) {
182 $path = pathinfo($infos->path);
183 if (preg_match(
"|(.*)/([0-9]+)\.[^\.]*|", $infos->path, $reg)) {
184 $newpath = $reg[1] .
"/" . $reg[2] .
"." . $epin;
185 rename($infos->path, $newpath);
189 if ($msg) $this->logger->error($msg);
192 if ($this->chrono) $this->logger->end(
"Rename");
199 if ($this->chrono) $this->logger->start(
"Stats");
200 $this->storage->Stats(
$s);
201 if ($this->chrono) $this->logger->end(
"Stats");
208 if ($this->chrono) $this->logger->start(
"ListFiles");
209 $this->storage->ListFiles(
$s);
210 if ($this->chrono) $this->logger->end(
"ListFiles");
217 if ($this->chrono) $this->logger->start(
"Destroy");
218 if ($this->use_cache) $this->cache->Delete(
$id);
219 $msg = $this->storage->Destroy(
$id);
220 if ($msg !=
'') $this->logger->error($msg);
221 if ($this->chrono) $this->logger->end(
"Destroy");