Beispiel #1
0
function do_like()
{
    global $vbulletin, $postinfo, $threadinfo, $forumid;
    @(require_once DIR . '/includes/functions_post_thanks.php');
    $vbulletin->input->clean_array_gpc('r', array('postid' => TYPE_INT));
    if (!function_exists('fetch_thanks') || !$vbulletin->userinfo['userid']) {
        return array('success' => true);
    }
    $thanks = fetch_thanks($vbulletin->GPC['postid']);
    // Figure out if we've thanked this post
    $thanked = false;
    if (is_array($thanks)) {
        foreach ($thanks as $thank) {
            if ($thank['userid'] == $vbulletin->userinfo['userid']) {
                $thanked = true;
                break;
            }
        }
    }
    $threadinfo = verify_id('thread', $postinfo['threadid'], 1, 1);
    if ($thanked) {
        delete_thanks($postinfo, $vbulletin->userinfo['userid']);
    } else {
        $postinfo = array_merge($postinfo, fetch_userinfo($postinfo['userid']));
        if (post_thanks_off($threadinfo['forumid'], $postinfo, $threadinfo['firstpostid']) || !can_thank_this_post($postinfo, $threadinfo['isdeleted']) || thanked_already($postinfo)) {
            return array('success' => true);
        }
        add_thanks($postinfo);
    }
    return array('success' => true);
}
Beispiel #2
0
require_once './global.php';
require_once DIR . '/includes/functions_post_thanks.php';
// #######################################################################
// ######################## START MAIN SCRIPT ############################
// #######################################################################
$vbulletin->input->clean_array_gpc('r', array('using_ajax' => TYPE_UINT, 'securitytoken' => TYPE_STR));
$using_ajax = $vbulletin->GPC['using_ajax'];
$securitytoken = $vbulletin->GPC['securitytoken'];
($hook = vBulletinHook::fetch_hook('post_thanks_main_start')) ? eval($hook) : false;
if ($_REQUEST['do'] == 'post_thanks_add') {
    ($hook = vBulletinHook::fetch_hook('post_thanks_main_add_thanks_start')) ? eval($hook) : false;
    $postinfo = array_merge($postinfo, fetch_userinfo($postinfo['userid']));
    if (post_thanks_off($forumid, $postinfo, $threadinfo['firstpostid']) || !can_thank_this_post($postinfo, $threadinfo['isdeleted'], true, $securitytoken) || thanked_already($postinfo)) {
        $using_ajax ? exit : print_no_permission();
    }
    add_thanks($postinfo);
    ($hook = vBulletinHook::fetch_hook('post_thanks_main_add_thanks_end')) ? eval($hook) : false;
    if ($using_ajax) {
        $thanks = fetch_thanks($postid, '', true);
        $postinfo['post_thanks_bit'] = fetch_thanks_bit($forumid, $thanks);
        $postinfo['post_thanks_amount'] = $postinfo['post_thanks_amount'] + 1;
        $postinfo['post_thanks_amount_formatted'] = vb_number_format($postinfo['post_thanks_amount']);
        if ($vbulletin->options['post_thanks_delete_own']) {
            $postinfo['show_thanks_remove_option'] = true;
        }
        $echo = fetch_post_thanks_template($postinfo);
        echo "{$echo}";
        exit;
    } else {
        $vbulletin->url = "showthread.php?{$session['sessionurl']}p={$postid}";
        eval(print_standard_redirect('redirect_post_thanks'));