]*(notify[:=].*)/m', $npage['text'], $nlist); $nlist = array_merge((array)@$NotifyList, (array)@$nlist[1]); if (!$nlist) return; ## make sure other processes are locked out Lock(2); ## let's load the current .notifylist table $nfile = FmtPageName($NotifyFile, $pagename); $nfp = @fopen($nfile, 'r'); if ($nfp) { ## get our current squelch and delay timestamps clearstatcache(); $sz = filesize($nfile); list($nextevent, $firstpost) = explode(' ', rtrim(fgets($nfp, $sz))); ## restore our notify array $notify = unserialize(fgets($nfp, $sz)); fclose($nfp); } if (!is_array($notify)) $notify = array(); ## if this is for a newly posted page, get its information if ($IsPagePosted) { $page = ReadPage($pagename, READPAGE_CURRENT); $FmtV['$PostTime'] = strftime($NotifyTimeFmt, $Now); $item = urlencode(FmtPageName($NotifyItemFmt, $pagename)); if ($firstpost < 1) $firstpost = $Now; } foreach($nlist as $n) { $opt = ParseArgs($n); $mailto = preg_split('/[\s,]+/', $opt['notify']); if (!$mailto) continue; if ($opt['squelch']) foreach($mailto as $m) $squelch[$m] = $opt['squelch']; if (!$IsPagePosted) continue; if ($opt['link']) { $link = MakePageName($pagename, $opt['link']); if (!preg_match("/(^|,)$link(,|$)/i", $page['targets'])) continue; } $pats = @(array)$SearchPatterns[$opt['list']]; if ($opt['group']) $pats[] = FixGlob($opt['group'], '$1$2.*'); if ($opt['name']) $pats[] = FixGlob($opt['name'], '$1*.$2'); if ($pats && !MatchPageNames($pagename, $pats)) continue; if ($opt['trail']) { $trail = ReadTrail($pagename, $opt['trail']); for ($i=0; $i= count($trail)) continue; } foreach($mailto as $m) { $notify[$m][] = $item; } } $nnow = time(); if ($nnow < $firstpost + $NotifyDelay) $nextevent = $firstpost + $NotifyDelay; else { $firstpost = 0; $nextevent = $nnow + 86400; $mailto = array_keys($notify); $subject = FmtPageName($NotifySubjectFmt, $pagename); if(preg_match("/[^\x20-\x7E]/", $subject)) $subject = strtoupper("=?$Charset?B?"). base64_encode($subject)."?="; $body = FmtPageName($NotifyBodyFmt, $pagename); foreach ($mailto as $m) { $msquelch = @$notify[$m]['lastmail'] + ((@$squelch[$m]) ? $squelch[$m] : $NotifySquelch); if ($nnow < $msquelch) { if ($msquelch < $nextevent && count($notify[$m])>1) $nextevent = $msquelch; continue; } unset($notify[$m]['lastmail']); if (!$notify[$m]) { unset($notify[$m]); continue; } $mbody = str_replace('$NotifyItems', urldecode(implode("\n", $notify[$m])), $body); if ($NotifyParameters) mail($m, $subject, $mbody, $NotifyHeaders, $NotifyParameters); else mail($m, $subject, $mbody, $NotifyHeaders); $notify[$m] = array('lastmail' => $nnow); } } ## save the updated notify status $nfp = @fopen($nfile, "w"); if ($nfp) { fputs($nfp, "$nextevent $firstpost\n"); fputs($nfp, serialize($notify) . "\n"); fclose($nfp); } Lock(0); return true; }