summaryrefslogtreecommitdiff
path: root/htdocs/deletepost.php
blob: 7ffc1fc3332763ee490a14b27d855f0af3e282e0 (plain)
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
<?php

/* Foursquare Community Site
 * 
 * Copyright (C) 2011 Foursquare Church.
 * 
 * Developers: Jesse Morgan <jmorgan@foursquarestaff.com>
 *
 */

require_once "src/base.inc.php";

require_once "src/header.inc.php";

// Make sure we have all the needed information
if (!isset($_GET['id']) or !is_numeric($_GET['id'])
    or !isset($_GET['secret'])) {
    errorNotFound();
}

// Get the post.
$post = Post::getById($_GET['id']);

// Got a post with the right secretid?
if (!$post and $post->getSecretId() == $_GET['secret']) {
    errorNotFound();
}

if (isset($_GET['confirmed'])) {
    // Delete post
    $post->delete();

    echo "<p>Your post has been removed.</p>";

    echo "<p><a href=\"". $GLOBALS['CONFIG']['urlroot']
        ."\">Return to homepage</a>.</p>";

} else {
    // Are you sure...
    echo "<p>Are you sure you want to remove your posting titled "
        . $post->getName() ."?</p>";
    echo "<p><a href=\"". $_SERVER['REQUEST_URI']
        ."&confirmed\">Yes, delete it.</a></p>";
    echo "<p><a href=\"". $GLOBALS['CONFIG']['urlroot']
        ."\">No, do not delete it.</a></p>";
}

require_once "src/footer.inc.php";

function errorNotFound() {
    // Get the 404 page
    $page = Page::getByUrl('404');
    if ($page) {
        echo $page->getContent();
    } else {
        echo "Error: Page not found.";
    }
    require_once "src/footer.inc.php";
    exit;
}

?>