10 ini_set(
"max_execution_time",
"36000");
14 include_once (
'FDL/Class.Doc.php');
15 include_once (
'FDL/Class.DocVaultIndex.php');
16 include_once (
'VAULT/Class.VaultFile.php');
22 print
"Database not found : param FREEDOM_DB";
29 $usage->setText(
"Examine vault files");
31 $vaultname =
$usage->addOption(
"vault",
"Name of the vault to examine", null,
"FREEDOM");
33 $test =
$usage->addOption(
"test",
"Enable/disable test mode: do not delete anything, just print what would be done", array(
46 $csv =
$usage->addOption(
"csv",
"Output in CSV format", array(
84 print sprintf(
"Unknown command '%s'.\n",
$command);
92 if (!
$csv) $fmt =
" %-5s | %-10s | %-" . $filel .
"s | %s\n";
93 else $fmt =
"%s;%s;%s;%s\n";
94 if (!is_array(
$t) || count(
$t) == 0)
return;
96 $s = sprintf($fmt,
"Vid",
"Access",
"Filename",
"Doc Id's");
98 echo
"---------------------------------------------------------------------------------------------\n";
100 foreach (
$t as $k => $v) {
103 if (is_array($v[
"docs"]) && count($v[
"docs"]) > 0) {
104 foreach ($v[
"docs"] as $kk => $vv) {
106 $ds.= ($first ?
"" :
"|") . $vv;
111 if (!
$csv && $ds ==
"") $ds =
"(none)";
112 if (strlen($v[
"file"]) > $filel && !
$csv) $f =
"..." . substr($v[
"file"], -($filel - 3));
113 else $f = $v[
"file"];
114 $s = sprintf($fmt, $v[
"vid"], ($v[
"access"] ?
"Ok" :
"No") , $f, $ds);
125 $vault->ListFiles($alls);
128 if (isset(
$filter[
"unref"])) $unref =
true;
130 if (isset(
$filter[
"unread"])) $unread =
true;
135 foreach ($alls as $k => $v) {
136 $vid = $v[
"id_file"];
140 $docids =
$dvi->GetDocIds($vid);
141 if (is_array($docids) && count($docids) > 0) {
142 foreach ($docids as $kk => $vv)
if ($vv->docid != - 1) $docs[] = $vv->docid;
145 $dvi->vaultid = $vid;
148 $vault->Show($vid, $inf);
150 if (is_readable(
$file)) $access =
true;
151 if (((!$unref && !$unread) || ($unref && count($docs) == 0) || ($unread && !$access))) {
152 $all[$if][
"vid"] = $vid;
153 $all[$if][
"file"] =
$file;
154 $all[$if][
"access"] = $access;
155 $all[$if][
"docs"] = $docs;
164 echo
"SetDocVaultIndex> $s\n";
169 if (!is_array($vt) || count($vt) == 0)
return;
172 if (
$test) $pref =
" [test] ";
176 foreach ($vt as $k => $v) {
179 $used = (is_array($v[
"docs"]) && count($v[
"docs"]) > 0 ?
true :
false);
181 loclog(
"$pref Suppress vault id $vid, filename $vname");
183 $vault->Destroy($vid);
184 $dvi->DeleteVaultId($vid);
186 }
else loclog(
" *** ERROR *** $vid used (referenced in doc(s))");