{$lang['strusers']}: ", $misc->printVal($_SESSION['webdbUsername']), ": {$lang['straccount']}\n"; $misc->printMsg($msg); $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 "\n"; echo ""; if ($data->hasUserSessionDefaults()) echo ""; echo "\n"; echo "\n\t\n"; echo "\t\n"; echo "\t\n"; echo "\t\n"; if ($data->hasUserSessionDefaults()) echo "\t\n"; echo "\n
{$lang['strusername']}{$lang['strsuper']}{$lang['strcreatedb']}{$lang['strexpires']}{$lang['strsessiondefaults']}
", $misc->printVal($userdata->f[$data->uFields['uname']]), "", (($userdata->f[$data->uFields['usuper']]) ? $lang['stryes'] : $lang['strno']), "", (($userdata->f[$data->uFields['ucreatedb']]) ? $lang['stryes'] : $lang['strno']), "", ($userdata->f[$data->uFields['uexpires']] == 'infinity' ? '' : $misc->printVal($userdata->f[$data->uFields['uexpires']])), "", $misc->printVal($userdata->f[$data->uFields['udefaults']]), "
\n"; } else echo "

{$lang['strnodata']}

\n"; echo "

{$lang['strchangepassword']}

\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 "

{$lang['strusers']}: ", $misc->printVal($_SESSION['webdbUsername']), ": {$lang['strchangepassword']}

\n"; $misc->printMsg($msg); if (!isset($_POST['password'])) $_POST['password'] = ''; if (!isset($_POST['confirm'])) $_POST['confirm'] = ''; echo "
\n"; echo "\n"; echo "\t\n\t\t\n"; echo "\t\t\n\t\n"; echo "\t\n\t\t\n"; echo "\t\t\n\t\n"; echo "
{$lang['strpassword']}
{$lang['strconfirm']}
\n"; echo "

\n"; echo "\n"; echo "\n"; echo "

\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 allow editing of a user */ function doEdit($msg = '') { global $data, $misc; global $PHP_SELF, $lang; echo "

{$lang['strusers']}: ", $misc->printVal($_REQUEST['username']), ": {$lang['stralter']}

\n"; $misc->printMsg($msg); $userdata = &$data->getUser($_REQUEST['username']); if ($userdata->recordCount() > 0) { $canRename = $data->hasUserRename() && ($_REQUEST['username'] != $_SESSION['webdbUsername']); $userdata->f[$data->uFields['usuper']] = $data->phpBool($userdata->f[$data->uFields['usuper']]); $userdata->f[$data->uFields['ucreatedb']] = $data->phpBool($userdata->f[$data->uFields['ucreatedb']]); if (!isset($_POST['formExpires'])){ if ($canRename) $_POST['newname'] = $userdata->f[$data->uFields['uname']]; if ($userdata->f[$data->uFields['usuper']]) $_POST['formSuper'] = ''; if ($userdata->f[$data->uFields['ucreatedb']]) $_POST['formCreateDB'] = ''; $_POST['formExpires'] = $userdata->f[$data->uFields['uexpires']] == 'infinity' ? '' : $userdata->f[$data->uFields['uexpires']]; $_POST['formPassword'] = ''; } echo "\n"; echo "
\n"; echo "\t\n\t\t\n"; echo "\t\t\n\t\n"; echo "\t\n\t\t\n"; echo "\t\t\n\t\n"; echo "\t\n\t\t\n"; echo "\t\t\n\t\n"; echo "\t\n\t\t\n"; echo "\t\t\n\t\n"; echo "\t\n\t\t\n"; echo "\t\t\n\t\n"; echo "\t\n\t\t\n"; echo "\t\t\n\t\n"; echo "
{$lang['strusername']}", ($canRename ? "" : $misc->printVal($userdata->f[$data->uFields['uname']])), "
{$lang['strsuper']}
{$lang['strcreatedb']}
{$lang['strexpires']}
{$lang['strpassword']}
{$lang['strconfirm']}
\n"; echo "

\n"; echo "\n"; echo "\n"; echo "

\n"; echo "\n"; } else echo "

{$lang['strnodata']}

\n"; } /** * Function to save after editing a user */ function doSaveEdit() { global $data, $lang; // Check name and password if (isset($_POST['newname']) && $_POST['newname'] == '') doEdit($lang['struserneedsname']); else if ($_POST['formPassword'] != $_POST['formConfirm']) doEdit($lang['strpasswordconfirm']); else { if (isset($_POST['newname'])) $status = $data->setRenameUser($_POST['username'], $_POST['formPassword'], isset($_POST['formCreateDB']), isset($_POST['formSuper']), $_POST['formExpires'], $_POST['newname']); else $status = $data->setUser($_POST['username'], $_POST['formPassword'], isset($_POST['formCreateDB']), isset($_POST['formSuper']), $_POST['formExpires']); if ($status == 0) doDefault($lang['struserupdated']); else doEdit($lang['struserupdatedbad']); } } /** * Show confirmation of drop and perform actual drop */ function doDrop($confirm) { global $data, $misc; global $PHP_SELF, $lang; if ($confirm) { echo "

{$lang['strusers']}: ", $misc->printVal($_REQUEST['username']), ": {$lang['strdrop']}

\n"; echo "

", sprintf($lang['strconfdropuser'], $misc->printVal($_REQUEST['username'])), "

\n"; echo "
\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "
\n"; } else { $status = $data->dropUser($_REQUEST['username']); if ($status == 0) doDefault($lang['struserdropped']); else doDefault($lang['struserdroppedbad']); } } /** * Displays a screen where they can enter a new user */ function doCreate($msg = '') { global $data, $misc, $username; global $PHP_SELF, $lang; if (!isset($_POST['formUsername'])) $_POST['formUsername'] = ''; if (!isset($_POST['formPassword'])) $_POST['formPassword'] = ''; if (!isset($_POST['formConfirm'])) $_POST['formConfirm'] = ''; if (!isset($_POST['formExpires'])) $_POST['formExpires'] = ''; echo "

{$lang['strusers']}: {$lang['strcreateuser']}

\n"; $misc->printMsg($msg); echo "
\n"; echo "\n"; echo "\t\n\t\t\n"; echo "\t\t\n\t\n"; echo "\t\n\t\t\n"; echo "\t\t\n\t\n"; echo "\t\n\t\t\n"; echo "\t\t\n\t\n"; echo "\t\n\t\t\n"; echo "\t\t\n\t\n"; echo "\t\n\t\t\n"; echo "\t\t\n\t\n"; echo "\t\n\t\t\n"; echo "\t\t\n\t\n"; echo "
{$lang['strusername']}
{$lang['strpassword']}
{$lang['strconfirm']}
{$lang['strsuper']}
{$lang['strcreatedb']}
{$lang['strexpires']}
\n"; echo "

\n"; echo "\n"; echo "

\n"; echo "
\n"; } /** * Actually creates the new user in the database */ function doSaveCreate() { global $data; global $lang; // Check data if ($_POST['formUsername'] == '') doCreate($lang['struserneedsname']); else if ($_POST['formPassword'] != $_POST['formConfirm']) doCreate($lang['strpasswordconfirm']); else { $status = $data->createUser($_POST['formUsername'], $_POST['formPassword'], isset($_POST['formCreateDB']), isset($_POST['formSuper']), $_POST['formExpires'], array()); if ($status == 0) doDefault($lang['strusercreated']); else doCreate($lang['strusercreatedbad']); } } /** * Show default list of users in the database */ function doDefault($msg = '') { global $data, $misc; global $PHP_SELF, $lang; echo "

{$lang['strusers']}

\n"; $misc->printMsg($msg); $users = &$data->getUsers(); if ($users->recordCount() > 0) { echo "\n"; echo ""; if ($data->hasUserSessionDefaults()) echo ""; echo "\n"; $i = 0; while (!$users->EOF) { $users->f[$data->uFields['usuper']] = $data->phpBool($users->f[$data->uFields['usuper']]); $users->f[$data->uFields['ucreatedb']] = $data->phpBool($users->f[$data->uFields['ucreatedb']]); $id = (($i % 2) == 0 ? '1' : '2'); echo "\n\t\n"; echo "\t\n"; echo "\t\n"; echo "\t\n"; if ($data->hasUserSessionDefaults()) echo "\t\n"; echo "\t\n"; echo "\t\n"; echo "\n"; $users->moveNext(); $i++; } echo "
{$lang['strusername']}{$lang['strsuper']}{$lang['strcreatedb']}{$lang['strexpires']}{$lang['strsessiondefaults']}{$lang['stractions']}
", $misc->printVal($users->f[$data->uFields['uname']]), "", ($users->f[$data->uFields['usuper']]) ? $lang['stryes'] : $lang['strno'], "", ($users->f[$data->uFields['ucreatedb']]) ? $lang['stryes'] : $lang['strno'], "", ($users->f[$data->uFields['uexpires']] == 'infinity' ? '' : $misc->printVal($users->f[$data->uFields['uexpires']])), "", $misc->printVal($users->f[$data->uFields['udefaults']]), "f[$data->uFields['uname']]), "\">{$lang['stralter']}f[$data->uFields['uname']]), "\">{$lang['strdrop']}
\n"; } else { echo "

{$lang['strnousers']}

\n"; } echo "

{$lang['strcreateuser']}

\n"; } $misc->printHeader($lang['strusers']); $misc->printBody(); switch ($action) { case 'changepassword': if (isset($_REQUEST['ok'])) doChangePassword(false); else doAccount(); break; case 'confchangepassword': doChangePassword(true); break; case 'account': doAccount(); break; case 'save_create': if (isset($_REQUEST['cancel'])) doDefault(); else doSaveCreate(); break; case 'create': doCreate(); break; case 'drop': if (isset($_REQUEST['cancel'])) doDefault(); else doDrop(false); break; case 'confirm_drop': doDrop(true); break; case 'save_edit': if (isset($_REQUEST['cancel'])) doDefault(); else doSaveEdit(); break; case 'edit': doEdit(); break; default: doDefault(); break; } $misc->printFooter(); ?>