示例#1
0
function print_result()
{
    global $response, $page_size;
    if ($response['ids']) {
        $rows = min($response['rows'], 1000);
        foreach ($response['ids'] as $id) {
            switch ($_REQUEST['w']) {
                case 'posts':
                    $obj = Post::from_db($id);
                    break;
                case 'comments':
                    $obj = Comment::from_db($id);
                    break;
                case 'links':
                default:
                    $obj = Link::from_db($id);
            }
            if (!$obj) {
                continue;
            }
            $obj->basic_summary = true;
            switch ($_REQUEST['w']) {
                case 'posts':
                    $obj->print_summary(800);
                    break;
                case 'comments':
                    if ($obj->type == 'admin' && !$current_user->admin) {
                        continue;
                    }
                    // link_object
                    $obj->print_summary(800);
                    break;
                case 'links':
                default:
                    $obj->print_summary();
            }
        }
    }
    do_pages($rows, $page_size);
}
示例#2
0
if ($votes_freq > $freq) {
    if ($current_user->user_id > 0 && $current_user->user_karma > 4) {
        // Crazy votes attack, decrease karma
        // she does not deserve it :-)
        $user = new User();
        $user->id = $current_user->user_id;
        $user->read();
        $user->karma = $user->karma - 0.1;
        $user->store();
        error(_('¡tranquilo cowboy!, tu karma ha bajado: ') . $user->karma);
    } else {
        error(_('¡tranquilo cowboy!'));
    }
}
$vote->value = $value * $current_user->user_karma;
$post = Post::from_db($id);
if (!$post) {
    error(_('nota no existente'));
}
if ($post->author == $current_user->user_id) {
    error(_('no puedes votar a tus comentarios'));
}
if ($post->date < time() - $globals['time_enabled_votes']) {
    error(_('votos cerrados'));
}
if (!$post->insert_vote($current_user->user_id, $vote->value)) {
    error(_('ya ha votado antes'));
}
$dict = array();
$dict['id'] = $id;
$dict['votes'] = $post->votes + 1;
示例#3
0
    //
    // 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();
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";
示例#4
0
文件: between.php 项目: manelio/woolr
 $id = intval($id);
 // Filter id, could be anything from $sorted
 if (!$show_thread) {
     if (isset($all[$id])) {
         foreach ($all[$id] as $e) {
             $leaves[$e] = true;
         }
     }
 }
 if (isset($leaves[$id])) {
     unset($leaves[$id]);
 }
 //$obj->basic_summary = true;
 switch ($type) {
     case 'posts':
         $obj = Post::from_db($id);
         break;
     case 'comments':
         $obj = Comment::from_db($id);
         break;
 }
 if (!$obj || $obj->type == 'admin' && !$current_user->admin) {
     continue;
 }
 if ($obj->author == $id1) {
     echo '<div style="margin-top: -10;margin-left: 10px; width:70%">';
 } else {
     echo '<div style="margin-top: -10;margin-left:30%">';
 }
 $obj->print_summary();
 echo "</div>\n";
示例#5
0
文件: index.php 项目: manelio/woolr
function print_answers($id, $level, $visited = false)
{
    // Print "conversation" for a given note
    global $db;
    if (!$visited) {
        $visited = array();
        $visited[] = $id;
    }
    $printed = array();
    $answers = $db->get_col("SELECT conversation_from FROM conversations WHERE conversation_type='post' and conversation_to = {$id} ORDER BY conversation_from asc LIMIT 100");
    $parent_reference = "/@\\p{L}[\\._\\p{L}\\d]+,{$id}/ui";
    // To check that the notes references to $id
    if ($answers) {
        echo '<div style="padding-left: 5%; padding-top: 5px;">';
        echo '<ol class="comments-list">';
        foreach ($answers as $post_id) {
            if (in_array($post_id, $visited)) {
                continue;
            }
            $answer = Post::from_db($post_id);
            if (!$answer) {
                continue;
            }
            if ($answer->user_level == 'autodisabled' || $answers->user_level == 'disabled') {
                continue;
            }
            // Check the post has a real reference to the parent (with the id), ignore othewrise
            if (!preg_match($parent_reference, $answer->content)) {
                continue;
            }
            echo '<li>';
            $answer->print_summary();
            echo '</li>';
            if ($level > 0) {
                $res = print_answers($answer->id, $level - 1, array_merge($visited, $answers));
                $visited = array_merge($visited, $res);
            }
            $printed[] = $answer->id;
            $visited[] = $answer->id;
        }
        echo '</ol>';
        echo '</div>';
        if ($level == 0) {
            Haanga::Load('get_total_answers_by_ids.html', array('type' => 'post', 'ids' => implode(',', $printed)));
        }
    }
    return $printed;
}
示例#6
0
文件: index.php 项目: rasomu/chuza
			if (overlay && overlay.myId > 0) {
				GDownloadUrl(base_url+"geo/"+overlay.myType+".php?id="+overlay.myId, function(data, responseCode) {
				overlay.openInfoWindowHtml(data);
				});
			} //else if (point) geo_map.panTo(point);
		});
	}
}
</script>
<?
} else {
	$posts = $db->get_results($sql);
	if ($posts) {
		echo '<ol class="comments-list">';
		foreach ($posts as $dbpost) {
			$post = Post::from_db($dbpost->post_id);
			if ( $post_id > 0 && $user->id > 0 && $user->id != $post->author) {
				echo '<li>'. _('Error: nota no existente') . '</li>';
			} else {
				echo '<li>';
				$post->print_summary();
				echo '</li>';
			}
		}
		echo "</ol>\n";

		// Print "conversation" for a given note
		if ($post_id > 0) {
			$sql = "SELECT conversation_from as post_id FROM conversations, posts WHERE conversation_type='post' and conversation_to = $post_id and post_id = conversation_from ORDER BY conversation_from asc LIMIT $page_size";
			$answers = $db->get_results($sql);
			if ($answers) {
示例#7
0
// It has to remove parenthesis
if (empty($_GET['what'])) {
    $what = 'link';
} else {
    $what = $_GET['what'];
}
$object = false;
switch ($what) {
    case 'link':
    case 'links':
        $object = Link::from_db($id, null, false);
        break;
    case 'comment':
    case 'comments':
        $object = Comment::from_db($id);
        break;
    case 'post':
    case 'posts':
        $object = Post::from_db($id);
        break;
}
if (!$object) {
    die;
}
$output = new stdClass();
foreach (preg_split('/,/', $fields, 10, PREG_SPLIT_NO_EMPTY) as $f) {
    if (!in_array($f, $forbidden) && property_exists($object, $f)) {
        $output->{$f} = $object->{$f};
    }
}
echo json_encode($output);
示例#8
0
<?php

// The source code packaged with this file is Free Software, Copyright (C) 2005-2011 by
// Ricardo Galli <gallir at gmail dot com>and Menéame Comunicacions
// 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".
// Use the alternate server for api, if it exists
// $globals['alternate_db_server'] = 'backend';
include '../config.php';
$id = intval($_GET['id']);
if (!$id) {
    die;
}
// Print answers to the comment
$sql = "SELECT conversation_from as comment_id FROM conversations, posts WHERE conversation_type='post' and conversation_to = {$id} and post_id = conversation_from ORDER BY conversation_from asc";
$res = $db->get_col($sql);
if ($res) {
    header('Content-Type: text/html; charset=UTF-8');
    foreach ($res as $answer) {
        $post = Post::from_db($answer);
        $post->basic_summary = true;
        $post->not_ignored = true;
        $post->prefix_id = "{$id}-";
        // This a trick in order not to confuse with other ids
        $post->print_summary();
        echo "\n";
    }
}