function HandleApprove($pagename) { global $ApproveUrlPattern, $WhiteUrlPatterns, $ApprovedUrlPagesFmt, $action; Lock(2); $page = ReadPage($pagename); $text = preg_replace('/[()]/', '', $page['text']); preg_match_all("/{$ApproveUrlPattern}/", $text, $match); ReadApprovedUrls($pagename); $addpat = array(); foreach ($match[0] as $a) { foreach ((array) $WhiteUrlPatterns as $pat) { if (preg_match("!^{$pat}(/|\$)!", $a)) { continue 2; } } if ($action == 'approvesites') { $a = preg_replace("!^([^:]+://[^/]+).*\$!", '$1', $a); } $addpat[] = $a; } if (count($addpat) > 0) { $aname = FmtPageName($ApprovedUrlPagesFmt[0], $pagename); $apage = ReadPage($aname, ''); $new = $apage; if (substr($new['text'], -1, 1) != "\n") { $new['text'] .= "\n"; } foreach ($addpat as $pat) { $new['text'] .= " {$pat}\n"; } $_REQUEST['post'] = 'y'; PostPage($aname, $apage, $new); } Redirect($pagename); }
function HandleApprove($pagename, $auth='edit') { global $ApproveUrlPattern,$WhiteUrlPatterns,$ApprovedUrlPagesFmt,$action; Lock(2); $page = ReadPage($pagename); $text = preg_replace('/[()]/','',$page['text']); preg_match_all("/$ApproveUrlPattern/",$text,$match); ReadApprovedUrls($pagename); $addpat = array(); foreach($match[0] as $a) { if ($action=='approvesites') $a=preg_replace("!^([^:]+://[^/]+).*$!",'$1',$a); $addpat[] = $a; } if (count($addpat)>0) { $aname = FmtPageName($ApprovedUrlPagesFmt[0],$pagename); $apage = RetrieveAuthPage($aname, $auth); if (!$apage) Abort("?cannot edit $aname"); $new = $apage; if (substr($new['text'],-1,1)!="\n") $new['text'].="\n"; foreach($addpat as $a) { foreach((array)$WhiteUrlPatterns as $pat) if (preg_match("!^$pat(/|$)!i",$a)) continue 2; $urlp = preg_quote($a,'!'); $WhiteUrlPatterns[] = $urlp; $new['text'].=" $a\n"; } $_POST['post'] = 'y'; PostPage($aname,$apage,$new); } Redirect($pagename); }