本文整理汇总了PHP中check_ban_proxy函数的典型用法代码示例。如果您正苦于以下问题:PHP check_ban_proxy函数的具体用法?PHP check_ban_proxy怎么用?PHP check_ban_proxy使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了check_ban_proxy函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: insert_comment
function insert_comment()
{
global $link, $db, $current_user, $globals;
$error = '';
require_once mnminclude . 'ban.php';
if (check_ban_proxy()) {
return _('dirección IP no permitida');
}
// Check if is a POST of a comment
if ($link->votes > 0 && $link->date > $globals['now'] - $globals['time_enabled_comments'] && $link->comments < $globals['max_comments'] && intval($_POST['link_id']) == $link->id && $current_user->authenticated && intval($_POST['user_id']) == $current_user->user_id && ($current_user->user_karma > $globals['min_karma_for_comments'] || $current_user->user_id == $link->author) && intval($_POST['randkey']) > 0 && mb_strlen(trim($_POST['comment_content'])) > 2) {
require_once mnminclude . 'comment.php';
$comment = new Comment();
$comment->link = $link->id;
$comment->randkey = intval($_POST['randkey']);
$comment->author = intval($_POST['user_id']);
$comment->karma = round($current_user->user_karma);
$comment->content = clean_text($_POST['comment_content'], 0, false, 10000);
// Check if is an admin comment
if ($current_user->user_level == 'god' && $_POST['type'] == 'admin') {
$comment->karma = 20;
$comment->type = 'admin';
}
if (mb_strlen($comment->content) > 0 && preg_match('/[a-zA-Z:-]/', $_POST['comment_content'])) {
// Check there are at least a valid char
$already_stored = intval($db->get_var("select count(*) from comments where comment_link_id = {$comment->link} and comment_user_id = {$comment->author} and comment_randkey = {$comment->randkey}"));
// Check the comment wasn't already stored
if (!$already_stored) {
if ($comment->type != 'admin') {
// Lower karma to comments' spammers
$comment_count = (int) $db->get_var("select count(*) from comments where comment_user_id = {$current_user->user_id} and comment_date > date_sub(now(), interval 3 minute)");
// Check the text is not the same
$same_count = $comment->same_text_count() + $comment->same_links_count();
} else {
$comment_count = $same_count = 0;
}
if ($comment_count > 2 || $same_count > 2) {
require_once mnminclude . 'user.php';
$reduction = 0;
if ($comment_count > 3) {
$reduction += ($comment_count - 3) * 0.1;
}
if ($same_count > 1) {
$reduction += $same_count * 0.25;
}
if ($reduction > 0) {
$user = new User();
$user->id = $current_user->user_id;
$user->read();
$user->karma = $user->karma - $reduction;
syslog(LOG_NOTICE, "Meneame: story decreasing {$reduction} of karma to {$current_user->user_login} (now {$user->karma})");
$user->store();
$error .= ' ' . 'penalización de karma por texto repetido o abuso de enlaces';
}
}
$comment->store();
$comment->insert_vote();
$link->update_comments();
// Re read link data
$link->read();
} else {
$error .= ' ' . 'duplicado';
}
} else {
$error .= ' ' . 'caracteres no válidos';
}
// We don't redirect, Firefox show cache data instead of the new data since we send lastmodification time.
//header('Location: '.$link->get_permalink());
//die;
} else {
$error .= ' ' . 'texto muy breve, karma bajo o usuario incorrecto';
}
return $error;
}
示例2: check_chat
function check_chat()
{
global $db, $current_user, $now, $now_f, $globals, $events;
if (empty($_POST['chat'])) {
return;
}
$comment = trim(preg_replace("/[\r\n\t]/", ' ', $_REQUEST['chat']));
$comment = clear_whitespace($comment);
if ($current_user->user_id > 0 && strlen(strip_tags($comment)) > 2) {
// Sends a message back if the user has a very low karma
if ($globals['min_karma_for_sneaker'] > 0 && $current_user->user_karma < $globals['min_karma_for_sneaker']) {
$comment = _('no tienes suficiente karma para comentar en la fisgona') . ' (' . $current_user->user_karma . ' < ' . $globals['min_karma_for_sneaker'] . ')';
send_chat_warn($comment);
return;
}
$period = $now - 4;
$counter = intval($db->get_var("select count(*) from chats where chat_time > {$period} and chat_uid = {$current_user->user_id}"));
if ($counter > 0) {
$comment = _('tranquilo charlatán') . ' ;-)';
send_chat_warn($comment);
return;
}
if (check_ban_proxy()) {
send_chat_warn(_('proxy abierto no permitido'));
return;
}
if (preg_match('/^!/', $comment)) {
require_once 'sneaker-stats.php';
if (!($comment = check_stats($comment))) {
send_chat_warn(_('comando no reconocido'));
} else {
send_string($comment);
}
return;
} else {
$comment = clean_text_with_tags($comment);
$comment = preg_replace('/(^|[\\s\\.,¿#@])\\/me([\\s\\.,\\?]|$)/', "\$1<i>{$current_user->user_login}</i>\$2", $comment);
if (mb_strlen($comment) > 255) {
// Cut text longer that database, to avoid unclosed html tags
$comment = mb_substr($comment, 0, 1) . mb_substr($comment, -254, 254);
}
}
$from = $now - 1500;
$db->query("delete from chats where chat_time < {$from}");
if ((!empty($_REQUEST['admin']) || preg_match('/^#/', $comment)) && $current_user->admin) {
$room = 'admin';
$comment = preg_replace('/^# */', '', $comment);
} elseif (!empty($_REQUEST['friends']) || preg_match('/^@/', $comment)) {
$room = 'friends';
$comment = preg_replace('/^@ */', '', $comment);
} else {
$room = 'all';
}
if (strlen($comment) > 0) {
$comment = $db->escape(trim(normalize_smileys($comment)));
$db->query("insert into chats (chat_time, chat_uid, chat_room, chat_user, chat_text) values ({$now_f}, {$current_user->user_id}, '{$room}', '{$current_user->user_login}', '{$comment}')");
}
}
}
示例3: header
<?php
// The source code packaged with this file is Free Software, Copyright (C) 2005 by
// Ricardo Galli <gallir at uib dot es>.
// 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".
include '../config.php';
include_once mnminclude . 'ban.php';
header('Content-Type: application/json; charset=UTF-8');
if (check_ban_proxy()) {
error(_('IP no permitida'));
}
if (!($id = check_integer('id'))) {
error(_('falta el ID del comentario'));
}
if (empty($_REQUEST['user'])) {
error(_('falta el código de usuario'));
}
if ($current_user->user_id != $_REQUEST['user']) {
error(_('usuario incorrecto') . $current_user->user_id . '-' . htmlspecialchars($_REQUEST['user']));
}
if (!check_security_key($_REQUEST['key'])) {
error(_('clave de control incorrecta'));
}
if (empty($_REQUEST['value']) || !is_numeric($_REQUEST['value'])) {
error(_('falta valor del voto'));
}
if ($current_user->user_karma < $globals['min_karma_for_post_votes']) {
error(_('karma bajo para votar comentarios'));
示例4: include
<?
// The source code packaged with this file is Free Software, Copyright (C) 2005 by
// Ricardo Galli <gallir at uib dot es>.
// 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".
include('../config.php');
include(mnminclude.'ban.php');
header('Content-Type: application/json; charset=UTF-8');
array_push($globals['cache-control'], 'no-cache');
http_cache();
if(!$globals["development"] && check_ban_proxy()) {
error(_('IP no permitida'));
}
if(!($id=check_integer('id'))) {
error(_('falta el ID del comentario'));
}
if(empty($_REQUEST['user'])) {
error(_('falta el código de usuario'));
}
if($current_user->user_id != $_REQUEST['user']) {
error(_('usuario incorrecto'));
}
示例5: save_from_post
static function save_from_post($link) {
global $db, $current_user, $globals;
require_once(mnminclude.'ban.php');
$error = '';
if(check_ban_proxy() && !$globals['development']) return _('dirección IP no permitida');
// Check if is a POST of a comment
if( ! ($link->votes > 0 && $link->date > $globals['now']-$globals['time_enabled_comments']*1.01 &&
$link->comments < $globals['max_comments'] &&
intval($_POST['link_id']) == $link->id && $current_user->authenticated &&
intval($_POST['user_id']) == $current_user->user_id &&
intval($_POST['randkey']) > 0
)) {
return _('comentario o usuario incorrecto');
}
if ($current_user->user_karma < $globals['min_karma_for_comments'] && $current_user->user_id != $link->author) {
return _('karma demasiado bajo');
}
$comment = new Comment;
$comment->link=$link->id;
$comment->ip = $db->escape($globals['user_ip']);
$comment->randkey=intval($_POST['randkey']);
$comment->author=intval($_POST['user_id']);
$comment->karma=round($current_user->user_karma);
$comment->content=clean_text_with_tags($_POST['comment_content'], 0, false, 10000);
$comment->parent=intval($_POST['parent_id']);
//get level
$parentComment = new Comment();
$parentComment->id = intval($comment->parent);
$parentComment->read_basic();
if ($parentComment->nested_level > $globals['NESTED_COMMENTS_MAX_LEVEL']) {
return _('Chegache ao nivel límite de comentarios aniñados...');
}
$comment->nested_level = $parentComment->nested_level + 1;
// Check if is an admin comment
if ($current_user->user_level == 'god' && $_POST['type'] == 'admin') {
$comment->type = 'admin';
}
// Don't allow to comment with a clone
$hours = intval($globals['user_comments_clon_interval']);
if ($hours > 0) {
$clones = $current_user->get_clones($hours+1);
if ( $clones) {
$l = implode(',', $clones);
$c = (int) $db->get_var("select count(*) from comments where comment_date > date_sub(now(), interval $hours hour) and comment_user_id in ($l)");
if ($c > 0) {
syslog(LOG_NOTICE, "Meneame, clon comment ($current_user->user_login, $comment->ip) in $link->uri");
return _('ya hizo un comentario con usuarios clones');
}
}
}
// Basic check to avoid abuses from same IP
if (!$current_user->admin && $current_user->user_karma < 6.2) { // Don't check in case of admin comments or higher karma
// Avoid astroturfing from the same link's author
if ($link->status != 'published' && $link->ip == $globals['user_ip'] && $link->author != $comment->author) {
UserAuth::insert_clon($comment->author, $link->author, $link->ip);
syslog(LOG_NOTICE, "Meneame, comment-link astroturfing ($current_user->user_login, $link->ip): ".$link->get_permalink());
return _('no se puede comentar desde la misma IP del autor del envío');
}
// Avoid floods with clones from the same IP
if (intval($db->get_var("select count(*) from comments where comment_link_id = $link->id and comment_ip='$comment->ip' and comment_user_id != $comment->author")) > 1) {
syslog(LOG_NOTICE, "Meneame, comment astroturfing ($current_user->user_login, $comment->ip)");
return _('demasiados comentarios desde la misma IP con usuarios diferentes');
}
}
if (mb_strlen($comment->content) < 5 || ! preg_match('/[a-zA-Z:-]/', $_POST['comment_content'])) { // Check there are at least a valid char
return _('texto muy breve o caracteres no válidos');
}
// Check the comment wasn't already stored
$already_stored = intval($db->get_var("select count(*) from comments where comment_link_id = $comment->link and comment_user_id = $comment->author and comment_randkey = $comment->randkey"));
if ($already_stored) {
return _('comentario duplicado');
}
if (! $current_user->admin) {
$comment->get_links();
if ($comment->banned && $current_user->Date() > $globals['now'] - 86400) {
syslog(LOG_NOTICE, "Meneame: comment not inserted, banned link ($current_user->user_login)");
return _('comentario no insertado, enlace a sitio deshabilitado (y usuario reciente)');
}
// Lower karma to comments' spammers
$comment_count = (int) $db->get_var("select count(*) from comments where comment_user_id = $current_user->user_id and comment_date > date_sub(now(), interval 3 minute)");
//.........这里部分代码省略.........
示例6: do_submit1
function do_submit1() {
global $db, $dblang, $current_user, $globals;
$url = clean_input_url($_POST['url']);
$url = preg_replace('/^http:\/\/http:\/\//', 'http://', $url); // Some users forget to delete the foo http://
if (! preg_match('/^\w{3,6}:\/\//', $url)) { // http:// forgotten, add it
$url = 'http://'.$url;
}
$url = preg_replace('/#[^\/]*$/', '', $url); // Remove the "#", people just abuse
echo '<div>'."\n";
$new_user = false;
if (!check_link_key()) {
echo '<p class="error"><strong>'._('clave incorrecta').'</strong></p> ';
echo '</div>'. "\n";
return;
}
if ($globals['min_karma_for_links'] > 0 && $current_user->user_karma < $globals['min_karma_for_links'] ) {
echo '<p class="error"><strong>'._('no tienes el mínimo de karma para enviar una nueva historia').'</strong></p> ';
echo '</div>'. "\n";
return;
}
// Don't allow to send a link by a clone
$hours = intval($globals['user_links_clon_interval']);
$clones = $current_user->get_clones($hours+1);
if ($hours > 0 && $clones) {
$l = implode(',', $clones);
$c = (int) $db->get_var("select count(*) from links where link_status!='published' and link_date > date_sub(now(), interval $hours hour) and link_author in ($l)");
if ($c > 0) {
echo '<p class="error">'._('ya se envió con otro usuario «clon» en las últimas horas'). ", "._('disculpa las molestias'). ' </p>';
syslog(LOG_NOTICE, "Meneame, clon submit ($current_user->user_login): $_POST[url]");
echo '<br style="clear: both;" />' . "\n";
echo '</div>'. "\n";
return;
}
}
// Check the number of links sent by a user
$queued_24_hours = (int) $db->get_var("select count(*) from links where link_status!='published' and link_date > date_sub(now(), interval 24 hour) and link_author=$current_user->user_id");
if (!$globals['development'])
if ($globals['limit_user_24_hours'] && $queued_24_hours > $globals['limit_user_24_hours']) {
echo '<p class="error">'._('debes esperar, tienes demasiados envíos en cola de las últimas 24 horas'). " ($queued_24_hours), "._('disculpa las molestias'). ' </p>';
syslog(LOG_NOTICE, "Meneame, too many queued in 24 hours ($current_user->user_login): $_POST[url]");
echo '<br style="clear: both;" />' . "\n";
echo '</div>'. "\n";
return;
}
// check the URL is OK and that it resolves
$url_components = @parse_url($url);
if (!$url_components || ! $url_components['host'] || gethostbyname($url_components['host']) == $url_components['host']) {
echo '<p class="error"><strong>'._('URL o nombre de servidor erróneo').'</strong></p> ';
echo '<p>'._('el nombre del servidor es incorrecto o éste tiene problemas para resolver el nombre'). ' </p>';
syslog(LOG_NOTICE, "Meneame, hostname error ($current_user->user_login): $url");
print_empty_submit_form();
echo '</div>'. "\n";
return;
}
$enqueued_last_minutes = (int) $db->get_var("select count(*) from links where link_status='queued' and link_date > date_sub(now(), interval 3 minute)");
if ($current_user->user_karma > $globals['limit_3_minutes_karma']) $enqueued_limit = $globals['limit_3_minutes'] * 1.5;
else $enqueued_limit = $globals['limit_3_minutes'];
if ($enqueued_last_minutes > $enqueued_limit) {
echo '<p class="error"><strong>'._('exceso de envíos').':</strong></p>';
echo '<p>'._('se han enviado demasiadas historias en los últimos 3 minutos'). " ($enqueued_last_minutes > $enqueued_limit), "._('disculpa las molestias'). ' </p>';
syslog(LOG_NOTICE, "Meneame, too many queued ($current_user->user_login): $_POST[url]");
echo '</div>'. "\n";
return;
}
// Check the user does not have too many drafts
$minutes = intval($globals['draft_time'] / 60) + 10;
$drafts = (int) $db->get_var("select count(*) from links where link_author=$current_user->user_id and link_date > date_sub(now(), interval $minutes minute) and link_status='discard' and link_votes = 0");
if (!$globals['development'])
if ($drafts > $globals['draft_limit']) {
echo '<p class="error"><strong>'._('demasiados borradores').':</strong></p>';
echo '<p>'._('has hecho demasiados intentos, debes esperar o continuar con ellos desde la'). ' <a href="shakeit.php?meta=_discarded">'. _('cola de descartadas').'</a></p>';
syslog(LOG_NOTICE, "Meneame, too many drafts ($current_user->user_login): $_POST[url]");
echo '</div>'. "\n";
return;
}
// Delete dangling drafts
if ($drafts > 0) {
$db->query("delete from links where link_author=$current_user->user_id and link_date > date_sub(now(), interval 30 minute) and link_date < date_sub(now(), interval 10 minute) and link_status='discard' and link_votes = 0");
}
// Check for banned IPs
if (!$globals['development'])
if(($ban = check_ban($globals['user_ip'], 'ip', true)) || ($ban = check_ban_proxy())) {
echo '<p class="error"><strong>'._('dirección IP no permitida para enviar').':</strong> '.$globals['user_ip'].'</p>';
echo '<p><strong>'._('Razón').'</strong>: '.$ban['comment'].'</p>';
if ($ban['expire'] > 0) {
echo '<p class="note"><strong>'._('caduca').'</strong>: '.get_date_time($ban['expire']).'</p>';
}
syslog(LOG_NOTICE, "Meneame, banned IP $globals[user_ip] ($current_user->user_login): $url");
//.........这里部分代码省略.........
示例7: implode
$title .= " -{$user_login}-";
if ($categories) {
$cats = implode(',', $categories);
$from_where .= " AND link_category in ({$cats}) ";
}
}
$order_by = " ORDER BY {$order_field} DESC ";
$last_modified = $db->get_var("SELECT UNIX_TIMESTAMP({$order_field}) {$from_where} {$order_by} LIMIT 1");
if ($if_modified > 0) {
$from_where .= " AND {$order_field} > FROM_UNIXTIME({$if_modified})";
}
$sql = "SELECT link_id {$from_where} {$order_by} LIMIT {$rows}";
}
do_header($title);
// Don't allow banned IPs o proxies
if (!check_ban($globals['user_ip'], 'ip', true) && !check_ban_proxy()) {
$links = $db->get_col($sql);
} else {
$links = false;
}
if ($links) {
foreach ($links as $link_id) {
$link = Link::from_db($link_id);
if (!$link) {
continue;
}
$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));
$permalink = $link->get_short_permalink();
/*
if (isset($_REQUEST['local']) || $globals['bot']) {
示例8: save_from_post
static function save_from_post($link, $redirect = true)
{
global $db, $current_user, $globals;
require_once mnminclude . 'ban.php';
if (check_ban_proxy()) {
return _('dirección IP no permitida');
}
// Check if is a POST of a comment
if (!($link->votes > 0 && $link->date > $globals['now'] - $globals['time_enabled_comments'] * 1.01 && $link->comments < $globals['max_comments'] && intval($_POST['link_id']) == $link->id && $current_user->authenticated && intval($_POST['user_id']) == $current_user->user_id && intval($_POST['randkey']) > 0)) {
return _('comentario o usuario incorrecto');
}
if ($current_user->user_karma < $globals['min_karma_for_comments'] && $current_user->user_id != $link->author) {
return _('karma demasiado bajo');
}
$comment = new Comment();
$comment->link = $link->id;
$comment->ip = $globals['user_ip'];
$comment->randkey = intval($_POST['randkey']);
$comment->author = intval($_POST['user_id']);
$comment->karma = round($current_user->user_karma);
$comment->content = clean_text_with_tags($_POST['comment_content'], 0, false, 10000);
// Check if is an admin comment
if ($current_user->user_level == 'god' && $_POST['type'] == 'admin') {
$comment->type = 'admin';
}
// Don't allow to comment with a clone
$hours = intval($globals['user_comments_clon_interval']);
if ($hours > 0) {
$clones = $current_user->get_clones($hours + 1);
if ($clones) {
$l = implode(',', $clones);
$c = (int) $db->get_var("select count(*) from comments where comment_date > date_sub(now(), interval {$hours} hour) and comment_user_id in ({$l})");
if ($c > 0) {
syslog(LOG_NOTICE, "Meneame, clon comment ({$current_user->user_login}, {$comment->ip}) in {$link->uri}");
return _('ya hizo un comentario con usuarios clones');
}
}
}
// Basic check to avoid abuses from same IP
if (!$current_user->admin && $current_user->user_karma < 6.2) {
// Don't check in case of admin comments or higher karma
// Avoid astroturfing from the same link's author
if ($link->status != 'published' && $link->ip == $globals['user_ip'] && $link->author != $comment->author) {
UserAuth::insert_clon($comment->author, $link->author, $link->ip);
syslog(LOG_NOTICE, "Meneame, comment-link astroturfing ({$current_user->user_login}, {$link->ip}): " . $link->get_permalink());
return _('no se puede comentar desde la misma IP del autor del envío');
}
// Avoid floods with clones from the same IP
if (intval($db->get_var("select count(*) from comments where comment_link_id = {$link->id} and comment_ip='{$comment->ip}' and comment_user_id != {$comment->author}")) > 1) {
syslog(LOG_NOTICE, "Meneame, comment astroturfing ({$current_user->user_login}, {$comment->ip})");
return _('demasiados comentarios desde la misma IP con usuarios diferentes');
}
}
if (mb_strlen($comment->content) < 5 || !preg_match('/[a-zA-Z:-]/', $_POST['comment_content'])) {
// Check there are at least a valid char
return _('texto muy breve o caracteres no válidos');
}
if (!$current_user->admin) {
$comment->get_links();
if ($comment->banned && $current_user->Date() > $globals['now'] - 86400) {
syslog(LOG_NOTICE, "Meneame: comment not inserted, banned link ({$current_user->user_login})");
return _('comentario no insertado, enlace a sitio deshabilitado (y usuario reciente)');
}
// Lower karma to comments' spammers
$comment_count = (int) $db->get_var("select count(*) from comments where comment_user_id = {$current_user->user_id} and comment_date > date_sub(now(), interval 3 minute)");
// Check the text is not the same
$same_count = $comment->same_text_count();
$same_links_count = $comment->same_links_count();
if ($comment->banned) {
$same_links_count *= 2;
}
$same_count += $same_links_count;
} else {
$comment_count = $same_count = 0;
}
$comment_limit = round(min($current_user->user_karma / 6, 2) * 2.5);
$karma_penalty = 0;
if ($comment_count > $comment_limit || $same_count > 2) {
if ($comment_count > $comment_limit) {
$karma_penalty += ($comment_count - 3) * 0.1;
}
if ($same_count > 1) {
$karma_penalty += $same_count * 0.25;
}
}
// Check image limits
if (!empty($_FILES['image']['tmp_name'])) {
$limit_exceded = Upload::current_user_limit_exceded($_FILES['image']['size']);
if ($limit_exceded) {
return $limit_exceded;
}
}
$db->transaction();
// Check the comment wasn't already stored
$r = intval($db->get_var("select count(*) from comments where comment_link_id = {$comment->link} and comment_user_id = {$comment->author} and comment_randkey = {$comment->randkey} FOR UPDATE"));
$already_stored = intval($r);
if ($already_stored) {
$db->rollback();
return _('comentario duplicado');
}
//.........这里部分代码省略.........
示例9: check_user_fields
function check_user_fields() {
global $globals, $db;
$error = false;
if(check_ban_proxy()) {
register_error(_("IP no permitida"));
$error=true;
}
if(!isset($_POST["username"]) || strlen($_POST["username"]) < 3) {
register_error(_("nombre de usuario erróneo, debe ser de 3 o más caracteres alfanuméricos"));
$error=true;
}
if(!check_username($_POST["username"])) {
register_error(_("nombre de usuario erróneo, caracteres no admitidos o no comienzan con una letra"));
$error=true;
}
if(user_exists(trim($_POST["username"])) ) {
register_error(_("el usuario ya existe"));
$error=true;
}
if(!check_email(trim($_POST["email"]))) {
register_error(_("el correo electrónico no es correcto"));
$error=true;
}
if(email_exists(trim($_POST["email"])) ) {
register_error(_("dirección de correo duplicada, o fue usada recientemente"));
$error=true;
}
if(preg_match('/[ \']/', $_POST["password"]) || preg_match('/[ \']/', $_POST["password2"]) ) {
register_error(_("caracteres inválidos en la clave"));
$error=true;
}
if(! check_password($_POST["password"])) {
register_error(_("clave demasiado corta, debe ser de 6 o más caracteres e incluir mayúsculas, minúsculas y números"));
$error=true;
}
if($_POST["password"] !== $_POST["password2"] ) {
register_error(_("las claves no coinciden"));
$error=true;
}
$hasStandard = false;
foreach ($globals['standards'] as &$val) {
if ($val['id'] == $_POST['standard']) {
$hasStandard = true;
}
}
if (!$hasStandard) {
print_r($_POST);
register_error("A norma enviada non coincide");
$error=true;
}
// Check registers from the same IP network
$user_ip = $globals['form_user_ip'];
$ip_classes = explode(".", $user_ip);
// From the same IP
$registered = (int) $db->get_var("select count(*) from logs where log_date > date_sub(now(), interval 24 hour) and log_type in ('user_new', 'user_delete') and log_ip = '$user_ip'");
if($registered > 0) {
syslog(LOG_NOTICE, "Meneame, register not accepted by IP address ($_POST[username]) $user_ip");
register_error(_("para registrar otro usuario desde la misma dirección debes esperar 24 horas"));
$error=true;
}
if ($error) return false;
// Check class
// nnn.nnn.nnn
$ip_class = $ip_classes[0] . '.' . $ip_classes[1] . '.' . $ip_classes[2] . '.%';
$registered = (int) $db->get_var("select count(*) from logs where log_date > date_sub(now(), interval 6 hour) and log_type in ('user_new', 'user_delete') and log_ip like '$ip_class'");
if($registered > 0) {
syslog(LOG_NOTICE, "Meneame, register not accepted by IP class ($_POST[username]) $ip_class");
register_error(_("para registrar otro usuario desde la misma red debes esperar 6 horas"). " ($ip_class)");
$error=true;
}
if ($error) return false;
// Check class
// nnn.nnn
$ip_class = $ip_classes[0] . '.' . $ip_classes[1] . '.%';
$registered = (int) $db->get_var("select count(*) from logs where log_date > date_sub(now(), interval 1 hour) and log_type in ('user_new', 'user_delete') and log_ip like '$ip_class'");
if($registered > 2) {
syslog(LOG_NOTICE, "Meneame, register not accepted by IP class ($_POST[username]) $ip_class");
register_error(_("para registrar otro usuario desde la misma red debes esperar unos minutos") . " ($ip_class)");
$error=true;
}
if ($error) return false;
return true;
}
示例10: do_submit1
function do_submit1()
{
global $db, $dblang, $current_user, $globals, $errors;
$url = clean_input_url(urldecode($_POST['url']));
$url = preg_replace('/#[^\\/]*$/', '', $url);
// Remove the "#", people just abuse
$url = preg_replace('/^http:\\/\\/http:\\/\\//', 'http://', $url);
// Some users forget to delete the foo http://
if (!preg_match('/^\\w{3,6}:\\/\\//', $url)) {
// http:// forgotten, add it
$url = 'http://' . $url;
}
$new_user = false;
if (!check_link_key()) {
add_submit_error(_('clave incorrecta'));
return false;
}
if ($globals['min_karma_for_links'] > 0 && $current_user->user_karma < $globals['min_karma_for_links']) {
add_submit_error(_('no tienes el mínimo de karma para enviar una nueva historia'));
return false;
}
// Don't allow to send a link by a clone
$hours = intval($globals['user_links_clon_interval']);
$clones = $current_user->get_clones($hours + 1);
if ($hours > 0 && $clones) {
$l = implode(',', $clones);
$c = (int) $db->get_var("select count(*) from links where link_status!='published' and link_date > date_sub(now(), interval {$hours} hour) and link_author in ({$l})");
if ($c > 0) {
add_submit_error(_('ya se envió con otro usuario «clon» en las últimas horas') . ", " . _('disculpa las molestias'));
syslog(LOG_NOTICE, "Meneame, clon submit ({$current_user->user_login}): " . $_REQUEST['url']);
return false;
}
}
// Check the number of links sent by a user
$queued_24_hours = (int) $db->get_var("select count(*) from links where link_status!='published' and link_date > date_sub(now(), interval 24 hour) and link_author={$current_user->user_id}");
if ($globals['limit_user_24_hours'] && $queued_24_hours > $globals['limit_user_24_hours']) {
add_submit_error(_('debes esperar, tienes demasiados envíos en cola de las últimas 24 horas') . " ({$queued_24_hours}), " . _('disculpa las molestias'));
syslog(LOG_NOTICE, "Meneame, too many queued in 24 hours ({$current_user->user_login}): " . $_REQUEST['url']);
return false;
}
// check the URL is OK and that it resolves
$url_components = @parse_url($url);
if (!$url_components || !$url_components['host'] || gethostbyname($url_components['host']) == $url_components['host']) {
add_submit_error(_('URL o nombre de servidor erróneo'), _('el nombre del servidor es incorrecto o éste tiene problemas para resolver el nombre'));
syslog(LOG_NOTICE, "Meneame, hostname error ({$current_user->user_login}): {$url}");
return false;
}
$enqueued_last_minutes = (int) $db->get_var("select count(*) from links where link_status='queued' and link_date > date_sub(now(), interval 3 minute)");
if ($current_user->user_karma > $globals['limit_3_minutes_karma']) {
$enqueued_limit = $globals['limit_3_minutes'] * 1.5;
} else {
$enqueued_limit = $globals['limit_3_minutes'];
}
if ($enqueued_last_minutes > $enqueued_limit) {
//echo '<p class="error"><strong>'._('exceso de envíos').':</strong></p>';
//echo '<p>'._('se han enviado demasiadas historias en los últimos 3 minutos'). " ($enqueued_last_minutes > $enqueued_limit), "._('disculpa las molestias'). ' </p>';
//echo '</div>'. "\n";
add_submit_error(_('exceso de envíos'), _('se han enviado demasiadas historias en los últimos 3 minutos') . " ({$enqueued_last_minutes} > {$enqueued_limit}), " . _('disculpa las molestias'));
syslog(LOG_NOTICE, "Meneame, too many queued ({$current_user->user_login}): " . $_REQUEST['url']);
return false;
}
// Check the user does not have too many drafts
$minutes = intval($globals['draft_time'] / 60) + 10;
$drafts = (int) $db->get_var("select count(*) from links where link_author={$current_user->user_id} and link_date > date_sub(now(), interval {$minutes} minute) and link_status='discard' and link_votes = 0");
if ($drafts > $globals['draft_limit']) {
add_submit_error(_('demasiados borradores'), _('has hecho demasiados intentos, debes esperar o continuar con ellos desde la') . ' <a href="shakeit.php?meta=_discarded">' . _('cola de descartadas') . '</a></p>');
syslog(LOG_NOTICE, "Meneame, too many drafts ({$current_user->user_login}): " . $_REQUEST['url']);
return false;
}
// Delete dangling drafts
if ($drafts > 0) {
$db->query("delete from links where link_author={$current_user->user_id} and link_date > date_sub(now(), interval 30 minute) and link_date < date_sub(now(), interval 10 minute) and link_status='discard' and link_votes = 0");
}
// Check for banned IPs
if (($ban = check_ban($globals['user_ip'], 'ip', true)) || ($ban = check_ban_proxy())) {
if ($ban['expire'] > 0) {
$expires = _('caduca') . ': ' . get_date_time($ban['expire']);
} else {
$expires = '';
}
add_submit_error(_('dirección IP no permitida para enviar'), $expires);
syslog(LOG_NOTICE, "Meneame, banned IP " . $globals['user_ip'] . " ({$current_user->user_login}): {$url}");
return false;
}
// Number of links sent by the user
$total_sents = (int) $db->get_var("select count(*) from links where link_author={$current_user->user_id}") - $drafts;
if ($total_sents > 0) {
$sents = (int) $db->get_var("select count(*) from links where link_author={$current_user->user_id} and link_date > date_sub(now(), interval 60 day)") - $drafts;
} else {
$new_user = true;
$sents = 0;
}
$register_date = $current_user->Date();
if ($globals['now'] - $register_date < $globals['new_user_time']) {
$new_user = true;
}
// check that a new user also votes, not only sends links
// it requires $globals['min_user_votes'] votes
if ($new_user && $globals['min_user_votes'] > 0 && $current_user->user_karma < $globals['new_user_karma']) {
$user_votes_total = (int) $db->get_var("select count(*) from votes where vote_type='links' and vote_user_id={$current_user->user_id}");
//.........这里部分代码省略.........
示例11: do_submit1
function do_submit1()
{
global $db, $dblang, $current_user, $globals;
$url = clean_input_url($_POST['url']);
$url = preg_replace('/^http:\\/\\/http:\\/\\//', 'http://', $url);
// Some users forget to delete the foo http://
$url = preg_replace('/#.*$/', '', $url);
// Remove the "#", people just abuse
do_banner_top();
echo '<div id="container-wide">' . "\n";
echo '<div id="genericform-contents">' . "\n";
$new_user = false;
if (!check_link_key()) {
echo '<p class="error"><strong>' . _('clave incorrecta') . '</strong></p> ';
echo '</div>' . "\n";
return;
}
if ($globals['min_karma_for_links'] > 0 && $current_user->user_karma < $globals['min_karma_for_links']) {
echo '<p class="error"><strong>' . _('no tienes el mínimo de karma para enviar una nueva historia') . '</strong></p> ';
echo '</div>' . "\n";
return;
}
$enqueued_last_minutes = (int) $db->get_var("select count(*) from links where link_status='queued' and link_date > date_sub(now(), interval 3 minute)");
if ($current_user->user_karma > 10) {
$enqueued_limit = $globals['limit_3_minutes'] * 1.5;
} else {
$enqueued_limit = $globals['limit_3_minutes'];
}
if ($enqueued_last_minutes > $enqueued_limit) {
echo '<p class="error"><strong>' . _('Exceso de envíos') . ':</strong></p>';
echo '<p>' . _('Se han enviado demasiadas noticias en los últimos 3 minutos') . " ({$enqueued_last_minutes} > {$enqueued_limit}), " . _('disculpa las molestias') . ' </p>';
syslog(LOG_NOTICE, "Meneame, too many queued ({$current_user->user_login}): {$_POST['url']}");
echo '</div>' . "\n";
return;
}
// Check the user does not have too many drafts
$drafts = (int) $db->get_var("select count(*) from links where link_author={$current_user->user_id} and link_date > date_sub(now(), interval 30 minute) and link_status='discard' and link_votes = 0");
if ($drafts > 3) {
echo '<p class="error"><strong>' . _('Demasiados borradores') . ':</strong></p>';
echo '<p>' . _('Has hecho demasiados intentos, debes esperar o continuar con ellos desde la') . ' <a href="shakeit.php?meta=_discarded">' . _('cola de descartadas') . '</a></p>';
syslog(LOG_NOTICE, "Meneame, too many drafts ({$current_user->user_login}): {$_POST['url']}");
echo '</div>' . "\n";
return;
}
// Delete dangling drafts
if ($drafts > 0) {
$db->query("delete from links where link_author={$current_user->user_id} and link_date > date_sub(now(), interval 30 minute) and link_date < date_sub(now(), interval 10 minute) and link_status='discard' and link_votes = 0");
}
// Check for banned IPs
if (check_ban($globals['user_ip'], 'ip', true) || check_ban_proxy()) {
echo '<p class="error"><strong>' . _('Dirección IP no permitida para enviar') . ':</strong> ' . $globals['user_ip'] . ' (' . $globals['ban_message'] . ')</p>';
syslog(LOG_NOTICE, "Meneame, banned IP {$globals['user_ip']} ({$current_user->user_login}): {$url}");
print_empty_submit_form();
echo '</div>' . "\n";
return;
}
// Number of links sent by the user
$total_sents = (int) $db->get_var("select count(*) from links where link_author={$current_user->user_id}") - $drafts;
if ($total_sents > 0) {
$sents = (int) $db->get_var("select count(*) from links where link_author={$current_user->user_id} and link_date > date_sub(now(), interval 60 day)") - $drafts;
} else {
$new_user = true;
$sents = 0;
}
$register_date = $current_user->Date();
if ($globals['now'] - $register_date < 86400 * 3) {
$new_user = true;
}
// check that a new user also votes, not only sends links
// it requires $globals['min_user_votes'] votes
if ($new_user && $globals['min_user_votes'] > 0 && $current_user->user_karma < 6.1) {
$user_votes_total = (int) $db->get_var("select count(*) from votes where vote_type='links' and vote_user_id={$current_user->user_id}");
$user_votes = (int) $db->get_var("select count(*) from votes where vote_type='links' and vote_date > date_sub(now(), interval 72 hour) 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 > date_sub(now(), interval 24 hour) and link_status != 'discard'");
$total_links = (int) $db->get_var("select count(*) from links where link_date > date_sub(now(), interval 24 hour) and link_status = 'queued'");
echo "<!-- {$user_votes_total}, {$user_links}, {$total_links} -->\n";
if ($sents == 0) {
// If is a new user, requires more votes, to avoid spam
$min_votes = $globals['min_user_votes'];
} else {
$min_votes = min(4, intval($total_links / 20)) * $user_links;
}
if ($current_user->user_level != 'god' && $current_user->user_level != 'admin' && $user_votes < $min_votes) {
$needed = $min_votes - $user_votes;
echo '<p class="error">';
if ($new_user) {
echo '<strong>' . _('¿es la primera vez que envías una noticia?') . '</strong></p> ';
echo '<p class="error-text">' . _('necesitas como mínimo') . " <strong>{$needed} " . _('votos') . '</strong><br/>';
} else {
echo '<strong>' . _('no tienes el mínimo de votos necesarios para enviar una nueva historia') . '</strong></p> ';
echo '<p class="error-text">' . _('necesitas votar como mínimo a') . " <strong>{$needed} " . _('noticias') . '</strong><br/>';
}
echo '<strong>' . _('no votes de forma apresurada, penaliza el karma') . '</strong><br/>';
echo '<a href="' . $globals['base_url'] . 'shakeit.php" target="_blank">' . _('haz clic aquí para ir a votar') . '</a></p>';
echo '<br style="clear: both;" />' . "\n";
echo '</div>' . "\n";
return;
}
}
// avoid spams, an extra security check
//.........这里部分代码省略.........
示例12: check_user_fields
function check_user_fields()
{
global $globals, $db;
$error = false;
if (check_ban_proxy()) {
register_error(_("IP no permitida"));
$error = true;
}
if (!isset($_POST["username"]) || strlen($_POST["username"]) < 3) {
register_error(_("Nombre de usuario erróneo, debe ser de 3 o más caracteres alfanuméricos"));
$error = true;
}
if (!check_username($_POST["username"])) {
register_error(_("Nombre de usuario erróneo, caracteres no admitidos o no comienzan con una letra"));
$error = true;
}
if (user_exists(trim($_POST["username"]))) {
register_error(_("El usuario ya existe"));
$error = true;
}
if (!check_email(trim($_POST["email"]))) {
register_error(_("El correo electrónico no es correcto"));
$error = true;
}
if (email_exists(trim($_POST["email"]))) {
register_error(_("Ya existe otro usuario con esa dirección de correo"));
$error = true;
}
if (preg_match('/[ \']/', $_POST["password"]) || preg_match('/[ \']/', $_POST["password2"])) {
register_error(_("Caracteres inválidos en la clave"));
$error = true;
}
if (strlen($_POST["password"]) < 5) {
register_error(_("Clave demasiado corta, debe ser de 5 o más caracteres"));
$error = true;
}
if ($_POST["password"] !== $_POST["password2"]) {
register_error(_("Las claves no coinciden"));
$error = true;
}
// Check registers from the same IP network
$user_ip = $globals['user_ip'];
$ip_classes = explode(".", $user_ip);
// From the same IP
$registered = (int) $db->get_var("select count(*) from logs where log_date > date_sub(now(), interval 24 hour) and log_type in ('user_new', 'user_delete') and log_ip = '{$user_ip}'");
if ($registered > 0) {
syslog(LOG_NOTICE, "Meneame, register not accepted by IP address ({$_POST['username']}) {$user_ip}");
register_error(_("Para registrar otro usuario desde la misma dirección debes esperar 24 horas."));
$error = true;
}
if ($error) {
return false;
}
// Check class
// nnn.nnn.nnn
$ip_class = $ip_classes[0] . '.' . $ip_classes[1] . '.' . $ip_classes[2] . '.%';
$registered = (int) $db->get_var("select count(*) from logs where log_date > date_sub(now(), interval 6 hour) and log_type in ('user_new', 'user_delete') and log_ip like '{$ip_class}'");
if ($registered > 0) {
syslog(LOG_NOTICE, "Meneame, register not accepted by IP class ({$_POST['username']}) {$ip_class}");
register_error(_("Para registrar otro usuario desde la misma red debes esperar 6 horas.") . " ({$ip_class})");
$error = true;
}
if ($error) {
return false;
}
// Check class
// nnn.nnn
$ip_class = $ip_classes[0] . '.' . $ip_classes[1] . '.%';
$registered = (int) $db->get_var("select count(*) from logs where log_date > date_sub(now(), interval 1 hour) and log_type in ('user_new', 'user_delete') and log_ip like '{$ip_class}'");
if ($registered > 2) {
syslog(LOG_NOTICE, "Meneame, register not accepted by IP class ({$_POST['username']}) {$ip_class}");
register_error(_("Para registrar otro usuario desde la misma red debes esperar unos minutos.") . " ({$ip_class})");
$error = true;
}
if ($error) {
return false;
}
return true;
}