disable comments $NB_COM_CLOSE = 1728000; # (20 days) number of seconds after which comments are closed $NB_COM_MAX_SIZE = 2000; # max number of chars in a comment $NB_COM_AUTHOR_MAX_SIZE = 100; # max number of chars in a name $NB_COM_URL_MAX_SIZE = 100; # max number of chars in an url $NB_COM_EMAIL_MAX_SIZE = 100; # max number of chars in an url $NB_COM_EMAIL_DEFAULT = "nobody@example.net"; $o_umask = umask(0); # for mkdir() # Display the comment form function form($id) { global $NB_COM; $me = $_SERVER['PHP_SELF']; $author = $_POST['author']; $url = $_POST['url']; $email = $_POST['email']; $com = stripslashes($_POST['comment']); $epoch = id2epoch($id); if ($NB_COM == 0) { echo "
"; echo ''; echo $com['date']; echo ''; echo '
$1", $text); # [code] - code examples $text = preg_replace("/\[code\]((.|\n)*?)\[\/code\]/", "$1
", $text); # [quote] - quote something $text = preg_replace("/\[quote\]((.|\n)*?)\[\/quote\]/", " ", $text); # [url]link[/url] $text = preg_replace("/\[url\]((.|\n)*?)\[\/url\]/", "$1", $text); # [url=domain]linkname[/url] $text = preg_replace("/\[url=(.*)\]((.|\n)*?)\[\/url\]/", "$2", $text); $text = nl2br($text); return $text; } # convert an article ID to epoch function id2epoch($id) { $m = array(); preg_match("/e(.*?)-(.*?)-(.*?)T(.*?)_(.*?)_(.*?)\.txt/", $id, $m); return strtotime($m[1] . "-" . $m[2] . "-" . $m[3] . " " . $m[4] . ":" . $m[5] . ":" . $m[6]); } # return FALSE when comments are OK, otherwise TRUE function closed($t) { global $NB_COM_CLOSE; if (time() - $t > $NB_COM_CLOSE) { return TRUE; } return FALSE; } # return a comment string in HTML # the string is with strike through if # commenting is closed otherwise it is # normal function commentstr($id, $permalink) { global $NB_COM; $epoch = id2epoch($id); $link = ""; if ($NB_COM != 1) { return "$linkComments: "; } if (closed($epoch)) { return "$linkComments: "; } else { return "${link}Comments: "; } } # not actually part of the comment system, but more of a # nb plugin. This adds a sidetitle with the most recent # comments, and links to the articles # show the 10 articles with the most recent articles function recent_comments() { global $NB_COM_BASE; global $NB_BASE; $comments = array(); $match = array(); $count = array(); foreach (glob("$NB_COM_BASE/*") as $artid) { $i = 0; foreach (glob("$artid/ok/*") as $com) { $comments[basename($com)] = basename($artid); $i++; } $count[basename($artid)] = $i; } arsort($comments); echo <<