本文整理汇总了PHP中post类的典型用法代码示例。如果您正苦于以下问题:PHP post类的具体用法?PHP post怎么用?PHP post使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了post类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: q_header
function q_header($database, &$array)
{
$dk = 1;
$search = 0;
$orderby = 'ORDER BY post_on DESC';
$limit = ' LIMIT 0, 10 ';
if (!empty($_GET['post_permalink'])) {
$value = addslashes($_GET['post_permalink']);
$dk = array('post_permalink' => $value);
}
if (!empty($_GET['cat_permalink'])) {
$value = addslashes($_GET['cat_permalink']);
$dk = array('cat_permalink' => $value);
}
if (!empty($_GET['author'])) {
$value = addslashes($_GET['author']);
$dk = array('user_name' => $value);
}
if (!empty($_GET['search'])) {
$search = 1;
$value = addslashes($_GET['search']);
$dk = array('post_name' => $value);
}
$post = new post($database);
$post->have_posts($dk, $search, $orderby, $limit);
if (isset($post->r)) {
if (mysqli_num_rows($post->r) > 0) {
while ($m = mysqli_fetch_array($post->r, MYSQLI_ASSOC)) {
$array[] = $m;
}
}
}
// print_r($array);
}
示例2: adminNotify
public function adminNotify()
{
if ($this->cookie->check("id_user") and $this->cookie->id_user == 1) {
//no notificamos a administrador de su propio comentario.
return;
}
$id = $this->registry->lastCommentID;
$Comment = new comment();
$comment = $Comment->find($id);
$comment['content'] = utils::nl2br($comment['content']);
if (!defined('GESHI_VERSION')) {
$comment['content'] = $this->comment_source_code_beautifier($comment['content'], 'addTagPRE');
} else {
$comment['content'] = $this->comment_source_code_beautifier($comment['content']);
}
$User = new user();
$user = $User->find(1);
$Post = new post();
$post = $Post->find($comment['ID_post']);
$commentsWaiting = $Comment->countCommentsByPost(null, 'waiting');
$mailStr = "\n\t\t\t<table width=\"100%\">\n\t\t\t<tr>\n\t\t\t\t<td>\n\t\t\t\t\t<small>\n\t\t\t\t\t\t<strong>From IP</strong>: {$comment['IP']}<br />\n\t\t\t\t\t\t<strong>URL</strong>: <a href=\"{$comment['url']}\">{$comment['url']}</a><br />\n\t\t\t\t\t\t<strong>Email</strong>: <a href=\"mailto:{$comment['email']}\">{$comment['email']}</a><br />\n\t\t\t\t\t\t<strong>DateTime</strong>: {$comment['created']}<br />\n\t\t\t\t\t</small>\n\t\t\t\t\t<hr>\n\t\t\t\t\t<strong>Author</strong>: {$comment['author']}<br />\n\t\t\t\t</td>\n\t\t\t</tr>\n\t\t\t\n\t\t\t<tr><td><strong>Content</strong></td></tr>\n\t\t\t<tr><td bgcolor=\"#f7f7f7\">\n\t\t\t\t{$comment['content']}\n\t\t\t\t<hr />\n\t\t\t</td></tr>\n\t\t\t\n\t\t\t<tr>\n\t\t\t\t<td>\n\t\t\t\t\t<p>\n\t\t\t\t\t\tModerate comment: <a href=\"{$this->registry->path}comments/edit/{$comment['ID']}\">{$this->registry->path}comments/edit/{$comment['ID']}</a><br />\n\t\t\t\t\t\tView entry: <a href=\"{$this->registry->path}{$post['urlfriendly']}\">{$this->registry->path}{$post['urlfriendly']}</a>\n\t\t\t\t\t</p>\n\t\t\n\t\t\t\t\t<p>\n\t\t\t\t\t\tThere are {$commentsWaiting} comments waiting for approbal. <br />\n\t\t\t\t\t\tPlease moderate comments: <a href=\"{$this->registry->path}comments/waiting\">{$this->registry->path}comments</a>\n\t\t\t\t\t</p>\n\t\t\t\t</td>\n\t\t\t</tr>\n\t\t\t\n\t\t\t</table>\n\t\t";
$conf = $this->registry->conf;
$subject = "[{$conf['blog_name']}] Nuevo Comentario en: {$post['title']}";
$this->enviaMail($user['email'], $subject, $mailStr, $user['email']);
}
示例3: getPosts
public function getPosts($status = null, $limitQuery = null)
{
$P = new post();
$posts = array();
if (is_null($status) === true) {
$posts = $P->findAll("ID,id_user,urlfriendly,title,IF(POSITION('<!--more-->' IN content)>0,MID(content,1,POSITION('<!--more-->' IN content)-1),content) as content, created", 'ID DESC', $limitQuery, null);
} else {
if (is_array($status) === false) {
$posts = $P->findAll("ID,id_user,urlfriendly,title,IF(POSITION('<!--more-->' IN content)>0,MID(content,1,POSITION('<!--more-->' IN content)-1),content) as content, created", 'ID DESC', $limitQuery, "WHERE status='{$status}'");
} else {
$status_sql = "";
foreach ($status as $st) {
$status_sql .= "status ='{$st}' OR ";
}
$status_sql = substr($status_sql, 0, -3);
$posts = $P->findAll("ID,id_user,urlfriendly,title,IF(POSITION('<!--more-->' IN content)>0,MID(content,1,POSITION('<!--more-->' IN content)-1),content) as content, created", 'ID DESC', $limitQuery, "WHERE ({$status_sql})");
}
}
$C = new comment();
foreach ($posts as $k => $p) {
$posts[$k]['title'] = htmlspecialchars($posts[$k]['title']);
$posts[$k]['tags'] = $this->getTags($posts[$k]['ID']);
$posts[$k]['comments_count'] = $C->countCommentsByPost($posts[$k]['ID'], "publish");
$U = new user();
if ($posts[$k]['id_user'] < 2) {
$posts[$k]['autor'] = $U->find(1);
} else {
$posts[$k]['autor'] = $U->find($posts[$k]['id_user']);
}
}
return $posts;
}
示例4: createPost
/**
* Create a post
*/
public static function createPost()
{
if (!Flight::has('currentUser')) {
Flight::redirect('/');
}
$post = new post(['user' => Flight::get('currentUser')->id, 'title' => Flight::request()->data->title, 'content' => Flight::request()->data->content]);
$post->store();
}
示例5: getPosts
function getPosts($dbh)
{
$stmt = $dbh->prepare("select * from " . post::$table_name . " ORDER BY id DESC;");
$stmt->execute();
$result = array();
while ($row = $stmt->fetch()) {
$p = new post();
$p->copyFromRow($row);
$result[] = $p;
}
return $result;
}
示例6: posts_of_user
public function posts_of_user($orderby = 'ORDER BY post_on DESC', $limit = 0)
{
if ($this->is_admin()) {
$post = new post($this->db);
$post->posts_of_user(array('user_id' => $this->user_id), 0, $orderby, $limit);
if (mysqli_num_rows($post->r) > 0) {
$this->post = $post->r;
return true;
} else {
return false;
}
} else {
return false;
}
}
示例7: rss
public function rss($id = NULL)
{
$this->plugin->call('feed_header');
$post = new post();
$this->view->conf = $this->conf;
$this->view->setLayout("feed");
$posts = $post->findAll("ID,urlfriendly,title,IF(POSITION('<!--more-->' IN content)>0,MID(content,1,POSITION('<!--more-->' IN content)-1),content) as content, created", "ID DESC", $this->conf['blog_posts_per_page'], "WHERE status = 'publish'");
$temp = array();
foreach ($posts as $a_post) {
$temp[$a_post['ID']] = $a_post;
$temp[$a_post['ID']]['tags'] = $post->getTags($a_post['ID'], 'string');
}
$this->view->posts = $temp;
$this->render("rss");
}
示例8: __construct
function __construct()
{
$this->session = session::getInstance();
$this->post = post::getInstance();
$this->get = get::getInstance();
$this->http = http::getInstance();
$this->file = new file();
$this->cookie = new cookie(config('cookie'));
}
示例9: __construct
function __construct()
{
$this->session = session::getInstance();
$this->post = post::getInstance();
$this->get = get::getInstance();
$this->http = http::getInstance();
$this->file = file::getInstance();
$this->cookie = cookie::getInstance();
}
示例10: update
/**
* Update the specified resource in storage.
*
* @param Request $request
* @param int $id
* @return Response
*/
public function update(PostEditFormRequest $request, $id)
{
//Actualiza un post
$post = post::whereId($id)->firstOrFail();
$post->title = $request->get('title');
$post->content = $request->get('content');
$post->slug = Str::slug($request->get('title'), '-');
$post->save();
$post->categories()->sync($request->get('categories'));
return redirect(action('Admin\\PostsController@edit', $post->id))->with('status', 'The post has been updated!');
}
示例11: submit
public function submit()
{
$post = $_POST;
$file = $_FILES['file_upload'];
$request = new post($post, $file);
$submission = $request->getPost();
$database = new database();
$query = $database->query();
$image = new image($query, $submission);
// upload image
try {
$upload = $image->upload();
} catch (Exception $e) {
echo 'Message: ' . $e->getMessage();
}
// insert image
if (isset($upload) && $upload == 'success') {
$images = new image($query, $submission);
$image->insert();
}
}
示例12: edit
public function edit($id = NULL)
{
$id = (int) $id;
if (!$id) {
$this->redirect('comments');
}
$this->view->conf = $this->conf;
$Comment = new comment();
$comment = $Comment->find($id);
$comment['content'] = utils::convert2HTML($comment['content']);
$Post = new post();
$post = $Post->findBy('ID', $comment['ID_post']);
$comment['post'] = array('urlfriendly' => $post['urlfriendly'], 'title' => $post['title']);
$this->view->comment = $comment;
$this->view->id = $id;
$statuses = array("publish", "waiting");
$this->view->statuses = $statuses;
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if (isset($_POST['cancelar'])) {
$this->redirect("comments");
} else {
###########
# Las siguientes dos lineas no deberian estar pero algo anda mal con el ActiveRecord que no deja las variables
# de las consultas que se realizan directamente desde dentro de algun metodo en el model con $this->db->query e interfiere
# con el actualizar por que podria haber campos que no se requieren en la actualizacion.
###########
$comment = new comment();
#######
$comment->find($id);
#######
$comment->prepareFromArray($_POST);
$comment->save();
$this->redirect("comments/edit/{$id}");
}
} else {
$this->view->setLayout("admin");
$this->title_for_layout($this->l10n->__("Editar comentario - Codice CMS"));
$this->render();
}
}
示例13: get
/**
* Load post from database. Returns false, if the post doesn't exist
* @param int $post_id
* @return boolean|Gn36\OoPostingApi\post
*/
static function get($post_id)
{
global $db;
$sql = "SELECT * FROM " . POSTS_TABLE . " WHERE post_id=" . intval($post_id);
$result = $db->sql_query($sql);
$post_data = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
if (!$post_data) {
//post does not exist, return false
return false;
}
return post::from_array($post_data);
}
示例14: index
public function index($id = NULL, $page = 1)
{
if (is_null($id) or is_numeric($id)) {
$this->redirect($this->conf['blog_siteurl']);
}
$tag = $id;
$post = new post();
$link = new link();
$comment = new comment();
$this->html->useTheme($this->conf['blog_current_theme']);
$info = array();
$info["isAdmin"] = false;
if ($this->cookie->check("logged") and $this->cookie->id_user == 1) {
$info["isAdmin"] = true;
}
$this->themes->info = $info;
$includes['charset'] = $this->html->charsetTag("UTF-8");
$includes['rssFeed'] = $this->html->includeRSS();
if ($page > 1) {
$includes['canonical'] = "<link rel=\"canonical\" href=\"{$this->conf['blog_siteurl']}/tag/" . rawurlencode($post->sql_escape($id)) . "/{$page}\" />";
} else {
$includes['canonical'] = "<link rel=\"canonical\" href=\"{$this->conf['blog_siteurl']}/tag/" . rawurlencode($post->sql_escape($id)) . "\" />";
}
$this->registry->includes = $includes;
$this->plugin->call('index_includes');
$includes = null;
foreach ($this->registry->includes as $include) {
$includes .= $include;
}
$this->themes->includes = $includes;
$this->themes->links = $link->findAll();
$this->themes->single = false;
$total_rows = $post->countPosts(array('status' => 'publish', 'tag' => $tag));
$page = (int) is_null($page) ? 1 : $page;
$limit = $this->conf['blog_posts_per_page'];
$offset = ($page - 1) * $limit;
$limitQuery = $offset . "," . $limit;
$targetpage = $this->path . "tag/{$tag}/";
$this->themes->pagination = $this->pagination->init($total_rows, $page, $limit, $targetpage);
$posts = $post->getPostsByTag($tag, $limitQuery);
foreach ($posts as $k => $p) {
$posts[$k]['title'] = htmlspecialchars($p['title']);
$posts[$k]['tags'] = $post->getTags($p['ID']);
$posts[$k]['comments_count'] = $comment->countCommentsByPost($posts[$k]['ID']);
$user = new user();
if ($posts[$k]['id_user'] < 2) {
$posts[$k]['autor'] = $user->find(1);
} else {
$posts[$k]['autor'] = $user->find($posts[$k]['id_user']);
}
}
$this->registry->posts = $posts;
$this->plugin->call("index_post_content");
$this->themes->posts = $this->registry->posts;
$this->themes->title_for_layout = "{$this->conf['blog_name']} - {$tag}";
$this->render();
}
示例15: post
<?php
//number of comments/page
$limit = 10;
//number of pages to display. number - 1. ex: for 5 value should be 4
$page_limit = 6;
//Load required class files. post.class and cache.class
$post = new post();
$cache = new cache();
header("Cache-Control: store, cache");
header("Pragma: cache");
$domain = $cache->select_domain();
$id = $db->real_escape_string($_GET['id']);
if (!is_numeric($id)) {
$id = str_replace("#", "", $id);
}
$id = (int) $id;
$date = date("Ymd");
//Load post_table data and the previous next values in array. 0 previous, 1 next.
$post_data = $post->show($id);
//Check if data exists in array, if so, kinda ignore it.
if ($post_data == "" || is_null($post_data)) {
header('Location: index.php?page=post&s=list');
exit;
}
$prev_next = $post->prev_next($id);
if (!is_dir("{$main_cache_dir}" . "" . "\\cache/{$id}")) {
$cache->create_page_cache("cache/{$id}");
}
$data = $cache->load("cache/" . $id . "/post.cache");
if ($data !== false) {