function jaiku_post($text, $short_url) { global $globals; syslog(LOG_NOTICE, "Meneame: jaiku updater called, {$short_url}"); $url = "http://api.jaiku.com/json"; if (!function_exists('curl_init')) { syslog(LOG_NOTICE, "Meneame: curl is not installed"); return; } $postdata = "method=presence.send"; $postdata .= "&user="******"&personal_key=" . $globals['jaiku_key']; $postdata .= "&icon=337"; // Event $postdata .= "&message=" . urlencode(text_to_summary(html_entity_decode($text), 115) . ' ' . $short_url); $session = curl_init(); curl_setopt($session, CURLOPT_URL, $url); curl_setopt($session, CURLOPT_HEADER, false); curl_setopt($session, CURLOPT_USERAGENT, "meneame.net"); curl_setopt($session, CURLOPT_CONNECTTIMEOUT, 15); curl_setopt($session, CURLOPT_TIMEOUT, 20); curl_setopt($session, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($session, CURLOPT_RETURNTRANSFER, 1); curl_setopt($session, CURLOPT_POST, 1); curl_setopt($session, CURLOPT_POSTFIELDS, $postdata); $result = curl_exec($session); curl_close($session); }
function twitter_post($auth, $text, $short_url, $image = false) { global $globals; if (empty($auth['twitter_token']) || empty($auth['twitter_token_secret']) || empty($auth['twitter_consumer_key']) || empty($auth['twitter_consumer_secret'])) { return false; } if (!class_exists("OAuth")) { syslog(LOG_NOTICE, "Meneame: pecl/oauth is not installed"); return; } if (!$auth['twitter_consumer_key'] || !$auth['twitter_consumer_secret'] || !$auth['twitter_token'] || !$auth['twitter_token_secret']) { syslog(LOG_NOTICE, "Meneame: consumer_key, consumer_secret, token, or token_secret not defined"); return; } $req_url = 'https://api.twitter.com/oauth/request_token'; $acc_url = 'https://api.twitter.com/oauth/access_token'; $authurl = 'https://api.twitter.com/oauth/authorize'; $api_url = 'https://api.twitter.com/1.1/statuses/update.json'; $api_media_url = 'https://api.twitter.com/1.1/statuses/update_with_media.json'; $api_args = array("empty_param" => NULL); $maxlen = 140 - 24; // minus the url length if ($image) { $maxlen -= 24; echo "Adding image: {$image}\n"; $api_args['@media[]'] = '@' . $image; $url = $api_media_url; } else { $url = $api_url; } $msg = mb_substr(text_to_summary(html_entity_decode($text), $maxlen), 0, $maxlen); $msg_full = $msg . ' ' . $short_url; $api_args["status"] = $msg_full; $oauth = new OAuth($auth['twitter_consumer_key'], $auth['twitter_consumer_secret'], OAUTH_SIG_METHOD_HMACSHA1, OAUTH_AUTH_TYPE_URI); $oauth->debug = 1; $oauth->setRequestEngine(OAUTH_REQENGINE_CURL); // For posting images $oauth->setToken($auth['twitter_token'], $auth['twitter_token_secret']); try { $oauth->fetch($url, $api_args, OAUTH_HTTP_METHOD_POST, array("User-Agent" => "pecl/oauth")); } catch (Exception $e) { syslog(LOG_INFO, 'Menéame, Twitter caught exception: ' . $e->getMessage() . " in " . basename(__FILE__) . "\n"); echo "Twitter post failed: {$msg} " . mb_strlen($msg) . "\n"; return false; } // $response_info = $oauth->getLastResponseInfo(); // echo $oauth->getLastResponse() . "\n"; return true; }
function print_summary($length = 0) { global $current_user, $globals; if ($current_user->user_id != $this->author && $current_user->user_id != $this->to) { return; } // Security check $post_meta_class = 'comment-meta'; $post_class = 'comment-body'; if ($this->date_read < $this->date) { $post_class .= ' new'; } if ($length > 0) { $this->content = text_to_summary($this->content, $length); } $this->content = $this->to_html($this->content) . $expand; $vars = compact('post_meta_class', 'post_class', 'length'); /* reference $this to use in the template */ $vars['self'] = $this; return Haanga::Load('priv_summary.html', $vars); }
function print_summary($type='full', $karma_best_comment = 0, $show_tags = true) { 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); $this->permalink = $this->get_permalink(); echo '<div class="news-summary">'; echo '<div class="news-body">'; if ($type != 'preview' && $this->title && $this->content && ($this->votes > 0 || $current_user->user_id == $this->author) ) { $this->print_shake_box(); } $this->print_warn(); if ($this->status != 'published') $nofollow = ' rel="nofollow"'; else $nofollow = ''; if($globals['ads']) echo "<!-- google_ad_section_start -->\n"; echo '<h1>'; echo '<a href="'.$url.'"'.$nofollow.'>'. $this->title. '</a>'; // Content type (for video and images) if ($this->content_type == 'image') { echo ' <img src="'.$globals['base_static'].'img/common/is-photo01.png" class="media-icon" width="18" height="15" alt="'._('imagen').'" title="'._('imagen').'" />'; } elseif ($this->content_type == 'video') { echo ' <img src="'.$globals['base_static'].'img/common/is-video01.png" class="media-icon" width="18" height="15" alt="'._('vídeo').'" title="'._('vídeo').'" />'; } echo '</h1> '; 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="" 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"; // Allow to invert user in japanese translations printf (_('por %s'), ' <a href="'.get_user_uri($this->username, 'history').'">'.$this->username.'</a> '); // Print dates if ($globals['now'] - $this->date > 604800 || empty($_SERVER['HTTP_USER_AGENT'])) { // 7 days or user agent is empty 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') { if (($src = $this->has_thumb())) { echo "<img src='$src' width='$this->thumb_x' height='$this->thumb_y' alt='' class='thumbnail'/>"; } echo '<p>'; echo text_to_html($this->content, 'links'); if ($globals['link'] && $type != 'preview' ) { if ($this->is_editable()) { echo ' <a href="'.$globals['base_url'].'editlink.php?id='.$this->id.'&user='******'" title="'._('editar noticia').' #'.$this->id.'"><img class="mini-icon-text" src="'.$globals['base_static'].'img/common/edit-misc01.png" alt="edit" width="18" height="12"/></a>'; } if ($this->geo && $this->is_map_editable()) { echo ' <a href="#" onclick="$(\'#geoedit\').load(\''.$globals['base_url']."geo/get_form.php?id=$this->id&type=link&icon=$this->status".'\'); return false;"><img class="mini-icon-text" src="'.$globals['base_static'].'img/common/edit-geo01.png" alt="edit" title="'._('editar geolocalización').'"/></a>'; } } echo '</p>'; } if ($this->start_date && (!$this->end_date || ($this->start_date==$this->end_date))) { echo '<div>'; echo _('Data:').' <strong>'.Link::format_date($this->start_date).'</strong>'; echo '</div>'; } elseif ($this->start_date && $this->end_date) { echo '<div>'; echo _('Do').' <strong>'.Link::format_date($this->start_date).'</strong> '._('ata o').' <strong>'.Link::format_date($this->end_date).'</strong>'; echo '</div>'; } // Print a summary of the best comment // with a least one vote and younger than a day if ($karma_best_comment > 0 && $this->comments > 0 && $this->comments < 50 && $globals['now'] - $this->date < 86400 && ($best_comment = $db->get_row("select SQL_CACHE comment_id, comment_order, substr(comment_content, 1, 225) as content from comments where comment_link_id = $this->id and comment_karma > $karma_best_comment and comment_votes > 0 order by comment_karma desc limit 1"))) { echo '<div class="box" style="font-size: 80%; border: 1px solid; border-color: #dadada; background: #fafafa; margin: 7px 50px 7px 25px; padding: 4px; overflow:hidden">'; $link = $this->permalink.'/000'.$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 ': '.text_to_summary($best_comment->content, 200).'</div>'; } if ($this->do_inline_friend_votes) $this->inline_friend_votes(); echo '<div class="news-details main">'; if($this->comments > 0) { $comments_mess = $this->comments . ' ' . _('comentarios'); } else { $comments_mess = _('sin comentarios'); } echo '<span class="comments-counter"> <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).'</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.'&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->votes_enabled && $this->negatives_allowed($globals['link_id'] > 0) && $type != 'preview' /*&& $this->author != $current_user->user_id*/) { $this->print_problem_form(); } echo '</div>'."\n"; // End news details if($globals['ads']) echo "<!-- google_ad_section_end -->\n"; // Displayed only in a story page // and tags in sent/voted listing if ($globals['link'] || $type == 'short') { if ($show_tags && !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&q='; } echo $tag_url.'">'.$tag_item.'</a>'; $tags_counter++; } echo '</div>'."\n"; } if ($type != 'short') { echo '<div class="news-details">'; echo '<strong>'._('negativos').'</strong>: <span id="a-neg-'.$this->id.'">'.$this->negatives.'</span> '; echo '<strong>'._('usuarios').'</strong>: <span id="a-usu-'.$this->id.'">'.$this->votes.'</span> '; echo '<strong>'._('anónimos').'</strong>: <span id="a-ano-'.$this->id.'">'.$this->anonymous.'</span> '; echo '<span class="tool">'; echo '<strong>'.('orde').'</strong>: <select id="selectCommentOrder" >' .'<option value="kdate" '.(!$current_user->comment_options['korder']?'selected="selected"':'').'>'._('data').'</option>' .'<option value="korder" '.($current_user->comment_options['korder']?'selected="selected"':'').'>'._('karma').'</option>' .'</select> '; echo '</span>'; echo '<span class="tool">'; // Share icons $short_permalink = $this->get_short_permalink(); echo '<strong>'; echo '<a href="'.$short_permalink.'" title="'._('enlace corto').'">'._('compartir').'</a>'; echo '</strong>:'; print_share_icons($this->permalink, $short_permalink, $this->title); echo '</span>'; echo '</div>' . "\n"; } } // Include post text ads do_banner_story(); 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->sent_date > $globals['now'] - 600 && !$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"; } }
$url['most'] = "http://" . get_server_name() . "/story.php?id={$res->link_id}"; } $res = $db->get_row("select link_id, link_title, link_votes, link_anonymous from links where link_status = 'published' order by link_date desc limit 1"); if ($res) { $title['published'] = text_to_summary($res->link_title, 70) . ' <span style="font-size: 90%;">[' . ($res->link_votes + $res->link_anonymous) . " " . _('votos') . "]</span>"; $url['published'] = "http://" . get_server_name() . "/story.php?id={$res->link_id}"; } $res = $db->get_row("select link_id, link_title, link_votes, link_anonymous from links where link_status = 'queued' order by link_date desc limit 1"); if ($res) { $title['sent'] = text_to_summary($res->link_title, 70) . ' <span style="font-size: 90%;">[' . ($res->link_votes + $res->link_anonymous) . " " . _('votos') . "]</span>"; $url['sent'] = "http://" . get_server_name() . "/story.php?id={$res->link_id}"; } $last_comment = (int) $db->get_var("select comment_link_id from comments order by comment_id desc limit 1"); $res = $db->get_row("select link_id, link_title, link_votes, link_anonymous from links where link_id = {$last_comment}"); if ($res) { $title['commented'] = text_to_summary($res->link_title, 70) . ' <span style="font-size: 90%;">[' . ($res->link_votes + $res->link_anonymous) . " " . _('votos') . "]</span>"; $url['commented'] = "http://" . get_server_name() . "/story.php?id={$res->link_id}"; } switch ($format) { case 'vertical': $div1 = '<div style="padding: 1px 1px 1px 1px; height: 23%; width: 100%; ">'; $div2 = '<div style="padding: 1px 1px 1px 1px; height: 23%; width: 100%; border-top: 1px solid #' . $color_border . ';">'; $div3 = '<div style="padding: 1px 1px 1px 1px; height: 23%; width: 100%; border-top: 1px solid #' . $color_border . ';">'; $div4 = '<div style="padding: 1px 1px 1px 1px; height: 23%; width: 100%; border-top: 1px solid #' . $color_border . ';">'; $signature = _('Menéame'); break; case 'horizontal': default: $div1 = '<div style="position: absolute; left: 2px; top: 2px; width: 24%;">'; $div2 = '<div style="position: absolute; left: 25%; top: 2px; width: 24%;">'; $div3 = '<div style="position: absolute; left: 50%; top: 2px; width: 24%;">';
function print_text($length = 0, $html_id = false) { global $current_user, $globals; if (!$html_id) { $html_id = $this->id; } if (!$this->basic_summary && ($this->author == $current_user->user_id && $globals['now'] - $this->date < $globals['comment_edit_time'] || ($this->author != $current_user->user_id || $this->type == 'admin') && $current_user->user_level == 'god')) { // gods can always edit $expand = ' <a href="javascript:get_votes(\'comment_edit.php\',\'edit_comment\',\'c-' . $html_id . '\',0,' . $this->id . ')" title="' . _('editar comentario') . '"><img class="mini-icon-text" src="' . $globals['base_static'] . 'img/common/edit-misc01.png" alt="edit" width="18" height="12"/></a>'; } if ($length > 0 && mb_strlen($this->content) > $length + $length / 2) { $this->content = text_to_summary($this->content, $length); // Check all html tags are closed if (preg_match('/<\\w+>/', $this->content)) { $this->content = close_tags($this->content); } $expand .= ' ' . '<a href="javascript:get_votes(\'get_comment.php\',\'comment\',\'cid-' . $this->id . '\',0,' . $this->id . ')" title="' . _('resto del comentario') . '">» ' . _('ver todo el comentario') . '</a>'; } echo put_smileys($this->put_comment_tooltips(save_text_to_html($this->content, 'comments'))) . $expand; echo "\n"; }
$new = new Comment(); $new_comment_error = $new->save_from_post($link); } $username = $comment->type == 'admin' ? 'admin' : $comment->username; if ($comment->type != 'admin') { $globals['search_options'] = array('w' => 'comments', 'u' => $comment->username); } $comment->check_visibility(); if (!$comment->hide_comment) { $globals['description'] = _('Autor') . ": {$username}, " . _('Resumen') . ': ' . text_to_summary($comment->content, 250); if ($globals['media_public'] && $comment->media_size > 0) { $globals['thumbnail'] = Upload::get_url('comment', $comment->id, 0, $comment->media_date, $comment->media_mime); } elseif ($comment->avatar) { $globals['thumbnail'] = get_avatar_url($comment->author, $comment->avatar, 80); } $title = text_to_summary($comment->content, 120); } else { $title = ''; } if (isset($globals['canonical_server_name']) && !empty($globals['canonical_server_name'])) { $globals['extra_head'] = '<link rel="canonical" href="http://' . $globals['canonical_server_name'] . $comment->get_relative_individual_permalink() . '" />'; } do_header($title . ' | ' . $globals['site_name']); //do_subheader(_('comentario de') . ' ' . $username); /*** SIDEBAR ****/ echo '<div id="sidebar">'; do_banner_right(); //do_best_stories(); do_best_comments(); do_banner_promotions(); echo '</div>' . "\n";
function do_best_posts() { global $db, $globals, $dblang; if ($globals['mobile']) { return; } $output = ''; $key = 'best_posts_' . $globals['css_main']; if (memcache_mprint($key)) { return; } $min_date = date("Y-m-d H:i:00", $globals['now'] - 86400); // about 24 hours $res = $db->get_results("select post_id from posts, users where post_date > '{$min_date}' and post_user_id = user_id and post_karma > 0 order by post_karma desc limit 10"); if ($res) { $output .= '<div class="sidebox"><div class="header"><h4><a href="' . post_get_base_url('_best') . '">' . _('mejores notas') . '</a></h4></div><div class="comments"><ul>' . "\n"; foreach ($res as $p) { $post = new Post(); $post->id = $p->post_id; $post->read(); $output .= '<li><img src="' . get_avatar_url($post->author, $post->avatar, 20) . '" alt="" width="20" height="20" class="avatar"/>'; $output .= '<p><strong>' . $post->username . '</strong>: <a onmouseout="tooltip.clear(event);" onclick="tooltip.clear(this);" onmouseover="return tooltip.ajax_delayed(event, \'get_post_tooltip.php\', \'' . $post->id . '\', 10000);" href="' . post_get_base_url($post->username) . '/' . $post->id . '"><em>' . text_to_summary($post->clean_content(), 80) . '</em></a></p></li>' . "\n"; } $output .= '</ul></div></div>'; echo $output; memcache_madd($key, $output, 300); } }
$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(); if ($sql) { $posts = $db->get_col($sql); } if ($posts) { foreach ($posts as $post_id) { $post = Post::from_db($post_id); if (!$post) { continue; } $title = text_to_summary($post->clean_content(), 40); $title = $post->username . ': ' . htmlentities2unicodeentities($title); $content = htmlentities2unicodeentities(put_smileys($post->to_html($post->clean_content()))); echo "\t<item>\n"; echo "\t\t<title>{$title}</title>\n"; echo "\t\t<link>http://" . get_server_name() . post_get_base_url($post->username) . '/' . $post->id . "</link>\n"; echo "\t\t<pubDate>" . date("r", $post->date) . "</pubDate>\n"; echo "\t\t<dc:creator>{$post->username}</dc:creator>\n"; echo "\t\t<guid>http://" . get_server_name() . post_get_base_url($post->username) . '/' . $post->id . "</guid>\n"; // Insert GEO if ($latlng = geo_latlng('user', $post->author)) { echo "\t\t<georss:point>{$latlng->lat} {$latlng->lng}</georss:point>\n"; } echo "\t\t<description><![CDATA[{$content}"; echo '</p><p>» ' . _('autor') . ': <strong>' . $post->username . '</strong></p>'; echo "]]></description>\n";
// AFFERO GENERAL PUBLIC LICENSE is also included in the file called "COPYING". include 'config.php'; $globals['force_ssl'] = False; // We open the bar always as http to allow loading no https pages include mnminclude . 'html1.php'; $url_args = $globals['path']; $id = intval($globals['path'][1]); if (!$id > 0 || !($link = Link::from_db($id))) { do_error(_('enlace no encontrado'), 404); } // Mark as read, add click if necessary $link->add_click(); if ($globals['https'] && !preg_match('/^https:/', $link->url)) { redirect($link->url); die; } $link->title = text_to_summary($link->title, 80); // From libs/html1.php do_header() header('Content-Type: text/html; charset=utf-8'); $globals['security_key'] = get_security_key(); setcookie('k', $globals['security_key'], 0, $globals['base_url']); // From libks/link.php print_summary() $link->is_votable(); $link->permalink = $link->get_permalink(); $link->can_vote_negative = !$link->voted && $link->votes_enabled && $link->negatives_allowed(true); $link->get_box_class(); $vars = compact('type'); $vars['self'] = $link; $globals['extra_css'] = 'bar.css'; do_header($link->title, 'post'); Haanga::Load("link_bar.html", $vars);
function send($link) { if (empty($this->url)) { return; } $this->title = clean_input_url($link->url); syslog(LOG_INFO, "Sending trackback " . $link->get_canonical_permalink()); if (preg_match('/^ping:/', $this->url)) { // we got a pingback adress require_once mnminclude . 'IXR_Library.inc.php'; $url = preg_replace('/^ping:/', '', $this->url); $client = new IXR_Client($url); $client->timeout = 3; $client->useragent .= ' -- Meneame/2'; $client->debug = false; if ($client->query('pingback.ping', $link->get_canonical_permalink(), $this->link)) { $this->status = 'ok'; $this->store(); syslog(LOG_NOTICE, "Meneame, pingback sent: {$this->link}, {$this->url}"); return true; } else { // Be quiet for pingbacks $this->status = 'error'; $this->title = $client->getErrorMessage(); $this->store(); // syslog(LOG_NOTICE, "Meneame, out pingback error: $url ".$link->get_canonical_permalink().': '.$client->getErrorCode().' '.$client->getErrorMessage()); return false; } } // Send standard old trackback $title = urlencode($link->title); // Convert everything to HTML and the strip all html tags. $excerpt = urlencode(text_to_summary($link->content, 250)); $blog_name = urlencode(get_server_name()); $tb_url = $this->url; $url = urlencode($link->get_canonical_permalink()); $query_string = "charset=UTF-8&title={$title}&url={$url}&blog_name={$blog_name}&excerpt={$excerpt}"; $trackback_url = parse_url($this->url); $http_request = 'POST ' . $trackback_url['path'] . ($trackback_url['query'] ? '?' . $trackback_url['query'] : '') . " HTTP/1.0\r\n"; $http_request .= 'Host: ' . $trackback_url['host'] . "\r\n"; $http_request .= 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' . "\r\n"; $http_request .= 'Content-Length: ' . strlen($query_string) . "\r\n"; $http_request .= "User-Agent: MNM (http://meneame.net) "; $http_request .= "\r\n\r\n"; $http_request .= $query_string; if (empty($trackback_url['port'])) { $trackback_url['port'] = 80; } $fs = @fsockopen($trackback_url['host'], $trackback_url['port'], $errno, $errstr, 5); if ($fs && ($res = @fputs($fs, $http_request))) { /*********** DEBUG ********* $debug_file = '/tmp/trackback.log'; $fp = fopen($debug_file, 'a'); fwrite($fp, "\n*****\nRequest:\n\n$http_request\n\nResponse:\n\n"); while(!@feof($fs)) { fwrite($fp, @fgets($fs, 4096)); } fwrite($fp, "\n\n"); fclose($fp); /*********** DEBUG ************/ @fclose($fs); $this->status = 'ok'; $this->store(); syslog(LOG_NOTICE, "Meneame, trackback sent: {$this->link}, {$this->url}"); return true; } $this->status = 'error'; $this->store(); return false; }
$link = new Link(); $link->id = $comment->link; $link->read(); $globals['link'] = $link; // Change to a min_value is times is changed for the current link_status if ($globals['time_enabled_comments_status'][$link->status]) { $globals['time_enabled_comments'] = min($globals['time_enabled_comments_status'][$link->status], $globals['time_enabled_comments']); } // Check for comment post if ($_POST['process'] == 'newcomment') { $new = new Comment(); $new_comment_error = $new->save_from_post($link); } $username = $comment->type == 'admin' ? 'admin' : $comment->username; $globals['search_options'] = array('w' => 'comments', 'u' => $comment->username); $globals['description'] = _('Autor') . ": {$username}, " . _('Resumen') . ': ' . text_to_summary($comment->content, 250); do_header(sprintf(_('comentario de %s'), $username) . ' (' . $comment->id . ') | ' . _('menéame')); //do_subheader(_('comentario de') . ' ' . $username); /*** SIDEBAR ****/ echo '<div id="sidebar">'; do_banner_right(); //do_best_stories(); //do_best_comments(); do_banner_promotions(); echo '</div>' . "\n"; /*** END SIDEBAR ***/ echo '<div id="newswrap">' . "\n"; echo '<h3 style="text-shadow: 0 1px #ccc"><a href="' . $link->get_permalink() . '">' . $link->title . '</a></h3>'; echo '<ol class="comments-list">'; echo '<li>'; $comment->print_summary($link, 10000, true);
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 ' <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 ' <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"> </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&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 ' <a href="' . $globals['base_url'] . 'editlink.php?id=' . $this->id . '&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 ' <a href="#" onclick="$(\'#geoedit\').load(\'' . $globals['base_url'] . "geo/get_form.php?id={$this->id}&type=link&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 ': ' . 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"> <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 . '&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&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> '; echo '<strong>' . _('usuarios') . '</strong>: ' . $this->votes . ' '; echo '<strong>' . _('anónimos') . '</strong>: ' . $this->anonymous . ' '; 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"; } }
if ($globals['time_enabled_comments_status'][$link->status]) { $globals['time_enabled_comments'] = min($globals['time_enabled_comments_status'][$link->status], $globals['time_enabled_comments']); } // Check for comment post if ($_POST['process'] == 'newcomment') { $new = new Comment(); $new_comment_error = $new->save_from_post($link); } $username = $comment->type == 'admin' ? 'admin' : $comment->username; if ($comment->type != 'admin') { $globals['search_options'] = array('w' => 'comments', 'u' => $comment->username); } $comment->check_visibility(); if (!$comment->hide_comment) { $description = text_to_summary($comment->content, 250); $title = text_to_summary($description, 117); $globals['description'] = _('Autor') . ": {$username}, " . _('Resumen') . ': ' . $description; if ($globals['media_public'] && $comment->media_size > 0) { $globals['thumbnail'] = Upload::get_url('comment', $comment->id, 0, $comment->media_date, $comment->media_mime); } elseif ($comment->avatar) { $globals['thumbnail'] = get_avatar_url($comment->author, $comment->avatar, 80); } } else { $title = ''; $globals['noindex'] = true; } // Canonical url if (isset($globals['canonical_server_name']) && !empty($globals['canonical_server_name'])) { $canonical_server = $globals['canonical_server_name']; } else { $canonical_server = $link->server_name;
function text_sub_text($str, $length=70) { // Just in case, to maintain compatibility return text_to_summary($str, $length); }
function get($url, $maxlen = 150000, $check_local = true) { global $globals, $current_user; $url = trim($url); $url_components = @parse_url($url); $this->noiframe = false; if ($response = get_url($url)) { $this->content_type = preg_replace('#^(\\w+).+#', '$1', $response['content_type']); // Check if it has pingbacks if (preg_match('/X-Pingback: *(.+)/i', $response['header'], $match)) { $this->pingback = 'ping:' . clean_input_url($match[1]); } /* Were we redirected? */ if ($response['redirect_count'] > 0) { /* update $url with where we were redirected to */ $new_url = clean_input_url($response['location']); } if (!empty($new_url) && $new_url != $url) { syslog(LOG_NOTICE, "Meneame, redirected ({$current_user->user_login}): {$url} -> {$new_url}"); /* Check again the url */ if (!$this->check_url($new_url, $check_local, true)) { $this->url = $new_url; return false; } // Change the url if we were directed to another host if (strlen($new_url) < 300 && ($new_url_components = @parse_url($new_url))) { if ($url_components['host'] != $new_url_components['host']) { syslog(LOG_NOTICE, "Meneame, changed source URL ({$current_user->user_login}): {$url} -> {$new_url}"); $url = $new_url; $url_components = $new_url_components; } } } $this->html = $response['content']; $url_ok = true; } else { syslog(LOG_NOTICE, "Meneame, error getting ({$current_user->user_login}): {$url}"); $url_ok = false; } $this->url = $url; // Fill content type if empty // Right now only check for typical image extensions if (empty($this->content_type)) { if (preg_match('/(jpg|jpeg|gif|png)(\\?|#|$)/i', $this->url)) { $this->content_type = 'image'; } } // NO more to do if (!$url_ok || !preg_match('/html/', $response['content_type'])) { return true; } // Check if it forbides including in an iframe if (preg_match('/X-Frame-Options: *(.+)/i', $response['header']) || preg_match('/top\\.location\\.href *=/', $response['content'])) { $this->noiframe = true; } if (preg_match('/charset=([a-zA-Z0-9-_]+)/i', $this->html, $matches)) { $this->encoding = trim($matches[1]); if (strcasecmp($this->encoding, 'utf-8') != 0) { $this->html = iconv($this->encoding, 'UTF-8//IGNORE', $this->html); } } // Check if the author doesn't want to share if (preg_match('/<!-- *noshare *-->/', $this->html)) { $this->ban = array(); $this->ban['comment'] = _('el autor no desea que se envíe el artículo, respeta sus deseos'); syslog(LOG_NOTICE, "Meneame, noshare ({$current_user->user_login}): {$url}"); return false; } // Now we analyse the html to find links to banned domains // It avoids the trick of using google or technorati // Ignore it if the link has a rel="nofollow" to ignore comments in blogs if (!preg_match('/content="[^"]*(vBulletin|phpBB)/i', $this->html)) { preg_match_all('/(< *meta +http-equiv|< *frame[^<]*>|window\\.|document.\\|parent\\.|top\\.|self\\.)[^><]*(url|src|replace) *[=\\(] *[\'"]{0,1}https*:\\/\\/[^\\s "\'>]+[\'"\\;\\)]{0,1}[^>]*>/i', $this->html, $matches); } else { preg_match_all('/(<* meta +http-equiv|<* iframe|<* frame[^<]*>|window\\.|document.\\|parent\\.|top\\.|self\\.)[^><]*(href|url|src|replace) *[=\\(] *[\'"]{0,1}https*:\\/\\/[^\\s "\'>]+[\'"\\;\\)]{0,1}[^>]*>/i', $this->html, $matches); } $check_counter = 0; $second_level = preg_quote(preg_replace('/^(.+\\.)*([^\\.]+)\\.[^\\.]+$/', "\$2", $url_components['host'])); foreach ($matches[0] as $match) { if (!preg_match('/<a.+rel=.*nofollow.*>/', $match)) { preg_match('/(href|url|src|replace) *[=\\(] *[\'"]{0,1}(https*:\\/\\/[^\\s "\'>]+)[\'"\\;\\)]{0,1}/i', $match, $url_a); $embeded_link = $url_a[2]; $new_url_components = @parse_url($embeded_link); if (!empty($embeded_link) && $check_counter < 5 && !$checked_links[$new_url_components['host']]) { if (!preg_match("/{$second_level}\\.[^\\.]+\$/", $new_url_components['host'])) { $check_counter++; } $checked_links[$new_url_components['host']] = true; if (!$this->check_url($embeded_link, false) && $this->banned) { return false; } } } } // The URL has been checked $this->valid = true; if (preg_match('/<title[^<>]*>([^<>]*)<\\/title>/si', $this->html, $matches)) { $url_title = clean_text($matches[1]); if (mb_strlen($url_title) > 3) { $this->url_title = $url_title; } } if (preg_match('/< *meta +name=[\'"]description[\'"] +content=[\'"]([^<>]+)[\'"] *\\/*>/si', $this->html, $matches)) { $url_description = clean_text($matches[1]); // Further clean up to eliminate links and tags inside the description $url_description = html_entity_decode($url_description, ENT_COMPAT, 'UTF-8'); $url_description = strip_tags($url_description); $url_description = @htmlspecialchars($url_description, ENT_COMPAT, 'UTF-8'); if (mb_strlen($url_description) > 20) { $this->url_description = text_to_summary($url_description, 400); } } return true; }
function get_post($time, $type, $postid, $userid) { global $db, $current_user, $events, $last_timestamp, $foo_link, $max_items; $event = $db->get_row("select SQL_CACHE user_login, post_user_id, post_content from posts, users where post_id = {$postid} and user_id={$userid}"); if (!$event) { return; } $json['link'] = post_get_base_url($event->user_login) . "/{$postid}"; $json['ts'] = $time; $json['type'] = $type; $json['who'] = $event->user_login; $json['status'] = _('nótame'); $json['title'] = put_smileys(text_to_summary(preg_replace('/(@[\\S.-]+)(,\\d+)/', '$1', $event->post_content), 130)); $json['votes'] = 0; $json['com'] = 0; $json['uid'] = $userid; $json['id'] = $postid; if ($userid > 0) { $json['icon'] = get_avatar_url($userid, -1, 20); } $key = $time . ':' . $type . ':' . $postid; $events[$key] = $json; if ($time > $last_timestamp) { $last_timestamp = $time; } }
function do_best_posts() { global $db, $globals, $dblang; $min_date = date("Y-m-d H:00:00", $globals['now'] - 22000); // about 6 hours $res = $db->get_results("select post_id, post_content, user_login from posts, users where post_date > '{$min_date}' and post_user_id = user_id order by post_karma desc limit 10"); if ($res) { echo '<div class="vertical-box">'; echo '<h4><a href="' . post_get_base_url('_best') . '">' . _('¿mejores? notas') . '</a></h4><ul>'; foreach ($res as $post) { echo '<li>' . $post->user_login . ': <a onmouseout="tooltip.clear(event);" onclick="tooltip.clear(this);" onmouseover="return tooltip.ajax_delayed(event, \'get_post_tooltip.php\', \'' . $post->post_id . '\', 10000);" href="' . post_get_base_url($post->user_login) . '/' . $post->post_id . '">' . text_to_summary($post->post_content, 50) . '</a></li>' . "\n"; } echo '</ul></div>'; } }
} if (!empty($link->tags)) { $globals['tags'] = $link->tags; } // Add canonical address $globals['extra_head'] .= '<link rel="canonical" href="' . $link->get_canonical_permalink($canonical_page) . '" />'; // add also a rel to the comments rss $globals['extra_head'] .= '<link rel="alternate" type="application/rss+xml" title="' . _('comentarios esta noticia') . '" href="http://' . get_server_name() . $globals['base_url'] . 'comments_rss2.php?id=' . $link->id . '" />'; if ($link->has_thumb()) { if ($link->thumb_medium_url) { $globals['thumbnail'] = $globals['base_static_noversion'] . $link->thumb_medium_uri; } else { $globals['thumbnail'] = $globals['base_static_noversion'] . $link->thumb_uri; } } $globals['description'] = text_to_summary($link->content, 200); do_header($link->title, 'post'); // Show the error if the comment couldn't be inserted if (!empty($new_comment_error)) { add_javascript('mDialog.notify("' . _('Aviso') . ": {$new_comment_error}" . '", 5);'); } do_tabs("main", _('noticia'), true); print_story_tabs($tab_option); /*** SIDEBAR ****/ echo '<div id="sidebar" class="' . $globals['sidebar_container_class'] . '">'; do_sub_message_right(); do_banner_right(); // GEO if ($link->latlng) { echo '<div id="map" style="width:300px;height:200px;margin-bottom:25px;"> </div>'; }
$width = 140; $height = 120; $avatar = 40; $text_length = 150; } if (!empty($_GET['border'])) { $border = get_hex_color($_GET['border'], '#'); } else { $border = '#bbb'; } $id = $db->get_var($sql); if (!$id > 0) { die; } $post = new Post(); $post->id = $id; $post->read(); if (!$post->read) { die; } echo 'document.write(\''; echo '<a href="http://' . get_server_name() . post_get_base_url($post->username) . '" style="text-decoration: none; border: none">'; echo '<div style="overflow: hidden; background: #fff; width: ' . $width . 'px; max-height: ' . $height . 'px; border: 1px solid; border-color: ' . $border . '; ">'; echo '<div style="padding: 4px 4px 4px 4px;">'; echo '<div style="overflow: hidden; color: #666; text-align: left; font-family: sans-serif; font-size: 8pt; padding: 0; line-height: 1.1">'; echo '<img src="' . get_avatar_url($post->author, $post->avatar, $avatar) . '" width="' . $avatar . '" height="' . $avatar . '" alt="avatar" style="float:left; margin: 0 5px 4px 0;" border: none/>'; echo '<div>'; echo '<span style="color: #111;">' . $post->username . '</span><br/>'; echo addslashes(text_to_summary($post->content, $text_length)); echo '</div></div></div></div></a>'; echo '\');';
// Ricardo Galli <gallir at uib dot es> and // Beldar <beldar.cat at gmail dot com> // 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 . 'comment.php'; include mnminclude . 'link.php'; header('Content-Type: text/html; charset=utf-8'); stats_increment('ajax'); $id = intval($_GET['id']); if (!$id > 0) { die; } $comment = new Comment(); $comment->id = $id; $comment->read(); if (!$comment->read) { die; } $link = new Link(); $link->id = $comment->link; $link->read_basic(); echo '<div style="font-size:8.5pt;width:280px; margin-right:15px; overflow:hidden">'; if ($comment->avatar) { echo '<img src="' . get_avatar_url($comment->author, $comment->avatar, 40) . '" width="40" height="40" alt="avatar" style="float:left; margin: 0 5px 4px 0;"/>'; } echo '<a href="' . $link->get_relative_permalink() . '#comment-' . $comment->order . '" target="_blank"><strong>' . $comment->username . '</strong></a><br/>'; echo put_smileys(text_to_summary($comment->content, 500)); echo '</div>';
function do_last_blogs() { global $db, $globals, $dblang; if ($globals['mobile'] || $globals['submnm']) { return; } $output = ''; $key = 'last_blogs_' . $globals['v']; if (memcache_mprint($key)) { return; } echo '<!-- Calculating ' . __FUNCTION__ . ' -->'; $entries = $db->get_results("select rss.blog_id, rss.user_id, title, url, user_login, user_avatar from rss, users where rss.user_id = users.user_id order by rss.date desc limit 10"); if ($entries) { $objects = array(); $title = _('apuntes de blogs'); $url = $globals['base_url'] . 'rsss'; foreach ($entries as $entry) { $obj = new stdClass(); $obj->user_id = $entry->user_id; $obj->avatar = $entry->user_avatar; $obj->title = text_to_summary($entry->title, 75); $obj->link = $entry->url; $obj->username = $entry->user_login; $objects[] = $obj; } $vars = compact('objects', 'title', 'url'); $output = Haanga::Load('last_blogs.html', $vars, true); echo $output; memcache_madd($key, $output, 300); } }
} if ($link->status != 'published') $globals['do_vote_queue']=true; if (!empty($link->tags)) $globals['tags']=$link->tags; // Add canonical address $globals['extra_head'] = '<link rel="canonical" href="'.$globals['link_permalink'].'" />'."\n"; // add also a rel to the comments rss $globals['extra_head'] .= '<link rel="alternate" type="application/rss+xml" title="'._('comentarios esta noticia').'" href="http://'.get_server_name().$globals['base_url'].'comments_rss2.php?id='.$link->id.'" />'."\n"; $globals['thumbnail'] = $link->has_thumb(); $globals['description'] = _('Autor') . ": $link->username, " . _('Resumen') . ': '. text_to_summary($link->content, 250); do_header($link->title, 'post'); // Show the error if the comment couldn't be inserted if (!empty($new_comment_error)) { echo '<script type="text/javascript">'; echo '$(function(){alert(\''._('Aviso'). ": $new_comment_error".'\')});'; echo '</script>'; } do_tabs("main",_('noticia'), true); print_story_tabs($tab_option); /*** SIDEBAR ****/ echo '<div id="sidebar">';
function prepare_summary_text($length = 0) { global $current_user, $globals; if (empty($this->basic_summary) && ($this->author == $current_user->user_id && time() - $this->date < $globals['posts_edit_time'] || $current_user->user_level == 'god' && time() - $this->date < $globals['posts_edit_time_admin'])) { // Admins can edit up to 10 days $this->can_edit = true; } else { $this->can_edit = false; } if ($length > 0) { $this->content = text_to_summary($this->content, $length); } $this->content = $this->to_html($this->content) . $expand; if ($this->media_size > 0) { $this->media_thumb_dir = Upload::get_cache_relative_dir($this->id); $this->media_url = Upload::get_url('post', $this->id, 0, $this->media_date, $this->media_mime); } }
function get_post($time, $type, $postid, $userid) { global $db, $current_user, $events, $last_timestamp, $foo_link, $max_items; $event = $db->get_row("select user_login, post_user_id, post_content from posts, users where post_id = {$postid} and user_id={$userid}"); if (!$event) { return; } // Dont show her notes if the user ignored if ($type == 'post' && friend_exists($current_user->user_id, $userid) < 0) { return; } $json['link'] = post_get_base_url($event->user_login) . "/{$postid}"; $json['ts'] = $time; $json['type'] = $type; $json['who'] = addslashes($event->user_login); $json['status'] = _('nótame'); $json['title'] = addslashes(text_to_summary($event->post_content, 130)); $json['votes'] = 0; $json['com'] = 0; $json['uid'] = $userid; $json['id'] = $postid; if ($userid > 0) { $json['icon'] = get_avatar_url($userid, -1, 20); } $key = $time . ':' . $type . ':' . $postid; $events[$key] = json_encode_single($json); if ($time > $last_timestamp) { $last_timestamp = $time; } }
function get_post($time, $type, $postid, $userid) { global $db, $current_user, $events, $last_timestamp, $foo_link, $max_items; $event = $db->get_row("select user_login, post_user_id, post_content, media.size as media_size from posts LEFT JOIN media ON (media.type='post' and media.id = posts.post_id and media.version = 0), users where post_id = {$postid} and user_id={$userid}"); if (!$event) { return; } $json['link'] = post_get_base_url($postid); $json['ts'] = $time; $json['type'] = $type; $json['who'] = $event->user_login; $json['status'] = _('nótame'); $json['title'] = put_smileys(text_to_summary(preg_replace('/(@[\\S.-]+)(,\\d+)/', '$1', $event->post_content), 130)); if (mb_strlen(trim($json['title'])) == 0) { $json['title'] = '...'; } $json['votes'] = 0; $json['com'] = 0; $json['uid'] = $userid; $json['id'] = $postid; if ($userid > 0) { $json['icon'] = get_avatar_url($userid, -1, 20); } if ($event->media_size > 0) { $json['thumb'] = $globals['base_static'] . Upload::get_cache_relative_dir($postid) . "/media_thumb-post-{$postid}.jpg"; } $key = $time . ':' . $type . ':' . $postid; $events[$key] = $json; if ($time > $last_timestamp) { $last_timestamp = $time; } }
// // 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(); $posts = $db->get_col($sql); if ($posts) { foreach ($posts as $post_id) { $post->id = $post_id; $post->read(); $title = strip_tags(text_to_summary($post->content, 40)); $title = $post->username . ': ' . htmlentities2unicodeentities($title); $content = htmlentities2unicodeentities(put_smileys(save_text_to_html($post->content))); echo "\t<item>\n"; echo "\t\t<title>{$title}</title>\n"; echo "\t\t<link>http://" . get_server_name() . post_get_base_url($post->username) . '/' . $post->id . "</link>\n"; echo "\t\t<pubDate>" . date("r", $post->date) . "</pubDate>\n"; echo "\t\t<dc:creator>{$post->username}</dc:creator>\n"; echo "\t\t<guid>http://" . get_server_name() . post_get_base_url($post->username) . '/' . $post->id . "</guid>\n"; // Insert GEO if ($latlng = geo_latlng('user', $post->author)) { echo "\t\t<georss:point>{$latlng->lat} {$latlng->lng}</georss:point>\n"; } echo "\t\t<description><![CDATA[{$content}"; echo '</p><p>» ' . _('autor') . ': <strong>' . $post->username . '</strong></p>'; echo "]]></description>\n";
//$rows = $db->get_var("SELECT SQL_CACHE count(*) FROM posts where post_date > '$min_date'"); $rss_option = "sneakme_rss2.php"; break; default: $tab_option = 4; if (is_numeric($argv[0]) && ($post_id = intval($argv[0])) > 0 || is_numeric($argv[1]) && ($post_id = intval($argv[1])) > 0) { // Individual post $user->id = $db->get_var("select post_user_id from posts where post_id={$post_id}"); if (!$user->read()) { do_error(_('usuario no encontrado'), 404); } $globals['permalink'] = 'http://' . get_server_name() . post_get_base_url($post_id); // Fill title $summary = text_to_summary($db->get_var("SELECT post_content from posts where post_id = {$post_id}"), 250); $globals['description'] = _('Autor') . ": {$user->username}, " . _('Resumen') . ': ' . $summary; $page_title = text_to_summary($summary, 120); if ($user->avatar) { $globals['thumbnail'] = get_avatar_url($user->id, $user->avatar, 80); } //$page_title = sprintf(_('nota de %s'), $user->username) . " ($post_id)"; $globals['search_options']['u'] = $user->username; $where = "post_id = {$post_id}"; $order_by = ""; $limit = ""; $rows = 1; } else { // User is specified $user->username = $db->escape($argv[0]); if (!$user->read() || $user->disabled()) { do_error(_('usuario no encontrado'), 404); }
function print_text($length = 0) { global $current_user, $globals; if (!$this->basic_summary && ($this->author == $current_user->user_id && time() - $this->date < $globals['posts_edit_time'] || $current_user->user_level == 'god' && time() - $this->date < $globals['posts_edit_time_admin'])) { // Admins can edit up to 10 days $expand = ' <a href="javascript:post_edit(' . $this->id . ')" title="' . _('editar') . '"><img class="mini-icon-text" src="' . $globals['base_static'] . 'img/common/edit-misc01.png" alt="edit" width="18" height="12"/></a>'; } elseif ($length > 0) { $this->content = text_to_summary($this->content, $length); } echo put_smileys($this->put_tooltips(save_text_to_html($this->content, 'posts'))) . $expand; echo "\n"; }