Skip to content

Commit

Permalink
Changes for testing and getting test data in meneame.jordisan.net
Browse files Browse the repository at this point in the history
  • Loading branch information
jordisan committed Jan 24, 2016
1 parent 428ea11 commit 7a432cc
Show file tree
Hide file tree
Showing 9 changed files with 70 additions and 47 deletions.
36 changes: 18 additions & 18 deletions www/config.php
Expand Up @@ -44,7 +44,7 @@
// Specify the name of the ssl server, ensure you have also setup "cookies_domain
$globals['ssl_server'] = False;

$globals['site_name'] = 'Menéame';
$globals['site_name'] = 'Pruébame';
$globals['site_shortname'] = 'mnm'; //Used to differentiate in keys

// If you user version, be careful to rewrite the directory for img, css and js
Expand Down Expand Up @@ -80,7 +80,7 @@
$globals['db_use_transactions'] = true; // Disable it if you use MyISAM and have high loads

// Administrator email
//$globals['adm_email'] = 'admin@administrador'
$globals['adm_email'] = 'ramsys+meneame@gmail.com';

//Specify the static web server, wiith port included, use same document root as the main server (i.e. base_url is used
// Don't forget to add a redirect to ooops.php in case of 404 error, for example in NGINX:
Expand Down Expand Up @@ -113,17 +113,17 @@
$globals['karma_user_affinity'] = false;
// Coefficient for links karma calculation
$globals['min_decay'] = 0.25;
$globals['karma_start_decay'] = 12; // In hours, when a link start to decrease its karma
$globals['karma_decay'] = 54; // In hours, when it reach its minimum
$globals['karma_start_decay'] = 48; // In hours, when a link start to decrease its karma
$globals['karma_decay'] = 108; // In hours, when it reach its minimum
//$globals['news_meta'] = 102; // The code of the "last news" meta category, other has a longer no decreasing period
// Similar values for "news_meta", used if the previous is defined
$globals['karma_news_start_decay'] = 7;
$globals['karma_news_decay'] = 42;
$globals['karma_news_start_decay'] = 8;
$globals['karma_news_decay'] = 84;
$globals['karma_clicks_bonus'] = 0.05; // Bonus to give due to clicks, it reaches this value when clicks/votes = 10;


// Memcache, set hostname if enabled
//$globals['memcache_host'] = 'localhost';
$globals['memcache_host'] = 'localhost';
$globals['memcache_port'] = 11211; // optional


Expand All @@ -142,8 +142,8 @@

// Min karma to highlights comments
// The negative is used to hide comments
$globals['comment_highlight_karma'] = 100;
$globals['comment_hidden_karma'] = -100;
$globals['comment_highlight_karma'] = 50;
$globals['comment_hidden_karma'] = -50;


// Upload images and files
Expand All @@ -169,12 +169,12 @@
$globals['limit_user_24_hours'] = 12;
$globals['limit_same_site_24_hours'] = 4;

$globals['karma_propaganda'] = 12; // min user karma to avoid extra spam/propaganda checks in the submits
$globals['karma_propaganda'] = 6; // min user karma to avoid extra spam/propaganda checks in the submits


$globals['karma_base']=6;
$globals['karma_base']=8;
$globals['karma_base_max']=9; // If not penalised, older users can get up to this value as base for the calculus
$globals['min_karma']=1; //min user karma
$globals['min_karma']=4; //min user karma
$globals['max_karma']=20; //max user karma
$globals['special_karma_gain']=17; //karma to gain 'special' status (max * 0.85)
$globals['special_karma_loss']=12; //karma to loss 'special' status (max * 0.6)
Expand Down Expand Up @@ -233,9 +233,9 @@



$globals['new_user_links_limit'] = 1; //links allowed to submit in interval for new users
$globals['new_user_links_limit'] = 5; //links allowed to submit in interval for new users
$globals['new_user_links_interval'] = 3600;
$globals['user_links_limit'] = 5;
$globals['user_links_limit'] = 10;
$globals['user_links_interval'] = 7200;
$globals['user_links_clon_interval'] = 12; // hours forbidden to send with a clone, 0 to allow it

Expand All @@ -245,7 +245,7 @@
//sneakme
$globals['posts_len'] = 500;
$globals['posts_period'] = 60;
$globals['posts_edit_time'] = 3600;
$globals['posts_edit_time'] = 7200;
$globals['posts_edit_time_admin'] = 864000;
$globals['post_highlight_karma'] = 100;
$globals['post_hide_karma'] = -50;
Expand Down Expand Up @@ -295,8 +295,8 @@
// Recaptcha settings
$globals['captcha_first_login'] = false;
// Put your keys en to enable recaptcha
//$globals['recaptcha_public_key'] = '';
//$globals['recaptcha_private_key'] = '';
$globals['recaptcha_public_key'] = '6LfrSxQTAAAAAGrj5IGOKrTlfFpzkNxzp3c4mY8W';
$globals['recaptcha_private_key'] = '6LfrSxQTAAAAANJJM1WBC7HDit1NpPFhBHgfSZEa';

// Twitter settings, with oauth
// Ensure you have pecl/oauth installed
Expand Down Expand Up @@ -347,7 +347,7 @@
//$globals['Amazon_secret_key'] = '';
//$globals['Amazon_S3_media_bucket'] = '';
//$globals['Amazon_S3_media_url'] = '';
$globals['Amazon_S3_local_cache'] = true;
$globals['Amazon_S3_local_cache'] = false;
$globals['Amazon_S3_upload'] = true;
$globals['Amazon_S3_delete_allowed'] = false;

Expand Down
13 changes: 8 additions & 5 deletions www/css/mnm.css
Expand Up @@ -15,7 +15,7 @@ font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-size: small;
background-image: url('{{ globals.base_static }}img/common/bkg-01.png');
color: #000;
background-color: #fff;
background-color: #FFFFFF;
margin:0px;
padding:0px;
}
Expand Down Expand Up @@ -141,7 +141,7 @@ top: 0px;
left: 0px;
width: 100%;
height:30px;
background-color:#3c3c3c;
background-color:#919203;
overflow:hidden;
white-space:nowrap;
z-index: 900;
Expand Down Expand Up @@ -1004,9 +1004,9 @@ box-shadow: 0 0 3px rgba(0,0,0,0.4);

.avatar, .news-submitted img {
border: 1px solid #ccc;
-moz-border-radius: 50%;
-webkit-border-radius: 50%;
border-radius: 50%;
-moz-border-radius: 10%;
-webkit-border-radius: 10%;
border-radius: 10%;
}

.avatar.big {
Expand Down Expand Up @@ -2408,6 +2408,8 @@ width:35px;
padding-top: 5px;
text-align:center;
vertical-align: middle;
background: #666 url('/v_40/img/menemojis/36/foreveralone.png') no-repeat;
background-size: cover;
}

#header-top #notifier:hover{
Expand All @@ -2418,6 +2420,7 @@ color: #f00;
#header-top #notifier.nonzero {
background:#f00;
color:#fff;
background-image:none;
}


Expand Down
Binary file modified www/img/common/bkg-01.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified www/img/mnm/h9_eli.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions www/js/sneak.js.php
Expand Up @@ -57,13 +57,13 @@

function start_sneak() {
$.ajaxSetup({
timeout: 20000,
timeout: 30000,
async: true,
cache: false,
error: function (req, error) {
$('#ping').html(error+'... retrying');
xmlhttp = undefined;
data_timer = setTimeout(get_data, 3000);
data_timer = setTimeout(get_data, 5000);
}
});

Expand Down
15 changes: 7 additions & 8 deletions www/libs/html1.php
Expand Up @@ -435,7 +435,7 @@ function do_vertical_tags($what=false) {
$max = 3;

$res = $db->get_col("select link_tags $from_where");
if ($res && count($res) > 5) {
if ($res && count($res) > 1) {
$url = $globals['base_url'].'cloud';
$title = _('etiquetas');
$content = '';
Expand All @@ -455,7 +455,6 @@ function do_vertical_tags($what=false) {
arsort($words);
$words = array_slice($words, 0, 20);
ksort($words);

foreach ($words as $word => $count) {
$size = round($min_pts + ($count-1)*$coef, 1);
$op = round(0.4 + 0.6*$count/$max, 2);
Expand Down Expand Up @@ -515,7 +514,7 @@ function do_most_clicked_sites() {
// The order is not exactly the votes counts
// but a time-decreasing function applied to the number of votes
$res = $db->get_results("select sum(counter) as total_count, sum(counter*(1-(unix_timestamp(now())-unix_timestamp(link_date))*0.5/172800)) as value, blog_url from links, link_clicks, blogs, sub_statuses where sub_statuses.id = ".SitesMgr::my_id()." AND link_id = link AND date > '$min_date' and status='published' and link_blog = blog_id AND link_clicks.id = link group by link_blog order by value desc limit 10");
if ($res && count($res) > 4) {
if ($res && count($res) > 1) {
$output = Haanga::Load("best_sites_posts.html", compact('res', 'title'), TRUE);
echo $output;
}
Expand All @@ -540,7 +539,7 @@ function do_best_comments() {
// The order is not exactly the comment_karma
// but a time-decreasing function applied to the number of votes
$res = $db->get_results("select comment_id, comment_order, user_id, user_login, user_avatar, link_id, link_uri, link_title, link_comments, comment_karma*(1-($now-unix_timestamp(comment_date))*0.7/43000) as value, link_negatives/link_votes as rel from comments, links, users, sub_statuses where id = ".SitesMgr::my_id()." AND status in ('published', 'queued') AND link_id = link AND date > '$link_min_date' and comment_date > '$min_date' and LENGTH(comment_content) > 32 and link_negatives/link_votes < 0.5 and comment_karma > 50 and comment_link_id = link and comment_user_id = user_id and user_level != 'disabled' order by value desc limit 10");
if ($res && count($res) > 4) {
if ($res && count($res) > 1) {
$objects = array();
$title = _('mejores comentarios');
$url = $globals['base_url'].'top_comments';
Expand Down Expand Up @@ -663,7 +662,7 @@ function do_best_stories() {
// The order is not exactly the votes
// but a time-decreasing function applied to the number of votes
$res = $db->get_results("select link_id, (link_votes-link_negatives*2)*(1-(unix_timestamp(now())-unix_timestamp(link_date))*0.8/129600) as value from links, sub_statuses where id = ".SitesMgr::my_id()." AND link_id = link AND status='published' and date > '$min_date' order by value desc limit 5");
if ($res && count($res) > 4 ) {
if ($res && count($res) > 3 ) {
$links = array();
$url = $globals['base_url'].'popular';
$link = new Link();
Expand Down Expand Up @@ -707,7 +706,7 @@ function do_best_queued() {
// The order is not exactly the votes
// but a time-decreasing function applied to the number of votes
$res = $db->get_results("select link_id from links, sub_statuses where id = ".SitesMgr::my_id()." AND status='queued' and link_id = link AND link_karma > $min_karma AND date > '$min_date' order by link_karma desc limit 20");
if ($res && count($res) > 5) {
if ($res && count($res) > 2) {
$url = $globals['base_url'].'queue?meta=_popular';
$links = array();
$link = new Link();
Expand Down Expand Up @@ -750,7 +749,7 @@ function do_most_clicked_stories() {
// The order is not exactly the votes
// but a time-decreasing function applied to the number of votes
$res = $db->get_results("select link_id, counter*(1-(unix_timestamp(now())-unix_timestamp(link_date))*0.5/172800) as value from links, link_clicks, sub_statuses where sub_statuses.id = ".SitesMgr::my_id()." AND link_id = link AND status='published' and date > '$min_date' and link_clicks.id = link order by value desc limit 5");
if ($res && count($res) > 4) {
if ($res && count($res) > 1) {
$links = array();
$url = $globals['base_url'].'top_visited';
$link = new Link();
Expand Down Expand Up @@ -787,7 +786,7 @@ function do_best_posts() {

$min_date = date("Y-m-d H:i:00", $globals['now'] - 86400); // about 24 hours
$res = $db->get_results("select post_id from posts, users where post_date > '$min_date' and post_user_id = user_id and post_karma > 0 order by post_karma desc limit 10");
if ($res && count($res) > 4) {
if ($res && count($res) > 1) {
$objects = array();
$title = _('mejores notas');
$url = post_get_base_url('_best');
Expand Down
15 changes: 10 additions & 5 deletions www/libs/link.php
Expand Up @@ -169,25 +169,31 @@ static function visited($id) {
function add_click($no_go=false) {
global $globals, $db;

if (! $globals['bot']
if ( true
&& ! $globals['bot']
&& ! Link::visited($this->id)
&& $globals['click_counter']
&& ($no_go || (isset($_COOKIE['k']) && check_security_key($_COOKIE['k'])))
&& $this->ip != $globals['user_ip']) {
&& $this->ip != $globals['user_ip']
) {
// Delay storing
self::$clicked = $this->id;
// delayed storing doesn't seem to work fine with php-fpm
self::store_clicks();
}
}

static function store_clicks() {
global $globals, $db;

// syslog(LOG_INFO, "store_clicks: ".self::$clicked);

if (!self::$clicked) return false;
$id = self::$clicked;
self::$clicked = 0;

if (! memcache_menabled()) {
$db->query("UPDATE link_clicks SET counter=counter+1 WHERE id = $id");
$db->query("INSERT INTO link_clicks (id, counter) VALUES ($id, 1) ON DUPLICATE KEY UPDATE counter=counter+1");
// $db->query("UPDATE link_clicks SET counter=counter+1 WHERE id = $id");
return true;
}

Expand Down Expand Up @@ -656,7 +662,6 @@ function read_basic($key='id') {

function read($key='id') {
global $db, $current_user;

SitesMgr::my_id(); // Force to read current sub_id
switch ($key) {
case 'id':
Expand Down
27 changes: 19 additions & 8 deletions www/register.php
Expand Up @@ -66,7 +66,7 @@ function do_register0() {
echo '&nbsp;<span id="usernamecheckitvalue"></span></p>' . "\n";

echo '<p><label for="email">email:</label><br />' . "\n";
echo '<span class="note">'._('es importante que sea correcta, recibirás un correo para validar la cuenta').'</span> <br />';
echo '<span class="note">'._('opcional, aunque recomendable').'</span> <br />';
echo '<input type="text" id="email" name="email" value="" onkeyup="enablebutton(this.form.checkbutton2, this.form.submit, this)" size="25" tabindex="2"/>' . "\n";
echo '<input type="button" class="button" id="checkbutton2" disabled="disabled" value="'._('verificar').'" onclick="checkfield(\'email\', this.form, this.form.email)"/>' . "\n";
echo '&nbsp;<span id="emailcheckitvalue"></span></p>' . "\n";
Expand Down Expand Up @@ -142,20 +142,29 @@ function do_register2() {
$dbemail=$db->escape($email); // sanity check
$user_ip = $globals['user_ip'];
if (!user_exists($username)) {
if ($db->query("INSERT INTO users (user_login, user_login_register, user_email, user_email_register, user_pass, user_date, user_ip) VALUES ('$dbusername', '$dbusername', '$dbemail', '$dbemail', '$password', now(), '$user_ip')")) {
if ($db->query("INSERT INTO users (user_login, user_login_register, user_email, user_email_register, user_pass, user_date, user_ip, user_validated_date) VALUES ('$dbusername', '$dbusername', '$dbemail', '$dbemail', '$password', now(), '$user_ip', now())")) {
echo '<fieldset>'."\n";
echo '<legend><span class="sign">'._("registro de usuario").'</span></legend>'."\n";
$user=new User();
$user->username=$username;
if(!$user->read()) {
register_error(_('error insertando usuario en la base de datos'));
} else {
require_once(mnminclude.'mail.php');
$sent = send_recover_mail($user);
if ($sent) {
// no enviamos verificacion email en pruebas
// require_once(mnminclude.'mail.php');
// $sent = send_recover_mail($user);
if (true) { // $sent) {
$globals['user_ip'] = $user_ip; //we force to insert de log with the same IP as the form
Log::insert('user_new', $user->id, $user->id);
syslog(LOG_INFO, "new user $user->id $user->username $email $user_ip");

// redirect to login URL
$now = time();
global $site_key;
$key = md5($user->id.$user->pass.$now.$site_key.get_server_name());
$url = 'http://'.get_server_name().$globals['base_url'].'profile?login='.$user->username.'&t='.$now.'&k='.$key;
print('<a href="'.$url.'">'.$url.'</a>');
print('<script type="text/javascript">window.location = "'.$url.'";</script>');
} else {
register_error(_("error enviando el correo electrónico, seguramente está bloqueado"));
}
Expand Down Expand Up @@ -189,10 +198,12 @@ function check_user_fields() {
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;
Expand All @@ -218,7 +229,7 @@ function check_user_fields() {

// 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) {
if($registered > 5) {
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;
Expand All @@ -229,7 +240,7 @@ function check_user_fields() {
// 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) {
if($registered > 5) {
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;
Expand All @@ -240,7 +251,7 @@ function check_user_fields() {
// 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) {
if($registered > 10) {
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;
Expand Down
7 changes: 6 additions & 1 deletion www/templates/header.html
Expand Up @@ -90,7 +90,6 @@

</head>
<body>

<div id="header-top">
<div id="nav-menu"></div>
<a href="{{ globals.base_url_general }}" title="{% trans _('portada') %} {{ globals.site_name }}" id="header-logo" class="logo-mnm">{% trans _('portada') %} {{ globals.site_name }}</a>
Expand Down Expand Up @@ -127,6 +126,12 @@
</span>
{% endif %} {# PARTIAL partial #}

<p style="background-color: yellow; padding: 10px 10px; text-align: center;">
<strong>en PRUEBAS: </strong> crea una cuenta
y &uacute;salo normalmente, <strong>sin incluir informaci&oacute;n personal</strong>.
<a href="https://www.meneame.net/notame/2316845" target="_blank">+ info</a>
</p>

<script type="text/javascript">
{% include 'js/basic.js' %}
</script>
Expand Down

0 comments on commit 7a432cc

Please sign in to comment.