Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- intodb_add_post_php
- <?php
- include 'intodb_functions.php';
- include '../../db.php';
- ob_start();
- global $connection;
- if (isset($_POST['addPost_submit'])) {
- $post_title = mysqli_real_escape_string($_POST['addPost_post_title']) ;
- $post_author = mysqli_real_escape_string($_POST['addPost_post_author']) ;
- $post_category = (int)mysqli_real_escape_string($_POST['addPost_post_category']) ;
- $post_tags = mysqli_real_escape_string($_POST['addPost_post_tags']) ;
- // $post_image = escape($_POST['addPost_post_image']) ;
- $post_content = mysqli_real_escape_string($_POST['addPost_post_content']) ;
- $post_date = date( "\D\a\y y,m,d" ). ' Time '. date("H:i:s") ;
- $post_views_counts = 13;
- $post_likes = 14;
- $post_user_id = 12;
- $post_comment_counts = 15;
- $post_status = (int)mysqli_real_escape_string($_POST['addPost_post_status']);
- $post_image = $_FILES['addPost_post_image'];
- $post_image_name = $_FILES['addPost_post_image']['name'];
- $post_image_tmp_name = $_FILES['addPost_post_image']['tmp_name'];
- $post_image_error = $_FILES['addPost_post_image']['error'];
- $post_image_type = $_FILES['addPost_post_image']['type'];
- $post_image_size = $_FILES['addPost_post_image']['size'];
- $post_image_ext = explode('.', $post_image_name);
- $post_image_actual_ext = strtolower(end($post_image_ext));
- $post_image_allowed = array('jpg','jpeg','png');
- if (in_array($post_image_actual_ext, $post_image_allowed)) {
- if ($post_image_error === 0) {
- if ($post_image_size < 200000) {
- $post_image_new_name = uniqid('', true). "." .$post_image_actual_ext;
- $post_image_destination = '../../uploads/';
- if (is_dir($post_image_destination) && is_writable($post_image_destination)) {
- $post_image_destination = '../../uploads/'.$post_image_new_name;
- var_dump($post_image_destination);
- move_uploaded_file($post_image_new_name, $post_image_destination);
- echo "Inside move_uploaded_file section";
- } else {
- echo 'Upload directory is not writable, or does not exist.';
- }
- } else {
- header('Location: ../admin_addPost.php?addPost_status=image_too_big');
- }
- } else {
- header('Location: ../admin_addPost.php?addPost_status=failed');
- }
- } else {
- header('Location: ../admin_addPost.php?addPost_status=image_type_not_allowed');
- }
- $query = "
- INSERT INTO posts
- (post_category, post_title, post_author, post_date, post_image, post_content, post_tags, post_comment_counts, post_status, post_views_counts, post_likes, post_user_id)
- VALUES($post_category, '$post_title', '$post_author', '$post_date', '$post_image_new_name', '$post_content', '$post_tags', $post_comment_counts, $post_status, $post_views_counts, $post_likes, $post_user_id)
- ";
- $query = mysqli_query($connection, $query);
- if ($query) {
- mysqli_close($connection);
- header('Location: ../admin_addPost.php?addPost_status=success');
- } else {
- echo $query;
- die( mysqli_error($connection));
- mysqli_close($connection);
- header('Location: ../admin_addPost.php?addPost_status=failed');
- }
- }
- html ( I am getting head, footer via include )
- <!-- body -->
- <div class="columns is-12 section is-centered ">
- <div class="box column is-9 has-background-white-ter ">
- <div class=" column is-centered">
- <div class="column has-text-centered is-12">
- <h4 class="title is-4">Add New Post</h4>
- </div>
- <?php
- if (isset($_GET['addPost_status'])) {
- $status = $_GET['addPost_status'];
- if ($status == 'success') {
- ?>
- <p style="margin-bottom: 15px;" class="has-background-
- success has-text-centered ">
- <?php
- echo '<b class="has-text-white"> Post Has Been Added <b/>
-  ';
- echo '<span class=""> <a href="admin_addPost.php">Add
- Another <a/><span/>  ';
- echo '<span class=""> <a href="#">Viwe Post <a/><span/>';
- ?>
- </p>
- <?php
- } else {
- ?>
- <p style="margin-bottom: 15px;" class="has-background-
- danger has-text-centered ">
- <?php
- echo '<b class="has-text-white"> Something Went Wrong,
- Please Try Again <b/>';
- ?>
- </p>
- <?php
- }
- }
- ?>
- <form action="intodb/intodb_add_post.php" method="post"
- enctype="multipart/form-data" class="">
- <div class="columns is-12 is-centered">
- <div class=" has-background-white-ter column is-9 ">
- <div class="field column">
- <p class="control ">
- <label class="label" for="addPost_post_title">Post
- Title</label>
- <input id="addPost_post_title" class="input" type="text"
- placeholder="Post Tile" name="addPost_post_title" />
- </p>
- </div>
- <div class="field column">
- <p class="control ">
- <label class="label" for="addPost_post_author">Post
- Author</label>
- <!-- <input class="input" id="addPost_post_author"
- disabled="disabled" type="text" placeholder="Author"
- value="whatever" name="addPost_post_author" />
- -->
- <input class="input" id="addPost_post_author"
- type="text" placeholder="Author" value="whatever"
- name="addPost_post_author" />
- </p>
- </div>
- <div class="field column">
- <p class="control ">
- <label class="label" for="addPost_post_status">Post
- Status</label>
- <div style="margin-top: 10px" class="select ">
- <select id="addPost_post_status" name="addPost_post_status">
- <option value="0"> Draft</option>
- <option value="1"> Publish</option>
- </select>
- </div>
- </p>
- </div>
- <div class="field column">
- <p class="control ">
- <label class="label" for="addPost_post_category">Post
- Category</label>
- <div style="margin-top: 10px" class="select ">
- <select id="addPost_post_category"
- name="addPost_post_category">
- <option value="0">Uncategorized</option>
- <option value="1"> option1</option>
- <option value="2"> option2</option>
- </select>
- </div>
- </p>
- </div>
- <div class="field column">
- <p class="control ">
- <label class="label" for="addPost_post_tags">Post
- Tags</label>
- <input class="input" id="addPost_post_tags" type="text"
- placeholder="Post Tags" name="addPost_post_tags" />
- </p>
- </div>
- <div class="file has-name is-fullwidth column">
- <label class="label" for="addPost_post_image">Post
- image</label>
- <label class="file-label">
- <input class="" type="file" id="addPost_post_image"
- name="addPost_post_image">
- </label>
- </div>
- <div class="contro column">
- <label class="label" for="addPost_post_content">Post
- Content</label>
- <textarea id="addPost_post_content"
- name="addPost_post_content" class="textarea has-fixed-size"
- placeholder="Your Post Content Here" rows="10"></textarea>
- </div>
- <div class="control column" >
- <input type="submit" name="addPost_submit" value="Create
- Post" class="button is-info my_fucking_hover_right_arrow" />
- </div>
- </div>
- </div>
- </form>
- </div>
- <!-- -->
- </div>
- </div>
- <!-- body -->
- Apache logs
- Error.log
- [Sun Apr 21 21:19:41.860228 2019] [php7:notice] [pid 6285] [client ::1:35682] PHP 1. {main}() /var/www/html/my_cms/admin/intodb/intodb_add_post.php:0, referer: http://localhost/my_cms/admin/admin_addPost.php?addPost_status=success
- [Sun Apr 21 21:19:41.860240 2019] [php7:notice] [pid 6285] [client ::1:35682] PHP 2. mysqli_real_escape_string() /var/www/html/my_cms/admin/intodb/intodb_add_post.php:17, referer: http://localhost/my_cms/admin/admin_addPost.php?addPost_status=success
- [Sun Apr 21 21:19:41.860345 2019] [php7:notice] [pid 6285] [client ::1:35682] PHP Warning: mysqli_real_escape_string() expects exactly 2 parameters, 1 given in /var/www/html/my_cms/admin/intodb/intodb_add_post.php on line 18, referer: http://localhost/my_cms/admin/admin_addPost.php?addPost_status=success
- [Sun Apr 21 21:19:41.860360 2019] [php7:notice] [pid 6285] [client ::1:35682] PHP Stack trace:, referer: http://localhost/my_cms/admin/admin_addPost.php?addPost_status=success
- [Sun Apr 21 21:19:41.860387 2019] [php7:notice] [pid 6285] [client ::1:35682] PHP 1. {main}() /var/www/html/my_cms/admin/intodb/intodb_add_post.php:0, referer: http://localhost/my_cms/admin/admin_addPost.php?addPost_status=success
- [Sun Apr 21 21:19:41.860398 2019] [php7:notice] [pid 6285] [client ::1:35682] PHP 2. mysqli_real_escape_string() /var/www/html/my_cms/admin/intodb/intodb_add_post.php:18, referer: http://localhost/my_cms/admin/admin_addPost.php?addPost_status=success
- [Sun Apr 21 21:19:41.860484 2019] [php7:notice] [pid 6285] [client ::1:35682] PHP Warning: mysqli_real_escape_string() expects exactly 2 parameters, 1 given in /var/www/html/my_cms/admin/intodb/intodb_add_post.php on line 20, referer: http://localhost/my_cms/admin/admin_addPost.php?addPost_status=success
- [Sun Apr 21 21:19:41.860497 2019] [php7:notice] [pid 6285] [client ::1:35682] PHP Stack trace:, referer: http://localhost/my_cms/admin/admin_addPost.php?addPost_status=success
- [Sun Apr 21 21:19:41.860506 2019] [php7:notice] [pid 6285] [client ::1:35682] PHP 1. {main}() /var/www/html/my_cms/admin/intodb/intodb_add_post.php:0, referer: http://localhost/my_cms/admin/admin_addPost.php?addPost_status=success
- [Sun Apr 21 21:19:41.860517 2019] [php7:notice] [pid 6285] [client ::1:35682] PHP 2. mysqli_real_escape_string() /var/www/html/my_cms/admin/intodb/intodb_add_post.php:20, referer: http://localhost/my_cms/admin/admin_addPost.php?addPost_status=success
- [Sun Apr 21 21:19:41.865455 2019] [php7:notice] [pid 6285] [client ::1:35682] PHP Warning: mysqli_real_escape_string() expects exactly 2 parameters, 1 given in /var/www/html/my_cms/admin/intodb/intodb_add_post.php on line 26, referer: http://localhost/my_cms/admin/admin_addPost.php?addPost_status=success
- [Sun Apr 21 21:19:41.865493 2019] [php7:notice] [pid 6285] [client ::1:35682] PHP Stack trace:, referer: http://localhost/my_cms/admin/admin_addPost.php?addPost_status=success
- [Sun Apr 21 21:19:41.865509 2019] [php7:notice] [pid 6285] [client ::1:35682] PHP 1. {main}() /var/www/html/my_cms/admin/intodb/intodb_add_post.php:0, referer: http://localhost/my_cms/admin/admin_addPost.php?addPost_status=success
- [Sun Apr 21 21:19:41.865522 2019] [php7:notice] [pid 6285] [client ::1:35682] PHP 2. mysqli_real_escape_string() /var/www/html/my_cms/admin/intodb/intodb_add_post.php:26, referer: http://localhost/my_cms/admin/admin_addPost.php?addPost_status=success
- [Sun Apr 21 21:19:41.865783 2019] [php7:notice] [pid 6285] [client ::1:35682] PHP Notice: Undefined variable: post_image_new_name in /var/www/html/my_cms/admin/intodb/intodb_add_post.php on line 72, referer: http://localhost/my_cms/admin/admin_addPost.php?addPost_status=success
- [Sun Apr 21 21:19:41.865801 2019] [php7:notice] [pid 6285] [client ::1:35682] PHP Stack trace:, referer: http://localhost/my_cms/admin/admin_addPost.php?addPost_status=success
- [Sun Apr 21 21:19:41.865815 2019] [php7:notice] [pid 6285] [client ::1:35682] PHP 1. {main}() /var/www/html/my_cms/admin/intodb/intodb_add_post.php:0, referer: http://localhost/my_cms/admin/admin_addPost.php?addPost_status=success
- access.log
- ::1 - - [21/Apr/2019:20:55:33 +0500] "POST /my_cms/admin/intodb/intodb_add_post.php HTTP/1.1" 302 9391 "http://localhost/my_cms/admin/admin_addPost.php?addPost_status=success" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36"
- ::1 - - [21/Apr/2019:20:55:39 +0500] "GET /my_cms/admin/admin_addPost.php?addPost_status=success HTTP/1.1" 200 2243 "http://localhost/my_cms/admin/admin_addPost.php?addPost_status=success" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36"
- ::1 - - [21/Apr/2019:21:05:15 +0500] "GET /my_cms/admin/ HTTP/1.1" 200 892 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36"
- ::1 - - [21/Apr/2019:21:05:22 +0500] "GET /my_cms/ HTTP/1.1" 200 2637 "http://localhost/my_cms/admin/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36"
- ::1 - - [21/Apr/2019:21:05:22 +0500] "GET /my_cms/inc/css/style.css HTTP/1.1" 304 178 "http://localhost/my_cms/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36"
- ::1 - - [21/Apr/2019:21:19:18 +0500] "POST /my_cms/admin/intodb/intodb_add_post.php HTTP/1.1" 302 10151 "http://localhost/my_cms/admin/admin_addPost.php?addPost_status=success" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36"
- ::1 - - [21/Apr/2019:21:19:18 +0500] "GET /my_cms/admin/admin_addPost.php?addPost_status=success HTTP/1.1" 200 2244 "http://localhost/my_cms/admin/admin_addPost.php?addPost_status=success" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36"
- ::1 - - [21/Apr/2019:21:19:41 +0500] "POST /my_cms/admin/intodb/intodb_add_post.php HTTP/1.1" 302 10151 "http://localhost/my_cms/admin/admin_addPost.php?addPost_status=success" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36"
- ::1 - - [21/Apr/2019:21:19:42 +0500] "GET /my_cms/admin/admin_addPost.php?addPost_status=success HTTP/1.1" 200 2244 "http://localhost/my_cms/admin/admin_addPost.php?addPost_status=success" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36"
- ::1 - - [21/Apr/2019:21:20:33 +0500] "-" 408 0 "-" "-"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement