-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathpost.php
More file actions
292 lines (251 loc) · 10.4 KB
/
Copy pathpost.php
File metadata and controls
292 lines (251 loc) · 10.4 KB
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
<?php
use Xmf\Request;
use XoopsModules\Tadtools\FormValidator;
use XoopsModules\Tadtools\TadUpFiles;
use XoopsModules\Tadtools\Utility;
/*-----------引入檔案區--------------*/
require_once __DIR__ . '/header.php';
$TadUpFiles = new TadUpFiles('tad_discuss');
/*-----------執行動作判斷區----------*/
$op = Request::getString('op');
$BoardID = Request::getInt('BoardID');
$DiscussID = Request::getInt('DiscussID');
$ReDiscussID = Request::getInt('ReDiscussID');
$boardTitle = Request::getString('boardTitle');
$setupRule = Request::getString('setupRule');
switch ($op) {
//新增資料
case 'insert_tad_discuss':
insert_tad_discuss(true);
header("location: {$_SERVER['PHP_SELF']}?op=reload&BoardID=$BoardID");
exit;
case 'fast_add_borard':
$BoardID = insert_tad_discuss_cbox_setup($boardTitle, $setupRule, $boardTitle);
header("location: {$_SERVER['PHP_SELF']}?op=reload&BoardID=$BoardID");
exit;
default:
$main = tad_discuss_form($BoardID, $DiscussID, $ReDiscussID);
break;
}
// 關閉除錯訊息
header('HTTP/1.1 200 OK');
$xoopsLogger->activated = false;
/*-----------秀出結果區--------------*/
echo "
<!DOCTYPE html>
<html lang='en'>
<head>
<meta charset='" . _CHARSET . "'>
<meta http-equiv='X-UA-Compatible' content='IE=edge'>
<title>Post Form</title>
<link rel='stylesheet' type='text/css' media='screen' href='" . XOOPS_URL . "/modules/tad_discuss/css/cbox.css'>
";
if ('reload' === $op) {
echo "<script type='text/javascript'>
window.open('" . XOOPS_URL . "/modules/tad_discuss/cbox.php?BoardID={$BoardID}','discussCboxMain');
window.open('" . XOOPS_URL . "/modules/tad_discuss/post.php?BoardID={$BoardID}','discussCboxForm');
</script>";
}
if (!empty($_GET['msg'])) {
echo "<script type='text/javascript'>alert('{$_GET['msg']}')</script>";
}
echo "\n</head>";
echo $main;
echo "\n</html>";
/*-----------function區--------------*/
//tad_discuss編輯表單
function tad_discuss_form($BoardID = '', $DiscussID = '', $ReDiscussID = '')
{
global $xoopsUser, $xoopsModuleConfig, $xoopsModule, $TadUpFiles, $tad_discuss_adm;
if (empty($BoardID)) {
if ($tad_discuss_adm and '1' == $xoopsModuleConfig['display_fast_setup']) {
$FormValidator = new FormValidator('#myForm', true);
$formValidator_code = $FormValidator->render();
$boardTitle = _MD_TADDISCUS_INPUT_BOARDTITLE;
$setupRule = $_GET['setupRule'];
$main = "
<body class='error_bg'>
<h3 style='display: none;'>POST Form</h3>
<div class='error_bg' style='color:#6C0000;font-size: 75%;line-height:150%;padding:10px 10px;'>
" . _MD_TADDISCUS_NEED_BOARDID . "
$formValidator_code
<form action='post.php' method='post'>
<input type='text' name='boardTitle' id='boardTitle' style='width:100%'; class='validate[required]' value='$boardTitle' onClick=\"if(this.value=='" . _MD_TADDISCUS_INPUT_BOARDTITLE . "'){this.value='';}\">
<input type='text' name='setupRule' id='setupRule' style='width:100%'; class='validate[required]' value='$setupRule'>
<input type='hidden' name='op' value='fast_add_borard'>
<div>" . _MD_TADDISCUS_SETUPRULE . "</div>
<input type='submit' value='" . _MD_TADDISCUS_ADD_BOARD . "'>
</form>
</div>
</body>";
} else {
$main = "
<body class='error_bg'>
<h3 style='display: none;'>POST Form</h3>
<div class='error_bg' style='color:#6C0000;font-size: 92%;line-height:180%;padding:20px 10px;'>
" . _MD_TADDISCUS_NEED_BOARDID . "
</div>
</body>";
}
return $main;
}
$TadUpFiles->set_col('DiscussID', $DiscussID); //若 $show_list_del_file ==true 時一定要有
$upform = $TadUpFiles->upform(false, 'upfile', 100, false);
//取得本模組編號
$module_id = $xoopsModule->mid();
//取得目前使用者的群組編號
if ($xoopsUser) {
$name = $xoopsUser->name();
if (!empty($name)) {
$publisher = $name;
} else {
$publisher = $xoopsUser->uname();
}
} else {
$publisher = _MD_TADDISCUS_DEFAULT_PUBLISHER;
}
$groups = $xoopsUser ? $xoopsUser->getGroups() : [XOOPS_GROUP_ANONYMOUS];
$gpermHandler = xoops_getHandler('groupperm');
if (!$gpermHandler->checkRight('forum_post', $BoardID, $groups, $module_id)) {
$main = "
<body>
<h1 style=\"display:none;\">Need Login</h1>
<div class='need_login'>" . sprintf(_MD_TADDISCUS_NEED_LOGIN, $BoardID, $BoardID) . '</div>
</body>';
return $main;
}
$publisher_txt = (!empty($ReDiscussID)) ? "<div class='remsg'>" . sprintf(_MD_TADDISCUS_RE_MSG, $ReDiscussID) . '</div>' : "<div class='remsg'>" . sprintf(_MD_TADDISCUS_ADD_MSG, $publisher) . '</div>';
$js = $smile_all = '';
$_SESSION['cbox_use_smile'] = 1;
if ('1' == $_SESSION['cbox_use_smile']) {
//找出表情圖
$dir = 'images/smiles/';
if (is_dir($dir)) {
if ($dh = opendir($dir)) {
while (false !== ($file = readdir($dh))) {
if ('.' === mb_substr($file, 0, 1) or 's' !== mb_substr($file, 0, 1)) {
continue;
}
$key = mb_substr($file, 1, -4);
$smile_gif[$key] = $file;
}
closedir($dh);
}
}
sort($smile_gif);
$smile_li = '';
foreach ($smile_gif as $file) {
$smile_li .= "<li><img src='" . XOOPS_URL . "/modules/tad_discuss/{$dir}{$file}' width='19' height='19' alt='{$file}' onClick='insertAtCursor(document.myForm.DiscussContent,\"[{$file}]\")' ></li>\n";
}
$js = "
$(document).ready(function() {
var w=$('.carousel').width();
if(w > 600) w=600;
var smile_num=Math.floor((w-60)/19);
$(\".jCarouselLite\").jCarouselLite({
btnNext: \".next\",
btnPrev: \".prev\",
visible: smile_num,
scroll: smile_num
});
});
function insertAtCursor(myField, myValue) {
//IE support
if (document.selection) {
myField.focus();
sel = document.selection.createRange();
sel.text = myValue;
} else if (myField.selectionStart || myField.selectionStart == '0') {
var startPos = myField.selectionStart;
var endPos = myField.selectionEnd;
myField.value = myField.value.substring(0, startPos)
+ myValue
+ myField.value.substring(endPos, myField.value.length);
} else {
myField.value += myValue;
}
}";
$smile_all = "
<tr><td colspan=2 id='smile'>
<div class='carousel' style='height:24px;'>
<a href='#' class='prev'> </a>
<div class='jCarouselLite' align=center><ul>$smile_li</ul></div>
<a href='#' class='next'> </a>
<div class='clear'></div>
</div>
</td></tr>";
}
$jquery = Utility::get_jquery();
//加入Token安全機制
$token = Utility::token_form('return');
$DiscussTitleForm = empty($ReDiscussID) ? "
<tr>
<td colspan=2><input type='text' name='DiscussTitle' value='' style='width:100%' placeholder='" . _MD_TADDISCUS_INPUT_TITLE . "' class='form-control validate[required]'>
</td>
</tr>" : '';
$main = "
<body bgcolor='#FCFCFC'>
{$jquery}
<script type='text/javascript' src='" . XOOPS_URL . "/modules/tad_discuss/class/jquery.jcarousellite.min.js'></script>
<script type='text/javascript'>
$js
var minChr = 4;
var nowChr = 0;
function count(value){
nowChr = value.length;
}
function check(){
if(nowChr < minChr){
alert('" . sprintf(_MD_TADDISCUS_MSG_MIN, $xoopsModuleConfig['input_min']) . "');
return;
}
document.myForm.submit();
}
</script>
<h3 style='display:none;'>Post Form</h3>
<div class='cbox'>
<form action='{$_SERVER['PHP_SELF']}' method='post' name='myForm' id='myForm' enctype='multipart/form-data' >
<table class='cbox_tbl' style='width:98%'>
<tr>
<td class='col'>{$publisher_txt}
<!--div style='font-size: 62.5%'>\$BoardID=$BoardID,\$DiscussID=$DiscussID,\$ReDiscussID=$ReDiscussID</div-->
</td>
<td>
<img src='images/reload.png' alt='reload' align='absmiddle' hspace=2 onclick=\"window.open('" . XOOPS_URL . "/modules/tad_discuss/cbox.php?BoardID={$BoardID}','discussCboxMain');window.open('" . XOOPS_URL . "/modules/tad_discuss/post.php?BoardID={$BoardID}','discussCboxForm');\">
<span onclick=\"window.open('" . XOOPS_URL . "/modules/tad_discuss/cbox.php?BoardID={$BoardID}','discussCboxMain');window.open('" . XOOPS_URL . "/modules/tad_discuss/post.php?BoardID={$BoardID}','discussCboxForm');\" style='cursor:pointer;color:#3366CC'>" . _MD_TADDISCUS_RELOAD . "</span>
</td>
</tr>
$DiscussTitleForm
<tr>
<td class='col' colspan=2>
<textarea name='DiscussContent' id='DiscussContent' style='width:100%' onkeyUp='count(this.value)' onClick=\"if(this.value=='" . _MD_TADDISCUS_MSG . "')this.value=''\">" . _MD_TADDISCUS_MSG . "</textarea>
</td>
</tr>
<tr>
<td class='col' colspan=2 style='text-align:right;'>
<input type='checkbox' name='only_root' value='1'><span style='font-size:80%'>" . _MD_TADDISCUS_ONLY_ROOT . "</span>
<input type='hidden' name='BoardID' value='{$BoardID}'>
<input type='hidden' name='DiscussID' value='{$DiscussID}'>
<input type='hidden' name='ReDiscussID' value='{$ReDiscussID}'>
<input type='hidden' name='publisher' value='{$publisher}'>
<input type='hidden' name='op' value='insert_tad_discuss'>
{$token}
<input type='button' value='" . _TAD_SAVE . "' style='height:100%' onClick='check();'>
$upform
</td>
</tr>
$smile_all
</table>
</form></div>
</body>";
return $main;
}
function mkpic($num = 0)
{
header('Content-type: image/png');
$im = @imagecreatetruecolor(28, 18);
$text_color = imagecolorallocate($im, 255, 255, 255);
imagestring($im, 2, 5, 2, $num, $text_color);
imagepng($im);
imagedestroy($im);
}