[ 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->warning_logs, "index.php?module=tools-warninglog"); 18 19 $plugins->run_hooks("admin_tools_warninglog_begin"); 20 21 // Revoke a warning 22 if($mybb->input['action'] == "do_revoke" && $mybb->request_method == "post") 23 { 24 $query = $db->simple_select("warnings", "*", "wid='".$mybb->get_input('wid', MyBB::INPUT_INT)."'"); 25 $warning = $db->fetch_array($query); 26 27 if(!$warning) 28 { 29 flash_message($lang->error_invalid_warning, 'error'); 30 admin_redirect("index.php?module=tools-warninglog"); 31 } 32 else if($warning['daterevoked']) 33 { 34 flash_message($lang->error_already_revoked, 'error'); 35 admin_redirect("index.php?module=tools-warninglog&action=view&wid={$warning['wid']}"); 36 } 37 38 $user = get_user($warning['uid']); 39 40 $plugins->run_hooks("admin_tools_warninglog_do_revoke"); 41 42 if(!trim($mybb->input['reason'])) 43 { 44 $warn_errors[] = $lang->error_no_revoke_reason; 45 $mybb->input['action'] = "view"; 46 } 47 else 48 { 49 // Warning is still active, lower users point count 50 if($warning['expired'] != 1) 51 { 52 $new_warning_points = $user['warningpoints']-$warning['points']; 53 if($new_warning_points < 0) 54 { 55 $new_warning_points = 0; 56 } 57 58 // Update user 59 $updated_user = array( 60 "warningpoints" => $new_warning_points 61 ); 62 } 63 64 // Update warning 65 $updated_warning = array( 66 "expired" => 1, 67 "daterevoked" => TIME_NOW, 68 "revokedby" => $mybb->user['uid'], 69 "revokereason" => $db->escape_string($mybb->input['reason']) 70 ); 71 72 $plugins->run_hooks("admin_tools_warninglog_do_revoke_commit"); 73 74 if($warning['expired'] != 1) 75 { 76 $db->update_query("users", $updated_user, "uid='{$warning['uid']}'"); 77 } 78 79 $db->update_query("warnings", $updated_warning, "wid='{$warning['wid']}'"); 80 81 flash_message($lang->redirect_warning_revoked, 'success'); 82 admin_redirect("index.php?module=tools-warninglog&action=view&wid={$warning['wid']}"); 83 } 84 } 85 86 // Detailed view of a warning 87 if($mybb->input['action'] == "view") 88 { 89 $query = $db->query(" 90 SELECT w.*, t.title AS type_title, u.username, p.subject AS post_subject 91 FROM ".TABLE_PREFIX."warnings w 92 LEFT JOIN ".TABLE_PREFIX."warningtypes t ON (t.tid=w.tid) 93 LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=w.issuedby) 94 LEFT JOIN ".TABLE_PREFIX."posts p ON (p.pid=w.pid) 95 WHERE w.wid='".$mybb->get_input('wid', MyBB::INPUT_INT)."' 96 "); 97 $warning = $db->fetch_array($query); 98 99 if(!$warning) 100 { 101 flash_message($lang->error_invalid_warning, 'error'); 102 admin_redirect("index.php?module=tools-warninglog"); 103 } 104 105 $user = get_user((int)$warning['uid']); 106 107 $plugins->run_hooks("admin_tools_warninglog_view"); 108 109 $page->add_breadcrumb_item($lang->warning_details, "index.php?module=tools-warninglog&action=view&wid={$warning['wid']}"); 110 111 $page->output_header($lang->warning_details); 112 113 $user_link = build_profile_link(htmlspecialchars_uni($user['username']), $user['uid'], "_blank"); 114 115 if(isset($warn_errors) && is_array($warn_errors)) 116 { 117 $page->output_inline_error($warn_errors); 118 $mybb->input['reason'] = htmlspecialchars_uni($mybb->input['reason']); 119 } 120 121 $table = new Table; 122 123 $post_link = ""; 124 if($warning['post_subject']) 125 { 126 if(!is_object($parser)) 127 { 128 require_once MYBB_ROOT."inc/class_parser.php"; 129 $parser = new postParser; 130 } 131 132 $warning['post_subject'] = $parser->parse_badwords($warning['post_subject']); 133 $warning['post_subject'] = htmlspecialchars_uni($warning['post_subject']); 134 $post_link = get_post_link($warning['pid']); 135 $table->construct_cell("<strong>{$lang->warned_user}</strong><br /><br />{$user_link}"); 136 $table->construct_cell("<strong>{$lang->post}</strong><br /><br /><a href=\"{$mybb->settings['bburl']}/{$post_link}\" target=\"_blank\">{$warning['post_subject']}</a>"); 137 $table->construct_row(); 138 } 139 else 140 { 141 $table->construct_cell("<strong>{$lang->warned_user}</strong><br /><br />{$user_link}", array('colspan' => 2)); 142 $table->construct_row(); 143 } 144 145 $issuedby = build_profile_link(htmlspecialchars_uni($warning['username']), $warning['issuedby'], "_blank"); 146 $notes = nl2br(htmlspecialchars_uni($warning['notes'])); 147 148 $date_issued = my_date('relative', $warning['dateline']); 149 if($warning['type_title']) 150 { 151 $warning_type = $warning['type_title']; 152 } 153 else 154 { 155 $warning_type = $warning['title']; 156 } 157 $warning_type = htmlspecialchars_uni($warning_type); 158 if($warning['points'] > 0) 159 { 160 $warning['points'] = "+{$warning['points']}"; 161 } 162 163 $points = $lang->sprintf($lang->warning_points, $warning['points']); 164 if($warning['expired'] != 1) 165 { 166 if($warning['expires'] == 0) 167 { 168 $expires = $lang->never; 169 } 170 else 171 { 172 $expires = my_date('relative', $warning['expires']); 173 } 174 $status = $lang->warning_active; 175 } 176 else 177 { 178 if($warning['daterevoked']) 179 { 180 $expires = $status = $lang->warning_revoked; 181 } 182 else if($warning['expires']) 183 { 184 $expires = $status = $lang->already_expired; 185 } 186 } 187 188 $table->construct_cell("<strong>{$lang->warning}</strong><br /><br />{$warning_type} {$points}", array('width' => '50%')); 189 $table->construct_cell("<strong>{$lang->date_issued}</strong><br /><br />{$date_issued}", array('width' => '50%')); 190 $table->construct_row(); 191 192 $table->construct_cell("<strong>{$lang->issued_by}</strong><br /><br />{$issuedby}", array('width' => '50%')); 193 $table->construct_cell("<strong>{$lang->expires}</strong><br /><br />{$expires}", array('width' => '50%')); 194 $table->construct_row(); 195 196 $table->construct_cell("<strong>{$lang->warning_note}</strong><br /><br />{$notes}", array('colspan' => 2)); 197 $table->construct_row(); 198 199 $table->output("<div class=\"float_right\" style=\"font-weight: normal;\">{$status}</div>".$lang->warning_details); 200 201 if(!$warning['daterevoked']) 202 { 203 $form = new Form("index.php?module=tools-warninglog", "post"); 204 $form_container = new FormContainer($lang->revoke_warning); 205 echo $form->generate_hidden_field('action', 'do_revoke'); 206 echo $form->generate_hidden_field('wid', $warning['wid']); 207 $form_container->output_row("", $lang->revoke_warning_desc, $form->generate_text_area('reason', $mybb->get_input('reason'), array('id' => 'reason')), 'reason'); 208 209 $form_container->end(); 210 $buttons[] = $form->generate_submit_button($lang->revoke_warning); 211 $form->output_submit_wrapper($buttons); 212 $form->end(); 213 } 214 else 215 { 216 $date_revoked = my_date('relative', $warning['daterevoked']); 217 $revoked_user = get_user($warning['revokedby']); 218 $revoked_by = build_profile_link(htmlspecialchars_uni($revoked_user['username']), $revoked_user['uid'], "_blank"); 219 $revoke_reason = nl2br(htmlspecialchars_uni($warning['revokereason'])); 220 221 $revoke_table = new Table; 222 $revoke_table->construct_cell("<strong>{$lang->revoked_by}</strong><br /><br />{$revoked_by}", array('width' => '50%')); 223 $revoke_table->construct_cell("<strong>{$lang->date_revoked}</strong><br /><br />{$date_revoked}", array('width' => '50%')); 224 $revoke_table->construct_row(); 225 226 $revoke_table->construct_cell("<strong>{$lang->reason}</strong><br /><br />{$revoke_reason}", array('colspan' => 2)); 227 $revoke_table->construct_row(); 228 229 $revoke_table->output($lang->warning_is_revoked); 230 } 231 232 $page->output_footer(); 233 } 234 235 if(!$mybb->input['action']) 236 { 237 $plugins->run_hooks("admin_tools_warninglog_start"); 238 239 $page->output_header($lang->warning_logs); 240 241 $sub_tabs['warning_logs'] = array( 242 'title' => $lang->warning_logs, 243 'link' => "index.php?module=tools-warninglog", 244 'description' => $lang->warning_logs_desc 245 ); 246 247 $page->output_nav_tabs($sub_tabs, 'warning_logs'); 248 249 if(empty($mybb->input['filter'])) 250 { 251 $mybb->input['filter'] = array(); 252 } 253 254 // Filter options 255 $where_sql = ''; 256 if(!empty($mybb->input['filter']['username'])) 257 { 258 $search_user = get_user_by_username($mybb->input['filter']['username']); 259 260 $mybb->input['filter']['uid'] = (int)$search_user['uid']; 261 } 262 if(!empty($mybb->input['filter']['uid'])) 263 { 264 $search['uid'] = (int)$mybb->input['filter']['uid']; 265 $where_sql .= " AND w.uid='{$search['uid']}'"; 266 if(!isset($mybb->input['search']['username'])) 267 { 268 $user = get_user($mybb->input['search']['uid']); 269 $mybb->input['search']['username'] = $user['username']; 270 } 271 } 272 if(!empty($mybb->input['filter']['mod_username'])) 273 { 274 $mod_user = get_user_by_username($mybb->input['filter']['mod_username']); 275 276 $mybb->input['filter']['mod_uid'] = (int)$mod_user['uid']; 277 } 278 if(!empty($mybb->input['filter']['mod_uid'])) 279 { 280 $search['mod_uid'] = (int)$mybb->input['filter']['mod_uid']; 281 $where_sql .= " AND w.issuedby='{$search['mod_uid']}'"; 282 if(!isset($mybb->input['search']['mod_username'])) 283 { 284 $mod_user = get_user($mybb->input['search']['uid']); 285 $mybb->input['search']['mod_username'] = $mod_user['username']; 286 } 287 } 288 if(!empty($mybb->input['filter']['reason'])) 289 { 290 $search['reason'] = $db->escape_string_like($mybb->input['filter']['reason']); 291 $where_sql .= " AND (w.notes LIKE '%{$search['reason']}%' OR t.title LIKE '%{$search['reason']}%' OR w.title LIKE '%{$search['reason']}%')"; 292 } 293 $sortbysel = array(); 294 $sortby_input = ''; 295 if(!empty($mybb->input['filter']['sortby'])) 296 { 297 $sortby_input = $mybb->input['filter']['sortby']; 298 } 299 switch($sortby_input) 300 { 301 case "username": 302 $sortby = "u.username"; 303 $sortbysel['username'] = ' selected="selected"'; 304 break; 305 case "expires": 306 $sortby = "w.expires"; 307 $sortbysel['expires'] = ' selected="selected"'; 308 break; 309 case "issuedby": 310 $sortby = "i.username"; 311 $sortbysel['issuedby'] = ' selected="selected"'; 312 break; 313 default: // "dateline" 314 $sortby = "w.dateline"; 315 $sortbysel['dateline'] = ' selected="selected"'; 316 } 317 $ordersel = array(); 318 if(empty($mybb->input['filter']['order']) || $mybb->input['filter']['order'] != "asc") 319 { 320 $order = "desc"; 321 $ordersel['desc'] = ' selected="selected"'; 322 } 323 else 324 { 325 $ordersel['asc'] = ' selected="selected"'; 326 } 327 328 // Expire any warnings past their expiration date 329 require_once MYBB_ROOT.'inc/datahandlers/warnings.php'; 330 $warningshandler = new WarningsHandler('update'); 331 332 $warningshandler->expire_warnings(); 333 334 // Pagination stuff 335 $sql = " 336 SELECT COUNT(wid) as count 337 FROM 338 ".TABLE_PREFIX."warnings w 339 LEFT JOIN ".TABLE_PREFIX."warningtypes t ON (w.tid=t.tid) 340 WHERE 1=1 341 {$where_sql} 342 "; 343 $query = $db->query($sql); 344 $total_warnings = $db->fetch_field($query, 'count'); 345 $view_page = 1; 346 if(isset($mybb->input['page']) && $mybb->get_input('page', MyBB::INPUT_INT) > 0) 347 { 348 $view_page = $mybb->get_input('page', MyBB::INPUT_INT); 349 } 350 $per_page = 20; 351 if(isset($mybb->input['filter']['per_page']) && (int)$mybb->input['filter']['per_page'] > 0) 352 { 353 $per_page = (int)$mybb->input['filter']['per_page']; 354 } 355 $start = ($view_page-1) * $per_page; 356 $pages = ceil($total_warnings / $per_page); 357 if($view_page > $pages) 358 { 359 $start = 0; 360 $view_page = 1; 361 } 362 // Build the base URL for pagination links 363 $url = 'index.php?module=tools-warninglog'; 364 if(is_array($mybb->input['filter']) && count($mybb->input['filter'])) 365 { 366 foreach($mybb->input['filter'] as $field => $value) 367 { 368 $value = urlencode($value); 369 $url .= "&filter[{$field}]={$value}"; 370 } 371 } 372 373 // The actual query 374 $sql = " 375 SELECT 376 w.wid, w.title as custom_title, w.points, w.dateline, w.issuedby, w.expires, w.expired, w.daterevoked, w.revokedby, 377 t.title, 378 u.uid, u.username, u.usergroup, u.displaygroup, 379 i.uid as mod_uid, i.username as mod_username, i.usergroup as mod_usergroup, i.displaygroup as mod_displaygroup 380 FROM ".TABLE_PREFIX."warnings w 381 LEFT JOIN ".TABLE_PREFIX."users u on (w.uid=u.uid) 382 LEFT JOIN ".TABLE_PREFIX."warningtypes t ON (w.tid=t.tid) 383 LEFT JOIN ".TABLE_PREFIX."users i ON (i.uid=w.issuedby) 384 WHERE 1=1 385 {$where_sql} 386 ORDER BY {$sortby} {$order} 387 LIMIT {$start}, {$per_page} 388 "; 389 $query = $db->query($sql); 390 391 392 $table = new Table; 393 $table->construct_header($lang->warned_user, array('width' => '15%')); 394 $table->construct_header($lang->warning, array("class" => "align_center", 'width' => '25%')); 395 $table->construct_header($lang->date_issued, array("class" => "align_center", 'width' => '20%')); 396 $table->construct_header($lang->expires, array("class" => "align_center", 'width' => '20%')); 397 $table->construct_header($lang->issued_by, array("class" => "align_center", 'width' => '15%')); 398 $table->construct_header($lang->options, array("class" => "align_center", 'width' => '5%')); 399 400 while($row = $db->fetch_array($query)) 401 { 402 if(!$row['username']) 403 { 404 $row['username'] = $lang->guest; 405 } 406 407 $trow = alt_trow(); 408 $username = format_name(htmlspecialchars_uni($row['username']), $row['usergroup'], $row['displaygroup']); 409 if(!$row['uid']) 410 { 411 $username_link = $username; 412 } 413 else 414 { 415 $username_link = build_profile_link($username, $row['uid'], "_blank"); 416 } 417 $mod_username = format_name(htmlspecialchars_uni($row['mod_username']), $row['mod_usergroup'], $row['mod_displaygroup']); 418 $mod_username_link = build_profile_link($mod_username, $row['mod_uid'], "_blank"); 419 $issued_date = my_date('relative', $row['dateline']); 420 $revoked_text = ''; 421 if($row['daterevoked'] > 0) 422 { 423 $revoked_date = my_date('relative', $row['daterevoked']); 424 $revoked_text = "<br /><small><strong>{$lang->revoked}</strong> {$revoked_date}</small>"; 425 } 426 if($row['expires'] > 0) 427 { 428 $expire_date = my_date('relative', $row['expires']); 429 } 430 else 431 { 432 $expire_date = $lang->never; 433 } 434 $title = $row['title']; 435 if(empty($row['title'])) 436 { 437 $title = $row['custom_title']; 438 } 439 $title = htmlspecialchars_uni($title); 440 if($row['points'] > 0) 441 { 442 $row['points'] = "+{$row['points']}"; 443 } 444 $points = $lang->sprintf($lang->warning_points, $row['points']); 445 446 $table->construct_cell($username_link); 447 $table->construct_cell("{$title} {$points}"); 448 $table->construct_cell($issued_date, array("class" => "align_center")); 449 $table->construct_cell($expire_date.$revoked_text, array("class" => "align_center")); 450 $table->construct_cell($mod_username_link); 451 $table->construct_cell("<a href=\"index.php?module=tools-warninglog&action=view&wid={$row['wid']}\">{$lang->view}</a>", array("class" => "align_center")); 452 $table->construct_row(); 453 } 454 455 if($table->num_rows() == 0) 456 { 457 $table->construct_cell($lang->no_warning_logs, array("colspan" => "6")); 458 $table->construct_row(); 459 } 460 461 $table->output($lang->warning_logs); 462 463 // Do we need to construct the pagination? 464 if($total_warnings > $per_page) 465 { 466 echo draw_admin_pagination($view_page, $per_page, $total_warnings, $url)."<br />"; 467 } 468 469 $sort_by = array( 470 'expires' => $lang->expiry_date, 471 'dateline' => $lang->issued_date, 472 'username' => $lang->warned_user, 473 'issuedby' => $lang->issued_by 474 ); 475 476 $order_array = array( 477 'asc' => $lang->asc, 478 'desc' => $lang->desc 479 ); 480 481 $user_filters = array(); 482 $input_filters = $mybb->get_input('filter', MyBB::INPUT_ARRAY); 483 foreach(array('username', 'mod_username', 'reason', 'sortby') as $key) 484 { 485 if(isset($input_filters[$key])) 486 { 487 $user_filters[$key] = $input_filters[$key]; 488 } 489 else 490 { 491 $user_filters[$key] = ''; 492 } 493 } 494 495 $form = new Form("index.php?module=tools-warninglog", "post"); 496 $form_container = new FormContainer($lang->filter_warning_logs); 497 $form_container->output_row($lang->filter_warned_user, "", $form->generate_text_box('filter[username]', $user_filters['username'], array('id' => 'filter_username')), 'filter_username'); 498 $form_container->output_row($lang->filter_issued_by, "", $form->generate_text_box('filter[mod_username]', $user_filters['mod_username'], array('id' => 'filter_mod_username')), 'filter_mod_username'); 499 $form_container->output_row($lang->filter_reason, "", $form->generate_text_box('filter[reason]', $user_filters['reason'], array('id' => 'filter_reason')), 'filter_reason'); 500 $form_container->output_row($lang->sort_by, "", $form->generate_select_box('filter[sortby]', $sort_by, $user_filters['sortby'], array('id' => 'filter_sortby'))." {$lang->in} ".$form->generate_select_box('filter[order]', $order_array, $order, array('id' => 'filter_order'))." {$lang->order}", 'filter_order'); 501 $form_container->output_row($lang->results_per_page, "", $form->generate_numeric_field('filter[per_page]', $per_page, array('id' => 'filter_per_page', 'min' => 1)), 'filter_per_page'); 502 503 $form_container->end(); 504 $buttons[] = $form->generate_submit_button($lang->filter_warning_logs); 505 $form->output_submit_wrapper($buttons); 506 $form->end(); 507 508 $page->output_footer(); 509 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
2005 - 2021 © MyBB.de | Alle Rechte vorbehalten! | Sponsor: netcup | Cross-referenced by PHPXref |