public function testSetAuthorUrl() { $c = new ae_CommentModel(); $c->setAuthorUrl('http://example.com:8080'); $this->assertEquals($c->getAuthorUrl(), 'http://example.com:8080'); $c->setAuthorUrl(''); $this->assertTrue($c->getAuthorUrl() === ''); $c->setAuthorUrl('https://127.0.0.1'); $this->assertEquals($c->getAuthorUrl(), 'https://127.0.0.1'); $this->setExpectedException('Exception'); $c->setAuthorUrl('example.com'); }
/** * Update the comment. * @return {int} ID of the comment. */ function updateComment() { if (!isset($_POST['edit-id'], $_POST['comment-author-name'], $_POST['comment-author-email'], $_POST['comment-author-url'], $_POST['comment-content'], $_POST['comment-user']) || $_POST['comment-content'] === '') { header('Location: ../admin.php?error=missing_data_for_comment'); exit; } $content = nl2br($_POST['comment-content']); $comment = new ae_CommentModel(); $comment->load($_POST['edit-id']); $comment->setAuthorName($_POST['comment-author-name']); $comment->setAuthorEmail($_POST['comment-author-email']); $comment->setAuthorUrl($_POST['comment-author-url']); $comment->setContent($content); $comment->setUserId($_POST['comment-user']); if (!$comment->save()) { return FALSE; } return $comment->getId(); }
} $content = ae_Security::sanitizeHTML(trim($_POST['comment-content'])); $content = nl2br($content); $co = new ae_CommentModel(); // Bad errors try { $co->setPostId($_POST['comment-post']); } catch (Exception $exc) { header('Location: ../?p=' . $_POST['comment-post'] . '&error=invalid_data#comment-form'); exit; } // Forgivable errors with default values for fallback try { $co->setAuthorName($_POST['comment-author-name']); $co->setAuthorEmail($_POST['comment-author-email']); $co->setAuthorUrl($url); $co->setAuthorIp($_SERVER['REMOTE_ADDR']); $co->setContent($content); $co->setStatus(COMMENT_DEFAULT_STATUS); if (ae_Security::isLoggedIn()) { $co->setUserId(ae_Security::getCurrentUserId()); } $filter = array('LIMIT' => FALSE, 'WHERE' => 'cf_status = :status'); $params = array(':status' => ae_CommentfilterModel::STATUS_ACTIVE); $cfList = new ae_CommentfilterList($filter, $params, FALSE); $keep = $cfList->applyFilters($co); if (!$keep) { header('Location: ../?p=' . $_POST['comment-post'] . '&error=comment_deleted_by_filter'); exit; } $co->save();