function postEditAction() { $data = isset($_POST['post']) ? $_POST['post'] : []; $errors = []; $post = []; if (isset($data['id'])) { $id = $data['id']; } else { if (isset($_GET['id'])) { $id = $_GET['id']; } } if (isset($id)) { $post = getPostById((int) $id); if (!$post) { header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found'); exit('Post not found'); } } if ($data) { $msg = 'Запись успешно ' . (isset($post['id']) ? 'обновлена' : 'добавлена'); $post = savePost($data, $errors); if (!$errors) { addFlashMessages($msg); header('location: index.php?r=post/edit&id=' . $post['id']); exit; } } /* * Мы попадаем сюда в 4-х случаях: * 1) форма не была отправлена, id не найден => добавить новую запись * 2) форма не была отправлена, id найден => вывести форму для редактирования существующей записи * 3) форма была отправлена, id не найден => добавление новой записи, но введенные данные не корректны * 4) форма была отправлена, id найден => редактирование записи, но введенные данные не корректны */ var_dump($post, $errors); require_once __DIR__ . '/../views/edit.php'; }
$form_valid = false; } // action taken if form filled in correctly... if ($form_valid == true) { updatePost($_GET['id'], $_SESSION['userId'], $_POST['title'], $_POST['editor1'], $_POST['category']); // variables set to createPost function for insertion into db... header('Location: ?page=cmsUpdated&goto=cmsPostsTable'); } } $id = $_GET['id']; $post = getPostById($id); include VIEWS . 'contentCMSUpdate.php'; break; case 'delete': $id = $_GET['id']; if (!empty($_POST)) { if ($_POST['deleteConf'] == 'Yes') { deletePost($id); header('Location: ?page=cmsUpdated&goto=cmsPostsTable'); } elseif ($_POST['deleteConf'] == 'No') { header('Location: ?page=cmsPostsTable'); } } $post = getPostById($id); include VIEWS . 'contentCMSDelete.php'; break; } } else { $posts = getAllPostsCMS(); include VIEWS . 'contentCMSPostsTable.php'; }
?> <title>Create/Edit Post >> ON DEMAND</title> <?php require "styles.php"; require "scripts.php"; ?> <?php require "HTML_top2.php"; ?> <?php $class = getClassById($_GET["cid"]); if (isset($_GET['pid'])) { $post = getPostById($_GET["pid"], $class->number); } require "topBar.php"; $uploadMsg = "Video files must be in .flv (Flash video) format and not exceed 10 MB in size.<br/>The video upload cap is currently subject to change, as we continue to optimize the site.<br/><br/>The video player on this site has a widescreen (16:9) aspect ratio with a resolution of 640x360 pixels.<br/>We suggest your video file match the video player's resolution or match 480x360 pixels if your video has a letterbox (4:3) aspect ratio."; if (isset($_GET['pid'])) { echo '<h5>Edit Post: ' . $post->title . '</h5>'; echo '<form action="post.php?cid=' . $_GET['cid'] . '&pid=' . $_GET['pid'] . '" method="post">'; echo '<input type="text" name="edit_post_title" value="' . $post->title . '" size="50" /><br/>'; echo '<input type="text" name="edit_post_topic" value="' . $post->topic . '" size="50" /><br/>'; echo '<textarea name="edit_post_description" rows="10" cols="50">' . $post->description . '</textarea><br/>'; echo '<input type="submit" name="edit_post" value="Submit Changes" />'; echo '<a href="post.php?cid=' . $_GET['cid'] . '&pid=' . $_GET['pid'] . '"><input type="button" value="Cancel" /></a>'; echo '</form><br/>'; echo '<form action="class.php?cid=' . $_GET['cid'] . '" method="post" class="right" onsubmit="return confirm(\'Are you sure you want to delete this post?\')">'; echo '<input type="hidden" name="edit_post_delete_pid" value="' . $post->getId() . '" />'; echo '<input type="submit" name="edit_post_delete" value="Delete Post" />';
include_once __DIR__ . "/" . "../controller/post_controller.php"; include_once __DIR__ . "/" . "../controller/image_controller.php"; session_start(); if (!isset($_SESSION["userLogged"])) { session_destroy(); //redirect login page header("location: ../login.php"); } else { $userLogged = $_SESSION["userLogged"]; } function acquireGetParamethers() { return $_GET["id"]; } $resp = null; $resp = getPostById(acquireGetParamethers()); if ($resp["response"]) { $postOnGet = $resp["latestPost"]; } else { $postOnGet = new Post(0, 0, 'titolo', 'sottotitolo', 'testo', 'preview', 'immagine', '1991-01-01'); } ?> <!DOCTYPE html> <html> <head> <?php include_once "admin_head.html"; ?> </head> <body>
<?php require_once __DIR__ . '/app/init.php'; $post = getPostById(isset($_GET['id']) ? $_GET['id'] : ''); if (!$post) { header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not found'); //под сервер протокол лежит адрес. то есть написано будет "адрес" не найден" exit('Post not found!'); } //var_dump($post); require_once __DIR__ . '/app/views/show.php';
<?php // controller for individual post display page... include DATA . 'posts.php'; include DATA . 'comments.php'; // set error array key value pairs so that correct error messages displayed... $error = array('editor1' => ''); $postId = $_GET['id']; $post = getPostById($postId); $comments = getAllPostComments($postId); if (!empty($_POST)) { $form_valid = true; // sanitization... $_POST['editor1'] = trim($_POST['editor1']); //validation if ($_POST['editor1'] == '') { $error['editor1'] = 'You have not entered any content! Try again yeh...?'; $form_valid = false; } // action taken if form filled in correctly... if ($form_valid == true) { createComment($post['userId'], $_GET['id'], $_POST['editor1']); // variables sent to createComment function for insertion into db... header('Location: ?page=postDisplay&id=' . $_GET['id']); // reloads the page with new comment... } } include VIEWS . 'header.php'; include VIEWS . 'contentPostDisplay.php'; include VIEWS . 'footer.php';
//var_dump($_POST); require_once __DIR__ . '/app/models/post.php'; require_once __DIR__ . '/libs/storage.php'; require_once __DIR__ . '/libs/viev.php'; $data = isset($_POST['post']) ? $_POST['post'] : []; $post = []; $errors = []; if (isset($data['id'])) { $id = $data['id']; } else { if (isset($_GET['id'])) { $id = $_GET['id']; } } if (isset($id)) { $post = getPostById((int) $id); if (!$post) { header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not found'); exit('Post not found!'); } } if ($data) { $post = savePost($data, $errors); if (!$errors) { // запись успешно сохранена header('location: edit.php?id=' . $post['id']); exit; } } ?> <!Doctype html>
<?php include_once 'include/config.php'; include_once 'include/functions.php'; if ($_GET['action'] == 'home') { $data = getAllPost(); echo prepareJsonOutput(1, $data); } elseif ($_GET['action'] == 'blog_details') { $data = getPostById($_GET['blogId']); echo prepareJsonOutput(1, $data); }