Show sourcecode

The following files exists in this folder. Click to view.

Foogler_blog/pages

PAuthor.php
PCommentProcess.php
PDeleteCommentProcess.php
PDeletePost.php
PDeletePostProcess.php
PEditPost.php
PEditPostProcess.php
PErDiagramme.php
PIndex.php
PInstall.php
PInstallProcess.php
PNewPost.php
PNewPostProcess.php
PRssFeed.php
PShowPost.php
PStatistics.php
PValidate.php
login/

PDeletePostProcess.php

69 lines ASCII Windows (CRLF)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
//--------------------------
// PDeletePostProcess.php
//
// Handles process for deleting post
//--------------------------

//Note: The tags aren't deleted at the moment

//Checks that user is logged in
if(!isset($_SESSION['accountUser'])) {
  require_once(
"login/PLogin.php");
  exit;  
} else if(
$_SESSION['accountUser'] == "guest" ) {
  die(
"Sorry, you don't have the priviliges for doing this...");
}

//--------------------------
//Handles GET variables
$chosenPost = isset($_GET['id']) ? $_GET['id'] : '';

//--------------------------
//DB stuff
$mysqli = new mysqli(DB_HOSTDB_USERDB_PASSWORDDB_DATABASE); //New DB object

if (mysqli_connect_error()) {
   echo 
"Connect failed: ".mysqli_connect_error()."<br>";
   exit();
}
$mysqli->set_charset("utf8");

//Prevent SQL injections
$chosenPost $mysqli->real_escape_string($chosenPost);

//----------------------
//SQL query
$tablePost   DB_PREFIX 'Post';
$tableTag   DB_PREFIX 'Tag';
$tablePostTag   DB_PREFIX 'PostTag';

$query = <<<END
--
-- Deletes post
--
DELETE FROM 
{$tablePost}
WHERE idPost = 
{$chosenPost}
LIMIT 1;
  
--
-- Deletes all post + tag combinations for the post
--
DELETE FROM 
{$tablePostTag}
WHERE PostTag_idPost = 
{$chosenPost};
END;

$mysqli->multi_query($query) or die("Could not query database" $mysqli->errno .":" $mysqli->error); //Performs query

//Checks if error
if ($mysqli->errno) { 
  
$html .= "<p>Stopped receiving results: {$mysqli->errno} ({$mysqli->error})</p>"
}

$mysqli->close(); //Closes DB connection

//---------------------
//Redirects to first page
header("Location:" WS_SITELINK "?p=index");
exit;