/** * Get the content of the filter target. * @param {string} $cfTarget Target identifier. * @param {ae_CommentModel} $co The comment. * @return {string} Target content. */ protected static function getTarget($cfTarget, ae_CommentModel $co) { switch ($cfTarget) { case ae_CommentfilterModel::TARGET_CONTENT: $target = $co->getContent(); break; case ae_CommentfilterModel::TARGET_EMAIL: $target = $co->getAuthorEmail(); break; case ae_CommentfilterModel::TARGET_IP: $target = $co->getAuthorIp(); break; case ae_CommentfilterModel::TARGET_NAME: $target = $co->getAuthorName(); break; case ae_CommentfilterModel::TARGET_URL: $target = $co->getAuthorUrl(); break; case ae_CommentfilterModel::TARGET_USERID: $target = $co->getUserId(); break; default: $target = NULL; } return $target; }
} else { $filter['WHERE'] = 'po_status != "trash"'; } $list = new ae_PostList($filter); } else { if (isset($_GET['user'])) { $area = 'user'; $areaName = 'Users'; if (ae_UserModel::isValidStatus($status)) { $filter['WHERE'] = 'u_status = "' . $status . '"'; } $list = new ae_UserList($filter); } else { $area = 'comment'; $areaName = 'Comments'; if (ae_CommentModel::isValidStatus($status)) { $filter['WHERE'] = 'co_status = "' . $status . '"'; } else { $filter['WHERE'] = 'co_status != "trash" AND co_status != "spam"'; } $list = new ae_CommentList($filter); } } } } $urlBasis = '?area=manage&offset=' . $pageOffset . '&' . $area; // pagination $numPages = ceil($list->getTotalNumItems() / $itemsPerPage); $queryStr = preg_replace('/[?&]offset=?[0-9]*/i', '', $_SERVER['QUERY_STRING']); $linkBase = 'admin.php?' . htmlspecialchars($queryStr) . '&offset='; ?>
public function testSetUserId() { $c = new ae_CommentModel(); $c->setUserId(4); $this->assertTrue($c->getUserId() === 4); $this->setExpectedException('Exception'); $c->setUserId(-1); }
$status = $_POST['bulk-status-change']; $mainArea = 'manage'; switch ($_POST['area']) { case 'category': $isValidStatus = $status == 'delete' ? TRUE : ae_CategoryModel::isValidStatus($status); $modelName = 'ae_CategoryModel'; $preDelete = ae_CategoryModel::STATUS_TRASH; break; case 'cofilter': $isValidStatus = $status == 'delete' ? TRUE : ae_CommentfilterModel::isValidStatus($status); $mainArea = 'settings'; $modelName = 'ae_CommentfilterModel'; $preDelete = ae_CommentfilterModel::STATUS_INACTIVE; break; case 'comment': $isValidStatus = $status == 'delete' ? TRUE : ae_CommentModel::isValidStatus($status); $modelName = 'ae_CommentModel'; $preDelete = ae_CommentModel::STATUS_TRASH; break; case 'media': $isValidStatus = $status == 'delete' ? TRUE : ae_MediaModel::isValidStatus($status); $mainArea = 'media'; $modelName = 'ae_MediaModel'; $preDelete = ae_MediaModel::STATUS_TRASH; break; case 'page': $isValidStatus = $status == 'delete' ? TRUE : ae_PageModel::isValidStatus($status); $modelName = 'ae_PageModel'; $preDelete = ae_PageModel::STATUS_TRASH; break; case 'post':
<?php if ($area == 'category') { $statuses = ae_CategoryModel::listStatuses(); } else { if ($area == 'cofilter') { $statuses = ae_CommentfilterModel::listStatuses(); } else { if ($area == 'comment') { $statuses = ae_CommentModel::listStatuses(); } else { if ($area == 'media') { $statuses = ae_MediaModel::listStatuses(); } else { if ($area == 'page') { $statuses = ae_PageModel::listStatuses(); } else { if ($area == 'post') { $statuses = ae_PostModel::listStatuses(); } else { if ($area == 'user') { $statuses = ae_UserModel::listStatuses(); } } } } } } } $select = ae_Forms::selectStatus('bulk-status-change', $statuses); if (isset($_GET['status']) && $_GET['status'] == 'trash') {
if (isset($_GET['category']) && ae_Validate::id($_GET['category'])) { $editArea = 'Category'; $areaId = 'category'; $model = new ae_CategoryModel(); $model->load($_GET['category']); } else { if (isset($_GET['cofilter']) && ae_Validate::id($_GET['cofilter'])) { $editArea = 'Comment filter'; $areaId = 'cofilter'; $model = new ae_CommentfilterModel(); $model->load($_GET['cofilter']); } else { if (isset($_GET['comment']) && ae_Validate::id($_GET['comment'])) { $editArea = 'Comment'; $areaId = 'comment'; $model = new ae_CommentModel(); $model->load($_GET['comment']); } else { if (isset($_GET['media']) && ae_Validate::id($_GET['media'])) { $editArea = 'Media'; $areaId = 'media'; $model = new ae_MediaModel(); $model->load($_GET['media']); } else { if (isset($_GET['page']) && ae_Validate::id($_GET['page'])) { $editArea = 'Page'; $areaId = 'page'; $model = new ae_PageModel(); $model->load($_GET['page']); } else { if (isset($_GET['post']) && ae_Validate::id($_GET['post'])) {
/** * 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(); }
require_once '../core/config.php'; if (isset($_POST['comment-do-not-fill']) && $_POST['comment-do-not-fill'] != '' || isset($_POST['comment-content-do-not-fill']) && $_POST['comment-content-do-not-fill'] != '' || !isset($_POST['comment-post'])) { header('Location: ../'); exit; } if (!isset($_POST['comment-author-name'], $_POST['comment-author-email'], $_POST['comment-author-url'], $_POST['comment-content'], $_POST['comment-post']) || mb_strlen(trim($_POST['comment-content'])) == 0) { header('Location: ../?p=' . $_POST['comment-post'] . '&error=missing_data#comment-form'); exit; } $url = trim($_POST['comment-author-url']); 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);