-
Notifications
You must be signed in to change notification settings - Fork 28
/
add.php
84 lines (73 loc) · 2.11 KB
/
add.php
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<?php
require_once("bootstrap.inc.php");
require_once("include_pouet/box-modalmessage.php");
require_once("include_pouet_index/box-index-oneliner-latest.php");
require_once("include_pouet/box-bbs-post.php");
require_once("include_pouet/box-bbs-open.php");
$errormessage = "";
////////////////////////////////////////////////////////////
$message = new PouetBoxModalMessage(false,true);
$message->title = "An error has occured:";
$box = NULL;
$thing = "";
$data = "";
if (!$currentUser) {
$message->message = "You got logged out somehow...";
} else {
switch ($_POST["type"]) {
case "oneliner":
{
$box = new PouetBoxIndexLatestOneliner();
$thing = "oneline";
$data = $_POST["message"];
$message->returnPage = "index.php";
} break;
case "post":
{
$box = new PouetBoxBBSPost($_POST["which"]);
$thing = "BBS post";
$data = $_POST["message"];
$message->returnPage = "topic.php?which=".(int)$_POST["which"];
} break;
case "bbs":
{
$box = new PouetBoxBBSOpen();
$thing = "bbs";
$data = $_POST["message"];
$message->returnPage = "index.php";
} break;
default:
{
$message->message = "not implemented!";
} break;
}
}
if ($box) {
$csrf = new CSRFProtect();
if (!$csrf->ValidateToken())
{
$message->classes[] = "errorbox";
$message->message = "who are you and where did you come from ?";
}
else
{
$errormessage = $box->ParsePostMessage($_POST);
if (!$errormessage) {
$message->title = "You've successfully added the following ".$thing.":";
$message->message = $data;
if ($box instanceof PouetBoxCachable)
$box->ForceCacheUpdate();
} else {
$message->classes[] = "errorbox";
$message->message = is_array($errormessage) ? implode("<br/>",$errormessage) : $errormessage;
}
}
} else {
$message->message = "not implemented!";
}
require_once("include_pouet/header.php");
require("include_pouet/menu.inc.php");
echo $message->Render();
require("include_pouet/menu.inc.php");
require_once("include_pouet/footer.php");
?>