$[New entry] 
"); SDV($CommentBoxFmt,"
$[Comment] 
$[Author] 
\n"); SDV($JournalDateFmt,'%d %B %Y'); SDV($JournalTimeFmt,'%H:%M'); SDV($JournalPattern,'/Journal$/'); SDV($DiaryPattern,'/Diary$/'); if ($action == 'comment') SDV($HandleActions['comment'],'HandleCommentPost'); else if ($action=='print' || $action=='publish') Markup('cbox',''.str_replace('\$Chrono','$1', FmtPageName(\$GLOBALS['CommentBoxFmt'],\$pagename))"); Markup('dbox',''.FmtPageName(\$GLOBALS['DiaryBoxFmt'],\$pagename)"); if (preg_match($JournalPattern,$pagename) || preg_match($DiaryPattern,$pagename)) { $GroupHeaderFmt .= '(:if auth edit:)(:diarybox:)(:if:)(:nl:)'; if (!PageExists($pagename)) $DefaultPageTextFmt = ''; } } function HandleCommentPost($pagename) { global $_POST,$JournalPattern,$DiaryPattern; global $AuthFunction, $oAuthFunction, $Author, $EnableBypassAuth, $HTMLStylesFmt; SDV($AuthFunction,'PmWikiAuth'); $oAuthFunction = $AuthFunction; $AuthFunction = 'BypassAuth'; if (preg_match($JournalPattern,$pagename)) HandleJournalPost($pagename); elseif (preg_match($DiaryPattern,$pagename)) HandleDiaryPost($pagename); else HandleMessagePost($pagename); HandleEdit($pagename); exit; } function FormatDateHeading($txt,$datefmt,$fmt) { return str_replace($txt,strftime($datefmt,time()),$fmt); } ## Journal entry function HandleJournalPost($pagename) { global $_POST, $JournalDateFmt, $JournalTimeFmt, $JPDateFmt, $JPTimeFmt, $Author; SDV($JPDateFmt,'!!!!$Date'); SDV($JPTimeFmt,"\n>>journalhead<<\n!!!!!– \$Time –\n"); SDV($JPItemStartFmt,">>journalitem<<\n"); SDV($JPItemEndFmt,""); $page = RetrieveAuthPage($pagename,"read"); if (@$_POST['author']=='') $Author = 'anon'; $date = FormatDateHeading('$Date',$JournalDateFmt,$JPDateFmt); $time = $date . FormatDateHeading('$Time',$JournalTimeFmt,$JPTimeFmt); $entry = $time.$JPItemStartFmt.$_POST['text'].$JPItemEndFmt; $_POST['text'] = (strstr(@$page['text'], $date)) ? str_replace($date, $entry, $page['text']) : "$entry\n>><<\n\n" . @$page['text']; } ## Diary entry function HandleDiaryPost($pagename) { global $_POST, $JournalDateFmt, $DPDateFmt, $DPItemFmt, $Author; SDV($DPDateFmt,'!!!!$Date'); SDV($DPItemStartFmt,"\n>>diaryitem<<\n"); SDV($DPItemEndFmt,""); $page = RetrieveAuthPage($pagename, "read"); if (@$_POST['author']=='') $Author = 'anon'; $now = time(); $date = FormatDateHeading('$Date',$JournalDateFmt,$DPDateFmt); $entry = $date.$DPItemStartFmt.$_POST['text'].$DPItemEndFmt; $_POST['text'] = (strstr(@$page['text'], $date)) ? str_replace($date, $entry, $page['text']) : "$entry\n>><<\n\n" . @$page['text']; } ## Comment entry function HandleMessagePost($pagename) { global $_POST,$JournalDateFmt,$JournalTimeFmt,$MPDateFmt,$MPTimeFmt, $MPItemFmt,$MPDateTimeFmt,$MultipleItemsPerDay,$Author; SDV($MPDateFmt,'!!!!$Date'); SDV($MPTimeFmt,"\n>>amessage<<\n!!!!!\$Author – [-at \$Time-] \n"); SDV($MPItemStartFmt,""); # was >>messageitem<<\n SDV($MPItemEndFmt,"\n>><<\n"); SDV($MPDateTimeFmt,"!!!!\$Date at \$Time by '''\$Author'''\n\n"); SDV($MultipleItemsPerDay,true); $name = @$_POST['author']; if (@$_POST['author']=='') $Author = 'anon'; # $name = ($name=='') ? 'anonymous' : '[[~' . $name . ']]'; # author links if ($name=='') $name = 'anonymous'; # no author links if ($MultipleItemsPerDay) { $date = FormatDateHeading('$Date',$JournalDateFmt,$MPDateFmt); $entry = str_replace('$Author',$name, FormatDateHeading('$Time',$JournalTimeFmt,$MPTimeFmt)); } else { $date = ''; $entry = FormatDateHeading('$Date',$JournalDateFmt, str_replace('$Author',$name, FormatDateHeading('$Time',$JournalTimeFmt,$MPDateTimeFmt))); } $entry.= $MPItemStartFmt.$_POST['text'].$MPItemEndFmt; $page = RetrieveAuthPage($pagename, "read"); $order= @$_POST['order']; if ($order=='') { if (strstr($page['text'],'(:commentbox:)')) { $pos = strpos($page['text'],'(:commentbox:)'); $len = strlen('(:commentbox:)'); $before = substr($page['text'],0,$pos+$len); $after = substr($page['text'],$pos+$len); } else { $before = ''; $after = $page['text']; } $entry = "$date$entry"; $after = ($MultipleItemsPerDay && strstr($after, $date)) ? str_replace($date, $entry, $after) : "\n$entry\n$after"; } else { $entry .= "\n"; if (strstr($page['text'],'(:commentboxchrono:)')) { $pos = strpos($page['text'],'(:commentboxchrono:)'); $before = substr($page['text'],0,$pos); $after = substr($page['text'],$pos); } else { $before = $page['text']; if ($before[strlen($before)-1]!='\n') $before .="\n"; $after = ''; } $before .= ($MultipleItemsPerDay && strstr($before, $date)) ? substr($entry,1) : "\n$date$entry"; } $_POST['text'] = "$before$after"; } function BypassAuth($pagename,$level,$authprompt=true) { global $AuthFunction,$oAuthFunction; if ($level=='edit') $AuthFunction = $oAuthFunction; return $oAuthFunction($pagename,"read",$authprompt); } ?>