-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathadd-forum-message.php
79 lines (47 loc) · 2 KB
/
add-forum-message.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
<?php
require 'class.base.php';
require 'class.html.php';
$base_instance=new base();
$html_instance=new html();
$userid=$base_instance->get_userid();
$title=isset($_POST['title']) ? $_POST['title'] : '';
$text=isset($_POST['text']) ? $_POST['text'] : '';
$followup=isset($_POST['followup']) ? (int)$_POST['followup'] : '';
if (isset($_POST['save'])) {
$error='';
if ($title) {
$title=trim($title);
if (strlen($title)>100) { $error.='<li> Title is too long (Max. 100 Characters)'; }
$title=str_replace('"','"',$title);
} else if (!$followup) { $error.='<li> Title cannot be left blank'; }
if ($text) {
$text=trim($text);
if (strlen($text)>65535) { $error.='<li> Text is too long (Max. 65535 Characters)'; }
} else { $error.='<li> Message cannot be left blank'; }
if (!$error) {
$datetime=$_POST['datetime'];
$base_instance->query('INSERT INTO '.$base_instance->entity['FORUM']['MAIN'].' (datetime,updated,text,title,followup,user) VALUES ("'.sql_safe($datetime).'","'.sql_safe($datetime).'","'.sql_safe($text).'","'.sql_safe($title).'",'.$followup.','.$userid.')');
if (_FORUM_NOTIFY==1 && $userid!=_ADMIN_USERID) {
$msg="New Forum Message:\n\n".$title."\n\n".$text;
$base_instance->send_email_from_admin('New Forum Message Notification',$msg,_ADMIN_EMAIL);
}
header('Location: show-forum.php'); exit;
}
else {
$html_instance->error_message=$error;
$text=stripslashes($text);
$title=stripslashes($title);
}
}
$html_instance->add_parameter(
array('ACTION'=>'show_form',
'HEADER'=>'New Forum Message',
'FORM_ACTION'=>$_SERVER['PHP_SELF'],
'BODY'=>'onLoad="javascript:document.form1.title.focus()"',
'BUTTON_TEXT'=>'Post new Message'
));
$html_instance->add_form_field(array('TYPE'=>'hidden','NAME'=>'followup','VALUE'=>"$followup"));
$html_instance->add_form_field(array('TYPE'=>'text','NAME'=>'title','VALUE'=>"$title",'SIZE'=>50,'TEXT'=>'Title'));
$html_instance->add_form_field(array('TYPE'=>'textarea','NAME'=>'text','VALUE'=>"$text",'COLS'=>90,'ROWS'=>11));
$html_instance->process();
?>