16 include_once (
"VAULT/Class.VaultDiskStorage.php");
17 include_once (
"Class.Log.php");
18 define(
"VAULT_FMODE", 0600);
19 define(
"VAULT_DMODE", 0700);
39 if (!isset($chrono)) $this->chrono = FALSE;
40 else $this->chrono = $chrono;
43 $this->logger =
new Log(
"",
"vault", $this->
name);
44 if ($this->chrono) $this->logger->warning(
"Running with chrono !!!!");
45 $this->dbaccess = $access;
50 switch ($this->
type) {
52 $this->logger->debug(
"Set Storage Type to FS");
69 function show($id_file, &$infos, $teng_lname =
"")
72 if ($this->chrono) $this->logger->start(
"Show");
73 $msg = $this->storage->Show($id_file, $infos, $teng_lname);
75 $this->logger->error(sprintf(
"File #%s : %s", $id_file, $msg));
77 if ($this->chrono) $this->logger->end(
"Show");
87 $this->storage->updateAccessDate($id_file);
98 if ($this->chrono) $this->logger->start(
"Retrieve");
99 if (isset(
$info)) unset($infos);
101 $msg = $this->storage->Show($id_file, $infos);
103 if ($msg !=
'') $this->logger->error($msg);
104 if ($this->chrono) $this->logger->end(
"Retrieve");
108 function store($infile, $public_access, &$id,
$fsname =
"", $te_name =
"", $te_id_file = 0, $tmp = null)
111 if ($this->chrono) $this->logger->start(
"Store");
113 if (!file_exists($infile) || !is_readable($infile) || !is_file($infile)) {
114 $this->logger->error(
"Can't access file [" . $infile .
"].");
115 $msg = _(
"can't access file");
117 if (!is_bool($public_access)) {
118 $public_access = FALSE;
119 $this->logger->warning(
"Access mode forced to RESTRICTED for " . $infile .
"].");
121 $this->storage->id_tmp = $tmp;
122 $msg = $this->storage->Store($infile, $public_access, $id,
$fsname, $te_name, $te_id_file);
123 if ($msg) $this->logger->error($msg);
125 if ($this->chrono) $this->logger->end(
"Store");
129 function save($infile, $public_access, $id)
132 if ($this->chrono) $this->logger->start(
"Save");
134 if (!is_bool($public_access)) {
135 $public_access = FALSE;
136 $this->logger->warning(
"Access mode forced to RESTRICTED for " . $infile .
"].");
139 $msg = $this->storage->Save($infile, $public_access, $id);
140 if ($msg) $this->logger->error($msg);
143 $this->storage->mime_s =
getSysMimeFile($infile, $this->storage->name);
144 $msg = $this->storage->Modify();
145 if ($this->chrono) $this->logger->end(
"Save");
157 if ($this->chrono) $this->logger->start(
"Rename");
159 if ($newname !=
"") {
160 $nn = str_replace(array(
167 if ($nn != $newname) {
168 addWarningMsg(sprintf(_(
"Some characters are not authorized for file name %s. They are replaced by -") , $nn));
172 include_once (
"WHAT/Lib.FileMime.php");
173 $infile = $this->storage->getPath();
174 $oldname = $this->storage->name;
175 $this->storage->Show($id_file, $infos);
176 $this->storage->name = $newname;
177 $this->storage->mime_t =
getTextMimeFile($infile, $this->storage->name);
178 $this->storage->mime_s =
getSysMimeFile($infile, $this->storage->name);
179 $msg = $this->storage->Modify();
181 $pio = pathinfo($oldname);
182 $pin = pathinfo($newname);
183 $epio = isset($pio[
'extension']) ? $pio[
'extension'] :
"";
184 if ($epio ==
"") $epio =
"nop";
185 $epin = isset($pin[
'extension']) ? $pin[
'extension'] :
"";
186 if ($epin ==
"") $epin =
"nop";
187 if ($epio != $epin) {
189 if (preg_match(
"|(.*)/([0-9]+)\\.[^\\.]*|", $infos->path, $reg)) {
190 $newpath = $reg[1] .
"/" . $reg[2] .
"." . $epin;
191 rename($infos->path, $newpath);
195 if ($msg) $this->logger->error($msg);
198 if ($this->chrono) $this->logger->end(
"Rename");
205 if ($this->chrono) $this->logger->start(
"ListFiles");
206 $this->storage->ListFiles(
$s);
207 if ($this->chrono) $this->logger->end(
"ListFiles");
214 if ($this->chrono) $this->logger->start(
"Destroy");
216 $msg = $this->storage->Destroy($id);
217 if ($msg !=
'') $this->logger->error($msg);
218 if ($this->chrono) $this->logger->end(
"Destroy");
getTextMimeFile($f, $fn= '')
print $fam getTitle() $fam name
retrieve($id_file, &$infos)
updateAccessDate($id_file)
getSysMimeFile($f, $fn="")
store($infile, $public_access, &$id, $fsname="", $te_name="", $te_id_file=0, $tmp=null)
save($infile, $public_access, $id)
show($id_file, &$infos, $teng_lname="")
rename($id_file, $newname)
__construct($access, $vaultname="Sample", $idf=-1)