public function testSetAuthorIp() { $c = new ae_CommentModel(); $c->setAuthorIp('127.0.0.1'); $this->assertEquals($c->getAuthorIp(), '127.0.0.1'); $c->setAuthorIp('FE80:0000:0000:0000:0202:B3FF:FE1E:8329'); $this->assertEquals($c->getAuthorIp(), 'FE80:0000:0000:0000:0202:B3FF:FE1E:8329'); $c->setAuthorIp('FE80::0202:B3FF:FE1E:8329'); $this->assertEquals($c->getAuthorIp(), 'FE80::0202:B3FF:FE1E:8329'); $this->setExpectedException('Exception'); $c->setAuthorIp('127.0.0.1.0'); }
$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(); } catch (Exception $exc) {