Exemple #1
0
function check_already_sent()
{
    global $db;
    // Check if the url has been sent already
    if (!empty($_GET['url'])) {
        $linkres = new Link();
        if ($found = $linkres->duplicates($_GET['url'])) {
            $linkres->url = $db->escape($found);
            if ($linkres->read('url')) {
                header('Location: ' . $linkres->get_permalink());
                die;
            }
        }
    }
}
Exemple #2
0
function check_already_sent()
{
    global $db;
    // Check if the url has been sent already
    if (!empty($_GET['url'])) {
        if ($found = Link::duplicates($_GET['url'])) {
            $link = new Link();
            $link->id = $found;
            if ($link->read()) {
                header('Location: ' . $link->get_permalink());
                die;
            }
        }
    }
}
Exemple #3
0
function do_link_item($sql)
{
    global $db;
    $link = new Link();
    $links = $db->get_col($sql);
    if ($links) {
        foreach ($links as $link_id) {
            $link->id = $link_id;
            $link->read();
            if ($_REQUEST['url'] == 'source') {
                $url = __($link->url);
            } else {
                $url = $link->get_permalink();
            }
            echo '<DT><A HREF="' . $url . '" REL="nofollow">' . $link->title . '</A>' . "\n";
        }
    }
}
$comment = new Comment;
$link = new Link;
$comments = $db->get_col($sql);
if ($comments) {
	foreach($comments as $comment_id) {
		$comment->id=$comment_id;
		$comment->read();
		$content = save_text_to_html($comment->content);
		echo "	<item>\n";
		$link_id = $link->id = $comment->link;
		$link->read();
		$link_title = $db->get_var("select link_title from links where link_id = $link_id");
		// Title must not carry htmlentities
		echo "		<title><![CDATA[".html_entity_decode($link_title)."]]></title>\n";
		echo "		<link>".$link->get_permalink()."#c-$comment_id</link>\n";
		echo "		<pubDate>".date("r", $comment->date)."</pubDate>\n";
		echo "		<dc:creator>$comment->username</dc:creator>\n";
		echo "		<guid>".$link->get_permalink()."#c-$comment_id</guid>\n";
		echo "		<description><![CDATA[<p>$content";
		echo '</p><p>&#187;&nbsp;'._('autor').': <strong>'.$comment->username.'</strong></p>';
		echo '<p><img src="http://'. get_server_name() .$globals['base_url'].'backend/votes_img.php?id='. $link_id .'" alt="votes" />';
		echo '&nbsp;<img src="http://'. get_server_name() .$globals['base_url'].'backend/comments_img.php?id='. $link_id .'" alt="comments" /></p>';
		echo "]]></description>\n";
		echo "	</item>\n\n";
	}
}

do_footer();

function do_header($title) {
// Get most voted link
$link_sqls[_('Más votada')] = "select vote_link_id as id, count(*) as n from sub_statuses, links, votes use index (vote_type_4) where id = " . SitesMgr::my_id() . " AND link_id = link AND link_status = 'published' AND vote_link_id = link AND vote_type='links' and vote_date > date_sub(now(), interval {$hours} hour) and vote_user_id > 0 and vote_value > 0 group by vote_link_id order by n desc limit 1";
// Most commented
$link_sqls[_('Más comentada')] = "select comment_link_id as id, count(*) as n from sub_statuses, comments use index (comment_date) where id = " . SitesMgr::my_id() . " AND sub_statuses.status in ('published', 'metapublished') AND comment_link_id = link AND comment_date > date_sub(now(), interval {$hours} hour) group by comment_link_id order by n desc limit 1";
if ($globals['click_counter'] && $hours > 20) {
    $link_sqls[_('Más leída')] = "select sub_statuses.link as id, counter as n from sub_statuses, link_clicks where sub_statuses.id = " . SitesMgr::my_id() . " AND sub_statuses.status in ('published', 'metapublished') AND date > date_sub(now(), interval {$hours} hour) and link_clicks.id = sub_statuses.link order by n desc limit 1";
}
foreach ($link_sqls as $key => $sql) {
    $res = $db->get_row($sql);
    if (!$res) {
        continue;
    }
    $link = new Link();
    $link->id = $res->id;
    if ($link->read()) {
        $url = $link->get_permalink();
        if ($globals['url_shortener']) {
            $short_url = $link->get_short_permalink();
        } else {
            //$short_url = fon_gs($link->get_permalink());
            $short_url = $url;
        }
        if ($hours < 72) {
            $intro = "{$key} {$hours}h";
        } else {
            $days = intval($hours / 24);
            $intro = "{$key} {$days}d";
        }
        $text = "{$intro}: {$link->title}";
        if ($globals['twitter_token']) {
            twitter_post($text, $url);
			// Do not allow annonimous users to give more karma than registered users
			if ($karma_new > 0) 
				$karma_new += min($karma_new, $karma_pos_ano + $karma_neg_ano);


			// Aged karma
			$diff = max(0, $now - ($link->date + 18*3600)); // 1 hour without decreasing
			$oldd = 1 - $diff/(3600*144);
			$oldd = max(0.5, $oldd);
			$oldd = min(1, $oldd);
			$aged_karma =  $karma_new * $oldd;
			$dblink->karma=$aged_karma;

			$max_karma_found = max($max_karma_found, $dblink->karma);
			if ( $dblink->karma > $past_karma * 0.5 ) {
				print "<tr><td>$link->id</td><td>".$link->votes."</td><td>".intval($dblink->karma)."</td><td><a href='".$link->get_permalink()."'>$link->title</a>\n";
				if (intval($link->karma) < intval($dblink->karma)) 
					printf ("<br>updated karma: %6d -> %-6d\n", $link->karma, $dblink->karma);
			}
			if (intval($link->karma) != intval($dblink->karma)) {
				$link->karma = $dblink->karma;
				$link->store();
			}
			//echo "$link->id:  $dblink->votes, $dblink->karma, '" . $link->title; echo "'\n";
			if ($max_karma_found == $dblink->karma)	{
				$best_title = $link->title;
				$best_url = $link->get_permalink();
			}
			
			if ($link->votes >= $min_votes && $dblink->karma >= $min_karma &&
				$dblink->karma > ($max_karma_found - 0.1) ) {
do_header($title);
$comment = new Comment();
$link = new Link();
$comments = $db->get_col($sql);
if ($comments) {
    foreach ($comments as $comment_id) {
        $comment->id = $comment_id;
        $comment->read();
        $content = save_text_to_html($comment->content);
        echo "\t<item>\n";
        $link_id = $link->id = $comment->link;
        $link->read();
        $link_title = $db->get_var("select link_title from links where link_id = {$link_id}");
        // Title must not carry htmlentities
        echo "\t\t<title><![CDATA[" . html_entity_decode($link_title) . "]]></title>\n";
        echo "\t\t<link>" . $link->get_permalink() . "#comment-" . $comment->order . "</link>\n";
        echo "\t\t<pubDate>" . date("r", $comment->date) . "</pubDate>\n";
        echo "\t\t<dc:creator>{$comment->username}</dc:creator>\n";
        echo "\t\t<guid>" . $link->get_permalink() . "#comment-" . $comment->order . "</guid>\n";
        echo "\t\t<description><![CDATA[<p>{$content}";
        echo '</p><p>&#187;&nbsp;' . _('autor') . ': <strong>' . $comment->username . '</strong></p>';
        echo '<p><img src="http://' . get_server_name() . $globals['base_url'] . 'backend/vote_com_img.php?id=' . $link->id . '" alt="votes" width=200, height=16 /></p>';
        echo "]]></description>\n";
        echo "\t</item>\n\n";
    }
}
do_footer();
function do_header($title)
{
    global $last_modified, $dblang, $home, $globals;
    header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $last_modified) . ' GMT');
$blog_name = $_POST['blog_name'];
$charset = $_POST['charset'];
if (!empty($charset)) {
    $title = @iconv($charset, 'UTF-8//IGNORE', $title);
    $excerpt = @iconv($charset, 'UTF-8//IGNORE', $excerpt);
    $blog_name = @iconv($charset, 'UTF-8//IGNORE', $blog_name);
}
$tb_id = intval($_GET['id']);
$link = new Link();
$link->id = $tb_id;
if (!$tb_id > 0 || !$link->read()) {
    trackback_response(1, 'I really need an ID for this to work.');
}
if (empty($title) && empty($tb_url) && empty($blog_name)) {
    // If it doesn't look like a trackback at all...
    header('Location: ' . $link->get_permalink());
    exit;
}
if (!empty($tb_url) && !empty($title) && !empty($excerpt)) {
    header('Content-Type: text/xml; charset=UTF-8');
    $title = htmlspecialchars(strip_tags($title));
    $title = strlen($title) > 150 ? substr($title, 0, 150) . '...' : $title;
    $excerpt = strip_tags($excerpt);
    $excerpt = strlen($excerpt) > 200 ? substr($excerpt, 0, 200) . '...' : $excerpt;
    $trackres = new Trackback();
    $trackres->link = $tb_id;
    $trackres->type = 'in';
    $trackres->url = $tb_url;
    $dupe = $trackres->read();
    if ($dupe) {
        syslog(LOG_DEBUG, 'We already have a ping from that URI for this post.');
Exemple #9
0
// The source code packaged with this file is Free Software, Copyright (C) 2005 by
// Ricardo Galli <gallir at uib dot es> and
// Beldar <beldar.cat at gmail dot com>
// It's licensed under the AFFERO GENERAL PUBLIC LICENSE unless stated otherwise.
// You can get copies of the licenses here:
// 		http://www.affero.org/oagpl.html
// AFFERO GENERAL PUBLIC LICENSE is also included in the file called "COPYING".
// The code below was made by Beldar <beldar at gmail dot com>
if (!defined('mnmpath')) {
    include_once '../config.php';
    header('Content-Type: text/html; charset=utf-8');
    stats_increment('ajax');
}
if (empty($_GET['id'])) {
    die;
}
$id = intval($_GET['id']);
$link = new Link();
$link->id = $id;
$link->read();
if (!$link->read) {
    die;
}
echo '<div style="font-size:8.5pt;width:250px; margin-right:15px">';
if ($link->avatar) {
    echo '<img src="' . get_avatar_url($link->author, $link->avatar, 40) . '" width="40" height="40" alt="avatar"  style="float:left; margin: 0 5px 4px 0;"/>';
}
echo '<a href="' . $link->get_permalink() . '" target="_blank"><strong>' . $link->title . '</strong></a><br clear="all"/>';
echo $link->meta_name . ', ' . $link->category_name . ' | ' . _('comentarios') . ':&nbsp;' . $link->comments . ' | karma:&nbsp;' . intval($link->karma) . ' | ' . _('negativos') . ':&nbsp;' . $link->negatives;
echo '</div>';
Exemple #10
0
function do_commented()
{
    global $db, $rows, $user, $offset, $page_size, $globals, $current_user;
    if ($globals['bot']) {
        return;
    }
    $link = new Link();
    $comment = new Comment();
    $rows = $db->get_var("SELECT count(*) FROM comments WHERE comment_user_id={$user->id}");
    $comments = $db->get_results("SELECT comment_id, link_id, comment_type FROM comments, links WHERE comment_user_id={$user->id} and link_id=comment_link_id ORDER BY comment_date desc LIMIT {$offset},{$page_size}");
    if ($comments) {
        echo '<div class="bookmarks-export-user-stories">';
        echo '<a href="' . $globals['base_url'] . 'link_bookmark.php?user_id=' . $user->id . '&amp;option=commented" title="' . _('exportar bookmarks en formato Mozilla') . '" class="bookmarks-export-user-commented"><img src="' . $globals['base_url'] . 'img/common/bookmarks-export-01.png" alt="Mozilla bookmark"/></a>';
        echo '&nbsp;&nbsp;<a href="' . $globals['base_url'] . 'comments_rss2.php?user_id=' . $user->id . '" title="' . _('obtener comentarios en rss2') . '"><img src="' . $globals['base_url'] . 'img/common/rss-button01.png" alt="rss2"/></a>';
        echo '</div>';
        foreach ($comments as $dbcomment) {
            if ($dbcomment->comment_type == 'admin' && $current_user->user_level != 'god' && $current_user->user_level != 'admin') {
                continue;
            }
            $link->id = $dbcomment->link_id;
            $comment->id = $dbcomment->comment_id;
            if ($last_link != $link->id) {
                $link->read();
                echo '<h4>';
                echo '<a href="' . $link->get_permalink() . '">' . $link->title . '</a>';
                echo ' [' . $link->comments . ']';
                echo '</h4>';
                $last_link = $link->id;
            }
            $comment->read();
            echo '<ol class="comments-list">';
            $comment->print_summary($link, 2000, false);
            echo "</ol>\n";
        }
    }
}
Exemple #11
0
    array_shift($url_args);
    // The first element is always a "/"
    $link->uri = $db->escape($url_args[0]);
    if (!$link->read('uri')) {
        not_found();
    }
} else {
    $url_args = preg_split('/\\/+/', $_REQUEST['id']);
    $link->id = intval($url_args[0]);
    if (is_numeric($url_args[0]) && $link->read('id')) {
        // Redirect to the right URL if the link has a "semantic" uri
        if (!empty($link->uri) && !empty($globals['base_story_url'])) {
            if (!empty($url_args[1])) {
                $extra_url = '/' . $url_args[1];
            }
            header('Location: ' . $link->get_permalink() . $extra_url);
            die;
        }
    } else {
        not_found();
    }
}
/*
// Check if the browser sent if-modified-since and act accordingly
// Reverted: firefox get fooked
//           it shows the old page if the user just authenticated
$if_modified = get_if_modified();
if ($if_modified > 0 && $if_modified == $link->modified) {
	header("HTTP/1.1 304 Not Modified");
	exit;
}
Exemple #12
0
function do_top($string)
{
    require_once mnminclude . 'link.php';
    global $db, $globals;
    $rank = "*Top* ";
    $sql = "select link_id from links where link_date > date_sub(now(), interval 4 day) and link_status='queued' order by link_karma desc limit 2";
    $result = $db->get_results($sql);
    foreach ($result as $linkid) {
        $link = new Link();
        $link->id = $linkid->link_id;
        $link->read();
        $rank .= '<br/> ' . $link->get_permalink() . " ({$link->karma})";
    }
    return $rank;
}
Exemple #13
0
            log_insert('link_depublished', $link->link_id, $link->link_author);
            // Add the discard to log/event
            $user = new User();
            $user->id = $link->link_author;
            if ($user->read()) {
                $user->karma -= $globals['instant_karma_per_depublished'];
                echo "{$user->username}: {$user->karma}\n";
                $user->store();
                $annotation = new Annotation("karma-{$user->id}");
                $annotation->append(_('Retirada de portada') . ": -" . $globals['instant_karma_per_depublished'] . ", karma: {$user->karma}\n");
            }
            if ($globals['twitter_user'] || $globals['jaiku_user']) {
                if ($globals['url_shortener']) {
                    $short_url = $l->get_short_permalink();
                } else {
                    $short_url = fon_gs($l->get_permalink());
                }
                $text = _('Retirada de portada') . ': ';
                if ($globals['twitter_user'] && $globals['twitter_password']) {
                    twitter_post($text, $short_url);
                }
                if ($globals['jaiku_user'] && $globals['jaiku_key']) {
                    jaiku_post($text, $short_url);
                }
            }
        }
    }
}
punish_comments();
// Discard links
$negatives = $db->get_results("select SQL_NO_CACHE link_id, link_karma, link_votes, link_negatives, link_author from links where link_date > {$min_date} and link_status = 'queued' and link_karma < 0 and (link_date < {$max_date} or link_karma < -100) and (link_karma < -link_votes*2 or (link_negatives > 20 and link_negatives > link_votes/2)) and (link_negatives > 20 or (link_negatives > 4 and link_negatives > link_votes) )");
Exemple #14
0
function do_commented()
{
    global $db, $rows, $user, $offset, $page_size;
    $link = new Link();
    $comment = new Comment();
    echo '<h2>' . _('comentarios') . '</h2><br />';
    $rows = $db->get_var("SELECT count(*) FROM comments WHERE comment_user_id={$user->id}");
    $comments = $db->get_results("SELECT comment_id, link_id FROM comments, links WHERE comment_user_id={$user->id} and link_id=comment_link_id ORDER BY comment_date desc LIMIT {$offset},{$page_size}");
    if ($comments) {
        foreach ($comments as $dbcomment) {
            $link->id = $dbcomment->link_id;
            $comment->id = $dbcomment->comment_id;
            if ($last_link != $link->id) {
                $link->read();
                echo '<h4>';
                echo '<a href="' . $link->get_permalink() . '">' . $link->title . '</a>';
                echo ' [' . $link->comments . ']';
                echo '</h4>';
                $last_link = $link->id;
            }
            $comment->read();
            echo '<ol class="comments-list">';
            $comment->print_summary($link, 2000, false);
            echo "</ol>\n";
        }
    }
}
Exemple #15
0
    }
    $sql = "SELECT link_id {$from_where} {$order_by} LIMIT {$rows}";
}
do_header($title);
$link = new Link();
$links = $db->get_col($sql);
if ($links) {
    foreach ($links as $link_id) {
        $link->id = $link_id;
        $link->read();
        $category_name = $db->get_var("SELECT category_name FROM categories WHERE category_id = {$link->category} AND category_lang='{$dblang}'");
        $content = text_to_html(htmlentities2unicodeentities($link->content));
        echo "\t<item>\n";
        // Title must not carry htmlentities
        echo "\t\t<title>" . htmlentities2unicodeentities($link->title) . "</title>\n";
        echo "\t\t<link>" . $link->get_permalink() . "</link>\n";
        echo "\t\t<comments>" . $link->get_permalink() . "</comments>\n";
        if (!empty($link_date)) {
            echo "\t\t<pubDate>" . date("r", $link->{$link_date}) . "</pubDate>\n";
        } else {
            echo "      <pubDate>" . date("r", $link->date) . "</pubDate>\n";
        }
        echo "\t\t<dc:creator>{$link->username}</dc:creator>\n";
        echo "\t\t<category><![CDATA[{$category_name}]]></category>\n";
        // Add tags as categories
        if (!empty($link->tags)) {
            $tags_array = explode(",", $link->tags);
            foreach ($tags_array as $tag_item) {
                $tag_item = trim($tag_item);
                echo "\t\t<category><![CDATA[" . $tag_item . "]]></category>\n";
            }
Exemple #16
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;
	
}
// Get most voted link
$link_sqls[_('Más votada')] = "select vote_link_id as id, count(*) as n from sub_statuses, links, votes use index (vote_type_4) where id = " . SitesMgr::my_id() . " AND link_id = link AND link_status = 'published' AND vote_link_id = link AND vote_type='links' and vote_date > date_sub(now(), interval {$hours} hour) and vote_user_id > 0 and vote_value > 0 group by vote_link_id order by n desc limit 1";
// Most commented
$link_sqls[_('Más comentada')] = "select comment_link_id as id, count(*) as n from sub_statuses, comments use index (comment_date) where id = " . SitesMgr::my_id() . " AND sub_statuses.status in ('published', 'metapublished') AND comment_link_id = link AND comment_date > date_sub(now(), interval {$hours} hour) group by comment_link_id order by n desc limit 1";
if ($globals['click_counter'] && $hours > 20) {
    $link_sqls[_('Más leída')] = "select sub_statuses.link as id, counter as n from sub_statuses, link_clicks where sub_statuses.id = " . SitesMgr::my_id() . " AND sub_statuses.status in ('published', 'metapublished') AND date > date_sub(now(), interval {$hours} hour) and link_clicks.id = sub_statuses.link order by n desc limit 1";
}
foreach ($link_sqls as $key => $sql) {
    $res = $db->get_row($sql);
    if (!$res) {
        continue;
    }
    $link = new Link();
    $link->id = $res->id;
    if ($link->read()) {
        $url = $link->get_permalink($info->sub);
        if ($globals['url_shortener']) {
            $short_url = $link->get_short_permalink();
        } else {
            //$short_url = fon_gs($link->get_permalink());
            $short_url = $url;
        }
        if ($hours < 72) {
            $intro = "{$key} {$hours}h";
        } else {
            $days = intval($hours / 24);
            $intro = "{$key} {$days}d";
        }
        $text = "{$intro}: {$link->title}";
        twitter_post($properties, $text, $url);
        facebook_post($properties, $link, $intro);
Exemple #18
0
function print_comment_list($comments, $user) {
	global $globals, $current_user;

	$link = new Link;
	$comment = new Comment;

	foreach ($comments as $dbcomment) {
		if ($dbcomment->comment_type == 'admin' && ! $current_user->admin) continue;
		$link->id=$dbcomment->link_id;
		$comment->id = $dbcomment->comment_id;
		if ($last_link != $link->id) {
			$link->read();
			echo '<h4>';
			echo '<a href="'.$link->get_permalink().'">'. $link->title. '</a>';
			echo ' ['.$link->comments.']';
			echo '</h4>';
			$last_link = $link->id;
		}
		$comment->read();
		echo '<ol class="comments-list">';
		echo '<li>';
		$comment->print_summary($link, 2000, false);
		echo '</li>';
		echo "</ol>\n";
	}
}
Exemple #19
0
 function pingback_ping($args)
 {
     global $db, $globals;
     $pagelinkedfrom = clean_input_string($args[0]);
     //$pagelinkedfrom = str_replace('&amp;', '&', $pagelinkedfrom);
     $pagelinkedto = clean_input_string($args[1]);
     $title = '';
     $urlfrom = parse_url($pagelinkedfrom);
     $urltest = parse_url($pagelinkedto);
     if (!$urlfrom || !$urltest) {
         return new IXR_Error(0, 'Is there no link to us?');
     }
     if ($urltest['host'] != get_server_name()) {
         return new IXR_Error(0, 'Is there no link to us?');
     }
     $base_uri = preg_quote($globals['base_url'] . $globals['base_story_url'], '/');
     $uri = preg_replace("/^{$base_uri}/", '', $urltest[path]);
     if (check_ban($globals['user_ip'], 'ip')) {
         syslog(LOG_NOTICE, "Meneame: pingback, IP is banned ({$globals['user_ip']}): {$pagelinkedfrom} - {$pagelinkedto}");
         return new IXR_Error(33, 'IP is banned.');
     }
     // Antispam of sites like xxx.yyy-zzz.info/archives/xxx.php
     if (preg_match('/http:\\/\\/[a-z0-9]\\.[a-z0-9]+-[^\\/]+\\.info\\/archives\\/.+\\.php$/', $pagelinkedfrom)) {
         return new IXR_Error(33, 'Host not allowed.');
     }
     if (check_ban($urlfrom[host], 'hostname', false)) {
         syslog(LOG_NOTICE, "Meneame: pingback, site is banned: {$pagelinkedfrom} - {$pagelinkedto}");
         return new IXR_Error(33, 'Site is banned.');
     }
     $link = new Link();
     $link->uri = preg_replace('/#[\\w\\-\\_]+$/', '', $uri);
     if (empty($uri) || !$link->read('uri')) {
         syslog(LOG_NOTICE, "Meneame: pingback, story does not exist: {$pagelinkedto}");
         return new IXR_Error(33, 'Story doesn\'t exist.');
     }
     if ($link->get_permalink() == $pagelinkedfrom) {
         syslog(LOG_NOTICE, "Meneame: pingback, points to the same post: {$pagelinkedfrom} - {$pagelinkedto}");
         return new IXR_Error(48, 'The pingback points to the same post.');
     }
     if ($link->date < time() - 86400 * 15) {
         syslog(LOG_NOTICE, "Meneame: pingback, story is too old: {$pagelinkedto}");
         return new IXR_Error(33, 'Story is too old for pingbacks.');
     }
     $trackres = new Trackback();
     $trackres->link_id = $link->id;
     $trackres->type = 'in';
     $trackres->link = $pagelinkedfrom;
     $trackres->url = $pagelinkedfrom;
     if ($trackres->abuse()) {
         return new IXR_Error(33, 'Don\'t send so many pings.');
     }
     $dupe = $trackres->read();
     if ($dupe) {
         syslog(LOG_NOTICE, "Meneame: pingback, we already have a ping from that URI for this post: {$pagelinkedfrom} - {$pagelinkedto}");
         return new IXR_Error(48, 'The pingback has already been registered.');
     }
     // very stupid, but gives time to the 'from' server to publish !
     sleep(1);
     // Let's check the remote site
     if (version_compare(phpversion(), '5.1.0') >= 0) {
         $contents = @file_get_contents($pagelinkedfrom, FALSE, NULL, 0, 100000);
     } else {
         $contents = @file_get_contents($pagelinkedfrom);
     }
     if (!$contents) {
         syslog(LOG_NOTICE, "Meneame: pingback, the provided URL does not seem to work: {$pagelinkedfrom} - {$pagelinkedto}");
         return new IXR_Error(16, 'The source URL does not exist.');
     }
     if (preg_match('/charset=([a-zA-Z0-9-_]+)/i', $contents, $matches)) {
         $this->encoding = trim($matches[1]);
         if (strcasecmp($this->encoding, 'utf-8') != 0) {
             $contents = iconv($this->encoding, 'UTF-8//IGNORE', $contents);
         }
     }
     // Check is links back to us
     $permalink = $link->get_permalink();
     $permalink_q = preg_quote($permalink, '/');
     $pattern = "/<\\s*a[^>]+href=[\"']" . $permalink_q . "[#\\/0-9a-z\\-]*[\"'][^>]*>/i";
     if (!preg_match($pattern, $contents)) {
         syslog(LOG_NOTICE, "Meneame: pingback, the provided URL does not have a link back to us: {$pagelinkedfrom} - {$pagelinkedto}");
         return new IXR_Error(17, 'The source URL does not contain a link to the target URL, and so cannot be used as a source.');
     }
     // Search Title
     if (preg_match('/<title[^<>]*>([^<>]*)<\\/title>/si', $contents, $matches)) {
         $url_title = clean_text($matches[1]);
         if (mb_strlen($url_title) > 3) {
             $title = $url_title;
         }
     }
     if (empty($title)) {
         syslog(LOG_NOTICE, "Meneame: pingback, cannot find a title on that page: {$pagelinkedfrom} - {$pagelinkedto}");
         return new IXR_Error(32, 'We cannot find a title on that page.');
     }
     $title = mb_strlen($title) > 120 ? mb_substr($title, 0, 120) . '...' : $title;
     $trackres->title = $title;
     $trackres->status = 'ok';
     $trackres->store();
     syslog(LOG_NOTICE, "Meneame: pingback ok: {$pagelinkedfrom} - {$pagelinkedto}");
     return "Pingback from registered. Keep the web talking! :-)";
 }
Exemple #20
0
     $karma_mess = sprintf("<br>updated karma: %6d (%d, %d) -> %-6d (%d, %d)\n", $link->karma, $link->votes, $link->negatives, round($dblink->karma), $votes_pos, $votes_neg);
     if ($link->karma > $dblink->karma) {
         $changes = 1;
     } else {
         $changes = 2;
     }
     // increase
     $link->karma = round($dblink->karma);
     $link->votes = $votes_pos;
     $link->negatives = $votes_neg;
     $link->store_basic();
 } else {
     $karma_mess = '';
 }
 print "<tr><td class='tnumber{$imod}'>{$link->id}</td><td class='tnumber{$imod}'>" . $link->votes . "</td><td class='tnumber{$imod}'>" . $link->negatives . "</td><td class='tnumber{$imod}'>" . intval($link->karma) . "</td>";
 echo "<td class='tdata{$imod}'><a href='" . $link->get_permalink() . "'>{$link->title}</a>\n";
 echo "{$karma_mess}</td>\n";
 /*
 if ($link->votes >= $min_votes && $dblink->karma >= $min_karma && $published < $max_to_publish) {
 	$published++;
 	$link->karma = $dblink->karma;
 	$link->status = 'published';
 	$link->published_date=time();
 	$link->store_basic();
 	$changes = 3; // to show a "published" later	
 }
 */
 echo "<td class='tnumber{$imod}'>";
 switch ($changes) {
     case 1:
         echo '<img src="../img/common/sneak-problem01.png" width="21" height="17" alt="' . _('descenso') . '"/>';

do_header($title);

$link = new Link;
$links = $db->get_col($sql);
if ($links) {
	foreach($links as $link_id) {
		$link->id=$link_id;
		$link->read();
		$category_name = $db->get_var("SELECT category_name FROM categories WHERE category_id = $link->category AND category_lang='$dblang'");
		$content = text_to_html($link->content);
		echo "	<item>\n";
		// Title must not carry htmlentities
		echo "		<title><![CDATA[".html_entity_decode($link->title)."]]></title>\n";
		echo "		<link>".$link->get_permalink()."</link>\n";
		echo "		<comments>".$link->get_permalink()."</comments>\n";
		if (!empty($link_date))
			echo "		<pubDate>".date("r", $link->$link_date)."</pubDate>\n";
		else echo "      <pubDate>".date("r", time())."</pubDate>\n";
		echo "		<dc:creator>$link->username</dc:creator>\n";
		echo "		<category>$category_name</category>\n";
		// Add tags as categories
		if (!empty($link->tags)) {
			$tags_array = explode(",", $link->tags);
			foreach ($tags_array as $tag_item) {
				$tag_item=trim($tag_item);
				echo "		<category>$tag_item</category>\n";
			}
		}
		echo "		<guid>".$link->get_permalink()."</guid>\n";
Exemple #22
0
function do_top($string)
{
    global $db, $globals;
    $rank = "<strong>Top</strong> ";
    $sql = "select link_id from links where link_date > date_sub(now(), interval 4 day) and link_status='queued' order by link_karma desc limit 3";
    $result = $db->get_results($sql);
    foreach ($result as $linkid) {
        $link = new Link();
        $link->id = $linkid->link_id;
        $link->read_basic();
        $rank .= '<br/> ' . $link->get_permalink() . " ({$link->karma})";
    }
    return $rank;
}
Exemple #23
0
 // Check if it was depubished before
 $depublished = (int) $db->get_var("select count(*) from logs where log_type = 'link_depublished' and log_ref_id = {$link->id}");
 if ($depublished > 0) {
     $karma_new *= 0.5;
     $link->message .= 'Previously depublished' . '<br/>';
     $link->annotation .= _('previamente quitada de portada') . "<br/>";
 }
 $link->karma = round($karma_new);
 // check differences, if > 4 store it
 if (abs($link->old_karma - $link->karma) > 6) {
     // Check percentage of low karma votes if difference > 20 (to avoid sending too many messages
     if ($link->old_karma > $link->karma + 20 && !empty($globals['adm_email']) && intval($link->low_karma_perc) >= 85) {
         echo "LOW KARMA WARN {$link->uri}\n";
         $subject = _('AVISO: enlace con muchos votos de karma menor que la media');
         $body = "Perc: {$link->low_karma_perc}% User votes: {$link->votes} Negatives: {$link->negatives}\n\n";
         $body .= $link->get_permalink();
         mail($globals['adm_email'], $subject, $body);
     }
     $link->message = sprintf("updated karma: %6d (%d, %d, %d) -> %-6d<br/>\n", $link->old_karma, $link->votes, $link->anonymous, $link->negatives, $link->karma) . $link->message;
     //$link->annotation .= _('ajuste'). ": $link->old_karma -&gt; $link->karma <br/>";
     if ($link->old_karma > $link->karma) {
         $changes = 1;
     } else {
         $changes = 2;
     }
     // increase
     if (!DEBUG) {
         $link->store_basic();
         $link->save_annotation('link-karma');
     } else {
         $link->message .= "To store: previous: {$link->old_karma} new: {$link->karma}<br>\n";
#! /usr/bin/env php
<?php 
include '../config.php';
include mnminclude . 'webimages.php';
$sql = "select link_id from links where link_status='queued' and link_thumb_status = 'unknown' and link_date > date_sub(now(), interval 8 hour) and link_date < date_sub(now(), interval 1 minute) and link_votes > 1 and link_votes > link_negatives * 10 order by link_date desc limit 10";
$res = $db->get_col($sql);
foreach ($res as $l) {
    $link = new Link();
    $link->id = $l;
    $link->read();
    echo $link->get_permalink() . ": ";
    if ($thumb = $link->get_thumb()) {
        echo $thumb;
    } else {
        echo "NO thumb";
    }
    echo "\n";
    ob_flush();
    flush();
}
Exemple #25
0
    print_index_tabs();
} else {
    print_index_tabs(0);
    $from_where = "FROM links WHERE link_status='published' ";
}
echo '<div id="banner"><img src="images/banner.png" alt="MeneameDS" /></div>' . "\n";
echo '<div id="container">';
$links = $db->get_col("SELECT link_id {$from_where} order by link_date desc LIMIT {$page_size}");
if ($links) {
    foreach ($links as $link_id) {
        $link->id = $link_id;
        $link->read();
        echo '<div class="news-summary">';
        echo '<div class="news-title"><a href="' . htmlspecialchars($link->url) . '">' . $link->title . '</a></div>' . "\n";
        echo '<p class="news-content">' . text_to_html($link->content) . '</p>' . "\n";
        echo '<div class="news-footer">' . $link->votes . ' votos &#187; ' . '<a href="' . $link->get_permalink() . '">en menéame</a>' . "\n";
        echo '</div></div>';
    }
}
echo "</div>\n";
echo "</body></html>";
function print_index_tabs($option = -1)
{
    global $globals, $db;
    echo '<div id="home-links">' . "\n";
    $active = array();
    // NOTA: Sólo se usa tabsub-this para la seleccionada, las demás van vacías
    // y es sólo para la activa
    if ($option == 0) {
        $class_tab = 'class="tab-active"';
    } else {
Exemple #26
0
    array_shift($url_args);
    // The first element is always a "/"
    $link->uri = $db->escape($url_args[0]);
    if (!$link->read('uri')) {
        not_found();
    }
} else {
    $url_args = preg_split('/\\/+/', $_REQUEST['id']);
    $link->id = intval($url_args[0]);
    if (is_numeric($url_args[0]) && $link->read('id')) {
        // Redirect to the right URL if the link has a "semantic" uri
        if (!empty($link->uri) && !empty($globals['base_story_url'])) {
            if (!empty($url_args[1])) {
                $extra_url = '/' . urlencode($url_args[1]);
            }
            header('Location: ' . $link->get_permalink() . $extra_url);
            die;
        }
    } else {
        not_found();
    }
}
if ($link->is_discarded()) {
    // Dont allow indexing of discarded links
    if ($globals['bot']) {
        not_found();
    }
} else {
    //Only shows ads in non discarded images
    $globals['ads'] = true;
}
Exemple #27
0
echo '<div class="air-with-footer">' . "\n";
$comments = $db->get_results("SELECT comment_id, link_id FROM comments, links WHERE comment_date > date_sub(now(), interval 24 hour) and link_id=comment_link_id ORDER BY comment_karma desc, link_id asc limit 25");
if ($comments) {
    foreach ($comments as $dbcomment) {
        $link->id = $dbcomment->link_id;
        $comment->id = $dbcomment->comment_id;
        $link->read();
        $comment->read();
        if ($last_link != $link->id) {
            if ($counter % 12 == 5) {
                // AdSense
                do_banner_story();
            }
            //$link->print_summary('short');
            echo '<h3>';
            echo '<a href="' . $link->get_permalink() . '">' . $link->title . '</a>';
            echo '</h3>';
        }
        echo '<ol class="comments-list">';
        $comment->print_summary($link, 2000, false);
        if ($last_link != $link->id) {
            $last_link = $link->id;
            $counter++;
        }
        echo "</ol>\n";
    }
}
echo '</div>';
echo '</div>';
echo '</div>';
do_sidebar_top();