/**
* Class to hold various commonly used functions
*
- * $Id: Misc.php,v 1.30 2003/05/07 06:29:54 chriskl Exp $
+ * $Id: Misc.php,v 1.31 2003/05/08 14:15:57 chriskl Exp $
*/
class Misc {
function &getDatabaseAccessor($host, $port, $database, $username, $password) {
global $conf;
+ $desc = null;
$type = $this->getDriver($host, $port, $username, $password,
- $conf['servers'][$_SESSION['webdbServerID']]['type']);
+ $conf['servers'][$_SESSION['webdbServerID']]['type'], $desc);
include_once('classes/database/' . $type . '.php');
$localData = new $type( $host,
$port,
* @param $user The username to use
* @param $password The password to use
* @param $type The ADODB database type name.
+ * @param (return-by-ref) $description A description of the database and version
* @return The class name of the driver eg. Postgres73
* @return -1 Database functions not compiled in
* @return -2 Invalid database type
* @return -3 Database-specific failure
*/
- function getDriver($host, $port, $user, $password, $type) {
+ function getDriver($host, $port, $user, $password, $type, &$description) {
switch ($type) {
case 'postgres7':
// Check functions are loaded
if (!isset($params[1])) return -3;
$version = $params[1]; // eg. 7.3.2
+ $description = "PostgreSQL {$params[1]}";
if (strpos($version, '7.4') === 0)
return 'Postgres74';
break;
case 'mysql':
// Check functions are loaded
+ $description = 'MySQL';
if (!function_exists('mysql_connect')) return -1;
return 'MySQL';
break;
* the functions provided by the database driver exclusively, and hence
* will work with any database without modification.
*
- * $Id: Reports.php,v 1.5 2003/04/21 06:36:24 chriskl Exp $
+ * $Id: Reports.php,v 1.6 2003/05/08 14:15:57 chriskl Exp $
*/
class Reports {
* @return A recordset
*/
function &getReports() {
+ global $conf;
+ // Filter for owned reports if necessary
+ if ($conf['owned_reports_only']) {
+ $filter['created_by'] = $_SESSION['webdbUsername'];
+ }
+ else $filter = array();
+
$sql = $this->driver->getSelectSQL('ppa_reports',
array('report_id', 'report_name', 'db_name', 'date_created', 'created_by', 'descr', 'report_sql'),
- array(), array(), array('report_name'));
+ $filter, array(), array('report_name'));
return $this->driver->selectSet($sql);
}
* A class that implements the DB interface for Postgres
* Note: This class uses ADODB and returns RecordSets.
*
- * $Id: Postgres.php,v 1.96 2003/05/07 15:00:56 chriskl Exp $
+ * $Id: Postgres.php,v 1.97 2003/05/08 14:15:57 chriskl Exp $
*/
// @@@ THOUGHT: What about inherits? ie. use of ONLY???
return $this->selectSet($sql);
}
+ /**
+ * Determines whether or not a user is a super user
+ * @param $username The username of the user
+ * @return True if is a super user, false otherwise
+ */
+ function isSuperUser($username) {
+ $this->clean($username);
+
+ $sql = "SELECT usesuper FROM pg_user WHERE usename='{$username}'";
+
+ $usesuper = $this->selectField($sql, 'usesuper');
+ if ($usesuper == -1) return false;
+ else return $usesuper == 't';
+ }
+
/**
* Creates a new user
* @param $username The username of the user to create
* Central phpPgAdmin configuration. As a user you may modify the
* settings here for your particular configuration.
*
- * $Id: config.inc.php-dist,v 1.18 2003/05/08 02:03:53 chriskl Exp $
+ * $Id: config.inc.php-dist,v 1.19 2003/05/08 14:15:58 chriskl Exp $
*/
// An example server. Create as many of these as you wish,
// (eg. Run 'SELECT * FROM pg_database' in the SQL area.)
$conf['owned_only'] = false;
+ // Display reports feature?
+ $conf['show_reports'] = true;
+
+ // Only show owned reports?
+ // Note: This does not prevent people from accessing other reports by other
+ // means.
+ $conf['owned_reports_only'] = false;
+
// Width of the left frame in pixels (object browser)
$conf['left_width'] = 200;
* English language file for phpPgAdmin. Use this as a basis
* for new translations.
*
- * $Id: english.php,v 1.74 2003/04/30 06:35:42 chriskl Exp $
+ * $Id: english.php,v 1.75 2003/05/08 14:15:58 chriskl Exp $
*/
// Language and character set
$lang['strconfdropuser'] = 'Are you sure you want to drop the user "%s"?';
$lang['struserdropped'] = 'User dropped.';
$lang['struserdroppedbad'] = 'Failed to drop user.';
+ $lang['straccount'] = 'Account';
+ $lang['strchangepassword'] = 'Change Password';
// Groups
$lang['strgroupadmin'] = 'Group Admin';
* English language file for phpPgAdmin. Use this as a basis
* for new translations.
*
- * $Id: english.php,v 1.26 2003/04/30 06:35:42 chriskl Exp $
+ * $Id: english.php,v 1.27 2003/05/08 14:15:59 chriskl Exp $
*/
// Language and character set
$lang['strconfdropuser'] = 'Are you sure you want to drop the user "%s"?';
$lang['struserdropped'] = 'User dropped.';
$lang['struserdroppedbad'] = 'Failed to drop user.';
+ $lang['straccount'] = 'Account';
+ $lang['strchangepassword'] = 'Change Password';
// Groups
$lang['strgroupadmin'] = 'Group Admin';
/**
* Function library read in upon startup
*
- * $Id: lib.inc.php,v 1.43 2003/05/07 01:20:02 chriskl Exp $
+ * $Id: lib.inc.php,v 1.44 2003/05/08 14:15:59 chriskl Exp $
*/
// Set error reporting level to max
$conf['servers'][$_SESSION['webdbServerID']]['port'],
$_SESSION['webdbUsername'],
$_SESSION['webdbPassword'],
- $conf['servers'][$_SESSION['webdbServerID']]['type']);
+ $conf['servers'][$_SESSION['webdbServerID']]['type'],
+ $conf['description']);
// Check return type
if ($_type == -1) {
echo $lang['strnotloaded'];
/**
* Top menu for phpPgAdmin
*
- * $Id: topbar.php,v 1.9 2003/04/21 06:36:23 chriskl Exp $
+ * $Id: topbar.php,v 1.10 2003/05/08 14:15:55 chriskl Exp $
*/
// Include application functions
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="211" rowspan="2"><img src="images/themes/<?php echo $conf['theme'] ?>/title.gif" width="211" height="50" alt="<?php echo htmlspecialchars($appName) ?>" /></td>
- <td width="69%">
- <?php echo sprintf($lang['strtopbar'], htmlspecialchars($conf['servers'][$_SESSION['webdbServerID']]['type']),
+ <td width="5" rowspan="2"> </td>
+ <td>
+ <?php echo sprintf($lang['strtopbar'], htmlspecialchars($conf['description']),
htmlspecialchars($conf['servers'][$_SESSION['webdbServerID']]['host']),
htmlspecialchars($conf['servers'][$_SESSION['webdbServerID']]['port']),
htmlspecialchars($_SESSION['webdbUsername']),
</tr>
<tr>
<td>
+<?php
+ // For superuser, show user and group admin. For normal user, show change password.
+ if ($data->isSuperUser($_SESSION['webdbUsername'])) :
+?>
<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;
+?>
+<?php if ($conf['show_reports']) : ?>
<a class="toplink" href="reports.php" target="detail"><?php echo $lang['strreports'] ?></a> |
+<?php endif; ?>
<a class="toplink" href="logout.php" target="_parent"><?php echo $lang['strlogout'] ?></a>
</td>
</tr>
/**
* Manage users in a database cluster
*
- * $Id: users.php,v 1.8 2003/04/19 09:25:22 chriskl Exp $
+ * $Id: users.php,v 1.9 2003/05/08 14:15:56 chriskl Exp $
*/
// Include application functions
$action = (isset($_REQUEST['action'])) ? $_REQUEST['action'] : '';
if (!isset($msg)) $msg = '';
$PHP_SELF = $_SERVER['PHP_SELF'];
-
+
+ /**
+ * If a user is not a superuser, then we have an 'account management' page
+ * where they can change their password, etc. We don't prevent them from
+ * messing with the URL to gain access to other user admin stuff, because
+ * the PostgreSQL permissions will prevent them changing anything anyway.
+ */
+ function doAccount($msg = '') {
+ global $data, $misc;
+ global $PHP_SELF, $lang;
+
+ echo "<h2>{$lang['strusers']}: ", htmlspecialchars($_SESSION['webdbUsername']), ": {$lang['straccount']}</h2>\n";
+ $misc->printMsg($msg);
+
+ $userdata = &$data->getUser($_SESSION['webdbUsername']);
+
+ if ($userdata->recordCount() > 0) {
+ 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\">", htmlspecialchars($userdata->f[$data->uFields['uexpires']]), "</td></tr>\n";
+ echo "</table>\n";
+ }
+ else echo "<p>{$lang['strnodata']}</p>\n";
+
+ echo "<p><a class=\"navlink\" href=\"$PHP_SELF?action=confchangepassword\">{$lang['strchangepassword']}</a></p>\n";
+ }
+
/**
* Function to save after editing a user
*/
$misc->printBody();
switch ($action) {
+ case 'account':
+ doAccount();
+ break;
case 'save_create':
doSaveCreate();
break;