. // 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'); include(mnminclude.'link.php'); include(mnminclude.'html1.php'); $globals['ads'] = true; $link = new Link; if (!defined($_REQUEST['id']) && !empty($_SERVER['PATH_INFO'])) { $url_args = preg_split('/\/+/', $_SERVER['PATH_INFO']); array_shift($url_args); // The first element is always a "/" $link->uri = $db->escape($url_args[0]); if (! $link->read('uri') ) { not_found(); } } else { $url_args = preg_split('/\/+/', $_REQUEST['id']); $link->id=intval($url_args[0]); if(is_numeric($url_args[0]) && $link->read('id') ) { // Redirect to the right URL if the link has a "semantic" uri if (!empty($link->uri) && !empty($globals['base_story_url'])) { if (!empty($url_args[1])) $extra_url = '/' . $url_args[1]; header('Location: ' . $link->get_permalink(). $extra_url); die; } } else { not_found(); } } // 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); } elseif ($link->is_map_editable()) { geo_init(null, null); } } if ($globals['comments_page_size'] && $link->comments > $globals['comments_page_size']*$globals['comments_page_threshold']) { if (!$current_page) $current_page = ceil($link->comments/$globals['comments_page_size']); $offset=($current_page-1)*$globals['comments_page_size']; $limit = "LIMIT $offset,".$globals['comments_page_size']; } break; case 'best-comments': $tab_option = 2; if ($globals['comments_page_size'] > 0 ) $limit = 'LIMIT ' . $globals['comments_page_size']; $order_field = 'comment_karma desc, comment_id asc'; break; case 'voters': $tab_option = 3; break; case 'log': $tab_option = 4; break; case 'sneak': $tab_option = 5; break; case 'favorites': $tab_option = 6; break; case 'trackbacks': $tab_option = 7; break; default: not_found(); } // Set globals $globals['link']=$link; $globals['link_id']=$link->id; $globals['category_id']=$link->category; $globals['category_name']=$link->category_name; $globals['link_permalink'] = $globals['link']->get_permalink(); // to avoid penalisation if ($tab_option != 1 || $link->status == 'discard') { $globals['noindex'] = true; } if ($_POST['process']=='newcomment') { insert_comment(); } do_modified_headers($link->modified, $current_user->user_id.'-'.$globals['link_id'].'-'.$link->comments.'-'.$link->modified); // Enable user AdSense // do_user_ad: 0 = noad, > 0: probability n/100 if ($link->status == 'published' && $link->user_karma > 7 && !empty($link->user_adcode)) { $globals['do_user_ad'] = $link->user_karma * 2; $globals['user_adcode'] = $link->user_adcode; $globals['user_adchannel'] = $user->adchannel; } if ($link->status != 'published') $globals['do_vote_queue']=true; if (!empty($link->tags)) $globals['tags']=$link->tags; do_header($link->title, 'post'); do_banner_top(); echo '
'."\n"; do_sidebar(false); echo '
'; do_tabs("main",_('noticia'), true); $link->print_summary(); switch ($tab_option) { case 1: case 2: echo '
'; // AdSense do_banner_story(); // Print tabs print_story_tabs($tab_option); // If option is "normal comments", show also last trackbakcs and pingbacks if ($tab_option == 1) { $trackbacks = $db->get_col("SELECT trackback_id FROM trackbacks WHERE trackback_link_id=$link->id AND trackback_type='in' and trackback_status = 'ok' ORDER BY trackback_date DESC limit 10"); if ($trackbacks) { echo '
'._('últimas relacionadas').''; echo '
    '; require_once(mnminclude.'trackback.php'); $trackback = new Trackback; foreach($trackbacks as $trackback_id) { $trackback->id=$trackback_id; $trackback->read(); echo '
  • '.$trackback->title.' ['.preg_replace('/https*:\/\/([^\/]+).*/', "$1", $trackback->url).']
  • ' . "\n"; } echo '
'; echo '
'; } } $comments = $db->get_col("SELECT comment_id FROM comments WHERE comment_link_id=$link->id ORDER BY $order_field $limit"); if ($comments) { echo '
    '; require_once(mnminclude.'comment.php'); $comment = new Comment; foreach($comments as $comment_id) { $comment->id=$comment_id; $comment->read(); $comment->print_summary($link, 700, true); echo "\n"; } echo "
\n"; } if($link->date < $globals['now']-$globals['time_enabled_comments']) { // Comments already closed if($tab_option == 1) do_comment_pages($link->comments, $current_page); echo '
'."\n"; echo _('comentarios cerrados')."\n"; echo '
'."\n"; } elseif ($current_user->authenticated && ($current_user->user_karma > $globals['min_karma_for_comments'] || $current_user->user_id == $link->author)) { // User can comment print_comment_form(); if($tab_option == 1) do_comment_pages($link->comments, $current_page); } else { // Noit enough karma or anonymous user if($tab_option == 1) do_comment_pages($link->comments, $current_page); echo '
'."\n"; if ($current_user->authenticated && $current_user->user_karma <= $globals['min_karma_for_comments']) echo _('No tienes el mínimo karma requerido')." (" . $globals['min_karma_for_comments'] . ") ". _('para comentar'). ": ".$current_user->user_karma ."\n"; else echo ''._('Autentifícate si deseas escribir').' '._('comentarios').'. '._('O regístrate'). ' aquí.'."\n"; echo '
'."\n"; } echo '
' . "\n"; break; case 3: // Show voters echo '
'; // AdSense do_banner_story(); print_story_tabs($tab_option); echo '
'; echo '
'; if ($globals['link']->date < $globals['now'] - 7776000) { // older than 90 days echo _('Noticia antigua, datos de votos archivados'); } else { include(mnmpath.'/backend/meneos.php'); } echo '

'; echo '
'; echo '
'; break; case 6: // Show favorited by echo '
'; // AdSense do_banner_story(); print_story_tabs($tab_option); echo '
'; echo '
'; include(mnmpath.'/backend/get_link_favorites.php'); echo '

'; echo '
'; echo '
'; break; case 4: // Show logs echo '
'; // AdSense do_banner_story(); print_story_tabs($tab_option); echo '
'._('registro de eventos de la noticia').''; echo '
'; $logs = $db->get_results("select logs.*, user_id, user_login, user_avatar from logs, users where log_type in ('link_new', 'link_publish', 'link_discard', 'link_edit', 'link_geo_edit') and log_ref_id=$link->id and user_id= log_user_id order by log_date asc"); if ($logs) { //echo '
'; foreach ($logs as $log) { echo '
'; echo '
'.$log->log_date.'
'; echo '
'.$log->log_type.'
'; echo ''; echo '
'; } //echo '
'; } else { echo _('no hay registros'); } echo '

'; echo '
'; echo '
'; break; case 5: // Micro sneaker echo '
'; // AdSense do_banner_story(); print_story_tabs($tab_option); echo '
'; include(mnmpath.'/libs/link_sneak.php'); echo '
'; echo '
'; echo '' . "\n"; break; case 7: // Show trackback echo '
'; // AdSense do_banner_story(); print_story_tabs($tab_option); echo ''._('enlace trackback').' '._('dirección de trackback').'' . "\n"; echo '
'._('lugares que enlazan esta noticia').''; echo '
    '; $trackbacks = $db->get_col("SELECT trackback_id FROM trackbacks WHERE trackback_link_id=$link->id AND trackback_type='in' and trackback_status = 'ok' ORDER BY trackback_date DESC limit 50"); if ($trackbacks) { require_once(mnminclude.'trackback.php'); $trackback = new Trackback; foreach($trackbacks as $trackback_id) { $trackback->id=$trackback_id; $trackback->read(); echo '
  • '.$trackback->title.' ['.preg_replace('/https*:\/\/([^\/]+).*/', "$1", $trackback->url).']
  • ' . "\n"; } } echo '
  • '._('Technorati').'
  • ' . "\n"; echo '
  • '._('Google').'
  • ' . "\n"; echo '
  • '._('Ask.com').'
  • ' . "\n"; echo '
'; echo '
'; echo '
'; break; } // echo '
 
'; echo '
'; echo ''."\n"; $globals['tag_status'] = $globals['link']->status; do_footer(); function print_comment_form() { global $link, $current_user, $globals; if (!$link->votes > 0) return; echo '
'."\n"; echo '
'."\n"; echo '
'."\n"; echo ''._('envía un comentario').''."\n"; print_simpleformat_buttons('comment'); echo ''."\n"; echo '
'."\n"; echo ''."\n"; echo ''."\n"; echo ''."\n"; echo ''."\n"; echo ''."\n"; echo '
'."\n"; echo '
'."\n"; echo "
\n"; } function insert_comment () { global $link, $db, $current_user, $globals; require_once(mnminclude.'ban.php'); if(check_ban_proxy()) return; // Check if is a POST of a comment if($link->votes > 0 && $link->date > $globals['now']-$globals['time_enabled_comments'] && intval($_POST['link_id']) == $link->id && $current_user->authenticated && intval($_POST['user_id']) == $current_user->user_id && ($current_user->user_karma > $globals['min_karma_for_comments'] || $current_user->user_id == $link->author) && intval($_POST['randkey']) > 0 && mb_strlen(trim($_POST['comment_content'])) > 2 ) { require_once(mnminclude.'comment.php'); $comment = new Comment; $comment->link=$link->id; $comment->randkey=intval($_POST['randkey']); $comment->author=intval($_POST['user_id']); $comment->karma=intval($current_user->user_karma); $comment->content=clean_text($_POST['comment_content'], 0, false, 10000); if (mb_strlen($comment->content) > 0 && preg_match('/[a-zA-Z:-]/', $_POST['comment_content'])) { // Check there are at least a valid char $already_stored = intval($db->get_var("select count(*) from comments where comment_link_id = $comment->link and comment_user_id = $comment->author and comment_randkey = $comment->randkey")); // Check the comment wasn't already stored if (!$already_stored) { // Lower karma to comments' spammers $comment_count = (int) $db->get_var("select count(*) from comments where comment_user_id = $current_user->user_id and comment_date > date_sub(now(), interval 3 minute)"); // Check the text is not the same $same_count = $comment->same_text_count() + $comment->same_links_count(); if ($comment_count > 3 || $same_count > 2) { require_once(mnminclude.'user.php'); $reduction = 0; if ($comment_count > 3) { $reduction += ($comment_count-3) * 0.1; } if($same_count > 1) { $reduction += $same_count * 0.25; } $user = new User; $user->id = $current_user->user_id; $user->read(); $user->karma = $user->karma - $reduction; syslog(LOG_NOTICE, "Meneame: story decreasing $reduction of karma to $current_user->user_login (now $user->karma)"); $user->store(); } $comment->store(); $comment->insert_vote(); $link->update_comments(); // Re read link data $link->read(); } } // We don't redirect, Firefox show cache data instead of the new data since we send lastmodification time. //header('Location: '.$link->get_permalink()); //die; } } function print_story_tabs($option) { global $globals; $active = array(); $active[$option] = 'class="tabsub-this"'; echo ''."\n"; } function do_comment_pages($total, $current, $reverse = true) { global $db, $globals; if ( ! $globals['comments_page_size'] || $total <= $globals['comments_page_size']*$globals['comments_page_threshold']) return; $index_limit = 10; if ($globals['base_story_url'] = 'story/') { $query = $globals['link_permalink']; } else { $query=preg_replace('/\/[0-9]+(#.*)$/', '', $_SERVER['QUERY_STRING']); if(!empty($query)) { $query = htmlspecialchars($query); $query = "?$query"; } } $total_pages=ceil($total/$globals['comments_page_size']); if (! $current) { if ($reverse) $current = $total_pages; else $current = 1; } $start=max($current-intval($index_limit/2), 1); $end=$start+$index_limit-1; echo '
'; if($current==1) { echo '« '._('anterior'). ''; } else { $i = $current-1; echo '« '._('anterior').''; } for ($i=1;$i<=$total_pages;$i++) { if($i==$current) { echo ''.$i.''; } else { echo ''.$i.''; } } if($current<$total_pages) { $i = $current+1; echo '» '._('siguiente').''; } else { echo '» '._('siguiente'). ''; } echo "
\n"; } function get_comment_page_url($i, $total, $query) { global $globals; if ($i == $total) return $query; else return $query.'/'.$i; } ?>