[ Index ] |
PHP Cross Reference of MyBB 1.8.38 |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * MyBB 1.8 4 * Copyright 2014 MyBB Group, All Rights Reserved 5 * 6 * Website: http://www.mybb.com 7 * License: http://www.mybb.com/about/license 8 * 9 */ 10 11 // Disallow direct access to this file for security reasons 12 if(!defined("IN_MYBB")) 13 { 14 die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined."); 15 } 16 17 $page->add_breadcrumb_item($lang->moderation_queue, "index.php?module=forum-moderation_queue"); 18 19 $sub_tabs['threads'] = array( 20 'title' => $lang->threads, 21 'link' => "index.php?module=forum-moderation_queue&type=threads", 22 'description' => $lang->threads_desc 23 ); 24 25 $sub_tabs['posts'] = array( 26 'title' => $lang->posts, 27 'link' => "index.php?module=forum-moderation_queue&type=posts", 28 'description' => $lang->posts_desc 29 ); 30 31 $sub_tabs['attachments'] = array( 32 'title' => $lang->attachments, 33 'link' => "index.php?module=forum-moderation_queue&type=attachments", 34 'description' => $lang->attachments_desc 35 ); 36 37 $plugins->run_hooks("admin_forum_moderation_queue_begin"); 38 39 // Actually performing our moderation choices 40 if($mybb->request_method == "post") 41 { 42 $plugins->run_hooks("admin_forum_moderation_queue_commit"); 43 44 require_once MYBB_ROOT."inc/functions_upload.php"; 45 require_once MYBB_ROOT."inc/class_moderation.php"; 46 $moderation = new Moderation; 47 48 if($mybb->get_input('threads', MyBB::INPUT_ARRAY)) 49 { 50 $threads_to_approve = $threads_to_delete = array(); 51 // Fetch threads 52 $query = $db->simple_select("threads", "tid", "tid IN (".implode(",", array_map("intval", array_keys($mybb->input['threads']))).")"); 53 while($thread = $db->fetch_array($query)) 54 { 55 $action = $mybb->input['threads'][$thread['tid']]; 56 if($action == "approve") 57 { 58 $threads_to_approve[] = $thread['tid']; 59 } 60 else if($action == "delete" && $mybb->settings['soft_delete'] != 1) 61 { 62 $moderation->delete_thread($thread['tid']); 63 } 64 else if($action == "delete") 65 { 66 $threads_to_delete[] = $thread['tid']; 67 } 68 } 69 if(!empty($threads_to_approve)) 70 { 71 $moderation->approve_threads($threads_to_approve); 72 } 73 if(!empty($threads_to_delete)) 74 { 75 $moderation->soft_delete_threads($threads_to_delete); 76 } 77 78 $plugins->run_hooks("admin_forum_moderation_queue_threads_commit"); 79 80 // Log admin action 81 log_admin_action('threads'); 82 83 flash_message($lang->success_threads, 'success'); 84 admin_redirect("index.php?module=forum-moderation_queue&type=threads"); 85 } 86 else if($mybb->get_input('posts', MyBB::INPUT_ARRAY)) 87 { 88 $posts_to_approve = $posts_to_delete = array(); 89 // Fetch posts 90 $pids = array_map( 91 "intval", 92 array_keys($mybb->get_input('posts', MyBB::INPUT_ARRAY)) 93 ); 94 95 $query = $db->simple_select("posts", "pid", "pid IN (".implode(",", $pids).")"); 96 while($post = $db->fetch_array($query)) 97 { 98 $action = $mybb->input['posts'][$post['pid']]; 99 if($action == "approve") 100 { 101 $posts_to_approve[] = $post['pid']; 102 } 103 else if($action == "delete" && $mybb->settings['soft_delete'] != 1) 104 { 105 $moderation->delete_post($post['pid']); 106 } 107 else if($action == "delete") 108 { 109 $posts_to_delete[] = $post['pid']; 110 } 111 } 112 if(!empty($posts_to_approve)) 113 { 114 $moderation->approve_posts($posts_to_approve); 115 } 116 if(!empty($posts_to_delete)) 117 { 118 $moderation->soft_delete_posts($posts_to_delete); 119 } 120 121 $plugins->run_hooks("admin_forum_moderation_queue_posts_commit"); 122 123 // Log admin action 124 log_admin_action('posts'); 125 126 flash_message($lang->success_posts, 'success'); 127 admin_redirect("index.php?module=forum-moderation_queue&type=posts"); 128 129 } 130 else if($mybb->get_input('attachments', MyBB::INPUT_ARRAY)) 131 { 132 $query = $db->simple_select("attachments", "aid, pid", "aid IN (".implode(",", array_map("intval", array_keys($mybb->input['attachments']))).")"); 133 while($attachment = $db->fetch_array($query)) 134 { 135 $action = $mybb->input['attachments'][$attachment['aid']]; 136 if($action == "approve") 137 { 138 $db->update_query("attachments", array("visible" => 1), "aid='{$attachment['aid']}'"); 139 } 140 else if($action == "delete") 141 { 142 remove_attachment($attachment['pid'], '', $attachment['aid']); 143 } 144 } 145 146 $plugins->run_hooks("admin_forum_moderation_queue_attachments_commit"); 147 148 // Log admin action 149 log_admin_action('attachments'); 150 151 flash_message($lang->success_attachments, 'success'); 152 admin_redirect("index.php?module=forum-moderation_queue&type=attachments"); 153 } 154 } 155 156 $all_options = "<ul class=\"modqueue_mass\">\n"; 157 $all_options .= "<li><a href=\"#\" class=\"mass_ignore\">{$lang->mark_as_ignored}</a></li>\n"; 158 $all_options .= "<li><a href=\"#\" class=\"mass_delete\">{$lang->mark_as_deleted}</a></li>\n"; 159 $all_options .= "<li><a href=\"#\" class=\"mass_approve\">{$lang->mark_as_approved}</a></li>\n"; 160 $all_options .= "</ul>\n"; 161 162 // Threads awaiting moderation 163 if(empty($mybb->input['type']) || $mybb->input['type'] == "threads") 164 { 165 $plugins->run_hooks("admin_forum_moderation_queue_threads"); 166 167 $forum_cache = $cache->read("forums"); 168 169 $query = $db->simple_select("threads", "COUNT(tid) AS unapprovedthreads", "visible=0"); 170 $unapproved_threads = $db->fetch_field($query, "unapprovedthreads"); 171 172 if($unapproved_threads > 0) 173 { 174 // Figure out if we need to display multiple pages. 175 $per_page = 15; 176 $mybb->input['page'] = $mybb->get_input('page', MyBB::INPUT_INT); 177 if($mybb->input['page'] > 0) 178 { 179 $current_page = $mybb->input['page']; 180 $start = ($current_page-1)*$per_page; 181 $pages = $unapproved_threads / $per_page; 182 $pages = ceil($pages); 183 if($current_page > $pages) 184 { 185 $start = 0; 186 $current_page = 1; 187 } 188 } 189 else 190 { 191 $start = 0; 192 $current_page = 1; 193 } 194 195 $pagination = draw_admin_pagination($current_page, $per_page, $unapproved_threads, "index.php?module=forum-moderation_queue&page={page}"); 196 197 $page->add_breadcrumb_item($lang->threads_awaiting_moderation); 198 $page->output_header($lang->threads_awaiting_moderation); 199 $page->output_nav_tabs($sub_tabs, "threads"); 200 201 $form = new Form("index.php?module=forum-moderation_queue", "post"); 202 203 $table = new Table; 204 $table->construct_header($lang->subject); 205 $table->construct_header($lang->author, array("class" => "align_center", "width" => "20%")); 206 $table->construct_header($lang->posted, array("class" => "align_center", "width" => "20%")); 207 208 $query = $db->query(" 209 SELECT t.tid, t.dateline, t.fid, t.subject, t.username AS threadusername, p.message AS postmessage, u.username AS username, t.uid 210 FROM ".TABLE_PREFIX."threads t 211 LEFT JOIN ".TABLE_PREFIX."posts p ON (p.pid=t.firstpost) 212 LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=t.uid) 213 WHERE t.visible='0' 214 ORDER BY t.lastpost DESC 215 LIMIT {$start}, {$per_page} 216 "); 217 while($thread = $db->fetch_array($query)) 218 { 219 $thread['subject'] = htmlspecialchars_uni($thread['subject']); 220 $thread['threadlink'] = get_thread_link($thread['tid']); 221 $thread['forumlink'] = get_forum_link($thread['fid']); 222 $forum_name = $forum_cache[$thread['fid']]['name']; 223 $threaddate = my_date('relative', $thread['dateline']); 224 225 if(!$thread['uid']) 226 { 227 if($thread['threadusername'] != "") 228 { 229 $profile_link = $thread['threadusername']; 230 } 231 else 232 { 233 $profile_link = htmlspecialchars_uni($lang->guest); 234 } 235 } 236 else 237 { 238 $profile_link = build_profile_link(htmlspecialchars_uni($thread['username']), $thread['uid'], "_blank"); 239 } 240 241 $thread['postmessage'] = nl2br(htmlspecialchars_uni($thread['postmessage'])); 242 243 $table->construct_cell("<a href=\"../{$thread['threadlink']}\" target=\"_blank\">{$thread['subject']}</a>"); 244 $table->construct_cell($profile_link, array("class" => "align_center")); 245 $table->construct_cell($threaddate, array("class" => "align_center")); 246 $table->construct_row(); 247 248 $controls = "<div class=\"modqueue_controls\">\n"; 249 $controls .= $form->generate_radio_button("threads[{$thread['tid']}]", "ignore", $lang->ignore, array('class' => 'radio_ignore', 'checked' => true))." "; 250 $controls .= $form->generate_radio_button("threads[{$thread['tid']}]", "delete", $lang->delete, array('class' => 'radio_delete', 'checked' => false))." "; 251 $controls .= $form->generate_radio_button("threads[{$thread['tid']}]", "approve", $lang->approve, array('class' => 'radio_approve', 'checked' => false)); 252 $controls .= "</div>"; 253 254 $forum = "<strong>{$lang->forum} <a href=\"../{$thread['forumlink']}\" target=\"_blank\">{$forum_name}</a></strong><br />"; 255 256 $table->construct_cell("<div class=\"modqueue_message\">{$controls}<div class=\"modqueue_meta\">{$forum}</div>{$thread['postmessage']}</div>", array("colspan" => 3)); 257 $table->construct_row(); 258 } 259 260 $table->output($lang->threads_awaiting_moderation, 1, "general tfixed"); 261 echo $all_options; 262 echo $pagination; 263 264 $buttons[] = $form->generate_submit_button($lang->perform_action); 265 $form->output_submit_wrapper($buttons); 266 $form->end(); 267 268 echo '<script type="text/javascript"> 269 $(".mass_ignore").on("click", function () { 270 $("input.radio_ignore").each(function(e) { 271 $(this).prop("checked", true); 272 }); 273 return false; 274 }); 275 $(".mass_delete").on("click", function () { 276 $("input.radio_delete").each(function(e) { 277 $(this).prop("checked", true); 278 }); 279 return false; 280 }); 281 $(".mass_approve").on("click", function () { 282 $("input.radio_approve").each(function(e) { 283 $(this).prop("checked", true); 284 }); 285 return false; 286 }); 287 </script>'; 288 289 $page->output_footer(); 290 } 291 } 292 293 // Posts awaiting moderation 294 if($mybb->get_input('type') == "posts" || $mybb->get_input('type') == "") 295 { 296 $plugins->run_hooks("admin_forum_moderation_queue_posts"); 297 298 $forum_cache = $cache->read("forums"); 299 300 $query = $db->query(" 301 SELECT COUNT(pid) AS unapprovedposts 302 FROM ".TABLE_PREFIX."posts p 303 LEFT JOIN ".TABLE_PREFIX."threads t ON (t.tid=p.tid) 304 WHERE p.visible='0' AND t.firstpost != p.pid 305 "); 306 $unapproved_posts = $db->fetch_field($query, "unapprovedposts"); 307 308 if($unapproved_posts > 0) 309 { 310 // Figure out if we need to display multiple pages. 311 $per_page = 15; 312 $mybb->input['page'] = $mybb->get_input('page', MyBB::INPUT_INT); 313 if($mybb->input['page'] > 0) 314 { 315 $current_page = $mybb->input['page']; 316 $start = ($current_page-1)*$per_page; 317 $pages = $unapproved_posts / $per_page; 318 $pages = ceil($pages); 319 if($current_page > $pages) 320 { 321 $start = 0; 322 $current_page = 1; 323 } 324 } 325 else 326 { 327 $start = 0; 328 $current_page = 1; 329 } 330 331 $pagination = draw_admin_pagination($current_page, $per_page, $unapproved_posts, "index.php?module=forum-moderation_queue&type=posts&page={page}"); 332 333 334 $page->add_breadcrumb_item($lang->posts_awaiting_moderation); 335 $page->output_header($lang->posts_awaiting_moderation); 336 $page->output_nav_tabs($sub_tabs, "posts"); 337 338 $form = new Form("index.php?module=forum-moderation_queue", "post"); 339 340 $table = new Table; 341 $table->construct_header($lang->subject); 342 $table->construct_header($lang->author, array("class" => "align_center", "width" => "20%")); 343 $table->construct_header($lang->posted, array("class" => "align_center", "width" => "20%")); 344 345 $query = $db->query(" 346 SELECT p.pid, p.subject, p.message, p.dateline, p.username AS postusername, t.subject AS threadsubject, t.tid, u.username, p.uid, t.fid 347 FROM ".TABLE_PREFIX."posts p 348 LEFT JOIN ".TABLE_PREFIX."threads t ON (t.tid=p.tid) 349 LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=p.uid) 350 WHERE p.visible='0' AND t.firstpost != p.pid 351 ORDER BY p.dateline DESC 352 LIMIT {$start}, {$per_page} 353 "); 354 while($post = $db->fetch_array($query)) 355 { 356 $altbg = alt_trow(); 357 $post['threadsubject'] = htmlspecialchars_uni($post['threadsubject']); 358 $post['subject'] = htmlspecialchars_uni($post['subject']); 359 360 if(!$post['subject']) 361 { 362 $post['subject'] = $lang->re." ".$post['threadsubject']; 363 } 364 365 $post['postlink'] = get_post_link($post['pid'], $post['tid']); 366 $post['threadlink'] = get_thread_link($post['tid']); 367 $post['forumlink'] = get_forum_link($post['fid']); 368 $forum_name = $forum_cache[$post['fid']]['name']; 369 $postdate = my_date('relative', $post['dateline']); 370 371 if(!$post['uid']) 372 { 373 if($post['postusername'] != "") 374 { 375 $profile_link = $post['postusername']; 376 } 377 else 378 { 379 $profile_link = $lang->guest; 380 } 381 } 382 else 383 { 384 $profile_link = build_profile_link(htmlspecialchars_uni($post['username']), $post['uid'], "_blank"); 385 } 386 387 $post['message'] = nl2br(htmlspecialchars_uni($post['message'])); 388 389 $table->construct_cell("<a href=\"../{$post['postlink']}#pid{$post['pid']}\" target=\"_blank\">{$post['subject']}</a>"); 390 $table->construct_cell($profile_link, array("class" => "align_center")); 391 $table->construct_cell($postdate, array("class" => "align_center")); 392 $table->construct_row(); 393 394 $controls = "<div class=\"modqueue_controls\">\n"; 395 $controls .= $form->generate_radio_button("posts[{$post['pid']}]", "ignore", $lang->ignore, array('class' => 'radio_ignore', 'checked' => true))." "; 396 $controls .= $form->generate_radio_button("posts[{$post['pid']}]", "delete",$lang->delete, array('class' => 'radio_delete', 'checked' => false))." "; 397 $controls .= $form->generate_radio_button("posts[{$post['pid']}]", "approve", $lang->approve, array('class' => 'radio_approve', 'checked' => false)); 398 $controls .= "</div>"; 399 400 $thread = "<strong>{$lang->thread} <a href=\"../{$post['threadlink']}\" target=\"_blank\">{$post['threadsubject']}</a></strong>"; 401 $forum = "<strong>{$lang->forum} <a href=\"../{$post['forumlink']}\" target=\"_blank\">{$forum_name}</a></strong><br />"; 402 403 $table->construct_cell("<div class=\"modqueue_message\">{$controls}<div class=\"modqueue_meta\">{$forum}{$thread}</div>{$post['message']}</div>", array("colspan" => 3)); 404 $table->construct_row(); 405 } 406 407 $table->output($lang->posts_awaiting_moderation, 1, "general tfixed"); 408 echo $all_options; 409 echo $pagination; 410 411 $buttons[] = $form->generate_submit_button($lang->perform_action); 412 $form->output_submit_wrapper($buttons); 413 $form->end(); 414 415 echo '<script type="text/javascript"> 416 $(".mass_ignore").on("click", function () { 417 $("input.radio_ignore").each(function(e) { 418 $(this).prop("checked", true); 419 }); 420 return false; 421 }); 422 $(".mass_delete").on("click", function () { 423 $("input.radio_delete").each(function(e) { 424 $(this).prop("checked", true); 425 }); 426 return false; 427 }); 428 $(".mass_approve").on("click", function () { 429 $("input.radio_approve").each(function(e) { 430 $(this).prop("checked", true); 431 }); 432 return false; 433 }); 434 </script>'; 435 436 $page->output_footer(); 437 } 438 else if($mybb->get_input('type') == "posts") 439 { 440 $page->output_header($lang->moderation_queue); 441 $page->output_nav_tabs($sub_tabs, "posts"); 442 echo "<p class=\"notice\">{$lang->error_no_posts}</p>"; 443 $page->output_footer(); 444 } 445 } 446 447 // Attachments awaiting moderation 448 if($mybb->get_input('type') == "attachments" || $mybb->get_input('type') == "") 449 { 450 $plugins->run_hooks("admin_forum_moderation_queue_attachments"); 451 452 $query = $db->query(" 453 SELECT COUNT(aid) AS unapprovedattachments 454 FROM ".TABLE_PREFIX."attachments a 455 LEFT JOIN ".TABLE_PREFIX."posts p ON (p.pid=a.pid) 456 LEFT JOIN ".TABLE_PREFIX."threads t ON (t.tid=p.tid) 457 WHERE a.visible='0' 458 "); 459 $unapproved_attachments = $db->fetch_field($query, "unapprovedattachments"); 460 461 if($unapproved_attachments > 0) 462 { 463 // Figure out if we need to display multiple pages. 464 $per_page = 15; 465 $mybb->input['page'] = $mybb->get_input('page', MyBB::INPUT_INT); 466 if($mybb->input['page'] > 0) 467 { 468 $current_page = $mybb->input['page']; 469 $start = ($current_page-1)*$per_page; 470 $pages = $unapproved_attachments / $per_page; 471 $pages = ceil($pages); 472 if($current_page > $pages) 473 { 474 $start = 0; 475 $current_page = 1; 476 } 477 } 478 else 479 { 480 $start = 0; 481 $current_page = 1; 482 } 483 484 $pagination = draw_admin_pagination($current_page, $per_page, $unapproved_attachments, "index.php?module=forum-moderation_queue&type=attachments&page={page}"); 485 486 $page->add_breadcrumb_item($lang->attachments_awaiting_moderation); 487 $page->output_header($lang->attachments_awaiting_moderation); 488 $page->output_nav_tabs($sub_tabs, "attachments"); 489 490 $form = new Form("index.php?module=forum-moderation_queue", "post"); 491 492 $table = new Table; 493 $table->construct_header($lang->filename); 494 $table->construct_header($lang->uploadedby, array("class" => "align_center", "width" => "20%")); 495 $table->construct_header($lang->posted, array("class" => "align_center", "width" => "20%")); 496 $table->construct_header($lang->controls, array("class" => "align_center", "colspan" => 3)); 497 498 $query = $db->query(" 499 SELECT a.*, p.subject AS postsubject, p.dateline, p.username AS postusername, p.uid, u.username, t.tid, t.subject AS threadsubject 500 FROM ".TABLE_PREFIX."attachments a 501 LEFT JOIN ".TABLE_PREFIX."posts p ON (p.pid=a.pid) 502 LEFT JOIN ".TABLE_PREFIX."threads t ON (t.tid=p.tid) 503 LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=p.uid) 504 WHERE a.visible='0' 505 ORDER BY a.dateuploaded DESC 506 LIMIT {$start}, {$per_page} 507 "); 508 509 while($attachment = $db->fetch_array($query)) 510 { 511 if(!$attachment['dateuploaded']) $attachment['dateuploaded'] = $attachment['dateline']; 512 $attachdate = my_date('relative', $attachment['dateuploaded']); 513 514 $attachment['postsubject'] = htmlspecialchars_uni($attachment['postsubject']); 515 $attachment['filename'] = htmlspecialchars_uni($attachment['filename']); 516 $attachment['threadsubject'] = htmlspecialchars_uni($attachment['threadsubject']); 517 $attachment['filesize'] = get_friendly_size($attachment['filesize']); 518 519 $link = get_post_link($attachment['pid'], $attachment['tid']) . "#pid{$attachment['pid']}"; 520 $thread_link = get_thread_link($attachment['tid']); 521 522 if(!$attachment['uid']) 523 { 524 if($attachment['postusername'] != "") 525 { 526 $profile_link = $attachment['postusername']; 527 } 528 else 529 { 530 $profile_link = htmlspecialchars_uni($lang->guest); 531 } 532 } 533 else 534 { 535 $profile_link = build_profile_link(htmlspecialchars_uni($attachment['username']), $attachment['uid'], "_blank"); 536 } 537 538 $table->construct_cell("<a href=\"../attachment.php?aid={$attachment['aid']}\" target=\"_blank\">{$attachment['filename']}</a> ({$attachment['filesize']})<br /><small class=\"modqueue_meta\">{$lang->post} <a href=\"{$link}\" target=\"_blank\">{$attachment['postsubject']}</a></small>"); 539 $table->construct_cell($profile_link, array("class" => "align_center")); 540 $table->construct_cell($attachdate, array("class" => "align_center")); 541 542 $table->construct_cell($form->generate_radio_button("attachments[{$attachment['aid']}]", "ignore", $lang->ignore, array('class' => 'radio_ignore', 'checked' => true)), array("class" => "align_center")); 543 $table->construct_cell($form->generate_radio_button("attachments[{$attachment['aid']}]", "delete", $lang->delete, array('class' => 'radio_delete', 'checked' => false)), array("class" => "align_center")); 544 $table->construct_cell($form->generate_radio_button("attachments[{$attachment['aid']}]", "approve", $lang->approve, array('class' => 'radio_approve', 'checked' => false)), array("class" => "align_center")); 545 $table->construct_row(); 546 } 547 $table->output($lang->attachments_awaiting_moderation); 548 echo $all_options; 549 echo $pagination; 550 551 $buttons[] = $form->generate_submit_button($lang->perform_action); 552 $form->output_submit_wrapper($buttons); 553 $form->end(); 554 555 echo '<script type="text/javascript"> 556 $(".mass_ignore").on("click", function () { 557 $("input.radio_ignore").each(function(e) { 558 $(this).prop("checked", true); 559 }); 560 return false; 561 }); 562 $(".mass_delete").on("click", function () { 563 $("input.radio_delete").each(function(e) { 564 $(this).prop("checked", true); 565 }); 566 return false; 567 }); 568 $(".mass_approve").on("click", function () { 569 $("input.radio_approve").each(function(e) { 570 $(this).prop("checked", true); 571 }); 572 return false; 573 }); 574 </script>'; 575 576 $page->output_footer(); 577 } 578 else if($mybb->get_input('type') == "attachments") 579 { 580 $page->output_header($lang->moderation_queue); 581 $page->output_nav_tabs($sub_tabs, "attachments"); 582 echo "<p class=\"notice\">{$lang->error_no_attachments}</p>"; 583 $page->output_footer(); 584 } 585 } 586 587 // Still nothing? All queues are empty! :-D 588 $page->output_header($lang->moderation_queue); 589 echo "<p class=\"notice\">{$lang->error_no_threads}</p>"; 590 $page->output_footer();
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
2005 - 2021 © MyBB.de | Alle Rechte vorbehalten! | Sponsor: netcup | Cross-referenced by PHPXref |