Пример #1
0
function do_profile()
{
    global $user, $current_user, $login, $db, $globals;
    $options = array();
    $options[$user->username] = get_user_uri($user->username);
    //$options[_('categorías personalizadas')] = get_user_uri($user->username, 'categories');
    if ($current_user->user_id == $user->id || $current_user->user_level == 'god') {
        $options[_('modificar perfil') . ' →'] = $globals['base_url'] . 'profile?login='******'extra_js'][] = 'jquery.flot.min.js';
        $globals['extra_js'][] = 'jquery.flot.time.min.js';
    }
    $post = new Post();
    if (!$post->read_last($user->id)) {
        $post = NULL;
    }
    if (!empty($user->url)) {
        if ($user->karma < 10) {
            $nofollow = 'rel="nofollow"';
        } else {
            $nofollow = '';
        }
        if (!preg_match('/^http/', $user->url)) {
            $url = 'http://' . $user->url;
        } else {
            $url = $user->url;
        }
    }
    if ($current_user->user_id > 0 && $current_user->user_id != $user->id) {
        $friend_icon = User::friend_teaser($current_user->user_id, $user->id);
    }
    $selected = 0;
    $rss = 'rss?sent_by=' . $user->id;
    $rss_title = _('envíos en rss2');
    $geodiv = $current_user->user_id > 0 && $current_user->user_id != $user->id && $globals['latlng'] && ($my_latlng = geo_latlng('user', $current_user->user_id));
    $show_email = $current_user->user_id > 0 && !empty($user->public_info) && ($current_user->user_id == $user->id || $current_user->user_level == 'god');
    $clones_from = "and clon_date > date_sub(now(), interval 30 day)";
    if ($current_user->admin) {
        $nclones = $db->get_var("select count(distinct clon_to) from clones where clon_from = {$user->id} {$clones_from}");
    }
    $user->all_stats();
    if (!$user->bio) {
        $user->bio = '';
    }
    if ($user->total_links > 1) {
        $entropy = intval(($user->blogs() - 1) / ($user->total_links - 1) * 100);
    }
    if ($user->total_links > 0 && $user->published_links > 0) {
        $percent = intval($user->published_links / $user->total_links * 100);
    } else {
        $percent = 0;
    }
    if ($globals['do_geo'] && $current_user->user_id == $user->id) {
        ob_start();
        geo_coder_print_form('user', $current_user->user_id, $globals['latlng'], _('ubícate en el mapa (si te apetece)'), 'user');
        $geo_form = ob_get_clean();
    }
    $addresses = array();
    if ($current_user->user_id == $user->id || $current_user->user_level == 'god' && !$user->admin) {
        // gods and admins know each other for sure, keep privacy
        $dbaddresses = $db->get_results("select distinct(vote_ip_int) as ip from votes where vote_type in ('links', 'comments', 'posts') and vote_user_id = {$user->id} order by vote_date desc limit 30");
        // Try with comments
        if (!$dbaddresses) {
            $dbaddresses = $db->get_results("select distinct(comment_ip_int) as ip from comments where comment_user_id = {$user->id} and comment_date > date_sub(now(), interval 30 day) order by comment_date desc limit 30");
        }
        if ($dbaddresses) {
            foreach ($dbaddresses as $dbaddress) {
                $ip = inet_dtop($dbaddress->ip);
                $ip_pattern = preg_replace('/[\\.\\:][0-9a-f]+$/i', '', $ip);
                if (!in_array($ip_pattern, $addresses)) {
                    $addresses[] = $ip_pattern;
                }
            }
        }
    }
    $prefs['use_bar'] = User::get_pref($user->id, 'use_bar');
    $prefs['last_com_first'] = User::get_pref($user->id, 'last_com_first');
    $vars = compact('post', 'options', 'selected', 'rss', 'rss_title', 'geodiv', 'user', 'my_latlng', 'url', 'nofollow', 'nclones', 'show_email', 'entropy', 'percent', 'geo_form', 'addresses', 'friend_icon');
    return Haanga::Load('/user/profile.html', $vars);
}
Пример #2
0
	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 '&nbsp;<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 '&nbsp;<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>'."&nbsp;<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 '&nbsp;&nbsp;<a href="'.$globals['base_url'].'editlink.php?id='.$this->id.'&amp;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 '&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 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 ':&nbsp;'.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">&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).'</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->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&amp;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>&nbsp;&nbsp;';
				echo '<strong>'._('usuarios').'</strong>: <span id="a-usu-'.$this->id.'">'.$this->votes.'</span>&nbsp;&nbsp;';
				echo '<strong>'._('anónimos').'</strong>: <span id="a-ano-'.$this->id.'">'.$this->anonymous.'</span>&nbsp;&nbsp;';

				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>&nbsp;&nbsp;';
				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";
		}

	}
Пример #3
0
function do_profile() {
	global $user, $current_user, $login, $db, $globals;

	$options = array();
	$options[$user->username] = get_user_uri($user->username);
	$options[_('categorías personalizadas')] = get_user_uri($user->username, 'categories');
	if ($current_user->user_id == $user->id || $current_user->user_level == 'god') {
		$options[_('modificar perfil').' &rarr;'] = $globals['base_url'].'profile.php?login='******'rss2.php?sent_by='.$user->id, _('envíos en rss2'));

	if(!empty($user->url)) {
		if ($user->karma < 10) $nofollow = 'rel="nofollow"';
		if (!preg_match('/^http/', $user->url)) $url = 'http://'.$user->url;
		else $url = $user->url;
	}

	// Print last user's note
	$post = new Post;
	if ($post->read_last($user->id)) {
		echo '<div id="addpost"></div>';
		echo '<ol class="comments-list" id="last_post">';   
		echo '<li>';
		$post->print_summary();
		echo '</li>';
		echo "</ol>\n";
	}   

	echo '<fieldset><legend>';
	echo _('información personal');
	echo '</legend>';


	// Avatar
	echo '<div style="float:right;text-align:center">';
	echo '<img id="avatar" class="avatar" src="'.get_avatar_url($user->id, $user->avatar, 80).'" width="80" height="80" alt="'.$user->username.'" title="avatar" />';

	// Print the button and associated div to change the avatar
	if ($current_user->user_id == $user->id) {
		echo '<div id="avatar_indicator" style="margin:0;padding:0;height:12px"></div>';
		echo '<button id="avatar_upload" style="margin:0" title="'._('imagen cuadrada de no más de 400 KB, sin transparencias').'">'._('cambiar avatar').'</button>'."\n";
		@include(mnminclude.'foreign/avatar_upload.html');
	}
	echo '</div>';


	// Geo div
	echo '<div style="width:140px; float:left;">';
	if($globals['do_geo']) {
		echo '<div id="map" class="thumbnail" style="width:130px; height:130px; overflow:hidden; float:left"></div>';
		if ($current_user->user_id > 0 && $current_user->user_id != $user->id && $globals['latlng'] && ($my_latlng = geo_latlng('user', $current_user->user_id))) {
			$distance = (int) geo_distance($my_latlng, $globals['latlng']);
			echo '<p style="color: #FF9400; font-size: 90%">'."$user->username "._('está a')." <strong>$distance kms</strong></p>";
		}
	}
	echo '&nbsp;</div>';


	echo '<div style="float:left;min-width:65%">';
	echo '<dl>';	
	if(!empty($user->username)) {
		echo '<dt>'._('usuario').':</dt><dd>';
		if (!empty($url)) {
			echo '<a href="'.$url.'" '.$nofollow.'>'.$user->username.'</a>';
		} else {
			echo $user->username;
		}

		$user->print_medals();

		$clones_from = "and clon_date > date_sub(now(), interval 30 day)";
		if ($current_user->admin &&
			($nclones = $db->get_var("select count(distinct clon_to) from clones where clon_from = $user->id $clones_from")) > 0 ) {
			echo ' (<a href="javascript:modal_from_ajax(\''.$globals['base_url'].'backend/ip_clones.php?id='.
			$user->id.'\', \''. _('clones por IP'). '\')" title="'._('clones').'">'._('clones').'</a><sup>'.$nclones.'</sup>) ';
		}
		// Print friend icon
		if ($current_user->user_id > 0 && $current_user->user_id != $user->id) {
			echo '&nbsp;<a id="friend-'.$current_user->user_id.'-'.$user->id.'" href="javascript:get_votes(\'get_friend.php\',\''.$current_user->user_id.'\',\'friend-'.$current_user->user_id.'-'.$user->id.'\',0,\''.$user->id.'\')">'.User::friend_teaser($current_user->user_id, $user->id).'</a>';
		}
		// Print user detailed info
		if ($user->id==$current_user->user_id || $current_user->admin) {
			echo " (" . _('id'). ": <em>$user->id</em>, ";
			echo "<em>$user->level</em>)";
		}
		if($current_user->user_level=='god') {
			echo " (<em>$user->username_register</em>)";
		}
		echo '</dd>';
	}

	if(!empty($user->names)) {
		echo '<dt>'._('nombre').':</dt><dd>'.$user->names.'</dd>';
	}

	// Show public info is it's a friend or god
	if($current_user->user_id > 0 && !empty($user->public_info) && (
			$current_user->user_id == $user->id
			|| $current_user->user_level=='god' 
			/*|| friend_exists($user->id, $current_user->user_id)*/ )) {  //friends cannot see the IM address (it was public before)
		echo '<dt>'._('IM/email').':</dt><dd> '.$user->public_info.'</dd>';
	}

	if(!empty($url)) {
		echo '<dt>'._('sitio web').':</dt><dd><a href="'.$url.'" '.$nofollow.'>'.$url.'</a></dd>';
	}

	echo '<dt>'._('desde').':</dt><dd>'.get_date_time($user->date).'</dd>';

	if($current_user->user_level=='god') {
		echo '<dt>'._('email').':</dt><dd>'.$user->email. " (<em>$user->email_register</em>)</dd>";
	}

	if ($user->id == $current_user->user_id || $current_user->user_level=='god' ) {
		echo '<dt>'._('clave API').':</dt><dd id="api-key"><a href="javascript:get_votes(\'get_user_api_key.php\',\'\',\'api-key\',0,\''.$user->id.'\')">'._('leer clave API').'</a> ('._('no la divulgues').')</dd>';
		if(!empty($user->adcode)) {
			echo '<dt>'._('Código AdSense').':</dt><dd>'.$user->adcode.'&nbsp;</dd>';
			echo '<dt>'._('Canal AdSense').':</dt><dd>'.$user->adchannel.'&nbsp;</dd>';
		}
	}

	echo '<dt>'._('karma').':</dt><dd>'.$user->karma;
	// Karma details
	if ($user->id == $current_user->user_id || $current_user->user_level=='god' ) {
		echo ' (<a href="javascript:modal_from_ajax(\''.$globals['base_url'].'backend/get_karma_numbers.php?id='.$user->id.'\', \''.
			_('cálculo del karma').
			'\')" title="'._('detalles').'">'._('detalle cálculo').'</a>)';
	}
	echo '</dd>';

	echo '<dt>'._('ranking').':</dt><dd>#'.$user->ranking().'</dd>';

	$user->all_stats();
	echo '<dt>'._('noticias enviadas').':</dt><dd>'.$user->total_links.'</dd>';
	if ($user->total_links > 0 && $user->published_links > 0) {
		$percent = intval($user->published_links/$user->total_links*100);
	} else {
		$percent = 0;
	}
	if ($user->total_links > 1) {
		$entropy = intval(($user->blogs() - 1) / ($user->total_links - 1) * 100);
		echo '<dt><em>'._('entropía').'</em>:</dt><dd>'.$entropy.'%</dd>';
	}
	echo '<dt>'._('noticias publicadas').':</dt><dd>'.$user->published_links.' ('.$percent.'%)</dd>';
	echo '<dt>'._('comentarios').':</dt><dd>'.$user->total_comments.'</dd>';
	echo '<dt>'._('notas').':</dt><dd>'.$user->total_posts.'</dd>';
	echo '<dt>'._('número de votos').':</dt><dd>'.$user->total_votes.'</dd>';

	// Print affinity to this user
	if ($current_user->user_id && ($aff_to = User::get_affinity($user->id, $current_user->user_id))) {
		$aff_to = round($aff_to/100, 2);
		echo '<dt><strong>'._('afinidad con este usuario').'</strong>:</dt><dd>'.$aff_to .'</dd>';
	}


	echo '</dl>';

	if ($user->id == $current_user->user_id) {
		echo '<div style="margin-top: 20px" align="center">';
		print_oauth_icons($_REQUEST['return']);
		echo '</div>'."\n";
	}

	echo '</div>';
	echo '</fieldset>';


	// Print GEO form
	if($globals['do_geo'] && $current_user->user_id == $user->id) {
		echo '<div class="geoform">';
		geo_coder_print_form('user', $current_user->user_id, $globals['latlng'], _('ubícate en el mapa (si te apetece)'), 'user');
		echo '</div>';
	}

	// Print a chart of the last 30 days activity
	if ($user->total_votes > 20 && ($current_user->user_id == $user->id || $current_user->admin)) {
		echo '<fieldset><legend>'._('votos/hora últimos 30 días').'</legend>';
		// Call to generate HMTL and javascript for the Flot chart
		echo '<script src="'.$globals['base_static'].'js/jquery.flot.min.js" type="text/javascript"></script>'."\n";
		//echo '<div id="flot" style="width:600px;height:150px;"></div>'."\n";
		echo '<div id="flot" style="width:100%;height:150px;"></div>'."\n";
		@include (mnminclude.'foreign/chart_user_votes_history.js');
		echo '</fieldset>';
	}

	// Show first numbers of the address if the user has god privileges
	if ($current_user->user_level == 'god' &&  ! $user->admin ) { // gods and admins know each other for sure, keep privacy
		$addresses = $db->get_results("select INET_NTOA(vote_ip_int) as ip from votes where vote_type='links' and vote_user_id = $user->id order by vote_date desc limit 30");

		// Try with comments
		if (! $addresses) {
			$addresses = $db->get_results("select comment_ip as ip from comments where comment_user_id = $user->id and comment_date > date_sub(now(), interval 30 day) order by comment_date desc limit 30");
		}

		if (! $addresses) {
			// Use register IP
			$addresses = $db->get_results("select user_ip as ip from users where user_id = $user->id");
		}

		// Not addresses to show
		if (! $addresses) {
			return;
		}

		$clone_counter = 0;
		echo '<fieldset><legend>'._('últimas direcciones IP').'</legend>';
		$prev_address = '';
		foreach ($addresses as $dbaddress) {
			$ip_pattern = preg_replace('/\.[0-9]+$/', '', $dbaddress->ip);
			if($ip_pattern != $prev_address) {
				echo '<p>'. $ip_pattern . '</p>';
				$clone_counter++;
				$prev_address = $ip_pattern;
				if ($clone_counter >= 30) break;
			}
		}
		echo '</fieldset>';
	}
}
Пример #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";
     }
 }
Пример #5
0
function do_profile()
{
    global $user, $current_user, $login, $db, $globals;
    if (!empty($user->url)) {
        if ($user->karma < 10) {
            $nofollow = 'rel="nofollow"';
        }
        if (!preg_match('/^http/', $user->url)) {
            $url = 'http://' . $user->url;
        } else {
            $url = $user->url;
        }
    }
    $post = new Post();
    if ($post->read_last($user->id)) {
        echo '<ol class="comments-list" id="last_post">';
        $post->print_summary();
        echo "</ol>\n";
    }
    echo '<fieldset><legend>';
    echo _('información personal');
    if ($login === $current_user->user_login) {
        echo ' (<a href="' . $globals['base_url'] . 'profile.php">' . _('modificar') . '</a>)';
    } elseif ($current_user->user_level == 'god') {
        echo ' (<a href="' . $globals['base_url'] . 'profile.php?login='******'">' . _('modificar') . '</a>)';
    }
    echo '</legend>';
    // Avatar
    echo '<img class="thumbnail" src="' . get_avatar_url($user->id, $user->avatar, 80) . '" width="80" height="80" alt="' . $user->username . '" title="avatar" />';
    // Geo div
    echo '<div style="width:140px; float:left;">';
    if ($globals['do_geo']) {
        echo '<div id="map" class="thumbnail" style="width:130px; height:130px; overflow:hidden; float:left"></div>';
        if ($current_user->user_id > 0 && $current_user->user_id != $user->id && $globals['latlng'] && ($my_latlng = geo_latlng('user', $current_user->user_id))) {
            $distance = (int) geo_distance($my_latlng, $globals['latlng']);
            echo '<p style="color: #FF9400; font-size: 90%">' . _('estás a') . " <strong>{$distance} kms</strong> " . _('de') . ' ' . $user->username . '</p>';
        }
    }
    echo '&nbsp;</div>';
    echo '<div style="float:left;min-width:65%">';
    echo '<dl>';
    if (!empty($user->username)) {
        echo '<dt>' . _('usuario') . ':</dt><dd>';
        if (!empty($url)) {
            echo '<a href="' . $url . '" ' . $nofollow . '>' . $user->username . '</a>';
        } else {
            echo $user->username;
        }
        // Print friend icon
        if ($current_user->user_id > 0 && $current_user->user_id != $user->id) {
            echo '&nbsp;<a id="friend-' . $current_user->user_id . '-' . $user->id . '" href="javascript:get_votes(\'get_friend.php\',\'' . $current_user->user_id . '\',\'friend-' . $current_user->user_id . '-' . $user->id . '\',0,\'' . $user->id . '\')">' . friend_teaser($current_user->user_id, $user->id) . '</a>';
        }
        // Print user detailed info
        if ($login === $current_user->user_login || $current_user->user_level == 'god') {
            echo " (" . _('id') . ": <em>{$user->id}</em>)";
            echo " (<em>{$user->level}</em>)";
        }
        if ($current_user->user_level == 'god') {
            echo " (<em>{$user->username_register}</em>)";
        }
        echo '</dd>';
    }
    if (!empty($user->names)) {
        echo '<dt>' . _('nombre') . ':</dt><dd>' . $user->names . '</dd>';
    }
    // Show public info is it's a friend or god
    if ($current_user->user_id > 0 && !empty($user->public_info) && ($current_user->user_id == $user->id || $current_user->user_level == 'god')) {
        //friends cannot see the IM address (it was public before)
        echo '<dt>' . _('IM/email') . ':</dt><dd> ' . $user->public_info . '</dd>';
    }
    if (!empty($url)) {
        echo '<dt>' . _('sitio web') . ':</dt><dd><a href="' . $url . '" ' . $nofollow . '>' . $url . '</a></dd>';
    }
    echo '<dt>' . _('desde') . ':</dt><dd>' . get_date_time($user->date) . '</dd>';
    if ($current_user->user_level == 'god') {
        echo '<dt>' . _('email') . ':</dt><dd>' . $user->email . " (<em>{$user->email_register}</em>)</dd>";
    }
    if ($user->id == $current_user->user_id || $current_user->user_level == 'god') {
        echo '<dt>' . _('clave API') . ':</dt><dd id="api-key"><a href="javascript:get_votes(\'get_user_api_key.php\',\'\',\'api-key\',0,\'' . $user->id . '\')">' . _('leer clave API') . '</a> (' . _('no la divulgues') . ')</dd>';
        if (!empty($user->adcode)) {
            echo '<dt>' . _('Código AdSense') . ':</dt><dd>' . $user->adcode . '&nbsp;</dd>';
            echo '<dt>' . _('Canal AdSense') . ':</dt><dd>' . $user->adchannel . '&nbsp;</dd>';
        }
    }
    echo '<dt>' . _('karma') . ':</dt><dd>' . $user->karma;
    // Karma details
    if ($user->id == $current_user->user_id || $current_user->user_level == 'god') {
        echo ' (<a href="javascript:modal_from_ajax(\'' . $globals['base_url'] . 'backend/get_karma_numbers.php?id=' . $user->id . '\', \'' . _('cálculo del karma') . '\')" title="' . _('detalles') . '">' . _('detalle cálculo') . '</a>)';
    }
    echo '</dd>';
    $user->all_stats();
    echo '<dt>' . _('noticias enviadas') . ':</dt><dd>' . $user->total_links . '</dd>';
    if ($user->total_links > 0 && $user->published_links > 0) {
        $percent = intval($user->published_links / $user->total_links * 100);
    } else {
        $percent = 0;
    }
    if ($user->total_links > 1) {
        $entropy = intval(($user->blogs() - 1) / ($user->total_links - 1) * 100);
        echo '<dt><em>' . _('entropía') . '</em>:</dt><dd>' . $entropy . '%</dd>';
    }
    echo '<dt>' . _('noticias publicadas') . ':</dt><dd>' . $user->published_links . ' (' . $percent . '%)</dd>';
    echo '<dt>' . _('comentarios') . ':</dt><dd>' . $user->total_comments . '</dd>';
    echo '<dt>' . _('notas') . ':</dt><dd>' . $user->total_posts . '</dd>';
    echo '<dt>' . _('número de votos') . ':</dt><dd>' . $user->total_votes . '</dd>';
    echo '</dl>';
    echo '</div>';
    echo '</fieldset>';
    // Print GEO form
    if ($globals['do_geo'] && $current_user->user_id == $user->id) {
        echo '<div class="geoform">';
        geo_coder_print_form('user', $current_user->user_id, $globals['latlng'], _('ubícate en el mapa (si te apetece)'), 'user');
        echo '</div>';
    }
    // Show first numbers of the address if the user has god privileges
    if ($current_user->user_level == 'god' && $user->level != 'god' && $user->level != 'admin') {
        // tops and admins know each other for sure, keep privacy
        $addresses = $db->get_results("select INET_NTOA(vote_ip_int) as ip from votes where vote_type='links' and vote_user_id = {$user->id} order by vote_date desc limit 30");
        // Try with comments
        if (!$addresses) {
            $addresses = $db->get_results("select comment_ip as ip from comments where comment_user_id = {$user->id} and comment_date > date_sub(now(), interval 30 day) order by comment_date desc limit 30");
        }
        // Not addresses to show
        if (!$addresses) {
            return;
        }
        $clone_counter = 0;
        echo '<fieldset><legend>' . _('últimas direcciones IP') . '</legend>';
        echo '<ol>';
        $prev_address = '';
        foreach ($addresses as $dbaddress) {
            $ip_pattern = preg_replace('/\\.[0-9]+$/', '', $dbaddress->ip);
            if ($ip_pattern != $prev_address) {
                echo '<li>' . $ip_pattern . ': <span id="clone-container-' . $clone_counter . '"><!--<a href="javascript:get_votes(\'ip_clones.php\',\'' . $ip_pattern . '\',\'clone-container-' . $clone_counter . '\',0,' . $user->id . ')" title="' . _('clones') . '">&#187;&#187;</a>--></span></li>';
                $clone_counter++;
                $prev_address = $ip_pattern;
                if ($clone_counter >= 30) {
                    break;
                }
            }
        }
        echo '</ol>';
        echo '</fieldset>';
    }
}
Пример #6
0
// 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 . 'geo.php';
header('Content-Type: text/html; charset=UTF-8');
stats_increment('ajax');
if (!($id = intval($_REQUEST['id']))) {
    error(_('falta el id') . " {$link}");
}
$type = clean_input_string($_REQUEST['type']);
$icontype = clean_input_string($_REQUEST['icon']);
if ($type == 'link') {
    $link = new Link();
    $link->id = $id;
    if (!$link->read()) {
        error(_('Artículo inexistente'));
    }
    if (!$link->is_map_editable()) {
        error(_("noticia no modificable"));
    }
    $latlng = $link->get_latlng();
} else {
    error(_('tipo incorrecto'));
}
geo_coder_print_form($type, $id, $latlng, _('edición localización'), $icontype);
function error($mess)
{
    echo "ERROR: {$mess}\n";
    die;
}