/[LeafOK_CVS]/fenglin/bbs/post.php
ViewVC logotype

Annotation of /fenglin/bbs/post.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.5 - (hide annotations)
Sat Apr 5 04:13:08 2025 UTC (11 months, 1 week ago) by sysadm
Branch: MAIN
Changes since 1.4: +2 -2 lines
Refine JS

1 sysadm 1.1 <?
2     require_once "../lib/common.inc.php";
3     require_once "../lib/db_open.inc.php";
4     require_once "./common_lib.inc.php";
5     require_once "./session_init.inc.php";
6     require_once "./check_sub.inc.php";
7     require_once "../lib/lml.inc.php";
8     require_once "../lib/str_process.inc.php";
9     ?>
10     <?
11     force_login();
12    
13     $id = (isset($_GET["id"]) ? intval($_GET["id"]) : 0);
14     $reply_id = (isset($_GET["reply_id"]) ? intval($_GET["reply_id"]) : 0);
15     $sid = (isset($_GET["sid"]) ? intval($_GET["sid"]) : $BBS_default_sid);
16     $quote = (isset($_GET["quote"]) && $_GET["quote"] == "0" ? false : true);
17    
18     $title = "";
19     $content = "";
20     $emoji = 1;
21     $reply_note = ($reply_id == 0 ? 1 : 0);
22    
23     if($id == 0) // Post article
24     {
25     if ($reply_id == 0) // Post new thread
26     {
27     $sql = "SELECT title FROM section_config WHERE SID = $sid AND enable";
28    
29     $rs = mysqli_query($db_conn, $sql);
30     if ($rs == false)
31     {
32     echo("Query section error: " . mysqli_error($db_conn));
33     exit();
34     }
35    
36     if ($row = mysqli_fetch_array($rs))
37     {
38     $section_title = $row["title"];
39     }
40     else
41     {
42     error_msg("版块不存在!",true);
43     exit();
44     }
45     mysqli_free_result($rs);
46    
47     if (!$_SESSION["BBS_priv"]->checkpriv($sid, S_POST))
48     {
49     error_msg("您无权发表文章!", true);
50     exit();
51     }
52     }
53     else // Reply article
54     {
55     $sql = "SELECT TID, bbs.SID, bbs.title, `lock`, username, nickname, content,
56     section_config.title AS s_title FROM bbs
57     INNER JOIN bbs_content ON bbs.CID = bbs_content.CID
58     INNER JOIN section_config ON bbs.SID = section_config.SID
59     WHERE bbs.AID = $reply_id AND visible";
60    
61     $rs = mysqli_query($db_conn, $sql);
62     if ($rs == false)
63     {
64     echo("Query article error: " . mysqli_error($db_conn));
65     exit();
66     }
67    
68     if ($row = mysqli_fetch_array($rs))
69     {
70     $tid = $row["TID"];
71     $sid = $row["SID"];
72     $title = $row["title"];
73     $lock = $row["lock"];
74     $r_username = $row["username"];
75     $r_nickname = $row["nickname"];
76     $content = $row["content"];
77     $section_title = $row["s_title"];
78     }
79     else
80     {
81     error_msg("回复的文章不存在!", true);
82     exit();
83     }
84     mysqli_free_result($rs);
85    
86     if ($tid != 0) // Article to be replied is not the head of topic thread
87     {
88     $sql = "SELECT SID, `lock` FROM bbs WHERE AID = $tid AND visible";
89    
90     $rs = mysqli_query($db_conn, $sql);
91     if ($rs == false)
92     {
93     echo("Query article error: " . mysqli_error($db_conn));
94     exit();
95     }
96    
97     if ($row = mysqli_fetch_array($rs))
98     {
99     $sid = $row["SID"]; // In case of inconsistent SID data
100     $lock = $row["lock"];
101     }
102     else
103     {
104     error_msg("回复的主题不存在!", true);
105     exit();
106     }
107     mysqli_free_result($rs);
108     }
109    
110     if (!$_SESSION["BBS_priv"]->checkpriv($sid, S_POST))
111     {
112     error_msg("您无权发表文章!", true);
113     exit();
114     }
115    
116     if ($lock)
117     {
118     error_msg("该主题谢绝回复!", true);
119     exit();
120     }
121     }
122     }
123     else // Modify article
124     {
125     $sql = "select UID, bbs.SID, TID, bbs.title, content, icon, reply_note, excerption,
126     section_config.title AS s_title FROM bbs
127     INNER JOIN bbs_content ON bbs.CID = bbs_content.CID
128     INNER JOIN section_config ON bbs.SID = section_config.SID
129     WHERE bbs.AID = $id AND visible";
130    
131     $rs = mysqli_query($db_conn, $sql);
132     if ($rs == false)
133     {
134     echo("Query article error: " . mysqli_error($db_conn));
135     exit();
136     }
137    
138     if ($row = mysqli_fetch_array($rs))
139     {
140     $uid = $row["UID"];
141     $sid = $row["SID"];
142     $tid = $row["TID"];
143     $title = $row["title"];
144     $content = $row["content"];
145     $emoji = $row["icon"];
146     $reply_note = $row["reply_note"];
147     $excerption = $row["excerption"];
148     $section_title = $row["s_title"];
149     }
150     else
151     {
152     error_msg("修改的文章不存在!", true);
153     exit();
154     }
155     mysqli_free_result($rs);
156    
157     if (!($_SESSION["BBS_priv"]->checkpriv($sid, S_POST) && $_SESSION["BBS_uid"] == $uid && (!$excerption)))
158     {
159     error_msg("您无权修改此文章!",true);
160     exit();
161     }
162     }
163     ?>
164     <html>
165     <head>
166     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
167     <title>发表文章</title>
168     <link rel="stylesheet" href="css/default.css" type="text/css">
169 sysadm 1.5 <script type="text/javascript" src="../js/nw_open.js"></script>
170     <script type="text/javascript" src="../js/lml_assistant.js"></script>
171 sysadm 1.1 <script src="../js/polyfill.min.js"></script>
172     <script src="../js/axios.min.js"></script>
173     <script type="text/javascript">
174     function refresh_err_msg(errorFieldMap)
175     {
176     document.getElementsByName("err_msg").forEach(element => {
177     if (errorFieldMap.has(element.id))
178     {
179     element.innerHTML = errorFieldMap.get(element.id);
180     }
181     else
182     {
183     element.innerHTML = "";
184     }
185     });
186     }
187    
188     function post_article(f)
189     {
190     instance.post('post_service.php', {
191     id: <? echo $id; ?>,
192     reply_id: <? echo $reply_id; ?>,
193     sid: <? echo $sid; ?>,
194     title: f.title.value,
195     transship: (f.transship != null && f.transship.checked ? "1" : "0"),
196     content: f.content.value,
197     emoji: f.emoji.value,
198 sysadm 1.4 sign_id: f.sign_id.value,
199 sysadm 1.1 reply_note: (f.reply_note.checked ? "1" : "0"),
200     attachment: f.attachment.files,
201     }, {
202     headers: {
203     'Content-Type': 'multipart/form-data',
204     }
205     })
206     .then(function (response) {
207     var ret = response.data;
208     var errorFieldMap = new Map();
209     switch (ret.return.code)
210     {
211     case 0: // OK
212     var returnPath = "view_article.php?id=" + ret.return.tid + "#" + ret.return.aid;
213     document.location = returnPath;
214     refresh_err_msg(errorFieldMap);
215     break;
216     case -1: // Input validation failed
217     ret.return.errorFields.forEach(field => {
218     errorFieldMap.set("err_msg_" + field.id, "<br />" + field.errMsg);
219     });
220     refresh_err_msg(errorFieldMap);
221     break;
222     case -2: // Internal error
223     console.log(ret.return.message);
224     errorFieldMap.set("err_msg_prompt", "内部错误");
225     refresh_err_msg(errorFieldMap);
226     break;
227     default:
228     console.log(ret.return.code);
229     break;
230     }
231     })
232     .catch(function (error) {
233     console.log(error);
234     });
235    
236     return false;
237     }
238    
239 sysadm 1.2 function upload_del(id)
240     {
241     if (window.confirm('真的要删除吗?') == false)
242     {
243     return false;
244     }
245    
246     instance.post('upload_del.php', {
247     aid: id
248     })
249     .then(function (response) {
250     var ret = response.data;
251     var errorFieldMap = new Map();
252     switch (ret.return.code)
253     {
254     case 0: // OK
255 sysadm 1.3 case 1: // Already deleted
256 sysadm 1.2 document.getElementById("attachment_" + id).style.display = "none";
257     refresh_err_msg(errorFieldMap);
258     break;
259     case -1: // Input validation failed
260 sysadm 1.3 errorFieldMap.set("err_msg_attachment", "<br />" + ret.return.message);
261 sysadm 1.2 refresh_err_msg(errorFieldMap);
262     break;
263     case -2: // Internal error
264     console.log(ret.return.message);
265     errorFieldMap.set("err_msg_prompt", "内部错误");
266     refresh_err_msg(errorFieldMap);
267     break;
268     default:
269     console.log(ret.return.code);
270     break;
271     }
272     })
273     .catch(function (error) {
274     console.log(error);
275     });
276    
277     return false;
278     }
279    
280 sysadm 1.1 const instance = axios.create({
281     withCredentials: true,
282     timeout: 3000,
283     baseURL: document.location.protocol + '//' + document.location.hostname + (document.location.port=='' ? '' : (':' + document.location.port)) + '/bbs/',
284     });
285    
286     window.addEventListener("load", () => {
287     var f = document.getElementById("post_form");
288     f.addEventListener("submit", (e) => {
289     e.preventDefault();
290     post_article(f);
291     });
292     });
293    
294     </script>
295     </head>
296     <body>
297     <center>
298     <table border="0" cellpadding="1" cellspacing="0" width="770">
299     <tr>
300     <td>
301     <a class="s2" href="main.php?sid=<? echo $sid; ?>"><? echo $BBS_name; ?></a>&gt;&gt;<a class="s2" href="bbs.php?sid=<? echo $sid; ?>"><? echo $section_title; ?></a>&gt;&gt;<?
302     if ($id == 0)
303     {
304     if ($reply_id > 0)
305     {
306     ?><a class="s2" href="view_article.php?id=<? echo ($tid ? $tid : $reply_id) . "#$reply_id"; ?>"><? echo split_line(htmlspecialchars($title, ENT_HTML401, 'UTF-8'), "", 65, 2, "<br />"); ?></a>&gt;&gt;<a class="s2" href="#">回复文章</a><?
307     }
308     else
309     {
310     ?><a class="s2" href="#">发表新文章</a><?
311     }
312     }
313     else
314     {
315     ?><a class="s2" href="view_article.php?id=<? echo ($tid ? $tid : $id) . "#$id"; ?>"><? echo split_line(htmlspecialchars($title, ENT_HTML401, 'UTF-8'), "", 65, 2, "<br />"); ?></a>&gt;&gt;<a class="s2" href="#">修改文章</a><?
316     }
317     ?>
318     </td>
319     </tr>
320     </table>
321     <form method="POST" ENCTYPE="multipart/form-data" id="post_form" name="post_form" action="#">
322     <table border="0" cellpadding="5" cellspacing="0" width="770">
323     <tr>
324     <td colspan="2" align="center" style="color:red;">别忙着发贴,请先看一下<a class="s0" href="doc/management.xml" target=_blank>《论坛管理章程》</a>吧!<br>
325     (请对您的言论负责,遵守有关法律、法规,尊重网络道德)</td>
326     </tr>
327     <tr height="10">
328 sysadm 1.2 <td colspan="2" align="center"><span id="err_msg_prompt" name="err_msg" style="color: red;"></span></td>
329 sysadm 1.1 </tr>
330     <tr>
331     <td width="10%" align="right">标题<span id="err_msg_title" name="err_msg" style="color: red;"></span></td>
332     <td width="90%">
333     <input type="text" name="title" id="title" size="80" <? echo ($id != 0 ? "readonly" : ""); ?> value="<? echo ($reply_id > 0 ? split_line(htmlspecialchars($title, ENT_QUOTES | ENT_HTML401, 'UTF-8'), "Re: ", 80, 1) : htmlspecialchars($title, ENT_QUOTES | ENT_HTML401, 'UTF-8')); ?>">
334     <?
335     if ($id == 0 && $reply_id == 0)
336     {
337     ?>
338     <input type="checkbox" name="transship">转载
339     <?
340     }
341     ?></td>
342     </tr>
343     <tr>
344     <td align="right">正文<span id="err_msg_content" name="err_msg" style="color: red;"></span></td>
345     <td>
346     <textarea name="content" id="content" cols="80" rows="25"><?
347     if ($reply_id == 0)
348     {
349     echo htmlspecialchars($content, ENT_HTML401, 'UTF-8');
350     }
351     else if ($quote)
352     {
353     ?>
354    
355    
356    
357     【 在 <? echo htmlspecialchars($r_username, ENT_HTML401, 'UTF-8'); ?> (<? echo htmlspecialchars($r_nickname, ENT_HTML401, 'UTF-8'); ?>) 的大作中提到: 】
358     <?
359     echo htmlspecialchars(LMLtagFilter(LML(split_line($content, ": ", 76, 20), false, false, 1024)), ENT_HTML401, 'UTF-8');
360     }
361     ?></textarea>
362     </td>
363     </tr>
364     <tr>
365     <td align="right"><a class="s0" href="doc/lml.htm" target=_blank>LML</a>助手</td>
366     <td>
367     <INPUT type="button" value="B" onclick="b_bold(content)" style="font-weight:bold; width:25px;">
368     <INPUT type="button" value="I" onclick="b_italic(content)" style="font-style:italic; width:25px;">
369     <INPUT type="button" value="U" onclick="b_underline(content)" style="text-decoration:underline; width:25px;">
370     <INPUT type="button" value="[" onclick="b_left(content)" style="width:20px;">
371     <INPUT type="button" value="]" onclick="b_right(content)" style="width:20px;">
372     <INPUT type="button" value="Aa" onclick="b_size(content)" style="width:30px;">
373     <INPUT type="button" value="A" onclick="b_color(content)" style="font-weight:bold; color:red; width:25px;">
374     <INPUT type="button" value="@" onclick="b_email(content)" style="width:25px;">
375     <INPUT type="button" value="Link" onclick="b_link(content)" style="text-decoration:underline; color:blue; width:40px;">
376     <INPUT type="button" value="主题" onclick="b_article(content)" style="text-decoration:underline; color:green; width:40px;">
377     <INPUT type="button" value="图片" onclick="b_image(content)" style="width:40px;">
378     <INPUT type="button" value="字幕" onclick="b_marquee(content)" style="width:40px;">
379     </td>
380     </tr>
381     <tr>
382 sysadm 1.2 <td align="right">上传附件<span id="err_msg_attachment" name="err_msg" style="color: red;"></span></td>
383 sysadm 1.1 <td>
384     单个文件大小不能超过<? echo $BBS_upload_size_limit; ?>M,
385     单次上传不超过<? echo $BBS_upload_count_limit; ?>个文件<br />
386     文件类型限于BMP,GIF,JPEG,PNG,TIFF,TXT,ZIP,RAR<br />
387     <INPUT TYPE=FILE SIZE=40 name="attachment[]" id="attachment" multiple>
388     <?
389     if ($id != 0) // Modify article
390     {
391     $sql = "SELECT * FROM upload_file WHERE ref_AID = $id
392     AND deleted = 0 AND deny = 0
393     ORDER BY AID";
394    
395     $rs = mysqli_query($db_conn, $sql);
396     if ($rs == false)
397     {
398     echo ("Read attachment error: " . mysqli_error($db_conn));
399     exit();
400     }
401    
402     if (mysqli_num_rows($rs) > 0)
403     {
404     ?>
405     <hr width="80%" align="left" />已上传附件<br />
406     <?
407     }
408    
409     while ($row = mysqli_fetch_array($rs))
410     {
411     $filename = $row["filename"];
412     $ext = strtolower(substr($filename, (strrpos($filename, ".") ? strrpos($filename, ".") + 1 : 0)));
413     ?>
414 sysadm 1.2 <span id="attachment_<? echo $row["AID"]; ?>"><img src="images/closed.gif"><a class="s2" href="dl_file.php?aid=<? echo $row["AID"]; ?>" target="_target"><? echo $filename; ?></a> (<? echo $row["size"]; ?>字节)
415 sysadm 1.1 <?
416     if ($row["check"] == 0)
417     {
418     ?><font color="red">未审核</font><?
419     }
420     ?>
421 sysadm 1.2 <a class="s2" href="#" onclick="return upload_del(<? echo $row["AID"]; ?>);">删除</a>
422     <br /></span>
423 sysadm 1.1 <?
424     }
425    
426     mysqli_free_result($rs);
427     }
428     ?>
429     </td>
430     </tr>
431     <tr>
432 sysadm 1.4 <td align="right">表情<span id="err_msg_emoji" name="err_msg" style="color: red;"></span></td>
433 sysadm 1.1 <td><?
434     for ($i = 1; $i <= $BBS_emoji_count; $i++)
435     {
436     ?><input type="radio" name="emoji" value="<? echo $i; ?>" <? echo ($i == $emoji ? "checked" : ""); ?>><img src="images/expression/<? echo $i; ?>.gif" width="15" height="15" alt="<? echo $i; ?>.gif"><?
437     if (($i % 12)==0)
438     {
439     ?><br><?
440     }
441     }
442     ?></td>
443     </tr>
444     <?
445     if ($id == 0)
446     {
447     ?>
448     <tr>
449 sysadm 1.4 <td align="right">签名<span id="err_msg_sign" name="err_msg" style="color: red;"></span></td>
450 sysadm 1.1 <td>
451 sysadm 1.4 <input type="radio" id="sign_id_0" name="sign_id" value="0" checked>不使用&nbsp;
452     <input type="radio" id="sign_id_1" name="sign_id" value="1">1&nbsp;
453 sysadm 1.1 <input type="radio" id="sign_id_2" name="sign_id" value="2">2&nbsp;
454     <input type="radio" id="sign_id_3" name="sign_id" value="3">3&nbsp;
455     <a class="s0" href="" onclick="return NW_open('preference.php', 'member_service', 500, 550);">设置个人签名</a>
456     </td>
457     </tr>
458     <?
459     }
460     ?>
461     <tr>
462     <td align="right"></td>
463     <td><input type="checkbox" name="reply_note" id="reply_note" <? echo ($reply_note ? "checked":""); ?>>有人回复该主题时通知我</td>
464     </tr>
465     </table>
466     <p><input type="submit" value="提交" name="submit">&nbsp;&nbsp;&nbsp;<input type="reset" value="重填" name="reset"></p>
467     </center>
468     </form>
469     <?
470     mysqli_close($db_conn);
471    
472     include "./foot.inc.php";
473     ?>
474     </body>
475     </html>

webmaster@leafok.com
ViewVC Help
Powered by ViewVC 1.3.0-beta1