changed git call from https to git readonly
[atutor.git] / mods / wiki / tools / t_remove.php
1 <?php
2   include("t_config.php");
3 ?>
4 <html>
5 <head>
6  <title>delete ewiki pages</title>
7  <link rel="stylesheet" type="text/css" href="t_config.css">
8 </head>
9 <body bgcolor="#ffffff" text="#000000">
10 <h1>delete pages from DB</h1>
11 <?php
12
13
14   if (empty($_REQUEST["remove"])) {
15
16      echo "
17         Note that only <b>unreferenced pages</b> will be listed here. And
18         because the ewiki engine itself does only limited testing if a page is
19         referenced it may miss some of them here.<br>
20         If you however empty a page first, it will get listed here too.
21         Various other database diagnostics are made as well.<br><br>\n";
22
23
24      $result = ewiki_db::GETALL(array("version"));
25      
26      $selected = array();
27
28      if (@$_REQUEST["listall"]) {
29         while ($row = $result->get()) {
30            $selected[$row["id"]] = "listall <br>";
31         }
32      }
33      else
34      while ($page = $result->get()) {
35
36         $id = $page["id"];
37         if (!strlen($id)) { continue; }
38         $page = ewiki_db::GET($id);
39         $flags = $page["flags"];
40
41         if (!strlen(trim(($page["content"])))) {
42            @$selected[$id] .= "EMPTY <br>";
43         }
44
45         $res2 = ewiki_db::SEARCH("content", $id);
46         if ($res2 && $res2->count()) {
47            $check2 = 1;
48            while ($row = $res2->get()) {
49               $check = ewiki_db::GET($row["id"]);
50               $check = strtolower($check["content"]);
51               $check2 &= (strpos($check, strtolower($id)) !== false);
52 #echo "rc({$row['id']})==>($id): $check2 <br>";
53            }
54            $check = $check2;
55         }
56         if (empty($check)) {
57            @$selected[$id] .= "UNREFerenced <br>";
58         }
59
60         if ($flags & EWIKI_DB_F_DISABLED) {
61            @$selected[$id] .= "disabled_page <br>";
62         }
63
64         if (($flags & 3) == 3) {
65            @$selected[$id] .= "errFLAGS(bin<b>+</b>txt) <br>";
66         }
67
68         if (!($flags & 3)) {
69            @$selected[$id] .= "errFLAGS(notype) <br>";
70         }
71
72         if ($flags & EWIKI_DB_F_HTML) {
73            @$selected[$id] .= "warning(HTML) <br>";
74         }
75
76         if (($flags & EWIKI_DB_F_READONLY) && !($flags & EWIKI_DB_F_BINARY)) {
77            @$selected[$id] .= "readonly <br>";
78         }
79
80         if (($flags & EWIKI_DB_F_READONLY) && ($flags & EWIKI_DB_F_WRITEABLE)) {
81            @$selected[$id] .= "errFLAGS(readonly<b>+</b>writable) <br>";
82         }
83
84         if (strlen($page["content"]) >= 65536) {
85            @$selected[$id] .= "size &gt;= 64K <br>";
86         }
87
88         if (preg_match("/\nDelete(d?Page|Me|This)\n/", $page["refs"])) {
89            @$selected[$id] .= "<tt>DeleteMe</tt> <br>";
90         }
91
92      }
93      
94
95
96      echo '<form action="t_remove.php" method="POST" enctype="multipart/form-data">';
97      echo '<input type="submit" name="listall" value="listall">';
98      echo '<table class="list" border="0" cellspacing="3" cellpadding="2" width="500">' . "\n";
99      echo "<tr><th>page name</th><th>error / reason</th></tr>\n";
100
101      foreach ($selected as $id => $reason) {
102         
103         echo '<tr><td>';
104
105         #-- checkbox
106         echo '<input type="checkbox" value="1" name="remove[' . rawurlencode($id) . ']">&nbsp;&nbsp;';
107
108         #-- link & id
109         if (strpos($id, EWIKI_IDF_INTERNAL) === false) {
110            echo '<a href="' . ewiki_script("", $id) . '">';
111         }
112         else {
113            echo '<a href="' . ewiki_script_binary("", $id) . '">';
114         }
115         echo htmlentities($id) . '</a></td>';
116
117         #-- print reason
118         echo '<td>' . $reason . "</td>";
119
120         echo "</tr>\n";
121
122      }
123
124      echo '</table><br><input type="submit" value="&nbsp; delete selected pages &nbsp;"></form>';
125
126   }
127   else {
128
129      echo "<ul>\n";
130      foreach ($_REQUEST["remove"] as $id => $uu) {
131
132         $id = rawurldecode($id);
133
134         echo "<li>purging »".htmlentities($id)."«...</li>";
135
136         $data = ewiki_db::GET($id);
137         for ($version=1; $version<=$data["version"]; $version++) {
138
139            ewiki_db::delete($id, $version);
140
141         }
142         
143      }
144      echo "</ul>\n";
145
146   }
147
148 ?>