function edit_action($id) { $edit_row = get_post_by_id($id); //var_dump($edit_row); $posts = get_all_posts(); $html = render_template("view/templates/edit.php", array('id' => $id, 'edit_row' => $edit_row, 'posts' => $posts)); return new Response($html); }
<?php require_once 'model.php'; $post = get_post_by_id($_GET['id']); require 'templates/show.php';
function show_action($id) { $post = get_post_by_id($id); $html = render_template('templates/show.php', array('post' => $post)); return new Response($html); }
public function get_reply_to() { return get_post_by_id($this->reply_to); }
function show_action($id) { $post = get_post_by_id($id); require APPLICATION_PATH . '/views/post.html.php'; }
function show_action($id) { $post = get_post_by_id($id); require 'templates/show.php'; }
<?php include_once '../../../includes/user.php'; include_once '../../../includes/topic.php'; include_once '../../../includes/thread.php'; include_once '../../../includes/post.php'; include_once '../../../includes/parsedown.php'; include_once '../../../includes/htmlpurifier/HTMLPurifier.auto.php'; session_start(); if (isset($_GET['id']) && isset($_POST['post_id']) && isset($_SESSION['user']) && isset($_POST['reply'])) { $thread_id = $_GET['id']; $post_id = $_POST['post_id']; $user = $_SESSION['user']; $parsedown = new Parsedown(); $reply = $parsedown->text($_POST['reply']); $htmlpurifierconfig = HTMLPurifier_Config::createDefault(); $purifier = new HTMLPurifier($htmlpurifierconfig); $reply = $purifier->purify($reply); create_post(get_thread_by_id($thread_id), $user, $reply, get_post_by_id($post_id)); header("HTTP/1.1 303 See Other"); header("Location: /forum/thread/?id=" . $thread_id); } else { header("HTTP/1.1 400 Bad Request"); }
<?php require 'init.php'; $post_id = $_GET['id']; $post = get_post_by_id($post_id); if (!$post) { display_not_found_page(); } $comments = get_post_comments($post_id); $comment_text = ''; $errors = []; if ($_SERVER['REQUEST_METHOD'] == 'POST') { $comment_text = $_POST['comment']; if ($comment_text == '') { $errors[] = "Коментар не може бути порожнім."; } if (!$errors) { $user_id = get_current_user_id(); add_comment($post_id, $user_id, $comment_text); redirect(APP_URL . '/view_post.php?id=' . $post_id); } } ?> <!DOCTYPE html> <head> <meta charset="utf-8"> <title>Tubogram</title> <?php echo js_and_css(); ?>
function add_post_meta($post_id, $meta_key, $meta_value) { global $sn_sql; if (!check_empty($post_id) || !check_empty($meta_key) || !check_empty($meta_value)) { return false; } $post_id = (int) $post_id; $meta_key = mysql_real_escape_string($meta_key); $meta_value = mysql_real_escape_string($meta_value); $post = get_post_by_id($post_id); $meta_exist = get_post_meta($post_id, $meta_key); if (!empty($meta_exist)) { return false; // exist meta; } if (!$post) { return false; } $sql_c = "INSERT INTO `post_meta` VALUES (null, {$post_id}, '{$meta_key}', '{$meta_value}')"; $meta = $sn_sql->query($sql_c); if (!$meta) { return false; } return $sn_sql->connect->insert_id; }