function showGuestBook($id, $path, $email, $captcha = TRUE, $direct_approval = TRUE) { $gb = new imGuestBook($path, $email, $direct_approval); if (isset($_GET['abuse'])) { $gb->setAbuse($id, $_GET['abuse'], 1); } if (isset($_POST['name']) && isset($_POST['email']) && isset($_POST['body']) && isset($_POST['post_id']) && $_POST['post_id'] == $id) { $result = $gb->addComment($id, $_POST['name'], $_POST['email'], $_POST['url'], $_POST['body']); if ($result === 0) { echo "<script type=\"text/javascript\">location.href='" . $_SERVER['PHP_SELF'] . "?ok_" . $id . "=1';</script>"; } else { echo "<script type=\"text/javascript\">location.href='" . $_SERVER['PHP_SELF'] . "?err_" . $id . "=" . $result . "';</script>"; } } else { $gb->showGuestBook($id, $captcha); } }