示例#1
0
require_once '../requires/session.php';
if (!isset($_SESSION['username'])) {
    header("Location: login.php");
    exit;
}
require_once '../requires/header.php';
require_once '../requires/functions.php';
use Ecvdphp\User;
use Ecvdphp\Post;
if (isset($_POST) && isset($_POST['edit_article'])) {
    Post::editPost($_GET['id'], $_POST['title'], $_POST['body']);
}
if (isset($_GET['id'])) {
    $user = User::getUser();
    $post = Post::getPostById($user['id'], $_GET['id']);
    if (!$post) {
        echo "This post doesn't exist.";
    } else {
        if ($post['image_id'] !== null) {
            $picture = User::getFileById($post['image_id']);
        }
        ?>

			<a href="post.php?id=<?php 
        echo $_GET['id'];
        ?>
">Get back on post</a>

			<form action="edit.php?id=<?php 
        echo $_GET['id'];
示例#2
0
<?php

require_once '../requires/session.php';
require_once '../requires/header.php';
require_once '../requires/functions.php';
use Ecvdphp\User;
use Ecvdphp\Post;
$user = User::getUser();
$all_posts = Post::getAllPosts($user['id']);
if (isset($_POST) && isset($_POST['post_article'])) {
    Post::insertPost();
}
?>

<h1>Voir les articles</h1>

<details>

	<?php 
foreach ($all_posts as $post) {
    ?>
		<div>
			<a href="post.php?id=<?php 
    echo $post['id'];
    ?>
"><?php 
    echo $post['title'];
    ?>
</a>
		</div>
	<?php 
示例#3
0
<?php

require_once '../requires/session.php';
if (!isset($_SESSION['username'])) {
    header("Location: login.php");
    exit;
}
require_once '../requires/header.php';
require_once '../requires/functions.php';
use Ecvdphp\User;
use Ecvdphp\Post;
if (isset($_GET['id'])) {
    $user = User::getUser();
    $post = Post::getPostById($user['id'], $_GET['id']);
    if (isset($_POST) && isset($_POST['delete_post'])) {
        Post::deletePost($_GET['id']);
    } else {
        if (!$post) {
            echo "This post doesn't exist.";
        } else {
            if ($post['image_id'] !== null) {
                $picture = User::getFileById($post['image_id']);
            }
            ?>
			<a href="index.php">Retour sur les posts</a>
			<h1><?php 
            echo $post['title'];
            ?>
</h1>

			<p><?php