Guest User

Untitled

a guest
Sep 26th, 2018
415
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.30 KB | None | 0 0
  1. <?php
  2.  
  3. define('IN_PHPBB', true);
  4. define('ADMIN_START', true);
  5. define('NEED_SID', true);
  6.  
  7. // Include files
  8. $phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './../';
  9. $phpEx = substr(strrchr(__FILE__, '.'), 1);
  10. require($phpbb_root_path . 'common.' . $phpEx);
  11. require($phpbb_root_path . 'includes/functions_admin.' . $phpEx);
  12. require($phpbb_root_path . 'includes/functions_module.' . $phpEx);
  13.  
  14. // Start session management
  15. $user->session_begin();
  16. $auth->acl($user->data);
  17. $user->setup('acp/common');
  18. // End session management
  19.  
  20. // Have they authenticated (again) as an admin for this session?
  21. if (!isset($user->data['session_admin']) || !$user->data['session_admin'])
  22. {
  23. login_box('', $user->lang['LOGIN_ADMIN_CONFIRM'], $user->lang['LOGIN_ADMIN_SUCCESS'], true, false);
  24. }
  25.  
  26. // Is user any type of admin? No, then stop here, each script needs to
  27. // check specific permissions but this is a catchall
  28. if (!$auth->acl_get('a_'))
  29. {
  30. trigger_error('NO_ADMIN');
  31. }
  32.  
  33. // We define the admin variables now, because the user is now able to use the admin related features...
  34. define('IN_ADMIN', true);
  35. $phpbb_admin_path = (defined('PHPBB_ADMIN_PATH')) ? PHPBB_ADMIN_PATH : './';
  36.  
  37.  
  38. $dbname = 'xxx';
  39. $dbuser = 'yyyy';
  40. $dbpasswd = 'zzz';
  41.  
  42.  
  43. $conn_string = "host=localhost dbname=$dbname user=$dbuser password=$dbpasswd";
  44.  
  45. $db = pg_connect($conn_string);
  46.  
  47. if (empty($_GET['op'])) {
  48.  
  49. $res = pg_query($db, "select user_id, username, user_regdate, user_posts from phpbb_users where user_type = 0 order by user_id");
  50.  
  51. print "<table border='1'>\n";
  52. while ($row = pg_fetch_assoc($res)) {
  53. print "<tr>
  54. <td>$row[user_id]</td>
  55. <td><a href='$_SERVER[PHP_SELF]?op=edit&user_id=$row[user_id]&sid=$_GET[sid]'>$row[username]</a></td>
  56. <td>".date('r',$row['user_regdate'])."</td>
  57. <td>$row[user_posts]</td>
  58. </tr>\n";
  59. }
  60. print "</table>";
  61. } else if ($_GET['op'] == 'edit') {
  62.  
  63. $res = pg_query($db, "select user_id, username, user_regdate, user_posts from phpbb_users where user_id = $_GET[user_id]");
  64.  
  65. print "
  66. <form action='$_SERVER[PHP_SELF]'>
  67. <table border='1'>\n";
  68. while ($row = pg_fetch_assoc($res)) {
  69. print "<tr>
  70. <td>$row[user_id]</td>
  71. <input type='hidden' name='edit_id' value='$row[user_id]'>
  72. <input type='hidden' name='sid' value='$_GET[sid]'>
  73. <td>$row[username]</td>
  74. <td>Date: ".date('r',$row['user_regdate'])." <input type='text' name='edit_date' value='$row[user_regdate]' size='10'></td>
  75. <td>Posts: <input type='text' name='edit_posts' value='$row[user_posts]' size='10'></td>
  76. <input type='hidden' name='op' value='do_edit'>
  77. <td><input type='submit' value='Submit'></td>
  78. </tr>\n</table>\n</form>";
  79. }
  80.  
  81.  
  82. } else if ($_GET['op'] == 'do_edit') {
  83. $sql = "update phpbb_users set user_regdate = $_GET[edit_date], user_posts = $_GET[edit_posts] where user_id=$_GET[edit_id]";
  84. print "$sql\n";
  85. $res = pg_query($db, $sql);
  86. print "<p>User edited.\n";
  87.  
  88. } else {
  89. print "WHOOPSIE\n";
  90. }
  91.  
  92. ?>
Add Comment
Please, Sign In to add comment