PageRenderTime 35ms CodeModel.GetById 9ms RepoModel.GetById 0ms app.codeStats 0ms

/core/admincp/modlog.php

https://gitlab.com/hub/vbulletin
PHP | 330 lines | 251 code | 50 blank | 29 comment | 38 complexity | 6749f78f056aed21a966b759b2b44ccb MD5 | raw file
Possible License(s): Apache-2.0, Unlicense
  1. <?php
  2. /*======================================================================*\
  3. || #################################################################### ||
  4. || # vBulletin 5.0.0
  5. || # ---------------------------------------------------------------- # ||
  6. || # Copyright ©2000-2013 vBulletin Solutions Inc. All Rights Reserved. ||
  7. || # This file may not be redistributed in whole or significant part. # ||
  8. || # ---------------- VBULLETIN IS NOT FREE SOFTWARE ---------------- # ||
  9. || # http://www.vbulletin.com | http://www.vbulletin.com/license.html # ||
  10. || #################################################################### ||
  11. \*======================================================================*/
  12. // ######################## SET PHP ENVIRONMENT ###########################
  13. error_reporting(E_ALL & ~E_NOTICE);
  14. // ##################### DEFINE IMPORTANT CONSTANTS #######################
  15. define('CVS_REVISION', '$RCSfile$ - $Revision: 69205 $');
  16. // #################### PRE-CACHE TEMPLATES AND DATA ######################
  17. global $phrasegroups, $specialtemplates, $vbphrase, $vbulletin;
  18. $phrasegroups = array('logging', 'threadmanage');
  19. $specialtemplates = array();
  20. // ########################## REQUIRE BACK-END ############################
  21. require_once(dirname(__FILE__) . '/global.php');
  22. require_once(DIR . '/includes/functions_log_error.php');
  23. // ############################# LOG ACTION ###############################
  24. if (!can_administer('canadminmodlog'))
  25. {
  26. print_cp_no_permission();
  27. }
  28. log_admin_action();
  29. // ########################################################################
  30. // ######################### START MAIN SCRIPT ############################
  31. // ########################################################################
  32. $vb5_config =& vB::getConfig();
  33. print_cp_header($vbphrase['moderator_log_gthreadmanage']);
  34. if (empty($_REQUEST['do']))
  35. {
  36. $_REQUEST['do'] = 'choose';
  37. }
  38. // ###################### Start view #######################
  39. if ($_REQUEST['do'] == 'view')
  40. {
  41. $vbulletin->input->clean_array_gpc('r', array(
  42. 'perpage' => vB_Cleaner::TYPE_UINT,
  43. 'pagenumber' => vB_Cleaner::TYPE_UINT,
  44. 'userid' => vB_Cleaner::TYPE_UINT,
  45. 'modaction' => vB_Cleaner::TYPE_STR,
  46. 'orderby' => vB_Cleaner::TYPE_NOHTML,
  47. 'product' => vB_Cleaner::TYPE_STR,
  48. 'startdate' => vB_Cleaner::TYPE_UNIXTIME,
  49. 'enddate' => vB_Cleaner::TYPE_UNIXTIME,
  50. ));
  51. if ($vbulletin->GPC['perpage'] < 1)
  52. {
  53. $vbulletin->GPC['perpage'] = 15;
  54. }
  55. $counterres = vB::getDbAssertor()->assertQuery('fetchModlogCount',$vbulletin->GPC);
  56. $counter = $counterres->current();
  57. $totalpages = ceil($counter['total'] / $vbulletin->GPC['perpage']);
  58. if ($vbulletin->GPC['pagenumber'] < 1)
  59. {
  60. $vbulletin->GPC['pagenumber'] = 1;
  61. }
  62. $logs = vB::getDbAssertor()->assertQuery('fetchModlogs',$vbulletin->GPC);
  63. if ($logs AND $logs->valid())
  64. {
  65. $vbulletin->GPC['modaction'] = htmlspecialchars_uni($vbulletin->GPC['modaction']);
  66. if ($vbulletin->GPC['pagenumber'] != 1)
  67. {
  68. $prv = $vbulletin->GPC['pagenumber'] - 1;
  69. $firstpage = "<input type=\"button\" class=\"button\" value=\"&laquo; " . $vbphrase['first_page'] . "\" tabindex=\"1\" onclick=\"window.location='modlog.php?" . vB::getCurrentSession()->get('sessionurl') . "do=view&modaction=" . $vbulletin->GPC['modaction'] . "&u=" . $vbulletin->GPC['userid'] . "&pp=" . $vbulletin->GPC['perpage'] . "&orderby=" . $vbulletin->GPC['orderby'] . "&page=1'\">";
  70. $prevpage = "<input type=\"button\" class=\"button\" value=\"&lt; " . $vbphrase['prev_page'] . "\" tabindex=\"1\" onclick=\"window.location='modlog.php?" . vB::getCurrentSession()->get('sessionurl') . "do=view&modaction=" . $vbulletin->GPC['modaction'] . "&u=" . $vbulletin->GPC['userid'] . "&pp=" . $vbulletin->GPC['perpage'] . "&orderby=" . $vbulletin->GPC['orderby'] . "&page=$prv'\">";
  71. }
  72. if ($vbulletin->GPC['pagenumber'] != $totalpages)
  73. {
  74. $nxt = $vbulletin->GPC['pagenumber'] + 1;
  75. $nextpage = "<input type=\"button\" class=\"button\" value=\"" . $vbphrase['next_page'] . " &gt;\" tabindex=\"1\" onclick=\"window.location='modlog.php?" . vB::getCurrentSession()->get('sessionurl') . "do=view&modaction=" . $vbulletin->GPC['modaction'] . "&u=" . $vbulletin->GPC['userid'] . "&pp=" . $vbulletin->GPC['perpage'] . "&orderby=" . $vbulletin->GPC['orderby'] . "&page=$nxt'\">";
  76. $lastpage = "<input type=\"button\" class=\"button\" value=\"" . $vbphrase['last_page'] . " &raquo;\" tabindex=\"1\" onclick=\"window.location='modlog.php?" . vB::getCurrentSession()->get('sessionurl') . "do=view&modaction=" . $vbulletin->GPC['modaction'] . "&u=" . $vbulletin->GPC['userid'] . "&pp=" . $vbulletin->GPC['perpage'] . "&orderby=" . $vbulletin->GPC['orderby'] . "&page=$totalpages'\">";
  77. }
  78. print_form_header('modlog', 'remove');
  79. print_description_row(construct_link_code($vbphrase['restart'], "modlog.php?" . vB::getCurrentSession()->get('sessionurl') . ""), 0, 5, 'thead', vB_Template_Runtime::fetchStyleVar('right'));
  80. print_table_header(construct_phrase($vbphrase['moderator_log_viewer_page_x_y_there_are_z_total_log_entries'], vb_number_format($vbulletin->GPC['pagenumber']), vb_number_format($totalpages), vb_number_format($counter['total'])), 6);
  81. $headings = array();
  82. $headings[] = $vbphrase['id'];
  83. $headings[] = "<a href=\"modlog.php?" . vB::getCurrentSession()->get('sessionurl') . "do=view&modaction=" . $vbulletin->GPC['modaction'] . "&u=" . $vbulletin->GPC['userid'] . "&pp=" . $vbulletin->GPC['perpage'] . "&orderby=user&page=" . $vbulletin->GPC['pagenumber'] . "\">" . str_replace(' ', '&nbsp;', $vbphrase['username']) . "</a>";
  84. $headings[] = "<a href=\"modlog.php?" . vB::getCurrentSession()->get('sessionurl') . "do=view&modaction=" . $vbulletin->GPC['modaction'] . "&u=" . $vbulletin->GPC['userid'] . "&pp=" . $vbulletin->GPC['perpage'] . "&orderby=date&page=" . $vbulletin->GPC['pagenumber'] . "\">" . $vbphrase['date'] . "</a>";
  85. $headings[] = "<a href=\"modlog.php?" . vB::getCurrentSession()->get('sessionurl') . "do=view&modaction=" . $vbulletin->GPC['modaction'] . "&u=" . $vbulletin->GPC['userid'] . "&pp=" . $vbulletin->GPC['perpage'] . "&orderby=modaction&page=" . $vbulletin->GPC['pagenumber'] . "\">" . $vbphrase['action'] . "</a>";
  86. $headings[] = str_replace(' ', '&nbsp;', $vbphrase['ip_address']);
  87. print_cells_row($headings, 1, 0, -3);
  88. foreach ($logs as $log)
  89. {
  90. $cell = array();
  91. $cell[] = $log['moderatorlogid'];
  92. $cell[] = "<a href=\"user.php?" . vB::getCurrentSession()->get('sessionurl') . "do=edit&u=$log[userid]\"><b>$log[username]</b></a>";
  93. $cell[] = '<span class="smallfont">' . vbdate($vbulletin->options['logdateformat'], $log['dateline']) . '</span>';
  94. if ($log['type'])
  95. {
  96. $phrase = vB_Library_Admin::GetModlogAction($log['type']);
  97. if (!$log['nodeid'])
  98. {
  99. // Pre vB5 logs
  100. if ($unserialized = @unserialize($log['action']))
  101. {
  102. array_unshift($unserialized, $vbphrase[$phrase]);
  103. $action = call_user_func_array('construct_phrase', $unserialized);
  104. }
  105. else
  106. {
  107. $action = construct_phrase($vbphrase[$phrase], $log['action']);
  108. }
  109. if ($log['threadtitle'])
  110. {
  111. $action .= ', \'' . $log['threadtitle'] . '\'';
  112. }
  113. }
  114. else
  115. {
  116. // vB5 logs
  117. $temp = array();
  118. $logdata = @unserialize($log['action']);
  119. $action = construct_phrase($vbphrase[$phrase], $log['username']);
  120. if ($logdata['userid'] AND $logdata['username'])
  121. {
  122. $name = '<a href="user.php?' . vB::getCurrentSession()->get('sessionurl') . 'do=edit&u=' . $logdata['userid'] . '">' . $logdata['username'] . '</a>';
  123. $temp[] = $vbphrase['author'] . ' = ' . $name;
  124. unset($logdata['userid'], $logdata['username']);
  125. }
  126. $logdata['nodeid'] = $log['nodeid'];
  127. if ($log['nodetitle'])
  128. {
  129. $logdata['title'] = $log['nodetitle'];
  130. }
  131. else
  132. {
  133. $logdata['title'] = $vbphrase['untitled'];
  134. }
  135. if (!empty($logdata))
  136. {
  137. foreach ($logdata AS $key => $data)
  138. {
  139. $temp[] = "$key = $data";
  140. }
  141. $action .= '<br />' . implode('; ', $temp);
  142. }
  143. }
  144. }
  145. else
  146. {
  147. $action = '-';
  148. }
  149. $cell[] = $action;
  150. $cell[] = '<span class="smallfont">' . iif($log['ipaddress'], "<a href=\"usertools.php?" . vB::getCurrentSession()->get('sessionurl') . "do=gethost&ip=$log[ipaddress]\">$log[ipaddress]</a>", '&nbsp;') . '</span>';
  151. print_cells_row($cell, 0, 0, -3);
  152. }
  153. print_table_footer(5, "$firstpage $prevpage &nbsp; $nextpage $lastpage");
  154. }
  155. else
  156. {
  157. print_stop_message2('no_results_matched_your_query');
  158. }
  159. }
  160. // ###################### Start prune log #######################
  161. if ($_REQUEST['do'] == 'prunelog' AND can_access_logs($vb5_config['SpecialUsers']['canpruneadminlog'], 0, '<p>' . $vbphrase['control_panel_log_pruning_permission_restricted'] . '</p>'))
  162. {
  163. $vbulletin->input->clean_array_gpc('r', array(
  164. 'daysprune' => vB_Cleaner::TYPE_UINT,
  165. 'userid' => vB_Cleaner::TYPE_UINT,
  166. 'modaction' => vB_Cleaner::TYPE_STR,
  167. 'product' => vB_Cleaner::TYPE_STR,
  168. ));
  169. $datecut = TIMENOW - (86400 * $vbulletin->GPC['daysprune']);
  170. $conditions[] = array('field' => 'dateline', 'value' => $vbulletin->GPC['datecut'], 'operator' => vB_dB_Query::OPERATOR_LT);
  171. if ($vbulletin->GPC['userid'])
  172. {
  173. $conditions[] = array('field' => 'userid', 'value' => $vbulletin->GPC['userid'], 'operator' => vB_dB_Query::OPERATOR_EQ);
  174. }
  175. if ($vbulletin->GPC['modaction'])
  176. {
  177. $conditions[] = array('field' => 'action', 'value' => $vbulletin->GPC['modaction'], 'operator' => vB_dB_Query::OPERATOR_INCLUDES);
  178. }
  179. if ($vbulletin->GPC['product'])
  180. {
  181. if ($vbulletin->GPC['product'] == 'vbulletin')
  182. {
  183. $conditions[] = array('field' => 'product', 'value' => array('', 'vbulletin'), 'operator' => vB_dB_Query::OPERATOR_EQ);
  184. }
  185. else
  186. {
  187. $conditions[] = array('field' => 'product', 'value' => $vbulletin->GPC['product'], 'operator' => vB_dB_Query::OPERATOR_EQ);
  188. }
  189. }
  190. $logsres = vB::getDbAssertor()->assertQuery('getModLogsByConds', array('conds' => $conditions));
  191. $logs = $logsres->current();
  192. if ($logs['total'])
  193. {
  194. print_form_header('modlog', 'doprunelog');
  195. construct_hidden_code('datecut', $datecut);
  196. construct_hidden_code('modaction', $vbulletin->GPC['modaction']);
  197. construct_hidden_code('userid', $vbulletin->GPC['userid']);
  198. construct_hidden_code('product', $vbulletin->GPC['product']);
  199. print_table_header($vbphrase['prune_moderator_log']);
  200. print_description_row(construct_phrase($vbphrase['are_you_sure_you_want_to_prune_x_log_entries_from_moderator_log'], vb_number_format($logs['total'])));
  201. print_submit_row($vbphrase['yes'], 0, 0, $vbphrase['no']);
  202. }
  203. else
  204. {
  205. print_stop_message2('no_logs_matched_your_query');
  206. }
  207. }
  208. // ###################### Start do prune log #######################
  209. if ($_POST['do'] == 'doprunelog' AND can_access_logs($vb5_config['SpecialUsers']['canpruneadminlog'], 0, '<p>' . $vbphrase['control_panel_log_pruning_permission_restricted'] . '</p>'))
  210. {
  211. $vbulletin->input->clean_array_gpc('p', array(
  212. 'datecut' => vB_Cleaner::TYPE_UINT,
  213. 'modaction' => vB_Cleaner::TYPE_STR,
  214. 'userid' => vB_Cleaner::TYPE_UINT,
  215. 'product' => vB_Cleaner::TYPE_STR,
  216. ));
  217. $conditions[] = array('field' => 'dateline', 'value' => $vbulletin->GPC['datecut'], 'operator' => vB_dB_Query::OPERATOR_LT);
  218. if (!empty($vbulletin->GPC['modaction']))
  219. {
  220. $conditions[] = array('field' => 'action', 'value' => $vbulletin->GPC['modaction'], 'operator' => vB_dB_Query::OPERATOR_INCLUDES);
  221. }
  222. if (!empty($vbulletin->GPC['userid']))
  223. {
  224. $conditions[] = array('field' => 'userid', 'value' => $vbulletin->GPC['userid'], 'operator' => vB_dB_Query::OPERATOR_EQ);
  225. }
  226. if ($vbulletin->GPC['product'])
  227. {
  228. if ($vbulletin->GPC['product'] == 'vbulletin')
  229. {
  230. $conditions[] = array('field' => 'product', 'value' => array('', 'vbulletin'), 'operator' => vB_dB_Query::OPERATOR_EQ);
  231. }
  232. else
  233. {
  234. $conditions[] = array('field' => 'product', 'value' => $vbulletin->GPC['product'], 'operator' => vB_dB_Query::OPERATOR_EQ);
  235. }
  236. }
  237. vB::getDbAssertor()->delete('moderatorlog', $conditions);
  238. print_stop_message2('pruned_moderator_log_successfully', 'modlog', array('do'=>'choose'));
  239. }
  240. // ###################### Start modify #######################
  241. if ($_REQUEST['do'] == 'choose')
  242. {
  243. $users = vB::getDbAssertor()->assertQuery('chooseModLog');
  244. $userlist = array('no_value' => $vbphrase['all_log_entries']);
  245. foreach ($users as $user)
  246. {
  247. $userlist["$user[userid]"] = $user['username'];
  248. }
  249. print_form_header('modlog', 'view');
  250. print_table_header($vbphrase['moderator_log_viewer']);
  251. print_input_row($vbphrase['log_entries_to_show_per_page'], 'perpage', 15);
  252. print_select_row($vbphrase['show_only_entries_generated_by'], 'userid', $userlist);
  253. print_time_row($vbphrase['start_date'], 'startdate', 0, 0);
  254. print_time_row($vbphrase['end_date'], 'enddate', 0, 0);
  255. if (count($products = fetch_product_list()) > 1)
  256. {
  257. print_select_row($vbphrase['product'], 'product', array('' => $vbphrase['all_products']) + $products);
  258. }
  259. print_select_row($vbphrase['order_by_gcpglobal'], 'orderby', array('date' => $vbphrase['date'], 'user' => $vbphrase['username']), 'date');
  260. print_submit_row($vbphrase['view'], 0);
  261. if (can_access_logs($vb5_config['SpecialUsers']['canpruneadminlog'], 0, ''))
  262. {
  263. print_form_header('modlog', 'prunelog');
  264. print_table_header($vbphrase['prune_moderator_log']);
  265. print_select_row($vbphrase['remove_entries_logged_by_user'], 'userid', $userlist);
  266. if (count($products) > 1)
  267. {
  268. print_select_row($vbphrase['product'], 'product', array('' => $vbphrase['all_products']) + $products);
  269. }
  270. print_input_row($vbphrase['remove_entries_older_than_days'], 'daysprune', 30);
  271. print_submit_row($vbphrase['prune_log_entries'], 0);
  272. }
  273. }
  274. print_cp_footer();
  275. /*======================================================================*\
  276. || ####################################################################
  277. || # CVS: $RCSfile$ - $Revision: 69205 $
  278. || ####################################################################
  279. \*======================================================================*/
  280. ?>