Advertisement
Guest User

op

a guest
Feb 28th, 2013
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.56 KB | None | 0 0
  1. function useredit($uid = 0) {
  2. global $nav;
  3. $nav[] = url('admin/users',t('Users'));
  4. $res = sql_query("select * from `".tb()."accounts` where id='$uid' ");
  5. $user = sql_fetch_array($res);
  6. $user['roles'] = explode('|',$user['roles']);
  7. if (!$user['id']) {
  8. die('wrong uid');
  9. }
  10. if ($user['featured']) $featured = 'checked';
  11. section_content('
  12. <p>
  13. '.t('Username').':
  14. <strong>'.$user['username'].'</strong>
  15. ('.url('u/'.$user['username'],t('View profile')).')<br />
  16. Email: '.$user['email'].'<br />
  17. Location: '.h($user['location']).'
  18. </p>
  19. <p>
  20. <label>User IP</label>
  21. <strong>'.$user['ipaddress'].'</strong> (<a href="http://www.google.ca/search?q='.$user['ipaddress'].'" target="_blank">Whois</a>)
  22. </p>
  23. <fieldset>
  24. <form action="'.url('admin/usereditpost').'" method="post">
  25. <p>
  26. '.label('User Roles'));
  27. $res = sql_query("select * from ".tb()."roles where (id=3 or id>9) order by id");
  28. while ($role = sql_fetch_array($res)) {
  29. $checked = '';
  30. if (in_array($role['id'],$user['roles'])) $checked = ' checked ';
  31. section_content('<input type="checkbox" name="set_roles[]" value="'.$role['id'].'" '.$checked.' />'.h($role['name']).' ');
  32. }
  33. section_content('
  34. </p>
  35.  
  36. <p>
  37. '.label(t('Status')).'
  38. <input type="radio" name="disabled" value=0 '.admin_check_status($user,0).' /> Verified
  39. <input type="radio" name="disabled" value=1 '.admin_check_status($user,1).' /> Un-verified
  40. <input type="radio" name="disabled" value=2 '.admin_check_status($user,2).' /> Suspended
  41. <input type="radio" name="disabled" value=3 '.admin_check_status($user,3).' /> Spammer<br />
  42. <span>
  43. <strong>Un-verified</strong> - can not post.<br />
  44. <strong>Suspended</strong> - can not login.<br />
  45. <strong>Spammer</strong> - can not post and old posts will be hidden.</span>
  46. </p>
  47. <p>
  48. '.label(t('Featured')).'
  49. <input type="checkbox" name="set_featured" value=1 '.
  50. $featured.' /> Featured<br />
  51. <span class="sub">Featured members have more chance to be displayed.</span>
  52. </p>
  53.  
  54. <p>
  55. <input type="hidden" name="uid" value="'.$user['id'].'" />
  56. <input type="submit" value="'.t('Save changes').'" class="button" />
  57. </p>
  58. </form>
  59. </fieldset>');
  60. if (!in_array(3,$user['roles'])) {
  61. section_content('<fieldset>
  62. <form action="'.url('admin/userdelete').'" method="post">
  63. If you delete this member, <strong>all</strong> his/her posts,comments,and messages will be deleted too.<br />
  64. <input type="submit" value="Delete" onclick="return confirm(\'Are you sure to delete this user?\');" style="background:yellow" />
  65. <input type="hidden" name="uid" value="'.$user['id'].'" />
  66. </form>
  67. </fieldset>
  68. ');
  69. }
  70. }
  71.  
  72. function userdelete() {
  73. $res = sql_query("select * from `".tb()."accounts` where id='{$_POST['uid']}' ");
  74. $user = sql_fetch_array($res);
  75. if (!$user['id']) {
  76. sys_back('wrong uid');
  77. }
  78. $uid = $user['id'];
  79. /*delete forum posts*/
  80. sql_query("delete from ".tb()."accounts where id='$uid'");
  81. sql_query("delete from ".tb()."forum_threads where userid='$uid'");
  82. sql_query("delete from ".tb()."forum_posts where uid='$uid'");
  83. /*delete comments*/
  84. sql_query("delete from ".tb()."comments where uid='$uid'");
  85. /*delete follower*/
  86. sql_query("delete from ".tb()."followers where uid='$uid' or fid='$uid'");
  87. /*others*/
  88. sql_query("delete from ".tb()."friends where uid='$uid' or fid='$uid'");
  89. sql_query("delete from ".tb()."groups where creatorid='$uid'");
  90. sql_query("delete from ".tb()."group_members where uid='$uid'");
  91. sql_query("delete from ".tb()."group_members_pending where uid='$uid'");
  92. sql_query("delete from ".tb()."group_posts where uid='$uid'");
  93. sql_query("delete from ".tb()."group_topics where uid='$uid'");
  94. sql_query("delete from ".tb()."messages where from_id='$uid' or to_id='$uid'");
  95. sql_query("delete from ".tb()."profiles where id='$uid'");
  96. sql_query("delete from ".tb()."profile_comments where uid='$uid'");
  97. $res = sql_query("select id from ".tb()."stories where uid='$uid'");
  98. while ($story = sql_fetch_array($res)) {
  99. $res2 = sql_query("select uri from ".tb()."story_photos where sid='{$story['id']}'");
  100. while($photo = sql_fetch_array($res2)) {
  101. @unlink($photo['uri']);
  102. }
  103. }
  104. sql_query("delete from ".tb()."stories where app='blogs'");
  105. sql_query("delete from ".tb()."stories where uid='$uid'");
  106. sql_query("delete from ".tb()."streams where uid='$uid'");
  107. sql_query("delete from ".tb()."liked where uid='$uid'");
  108. redirect('admin/members_quick',1);
  109.  
  110. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement