[ 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->mod_logs, "index.php?module=tools-modlog"); 18 19 $sub_tabs['mod_logs'] = array( 20 'title' => $lang->mod_logs, 21 'link' => "index.php?module=tools-modlog", 22 'description' => $lang->mod_logs_desc 23 ); 24 $sub_tabs['prune_mod_logs'] = array( 25 'title' => $lang->prune_mod_logs, 26 'link' => "index.php?module=tools-modlog&action=prune", 27 'description' => $lang->prune_mod_logs_desc 28 ); 29 30 $plugins->run_hooks("admin_tools_modlog_begin"); 31 32 if($mybb->input['action'] == 'prune') 33 { 34 $plugins->run_hooks("admin_tools_modlog_prune"); 35 36 if($mybb->request_method == 'post') 37 { 38 $is_today = false; 39 $mybb->input['older_than'] = $mybb->get_input('older_than', MyBB::INPUT_INT); 40 if($mybb->input['older_than'] <= 0) 41 { 42 $is_today = true; 43 $mybb->input['older_than'] = 1; 44 } 45 $where = 'dateline < '.(TIME_NOW-($mybb->input['older_than']*86400)); 46 47 // Searching for entries by a particular user 48 if($mybb->input['uid']) 49 { 50 $where .= " AND uid='".$mybb->get_input('uid', MyBB::INPUT_INT)."'"; 51 } 52 53 // Searching for entries in a specific module 54 if($mybb->input['fid'] > 0) 55 { 56 $where .= " AND fid='".$db->escape_string($mybb->input['fid'])."'"; 57 } 58 else 59 { 60 $mybb->input['fid'] = 0; 61 } 62 63 $db->delete_query("moderatorlog", $where); 64 $num_deleted = $db->affected_rows(); 65 66 $plugins->run_hooks("admin_tools_modlog_prune_commit"); 67 68 if(!isset($forum_cache) || !is_array($forum_cache)) 69 { 70 $forum_cache = cache_forums(); 71 } 72 73 // Log admin action 74 if(!empty($forum_cache[$mybb->get_input('fid')]['name'])) 75 { 76 $name = $forum_cache[$mybb->get_input('fid')]['name']; 77 } else 78 { 79 $name = null; 80 } 81 82 log_admin_action($mybb->get_input('older_than'), $mybb->get_input('uid'), $mybb->get_input('fid'), $num_deleted, $name); 83 84 $success = $lang->success_pruned_mod_logs; 85 if($is_today == true && $num_deleted > 0) 86 { 87 $success .= ' '.$lang->note_logs_locked; 88 } 89 elseif($is_today == true && $num_deleted == 0) 90 { 91 flash_message($lang->note_logs_locked, 'error'); 92 admin_redirect("index.php?module=tools-modlog"); 93 } 94 flash_message($success, 'success'); 95 admin_redirect("index.php?module=tools-modlog"); 96 } 97 $page->add_breadcrumb_item($lang->prune_mod_logs, "index.php?module=tools-modlog&action=prune"); 98 $page->output_header($lang->prune_mod_logs); 99 $page->output_nav_tabs($sub_tabs, 'prune_mod_logs'); 100 101 // Fetch filter options 102 $sortbysel[$mybb->get_input('sortby')] = 'selected="selected"'; 103 $ordersel[$mybb->get_input('order')] = 'selected="selected"'; 104 105 $user_options[''] = $lang->all_moderators; 106 $user_options['0'] = '----------'; 107 108 $query = $db->query(" 109 SELECT DISTINCT l.uid, u.username 110 FROM ".TABLE_PREFIX."moderatorlog l 111 LEFT JOIN ".TABLE_PREFIX."users u ON (l.uid=u.uid) 112 ORDER BY u.username ASC 113 "); 114 while($user = $db->fetch_array($query)) 115 { 116 // Deleted Users 117 if(!$user['username']) 118 { 119 $user['username'] = htmlspecialchars_uni($lang->na_deleted); 120 } 121 122 $user_options[$user['uid']] = htmlspecialchars_uni($user['username']); 123 } 124 125 $form = new Form("index.php?module=tools-modlog&action=prune", "post"); 126 $form_container = new FormContainer($lang->prune_moderator_logs); 127 $form_container->output_row($lang->forum, "", $form->generate_forum_select('fid', $mybb->get_input('fid'), array('id' => 'fid', 'main_option' => $lang->all_forums)), 'fid'); 128 $form_container->output_row($lang->forum_moderator, "", $form->generate_select_box('uid', $user_options, $mybb->get_input('uid'), array('id' => 'uid')), 'uid'); 129 if(!$mybb->get_input('older_than')) 130 { 131 $mybb->input['older_than'] = '30'; 132 } 133 $form_container->output_row($lang->date_range, "", $lang->older_than.$form->generate_numeric_field('older_than', $mybb->get_input('older_than'), array('id' => 'older_than', 'style' => 'width: 50px', 'min' => 0)).' '.$lang->days, 'older_than'); 134 $form_container->end(); 135 $buttons[] = $form->generate_submit_button($lang->prune_moderator_logs); 136 $form->output_submit_wrapper($buttons); 137 $form->end(); 138 139 $page->output_footer(); 140 } 141 142 if(!$mybb->input['action']) 143 { 144 $plugins->run_hooks("admin_tools_modlog_start"); 145 146 $page->output_header($lang->mod_logs); 147 148 $page->output_nav_tabs($sub_tabs, 'mod_logs'); 149 150 $perpage = $mybb->get_input('perpage', MyBB::INPUT_INT); 151 if(!$perpage) 152 { 153 if(!$mybb->settings['threadsperpage'] || (int)$mybb->settings['threadsperpage'] < 1) 154 { 155 $mybb->settings['threadsperpage'] = 20; 156 } 157 158 $perpage = $mybb->settings['threadsperpage']; 159 } 160 161 $where = 'WHERE 1=1'; 162 163 // Searching for entries by a particular user 164 $mybb->input['uid'] = $mybb->get_input('uid', MyBB::INPUT_INT); 165 if($mybb->input['uid'] > 0) 166 { 167 $where .= " AND l.uid='".$mybb->input['uid']."'"; 168 } 169 170 // Searching for entries in a specific forum 171 $mybb->input['fid'] = $mybb->get_input('fid', MyBB::INPUT_INT); 172 if($mybb->input['fid'] > 0) 173 { 174 $where .= " AND l.fid='".$mybb->input['fid']."'"; 175 } 176 177 // Order? 178 $mybb->input['sortby'] = $mybb->get_input('sortby'); 179 switch($mybb->input['sortby']) 180 { 181 case "username": 182 $sortby = "u.username"; 183 break; 184 case "forum": 185 $sortby = "f.name"; 186 break; 187 case "thread": 188 $sortby = "t.subject"; 189 break; 190 default: 191 $sortby = "l.dateline"; 192 } 193 $order = $mybb->get_input('order'); 194 if($order != "asc") 195 { 196 $order = "desc"; 197 } 198 199 $query = $db->query(" 200 SELECT COUNT(l.dateline) AS count 201 FROM ".TABLE_PREFIX."moderatorlog l 202 {$where} 203 "); 204 $rescount = $db->fetch_field($query, "count"); 205 206 // Figure out if we need to display multiple pages. 207 if($mybb->get_input('page') != "last") 208 { 209 $pagecnt = $mybb->get_input('page', MyBB::INPUT_INT); 210 } 211 212 $postcount = (int)$rescount; 213 $pages = $postcount / $perpage; 214 $pages = ceil($pages); 215 216 if($mybb->get_input('page') == "last") 217 { 218 $pagecnt = $pages; 219 } 220 221 if($pagecnt > $pages) 222 { 223 $pagecnt = 1; 224 } 225 226 if($pagecnt) 227 { 228 $start = ($pagecnt-1) * $perpage; 229 } 230 else 231 { 232 $start = 0; 233 $pagecnt = 1; 234 } 235 236 $table = new Table; 237 $table->construct_header($lang->username, array('width' => '10%')); 238 $table->construct_header($lang->date, array("class" => "align_center", 'width' => '15%')); 239 $table->construct_header($lang->action, array("class" => "align_center", 'width' => '35%')); 240 $table->construct_header($lang->information, array("class" => "align_center", 'width' => '30%')); 241 $table->construct_header($lang->ipaddress, array("class" => "align_center", 'width' => '10%')); 242 243 $query = $db->query(" 244 SELECT l.*, u.username, u.usergroup, u.displaygroup, t.subject AS tsubject, f.name AS fname, p.subject AS psubject 245 FROM ".TABLE_PREFIX."moderatorlog l 246 LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=l.uid) 247 LEFT JOIN ".TABLE_PREFIX."threads t ON (t.tid=l.tid) 248 LEFT JOIN ".TABLE_PREFIX."forums f ON (f.fid=l.fid) 249 LEFT JOIN ".TABLE_PREFIX."posts p ON (p.pid=l.pid) 250 {$where} 251 ORDER BY {$sortby} {$order} 252 LIMIT {$start}, {$perpage} 253 "); 254 while($logitem = $db->fetch_array($query)) 255 { 256 $information = ''; 257 $logitem['action'] = htmlspecialchars_uni($logitem['action']); 258 $logitem['dateline'] = my_date('relative', $logitem['dateline']); 259 $trow = alt_trow(); 260 if($logitem['username']) 261 { 262 $username = format_name(htmlspecialchars_uni($logitem['username']), $logitem['usergroup'], $logitem['displaygroup']); 263 $logitem['profilelink'] = build_profile_link($username, $logitem['uid'], "_blank"); 264 } 265 else 266 { 267 $username = $logitem['profilelink'] = $logitem['username'] = htmlspecialchars_uni($lang->na_deleted); 268 } 269 if($logitem['tsubject']) 270 { 271 $information = "<strong>{$lang->thread}</strong> <a href=\"../".get_thread_link($logitem['tid'])."\" target=\"_blank\">".htmlspecialchars_uni($logitem['tsubject'])."</a><br />"; 272 } 273 if($logitem['fname']) 274 { 275 $information .= "<strong>{$lang->forum}</strong> <a href=\"../".get_forum_link($logitem['fid'])."\" target=\"_blank\">".htmlspecialchars_uni($logitem['fname'])."</a><br />"; 276 } 277 if($logitem['psubject']) 278 { 279 $information .= "<strong>{$lang->post}</strong> <a href=\"../".get_post_link($logitem['pid'])."#pid{$logitem['pid']}\" target=\"_blank\">".htmlspecialchars_uni($logitem['psubject'])."</a>"; 280 } 281 282 if(!$logitem['tsubject'] || !$logitem['fname'] || !$logitem['psubject']) 283 { 284 $data = my_unserialize($logitem['data']); 285 if(!empty($data['uid'])) 286 { 287 $information = "<strong>{$lang->user_info}</strong> <a href=\"../".get_profile_link($data['uid'])."\" target=\"_blank\">".htmlspecialchars_uni($data['username'])."</a>"; 288 } 289 if(!empty($data['aid'])) 290 { 291 $information = "<strong>{$lang->announcement}</strong> <a href=\"../".get_announcement_link($data['aid'])."\" target=\"_blank\">".htmlspecialchars_uni($data['subject'])."</a>"; 292 } 293 } 294 295 $plugins->run_hooks("admin_tools_modlog_modlogs_result"); 296 297 $table->construct_cell($logitem['profilelink']); 298 $table->construct_cell($logitem['dateline'], array("class" => "align_center")); 299 $table->construct_cell($logitem['action'], array("class" => "align_center")); 300 $table->construct_cell($information); 301 $table->construct_cell(my_inet_ntop($db->unescape_binary($logitem['ipaddress'])), array("class" => "align_center")); 302 $table->construct_row(); 303 } 304 305 if($table->num_rows() == 0) 306 { 307 $table->construct_cell($lang->no_modlogs, array("colspan" => "5")); 308 $table->construct_row(); 309 } 310 311 $table->output($lang->mod_logs); 312 313 // Do we need to construct the pagination? 314 if($rescount > $perpage) 315 { 316 echo draw_admin_pagination($pagecnt, $perpage, $rescount, "index.php?module=tools-modlog&perpage=$perpage&uid={$mybb->input['uid']}&fid={$mybb->input['fid']}&sortby={$mybb->input['sortby']}&order={$order}")."<br />"; 317 } 318 319 // Fetch filter options 320 $sortbysel[$mybb->get_input('sortby')] = "selected=\"selected\""; 321 $ordersel[$mybb->get_input('order')] = "selected=\"selected\""; 322 323 $user_options[''] = $lang->all_moderators; 324 $user_options['0'] = '----------'; 325 326 $query = $db->query(" 327 SELECT DISTINCT l.uid, u.username 328 FROM ".TABLE_PREFIX."moderatorlog l 329 LEFT JOIN ".TABLE_PREFIX."users u ON (l.uid=u.uid) 330 ORDER BY u.username ASC 331 "); 332 while($user = $db->fetch_array($query)) 333 { 334 // Deleted Users 335 if(!$user['username']) 336 { 337 $user['username'] = $lang->na_deleted; 338 } 339 340 $selected = ''; 341 if($mybb->get_input('uid') == $user['uid']) 342 { 343 $selected = "selected=\"selected\""; 344 } 345 $user_options[$user['uid']] = htmlspecialchars_uni($user['username']); 346 } 347 348 $sort_by = array( 349 'dateline' => $lang->date, 350 'username' => $lang->username, 351 'forum' => $lang->forum_name, 352 'thread' => $lang->thread_subject 353 ); 354 355 $order_array = array( 356 'asc' => $lang->asc, 357 'desc' => $lang->desc 358 ); 359 360 $form = new Form("index.php?module=tools-modlog", "post"); 361 $form_container = new FormContainer($lang->filter_moderator_logs); 362 $form_container->output_row($lang->forum, "", $form->generate_forum_select('fid', $mybb->get_input('fid'), array('id' => 'fid', 'main_option' => $lang->all_forums)), 'fid'); 363 $form_container->output_row($lang->forum_moderator, "", $form->generate_select_box('uid', $user_options, $mybb->get_input('uid'), array('id' => 'uid')), 'uid'); 364 $form_container->output_row($lang->sort_by, "", $form->generate_select_box('sortby', $sort_by, $mybb->get_input('sortby'), array('id' => 'sortby'))." {$lang->in} ".$form->generate_select_box('order', $order_array, $order, array('id' => 'order'))." {$lang->order}", 'order'); 365 $form_container->output_row($lang->results_per_page, "", $form->generate_numeric_field('perpage', $perpage, array('id' => 'perpage', 'min' => 1)), 'perpage'); 366 367 $form_container->end(); 368 $buttons[] = $form->generate_submit_button($lang->filter_moderator_logs); 369 $form->output_submit_wrapper($buttons); 370 $form->end(); 371 372 $page->output_footer(); 373 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
2005 - 2021 © MyBB.de | Alle Rechte vorbehalten! | Sponsor: netcup | Cross-referenced by PHPXref |