$sql = "SELECT vote_link_id FROM votes WHERE vote_type='links' and vote_user_id = {$user_id} and vote_value > 0 ORDER BY vote_date DESC limit {$rows}"; $user_login = $db->get_var("select user_login from users where user_id={$user_id}"); $title = $site_info->name . ': ' . sprintf(_('votadas por %s'), $user_login); } elseif (!empty($_REQUEST['friends_of'])) { ///// // users' friends ///// $user_id = guess_user_id($_REQUEST['friends_of']); $sql = "SELECT link_id FROM links, friends WHERE friend_type='manual' and friend_from = {$user_id} and friend_to=link_author and friend_value > 0 and link_status in ('queued', 'published') ORDER BY link_date DESC limit {$rows}"; $user_login = $db->get_var("select user_login from users where user_id={$user_id}"); $title = $site_info->name . ': ' . sprintf(_('amigos de %s'), $user_login); } elseif (!empty($_REQUEST['sent_by'])) { ///// // sent links ///// $user_id = guess_user_id($_REQUEST['sent_by']); $sql = "SELECT link_id FROM links WHERE link_author={$user_id} and link_votes > 0 ORDER BY link_id DESC limit {$rows}"; $user_login = $db->get_var("select user_login from users where user_id={$user_id}"); $title = $site_info->name . ': ' . sprintf(_('noticias de %s'), $user_login); } elseif (isset($_REQUEST['active'])) { $title = $site_info->name . ': ' . _('más activas'); $top = new Annotation('top-actives-' . $globals['site_shortname']); if ($top->read()) { $links = explode(',', $top->text); } } elseif (isset($_REQUEST['popular'])) { $min_date = date("Y-m-d H:i:00", $globals['now'] - 129600); // 36 hours // The order is not exactly the votes // but a time-decreasing function applied to the number of votes $sql = "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 25";
$last_modified = $db->get_var("SELECT UNIX_TIMESTAMP(post_date) FROM posts, friends WHERE friend_type='manual' and friend_from = {$id} and friend_to=post_user_id and friend_value > 0 ORDER BY post_date DESC LIMIT 1"); $title = _('Nótame') . ': ' . sprintf(_('amigos de %s'), $username); } elseif (!empty($_REQUEST['favorites_of'])) { ///// // users' favorites ///// $user_id = guess_user_id($_REQUEST['favorites_of']); $username = $db->get_var("select user_login from users where user_id={$user_id}"); $sql = "SELECT post_id FROM posts, favorites WHERE favorite_user_id={$user_id} AND favorite_type='post' AND favorite_link_id=post_id ORDER BY favorite_date DESC limit {$rows}"; $last_modified = $db->get_var("SELECT UNIX_TIMESTAMP(max(favorite_date)) from favorites where favorite_user_id={$user_id} AND favorite_type='post'"); $title = _('Nótame') . ': ' . sprintf(_('favoritos de %s'), $username); } elseif (!empty($_REQUEST['conversation_of'])) { // // Conversation posts // $id = guess_user_id($_GET['conversation_of']); $username = $db->get_var("select user_login from users where user_id={$id}"); $sql = "SELECT conversation_from as post_id FROM conversations WHERE conversation_user_to={$id} and conversation_type='post' ORDER BY conversation_time desc LIMIT {$rows}"; $last_modified = $db->get_var("SELECT UNIX_TIMESTAMP(conversation_time) FROM conversations WHERE conversation_user_to={$id} and conversation_type='post' ORDER BY conversation_time DESC LIMIT 1"); $title = _('Nótame') . ': ' . sprintf(_('conversación de %s'), $username); } else { // // All posts // $id = 0; $sql = "SELECT post_id FROM posts WHERE {$from_time} ORDER BY post_date DESC LIMIT {$rows}"; $last_modified = $db->get_var("SELECT UNIX_TIMESTAMP(post_date) FROM posts ORDER BY post_date DESC LIMIT 1"); $title = _('Nótame') . ': ' . _('notas'); } do_header($title); $post = new Post();
$individual_user = true; $id = guess_user_id($_GET['author_id']); $username = $db->get_var("select user_login from users where user_id={$id}"); if ($if_modified > 0) { $from_time = "AND comment_date > FROM_UNIXTIME({$if_modified})"; } $sql = "SELECT comment_id FROM comments, links WHERE link_author={$id} and comment_link_id=link_id {$from_time} ORDER BY comment_date DESC LIMIT {$rows}"; $last_modified = $db->get_var("SELECT UNIX_TIMESTAMP(comment_date) FROM comments, links WHERE link_author={$id} and comment_link_id=link_id ORDER BY comment_date DESC LIMIT 1"); $title = $globals['site_name'] . ': ' . sprintf(_('comentarios noticias de %s'), $username); $globals['redirect_feedburner'] = false; } elseif (!empty($_GET['answers_id'])) { // // Answers to this user's comments // $individual_user = true; $id = guess_user_id($_GET['answers_id']); $username = $db->get_var("select user_login from users where user_id={$id}"); if ($if_modified > 0) { $from_time = "AND conversation_time > FROM_UNIXTIME({$if_modified})"; } $sql = "SELECT conversation_from FROM conversations WHERE conversation_user_to={$id} and conversation_type='comment' {$from_time} ORDER BY conversation_time DESC LIMIT {$rows}"; $last_modified = $db->get_var("SELECT UNIX_TIMESTAMP(conversation_time) FROM conversations WHERE conversation_user_to={$id} and conversation_type='comment' ORDER BY conversation_time DESC LIMIT 1"); $title = $globals['site_name'] . ': ' . sprintf(_('respuestas a %s'), $username); $globals['redirect_feedburner'] = false; } else { // // All comments // $id = 0; if ($if_modified > 0) { $from_time = "AND comment_date > FROM_UNIXTIME({$if_modified})";
$username = $db->get_var("select user_login from users where user_id={$id}"); if ($if_modified > 0 && $if_modified > time() - 86400 * 3) { $from_time = "FROM_UNIXTIME({$if_modified})"; } else { $from_time = "date_sub(now(), interval 5 day)"; } $sql = "SELECT DISTINCT comments1.comment_id FROM comments AS comments1 INNER JOIN comments AS comments2 WHERE comments1.comment_link_id = comments2.comment_link_id AND comments2.comment_user_id={$id} AND comments2.comment_date > {$from_time} order by comments1.comment_id desc LIMIT {$rows}"; $last_modified = $db->get_var("SELECT UNIX_TIMESTAMP(comments1.comment_date) FROM comments AS comments1 INNER JOIN comments AS comments2 WHERE comments1.comment_link_id = comments2.comment_link_id AND comments2.comment_user_id={$id} AND comments2.comment_date > {$from_time} order by comments1.comment_id desc LIMIT 1"); $title = _('Menéame: conversación de ') . $username; $globals['redirect_feedburner'] = false; } elseif (!empty($_GET['author_id'])) { // // User's link comments // $individual_user = true; $id = guess_user_id($_GET['author_id']); $username = $db->get_var("select user_login from users where user_id={$id}"); if ($if_modified > 0) { $from_time = "AND comment_date > FROM_UNIXTIME({$if_modified})"; } $sql = "SELECT comment_id FROM comments, links WHERE link_author={$id} and comment_link_id=link_id {$from_time} ORDER BY comment_date DESC LIMIT {$rows}"; $last_modified = $db->get_var("SELECT UNIX_TIMESTAMP(comment_date) FROM comments, links WHERE link_author={$id} and comment_link_id=link_id ORDER BY comment_date DESC LIMIT 1"); $title = _('Menéame: comentarios noticias de ') . $username; $globals['redirect_feedburner'] = false; } else { // // All comments // $id = 0; if ($if_modified > 0) { $from_time = "WHERE comment_date > FROM_UNIXTIME({$if_modified})";
function get_user_uri_by_uid($user, $view='') { global $globals; $uid = guess_user_id($user); if ($uid == 0) $uid = -1; // User does not exist, ensure it will give error later $uri = get_user_uri($user, $view); if (!empty($globals['base_user_url'])) { $uri .= "/$uid"; } else { $uri .= "&uid=$uid"; } return $uri; }
} $from_time = "post_date > FROM_UNIXTIME({$if_modified})"; if (!empty($_GET['user_id'])) { // // Users posts // $id = guess_user_id($_GET['user_id']); $username = $db->get_var("select user_login from users where user_id={$id}"); $sql = "SELECT post_id FROM posts WHERE post_user_id={$id} and {$from_time} ORDER BY post_date DESC LIMIT {$rows}"; $last_modified = $db->get_var("SELECT UNIX_TIMESTAMP(post_date) FROM posts WHERE post_user_id={$id} ORDER BY post_date DESC LIMIT 1"); $title = _('Nótame: notas de ') . $username; } elseif (!empty($_REQUEST['friends_of'])) { // // User's friend posts // $id = guess_user_id($_GET['friends_of']); $username = $db->get_var("select user_login from users where user_id={$id}"); $sql = "SELECT post_id FROM posts, friends WHERE friend_type='manual' and friend_from = {$id} and friend_to=post_user_id and friend_value > 0 and {$from_time} ORDER BY post_date DESC LIMIT {$rows}"; $last_modified = $db->get_var("SELECT UNIX_TIMESTAMP(post_date) FROM posts, friends WHERE friend_type='manual' and friend_from = {$id} and friend_to=post_user_id and friend_value > 0 ORDER BY post_date DESC LIMIT 1"); $title = _('Nótame: notas amigos de ') . $username; } else { // // All posts // $id = 0; $sql = "SELECT post_id FROM posts WHERE {$from_time} ORDER BY post_date DESC LIMIT {$rows}"; $last_modified = $db->get_var("SELECT UNIX_TIMESTAMP(post_date) FROM posts ORDER BY post_date DESC LIMIT 1"); $title = _('Nótame: notas'); } do_header($title); $post = new Post();