Example #1
0
 function store($full = true)
 {
     require_once mnminclude . 'log.php';
     global $db, $current_user, $globals;
     $db->transaction();
     if (!$this->date) {
         $this->date = time();
     }
     $post_author = $this->author;
     $post_src = $this->src;
     $post_karma = $this->karma;
     $post_date = $this->date;
     $post_randkey = $this->randkey;
     $post_content = $db->escape($this->normalize_content());
     if ($this->id === 0) {
         $this->ip = $globals['user_ip_int'];
         $db->query("INSERT INTO posts (post_user_id, post_karma, post_ip_int, post_date, post_randkey, post_src, post_content) VALUES ({$post_author}, {$post_karma}, {$this->ip}, FROM_UNIXTIME({$post_date}), {$post_randkey}, '{$post_src}', '{$post_content}')");
         $this->id = $db->insert_id;
         $this->insert_vote($post_author);
         // Insert post_new event into logs
         if ($full) {
             log_insert('post_new', $this->id, $post_author);
         }
     } else {
         $db->query("UPDATE posts set post_user_id={$post_author}, post_karma={$post_karma}, post_ip_int = '{$this->ip}', post_date=FROM_UNIXTIME({$post_date}), post_randkey={$post_randkey}, post_content='{$post_content}' WHERE post_id={$this->id}");
         // Insert post_new event into logs
         if ($full) {
             log_conditional_insert('post_edit', $this->id, $post_author, 30);
         }
     }
     if ($full) {
         $this->update_conversation();
     }
     $db->commit();
 }
Example #2
0
	function store($full = true) {
		require_once(mnminclude.'log.php');
		global $db, $current_user, $globals;

		if(!$this->date) $this->date=$globals['now'];
		$comment_author = $this->author;
		$comment_link = $this->link;
		$comment_karma = $this->karma;
		$comment_date = $this->date;
		$comment_randkey = $this->randkey;
		$comment_content = $db->escape($this->normalize_content());
		if ($this->type == 'admin') $comment_type = 'admin';
		else $comment_type = 'normal';
		$db->transaction();
		if($this->id===0) {
			$this->ip = $db->escape($globals['user_ip']);
			$db->query("INSERT INTO comments (comment_user_id, comment_link_id, comment_type, comment_karma, comment_ip, comment_date, comment_randkey, comment_content) VALUES ($comment_author, $comment_link, '$comment_type', $comment_karma, '$this->ip', FROM_UNIXTIME($comment_date), $comment_randkey, '$comment_content')");
			$this->id = $db->insert_id;

			// Insert comment_new event into logs
			if ($full) log_insert('comment_new', $this->id, $current_user->user_id);
		} else {
			$db->query("UPDATE comments set comment_user_id=$comment_author, comment_link_id=$comment_link, comment_type='$comment_type', comment_karma=$comment_karma, comment_ip = '$this->ip', comment_date=FROM_UNIXTIME($comment_date), comment_modified=now(), comment_randkey=$comment_randkey, comment_content='$comment_content' WHERE comment_id=$this->id");
			// Insert comment_new event into logs
			if ($full) log_conditional_insert('comment_edit', $this->id, $current_user->user_id, 60);
		}
		if ($full) {
			$this->update_order();
			$this->update_conversation();
		}
		$db->commit();
	}
Example #3
0
 function store()
 {
     require_once mnminclude . 'log.php';
     global $db, $current_user, $globals;
     if (!$this->date) {
         $this->date = $globals['now'];
     }
     $comment_author = $this->author;
     $comment_link = $this->link;
     $comment_karma = $this->karma;
     $comment_date = $this->date;
     $comment_randkey = $this->randkey;
     $comment_content = $db->escape(clean_lines($this->content));
     if ($this->type == 'admin') {
         $comment_type = 'admin';
     } else {
         $comment_type = 'normal';
     }
     if ($this->id === 0) {
         $this->ip = $db->escape($globals['user_ip']);
         $db->query("INSERT INTO comments (comment_user_id, comment_link_id, comment_type, comment_karma, comment_ip, comment_date, comment_randkey, comment_content) VALUES ({$comment_author}, {$comment_link}, '{$comment_type}', {$comment_karma}, '{$this->ip}', FROM_UNIXTIME({$comment_date}), {$comment_randkey}, '{$comment_content}')");
         $this->id = $db->insert_id;
         // Insert comment_new event into logs
         log_insert('comment_new', $this->id, $current_user->user_id);
     } else {
         $db->query("UPDATE comments set comment_user_id={$comment_author}, comment_link_id={$comment_link}, comment_type='{$comment_type}', comment_karma={$comment_karma}, comment_ip = '{$this->ip}', comment_date=FROM_UNIXTIME({$comment_date}), comment_randkey={$comment_randkey}, comment_content='{$comment_content}' WHERE comment_id={$this->id}");
         // Insert comment_new event into logs
         log_conditional_insert('comment_edit', $this->id, $current_user->user_id, 30);
     }
     $this->update_order();
 }
Example #4
0
    }
} elseif ($type == 'link') {
    require_once mnminclude . 'link.php';
    $link = new Link();
    $link->id = $id;
    if (!$link->read()) {
        error(_('Artículo inexistente'));
    }
    if (!$link->is_map_editable()) {
        error(_("noticia no modificable"));
    }
} else {
    error(_('tipo incorrecto'));
}
$lat = (double) $_REQUEST['lat'];
$lng = (double) $_REQUEST['lng'];
$text = clean_text($_REQUEST['text'], 0, true, 75);
if (geo_insert($type, $id, $lat, $lng, $text)) {
    echo "OK";
    if ($type == 'link') {
        require_once mnminclude . 'log.php';
        log_conditional_insert('link_geo_edit', $link->id, $current_user->user_id, 60);
    }
} else {
    error(_('no se insertó en la base de datos'));
}
function error($mess)
{
    echo "ERROR: {$mess}\n";
    die;
}
Example #5
0
function do_save()
{
    global $linkres, $dblang, $current_user;
    $linkres->read_content_type_buttons($_POST['type']);
    $linkres->category = intval($_POST['category']);
    if (!empty($_POST['url']) && ($current_user->user_level == 'admin' || $current_user->user_level == 'god')) {
        $linkres->url = clean_input_url($_POST['url']);
    }
    $linkres->title = clean_text($_POST['title'], 40);
    $linkres->content = clean_text($_POST['bodytext']);
    $linkres->tags = tags_normalize_string($_POST['tags']);
    // change the status
    if (($current_user->user_level == 'god' || $linkres->status != 'published') && ($_POST['status'] == 'queued' || $_POST['status'] == 'discard' || $_POST['status'] == 'abuse' || $_POST['status'] == 'autodiscard')) {
        if (!$linkres->is_discarded() && ($_POST['status'] == 'discard' || $_POST['status'] == 'abuse' || $_POST['status'] == 'autodiscard')) {
            // Insert a log entry if the link has been manually discarded
            $insert_discard_log = true;
        }
        $linkres->status = $_POST['status'];
    }
    if (!link_edit_errors($linkres)) {
        if (empty($linkres->uri)) {
            $linkres->get_uri();
        }
        $linkres->store();
        tags_insert_string($linkres->id, $dblang, $linkres->tags, $linkres->date);
        // Insert edit log/event
        require_once mnminclude . 'log.php';
        if ($insert_discard_log) {
            // Insert always a link and discard event if the status has been changed to discard
            log_insert('link_discard', $linkres->id, $current_user->user_id);
            log_insert('link_edit', $linkres->id, $current_user->user_id);
        } else {
            log_conditional_insert('link_edit', $linkres->id, $current_user->user_id, 60);
        }
        echo '<div class="form-error-submit">&nbsp;&nbsp;' . _("noticia actualizada") . '</div>' . "\n";
    }
    $linkres->read();
    echo '<div class="formnotice">' . "\n";
    $linkres->print_summary('preview');
    echo '</div>' . "\n";
    echo '<form id="genericform" method="GET" action="story.php" >';
    echo '<input type="hidden" name="id" value="' . $linkres->id . '" />' . "\n";
    echo '<input class="genericsubmit" type="button" onclick="window.history.go(-1)" value="' . _('&#171; modificar') . '">&nbsp;&nbsp;' . "\n";
    echo '<input class="genericsubmit" type="submit" value="' . _('ir a la noticia') . '" />' . "\n";
    echo '</form>' . "\n";
}
Example #6
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;
}
Example #7
0
	function store_basic() {
		global $db, $current_user, $globals;

		if(!$this->date) $this->date=$globals['now'];
		$link_author = $this->author;
		$link_blog = $this->blog;
		$link_status = $db->escape($this->status);
		$link_anonymous = $this->anonymous;
		$link_karma = $this->karma;
		$link_votes_avg = $this->votes_avg;
		$link_randkey = $this->randkey;
		$link_category = $this->category;
		$link_date = $this->date;
		$link_sent_date = $this->sent_date;
		$link_published_date = $this->published_date;
		$link_content_type = $db->escape($this->content_type);
		$link_ip = $db->escape($this->ip);
		if($this->id===0) {
			$db->query("INSERT INTO links (link_author, link_blog, link_status, link_randkey, link_category, link_date, link_sent_date, link_published_date, link_karma, link_anonymous, link_votes_avg, link_content_type, link_ip) VALUES ($link_author, $link_blog, '$link_status', $link_randkey, $link_category, FROM_UNIXTIME($link_date), FROM_UNIXTIME($link_sent_date), FROM_UNIXTIME($link_published_date), $link_karma, $link_anonymous, $link_votes_avg, '$link_content_type', '$link_ip')");
			$this->id = $db->insert_id;
		} else {
		// update
			$db->query("UPDATE links set link_author=$link_author, link_blog=$link_blog, link_status='$link_status', link_randkey=$link_randkey, link_category=$link_category, link_date=FROM_UNIXTIME($link_date), link_sent_date=FROM_UNIXTIME($link_sent_date), link_published_date=FROM_UNIXTIME($link_published_date), link_karma=$link_karma, link_votes_avg=$link_votes_avg, link_content_type='$link_content_type', link_ip='$link_ip' WHERE link_id=$this->id");
		}
		if ($this->votes == 1 && $this->negatives == 0 && $this->status == 'queued') {
			// This is a new link, add it to the events, it an additional control
			// just in case the user dind't do the last submit phase and voted later
			log_conditional_insert('link_new', $this->id, $this->author);
		}

		$this->update_votes(); 
		$this->update_comments(); 
	}
Example #8
0
function do_save() {
	global $linkres, $dblang, $current_user;

	$linkres->read_content_type_buttons($_POST['type']);

	$linkres->category=intval($_POST['category']);
	if ($current_user->admin) {
		if (!empty($_POST['url'])) {
			$linkres->url = clean_input_url($_POST['url']);
		}
		if ($_POST['thumb_delete']) {
			$linkres->delete_thumb();
		}
		if ($_POST['thumb_get']) {
			$linkres->get_thumb();
		}
	}
	$linkres->title = clean_text($_POST['title'], 40);
	$linkres->content = clean_text_with_tags($_POST['bodytext']);
	$linkres->tags = tags_normalize_string($_POST['tags']);
	// change the status
	if ($_POST['status'] != $linkres->status
		&& ($_POST['status'] == 'autodiscard' || $current_user->admin)
		&& preg_match('/^[a-z]{4,}$/', $_POST['status'])
		&& ( ! $linkres->is_discarded() || $current_user->admin)) {
		if (preg_match('/discard|abuse|duplicated|autodiscard/', $_POST['status'])) {
			// Insert a log entry if the link has been manually discarded
			$insert_discard_log = true;
		}
		$linkres->status = $_POST['status'];
	}

  // EVENTS
  $d = $_POST["datepicker1"];
  $linkres->start_date = substr($d,3,2).'-'.substr($d, 0, 2).'-'.substr($d,6,4);

  $d = $_POST["datepicker2"];
  $linkres->end_date = substr($d,3,2).'-'.substr($d, 0, 2).'-'.substr($d,6,4);


	if (!link_edit_errors($linkres)) {
		if (empty($linkres->uri)) $linkres->get_uri();
		$linkres->store();
		tags_insert_string($linkres->id, $dblang, $linkres->tags, $linkres->date);

		// Insert edit log/event if the link it's newer than 15 days
		if ($globals['now'] - $linkres->date < 86400*15) {
			require_once(mnminclude.'log.php');
			if ($insert_discard_log) {
				// Insert always a link and discard event if the status has been changed to discard
				log_insert('link_discard', $linkres->id, $current_user->user_id);
				if ($linkres->author == $current_user->user_id) { // Don't save edit log if it's discarded by an admin
					log_insert('link_edit', $linkres->id, $current_user->user_id);
				}
			} elseif ($linkres->votes > 0) {
				log_conditional_insert('link_edit', $linkres->id, $current_user->user_id, 60);
			}
		}

		echo '<div class="form-error-submit">&nbsp;&nbsp;'._("noticia actualizada").'</div>'."\n";
	}

	$linkres->read();

	echo '<div class="formnotice">'."\n";
	$linkres->print_summary('preview');
	echo '</div>'."\n";

	echo '<form class="note" method="GET" action="story.php" >';
	echo '<input type="hidden" name="id" value="'.$linkres->id.'" />'."\n";
	echo '<input class="button" type="button" onclick="window.history.go(-1)" value="&#171; '._('modificar').'">&nbsp;&nbsp;'."\n";;
	echo '<input class="button" type="submit" value="'._('ir a la noticia').'" />'."\n";
	echo '</form>'. "\n";
}
Example #9
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->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;
	
}
Example #10
0
 function store_basic()
 {
     global $db, $current_user;
     if (!$this->date) {
         $this->date = time();
     }
     $link_author = $this->author;
     $link_blog = $this->blog;
     $link_status = $db->escape($this->status);
     $link_votes = $this->votes;
     $link_negatives = $this->negatives;
     $link_comments = $this->comments;
     $link_karma = $this->karma;
     $link_randkey = $this->randkey;
     $link_category = $this->category;
     $link_date = $this->date;
     $link_published_date = $this->published_date;
     if ($this->id === 0) {
         $db->query("INSERT INTO links (link_author, link_blog, link_status, link_randkey, link_category, link_date, link_published_date, link_votes, link_negatives, link_karma) VALUES ({$link_author}, {$link_blog}, '{$link_status}', {$link_randkey}, {$link_category}, FROM_UNIXTIME({$link_date}), FROM_UNIXTIME({$link_published_date}), {$link_votes}, {$link_negatives}, {$link_karma})");
         $this->id = $db->insert_id;
     } else {
         // update
         $db->query("UPDATE links set link_author={$link_author}, link_blog={$link_blog}, link_status='{$link_status}', link_randkey={$link_randkey}, link_category={$link_category}, link_date=FROM_UNIXTIME({$link_date}), link_published_date=FROM_UNIXTIME({$link_published_date}), link_votes={$link_votes}, link_negatives={$link_negatives}, link_comments={$link_comments}, link_karma={$link_karma} WHERE link_id={$this->id}");
     }
     if ($this->votes == 1 && $this->negatives == 0 && $this->status == 'queued') {
         // This is a new link, add it to the events, it an additional control
         // just in case the user dind't do the last submit phase and voted later
         log_conditional_insert('link_new', $this->id, $this->author);
     }
 }
Example #11
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;
}