Example #1
0
    if ($globals['bot']) {
        not_found();
    }
} else {
    //Only shows ads in non discarded images
    $globals['ads'] = true;
}
/*
if ($globals['bot'] && $link->is_discarded()) not_found();
if (! $link->is_discarded()) $globals['ads'] = true;;
*/
// Check for a page number which has to come to the end, i.e. ?id=xxx/P or /story/uri/P
if (count($url_args) > 1 && ($last_arg = $url_args[count($url_args) - 1]) > 0) {
    if (preg_match('/^000/', $last_arg)) {
        // Dirty trick to redirect to a comment' page
        header('Location: ' . $link->get_permalink() . get_comment_page_suffix($globals['comments_page_size'], (int) $last_arg, $link->comments) . '#comment-' . (int) $last_arg);
        die;
    }
    $current_page = (int) $last_arg;
    array_pop($url_args);
}
switch ($url_args[1]) {
    case '':
        $tab_option = 1;
        $order_field = 'comment_order';
        // Geo check
        if ($globals['google_maps_api']) {
            $link->geo = true;
            $link->latlng = $link->get_latlng();
            if ($link->latlng) {
                geo_init('geo_coder_load', $link->latlng, 5, $link->status);
Example #2
0
function do_best_comments()
{
    global $db, $globals, $dblang;
    $foo_link = new Link();
    if (memcache_mprint('best_comments')) {
        return;
    }
    $min_date = date("Y-m-d H:i:00", $globals['now'] - 22000);
    // about 6 hours
    $res = $db->get_results("select comment_id, comment_order, user_login, link_id, link_uri, link_title, link_comments from comments, links, users  where comment_date > '{$min_date}' and comment_karma > 10 and comment_link_id = link_id and comment_user_id = user_id order by comment_karma desc limit 12");
    if ($res) {
        $output = '<div class="vertical-box">';
        $output .= '<h4><a href="' . $globals['base_url'] . 'topcomments.php">' . _('mejores comentarios') . '</a></h4><ul>' . "\n";
        foreach ($res as $comment) {
            $foo_link->uri = $comment->link_uri;
            $link = $foo_link->get_relative_permalink() . get_comment_page_suffix($globals['comments_page_size'], $comment->comment_order, $comment->link_comments) . '#comment-' . $comment->comment_order;
            $output .= '<li>' . $comment->user_login . ' ' . _('en') . ' <a  onmouseout="tooltip.clear(event);"  onclick="tooltip.clear(this);" onmouseover="return tooltip.ajax_delayed(event, \'get_comment_tooltip.php\', \'' . $comment->comment_id . '\', 10000);" href="' . $link . '">' . $comment->link_title . '</a></li>' . "\n";
        }
        $output .= '</ul></div>';
        echo $output;
        memcache_madd('best_comments', $output, 300);
    }
}
Example #3
0
 function print_summary($link, $length = 0, $single_link = true)
 {
     global $current_user, $globals;
     if (!$this->read) {
         return;
     }
     echo '<li id="ccontainer-' . $this->id . '">';
     $this->hidden = $this->karma < -80 || $this->user_level == 'disabled' && $this->type != 'admin';
     if ($this->hidden) {
         $comment_meta_class = 'comment-meta-hidden';
         $comment_class = 'comment-body-hidden';
     } else {
         $comment_meta_class = 'comment-meta';
         $comment_class = 'comment-body';
         if ($this->karma > 80) {
             $comment_class .= ' high';
         }
     }
     $this->link_permalink = $link->get_relative_permalink();
     echo '<div class="' . $comment_class . '">';
     echo '<a href="' . $this->link_permalink . get_comment_page_suffix($globals['comments_page_size'], $this->order, $globals['link']->comments) . '#comment-' . $this->order . '"><strong>#' . $this->order . '</strong></a>';
     if ($single_link) {
         echo '<span id="comment-' . $this->order . '">';
     }
     echo '&nbsp;&nbsp;&nbsp;<span  id="cid-' . $this->id . '">';
     if ($this->hidden && ($current_user->user_comment_pref & 1) == 0) {
         echo '&#187;&nbsp;<a href="javascript:get_votes(\'get_comment.php\',\'comment\',\'cid-' . $this->id . '\',0,' . $this->id . ')" title="' . _('ver comentario') . '">' . _('ver comentario') . '</a>';
     } else {
         $this->print_text($length, $single_link);
     }
     if ($single_link) {
         echo '</span>';
     }
     echo '</span></div>';
     // The comments info bar
     echo '<div class="' . $comment_meta_class . '">';
     // Check that the user can vote
     if ($this->type != 'admin' && $this->user_level != 'disabled') {
         // Print the votes info (left)
         echo '<div class="comment-votes-info">';
         if ($current_user->user_id > 0 && $this->author != $current_user->user_id && $single_link) {
             $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 '&nbsp;&nbsp;<a href="javascript:modal_from_ajax(\'' . $globals['base_url'] . 'backend/get_c_v.php?id=' . $this->id . '\')">';
             echo '<img src="' . $globals['base_url'] . 'img/common/vote-info01.png" width="12" height="12" alt="+ info" title="' . _('¿quién ha votado?') . '"/>';
             echo '</a>';
         }
         echo '</div>';
     }
     // Print comment info (right)
     echo '<div class="comment-info">';
     echo _('por') . ' ';
     if ($this->type == 'admin') {
         echo '<strong>' . get_server_name() . '</strong> ';
         if ($current_user->user_level == 'god' || $current_user->user_level == 'admin') {
             echo ' (' . $this->username . ') ';
         }
     } elseif ($single_link) {
         echo '<a href="' . get_user_uri($this->username) . '" title="karma:&nbsp;' . $this->user_karma . '" id="cauthor-' . $this->order . '">' . $this->username . '</a> ';
     } else {
         echo '<a href="' . get_user_uri($this->username) . '" title="karma:&nbsp;' . $this->user_karma . '">' . $this->username . '</a> ';
     }
     // Print dates
     if ($globals['now'] - $this->date > 604800) {
         // 7 days
         echo _('el') . get_date_time($this->date);
     } else {
         echo _('hace') . ' ' . txt_time_diff($this->date);
     }
     if (!$this->hidden && $this->type != 'admin') {
         echo '<img src="' . get_avatar_url($this->author, $this->avatar, 20) . '" width="20" height="20" alt="' . $this->username . '" title="' . $this->username . ',&nbsp;karma:&nbsp;' . $this->user_karma . '" />';
     }
     echo '</div></div>';
     echo "</li>\n";
 }
Example #4
0
 function print_summary($type = 'full', $karma_best_comment = 0)
 {
     global $current_user, $current_user, $globals, $db;
     if (!$this->read) {
         return;
     }
     if ($this->is_votable()) {
         $this->voted = $this->vote_exists($current_user->user_id);
         if (!$this->voted) {
             $this->md5 = md5($current_user->user_id . $this->id . $this->randkey . $globals['user_ip']);
         }
     }
     $url = htmlspecialchars($this->url);
     echo '<div class="news-summary">';
     echo '<div class="news-body">';
     if ($type != 'preview' && !empty($this->title) && !empty($this->content)) {
         $this->print_shake_box($votes_enabled);
     }
     $this->print_warn();
     //if($globals['external_ads']) echo "<!-- google_ad_section_start -->\n";
     if ($this->status != 'published') {
         $nofollow = ' rel="nofollow"';
     } else {
         $nofollow = '';
     }
     echo '<h1>';
     echo '<a href="' . $url . '"' . $nofollow . '>' . $this->title . '</a>';
     // Content type (for video and images)
     if ($this->content_type == 'image') {
         echo '&nbsp;<img src="' . $globals['base_url'] . 'img/common/is-photo01.png" class="media-icon" width="18" height="15" alt="' . _('imagen') . '" title="' . _('imagen') . '" />';
     } elseif ($this->content_type == 'video') {
         echo '&nbsp;<img src="' . $globals['base_url'] . 'img/common/is-video01.png" class="media-icon" width="18" height="15" alt="' . _('vídeo') . '" title="' . _('vídeo') . '" />';
     }
     echo '</h1>';
     if (!$globals['bot']) {
         // GEO
         if ($this->latlng) {
             echo '<div class="thumbnail" id="map" style="width:130px;height:130px">&nbsp;</div>' . "\n";
         } elseif ($type == 'full' && $globals['do_websnapr'] && $this->votes_enabled && $globals['link_id'] > 0 && !empty($this->url_title)) {
             // Websnapr
             // In order not to overload websnapr, display the image only if votes are enabled
             echo '<img class="news-websnapr" alt="websnapr.com" src="http://images.websnapr.com/?size=T&amp;url=' . $url . '" width="92" height="70"  onmouseover="return tooltip.ajax_delayed(event, \'get_link_snap.php\', ' . $this->id . ');" onmouseout="tooltip.clear(event);" onclick="tooltip.clear(this);"/>';
         }
         echo '<div class="news-submitted">';
         if ($type != 'short') {
             echo '<a href="' . get_user_uri($this->username) . '"><img src="' . get_avatar_url($this->author, $this->avatar, 25) . '" width="25" height="25" alt="' . $this->username . '" onmouseover="return tooltip.ajax_delayed(event, \'get_user_info.php\', ' . $this->author . ');" onmouseout="tooltip.clear(event);" /></a>';
         }
         echo '<strong>' . htmlentities(preg_replace('/^https*:\\/\\//', '', txt_shorter($this->url))) . '</strong>' . "<br />\n";
         echo _('por') . ' <a href="' . get_user_uri($this->username, 'history') . '">' . $this->username . '</a> ';
         // Print dates
         if ($globals['now'] - $this->date > 604800) {
             // 7 days
             echo _('el') . get_date_time($this->sent_date);
             if ($this->status == 'published') {
                 echo ', ' . _('publicado el') . get_date_time($this->date);
             }
         } else {
             echo _('hace') . txt_time_diff($this->sent_date);
             if ($this->status == 'published') {
                 echo ', ' . _('publicado hace') . txt_time_diff($this->date);
             }
         }
         echo "</div>\n";
     }
     if ($type == 'full' || $type == 'preview') {
         echo '<p>' . text_to_html($this->content);
         if ($type != 'preview') {
             if ($this->is_editable()) {
                 echo '&nbsp;&nbsp;<a href="' . $globals['base_url'] . 'editlink.php?id=' . $this->id . '&amp;user='******'" title="' . _('editar noticia') . ' #' . $this->id . '"><img src="' . $globals['base_url'] . 'img/common/edit-misc01.png" alt="edit"/></a>';
             }
             if ($this->geo && $this->is_map_editable()) {
                 echo '&nbsp;&nbsp;<a href="#" onclick="$(\'#geoedit\').load(\'' . $globals['base_url'] . "geo/get_form.php?id={$this->id}&amp;type=link&amp;icon={$this->status}" . '\'); return false;"><img src="' . $globals['base_url'] . 'img/common/edit-geo01.png" alt="edit" title="' . _('editar geolocalización') . '"/></a>';
             }
         }
         echo '</p>';
     }
     // Print a summary of the best comment
     if ($karma_best_comment > 0 && ($best_comment = $db->get_row("select comment_id, comment_order, comment_content from comments where comment_link_id = {$this->id} and comment_karma > {$karma_best_comment} order by comment_karma desc limit 1"))) {
         echo '<div style="font-size: 80%; border: 1px solid; border-color: #dadada; background: #fafafa; margin: 7px 50px 7px 25px; padding: 4px; overflow:hidden">';
         $link = $this->get_permalink() . get_comment_page_suffix($globals['comments_page_size'], $best_comment->comment_order, $this->comments) . '#comment-' . $best_comment->comment_order;
         echo '<a onmouseout="tooltip.clear(event);"  onclick="tooltip.clear(this);" onmouseover="return tooltip.ajax_delayed(event, \'get_comment_tooltip.php\', \'' . $best_comment->comment_id . '\', 10000);" href="' . $link . '"><strong>' . $best_comment->comment_order . '</strong></a>';
         echo ':&nbsp;' . text_to_summary($best_comment->comment_content, 200) . '</div>';
     }
     echo '<div class="news-details">';
     if ($this->comments > 0) {
         $comments_mess = $this->comments . ' ' . _('comentarios');
     } else {
         $comments_mess = _('sin comentarios');
     }
     echo '<span class="comments">&nbsp;<a href="' . $this->get_relative_permalink() . '">' . $comments_mess . '</a></span>';
     // If the user is authenticated, show favorite box
     if ($current_user->user_id > 0) {
         echo '<span class="tool"><a id="fav-' . $this->id . '" href="javascript:get_votes(\'get_favorite.php\',\'' . $current_user->user_id . '\',\'fav-' . $this->id . '\',0,\'' . $this->id . '\')">' . favorite_teaser($current_user->user_id, $this->id) . '</a></span>';
     }
     // Print meta and category
     echo ' <span class="tool">' . _('en') . ': ';
     echo '<a href="' . $globals['base_url'] . '?meta=' . $this->meta_uri . '" title="' . _('meta') . '">' . $this->meta_name . '</a>, ';
     echo '<a href="' . $globals['base_url'] . '?meta=' . $this->meta_uri . '&amp;category=' . $this->category . '" title="' . _('categoría') . '">' . $this->category_name . '</a>';
     echo '</span>';
     echo ' <span class="tool">karma: <span id="a-karma-' . $this->id . '">' . intval($this->karma) . '</span></span>';
     if (!$this->voted && $this->negatives_allowed() && $type != 'preview' && $this->votes_enabled) {
         $this->print_problem_form();
     }
     echo '</div>' . "\n";
     // End news details
     // Displayed only in a story page
     if ($globals['link']) {
         if (!empty($this->tags)) {
             echo '<div class="news-details">';
             echo '<strong>' . _('etiquetas') . '</strong>:';
             $tags_array = explode(",", $this->tags);
             $tags_counter = 0;
             foreach ($tags_array as $tag_item) {
                 $tag_item = trim($tag_item);
                 $tag_url = urlencode($tag_item);
                 if ($tags_counter > 0) {
                     echo ',';
                 }
                 if ($globals['base_search_url']) {
                     echo ' <a href="' . $globals['base_url'] . $globals['base_search_url'] . 'tag:';
                 } else {
                     echo ' <a href="' . $globals['base_url'] . 'search.php?p=tag&amp;q=';
                 }
                 echo $tag_url . '">' . $tag_item . '</a>';
                 $tags_counter++;
             }
             echo '</div>' . "\n";
         }
         echo '<div class="news-details">';
         echo '<strong>' . _('votos negativos') . '</strong>: <span id="a-neg-' . $this->id . '">' . $this->negatives . '</span>&nbsp;&nbsp;';
         echo '<strong>' . _('usuarios') . '</strong>: ' . $this->votes . '&nbsp;&nbsp;';
         echo '<strong>' . _('anónimos') . '</strong>: ' . $this->anonymous . '&nbsp;&nbsp;';
         echo '</div>' . "\n";
     } else {
         echo "<!--tags: {$this->tags}-->\n";
     }
     //if($globals['external_ads']) echo "<!-- google_ad_section_end -->\n";
     echo '</div>' . "\n";
     echo '</div>' . "\n";
     // Geo edit form div
     if ($this->geo && $this->is_map_editable()) {
         echo '<div id="geoedit" class="geoform" style="margin-left:20px">';
         if ($current_user->user_id == $this->author && !$this->latlng) {
             geo_coder_print_form('link', $this->id, $globals['latlng'], _('ubica al origen de la noticia o evento (ciudad, país)'));
         }
         echo '</div>' . "\n";
     }
 }
Example #5
0
function get_comment($time, $type, $commentid, $userid)
{
    global $db, $events, $last_timestamp, $foo_link, $max_items, $globals;
    $event = $db->get_row("select user_login, comment_user_id, comment_type, comment_order, link_id, link_title, link_uri, link_status, link_date, link_votes, link_anonymous, link_comments from comments, links, users where comment_id = {$commentid} and link_id = comment_link_id and user_id={$userid}");
    if (!$event) {
        return;
    }
    $foo_link->id = $event->link_id;
    $foo_link->uri = $event->link_uri;
    $json['link'] = $foo_link->get_relative_permalink() . get_comment_page_suffix($globals['comments_page_size'], $event->comment_order, $event->link_comments) . "#comment-{$event->comment_order}";
    $json['id'] = $commentid;
    $json['status'] = get_status($event->link_status);
    $json['ts'] = $time;
    $json['type'] = $type;
    $json['votes'] = $event->link_votes + $event->link_anonymous;
    $json['com'] = $event->link_comments;
    $json['title'] = addslashes($event->link_title);
    if ($event->comment_type == 'admin') {
        $json['who'] = get_server_name();
        $userid = 0;
    } else {
        $json['who'] = addslashes($event->user_login);
    }
    $json['uid'] = $userid;
    if ($userid > 0) {
        $json['icon'] = get_avatar_url($userid, -1, 20);
    }
    $key = $time . ':' . $type . ':' . $commentid;
    $events[$key] = json_encode_single($json);
    if ($time > $last_timestamp) {
        $last_timestamp = $time;
    }
}