getServerInfo(); $userdata = $data->getUser($server_info['username']); $_REQUEST['user'] = $server_info['username']; $misc->printTrail('user'); $misc->printTabs('server','account'); $misc->printMsg($msg); if ($userdata->recordCount() > 0) { $userdata->fields['usesuper'] = $data->phpBool($userdata->fields['usesuper']); $userdata->fields['usecreatedb'] = $data->phpBool($userdata->fields['usecreatedb']); echo "\n"; echo ""; echo ""; echo "\n"; echo "\n\t\n"; echo "\t\n"; echo "\t\n"; echo "\t\n"; echo "\t\n"; echo "\n
{$lang['strusername']}{$lang['strsuper']}{$lang['strcreatedb']}{$lang['strexpires']}{$lang['strsessiondefaults']}
", $misc->printVal($userdata->fields['usename']), "", $misc->printVal($userdata->fields['usesuper'], 'yesno'), "", $misc->printVal($userdata->fields['usecreatedb'], 'yesno'), "", ($userdata->fields['useexpires'] == 'infinity' || is_null($userdata->fields['useexpires']) ? $lang['strnever'] : $misc->printVal($userdata->fields['useexpires'])), "", $misc->printVal($userdata->fields['useconfig']), "
\n"; } else echo "

{$lang['strnodata']}

\n"; $misc->printNavLinks(array ('changepassword' => array ( 'attr'=> array ( 'href' => array ( 'url' => 'users.php', 'urlvars' => array ( 'action' => 'confchangepassword', 'server' => $_REQUEST['server'] ) ) ), 'content' => $lang['strchangepassword'] )), 'users-account', get_defined_vars()); } /** * Show confirmation of change password and actually change password */ function doChangePassword($confirm, $msg = '') { global $data, $misc; global $lang, $conf; $server_info = $misc->getServerInfo(); if ($confirm) { $_REQUEST['user'] = $server_info['username']; $misc->printTrail('user'); $misc->printTitle($lang['strchangepassword'],'pg.user.alter'); $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 $misc->form; 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($server_info['username'], $_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 $lang; $misc->printTrail('user'); $misc->printTitle($lang['stralter'],'pg.user.alter'); $misc->printMsg($msg); $userdata = $data->getUser($_REQUEST['username']); if ($userdata->recordCount() > 0) { $server_info = $misc->getServerInfo(); $canRename = $data->hasUserRename() && ($_REQUEST['username'] != $server_info['username']); $userdata->fields['usesuper'] = $data->phpBool($userdata->fields['usesuper']); $userdata->fields['usecreatedb'] = $data->phpBool($userdata->fields['usecreatedb']); if (!isset($_POST['formExpires'])){ if ($canRename) $_POST['newname'] = $userdata->fields['usename']; if ($userdata->fields['usesuper']) $_POST['formSuper'] = ''; if ($userdata->fields['usecreatedb']) $_POST['formCreateDB'] = ''; $_POST['formExpires'] = $userdata->fields['useexpires'] == 'infinity' ? '' : $userdata->fields['useexpires']; $_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 ? "_maxNameLen}\" value=\"" . htmlspecialchars($_POST['newname']) . "\" />" : $misc->printVal($userdata->fields['usename'])), "
{$lang['strexpires']}
{$lang['strpassword']}
{$lang['strconfirm']}
\n"; echo "

\n"; echo "\n"; echo $misc->form; 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 $lang; if ($confirm) { $misc->printTrail('user'); $misc->printTitle($lang['strdrop'],'pg.user.drop'); echo "

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

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

\n"; echo "\n"; echo $misc->form; 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 $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'] = ''; $misc->printTrail('server'); $misc->printTitle($lang['strcreateuser'],'pg.user.create'); $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']}_maxNameLen}\" name=\"formUsername\" value=\"", htmlspecialchars($_POST['formUsername']), "\" />
{$lang['strpassword']}
{$lang['strconfirm']}
{$lang['strexpires']}
\n"; echo "

\n"; echo $misc->form; 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 $lang; function renderUseExpires($val) { global $lang; return $val == 'infinity' ? $lang['strnever'] : htmlspecialchars($val); } $misc->printTrail('server'); $misc->printTabs('server','users'); $misc->printMsg($msg); $users = $data->getUsers(); $columns = array( 'user' => array( 'title' => $lang['strusername'], 'field' => field('usename'), ), 'superuser' => array( 'title' => $lang['strsuper'], 'field' => field('usesuper'), 'type' => 'yesno', ), 'createdb' => array( 'title' => $lang['strcreatedb'], 'field' => field('usecreatedb'), 'type' => 'yesno', ), 'expires' => array( 'title' => $lang['strexpires'], 'field' => field('useexpires'), 'type' => 'callback', 'params'=> array('function' => 'renderUseExpires', 'null' => $lang['strnever']), ), 'defaults' => array( 'title' => $lang['strsessiondefaults'], 'field' => field('useconfig'), ), 'actions' => array( 'title' => $lang['stractions'], ), ); $actions = array( 'alter' => array( 'content' => $lang['stralter'], 'attr'=> array ( 'href' => array ( 'url' => 'users.php', 'urlvars' => array ( 'action' => 'edit', 'username' => field('usename') ) ) ) ), 'drop' => array( 'content' => $lang['strdrop'], 'attr'=> array ( 'href' => array ( 'url' => 'users.php', 'urlvars' => array ( 'action' => 'confirm_drop', 'username' => field('usename') ) ) ) ), ); $misc->printTable($users, $columns, $actions, 'users-users', $lang['strnousers']); $misc->printNavLinks(array ('create' => array ( 'attr'=> array ( 'href' => array ( 'url' => 'users.php', 'urlvars' => array ( 'action' => 'create', 'server' => $_REQUEST['server'] ) ) ), 'content' => $lang['strcreateuser'] )), 'users-users', get_defined_vars()); } $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(); ?>