本文整理汇总了PHP中Post::read方法的典型用法代码示例。如果您正苦于以下问题:PHP Post::read方法的具体用法?PHP Post::read怎么用?PHP Post::read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Post
的用法示例。
在下文中一共展示了Post::read方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: edit
function edit($id = null)
{
if (!$id && empty($this->data)) {
$this->flash(__('Invalid Post', true), array('action' => 'index'));
}
if (!empty($this->data)) {
if ($this->Post->save($this->data)) {
$this->flash(__('The Post has been saved.', true), array('action' => 'index'));
} else {
}
}
if (empty($this->data)) {
$this->data = $this->Post->read(null, $id);
//$this->data = $this->Post->find('first', array('conditions' => array('_id' => $id)));
}
}
示例2: header
if (!$date) {
$date = $globals['now'];
}
$id = (int) $db->get_var("select post_id from posts, users where user_login = '{$user}' and post_user_id = user_id and post_date < FROM_UNIXTIME({$date}) order by post_date desc limit 1");
}
if (!$id > 0) {
// Check if the user exists
$uid = (int) $db->get_var("select user_id from users where user_login = '{$user}' limit 1");
if (!$uid) {
not_found('<strong>Error: </strong>' . _('usuario inexistente'));
} else {
header('Location: http://' . get_server_name() . post_get_base_url($user));
die;
}
die;
}
} else {
$id = intval($_GET['id']);
}
} else {
die;
}
$post = new Post();
$post->id = $id;
$post->read();
if (!$post->read) {
not_found('<strong>Error: </strong>' . _('nota no encontrada'));
die;
}
header('Location: http://' . get_server_name() . post_get_base_url($post->id));
echo $link;
示例3: do_best_posts
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);
}
}
示例4: do_best_posts
function do_best_posts()
{
global $db, $globals, $dblang;
if ($globals['mobile']) {
return;
}
$output = '';
$key = 'best_posts_' . $globals['site_shortname'] . $globals['v'];
if (memcache_mprint($key)) {
return;
}
echo '<!-- Calculating ' . __FUNCTION__ . ' -->';
$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) {
$objects = array();
$title = _('mejores notas');
$url = post_get_base_url('_best');
foreach ($res as $p) {
$obj = new stdClass();
$post = new Post();
$post->id = $p->post_id;
$post->read();
$obj->id = $post->id;
$obj->link = post_get_base_url() . $post->id;
$obj->user_id = $post->author;
$obj->avatar = $post->avatar;
$obj->title = text_to_summary($post->clean_content(), 80);
$obj->username = $post->username;
$obj->tooltip = 'p';
$objects[] = $obj;
}
$vars = compact('objects', 'title', 'url');
$output = Haanga::Load('best_comments_posts.html', $vars, true);
echo $output;
memcache_madd($key, $output, 300);
}
}
示例5: save_post
function save_post($post_id)
{
global $link, $db, $post, $current_user, $globals, $site_key;
$post = new Post();
$_POST['post'] = clean_text_with_tags($_POST['post'], 0, false, $globals['posts_len']);
if (mb_strlen($_POST['post']) < 5) {
echo 'ERROR: ' . _('texto muy corto');
die;
}
if ($post_id > 0) {
$post->id = $post_id;
if (!$post->read()) {
die;
}
if ((intval($_POST['user_id']) == $current_user->user_id && $current_user->user_id == $post->author && time() - $post->date < 3600 || $current_user->user_level == 'god' && time() - $post->date < 864000) && $_POST['key'] == $post->randkey) {
$post->content = $_POST['post'];
if (strlen($post->content) > 0) {
$post->store();
}
} else {
echo 'ERROR: ' . _('no tiene permisos para grabar');
die;
}
} else {
if ($current_user->user_id != intval($_POST['user_id'])) {
die;
}
if ($current_user->user_karma < $globals['min_karma_for_posts']) {
echo 'ERROR: ' . _('el karma es muy bajo');
die;
}
// Check the post wasn't already stored
$post->randkey = intval($_POST['key']);
$post->author = $current_user->user_id;
$post->content = $_POST['post'];
$dupe = intval($db->get_var("select count(*) from posts where post_user_id = {$current_user->user_id} and post_date > date_sub(now(), interval 1 hour) and post_randkey = {$post->randkey}"));
if (!$dupe && !$post->same_text_count()) {
// Verify that there are a period of 1 minute between posts.
if (intval($db->get_var("select count(*) from posts where post_user_id = {$current_user->user_id} and post_date > date_sub(now(), interval 1 minute)")) > 0) {
echo 'ERROR: ' . _('debe esperar 1 minuto entre notas');
die;
}
$same_links = $post->same_links_count();
if ($same_links > 2) {
$user = new User();
$user->id = $current_user->user_id;
$user->read();
$reduction = $same_links * 0.2;
$user->karma = $user->karma - $reduction;
syslog(LOG_NOTICE, "Meneame: post_edit decreasing {$reduction} of karma to {$user->username} (now {$user->karma})");
$user->store();
$annotation = new Annotation("karma-{$user->id}");
$annotation->append(_('demasiados enlaces al mismo dominio en las notas') . ": -{$reduction}, karma: {$user->karma}\n");
}
// Check again for last seconds, ajax calls sometimes add two posts
$dupe = intval($db->get_var("select count(*) from posts where post_user_id = {$current_user->user_id} and post_date > date_sub(now(), interval 10 second) and post_randkey = {$post->randkey}"));
if (!$dupe) {
$post->store();
}
} else {
echo 'ERROR: ' . _('comentario grabado previamente');
die;
}
}
$post->print_summary();
}
示例6: save_post
function save_post($post_id)
{
global $link, $db, $post, $current_user, $globals, $site_key;
$post = new Post();
$_POST['post'] = clean_text($_POST['post'], 0, false, 300);
if (mb_strlen($_POST['post']) < 5) {
echo 'ERROR: ' . _('texto muy corto');
die;
}
if ($post_id > 0) {
$post->id = $post_id;
if (!$post->read()) {
die;
}
if ((intval($_POST['user_id']) == $current_user->user_id && $current_user->user_id == $post->author && time() - $post->date < 3600 || $current_user->user_level == 'god' && time() - $post->date < 864000) && $_POST['key'] == $post->randkey) {
$post->content = $_POST['post'];
if (strlen($post->content) > 0) {
$post->store();
}
} else {
echo 'ERROR: ' . _('no tiene permisos para grabar');
die;
}
} else {
if ($current_user->user_id != intval($_POST['user_id'])) {
die;
}
if ($current_user->user_karma < $globals['min_karma_for_posts']) {
echo 'ERROR: ' . _('el karma es muy bajo');
die;
}
// Check the post wasn't already stored
$post->randkey = intval($_POST['key']);
$post->author = $current_user->user_id;
$post->content = $_POST['post'];
$already_stored = intval($db->get_var("select count(*) from posts where post_user_id = {$current_user->user_id} and post_date > date_sub(now(), interval 12 hour) and post_randkey = {$post->randkey}")) + $post->same_text_count();
if (!$already_stored) {
// Verify that there are a period of 1 minute between posts.
if (intval($db->get_var("select count(*) from posts where post_user_id = {$current_user->user_id} and post_date > date_sub(now(), interval 1 minute)")) > 0) {
echo 'ERROR: ' . _('debe esperar 1 minuto entre notas');
die;
}
$same_links = $post->same_links_count();
if ($same_links > 2) {
require_once mnminclude . 'user.php';
$user = new User();
$user->id = $current_user->user_id;
$user->read();
$reduction = $same_links * 0.2;
$user->karma = $user->karma - $reduction;
syslog(LOG_NOTICE, "Meneame: post_edit decreasing {$reduction} of karma to {$user->username} (now {$user->karma})");
$user->store();
}
$post->store();
} else {
echo 'ERROR: ' . _('comentario grabado previamente');
die;
}
}
$post->print_summary();
}
示例7: header
<?php
// The source code packaged with this file is Free Software, Copyright (C) 2005 by
// 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".
// The code below was made by Beldar <beldar at gmail dot com>
if (!defined('mnmpath')) {
include_once '../config.php';
header('Content-Type: text/html; charset=utf-8');
}
if (empty($_GET['id'])) {
die;
}
$id = intval($_GET['id']);
$post = new Post();
$post->id = $id;
if (!$post->read()) {
die;
}
if (!$post->read) {
die;
}
$post->print_text(0);
示例8:
}
}
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) {
$answer = new Post;
echo '<div style="padding-left: 40px; padding-top: 10px">'."\n";
//echo '<h3>'._('Respuestas').'</h3>';
echo '<ol class="comments-list">';
foreach ($answers as $dbanswer) {
$answer->id = $dbanswer->post_id;
$answer->read();
echo '<li>';
$answer->print_summary();
echo '</li>';
}
echo "</ol>\n";
echo '</div>'."\n";
}
}
}
echo '</div>';
do_pages($rows, $page_size);
}
echo '</div>';
if ($rows > 15) do_footer_menu();
示例9: save_post
function save_post($post_id)
{
global $link, $db, $post, $current_user, $globals, $site_key;
$post = new Post();
$_POST['post'] = clean_text_with_tags($_POST['post'], 0, false, $globals['posts_len']);
if (!empty($_FILES['image']['tmp_name'])) {
$limit_exceded = Upload::current_user_limit_exceded($_FILES['image']['size']);
if ($limit_exceded) {
echo 'ERROR: ' . $limit_exceded;
die;
}
}
if (mb_strlen($_POST['post']) < 5) {
echo 'ERROR: ' . _('texto muy corto');
die;
}
if ($post_id > 0) {
$post->id = $post_id;
if (!$post->read()) {
die;
}
if ((intval($_POST['user_id']) == $current_user->user_id && $current_user->user_id == $post->author && time() - $post->date < 3600 || $current_user->user_level == 'god' && time() - $post->date < $globals['posts_edit_time_admin'] * 1.5) && $_POST['key'] == $post->randkey) {
$post->content = $_POST['post'];
if (strlen($post->content) > 0) {
$post->store();
store_image($post);
}
} else {
echo 'ERROR: ' . _('no tiene permisos para grabar');
die;
}
} else {
if ($current_user->user_id != intval($_POST['user_id'])) {
die;
}
if ($current_user->user_karma < $globals['min_karma_for_posts']) {
echo 'ERROR: ' . _('el karma es muy bajo');
die;
}
// Check the post wasn't already stored
$post->randkey = intval($_POST['key']);
$post->author = $current_user->user_id;
$post->content = $_POST['post'];
// Verify that there are a period of 1 minute between posts.
if (intval($db->get_var("select count(*) from posts where post_user_id = {$current_user->user_id} and post_date > date_sub(now(), interval " . $globals['posts_period'] . " second)")) > 0) {
echo 'ERROR: ' . _('debe esperar entre notas');
die;
}
$same_text = $post->same_text_count();
$same_links = $post->same_links_count(10);
$db->transaction();
$r = $db->get_var("select count(*) from posts where post_user_id = {$current_user->user_id} and post_date > date_sub(now(), interval 5 minute) and post_randkey = {$post->randkey} FOR UPDATE");
$dupe = intval($r);
if (!is_null($r) && !$dupe && !$same_text) {
if ($same_links > 2) {
$reduction = $same_links * 0.2;
$user = new User($current_user->user_id);
$user->add_karma(-$reduction, _('demasiados enlaces al mismo dominio en las notas'));
syslog(LOG_NOTICE, "Meneame: post_edit decreasing {$reduction} of karma to {$user->username} (now {$user->karma})");
}
$post->store();
$db->commit();
store_image($post);
} else {
$db->commit();
echo 'ERROR: ' . _('comentario grabado previamente');
die;
}
}
$post->print_summary();
}