示例#1
0
 /**
  */
 public static function ext_approveComment()
 {
     global $PIVOTX;
     $PIVOTX['session']->minLevel(PIVOTX_UL_NORMAL);
     $result = 'error';
     if (isset($_GET['comment']) && is_numeric($_GET['comment']) && $_GET['comment'] > 0) {
         $comment_uid = intval($_GET['comment']);
         include_once "modules/module_comments.php";
         approveComments(array($comment_uid));
         $result = 'ok';
     }
     echo $result;
 }
示例#2
0
/**
 * Display 'Comments' page.
 */
function pageComments()
{
    require_once dirname(__FILE__) . '/modules/module_comments.php';
    global $PIVOTX;
    // check if the user has the required userlevel to view this page.
    $PIVOTX['session']->minLevel(PIVOTX_UL_NORMAL);
    $PIVOTX['template']->assign('title', __('Comments'));
    if ($_GET['uid'] != "") {
        // Editing an entry.. Get it from the DB..
        $entry = $PIVOTX['db']->read_entry(intval($_GET['uid']));
        $comments = $entry['comments'];
        // Check if the user is allowed to edit this entry. It should either be his/her own
        // Entry, or the userlevel should be advanced.
        if ($PIVOTX['session']->currentUsername() != $entry['user']) {
            $PIVOTX['session']->minLevel(PIVOTX_UL_ADVANCED);
        }
        $heading = __('Edit or Delete Comments for Entry %number% - %editlink%');
        $heading = str_replace('%number%', $entry['uid'], $heading);
        $heading = str_replace('%editlink%', '<a href="index.php?page=entry&amp;uid=' . $entry['uid'] . '">' . $entry['title'] . '</a>', $heading);
        $PIVOTX['template']->assign('heading', $heading);
        if ($_GET['del'] != "") {
            // Perhaps delete a comment
            $PIVOTX['db']->delete_comment($_GET['del']);
            $PIVOTX['messages']->addMessage(__("The comment was deleted."));
            // Reread comments
            $entry = $PIVOTX['db']->read_entry(intval($_GET['uid']));
            $comments = $entry['comments'];
            // If we have to return to the dahboard or the overview screen, we do it here..
            if ($_GET['return'] == "overview") {
                $_GET['uid'] = '';
                // Clear the uid, so PivotX doesn't try to load the entry.
                pageComments();
                die;
            } else {
                if ($_GET['return'] == "dashboard") {
                    pageDashboard();
                    die;
                }
            }
        } else {
            if ($_GET['block'] != "") {
                // Or add the IP to the blocklist..
                $comment = $PIVOTX['db']->get_comment($_GET['block']);
                if (!empty($comment['ip'])) {
                    // Initialise the IP blocklist.
                    $blocklist = new IPBlock();
                    $blocklist->add($comment['ip'], $comment['name']);
                    $PIVOTX['messages']->addMessage(__("The IP-address has been added to the blocklist."));
                } else {
                    $PIVOTX['messages']->addMessage(__("The IP-address couldn't be added to the blocklist."));
                }
                // Reread comments
                $entry = $PIVOTX['db']->read_entry(intval($_GET['uid']));
                $comments = $entry['comments'];
            } else {
                if ($_GET['unblock'] != "") {
                    // Or remove the IP to the blocklist..
                    $comment = $PIVOTX['db']->get_comment($_GET['unblock']);
                    if (!empty($comment['ip'])) {
                        // Initialise the IP blocklist.
                        $blocklist = new IPBlock();
                        $blocklist->remove($comment['ip'], $comment['name']);
                        $PIVOTX['messages']->addMessage(__("The IP-address has been removed from the blocklist."));
                    } else {
                        $PIVOTX['messages']->addMessage(__("The IP-address couldn't be removed from the blocklist."));
                    }
                    // Reread comments
                    $entry = $PIVOTX['db']->read_entry(intval($_GET['uid']));
                    $comments = $entry['comments'];
                } elseif ($_GET['msg'] != "") {
                    $PIVOTX['messages']->addMessage($_GET['msg']);
                }
            }
        }
        switch ($_GET['return']) {
            case 'moderatecomments':
                pivotxAdminRedirect('moderatecomments');
                break;
        }
        // Check for blocked IPs
        $blocklist = new IPBlock();
        foreach ($comments as $key => $comment) {
            $comments[$key]['blocked'] = $blocklist->isBlocked($comment["ip"]);
        }
        $PIVOTX['template']->assign('moderating', false);
        $PIVOTX['template']->assign('uid', $_GET['uid']);
        $PIVOTX['template']->assign('entry', $entry);
        $PIVOTX['template']->assign('comments', $comments);
    } else {
        $PIVOTX['template']->assign('heading', __('Edit or Delete Latest Comments'));
        // If we don't get a specific uid, we show the comments that are in moderation, and the latest comments..
        if (isset($_POST['action_approve'])) {
            approveComments($_POST['checked']);
        } elseif (isset($_POST['action_delete'])) {
            deleteComments($_POST['checked']);
        }
        $latestcomments = $PIVOTX['db']->read_latestcomments(array('amount' => 10, 'cats' => '', 'count' => 15, 'moderated' => 1));
        // Since 'comments.tpl' displays if the entry is moderated or not
        // we must add this to the latest comments.
        foreach ($latestcomments as $key => $value) {
            $latestcomments[$key]['moderate'] = 0;
        }
        // Check for blocked IPs
        $blocklist = new IPBlock();
        foreach ($latestcomments as $key => $comment) {
            $latestcomments[$key]['blocked'] = $blocklist->isBlocked($comment["ip"]);
        }
        $PIVOTX['template']->assign('moderating', true);
        $PIVOTX['template']->assign('comments', $latestcomments);
    }
    // Allow only admins to block/unblock IP addresses..
    $currentuser = $PIVOTX['users']->getUser($PIVOTX['session']->currentUsername());
    $allowblock = $currentuser['userlevel'] >= PIVOTX_UL_ADMIN ? true : false;
    $PIVOTX['template']->assign('allowblock', $allowblock);
    $truncate = getDefault($PIVOTX['config']->get('comment_truncate'), 210);
    $PIVOTX['template']->assign('truncate', $truncate);
    renderTemplate('comments.tpl');
}
示例#3
0
        COM_redirect($_CONF['site_admin_url'] . '/index.php');
    }
}
// MAIN
$list = $_FINPUT->post('list', '');
if ($list === SUFFIX_COMMENTS) {
    $suffix = SUFFIX_COMMENTS;
} elseif ($list === SUFFIX_COMMENT_SUBMISSIONS) {
    $suffix = SUFFIX_COMMENT_SUBMISSIONS;
} else {
    $suffix = '';
}
$action = $_FINPUT->post('bulk_action' . $suffix, '');
switch ($action) {
    case 'bulk_approve':
        approveComments($suffix);
        break;
    case 'bulk_delete':
        deleteComments($suffix);
        break;
    case 'bulk_ban_user':
        banUsers($suffix);
        break;
    case 'bulk_ban_ip_address':
        banIpAddresses($suffix);
        break;
    default:
        // Do nothing here
        break;
}
$content = COM_showMessageFromParameter() . listComments();