} $user->username = $login; } if (!$user->read()) { do_error(_('usuario inexistente'), 404); } $login = $user->username; // Just in case, we user the database username $globals['search_options'] = array('u' => $user->username); $view = clean_input_string($_REQUEST['view']); if (empty($view)) { $view = 'profile'; } // The profile's use marked the current one as friend if ($current_user->user_id) { $user->friendship = User::friend_exists($user->id, $current_user->user_id); } else { $user->friendship = 0; } // For editing notes and sending privates if ($current_user->user_id == $user->id || $current_user->admin || $user->friendship) { $globals['extra_js'][] = 'ajaxupload.min.js'; } // Enable user AdSense // do_user_ad: 0 = noad, > 0: probability n/100 // 100 if the user is the current one if ($globals['external_user_ads'] && !empty($user->adcode)) { $globals['user_adcode'] = $user->adcode; $globals['user_adchannel'] = $user->adchannel; if ($current_user->user_id == $user->id || $current_user->admin) { $globals['do_user_ad'] = 100;
function get_votes($dbtime) { global $db, $events, $last_timestamp, $foo_link, $max_items, $current_user; $res = $db->get_results("select vote_id, unix_timestamp(vote_date) as timestamp, vote_value, INET_NTOA(vote_ip_int) as vote_ip, vote_user_id, link_id, link_title, link_uri, link_status, link_date, link_votes, link_anonymous, link_comments from votes, links, sub_statuses where sub_statuses.id = " . SitesMgr::my_id() . " and vote_type='links' and vote_date > {$dbtime} and link_id = sub_statuses.link and sub_statuses.link = vote_link_id and vote_user_id != link_author order by vote_date desc limit {$max_items}"); if (!$res) { return; } foreach ($res as $event) { if ($current_user->user_id > 0) { if (!empty($_REQUEST['friends']) && $event->vote_user_id != $current_user->user_id) { // Check the user is a friend if (User::friend_exists($current_user->user_id, $event->vote_user_id) <= 0) { continue; } elseif ($event->vote_value < 0) { // If the vote is negative, verify also the other user has selected as friend to the current one if (User::friend_exists($event->vote_user_id, $current_user->user_id) <= 0) { continue; } } } elseif (!empty($_REQUEST['admin']) && $current_user->admin) { $user_level = $db->get_var("select user_level from users where user_id={$event->vote_user_id}"); if ($user_level != 'admin' && $user_level != 'god') { continue; } } } if ($event->vote_value >= 0) { if ($_REQUEST['novote']) { continue; } if ($event->link_status == 'published' && $_REQUEST['nopubvotes']) { continue; } } else { if ($_REQUEST['noproblem']) { continue; } } $foo_link->id = $event->link_id; $foo_link->uri = $event->link_uri; $foo_link->get_relative_permalink(); $uid = $event->vote_user_id; if ($event->vote_user_id > 0) { $res = $db->get_row("select user_login from users where user_id = {$event->vote_user_id}"); $user = $res->user_login; } else { $user = preg_replace('/\\.[0-9]+$/', '', $event->vote_ip); } if ($event->vote_value >= 0) { $type = 'vote'; $who = $user; } else { $type = 'problem'; $who = get_negative_vote($event->vote_value); // Show user_login if she voted more than N negatives in one minute if ($current_user->user_id > 0 && $current_user->admin) { $negatives_last_minute = $db->get_var("select count(*) from votes where vote_type='links' and vote_user_id={$event->vote_user_id} and vote_date > date_sub(now(), interval 30 second) and vote_value < 0"); if ($negatives_last_minute > 2) { $who .= "<br>({$user})"; } } } $json['status'] = get_status($event->link_status); $json['type'] = $type; $json['ts'] = $event->timestamp; $json['votes'] = $event->link_votes + $event->link_anonymous; $json['com'] = $event->link_comments; $json['link'] = $foo_link->get_relative_permalink(); $json['title'] = $event->link_title; $json['who'] = $who; $json['uid'] = $event->vote_user_id; $json['id'] = $event->link_id; if ($event->vote_user_id > 0) { $json['icon'] = get_avatar_url($event->vote_user_id, -1, 20); } $key = $event->timestamp . ':votes:' . $event->vote_id; $events[$key] = $json; if ($event->timestamp > $last_timestamp) { $last_timestamp = $event->timestamp; } } }
function print_summary($link = 0, $length = 0, $single_link=true, $no_padding = false) { global $current_user, $globals; if(!$this->read) return; if (! $link && $this->link > 0) { $link = new Link; $link->id = $this->link; $link->read(); $this->link_object = $link; } if ($single_link) $html_id = $this->order; else $html_id = $this->id; if ($this->nested_level == 1) $no_padding = true; if ($no_padding) { $padding = 0;//(int)$this->level * 30; } else { $padding = 33;//(int)$this->level * 30; } //echo '<div id="c-'.$html_id.'" class="'.(($this->nested_level>1)?'cmt':'cmt').'" style="margin-left:'.$padding.'px;" >'; echo '<style>'; echo ' div.cmt { border-width:0px 0px 0px 1px; border-style:dotted; border-color:#AADB7A; }'; echo '</style>'; echo '<div id="c-'.$html_id.'" class="'.(($this->nested_level>1)?'cmt':'').'" style="margin-left:'.$padding.'px;" >'; /* if ($this->type != 'admin' && $this->user_level != 'disabled') { // Print the votes info (left) if ($current_user->user_id > 0 && $this->author != $current_user->user_id && $single_link && $this->date > $globals['now'] - $globals['time_enabled_comments'] && $this->level != 'autodisabled') { */ $this->print_shake_icons(); /* } else { echo '<div style="float:left">'; echo '<span id="c-votes-'.$this->id.'">'; echo '<a href="javascript:menealo_comment('."$current_user->user_id,$this->id,1".')" title="'._('informativo, opinión razonada, buen humor...').'"><img src="'.$globals['base_static'].'img/common/vote-up02.png" width="18" height="16" alt="'._('voto positivo').'"/></a><br/>'; echo '<a href="javascript:menealo_comment('."$current_user->user_id,$this->id,-1".')" title="'._('abuso, insulto, acoso, spam, magufo...').'"><img style="padding-top:5px;" src="'.$globals['base_static'].'img/common/vote-down02.png" width="18" height="16" alt="'._('voto negativo').'"/></a> '; echo '</span>'; echo '</div>'; } } */ $this->ignored = ($current_user->user_id > 0 && $this->type != 'admin' && User::friend_exists($current_user->user_id, $this->author) < 0); $this->hidden = ($globals['comment_highlight_karma'] > 0 && $this->karma < -$globals['comment_highlight_karma']) || ($this->user_level == 'disabled' && $this->type != 'admin'); if ($this->hidden || $this->ignored) { $comment_meta_class = 'comment-meta-hidden'; $comment_class = 'comment-body-hidden'; } else { $comment_meta_class = 'comment-meta'; $comment_class = 'comment-body'; if ($this->type == 'admin') { $comment_class .= ' admin'; } elseif ($globals['comment_highlight_karma'] > 0 && $this->karma > $globals['comment_highlight_karma']) { $comment_class .= ' high'; } } $this->link_permalink = $link->get_relative_permalink(); /* $bgcolor = Array("R"=>hexdec("C5"),"G"=>hexdec("E7"),"B"=>hexdec("A4")); $n = $this->nested_level - 1; $bgcolor["R"] = min($bgcolor["R"] + (((255 - $bgcolor["R"]) / 5) * $n), 255); $bgcolor["G"] = min($bgcolor["G"] + (((255 - $bgcolor["G"]) / 5) * $n), 255); $bgcolor["B"] = min($bgcolor["B"] + (((255 - $bgcolor["B"]) / 5) * $n), 255); $bgcolor = dechex($bgcolor["R"]) . dechex($bgcolor["G"]) . dechex($bgcolor["B"]); */ $color_list = Array( '#C5E7A4', '#C4E6A2', '#A2E6A2', '#A2E6C4', '#A2E6E6', '#A2C4E6', '#A2A2E6', '#C4A2E6', '#E6A2E6', '#E6A2C4', '#E6A2A2', '#E6C4A2', '#E6E6A2', '#A6DA72', '#87CD42', '#A672DA', '#8742CD' ); $bgcolor = $color_list[$this->nested_level]; if (empty($bgcolor)) $bgcolor = end($color_list); //echo '<div class="'.$comment_class.'" style="margin-bottom:10px;padding-bottom:5px;background-color:'.$bgcolor.' !important;">'; echo '<div class="'.$comment_class.'" style="margin-bottom:10px;padding-bottom:5px;background-color:white;min-width:600px;">'; //echo '<a href="'.$this->link_permalink.'/000'.$this->order.'"><strong>#'.$this->order.'</strong></a>'; echo '<a href="#" class="f-'.$this->id.' fold" style="font-family:verdana;font-size:x-small;" ></strong>(-)</strong></a>'; //echo ' <span id="cid-'.$this->id.'">'; echo ' <span id="cid-'.$this->id.'">'; if ($this->ignored || ($this->hidden && ($current_user->user_comment_pref & 1) == 0)) { echo '» <a href="javascript:get_votes(\'get_comment.php\',\'comment\',\'cid-'.$this->id.'\',0,'.$this->id.')" title="'._('ver comentario').'">'._('ver comentario').'</a>'; echo '</span>'; } else { $this->print_text($length, $html_id); echo '</span>'; } //echo '</div>'; // The comments info bar echo '<div class="'.$comment_meta_class.' comment_mc" >'; // Check that the user can vote echo '<div class="comment-votes-info">'; echo '<a class="comment_vi" href="#c-'.$this->c_order.'" >#'.$this->c_order.'</a> '; if ($this->type != 'admin' && $this->user_level != 'disabled') { // Print the votes info (left) /* if ($current_user->user_id > 0 && $this->author != $current_user->user_id && $single_link && $this->date > $globals['now'] - $globals['time_enabled_comments'] && $this->level != 'autodisabled') { //$this->print_shake_icons(); } */ echo _('votos').': <span id="vc-'.$this->id.'">'.$this->votes.'</span>, '._('karma').': <span id="vk-'.$this->id.'">'.$this->karma.'</span> '; // Add the icon to show votes if ($this->votes > 0 && $this->date > $globals['now'] - 30*86400) { // Show votes if newer than 30 days echo '<a href="javascript:modal_from_ajax(\''.$globals['base_url'].'backend/get_c_v.php?id='.$this->id.'\')">'; echo '<img src="'.$globals['base_static'].'img/common/vote-info02.png" width="18" height="16" alt="+ info" title="'._('¿quién ha votado?').'"/>'; echo '</a>'; } } // Comment reply if ($current_user->user_id > 0 && $globals['link'] && $globals['link']->date > $globals['now'] - $globals['time_enabled_comments']) { echo '<a href="javascript:comment_reply('.$this->order.','.$this->id.')" title="'._('responder').'"><img src="'.$globals['base_static'].'img/common/reply02.png" width="18" height="16"/></a>'; } // Comment permalink echo '<a href="'.$this->get_relative_individual_permalink().'" title="permalink"><img class="link-icon" src="'.$globals['base_static'].'img/common/link-02.png" width="18" height="16" alt="link" title="'._('enlace permanente').'"/></a>'; // If the user is authenticated, show favorite box if ($current_user->user_id > 0) { echo '<a id="fav-'.$this->id.'" href="javascript:get_votes(\'get_favorite_comment.php\',\''.$current_user->user_id.'\',\'fav-'.$this->id.'\',0,\''.$this->id.'\')">'.favorite_teaser($current_user->user_id, $this, 'comment').'</a>'; } echo '</div>'; // Print comment info (right) echo '<div class="comment-info">'; if ($this->type == 'admin') { $author = '<strong>'._('admin').'</strong> '; if ($current_user->admin) { $author .= ' ('.$this->username.')'; } } elseif ($single_link) { $author = '<a href="'.get_user_uri($this->username).'" title="karma: '.$this->user_karma.'" id="cauthor-'.$this->order.'">'.$this->username.'</a>'; } else { $author = '<a href="'.get_user_uri($this->username).'" title="karma: '.$this->user_karma.'">'.$this->username.'</a>'; } // Print dates if ($this->modified > $this->date + 1) { $edited = sprintf('<strong title="'. _('editado %s después').'">* </strong>', txt_time_diff($this->date, $this->modified)); } else $edited = ''; if (!$this->hidden && $this->type != 'admin' && $this->avatar) { $avatar = get_avatar_url($this->author, $this->avatar, 20); } else { $avatar = get_no_avatar_url(20); } if ($globals['now'] - $this->date > 604800) { // 7 days printf(_('el %s %s por %s'), get_date_time($this->date), $edited, $author); } else { printf(_('fai %s %s por %s'), txt_time_diff($this->date), $edited, $author); } echo '<img src="'.$avatar.'" width="20" height="20" alt="" title="'.$this->username.', karma: '.$this->user_karma.'" />'; echo '</div>'; echo '</div></div>'; }
function update_conversation() { global $db, $globals; $previous_ids = $db->get_col("select distinct conversation_to from conversations where conversation_type='post' and conversation_from={$this->id}"); if ($previous_ids) { // Select users previous conversation to decrease in the new system $previous_users = $db->get_col("select distinct conversation_user_to from conversations where conversation_type='post' and conversation_from={$this->id}"); } else { $previous_users = array(); } //$db->query("delete from conversations where conversation_type='post' and conversation_from=$this->id"); $seen_users = array(); $seen_ids = array(); $refs = 0; if (!$this->date) { $this->date = time(); } if (preg_match_all(Post::REF_PREG, $this->content, $matches)) { foreach ($matches[2] as $reference) { $user = $db->escape(preg_replace('/,\\d+$/', '', $reference)); $to = $db->get_var("select user_id from users where user_login = '******'"); $id = intval(preg_replace('/[^\\s]+,(\\d+)$/', '$1', $reference)); if (!$to > 0) { continue; } if (!$id > 0) { $id = (int) $db->get_var("select post_id from posts where post_user_id = {$to} and post_date < FROM_UNIXTIME({$this->date}) order by post_date desc limit 1"); } if (!in_array($id, $previous_ids) && !in_array($id, $seen_ids)) { if (User::friend_exists($to, $this->author) >= 0 && $refs < 10 && $this->author != $to && !in_array($to, $seen_users) && !in_array($to, $previous_users)) { User::add_notification($to, 'post'); } $db->query("insert into conversations (conversation_user_to, conversation_type, conversation_time, conversation_from, conversation_to) values ({$to}, 'post', from_unixtime({$this->date}), {$this->id}, {$id})"); } $refs++; if (!in_array($id, $seen_ids)) { $seen_ids[] = $id; } if (!in_array($to, $seen_users)) { $seen_users[] = $to; } } } $to_delete = array_diff($previous_ids, $seen_ids); if ($to_delete) { $to_delete = implode(',', $to_delete); $db->query("delete from conversations where conversation_type='post' and conversation_from={$this->id} and conversation_to in ({$to_delete})"); } $to_unnotify = array_diff($previous_users, $seen_users); foreach ($to_unnotify as $to) { User::add_notification($to, 'post', -1); } }
function print_summary($length = 0) { global $current_user, $globals; if (!$this->read) { $this->read(); } $this->hidden = $this->karma < $globals['post_hide_karma'] || $this->user_level == 'disabled'; $this->ignored = $current_user->user_id > 0 && User::friend_exists($current_user->user_id, $this->author) < 0; echo '<div id="pcontainer-' . $this->id . '">'; if ($this->hidden || $this->ignored) { $post_meta_class = 'comment-meta-hidden'; $post_class = 'comment-body-hidden'; } else { $post_meta_class = 'comment-meta'; $post_class = 'comment-body'; if ($this->karma > $globals['post_highlight_karma']) { $post_class .= ' high'; } } echo '<div class="' . $post_class . '" id="pid-' . $this->id . '">'; if ($this->ignored || $this->hidden && ($current_user->user_comment_pref & 1) == 0) { echo '» <a href="javascript:get_votes(\'get_post.php\',\'post\',\'pid-' . $this->id . '\',0,' . $this->id . ')" title="' . _('ver texto') . '">' . _('ver texto') . '</a>'; } else { $this->print_user_avatar(40); $this->print_text($length); } echo '</div>'; // The comments info bar echo '<div class="' . $post_meta_class . '">'; // Print the votes info (left) echo '<div class="comment-votes-info">'; // Check that the user can vote if ($current_user->user_id > 0 && $this->author != $current_user->user_id && $this->date > time() - $globals['time_enabled_votes']) { $this->print_shake_icons(); } echo _('votos') . ': <span id="vc-' . $this->id . '">' . $this->votes . '</span>, ' . _('karma') . ': <span id="vk-' . $this->id . '">' . $this->karma . '</span> '; // Add the icon to show votes if ($this->votes > 0 && $this->date > $globals['now'] - 30 * 86400) { // Show votes if newer than 30 days echo '<a href="javascript:modal_from_ajax(\'' . $globals['base_url'] . 'backend/get_p_v.php?id=' . $this->id . '\')">'; echo '<img src="' . $globals['base_static'] . 'img/common/vote-info02.png" width="18" height="16" alt="+ info" title="' . _('¿quién ha votado?') . '"/>'; echo '</a>'; } // Reply button if ($current_user->user_id > 0) { echo '<a href="javascript:post_reply(' . $this->id . ',\'' . $this->username . '\')" title="' . _('responder') . '"><img src="' . $globals['base_static'] . 'img/common/reply02.png" width="18" height="16"/></a>'; } // Permalink echo '<a href="' . post_get_base_url($this->id) . '" title="permalink"><img class="link-icon" src="' . $globals['base_static'] . 'img/common/link-02.png" width="18" height="16" alt="link" title="' . _('enlace permanente') . '"/></a>'; // If the user is authenticated, show favorite box if ($current_user->user_id > 0) { echo '<a id="fav-' . $this->id . '" href="javascript:get_votes(\'get_favorite_post.php\',\'' . $current_user->user_id . '\',\'fav-' . $this->id . '\',0,\'' . $this->id . '\')">' . favorite_teaser($current_user->user_id, $this, 'post') . '</a>'; } echo '</div>'; // Print comment info (right) echo '<div class="comment-info">'; $author = '<a href="' . post_get_base_url($this->username) . '">' . ' ' . $this->username . '</a> (' . $this->src . ')'; // Print dates if ($globals['now'] - $this->date > 604800) { // 7 days printf(_('el %s %s por %s'), get_date_time($this->date), '', $author); } else { printf(_('hace %s %s por %s'), txt_time_diff($this->date), '', $author); } //$this->print_user_avatar(20); echo '</div></div>'; echo "</div>\n"; }
function update_conversation() { global $db, $globals, $current_user; $previous_ids = $db->get_col("select distinct conversation_to from conversations where conversation_type='comment' and conversation_from={$this->id}"); if ($previous_ids) { // Select users previous conversation to decrease in the new system $previous_users = $db->get_col("select distinct conversation_user_to from conversations where conversation_type='comment' and conversation_from={$this->id}"); } else { $previous_users = array(); } $seen_users = array(); $seen_ids = array(); $refs = 0; $orders = array(); if (preg_match_all('/(?:^|\\W)(#(?:\\d+)|@(?:[\\p{L}\\.][\\.\\d\\-_\\p{L}]+))\\b/u', $this->content, $matches)) { foreach ($matches[1] as $order) { $order = substr($order, 1); // Delete the # or @ $orders[$order] += 1; } } if (!$this->date) { $this->date = time(); } foreach ($orders as $order => $val) { if ($refs > 10) { // Limit the number of references to avoid abuses/spam syslog(LOG_NOTICE, "Meneame: too many references in comment: {$this->id} ({$current_user->user_login})"); break; } if (!preg_match('/^\\d+/', $order)) { $username_to = $db->escape($order); $to = $db->get_row("select 0 as id, user_id from users where user_login = '******'"); } elseif ($order == 0) { $to = $db->get_row("select 0 as id, link_author as user_id from links where link_id = {$this->link}"); } else { $to = $db->get_row("select comment_id as id, comment_user_id as user_id from comments where comment_link_id = {$this->link} and comment_order={$order} and comment_type != 'admin'"); } if (!$to) { continue; } if (!in_array($to->id, $previous_ids) && !in_array($to->id, $seen_ids)) { if (User::friend_exists($to->user_id, $this->author) >= 0 && $to->user_id != $this->author && !in_array($to->user_id, $seen_users) && !in_array($to->user_id, $previous_users)) { User::add_notification($to->user_id, 'comment'); } $db->query("insert into conversations (conversation_user_to, conversation_type, conversation_time, conversation_from, conversation_to) values ({$to->user_id}, 'comment', from_unixtime({$this->date}), {$this->id}, {$to->id})"); } $refs++; if (!in_array($id, $seen_ids)) { $seen_ids[] = $to->id; } if (!in_array($to, $seen_users)) { $seen_users[] = $to->user_id; } } $to_delete = array_diff($previous_ids, $seen_ids); if ($to_delete) { $to_delete = implode(',', $to_delete); $db->query("delete from conversations where conversation_type='comment' and conversation_from={$this->id} and conversation_to in ({$to_delete})"); } $to_unnotify = array_diff($previous_users, $seen_users); foreach ($to_unnotify as $to) { User::add_notification($to, 'comment', -1); } }
static function can_send($from, $to) { global $db; $friendship = User::friend_exists($to, $from); return $friendship > 0 || !$friendship && intval($db->get_var("select count(*) from privates where user = {$to} and `to` = {$from} and date > date_sub(now(), interval 15 day)")) > 0; }
function print_summary($link = 0, $length = 0, $single_link=true) { global $current_user, $globals; if(!$this->read) return; if (! $link && $this->link > 0) { $link = new Link; $link->id = $this->link; $link->read(); $this->link_object = $link; } if ($single_link) $html_id = $this->order; else $html_id = $this->id; echo '<div id="c-'.$html_id.'">'; $this->ignored = ($current_user->user_id > 0 && $this->type != 'admin' && User::friend_exists($current_user->user_id, $this->author) < 0); $this->hidden = ($globals['comment_highlight_karma'] > 0 && $this->karma < -$globals['comment_highlight_karma']) || ($this->user_level == 'disabled' && $this->type != 'admin'); if ($this->hidden || $this->ignored) { $comment_meta_class = 'comment-meta-hidden'; $comment_class = 'comment-body-hidden'; } else { $comment_meta_class = 'comment-meta'; $comment_class = 'comment-body'; if ($this->type == 'admin') { $comment_class .= ' admin'; } elseif ($globals['comment_highlight_karma'] > 0 && $this->karma > $globals['comment_highlight_karma']) { $comment_class .= ' high'; } } $this->link_permalink = $link->get_relative_permalink(); echo '<div class="'.$comment_class.'">'; echo '<a href="'.$this->link_permalink.'/000'.$this->order.'"><strong>#'.$this->order.'</strong></a>'; echo ' <span id="cid-'.$this->id.'">'; if ($this->ignored || ($this->hidden && ($current_user->user_comment_pref & 1) == 0)) { echo '» <a href="javascript:get_votes(\'get_comment.php\',\'comment\',\'cid-'.$this->id.'\',0,'.$this->id.')" title="'._('ver comentario').'">'._('ver comentario').'</a>'; echo '</span>'; } else { $this->print_text($length, $html_id); echo '</span>'; } echo '</div>'; // The comments info bar echo '<div class="'.$comment_meta_class.'">'; // Check that the user can vote echo '<div class="comment-votes-info">'; if ($this->type != 'admin' && $this->user_level != 'disabled') { // Print the votes info (left) if ($current_user->user_id > 0 && $this->author != $current_user->user_id && $single_link && $this->date > $globals['now'] - $globals['time_enabled_comments'] && $this->level != 'autodisabled') { $this->print_shake_icons(); } echo _('votos').': <span id="vc-'.$this->id.'">'.$this->votes.'</span>, '._('karma').': <span id="vk-'.$this->id.'">'.$this->karma.'</span> '; // Add the icon to show votes if ($this->votes > 0 && $this->date > $globals['now'] - 30*86400) { // Show votes if newer than 30 days echo '<a href="javascript:modal_from_ajax(\''.$globals['base_url'].'backend/get_c_v.php?id='.$this->id.'\')">'; echo '<img src="'.$globals['base_static'].'img/common/vote-info02.png" width="18" height="16" alt="+ info" title="'._('¿quién ha votado?').'"/>'; echo '</a>'; } } // Comment reply if ($current_user->user_id > 0 && $globals['link'] && $globals['link']->date > $globals['now'] - $globals['time_enabled_comments']) { echo '<a href="javascript:comment_reply('.$this->order.')" title="'._('responder').'"><img src="'.$globals['base_static'].'img/common/reply02.png" width="18" height="16"/></a>'; } // Comment permalink echo '<a href="'.$this->get_relative_individual_permalink().'" title="permalink"><img class="link-icon" src="'.$globals['base_static'].'img/common/link-02.png" width="18" height="16" alt="link" title="'._('enlace permanente').'"/></a>'; // If the user is authenticated, show favorite box if ($current_user->user_id > 0) { echo '<a id="fav-'.$this->id.'" href="javascript:get_votes(\'get_favorite_comment.php\',\''.$current_user->user_id.'\',\'fav-'.$this->id.'\',0,\''.$this->id.'\')">'.favorite_teaser($current_user->user_id, $this, 'comment').'</a>'; } echo '</div>'; // Print comment info (right) echo '<div class="comment-info">'; if ($this->type == 'admin') { $author = '<strong>'._('admin').'</strong> '; if ($current_user->admin) { $author .= ' ('.$this->username.')'; } } elseif ($single_link) { $author = '<a href="'.get_user_uri($this->username).'" title="karma: '.$this->user_karma.'" id="cauthor-'.$this->order.'">'.$this->username.'</a>'; } else { $author = '<a href="'.get_user_uri($this->username).'" title="karma: '.$this->user_karma.'">'.$this->username.'</a>'; } // Print dates if ($this->modified > $this->date + 1) { $edited = sprintf('<strong title="'. _('editado %s después').'">* </strong>', txt_time_diff($this->date, $this->modified)); } else $edited = ''; if (!$this->hidden && $this->type != 'admin' && $this->avatar) { $avatar = get_avatar_url($this->author, $this->avatar, 20); } else { $avatar = get_no_avatar_url(20); } if ($globals['now'] - $this->date > 604800) { // 7 days printf(_('el %s %s por %s'), get_date_time($this->date), $edited, $author); } else { printf(_('hace %s %s por %s'), txt_time_diff($this->date), $edited, $author); } echo '<img src="'.$avatar.'" width="20" height="20" alt="" title="'.$this->username.', karma: '.$this->user_karma.'" />'; echo '</div></div>'; echo "</div>\n"; }
function get_votes($dbtime) { global $db, $globals, $events, $last_timestamp, $max_items, $current_user; if ($globals['subs']) { $filter = 'and sub_statuses.id in (' . $globals['subs'] . ')'; } else { $filter = ''; } $res = $db->get_results("select vote_link_id, vote_id, unix_timestamp(vote_date) as timestamp, vote_value, INET_NTOA(vote_ip_int) as vote_ip, vote_user_id, user_login, user_level from votes LEFT JOIN users on (user_id = vote_user_id), sub_statuses where vote_type='links' and vote_date > {$dbtime} and sub_statuses.link = vote_link_id {$filter} order by vote_date desc limit {$max_items}"); if (!$res) { return; } foreach ($res as $event) { $link = Link::from_db($event->vote_link_id, null, false); if (!$link) { continue; } if ($current_user->user_id > 0) { if (!empty($_REQUEST['friends']) && $event->vote_user_id != $current_user->user_id) { // Check the user is a friend if (User::friend_exists($current_user->user_id, $event->vote_user_id) <= 0) { continue; } elseif ($event->vote_value < 0) { // If the vote is negative, verify also the other user has selected as friend to the current one if (User::friend_exists($event->vote_user_id, $current_user->user_id) <= 0) { continue; } } } elseif (!empty($_REQUEST['admin']) && $current_user->admin) { if ($event->user_level != 'admin' && $event->user_level != 'god') { continue; } } } if ($event->vote_value >= 0) { if ($_REQUEST['novote']) { continue; } if ($link->get_a_status() == 'published' && $_REQUEST['nopubvotes']) { continue; } } else { if ($_REQUEST['noproblem']) { continue; } } $uid = $event->vote_user_id; if ($event->vote_user_id > 0) { $user = $event->user_login; } else { $user = preg_replace('/(\\.[0-9]+|){2}$|(:[0-9a-f]*){4}$/i', '', $event->vote_ip) . '…'; } if ($event->vote_value >= 0) { $type = 'vote'; $who = $user; } else { $type = 'problem'; $who = get_negative_vote($event->vote_value); // Show user_login if she voted more than N negatives in one minute if ($current_user->user_id > 0 && $current_user->admin) { $negatives_last_minute = $db->get_var("select count(*) from votes where vote_type='links' and vote_user_id={$event->vote_user_id} and vote_date > date_sub(now(), interval 30 second) and vote_value < 0"); if ($negatives_last_minute > 2) { $who .= "<br>({$user})"; } } } $json['status'] = get_status($link->get_a_status()); $json['sub_name'] = $link->sub_name; $json['type'] = $type; $json['ts'] = $event->timestamp; $json['votes'] = $link->total_votes; $json['com'] = $link->comments; $json['link'] = $link->get_relative_permalink(); $json['title'] = $link->title; $json['who'] = $who; $json['uid'] = $event->vote_user_id; $json['id'] = $link->id; if ($event->vote_user_id > 0) { $json['icon'] = get_avatar_url($event->vote_user_id, -1, 20); } $key = $event->timestamp . ':votes:' . $event->vote_id; $events[$key] = $json; if ($event->timestamp > $last_timestamp) { $last_timestamp = $event->timestamp; } } }