changed git call from https to git readonly
[atutor.git] / mods / wiki / tools / cron.d / S63deletedpage.php
1 <?php
2 /*
3    Any page that has "DeletedPage" as content will be removed if that wasn't
4    changed in a given timeframe (typically a month or two weeks). If a page
5    is completely empty that will also work. Other aliases to engage this
6    action are:
7     - "deleted" (or "DeletedPage")
8     - "DeletePage" or "delete"
9     - simply "trash" or a link to "TrashCan"
10     - "RemovePage", "remove"
11     - "RemovedPage", "removed"
12    
13    This feature is also known as MeatBall:KeptPages.
14 */
15
16
17 // define("DELETEPAGES", 1);
18
19
20 #-- proceed
21 if (defined("DELETEPAGES") && DELETEPAGES && $keptpages) {
22
23    echo "[$cron]: Scanning for pages to kill...\n";
24
25    $triggers = array(
26       "delete",
27       "deleted",
28       "del",
29       "remove",
30       "removed",
31       "kill",
32       "unlink",
33       "unlink()",
34       "unlink();",
35       "trash",
36       "rm",
37       "rm -f",
38       "DeletePage",
39       "DeletedPage",
40       "RemovePage",
41       "KillPage",
42       "UnlinkPage",
43       "TrashCan",
44    );
45
46    #-- list all
47    $all = ewiki_db::GETALL("id", "version", "lastmodified");
48    while ($row = $all->get()) {
49    
50       #-- check that it wasn't modified lately
51       if (time() >= $row["lastmodified"] + $keptpages) {
52
53          #-- check page content for trigger words
54          $id = $row["id"];
55          $row = ewiki_db::GET($id);
56          $text = strtolower(trim($row["content"]));
57          $refs = trim($row["refs"]);
58          if (in_array($text, $triggers)
59          or ewiki_in_array($refs, $triggers))
60          {
61             #-- purge it, no mercy!!!!!
62             echo "   $id";
63             for ($v=$row["version"]; $v>=1; $v--) {
64                if (ewiki_db::GET($id, $v)) {
65                   echo " [$v]";
66                   ewiki_db::DELETE($id, $v);
67                }
68             }
69             echo "\n";
70          }
71       }
72       
73    }
74 }
75
76
77 ?>