3 Everybody who leaves a mail address on the "RecentNotify" page, will
4 get a summary of all made edits, once in a week (configured to 8 days
8 define("RECENTNOTIFY", "RecentNotify"); // special page name (w/ subscribers)
9 define("RECENTNOTIFY_DAYS", 8); // in days
13 if (RECENTNOTIFY_DAYS && ($data = ewiki_db::GET(RECENTNOTIFY))) {
14 echo "[$cron]: checking for " . RECENTNOTIFY . " subscribers\n";
16 #-- look up subscribers
17 ewiki_scan_wikiwords($data["content"], $uu, $_strip_email=0);
18 $subscribers = array();
19 if ($uu) foreach ($uu as $str=>$x) {
20 if (strpos($str, "@")) {
21 if (strpos($str, "notify:")!==false) {
22 $str = substr($str, strpos($str, ":"));
24 $subscribers[] = $str;
28 #-- only calc the RC if we have at least one interested
30 echo "[$cron]: ".count($subscribers)." listed (".implode(", ", $subscribers).")\n";
31 $min_time = time() - RECENTNOTIFY_DAYS * 24 * 3600;
36 #-- find pages changed in given timeframe
37 $all = ewiki_db::GETALL(array("id", "version", "flags", "lastmodified"));
38 while ($row = $all->get(0, 0x137f)) {
40 if ($row["lastmodified"] >= $min_time) {
41 $rc[$row["id"]] = $row["lastmodified"];
42 $vers[$row["id"]] = $row["version"];
46 #-- go through rc list
47 echo "[$cron]: generating RC list\n";
54 list($id, $lm) = each($rc);
59 $row = ewiki_db::GET($id, $ver);
60 $m_ver = $row["version"];
61 ($m_log = $row["meta"]["log"]) and ($m_log = " . [{$m_log}] . .");
62 $m_author = $row["author"];
63 $m_ua = $row["meta"]["user-agent"];
64 $m_time = strftime("%H:%M", $lm);
66 if ($row["flags"] & EWIKI_DB_F_MINOR) {
67 $m_flags .= " MINOR EDIT";
69 if ($row["flags"] & EWIKI_DB_F_APPENDONLY) {
70 $m_flags .= " (append-only)";
72 if ($row["flags"] & EWIKI_DB_F_HIDDEN) {
73 $m_flags .= " (hidden page)";
75 $datestr = strftime("%Y-%m-%d, %a", $lm);
76 if ($lastdatestr != $datestr) {
77 $lastdatestr = $datestr;
78 $mail .= "\n$datestr\n";
80 $mail .= "ยท {$id} - [{$m_ver}]{$m_flags} {$m_time} . . .{$m_log} by {$m_author} / {$m_ua}\n";
82 #-- check previous version of this page
83 if (($ver--) && ($row = ewiki_db::GET($id, $ver))) {
84 if ($row["lastmodified"] >= $min_time) {
85 $vers[$id] = $row["version"];
86 $rc[$id] = $row["lastmodified"];
95 $subj = RECENTNOTIFY ." on ". EWIKI_NAME;
96 $to = implode(", ", $subscribers);
97 $mail = "This is the full list of latest changes on " . EWIKI_NAME . ".\n"
98 . ewiki_script_url("", EWIKI_PAGE_INDEX) . "\n"
99 . "Unsubscribe yourself on " . ewiki_script_url("edit", RECENTNOTIFY) . "\n"
102 . "\n\n-- \nThere is no Web like WikiWikiWeb.\n";
103 mail($to, $subj, $mail);