$[New entry]
"); SDV($CommentBoxFmt,"
$[Comment]
$[Author]
"); 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 .= '(:diarybox:)(:nl:)'; } function HandleCommentPost($pagename) { global $_POST,$JournalPattern,$DiaryPattern; global $AuthFunction,$oAuthFunction; SDV($AuthFunction,'BasicAuth'); $oAuthFunction = $AuthFunction; $AuthFunction = 'BypassAuth'; # $_POST['text'] = IndentParagraphs(stripmagic($_POST['text'])); if (preg_match($JournalPattern,$pagename)) HandleJournalPost($pagename); elseif (preg_match($DiaryPattern,$pagename)) HandleDiaryPost($pagename); else HandleMessagePost($pagename); HandleEdit($pagename); exit; } ## This function handles the behaviour and conversion of a Journal entry function HandleJournalPost($pagename) { global $_POST, $JournalDateFmt, $JournalTimeFmt; $page = RetrieveAuthPage($pagename, "read"); $now = time(); $date = "!!!!!".strftime($JournalDateFmt,$now); $time = "'''".strftime($JournalTimeFmt,$now)." :''' "; $repl = "$date\n->$time" . $_POST['text']; if (strstr(@$page['text'], $date)) $_POST['text'] = str_replace($date, $repl, $page['text']); else $_POST['text'] = $repl . "\n\n" . @$page['text']; } ## This function handles the behaviour and conversion of a Diary entry function HandleDiaryPost($pagename) { global $_POST, $JournalDateFmt; $page = RetrieveAuthPage($pagename, "read"); $now = time(); $date = "!!!!!".strftime($JournalDateFmt,$now)."\n"; $repl = $date . $_POST['text'] . "\n"; if (strstr(@$page['text'], $date)) $_POST['text'] = str_replace($date, $repl . "*", $page['text']); else $_POST['text'] = $repl . "\n\n" . @$page['text']; } ## This function handles the behaviour and conversion of a Comment entry function HandleMessagePost($pagename) { global $_POST, $JournalDateFmt, $JournalTimeFmt; $name = @$_POST['author']; $name = ($name=='') ? 'anonymous' : '[[~' . $name . ']]'; $now = time(); $date = "!!!!!".strftime($JournalDateFmt,$now); $time = "'''".strftime($JournalTimeFmt,$now). "''' - '''''$name''''' ''':''' "; $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']; } $repl = "\n$date\n$time" . $_POST['text'] . "\n----"; if (strstr($after, $date)) { $after = str_replace($date, $repl, $after); } else { $after = "$repl$after"; } $_POST['text'] = "$before$after"; } else { 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 = ''; } if (strstr($before, $date)) { $repl = "$time"; } else { $repl = "\n$date\n$time"; } $repl .= $_POST['text'] . "\n----"; $_POST['text'] = "$before$repl$after"; } } function IndentParagraphs($text) { $text = preg_replace("/\n([[:alnum:]])/","\n->$1",$text); $text = preg_replace("/\n([#*])([^#*])/","\n$1$1$2",$text); return preg_replace("/\n:([^:]+):/","\n::$1:",$text); } function BypassAuth($pagename,$level,$authprompt=true) { global $AuthFunction,$oAuthFunction; if ($level=='edit') $AuthFunction = $oAuthFunction; return $oAuthFunction($pagename,"read",$authprompt); } ?>