Skip to content

Instantly share code, notes, and snippets.

@evandhoffman
Created April 12, 2012 03:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save evandhoffman/2364455 to your computer and use it in GitHub Desktop.
Save evandhoffman/2364455 to your computer and use it in GitHub Desktop.
phpbb_postcount_editor.php
<?php
define('IN_PHPBB', true);
define('ADMIN_START', true);
define('NEED_SID', true);
// Include files
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './../';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
require($phpbb_root_path . 'common.' . $phpEx);
require($phpbb_root_path . 'includes/functions_admin.' . $phpEx);
require($phpbb_root_path . 'includes/functions_module.' . $phpEx);
// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup('acp/common');
// End session management
// Have they authenticated (again) as an admin for this session?
if (!isset($user->data['session_admin']) || !$user->data['session_admin'])
{
login_box('', $user->lang['LOGIN_ADMIN_CONFIRM'], $user->lang['LOGIN_ADMIN_SUCCESS'], true, false);
}
// Is user any type of admin? No, then stop here, each script needs to
// check specific permissions but this is a catchall
if (!$auth->acl_get('a_'))
{
trigger_error('NO_ADMIN');
}
// We define the admin variables now, because the user is now able to use the admin related features...
define('IN_ADMIN', true);
$phpbb_admin_path = (defined('PHPBB_ADMIN_PATH')) ? PHPBB_ADMIN_PATH : './';
$dbname = 'xxx';
$dbuser = 'yyyy';
$dbpasswd = 'zzz';
$conn_string = "host=localhost dbname=$dbname user=$dbuser password=$dbpasswd";
$db = pg_connect($conn_string);
if (empty($_GET['op'])) {
$res = pg_query($db, "select user_id, username, user_regdate, user_posts from phpbb_users where user_type = 0 order by user_id");
print "<table border='1'>\n";
while ($row = pg_fetch_assoc($res)) {
print "<tr>
<td>$row[user_id]</td>
<td><a href='$_SERVER[PHP_SELF]?op=edit&user_id=$row[user_id]&sid=$_GET[sid]'>$row[username]</a></td>
<td>".date('r',$row['user_regdate'])."</td>
<td>$row[user_posts]</td>
</tr>\n";
}
print "</table>";
} else if ($_GET['op'] == 'edit') {
$res = pg_query($db, "select user_id, username, user_regdate, user_posts from phpbb_users where user_id = $_GET[user_id]");
print "
<form action='$_SERVER[PHP_SELF]'>
<table border='1'>\n";
while ($row = pg_fetch_assoc($res)) {
print "<tr>
<td>$row[user_id]</td>
<input type='hidden' name='edit_id' value='$row[user_id]'>
<input type='hidden' name='sid' value='$_GET[sid]'>
<td>$row[username]</td>
<td>Date: ".date('r',$row['user_regdate'])." <input type='text' name='edit_date' value='$row[user_regdate]' size='10'></td>
<td>Posts: <input type='text' name='edit_posts' value='$row[user_posts]' size='10'></td>
<input type='hidden' name='op' value='do_edit'>
<td><input type='submit' value='Submit'></td>
</tr>\n</table>\n</form>";
}
} else if ($_GET['op'] == 'do_edit') {
$sql = "update phpbb_users set user_regdate = $_GET[edit_date], user_posts = $_GET[edit_posts] where user_id=$_GET[edit_id]";
print "$sql\n";
$res = pg_query($db, $sql);
print "<p>User edited.\n";
} else {
print "WHOOPSIE\n";
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment