Example #1
0
        case 'post':
            $url = $globals['scheme'] . '//' . get_server_name() . post_get_base_url($id);
            do_redirection($url);
            exit(0);
        case 'comment':
            $c = new Comment();
            $c->id = $id;
            $url = $globals['scheme'] . '//' . get_server_name() . $c->get_relative_individual_permalink();
            do_redirection($url);
            exit(0);
        default:
            $l = Link::from_db($id, null, false);
            if (!$l) {
                exit(0);
            }
            if (!$globals['mobile'] && !$globals['mobile_version'] && !empty($l->url) && $current_user->user_id > 0 && (empty($globals['https']) || preg_match('/^https:/', $l->url)) && User::get_pref($current_user->user_id, 'use_bar') && $db->get_var("select blog_type from blogs where blog_id = {$l->blog}") != 'noiframe') {
                $url = $globals['scheme'] . '//' . get_server_name() . $globals['base_url'] . 'b/' . $id;
                // we use always http to load no https pages
                do_redirection($url, 307);
            } else {
                if (empty($l->url)) {
                    $url = $l->get_permalink();
                } else {
                    $url = $l->url;
                }
                do_redirection($url);
            }
            $l->add_click();
            exit(0);
    }
} else {
Example #2
0
function notify_user($from, $to, $text)
{
    $sender = new User($from);
    $user = new User($to);
    if (!$user || !$sender) {
        return;
    }
    if (!check_email($user->email)) {
        return;
    }
    if (!User::get_pref($to, 'notify_priv')) {
        return;
    }
    $url = 'http://' . get_server_name() . post_get_base_url('_priv');
    $subject = "Notificación de mensaje privado de {$sender->username}";
    $message = "{$sender->username} " . _('escribió') . ":\n{$url}\n\n{$text}";
    require_once mnminclude . 'mail.php';
    send_mail($user->email, $subject, $message);
}
Example #3
0
function do_profile()
{
    global $user, $current_user, $login, $db, $globals;
    $options = array();
    $options[$user->username] = get_user_uri($user->username);
    //$options[_('categorías personalizadas')] = get_user_uri($user->username, 'categories');
    if ($current_user->user_id == $user->id || $current_user->user_level == 'god') {
        $options[_('modificar perfil') . ' →'] = $globals['base_url'] . 'profile?login='******'extra_js'][] = 'jquery.flot.min.js';
        $globals['extra_js'][] = 'jquery.flot.time.min.js';
    }
    $post = new Post();
    if (!$post->read_last($user->id)) {
        $post = NULL;
    }
    if (!empty($user->url)) {
        if ($user->karma < 10) {
            $nofollow = 'rel="nofollow"';
        } else {
            $nofollow = '';
        }
        if (!preg_match('/^http/', $user->url)) {
            $url = 'http://' . $user->url;
        } else {
            $url = $user->url;
        }
    }
    if ($current_user->user_id > 0 && $current_user->user_id != $user->id) {
        $friend_icon = User::friend_teaser($current_user->user_id, $user->id);
    }
    $selected = 0;
    $rss = 'rss?sent_by=' . $user->id;
    $rss_title = _('envíos en rss2');
    $geodiv = $current_user->user_id > 0 && $current_user->user_id != $user->id && $globals['latlng'] && ($my_latlng = geo_latlng('user', $current_user->user_id));
    $show_email = $current_user->user_id > 0 && !empty($user->public_info) && ($current_user->user_id == $user->id || $current_user->user_level == 'god');
    $clones_from = "and clon_date > date_sub(now(), interval 30 day)";
    if ($current_user->admin) {
        $nclones = $db->get_var("select count(distinct clon_to) from clones where clon_from = {$user->id} {$clones_from}");
    }
    $user->all_stats();
    if (!$user->bio) {
        $user->bio = '';
    }
    if ($user->total_links > 1) {
        $entropy = intval(($user->blogs() - 1) / ($user->total_links - 1) * 100);
    }
    if ($user->total_links > 0 && $user->published_links > 0) {
        $percent = intval($user->published_links / $user->total_links * 100);
    } else {
        $percent = 0;
    }
    if ($globals['do_geo'] && $current_user->user_id == $user->id) {
        ob_start();
        geo_coder_print_form('user', $current_user->user_id, $globals['latlng'], _('ubícate en el mapa (si te apetece)'), 'user');
        $geo_form = ob_get_clean();
    }
    $addresses = array();
    if ($current_user->user_id == $user->id || $current_user->user_level == 'god' && !$user->admin) {
        // gods and admins know each other for sure, keep privacy
        $dbaddresses = $db->get_results("select distinct(vote_ip_int) as ip from votes where vote_type in ('links', 'comments', 'posts') and vote_user_id = {$user->id} order by vote_date desc limit 30");
        // Try with comments
        if (!$dbaddresses) {
            $dbaddresses = $db->get_results("select distinct(comment_ip_int) as ip from comments where comment_user_id = {$user->id} and comment_date > date_sub(now(), interval 30 day) order by comment_date desc limit 30");
        }
        if ($dbaddresses) {
            foreach ($dbaddresses as $dbaddress) {
                $ip = inet_dtop($dbaddress->ip);
                $ip_pattern = preg_replace('/[\\.\\:][0-9a-f]+$/i', '', $ip);
                if (!in_array($ip_pattern, $addresses)) {
                    $addresses[] = $ip_pattern;
                }
            }
        }
    }
    $prefs['use_bar'] = User::get_pref($user->id, 'use_bar');
    $prefs['last_com_first'] = User::get_pref($user->id, 'last_com_first');
    $vars = compact('post', 'options', 'selected', 'rss', 'rss_title', 'geodiv', 'user', 'my_latlng', 'url', 'nofollow', 'nclones', 'show_email', 'entropy', 'percent', 'geo_form', 'addresses', 'friend_icon');
    return Haanga::Load('/user/profile.html', $vars);
}
Example #4
0
        case 'post':
            $url = 'http://' . get_server_name() . post_get_base_url($id);
            do_redirection($url);
            exit(0);
        case 'comment':
            $c = new Comment();
            $c->id = $id;
            $url = 'http://' . get_server_name() . $c->get_relative_individual_permalink();
            do_redirection($url);
            exit(0);
        default:
            $l = Link::from_db($id, null, false);
            if (!$l) {
                exit(0);
            }
            if (!$globals['mobile'] && !$globals['mobile_version'] && $current_user->user_id > 0 && User::get_pref($current_user->user_id, 'use_bar') && $db->get_var("select blog_type from blogs where blog_id = {$l->blog}") != 'noiframe') {
                if ($globals['base_bar_url']) {
                    $url = $globals['base_url'] . $globals['base_bar_url'] . $id;
                } else {
                    $url = $globals['base_url'] . "bar.php?id={$id}";
                }
                do_redirection($url, 307);
            } else {
                do_redirection($l->url);
            }
            $l->add_click();
            exit(0);
    }
} else {
    require mnminclude . $globals['html_main'];
    do_error(_('enlace inexistente'), 404);
Example #5
0
// 		http://www.affero.org/oagpl.html
// AFFERO GENERAL PUBLIC LICENSE is also included in the file called "COPYING".
include '../config.php';
header('Content-Type: application/json; charset=UTF-8');
if (!($id = intval($_POST['id']))) {
    error(_('falta el ID') . " {$id}");
}
if (!$current_user->user_id) {
    error(_('usuario incorrecto'));
}
$user = $current_user->user_id;
if (!check_security_key($_POST['key'])) {
    error(_('clave de control incorrecta'));
}
$db->transaction();
$exists = User::get_pref($user, 'sub_follow', $id);
if (empty($_POST['change'])) {
    $dict['value'] = $exists;
    $globals['access_log'] = false;
    // Don't log it, to avoid IP blocks
} else {
    if ($exists) {
        User::delete_pref($user, 'sub_follow', $id);
        $dict['value'] = 0;
    } else {
        User::set_pref($user, 'sub_follow', $id);
        $dict['value'] = 1;
    }
}
$db->commit();
echo json_encode($dict);
Example #6
0
    $globals['time_enabled_comments'] = min($globals['time_enabled_comments_status'][$link->status], $globals['time_enabled_comments']);
}
// Check for comment post
if ($_POST['process'] == 'newcomment') {
    $new_comment_error = Comment::save_from_post($link);
}
$offset = 0;
$limit = '';
$globals['page_base'] = empty($url_args[1]) ? '' : '/' . $url_args[1];
switch ($url_args[1]) {
    case '':
        $tab_option = 1;
        $order_field = 'comment_order';
        if ($globals['comments_page_size'] && $link->comments > $globals['comments_page_size'] * $globals['comments_page_threshold']) {
            if ($no_page) {
                if ($current_user->user_id > 0 && User::get_pref($current_user->user_id, 'last_com_first')) {
                    $last_com_first = true;
                    $canonical_page = $current_page = ceil($link->comments / $globals['comments_page_size']);
                } else {
                    $canonical_page = $current_page = 1;
                }
            }
            $offset = ($current_page - 1) * $globals['comments_page_size'];
            $limit = "LIMIT {$offset}," . $globals['comments_page_size'];
        } else {
            $canonical_page = 1;
        }
        if ($canonical_page > 1) {
            $globals['extra_head'] .= '<link rel="prev" href="' . $link->get_canonical_permalink($canonical_page - 1) . '" />';
        }
        if ($canonical_page < $total_pages) {
Example #7
0
do_header($page_title, _('privados'), get_posts_menu(5, $user->username));
$options = array(_('recibidos') => post_get_base_url('_priv'), _('enviados') => post_get_base_url('_priv') . '/sent');
do_priv_subheader($options, $view);
/*** SIDEBAR ****/
echo '<div id="sidebar">';
do_banner_right();
//do_best_stories();
if ($rows > 20) {
    do_best_posts();
    do_best_comments();
}
echo '</div>' . "\n";
/*** END SIDEBAR ***/
echo '<div id="newswrap">' . "\n";
if (check_email($current_user->user_email)) {
    $notify = User::get_pref($current_user->user_id, 'notify_priv');
    Haanga::Load('priv_notify.html', compact('notify'));
}
$messages = $db->object_iterator("SELECT" . PrivateMessage::SQL . "{$from} WHERE {$where} {$order_by} {$limit}", 'PrivateMessage');
if ($messages) {
    echo '<ol class="comments-list">';
    foreach ($messages as $message) {
        if ($message_id > 0 && $user->id > 0 && $user->id != $message->author) {
            echo '<li>' . _('Error: nota no existente') . '</li>';
        } else {
            echo '<li>';
            $message->print_summary();
            if (!$message->date_read && $message->to == $current_user->user_id) {
                $message->mark_read();
            }
            echo '</li>';
Example #8
0
// 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';
if (!check_security_key($_POST['control_key'])) {
    die;
}
$user = intval($_POST['id']);
$key = $_POST['key'];
$value = intval($_POST['value']);
if (!$value) {
    $value = false;
}
if (!$user || $user != $current_user->user_id) {
    die;
}
if (empty($key)) {
    die;
}
if (!empty($_POST['set'])) {
    $value = intval($_POST['value']);
    if (User::set_pref($user, $key, $value)) {
        $res = $value;
    } else {
        $res = false;
    }
} else {
    $res = User::get_pref($user, $key, $value);
}
header('Content-Type: application/json; charset=UTF-8');
echo json_encode($res);
Example #9
0
<?php

// The source code packaged with this file is Free Software, Copyright (C) 2011 by
// Ricardo Galli <gallir at gmail.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".
include '../config.php';
$user = intval($_POST['id']);
$key = $_POST['key'];
if (!$user || $user != $current_user->user_id) {
    die;
}
if (empty($key)) {
    die;
}
if (isset($_POST['value'])) {
    $value = intval($_POST['value']);
    if (User::set_pref($user, $key, $value)) {
        $res = $value;
    } else {
        $res = false;
    }
} else {
    $res = User::get_pref($user, $key);
}
header('Content-Type: application/json; charset=UTF-8');
echo json_encode($res);