-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcomment.php
executable file
·55 lines (54 loc) · 2.36 KB
/
comment.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
<?php
/* Copyright (C) 2011-2013 Josh Ventura <[email protected]>
*
* This file is part of the ENIGMA Developers Community (EDC).
*
* The EDC is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, version 3 of the License, or (at your option) any later version.
*
* This source is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* this code. If not, see <http://www.gnu.org/licenses/>.
*/
require_once('common.php');
if ($context['user']['is_guest'])
{
echo "<h1>No login; perhaps it has expired. Redirecting in three seconds...</h1>";
echo "<meta http-equiv=\"REFRESH\" content=\"3;url=" . htmlspecialchars($_POST['redirect']) . "\">";
echo "<p>In case you're having a bad browser day, here's the message you posted:</p>";
echo "<div style=\"border: 1px solid; padding: 16px\">" . htmlSpecialChars($_POST['message']) . "</div>";
}
else
{
$action = isset($_GET['action']) ? $_GET['action'] : 'comment';
switch ($action)
{
case 'comment':
if (empty($_POST['message']))
{
echo "<meta http-equiv=\"REFRESH\" content=\"2;url=" . htmlspecialchars($_POST['redirect']) . "\">";
echo "<h1>Error</h1>\nPost contained no text. You will be redirected shortly.";
return;
}
$smcFunc['db_select_db']($db_name);
$iq = $smcFunc['db_insert']('insert', 'edc_comments',
array('id_author' => 'int', 'id_thread' => 'int', 'message' => 'string'),
array($context['user']['id'], $_POST['thread_id'], $_POST['message']),
array());
echo "<meta http-equiv=\"REFRESH\" content=\"0;url=" . htmlspecialchars($_POST['redirect']) . "\">";
echo "<h3>Your comment has been posted.</h3>\n";
echo "You should be redirected to <a href=\"" . htmlspecialchars($_POST['redirect']) . "\">" . htmlspecialchars($_POST['redirect']) . "</a> shortly.";
break;
case 'edit':
$smcFunc['db_select_db']($db_name);
break;
case 'delete':
$smcFunc['db_select_db']($db_name);
break;
}
}
?>