예제 #1
0
 function insert_vote($user = 0, $value = 10)
 {
     if (parent::insert_vote($user, $value)) {
         $vote = new Vote();
         $vote->type = 'links';
         $vote->link = $this->id;
         if (Voting_Method == 2) {
             $this->votes = $vote->rating("!=0");
             $this->votecount = $vote->count("!=0");
             $this->reports = $this->count_all_votes("<0");
         } else {
             $this->reports = $this->count_all_votes("<0");
             $this->votes = $vote->count() - $this->reports;
         }
         $this->store_basic();
         $this->check_should_publish();
         $vars = array('vote' => $this);
         check_actions('link_insert_vote_post', $vars);
         return true;
     }
     return false;
 }
예제 #2
0
 	}
 
 	if($link->votes($current_user->user_id) > 0 || $link->reports($current_user->user_id) > 0) {
 	}
 */
 $value = sanitize($_POST['value'], 3);
 /*	if(sanitize($_POST['unvote'], 3) == 'true'){
 		$link->remove_vote($current_user->user_id, $value);
 	} else {
 	if($link->votes($current_user->user_id) > 0 || $link->reports($current_user->user_id) > 0 ||
 	   // DB 11/10/08
 	   (votes_per_ip > 0 && $link->votes_from_ip() + $link->reports_from_ip() >= votes_per_ip)) {
 	   /////
 		error($main_smarty->get_config_vars('PLIGG_Visual_Vote_AlreadyVoted'));
 	}*/
 $link->insert_vote($current_user->user_id, $value);
 //	}
 /*	if ($link->status == 'discard') {
 	$link->read();
 	$link->status = 'queued';
 	$link->store();
 	}
 */
 if (Voting_Method == 2) {
     $link_rating = $link->rating($link->id) / 2;
     $rating_width = $link_rating * 25;
     $vote_count = $link->countvotes();
     echo $rating_width . "~" . $link_rating . "~" . $vote_count;
 }
 /*	else
 	{
예제 #3
0
function do_submit3()
{
    global $db, $current_user;
    $linkres = new Link();
    $linkres->id = $link_id = intval($_POST['id']);
    $linkres->read();
    // Check it is not in the queue already
    if ($linkres->votes == 0 && $linkres->status != 'queued') {
        $linkres->status = 'queued';
        $linkres->date = time();
        $linkres->get_uri();
        $linkres->store();
        $linkres->insert_vote($current_user->user_id, $current_user->user_karma);
        // Add the new link log/event
        require_once mnminclude . 'log.php';
        log_conditional_insert('link_new', $linkres->id, $linkres->author);
        $db->query("delete from links where link_author = {$linkres->author} and link_status='discard' and link_votes=0");
        if (!empty($_POST['trackback'])) {
            require_once mnminclude . 'trackback.php';
            $trackres = new Trackback();
            $trackres->url = clean_input_url($_POST['trackback']);
            $trackres->link = $linkres->id;
            $trackres->title = $linkres->title;
            $trackres->author = $linkres->author;
            $trackres->content = $linkres->content;
            $res = $trackres->send($linkres);
        }
    }
    header("Location: shakeit.php");
    die;
}
예제 #4
0
        $user->read();
        $user->karma = $user->karma - 0.2;
        $user->store();
        $annotation = new Annotation("karma-{$user->id}");
        $annotation->append(_('voto cowboy') . ": -0.2, karma: {$user->karma}\n");
        error(_('¡tranquilo cowboy!') . ', ' . _('tu karma ha bajado: ') . $user->karma);
    } else {
        error(_('¡tranquilo cowboy!'));
    }
}
if ($current_user->user_id > 0) {
    $value = $current_user->user_karma;
} else {
    $value = $anon_karma;
}
if (!$link->insert_vote($value)) {
    if ($current_user->user_id > 0) {
        error(_('ya se votó antes con el mismo usuario o IP'));
    } else {
        error(_('ya se votó antes desde la misma IP'));
    }
}
if ($link->status == 'discard' && $current_user->user_id > 0 && $link->votes > $link->negatives && $link->karma > 0) {
    $link->status = 'queued';
    $link->store_basic();
}
echo $link->json_votes_info(intval($value));
function error($mess)
{
    $dict['error'] = $mess;
    echo json_encode($dict);
예제 #5
0
function do_submit3() {
	global $db, $current_user;

	$linkres=new Link;

	$linkres->id=$link_id = intval($_POST['id']);
	$linkres->read();
	// Check it is not in the queue already
	if($linkres->votes == 0 && $linkres->status != 'queued') {
		$linkres->status='queued';
		$linkres->date=time();
		$linkres->store_basic();
		$linkres->insert_vote($current_user->user_id);
		$db->query("delete from links where link_author = $linkres->author and link_status='discard' and link_votes=0");
		if(!empty($_POST['trackback'])) {
			require_once(mnminclude.'trackback.php');
			$trackres = new Trackback;
			$trackres->url=preg_replace('/ /', '+', trim($_POST['trackback']));
			$trackres->link=$linkres->id;
			$trackres->title=$linkres->title;
			$trackres->author=$linkres->author;
			$trackres->content=$linkres->content;
			$res = $trackres->send();
		}
	}

	header("Location: ./shakeit.php");
	die;
	
}
예제 #6
0
파일: submit.php 프로젝트: rasomu/chuza
function do_submit3() {
	global $db, $current_user;

	$linkres=new Link;

	$linkres->id=$link_id = intval($_POST['id']);

	if(!check_link_key() || !$linkres->read()) die;

	// Check it is not in the queue already
	if ($linkres->duplicates($linkres->url)) {
		// Write headers, they were not printed yet
		do_header(_("enviar noticia"), "post");
		echo '<div id="singlewrap">' . "\n";
		report_dupe($linkres->url);
		return;
	}

	// Check this one was not already queued
	if($linkres->votes == 0 && $linkres->status != 'queued') {
		$db->transaction();
		$linkres->status='queued';
		$linkres->sent_date = $linkres->date=time();
		$linkres->get_uri();
		$linkres->store();
		$linkres->insert_vote($current_user->user_karma);
		$db->commit();

		// Add the new link log/event
		require_once(mnminclude.'log.php');
		log_conditional_insert('link_new', $linkres->id, $linkres->author);

		$db->query("delete from links where link_author = $linkres->author and link_date > date_sub(now(), interval 30 minute) and link_status='discard' and link_votes=0");
		if(!empty($_POST['trackback'])) {
			$trackres = new Trackback;
			$trackres->url=clean_input_url($_POST['trackback']);
			$trackres->link_id=$linkres->id;
			$trackres->link=$linkres->url;
			$trackres->author=$linkres->author;
			$trackres->status = 'pendent';
			$trackres->store();
		}
		fork("backend/send_pingbacks.php?id=$linkres->id");
	}

	header('Location: '. $linkres->get_permalink());
	die;
	
}
예제 #7
0
function do_submit2()
{
    global $db, $main_smarty, $dblang, $the_template, $linkres, $current_user, $Story_Content_Tags_To_Allow;
    $main_smarty->assign('auto_vote', auto_vote);
    $main_smarty->assign('Submit_Show_URL_Input', Submit_Show_URL_Input);
    $main_smarty->assign('Submit_Require_A_URL', Submit_Require_A_URL);
    $main_smarty->assign('link_id', sanitize($_POST['id'], 3));
    define('pagename', 'submit');
    $main_smarty->assign('pagename', pagename);
    if ($current_user->authenticated != TRUE) {
        $vars = array('username' => $current_user->user_login);
        check_actions('register_check_errors', $vars);
    }
    check_actions('submit2_check_errors', $vars);
    if ($vars['error'] == true) {
        // No action
    }
    $linkres = new Link();
    $linkres->id = sanitize($_POST['id'], 3);
    if ($_SESSION['step'] != 1) {
        die('Wrong step');
    }
    if (!is_numeric($linkres->id)) {
        die;
    }
    if (!$linkres->verify_ownership($current_user->user_id)) {
        die($main_smarty->get_config_vars('PLIGG_Visual_Submit2Errors_NoAccess'));
    }
    $linkres->read(FALSE);
    if ($linkres->votes($current_user->user_id) == 0 && auto_vote == true) {
        $linkres->insert_vote($current_user->user_id, '10');
        $linkres->store_basic();
        $linkres->read(FALSE);
    }
    if (is_array($_POST['category'])) {
        $linkres->category = sanitize($_POST['category'][0], 3);
        $linkres->additional_cats = array_slice($_POST['category'], 1);
    } else {
        $linkres->category = sanitize($_POST['category'], 3);
    }
    $thecat = get_cached_category_data('category_id', $linkres->category);
    $main_smarty->assign('request_category_name', $thecat->category_name);
    $linkres->title = stripslashes(sanitize($_POST['title'], 3));
    $linkres->title_url = makeUrlFriendly($linkres->title, $linkres->id);
    $linkres->tags = tags_normalize_string(stripslashes(sanitize($_POST['tags'], 3)));
    $linkres->content = close_tags(stripslashes(sanitize($_POST['bodytext'], 4, $Story_Content_Tags_To_Allow)));
    //$linkres->content = str_replace("\n", "<br />", $linkres->content);
    if (isset($_POST['link_field1'])) {
        $linkres->link_field1 = sanitize($_POST['link_field1'], 4, $Story_Content_Tags_To_Allow);
    }
    if (isset($_POST['link_field2'])) {
        $linkres->link_field2 = sanitize($_POST['link_field2'], 4, $Story_Content_Tags_To_Allow);
    }
    if (isset($_POST['link_field3'])) {
        $linkres->link_field3 = sanitize($_POST['link_field3'], 4, $Story_Content_Tags_To_Allow);
    }
    if (isset($_POST['link_field4'])) {
        $linkres->link_field4 = sanitize($_POST['link_field4'], 4, $Story_Content_Tags_To_Allow);
    }
    if (isset($_POST['link_field5'])) {
        $linkres->link_field5 = sanitize($_POST['link_field5'], 4, $Story_Content_Tags_To_Allow);
    }
    if (isset($_POST['link_field6'])) {
        $linkres->link_field6 = sanitize($_POST['link_field6'], 4, $Story_Content_Tags_To_Allow);
    }
    if (isset($_POST['link_field7'])) {
        $linkres->link_field7 = sanitize($_POST['link_field7'], 4, $Story_Content_Tags_To_Allow);
    }
    if (isset($_POST['link_field8'])) {
        $linkres->link_field8 = sanitize($_POST['link_field8'], 4, $Story_Content_Tags_To_Allow);
    }
    if (isset($_POST['link_field9'])) {
        $linkres->link_field9 = sanitize($_POST['link_field9'], 4, $Story_Content_Tags_To_Allow);
    }
    if (isset($_POST['link_field10'])) {
        $linkres->link_field10 = sanitize($_POST['link_field10'], 4, $Story_Content_Tags_To_Allow);
    }
    if (isset($_POST['link_field11'])) {
        $linkres->link_field11 = sanitize($_POST['link_field11'], 4, $Story_Content_Tags_To_Allow);
    }
    if (isset($_POST['link_field12'])) {
        $linkres->link_field12 = sanitize($_POST['link_field12'], 4, $Story_Content_Tags_To_Allow);
    }
    if (isset($_POST['link_field13'])) {
        $linkres->link_field13 = sanitize($_POST['link_field13'], 4, $Story_Content_Tags_To_Allow);
    }
    if (isset($_POST['link_field14'])) {
        $linkres->link_field14 = sanitize($_POST['link_field14'], 4, $Story_Content_Tags_To_Allow);
    }
    if (isset($_POST['link_field15'])) {
        $linkres->link_field15 = sanitize($_POST['link_field15'], 4, $Story_Content_Tags_To_Allow);
    }
    if (!isset($_POST['summarytext'])) {
        $linkres->link_summary = utf8_substr(sanitize($_POST['bodytext'], 4, $Story_Content_Tags_To_Allow), 0, StorySummary_ContentTruncate - 1);
        //$linkres->link_summary = close_tags(str_replace("\n", "<br />", $linkres->link_summary));
    } else {
        $linkres->link_summary = sanitize($_POST['summarytext'], 4, $Story_Content_Tags_To_Allow);
        //$linkres->link_summary = close_tags(str_replace("\n", "<br />", $linkres->link_summary));
        if (utf8_strlen($linkres->link_summary) > StorySummary_ContentTruncate) {
            loghack('SubmitAStory-SummaryGreaterThanLimit', 'username: '******'|email: ' . sanitize($_POST["email"], 3), true);
            $linkres->link_summary = utf8_substr($linkres->link_summary, 0, StorySummary_ContentTruncate - 1);
            //$linkres->link_summary = close_tags(str_replace("\n", "<br />", $linkres->link_summary));
        }
    }
    //get link_group_id
    if (isset($_REQUEST['link_group_id']) && $_REQUEST['link_group_id'] != '') {
        $linkres->link_group_id = intval($_REQUEST['link_group_id']);
    } else {
        $linkres->link_group_id = 0;
    }
    $linkres->store();
    if (link_errors($linkres)) {
        return;
    }
    //comment subscription
    if (isset($_POST['comment_subscription'])) {
        $vars = array('link_id' => $linkres->id);
        check_actions('comment_subscription_insert_function', $vars);
    }
    //comment subscription
    if (isset($_POST['timestamp_date_day'])) {
        //open date
        $timestamp_date_day = $_POST['timestamp_date_day'];
        $timestamp_date_month = $_POST['timestamp_date_month'];
        $timestamp_date_year = $_POST['timestamp_date_year'];
        if (!is_numeric($timestamp_date_day) || !is_numeric($timestamp_date_month) || !is_numeric($timestamp_date_year)) {
            $timestamp_date = date("m-d-Y");
        } else {
            $timestamp_date = $timestamp_date_month . "-" . $timestamp_date_day . "-" . $timestamp_date_year;
        }
        $vars = array('link_id' => $linkres->id);
        $vars = array('timestamp_date' => $timestamp_date, 'link_id' => $linkres->id);
        check_actions('comment_subscription_insert_function', $vars);
    }
    $vars = '';
    check_actions('submit_step_3_after_first_store', $vars);
    if ($vars['error'] == true && link_catcha_errors('captcha_error')) {
        return;
    }
    $linkres->read(FALSE);
    $edit = true;
    $link_title = $linkres->title;
    $link_content = $linkres->content;
    $link_title = stripslashes(sanitize($_POST['title'], 3));
    $main_smarty->assign('the_story', $linkres->print_summary('full', true));
    $main_smarty->assign('tags', $linkres->tags);
    if (!empty($linkres->tags)) {
        $tags_words = str_replace(",", ", ", $linkres->tags);
        $tags_url = urlencode($linkres->tags);
        $main_smarty->assign('tags_words', $tags_words);
        $main_smarty->assign('tags_url', $tags_url);
    }
    if (isset($url)) {
        $main_smarty->assign('submit_url', $url);
    } else {
        $main_smarty->assign('submit_url', '');
    }
    $data = parse_url($linkres->url);
    $main_smarty->assign('url_short', $data['host']);
    $main_smarty->assign('submit_url_title', $linkres->url_title);
    $main_smarty->assign('submit_id', $linkres->id);
    $main_smarty->assign('submit_type', $linkres->type());
    $main_smarty->assign('submit_title', str_replace('"', "&#034;", $link_title));
    $main_smarty->assign('submit_content', $link_content);
    if (isset($trackback)) {
        $main_smarty->assign('submit_trackback', $trackback);
    } else {
        $main_smarty->assign('submit_trackback', '');
    }
    $main_smarty->assign('tpl_extra_fields', $the_template . '/submit_extra_fields');
    $main_smarty->assign('tpl_center', $the_template . '/submit_step_3_center');
    $vars = '';
    check_actions('do_submit2', $vars);
    $_SESSION['step'] = 2;
    if (Submit_Complete_Step2) {
        do_submit3();
    } else {
        $main_smarty->display($the_template . '/pligg.tpl');
    }
}
예제 #8
0
function do_submit3()
{
    global $db, $current_user;
    $linkres = new Link();
    $linkres->id = $link_id = intval($_POST['id']);
    if (!check_link_key() || !$linkres->read()) {
        die;
    }
    // Check it is not in the queue already
    if ($linkres->votes == 0 && $linkres->status != 'queued') {
        $linkres->status = 'queued';
        $linkres->sent_date = $linkres->date = time();
        $linkres->get_uri();
        $linkres->store();
        $linkres->insert_vote($current_user->user_id, $current_user->user_karma);
        // Add the new link log/event
        require_once mnminclude . 'log.php';
        log_conditional_insert('link_new', $linkres->id, $linkres->author);
        $db->query("delete from links where link_author = {$linkres->author} and link_date > date_sub(now(), interval 30 minute) and link_status='discard' and link_votes=0");
        if (!empty($_POST['trackback'])) {
            require_once mnminclude . 'trackback.php';
            $trackres = new Trackback();
            $trackres->url = clean_input_url($_POST['trackback']);
            $trackres->link_id = $linkres->id;
            $trackres->link = $linkres->url;
            //$trackres->title=$linkres->title;
            $trackres->author = $linkres->author;
            //$trackres->content=$linkres->content;
            $res = $trackres->send($linkres);
        }
        fork("backend/send_pingbacks.php?id={$linkres->id}");
    }
    header('Location: ' . $linkres->get_permalink());
    die;
}
	';
?>



	<?php 
global $db, $main_smarty, $dblang, $the_template, $linkres, $current_user;
$linkres = new Link();
$linkres->id = $link_id = $_POST['id'];
if (!is_numeric($link_id)) {
    die;
}
$linkres->read(FALSE);
$linkres->related_category = $_POST['category_related'];
if ($linkres->votes($current_user->user_id) == 0 && auto_vote == true) {
    $linkres->insert_vote($current_user->user_id, '10');
    $linkres->store_basic();
    $linkres->read(FALSE);
}
if (checklevel('god')) {
    $Story_Content_Tags_To_Allow = Story_Content_Tags_To_Allow_God;
} elseif (checklevel('admin')) {
    $Story_Content_Tags_To_Allow = Story_Content_Tags_To_Allow_Admin;
} else {
    $Story_Content_Tags_To_Allow = Story_Content_Tags_To_Allow_Normal;
}
$linkres->category = strip_tags($_POST['category']);
$linkres->title = strip_tags(trim($_POST['title']));
$linkres->title_url = makeUrlFriendly($linkres->title);
$linkres->tags = tags_normalize_string(strip_tags(trim($_POST['tags'])));
$linkres->content = strip_tags(trim($_POST['bodytext']), $Story_Content_Tags_To_Allow);