";
- echo "
$year_posted/$month_posted/$day_posted/$title
";
- echo $entry['text'];
+ $this->display_note();
+ if ($this->comments_enabled) {
+ $this->display_comments();
+ $this->display_comment_form();
+ }
$this->write_navigation();
$this->display_close();
}
- private function write_navigation() {
+ private function verify() {
+ require_once('includes/recaptchalib.php');
echo "
";
- echo "
";
- echo "
";
- echo "notes/";
- echo "
";
- echo "
";
+ $resp = recaptcha_check_answer ($this->recaptcha_privatekey,
+ $_SERVER["REMOTE_ADDR"],
+ $_POST["recaptcha_challenge_field"],
+ $_POST["recaptcha_response_field"]);
+ if (!$resp->is_valid) {
+ $this->failed_captcha = true;
+ } else {
+ $sql = ("INSERT INTO comments (date_posted, author,
+ email, text, note)
+ VALUES(NOW(), ?, ?, ?, ?)");
+ $stmt = $this->db->prepare($sql);
+ // Checks are needed here (no blank text,
+ // and a default author / email need to be set
+ $stmt->bind_param('ssss',
+ htmlspecialchars($_POST['author']),
+ htmlspecialchars($_POST['email']),
+ htmlspecialchars($_POST['text']),
+ $this->id);
+ $stmt->execute();
+ }
+ }
+
+ private function display_note() {
+ echo "
";
+ echo "
$this->year_posted/$this->month_posted/$this->day_posted/$this->title
";
+ echo $this->text;
+ }
+
+ private function write_navigation() {
+ echo <<
+
+
+END_OF_NAVIGATION;
+ if ($this->failed_captcha) {
+ echo "sorry, reCAPTCHA said you're not human.
";
+ }
+ if (!$this->comments_enabled) {
+ $this->display_comment_link();
+ }
+ echo <<notes/
+
+
+END_OF_NAVIGATION;
+ }
+
+ private function display_comment_link() {
+ if ($this->number_of_comments > 0) {
+ $anchor_text = "comments ($this->number_of_comments)";
+ } else {
+ $anchor_text = "comment?";
+ }
+ if (substr($this->url, (strlen($this->url)-1), strlen($this->url)) == '/') {
+ $url = $this->url . 'comments/';
+ } else {
+ $url = $this->url . '/comments/';
+ }
+ echo "";
+ }
+
+ private function display_comments() {
+ echo "";
+ }
+
+ private function display_comment_form() {
+ $publickey = $this->recaptcha_publickey;
+ echo <<
+function showRecaptcha(element) {
+Recaptcha.create("$publickey",
+ "recaptcha_div",
+ {
+ theme : 'custom',
+ custom_theme_widget: 'recaptcha_widget',
+ callback: Recaptcha.focus_response_field
+ });
+}
+
+END_CAPTCHA_STYLE;
+ require_once('includes/recaptchalib.php');
+ // Trailing slash is necessary for reloads to work
+ $url = $this->url . "verify";
+ echo "
+
+END_OF_FORM;
}
}
@@ -437,7 +595,11 @@ switch (cms::determine_type()) {
$project->display();
break;
case "note":
- $note = new note;
+ if (isset($_GET['comments'])) {
+ $note = new note($comments_enabled = true);
+ } else {
+ $note = new note;
+ }
$note->display();
break;
case "page":