11 include_once (
'FDL/Class.Doc.php');
12 include_once (
'FDL/Class.DocVaultIndex.php');
13 include_once (
'VAULT/Class.VaultFile.php');
19 print "Database not found : appl->dbaccess";
26 $usage->setDefinitionText(
"Examine vault files");
28 $vaultname =
$usage->addOptionalParameter(
"vault",
"Name of the vault to examine", null,
"FREEDOM");
30 $test =
$usage->addEmptyParameter(
"test",
"Enable/disable test mode: do not delete anything, just print what would be done");
41 $csv =
$usage->addEmptyParameter(
"csv",
"Output in CSV format");
67 $action->exitError(
"Use \"cleanVaultOrphans\" wsh script to delete orphans files");
79 if (!
$csv) $fmt =
" %-5s | %-10s | %-" . $filel .
"s | %s\n";
80 else $fmt =
"%s;%s;%s;%s\n";
81 if (!is_array($t) || count($t) == 0)
return;
83 $s = sprintf($fmt,
"Vid",
"Access",
"Filename",
"Doc Id's");
85 echo
"---------------------------------------------------------------------------------------------\n";
87 foreach ($t as $k => $v) {
90 if (is_array($v[
"docs"]) && count($v[
"docs"]) > 0) {
91 foreach ($v[
"docs"] as $kk => $vv) {
93 $ds.= ($first ?
"" :
"|") . $vv;
98 if (!
$csv && $ds ==
"") $ds =
"(none)";
99 if (strlen($v[
"file"]) > $filel && !
$csv) $f =
"..." . substr($v[
"file"], -($filel - 3));
100 else $f = $v[
"file"];
101 $s = sprintf($fmt, $v[
"vid"], ($v[
"access"] ?
"Ok" :
"No") , $f, $ds);
112 $vault->ListFiles($alls);
115 if (isset(
$filter[
"unref"])) $unref =
true;
117 if (isset(
$filter[
"unread"])) $unread =
true;
122 foreach ($alls as $k => $v) {
123 $vid = $v[
"id_file"];
127 $docids =
$dvi->GetDocIds($vid);
128 if (is_array($docids) && count($docids) > 0) {
129 foreach ($docids as $kk => $vv)
if ($vv->docid != - 1) $docs[] = $vv->docid;
132 $dvi->vaultid = $vid;
135 $vault->Show($vid, $inf);
137 if (is_readable(
$file)) $access =
true;
138 if (((!$unref && !$unread) || ($unref && count($docs) == 0) || ($unread && !$access))) {
139 $all[$if][
"vid"] = $vid;
140 $all[$if][
"file"] =
$file;
141 $all[$if][
"access"] = $access;
142 $all[$if][
"docs"] = $docs;
151 echo
"SetDocVaultIndex> $s\n";
156 if (!is_array($vt) || count($vt) == 0)
return;
159 if (
$test) $pref =
" [test] ";
163 foreach ($vt as $k => $v) {
166 $used = (is_array($v[
"docs"]) && count($v[
"docs"]) > 0 ?
true :
false);
168 loclog(
"$pref Suppress vault id $vid, filename $vname");
170 $vault->Destroy($vid);
171 $dvi->DeleteVaultId($vid);
173 }
else loclog(
" *** ERROR *** $vid used (referenced in doc(s))");
view($dbaccess, $vaultname, $filter=array())
cleanVault($dbaccess, $vaultname, $vt, $test)
Verify arguments for wsh programs.