header("Status: 404 Not Found"); die; } $size = intval($_GET['size']); if (!$size > 0) { $size = 80; } $time = $db->get_var("select user_avatar from users where user_id={$id}"); if (!$time > 0) { header('HTTP/1.1 302 Moved'); header('Location: ' . get_no_avatar_url($size)); die; } // If the time given in the URL is wrong, redirect to the right one if (isset($_GET['time']) && $_GET['time'] != $time) { header('HTTP/1.1 301 Moved'); header('Location: ' . get_avatar_url($id, $time, $size)); die; } if (!($img = avatar_get_from_file($id, $size, $time))) { //syslog(LOG_INFO, "Meneame, creating avatar for user $id size $size time $time"); $img = avatar_get_from_db($id, $size); } if ($img) { header('HTTP/1.1 200 OK'); header("Content-type: image/jpeg"); echo $img; } else { header('HTTP/1.1 307 Image not found'); header('Location: ' . get_no_avatar_url($size)); }
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>'; }
// Show logs echo '<div class="voters" id="voters">'; echo '<fieldset><legend>'._('registro de eventos de la noticia').'</legend>'; echo '<div id="voters-container">'; $logs = $db->get_results("select logs.*, UNIX_TIMESTAMP(logs.log_date) as ts, user_id, user_login, user_level, user_avatar from logs, users where log_type in ('link_new', 'link_publish', 'link_discard', 'link_edit', 'link_geo_edit', 'link_depublished') and log_ref_id=$link->id and user_id= log_user_id order by log_date desc"); if ($logs) { foreach ($logs as $log) { echo '<div style="width:100%; display: block; clear: both; border-bottom: 1px solid #FFE2C5;">'; echo '<div style="width:30%; float: left;padding: 4px 0 4px 0;">'.get_date_time($log->ts).'</div>'; echo '<div style="width:24%; float: left;padding: 4px 0 4px 0;"><strong>'.$log->log_type.'</strong></div>'; echo '<div style="width:45%; float: left;padding: 4px 0 4px 0;">'; if ($link->author != $log->user_id && ($log->user_level == 'admin' || $log->user_level == 'god')) { // It was edited by an admin echo '<img src="'.get_no_avatar_url(20).'" width="20" height="20" alt="'.$log->user_login.'"/> '; echo ('admin'); if ($current_user->admin) { echo ' ('.$log->user_login.')'; } } else { echo '<a href="'.get_user_uri($log->user_login).'" title="'.$log->date.'">'; echo '<img src="'.get_avatar_url($log->log_user_id, $log->user_avatar, 20).'" width="20" height="20" alt="'.$log->user_login.'"/> '; echo $log->user_login; echo '</a>'; } echo '</div>'; echo '</div>'; } } else {
$q = mb_strtolower(trim($_GET['q'])); } if (!$q) { return; } $q = $db->escape($q); if (isset($_GET['friends']) && $_GET['friends']) { if (!$current_user->user_id) { return; } $from = "users, friends"; $where = "friend_type = 'manual' and friend_to = {$current_user->user_id} and friend_value > 0 and user_id = friend_from and user_login like '{$q}%'"; } else { $from = "users"; $where = "user_login like '{$q}%'"; } $users = $db->get_results("select user_id, user_login, user_avatar from {$from} where {$where} order by user_login asc limit 20"); if ($users) { foreach ($users as $user) { if (isset($_GET['avatar']) && $_GET['avatar']) { if ($user->user_avatar > 0) { $avatar = get_avatar_url($user->user_id, $user->user_avatar, 20); } else { $avatar = get_no_avatar_url(20); } } else { $avatar = $user->user_avatar; } echo mb_strtolower($user->user_login) . '|' . $avatar . "\n"; } }
function get_avatar_url($user, $avatar, $size) { global $globals; if ($avatar > 0 && !empty($globals['avatars_dir'])) { $file = $globals['avatars_dir'] . '/' . intval($user / $globals['avatars_files_per_dir']) . '/' . $user . "-{$size}.jpg"; $file_path = mnmpath . '/' . $file; if (is_readable($file_path)) { return $globals['base_url'] . $file; } else { return $globals['base_url'] . "backend/get_avatar.php?id={$user}&size={$size}"; } } return get_no_avatar_url($size); }
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_avatar_url($user, $avatar, $size) { global $globals, $db; // If it does not get avatar status, check the database if ($user > 0 && $avatar < 0) { $avatar = (int) $db->get_var("select user_avatar from users where user_id = {$user}"); } if ($avatar > 0 && $globals['cache_dir']) { $file = $globals['cache_dir'] . '/avatars/' . intval($user / $globals['avatars_files_per_dir']) . '/' . $user . "-{$size}.jpg"; // Don't check every time, but 1/10, decrease VM pressure // Disabled for the moment, it fails just too much for size 40 //if (rand(0, 10) < 10) return $globals['base_url'] . $file; $file_path = mnmpath . '/' . $file; if (is_readable($file_path)) { return $globals['base_url'] . $file; } else { return $globals['base_url'] . "backend/get_avatar.php?id={$user}&size={$size}"; } } return get_no_avatar_url($size); }
function get_avatar_url($user, $avatar, $size) { global $globals, $db; // If it does not get avatar status, check the database if ($user > 0 && $avatar < 0) { $avatar = (int) $db->get_var("select user_avatar from users where user_id = $user"); } if ($avatar > 0) { if ($globals['Amazon_S3_media_url'] && !$globals['Amazon_S3_local_cache']) { return $globals['Amazon_S3_media_url']."/avatars/$user-$avatar-$size.jpg"; } elseif ($globals['cache_dir']) { $file = $globals['cache_dir'].'/'.get_cache_dir_chain($user). "/$user-$avatar-$size.jpg"; // Don't check every time, but 1/10, decrease VM pressure // Disabled for the moment, it fails just too much for size 40 //if (rand(0, 10) < 10) return $globals['base_url'] . $file; $file_path = mnmpath.'/'.$file; if ($globals['avatars_check_always']) { if (is_readable($file_path)) { return $globals['base_static'] . $file; } else { return $globals['base_url'] . "backend/get_avatar.php?id=$user&size=$size&time=$avatar"; } } else { return $globals['base_static'] . $file; } } } return get_no_avatar_url($size); }