예제 #1
0
파일: create.php 프로젝트: sebadorn/aestas3
/**
 * 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();
}
예제 #2
0
 public function testSetAuthorName()
 {
     $c = new ae_CommentModel();
     $c->setAuthorName('  Ein  Bär ');
     $this->assertEquals($c->getAuthorName(), 'Ein  Bär');
 }
예제 #3
0
if (mb_strlen($url) > 0 && !preg_match('/^(http|ftp)s?:\\/\\//i', $url)) {
    $url = 'http://' . $url;
}
$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;