Hỏi[Phonho] Phòng chát thiếu phần xóa /sửa hội thoại

2 bài đăng
29.05.2022 / 22:13
hoangchan
Bài đăng: 102
Member
HÔNG

Như tiêu đề nhờ mọi người hỗ trợ viết thêm phần xóa/sửa nội dung đoạn hội thoại (dành cho admin)

Đoạn code phòng chát chat.php

PHP
  1. <?php
  2. define('_MRKEN_CMS', 1);
  3. $headmod = 'chatroom';
  4. require('incfiles/core.php');
  5. if (!$user_id) {
  6. $_SESSION['ref'] = SITE_URL . '/chat.php';
  7. header('Location: ' . SITE_URL . '/login.php'); exit;
  8. }
  9. function forum_link($m)
  10. {
  11. global $set;
  12. if (!isset($m[3])) {
  13. return '[url=' . $m[1] . ']' . $m[2] . '[/url]';
  14. } else {
  15. $p = parse_url($m[3]);
  16. if (('http://' . $p['host'] . (isset($p['path']) ? $p['path'] : '') . '?id=' == SITE_URL . '/forum/index.php?id=') || ('http://' . $p['host'] . (isset($p['path']) ? $p['path'] : '') . '?id=' == SITE_URL. '/forum/?id=') || ('http://' . $p['host'] == SITE_URL && isset($p['path']) && preg_match('#/forum/([^\.]+?)\.([\d]+?)\.html#', $p['path']))) {
  17. if(preg_match('#/forum/([^\.]+?)\.([\d]+?)\.html#', $p['path'])){
  18. $thid = abs(intval(preg_replace('/^([^\.]+?)\./si', '', $p['path'])));
  19. }else{
  20. $thid = abs(intval(preg_replace('/(.*?)id=/si', '', $m[3])));
  21. }
  22. $req = mysql_query("SELECT `text` FROM `forum` WHERE `id`= '$thid' AND `type` = 't' AND `close` != '1'");
  23. if (mysql_num_rows($req) > 0) {
  24. $res = mysql_fetch_array($req);
  25. $name = strtr($res['text'], array(
  26. '[' => '',
  27. ']' => ''
  28. ));
  29. if (mb_strlen($name) > 40)
  30. $name = mb_substr($name, 0, 63) . '...';
  31.  
  32. return '[url=' . $m[3] . ']' . $name . '[/url]';
  33. } else {
  34. return $m[3];
  35. }
  36. } else
  37. return $m[3];
  38. }
  39. }
  40. $text = '';
  41. $error = '';
  42. if(isset($_POST['submit'])){
  43. $text = isset($_POST['text']) ? functions::checkin($_POST['text']) : '';
  44. $flood = functions::antiflood();
  45. if(isset($ban['1']) || isset($ban['12'])){
  46. $error = 'Bạn đang bị cấm chat!';
  47. }elseif(!(isset($_POST['token']) && $_POST['token'] == $datauser['priv_key'])){
  48. $error = 'Dữ liệu không đúng!';
  49. }elseif($flood){
  50. $error = 'Bạn không được gửi tin nhắn quá nhanh! Vui lòng chờ '.$flood.' giây!';
  51. }elseif(empty($text) || mb_strlen($text) < 2 || mb_strlen($text) > 1023){
  52. $error = 'Độ dài tin nhắn là từ 2 đến 1023 ký tự!';
  53. }
  54. if(empty($error)){
  55. if($text == '/clear' && $rights >= 6){
  56. mysql_query('TRUNCATE `cms_chat`');
  57. mysql_query('INSERT INTO `cms_chat` SET `uid`="2",`text`="đã làm sạch chatbox",`time`="'.time().'"');
  58. header('Location: '. SITE_URL); exit;
  59. }else{
  60. $text = preg_replace_callback('~\\[url=(http://.+?)\\](.+?)\\[/url\\]|(http://(www.)?[0-9a-zA-Z\.-]+\.[0-9a-zA-Z]{2,6}[0-9a-zA-Z/\?\.\~&_=/%-:#]*)~', 'forum_link', $text);
  61. $query = mysql_query('INSERT INTO `cms_chat` SET `uid`="'.$user_id.'",`text`="'.mysql_real_escape_string($text).'",`time`="'.time().'"');
  62. if($query){
  63. mysql_query('UPDATE `users` SET `lastpost`="'.time().'" WHERE `id`="'.$user_id.'" LIMIT 1');
  64. if(isset($_GET['in'])){
  65. header('Location: ' . SITE_URL);
  66. }else{
  67. header('Location: ' . SITE_URL . '/chat.php?r='.rand(1000,9999).'');
  68. }
  69. exit;
  70. }
  71. }
  72. }
  73. }
  74. require('incfiles/head.php');
  75. $total = mysql_result(mysql_query('SELECT COUNT(*) FROM `cms_chat`'),0);
  76. echo '<div class="phdr"><b>Phòng chat</b> (<span id="total">'.$total.'</span>)</div>';
  77. if(!empty($error)) echo functions::display_error($error);
  78. echo '<div id="error" class="hide rmenu"></div><div class="topmenu"><form action="chat.php" method="post" name="chat" id="chat">'.bbcode::auto_bb('chat','chat_input').'<div><textarea name="text" id="chat_input" rows="'.$set_user['field_h'].'" required></textarea></div><div><input type="hidden" name="token" value="'.$datauser['priv_key'].'" /><input type="submit" name="submit" value="Gửi" id="chat_submit"></div></div><div id="chatbox">';
  79. $req = mysql_query('SELECT `cms_chat`.*,`users`.`account`,`users`.`rights` FROM `cms_chat` LEFT JOIN `users` ON `users`.`id`=`cms_chat`.`uid` ORDER BY `cms_chat`.`id` DESC LIMIT '.$start.','.$kmess.'');
  80. $i=0;
  81. while($res = mysql_fetch_assoc($req)){
  82. $text = functions::checkout($res['text'], 1, 1, 1);
  83. echo ($i%2 ? '<div class="list1">':'<div class="list2">').'<b><a href="users/profile.php?user='.$res['uid'].'" title="'.functions::display_date($res['time']).'">'.functions::nick_color($res['account'], $res['rights']).'</a></b>: '.$text.' </div>';
  84. $i++;
  85. }
  86. echo '</div>'.(!$wap || $total > $kmess ? '<div class="topmenu" id="pagination">' : '');
  87. if($total > $kmess) echo ''.functions::display_pagination('chat.php?page=',$start,$total,$kmess).'';
  88. echo (!$wap || $total > $kmess ? '</div>' : '');
  89. require('incfiles/end.php');
Đã chỉnh sửa. hoangchan (29.05.2022 / 22:14)
01.06.2022 / 14:30
MnpNgok
Bài đăng: 51
Member
http://keyit.my.id

Đây ko phải thiếu mà là một tính năng >> theo lời tiên tri của các bậc tiền bối thánh coder :>