// The source code packaged with this file is Free Software, Copyright (C) 2005 by
// Ricardo Galli .
// 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".
require_once('config.php');
require_once(mnminclude.'html1.php');
require_once(mnminclude.'link.php');
require_once(mnminclude.'tags.php');
require_once(mnminclude.'ban.php');
require_once(mnminclude.'blog.php');
require_once(mnminclude.'thumbnails.php');
$globals['ads'] = true;
if(isset($_POST["phase"])) {
force_authentication();
switch ($_POST["phase"]) {
case 1:
do_header(_("enviar noticia"), "post");
do_submit1();
break;
case 2:
do_header(_("enviar noticia"), "post");
do_submit2();
break;
case 3:
do_submit3();
break;
}
} else {
check_already_sent();
force_authentication();
do_header(_("enviar noticia"), "post");
do_submit0();
}
do_footer();
exit;
function preload_indicators() {
global $globals;
echo ''."\n";
}
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->id = $found;
if($linkres->read()) {
header('Location: ' . $linkres->get_permalink());
die;
}
}
}
}
function print_empty_submit_form() {
global $globals;
preload_indicators();
if (!empty($_GET['url'])) {
$url = clean_input_url($_GET['url']);
} else {
$url = 'http://';
}
echo '
';
echo '';
echo '
';
}
function do_submit0() {
do_banner_top();
echo '
' . "\n";
echo '
'."\n";
echo '
'._('envío de una nueva noticia: paso 1 de 3').'
';
echo '
';
echo '
'._('por favor, respeta estas instrucciones para mejorar la calidad:').'
';
echo '
';
echo '
'._('contenido interesante').': '._('¿la noticia conseguirá suficientes votos por méritos propios? esto es, sin que haga falta la ayuda de tus amigos, conocidos y saludados. usa la empatía para intentar averiguarlo: ¿interesará a una cantidad razonable de lectores?').'
';
echo '
'._('enlaza la fuente original').': '._('no hagas perder tiempo a los lectores.').'
'. "\n";
return;
}
// avoid spams, an extra security check
// it counts the numbers of links in the last 2 hours
$same_user = $db->get_var("select count(*) from links where link_date > date_sub(now(), interval 2 hour) and link_author=$current_user->user_id and link_votes > 0");
$same_ip = $db->get_var("select count(*) from links, votes where link_date > date_sub(now(), interval 2 hour) and vote_type='links' and vote_link_id = link_id and vote_user_id = link_author and vote_ip_int = ".$globals['user_ip_int']);
if ($same_user > 6 || $same_ip > 6 ) {
echo '
'._('debes esperar, ya se enviaron varias con el mismo usuario o dirección IP'). '
';
echo ' ' . "\n";
echo '
'. "\n";
return;
}
// avoid users sending continuous "rubbsih" or "propaganda", specially new users
// it takes in account the number of positive votes in the last six hours
if ($same_user > 1 && $current_user->user_karma < 7.5) {
$positives_received = $db->get_var("select count(*) from votes left join links on link_date > date_sub(now(), interval 6 hour) and link_author = $current_user->user_id where vote_type='links' and vote_link_id = link_id and vote_user_id > 0 and vote_value > 0");
$negatives_received = $db->get_var("select count(*) from votes left join links on link_date > date_sub(now(), interval 6 hour) and link_author = $current_user->user_id where vote_type='links' and vote_link_id = link_id and vote_user_id > 0 and vote_value < 0");
echo "\n";
echo "\n";
if ($negatives_received > $positives_received * 1.5) {
echo '
'._('debes esperar, has tenido demasiados votos negativos en tus últimos envíos'). '
'._('URL inválido, incompleto o no permitido'). ' ('. $globals['ban_message'].')
';
// If the domain is banned, decrease user's karma
if ($linkres->banned) {
$db->query("update users set user_karma = user_karma - 0.05 where user_id = $current_user->user_id");
}
print_empty_submit_form();
echo ''. "\n";
return;
}
// If the URL has changed, check again is not dupe
if($linkres->url != $url && report_dupe($linkres->url)) return;
$linkres->randkey = intval($_POST['randkey']);
if(!$linkres->valid) {
echo '
'._('error leyendo el url').': '.htmlspecialchars($url).'
';
// Dont allow new users with low karma to post wrong URLs
if ($current_user->user_karma < 8 && $current_user->user_level == 'normal') {
echo '
'._('URL inválido, incompleto o no permitido').'
';
print_empty_submit_form();
return;
}
echo '
'._('no es válido, está fuera de línea, o tiene mecanismos antibots, continúa, pero asegúrate que sea correcto').'
';
}
// check that the user also votes, not only sends links
if ($current_user->user_karma < 7) {
$from = time() - 3600*24;
$user_votes = $db->get_var("select count(*) from votes where vote_type='links' and vote_date > from_unixtime($from) and vote_user_id=$current_user->user_id");
$user_links = 1 + $db->get_var("select count(*) from links where link_author=$current_user->user_id and link_date > from_unixtime($from) and link_status != 'discard'");
$total_links = $db->get_var("select count(*) from links where link_date > from_unixtime($from) and link_status = 'queued'");
$min_votes = min(4, intval($total_links/20)) * $user_links;
if ($user_votes < $min_votes) {
$needed = $min_votes - $user_votes;
echo '
'._('no tienes el mínimo de votos necesarios para enviar una nueva historia').'
';
echo ' ' . "\n";
echo ''. "\n";
return;
}
}
$linkres->status='discard';
$linkres->author=$current_user->user_id;
if (!$linkres->trackback()) {
$linkres->pingback();
}
$trackback=htmlspecialchars($linkres->trackback);
$linkres->create_blog_entry();
$blog = new Blog;
$blog->id = $linkres->blog;
$blog->read();
$blog_url_components = @parse_url($blog->url);
$blog_url = $blog_url_components[host].$blog_url_components[path];
// Now we check against the blog table
// it's done because there could be banned blogs like http://lacotelera.com/something
if(check_ban($blog_url, 'hostname', false)) {
echo '
';
syslog(LOG_NOTICE, "Meneame, banned site ($current_user->user_login): $blog->url <- $_POST[url]");
print_empty_submit_form();
echo ''. "\n";
return;
}
// avoid auto-promotion (autobombo)
$minutes = 15;
$same_blog = $db->get_var("select count(*) from links where link_date > date_sub(now(), interval $minutes minute) and link_author=$current_user->user_id and link_blog=$linkres->blog and link_votes > 0");
if ($same_blog > 0 && $current_user->user_karma < 12) {
syslog(LOG_NOTICE, "Meneame, forbidden due to short period between links to same site ($current_user->user_login): $linkres->url");
echo '
'._('ya has enviado un enlace al mismo sitio hace poco tiempo').'
';
echo '
'._('debes esperar'). " $minutes " . _(' minutos entre cada envío al mismo sitio.') . ', ';
echo ''._('lee el FAQ').'
';
echo ' ' . "\n";
echo ''. "\n";
return;
}
// Avoid spam, count links in last two months
$sents = $db->get_var("select count(*) from links where link_author=$current_user->user_id and link_date > date_sub(now(), interval 60 day) and link_votes > 0");
$same_blog = $db->get_var("select count(*) from links where link_author=$current_user->user_id and link_date > date_sub(now(), interval 60 day) and link_blog=$linkres->blog and link_votes > 0");
if ($sents > 2 && $same_blog > 0 && ($ratio = $same_blog/$sents) > 0.5) {
// Check if the domain should be banned
// Calculate ban period according to previous karma
$avg_karma = (int) $db->get_var("select avg(link_karma) from links where link_blog=$blog->id and link_date > date_sub(now(), interval 30 day) and link_votes > 0");
// This is the case of unique/few users sending just their site and take care of choosing goog titles and text
// the condition is stricter, more links and higher ratio
if (($sents > 2 && $ratio > 0.9) || ($sents > 6 && $ratio > 0.8) || ($sents > 12 && $ratio > 0.6)) {
$unique_users = (int) $db->get_var("select count(distinct link_author) from links where link_blog=$blog->id and link_date > date_sub(now(), interval 15 day);");
if ($unique_users < 3) {
if ($avg_karma < -10) {
$ban_period = 86400*30;
$ban_period_txt = _('un mes');
} else {
$ban_period = 86400*7;
$ban_period_txt = _('una semana');
}
syslog(LOG_NOTICE, "Meneame, high ratio ($ratio) and few users ($unique_users), going to ban $blog->url ($current_user->user_login)");
}
// Otherwise check previous karma
} elseif ($sents > 4 && $avg_karma < 30) {
if ($avg_karma < -40) {
$ban_period = 86400*30;
$ban_period_txt = _('un mes');
} elseif ($avg_karma < -10) {
$ban_period = 86400*7;
$ban_period_txt = _('una semana');
} elseif ($avg_karma < 10) {
$ban_period = 86400;
$ban_period_txt = _('un día');
} else {
$ban_period = 7200;
$ban_period_txt = _('dos horas');
}
syslog(LOG_NOTICE, "Meneame, high ratio ($ratio) and low karma ($avg_karma), going to ban $blog->url ($current_user->user_login)");
}
if ($ban_period > 0) {
echo '
'._('ya has enviado demasiados enlaces a')." $blog->url".'
';
echo '
'._('varía tus fuentes, es para evitar abusos y enfados por votos negativos') . ', ';
echo ''._('lee el FAQ').'
'._('el dominio'). " '$banned_host' ". _('ha sido baneado por')." $ban_period_txt
";
syslog(LOG_NOTICE, "Meneame, banned '$ban_period_txt' due to high ratio ($current_user->user_login): $banned_host <- $linkres->url");
} else {
syslog(LOG_NOTICE, "Meneame, error parsing during ban: $blog->id, $blog->url ($current_user->user_login)");
}
echo ' ' . "\n";
echo ''. "\n";
return;
} else {
echo '
'._('Aviso, estás enviando noticias del mismo web, podrías recibir muchos votos negativos y/o el sitio podría ser baneado automáticamente si continúas enviando').'
';
syslog(LOG_NOTICE, "Meneame, warn, high ratio ($current_user->user_login): $linkres->url");
}
}
// check there is no an "overflow" from the same site
if ($current_user->user_karma < 15) {
$total_links = $db->get_var("select count(*) from links where link_date > date_sub(now(), interval 24 hour)");
$site_links = intval($db->get_var("select count(*) from links where link_date > date_sub(now(), interval 24 hour) and link_blog=$linkres->blog"));
if ($site_links > 5 && $site_links > $total_links * 0.04) { // Only 4% from the same site
syslog(LOG_NOTICE, "Meneame, forbidden due to overflow to the same site ($current_user->user_login): $linkres->url");
echo '
'._('ya se han enviado demasiadas noticias del mismo sitio, espera unos minutos por favor').'
';
echo '
'._('total en 24 horas').": $site_links , ". _('el máximo actual es'). ': ' . intval($total_links * 0.04). '
';
echo ' ' . "\n";
echo ''. "\n";
return;
}
}
// Now stores new draft
$linkres->store();
echo '
'._('envío de una nueva noticia: paso 2 de 3').'
'."\n";
echo '
'."\n";
echo '
'."\n";
echo '
'."\n";
echo ''._('Opcional. Esta función puede dar error o largos tiempos de espera. Pulsa en cargar imágenes y selecciona la que quieras adjuntar al enlace.').''."\n";
echo ' '._('Mostrar imágenes').'';
echo '
';
///////////// End of TODO
echo ' ';
echo '
'."\n";
if (empty($trackback)) {
echo ''._('puedes agregar o cambiar el trackback si ha sido detectado automáticamente').''."\n";
echo '