* A class that implements the DB interface for Postgres
* Note: This class uses ADODB and returns RecordSets.
*
- * $Id: Postgres.php,v 1.97 2003/05/08 14:15:57 chriskl Exp $
+ * $Id: Postgres.php,v 1.98 2003/05/08 15:14:14 chriskl Exp $
*/
// @@@ THOUGHT: What about inherits? ie. use of ONLY???
// User functions
+ /**
+ * Changes a user's password
+ * @param $username The username
+ * @param $password The new password
+ * @return 0 success
+ */
+ function changePassword($username, $password) {
+ $this->fieldClean($username);
+ $this->clean($password);
+
+ $sql = "ALTER USER \"{$username}\" WITH PASSWORD '{$password}'";
+
+ return $this->execute($sql);
+ }
+
/**
* Returns all users in the database cluster
* @return All users
$sql = "SELECT grolist FROM pg_group WHERE groname = '{$groname}'";
$grodata = $this->selectSet($sql);
- $members = $grodata->f['grolist'];
- $members = ereg_replace("\{|\}","",$members);
- $this->clean($members);
+ if ($grodata->f['grolist'] !== null && $grodata->f['grolist'] != '{}') {
+ $members = $grodata->f['grolist'];
+ $members = ereg_replace("\{|\}","",$members);
+ $this->clean($members);
- $sql = "SELECT usename FROM pg_user WHERE usesysid IN ({$members}) ORDER BY usename";
+ $sql = "SELECT usename FROM pg_user WHERE usesysid IN ({$members}) ORDER BY usename";
+ }
+ else $sql = "SELECT usename FROM pg_user WHERE false";
return $this->selectSet($sql);
}
* Central phpPgAdmin configuration. As a user you may modify the
* settings here for your particular configuration.
*
- * $Id: config.inc.php-dist,v 1.19 2003/05/08 14:15:58 chriskl Exp $
+ * $Id: config.inc.php-dist,v 1.20 2003/05/08 15:14:15 chriskl Exp $
*/
// An example server. Create as many of these as you wish,
// means.
$conf['owned_reports_only'] = false;
+ // Minimum length users can set their password to.
+ $conf['min_password_length'] = 1;
+
// Width of the left frame in pixels (object browser)
$conf['left_width'] = 200;
* Don't modify anything below this line *
*****************************************/
- $conf['version'] = 6;
+ $conf['version'] = 7;
?>
/**
* Manage groups in a database cluster
*
- * $Id: groups.php,v 1.7 2003/04/18 11:08:26 chriskl Exp $
+ * $Id: groups.php,v 1.8 2003/05/08 15:14:14 chriskl Exp $
*/
// Include application functions
echo "</table>\n";
}
- else echo "<p>{$lang['strinvalidparam']}</p>\n";
+ else echo "<p>{$lang['strnousers']}</p>\n";
echo "<p><a class=\"navlink\" href=\"$PHP_SELF\">{$lang['strshowallgroups']}</a></p>\n";
}
* English language file for phpPgAdmin. Use this as a basis
* for new translations.
*
- * $Id: english.php,v 1.75 2003/05/08 14:15:58 chriskl Exp $
+ * $Id: english.php,v 1.76 2003/05/08 15:14:15 chriskl Exp $
*/
// Language and character set
$lang['strunique'] = 'Unique';
$lang['strprimary'] = 'Primary';
$lang['strexport'] = 'Export';
+ $lang['strimport'] = 'Import';
$lang['strsql'] = 'SQL';
$lang['strgo'] = 'Go';
$lang['stradmin'] = 'Admin';
$lang['strinstead'] = 'Do Instead';
$lang['strwhen'] = 'When';
$lang['strformat'] = 'Format';
+ $lang['strdata'] = 'Data';
+ $lang['strconfirm'] = 'Confirm';
// Error handling
$lang['strnoframes'] = 'You need a frames-enabled browser to use this application.';
$lang['strcreatedb'] = 'Create DB?';
$lang['strexpires'] = 'Expires';
$lang['strnousers'] = 'No users found.';
- $lang['struserupdated'] = 'User updated.';
+ $lang['struserupdated'] = 'User updated.';
$lang['struserupdatedbad'] = 'User update failed.';
$lang['strshowallusers'] = 'Show All Users';
$lang['strcreateuser'] = 'Create User';
$lang['struserdroppedbad'] = 'Failed to drop user.';
$lang['straccount'] = 'Account';
$lang['strchangepassword'] = 'Change Password';
-
+ $lang['strpasswordchanged'] = 'Password changed.';
+ $lang['strpasswordchangedbad'] = 'Failed to change password.';
+ $lang['strpasswordshort'] = 'Password is too short.';
+ $lang['strpasswordconfirm'] = 'Password does not match confirmation.';
+
// Groups
$lang['strgroupadmin'] = 'Group Admin';
$lang['strgroup'] = 'Group';
* English language file for phpPgAdmin. Use this as a basis
* for new translations.
*
- * $Id: english.php,v 1.27 2003/05/08 14:15:59 chriskl Exp $
+ * $Id: english.php,v 1.28 2003/05/08 15:14:15 chriskl Exp $
*/
// Language and character set
$lang['strunique'] = 'Unique';
$lang['strprimary'] = 'Primary';
$lang['strexport'] = 'Export';
+ $lang['strimport'] = 'Import';
$lang['strsql'] = 'SQL';
$lang['strgo'] = 'Go';
$lang['stradmin'] = 'Admin';
$lang['strinstead'] = 'Do Instead';
$lang['strwhen'] = 'When';
$lang['strformat'] = 'Format';
+ $lang['strdata'] = 'Data';
+ $lang['strconfirm'] = 'Confirm';
// Error handling
$lang['strnoframes'] = 'You need a frames-enabled browser to use this application.';
$lang['strcreatedb'] = 'Create DB?';
$lang['strexpires'] = 'Expires';
$lang['strnousers'] = 'No users found.';
- $lang['struserupdated'] = 'User updated.';
+ $lang['struserupdated'] = 'User updated.';
$lang['struserupdatedbad'] = 'User update failed.';
$lang['strshowallusers'] = 'Show All Users';
$lang['strcreateuser'] = 'Create User';
$lang['struserdroppedbad'] = 'Failed to drop user.';
$lang['straccount'] = 'Account';
$lang['strchangepassword'] = 'Change Password';
-
+ $lang['strpasswordchanged'] = 'Password changed.';
+ $lang['strpasswordchangedbad'] = 'Failed to change password.';
+ $lang['strpasswordshort'] = 'Password is too short.';
+ $lang['strpasswordconfirm'] = 'Password does not match confirmation.';
+
// Groups
$lang['strgroupadmin'] = 'Group Admin';
$lang['strgroup'] = 'Group';
/**
* Function library read in upon startup
*
- * $Id: lib.inc.php,v 1.44 2003/05/08 14:15:59 chriskl Exp $
+ * $Id: lib.inc.php,v 1.45 2003/05/08 15:14:15 chriskl Exp $
*/
// Set error reporting level to max
// Configuration file version. If this is greater than that in config.inc.php, then
// the app will refuse to run. This and $conf['version'] should be incremented whenever
// backwards incompatible changes are made to config.inc.php-dist.
- $conf['base_version'] = 6;
+ $conf['base_version'] = 7;
// List of available language files
$appLangFiles = array(
/**
* Top menu for phpPgAdmin
*
- * $Id: topbar.php,v 1.10 2003/05/08 14:15:55 chriskl Exp $
+ * $Id: topbar.php,v 1.11 2003/05/08 15:14:14 chriskl Exp $
*/
// Include application functions
?>
<a class="toplink" href="users.php" target="detail"><?php echo $lang['struseradmin'] ?></a> |
<a class="toplink" href="groups.php" target="detail"><?php echo $lang['strgroupadmin'] ?></a> |
-<?php
- else :
-?>
- <a class="toplink" href="users.php?action=account" target="detail"><?php echo $lang['straccount'] ?></a> |
<?php
endif;
?>
+ <a class="toplink" href="users.php?action=account" target="detail"><?php echo $lang['straccount'] ?></a> |
<?php if ($conf['show_reports']) : ?>
<a class="toplink" href="reports.php" target="detail"><?php echo $lang['strreports'] ?></a> |
<?php endif; ?>
/**
* Manage users in a database cluster
*
- * $Id: users.php,v 1.9 2003/05/08 14:15:56 chriskl Exp $
+ * $Id: users.php,v 1.10 2003/05/08 15:14:14 chriskl Exp $
*/
// Include application functions
$userdata = &$data->getUser($_SESSION['webdbUsername']);
if ($userdata->recordCount() > 0) {
+ $userdata->f[$data->uFields['usuper']] = $data->phpBool($userdata->f[$data->uFields['usuper']]);
+ $userdata->f[$data->uFields['ucreatedb']] = $data->phpBool($userdata->f[$data->uFields['ucreatedb']]);
echo "<table>\n";
echo "<tr><th class=\"data\">{$lang['strusername']}</th><th class=\"data\">{$lang['strsuper']}</th><th class=\"data\">{$lang['strcreatedb']}</th><th class=\"data\">{$lang['strexpires']}</th></tr>\n";
echo "<tr><td class=\"data1\">", htmlspecialchars($userdata->f[$data->uFields['uname']]), "</td>\n";
- echo "<td class=\"data1\">", $userdata->f[$data->uFields['usuper']], "</td>\n";
- echo "<td class=\"data1\">", $userdata->f[$data->uFields['ucreatedb']], "</td>\n";
+ echo "<td class=\"data1\">", (($userdata->f[$data->uFields['usuper']]) ? $lang['stryes'] : $lang['strno']), "</td>\n";
+ echo "<td class=\"data1\">", (($userdata->f[$data->uFields['ucreatedb']]) ? $lang['stryes'] : $lang['strno']), "</td>\n";
echo "<td class=\"data1\">", htmlspecialchars($userdata->f[$data->uFields['uexpires']]), "</td></tr>\n";
echo "</table>\n";
}
echo "<p><a class=\"navlink\" href=\"$PHP_SELF?action=confchangepassword\">{$lang['strchangepassword']}</a></p>\n";
}
+ /**
+ * Show confirmation of change password and actually change password
+ */
+ function doChangePassword($confirm, $msg = '') {
+ global $data, $misc;
+ global $PHP_SELF, $lang, $conf;
+
+ if ($confirm) {
+ echo "<h2>{$lang['strusers']}: ", htmlspecialchars($_SESSION['webdbUsername']), ": {$lang['strchangepassword']}</h2>\n";
+ $misc->printMsg($msg);
+
+ if (!isset($_POST['password'])) $_POST['password'] = '';
+ if (!isset($_POST['confirm'])) $_POST['confirm'] = '';
+
+
+ echo "<form action=\"$PHP_SELF\" method=\"post\">\n";
+ echo $lang['strpassword'], "<br />\n";
+ echo "<input type=\"password\" name=\"password\" size=\"32\" value=\"",
+ htmlspecialchars($_POST['password']), "\" /><br /><br />\n";
+ echo $lang['strconfirm'], "<br />\n";
+ echo "<input type=\"password\" name=\"confirm\" size=\"32\" value=\"",
+ htmlspecialchars($_POST['confirm']), "\" /><br /><br />\n";
+ echo "<input type=\"hidden\" name=\"action\" value=\"changepassword\" />\n";
+ echo "<input type=\"submit\" name=\"ok\" value=\"{$lang['strok']}\" />\n";
+ echo "<input type=\"submit\" name=\"cancel\" value=\"{$lang['strcancel']}\" />\n";
+ echo "</form>\n";
+ }
+ else {
+ // Check that password is minimum length
+ if (strlen($_POST['password']) < $conf['min_password_length'])
+ doChangePassword(true, $lang['strpasswordshort']);
+ // Check that password matches confirmation password
+ elseif ($_POST['password'] != $_POST['confirm'])
+ doChangePassword(true, $lang['strpasswordconfirm']);
+ else {
+ $status = $data->changePassword($_SESSION['webdbUsername'],
+ $_POST['password']);
+ if ($status == 0)
+ doAccount($lang['strpasswordchanged']);
+ else
+ doAccount($lang['strpasswordchangedbad']);
+ }
+ }
+ }
+
/**
* Function to save after editing a user
*/
$userdata = &$data->getUser($_REQUEST['username']);
if ($userdata->recordCount() > 0) {
+ $userdata->f[$data->uFields['usuper']] = $data->phpBool($userdata->f[$data->uFields['usuper']]);
+ $userdata->f[$data->uFields['ucreatedb']] = $data->phpBool($userdata->f[$data->uFields['ucreatedb']]);
echo "<table>\n";
echo "<tr><th class=\"data\">{$lang['strusername']}</th><th class=\"data\">{$lang['strsuper']}</th><th class=\"data\">{$lang['strcreatedb']}</th><th class=\"data\">{$lang['strexpires']}</th></tr>\n";
echo "<tr><td class=\"data1\">", htmlspecialchars($userdata->f[$data->uFields['uname']]), "</td>\n";
- echo "<td class=\"data1\">", $userdata->f[$data->uFields['usuper']], "</td>\n";
- echo "<td class=\"data1\">", $userdata->f[$data->uFields['ucreatedb']], "</td>\n";
+ echo "<td class=\"data1\">", (($userdata->f[$data->uFields['usuper']]) ? $lang['stryes'] : $lang['strno']), "</td>\n";
+ echo "<td class=\"data1\">", (($userdata->f[$data->uFields['ucreatedb']]) ? $lang['stryes'] : $lang['strno']), "</td>\n";
echo "<td class=\"data1\">", htmlspecialchars($userdata->f[$data->uFields['uexpires']]), "</td></tr>\n";
echo "</table>\n";
}
$misc->printBody();
switch ($action) {
+ case 'changepassword':
+ if (isset($_REQUEST['ok'])) doChangePassword(false);
+ else doAccount();
+ break;
+ case 'confchangepassword':
+ doChangePassword(true);
+ break;
case 'account':
doAccount();
break;