Просмотр файла includes/usercp_delete.php

Размер файла: 6.14Kb
  1. <?php
  2. /***************************************************************************
  3. * mides.ru
  4. * -------------------
  5. ***************************************************************************/
  6. if ( !defined('IN_PHPBB') )
  7. {
  8. die("Hacking attempt");
  9. exit;
  10. }
  11. if ( empty($HTTP_GET_VARS[POST_USERS_URL]) || $HTTP_GET_VARS[POST_USERS_URL] == ANONYMOUS )
  12. {
  13. message_die(GENERAL_MESSAGE, $lang['No_user_id_specified']);
  14. }
  15.  
  16. if ( $userdata['user_level'] == ADMIN )
  17. {
  18.  
  19. $confirm = isset($HTTP_POST_VARS['confirm']) ? true : false;
  20. $user_id = intval($HTTP_GET_VARS[POST_USERS_URL]);
  21.  
  22. if (!($this_userdata = get_userdata($user_id)))
  23. {
  24. message_die(GENERAL_MESSAGE, $lang['No_user_id_specified'] );
  25. }
  26. if ( $this_userdata['user_level'] != USER )
  27. {
  28. message_die(GENERAL_MESSAGE, 'Администрацию удалять нельзя');
  29. }
  30. if( $userdata['user_id'] == $user_id )
  31. {
  32. message_die(GENERAL_MESSAGE, 'Ты больной? Зачем тебе удалять самого себя??? о_0');
  33. }
  34.  
  35. if ( $confirm )
  36. {
  37. $sql = "SELECT g.group_id
  38. FROM " . USER_GROUP_TABLE . " ug, " . GROUPS_TABLE . " g
  39. WHERE ug.user_id = $user_id
  40. AND g.group_id = ug.group_id
  41. AND g.group_single_user = 1";
  42. if( !($result = $db->sql_query($sql)) )
  43. {
  44. message_die(GENERAL_ERROR, 'Could not obtain group information for this user', '', __LINE__, __FILE__, $sql);
  45. }
  46.  
  47. $row = $db->sql_fetchrow($result);
  48.  
  49. $sql = "UPDATE " . POSTS_TABLE . "
  50. SET poster_id = " . DELETED . ", post_username = '" . str_replace("\\'", "''", addslashes($this_userdata['username'])) . "'
  51. WHERE poster_id = $user_id";
  52. if( !$db->sql_query($sql) )
  53. {
  54. message_die(GENERAL_ERROR, 'Could not update posts for this user', '', __LINE__, __FILE__, $sql);
  55. }
  56.  
  57. $sql = "UPDATE " . TOPICS_TABLE . "
  58. SET topic_poster = " . DELETED . "
  59. WHERE topic_poster = $user_id";
  60. if( !$db->sql_query($sql) )
  61. {
  62. message_die(GENERAL_ERROR, 'Could not update topics for this user', '', __LINE__, __FILE__, $sql);
  63. }
  64.  
  65. $sql = "UPDATE " . VOTE_USERS_TABLE . "
  66. SET vote_user_id = " . DELETED . "
  67. WHERE vote_user_id = $user_id";
  68. if( !$db->sql_query($sql) )
  69. {
  70. message_die(GENERAL_ERROR, 'Could not update votes for this user', '', __LINE__, __FILE__, $sql);
  71. }
  72.  
  73. $sql = "UPDATE " . GROUPS_TABLE . "
  74. SET group_moderator = " . $userdata['user_id'] . "
  75. WHERE group_moderator = $user_id";
  76. if( !$db->sql_query($sql) )
  77. {
  78. message_die(GENERAL_ERROR, 'Could not update group moderators', '', __LINE__, __FILE__, $sql);
  79. }
  80.  
  81. $sql = "DELETE FROM " . USERS_TABLE . "
  82. WHERE user_id = $user_id";
  83. if( !$db->sql_query($sql) )
  84. {
  85. message_die(GENERAL_ERROR, 'Could not delete user', '', __LINE__, __FILE__, $sql);
  86. }
  87.  
  88. $sql = "DELETE FROM " . USER_GROUP_TABLE . "
  89. WHERE user_id = $user_id";
  90. if( !$db->sql_query($sql) )
  91. {
  92. message_die(GENERAL_ERROR, 'Could not delete user from user_group table', '', __LINE__, __FILE__, $sql);
  93. }
  94.  
  95. $sql = "DELETE FROM " . GROUPS_TABLE . "
  96. WHERE group_id = " . $row['group_id'];
  97. if( !$db->sql_query($sql) )
  98. {
  99. message_die(GENERAL_ERROR, 'Could not delete group for this user', '', __LINE__, __FILE__, $sql);
  100. }
  101.  
  102. $sql = "DELETE FROM " . AUTH_ACCESS_TABLE . "
  103. WHERE group_id = " . $row['group_id'];
  104. if( !$db->sql_query($sql) )
  105. {
  106. message_die(GENERAL_ERROR, 'Could not delete group for this user', '', __LINE__, __FILE__, $sql);
  107. }
  108.  
  109. $sql = "DELETE FROM " . TOPICS_WATCH_TABLE . "
  110. WHERE user_id = $user_id";
  111. if ( !$db->sql_query($sql) )
  112. {
  113. message_die(GENERAL_ERROR, 'Could not delete user from topic watch table', '', __LINE__, __FILE__, $sql);
  114. }
  115. $sql = "DELETE FROM " . BANLIST_TABLE . "
  116. WHERE ban_userid = $user_id";
  117. if ( !$db->sql_query($sql) )
  118. {
  119. message_die(GENERAL_ERROR, 'Could not delete user from banlist table', '', __LINE__, __FILE__, $sql);
  120. }
  121.  
  122. $sql = "DELETE FROM " . SESSIONS_TABLE . "
  123. WHERE session_user_id = $user_id";
  124. if ( !$db->sql_query($sql) )
  125. {
  126. message_die(GENERAL_ERROR, 'Could not delete sessions for this user', '', __LINE__, __FILE__, $sql);
  127. }
  128.  
  129. $sql = "DELETE FROM " . SESSIONS_KEYS_TABLE . "
  130. WHERE user_id = $user_id";
  131. if ( !$db->sql_query($sql) )
  132. {
  133. message_die(GENERAL_ERROR, 'Could not delete auto-login keys for this user', '', __LINE__, __FILE__, $sql);
  134. }
  135.  
  136. $sql = "SELECT privmsgs_id
  137. FROM " . PRIVMSGS_TABLE . "
  138. WHERE privmsgs_from_userid = $user_id
  139. OR privmsgs_to_userid = $user_id";
  140. if ( !($result = $db->sql_query($sql)) )
  141. {
  142. message_die(GENERAL_ERROR, 'Could not select all users private messages', '', __LINE__, __FILE__, $sql);
  143. }
  144.  
  145. while ( $row_privmsgs = $db->sql_fetchrow($result) )
  146. {
  147. $mark_list[] = $row_privmsgs['privmsgs_id'];
  148. }
  149. if ( count($mark_list) )
  150. {
  151. $delete_sql_id = implode(', ', $mark_list);
  152.  
  153. $delete_text_sql = "DELETE FROM " . PRIVMSGS_TEXT_TABLE . "
  154. WHERE privmsgs_text_id IN ($delete_sql_id)";
  155. $delete_sql = "DELETE FROM " . PRIVMSGS_TABLE . "
  156. WHERE privmsgs_id IN ($delete_sql_id)";
  157. if ( !$db->sql_query($delete_sql) )
  158. {
  159. message_die(GENERAL_ERROR, 'Could not delete private message info', '', __LINE__, __FILE__, $delete_sql);
  160. }
  161. if ( !$db->sql_query($delete_text_sql) )
  162. {
  163. message_die(GENERAL_ERROR, 'Could not delete private message text', '', __LINE__, __FILE__, $delete_text_sql);
  164. }
  165. }
  166.  
  167. message_die(GENERAL_MESSAGE, 'Юзер отправился фтопку');
  168.  
  169. } else {
  170.  
  171. include($phpbb_root_path . 'includes/page_header.'.$phpEx);
  172.  
  173. $template->set_filenames(array(
  174. 'confirm_body' => 'confirm_body.tpl')
  175. );
  176.  
  177. $template->assign_vars(array(
  178. 'MESSAGE_TITLE' => 'Эээ...',
  179. 'MESSAGE_TEXT' => 'Ты действительно считаешь что юзер достоен удаления твоей рукой?',
  180.  
  181. 'L_YES' => $lang['Yes'],
  182. 'L_NO' => $lang['No'],
  183.  
  184. 'S_CONFIRM_ACTION' => append_sid("profile.$phpEx?mode=delete&amp;u=$user_id"))
  185. );
  186.  
  187. $template->pparse('confirm_body');
  188.  
  189. include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
  190.  
  191. }
  192.  
  193. } else {
  194. message_die(GENERAL_MESSAGE, 'Ты кто такой? Топай отсюда по-хорошему...');
  195. }
  196.  
  197. ?>