- improved 'edit ftp-account', fixes #116

This commit is contained in:
Michael Kaufmann (d00p)
2010-04-07 06:08:09 +00:00
parent fb4ade70d2
commit 368e6a5c50
6 changed files with 89 additions and 21 deletions

View File

@@ -173,18 +173,12 @@ elseif($page == 'accounts')
}
else
{
$userpath = makeCorrectDir($path);
$path = makeCorrectDir($userinfo['documentroot'] . '/' . $path);
$db->query("INSERT INTO `" . TABLE_FTP_USERS . "` (`customerid`, `username`, `password`, `homedir`, `login_enabled`, `uid`, `gid`) VALUES ('" . (int)$userinfo['customerid'] . "', '" . $db->escape($username) . "', ENCRYPT('" . $db->escape($password) . "'), '" . $db->escape($path) . "', 'y', '" . (int)$userinfo['guid'] . "', '" . (int)$userinfo['guid'] . "')");
$db->query("UPDATE `" . TABLE_FTP_GROUPS . "` SET `members`=CONCAT_WS(',',`members`,'" . $db->escape($username) . "') WHERE `customerid`='" . $userinfo['customerid'] . "' AND `gid`='" . (int)$userinfo['guid'] . "'");
// $db->query("INSERT INTO `".TABLE_FTP_GROUPS."` (`customerid`, `groupname`, `gid`, `members`) VALUES ('".$userinfo['customerid']."', '$username', '$uid', '$username')");
$db->query("UPDATE `" . TABLE_PANEL_CUSTOMERS . "` SET `ftps_used`=`ftps_used`+1, `ftp_lastaccountnumber`=`ftp_lastaccountnumber`+1 WHERE `customerid`='" . (int)$userinfo['customerid'] . "'");
// $db->query("UPDATE `".TABLE_PANEL_SETTINGS."` SET `value`='$uid' WHERE settinggroup='ftp' AND varname='lastguid'");
$log->logAction(USR_ACTION, LOG_INFO, "added ftp-account '" . $username . " (" . $path . ")'");
inserttask(5);
redirectTo($filename, Array('page' => $page, 's' => $s));
@@ -213,7 +207,7 @@ elseif($page == 'accounts')
elseif($action == 'edit'
&& $id != 0)
{
$result = $db->query_first("SELECT `id`, `username`, `homedir` FROM `" . TABLE_FTP_USERS . "` WHERE `customerid`='" . (int)$userinfo['customerid'] . "' AND `id`='" . (int)$id . "'");
$result = $db->query_first("SELECT `id`, `username`, `homedir`, `uid`, `gid` FROM `" . TABLE_FTP_USERS . "` WHERE `customerid`='" . (int)$userinfo['customerid'] . "' AND `id`='" . (int)$id . "'");
if(isset($result['username'])
&& $result['username'] != '')
@@ -221,8 +215,18 @@ elseif($page == 'accounts')
if(isset($_POST['send'])
&& $_POST['send'] == 'send')
{
$password = validate($_POST['ftp_password'], 'password');
$path = validate($_POST['path'], 'path');
$_setnewpass = false;
if(isset($_POST['ftp_password']) && $_POST['ftp_password'] != '')
{
$password = validate($_POST['ftp_password'], 'password');
$password = validatePassword($password);
$_setnewpass = true;
}
if($_setnewpass)
{
if($password == '')
{
standard_error(array('stringisempty', 'mypassword'));
@@ -230,13 +234,55 @@ elseif($page == 'accounts')
}
else
{
$log->logAction(USR_ACTION, LOG_INFO, "updated ftp-account password for '" . $result['username'] . "'");
$db->query("UPDATE `" . TABLE_FTP_USERS . "` SET `password`=ENCRYPT('" . $db->escape($password) . "') WHERE `customerid`='" . (int)$userinfo['customerid'] . "' AND `id`='" . (int)$id . "'");
$log->logAction(USR_ACTION, LOG_INFO, "edited ftp-account '" . $result['username'] . "'");
redirectTo($filename, Array('page' => $page, 's' => $s));
}
}
if($path != '')
{
$path = makeCorrectDir($userinfo['documentroot'] . '/' . $path);
if($path != $result['homedir'])
{
if(!file_exists($path))
{
mkDirWithCorrectOwnership($userinfo['documentroot'], $path, $result['uid'], $result['gid']);
}
$log->logAction(USR_ACTION, LOG_INFO, "updated ftp-account homdir for '" . $result['username'] . "'");
$db->query("UPDATE `" . TABLE_FTP_USERS . "` SET `homedir`= '" . $db->escape($path) . "' WHERE `customerid`='" . (int)$userinfo['customerid'] . "' AND `id`='" . (int)$id . "'");
}
}
redirectTo($filename, Array('page' => $page, 's' => $s));
}
else
{
if(strpos($result['homedir'], $userinfo['documentroot']) === 0)
{
$homedir = substr($result['homedir'], strlen($userinfo['documentroot']));
}
else
{
$homedir = $result['homedir'];
}
$homedir = makeCorrectDir($homedir);
$pathSelect = makePathfield($userinfo['documentroot'], $userinfo['guid'], $userinfo['guid'], $settings['panel']['pathedit'], $homedir);
if($settings['customer']['ftpatdomain'] == '1')
{
$domains = '';
$result_domains = $db->query("SELECT `domain` FROM `" . TABLE_PANEL_DOMAINS . "` WHERE `customerid`='" . (int)$userinfo['customerid'] . "'");
while($row_domain = $db->fetch_array($result_domains))
{
$domains.= makeoption($idna_convert->decode($row_domain['domain']), $row_domain['domain']);
}
}
eval("echo \"" . getTemplate("ftp/accounts_edit") . "\";");
}
}

View File

@@ -38,7 +38,7 @@ function makePathfield($path, $uid, $gid, $fieldType, $value = '')
if($fieldType == 'Manual')
{
$field = '<input type="text" name="path" value="' . htmlspecialchars($value) . '" size="30" />';
$field = '<input type="text" name="path" value="' . htmlspecialchars($value) . '" />';
}
elseif($fieldType == 'Dropdown')
{
@@ -65,7 +65,7 @@ function makePathfield($path, $uid, $gid, $fieldType, $value = '')
else
{
$field = $lng['panel']['toomanydirs'];
$field.= '<input type="text" name="path" value="' . htmlspecialchars($value) . '" size="30" />';
$field.= '<input type="text" name="path" value="' . htmlspecialchars($value) . '" />';
}
}
else

View File

@@ -1347,4 +1347,8 @@ $lng['cron']['changewarning'] = 'Changing these values can have a negative cause
$lng['serversettings']['stdsubdomainhost']['title'] = 'Customer standard subdomain';
$lng['serversettings']['stdsubdomainhost']['description'] = 'What hostname should be used to create standard subdomains for customer. If empty, the system-hostname is used.';
// ADDED IN FROXLOR 0.9.4-1
$lng['ftp']['account_edit'] = 'Edit ftp account';
$lng['ftp']['editpassdescription'] = 'Set new password or leave blank for no change.';
?>

View File

@@ -1328,4 +1328,8 @@ $lng['cron']['changewarning'] = '&Auml;nderungen an diesen Werten kann einen neg
$lng['serversettings']['stdsubdomainhost']['title'] = 'Kunden Standard-Subdomain';
$lng['serversettings']['stdsubdomainhost']['description'] = 'Welcher Hostname soll f&uuml;r das Erstellen der Kunden-Standard-Subdomain verwendet werden? Falls leer wird der System-Hostname verwendet.';
// ADDED IN FROXLOR 0.9.4-1
$lng['ftp']['account_edit'] = 'FTP Konto bearbeiten';
$lng['ftp']['editpassdescription'] = 'Neues Passwort setzen oder leer f&uuml;r keine &Auml;nderung.';
?>

View File

@@ -1,6 +1,6 @@
<tr class="" onmouseover="this.className='RowOverSelected';" onmouseout="this.className='';">
<td class="field_name_border_left">{$row['username']}</td>
<td class="field_name">{$row['documentroot']}</td>
<td class="field_name"><a href="$filename?page=accounts&amp;action=edit&amp;id={$row['id']}&amp;s=$s">{$lng['menue']['main']['changepassword']}</a></td>
<td class="field_name"><a href="$filename?page=accounts&amp;action=edit&amp;id={$row['id']}&amp;s=$s">{$lng['panel']['edit']}</a></td>
<td class="field_name"><a href="$filename?page=accounts&amp;action=delete&amp;id={$row['id']}&amp;s=$s">{$lng['panel']['delete']}</a></td>
</tr>

View File

@@ -6,18 +6,32 @@ $header
<input type="hidden" name="id" value="$id" />
<table cellpadding="5" cellspacing="4" border="0" align="center" class="maintable_60">
<tr>
<td class="maintitle" colspan="2"><b><img src="images/title.gif" alt="" />&nbsp;{$lng['menue']['main']['changepassword']}</b></td>
<td class="maintitle" colspan="2"><b><img src="images/title.gif" alt="" />&nbsp;{$lng['ftp']['account_edit']}</b></td>
</tr>
<tr>
<td class="main_field_name">{$lng['login']['username']}:</td>
<td class="main_field_display" nowrap="nowrap">{$result['username']}</td>
</tr>
<if $settings['customer']['ftpatdomain'] == '1'>
<tr>
<td class="main_field_name">{$lng['login']['password']}:</td>
<td class="main_field_name">{$lng['login']['username']}:</td>
<td class="main_field_display" nowrap="nowrap"><input type="text" class="text" name="ftp_username" size="30" /></td>
</tr>
<tr>
<td class="main_field_name">{$lng['domains']['domainname']}:</td>
<td class="main_field_display" nowrap="nowrap"><select class="dropdown_noborder" name="ftp_domain">$domains</select></td>
</tr>
</if>
<tr>
<td class="main_field_name">{$lng['panel']['path']}:<if $settings['panel']['pathedit'] != 'Dropdown'><br /><font size="1">{$lng['panel']['pathDescription']}</font></if></td>
<td class="main_field_display" nowrap="nowrap">{$pathSelect}</td>
</tr>
<tr>
<td class="main_field_name">{$lng['login']['password']}:<br /><font size="1">{$lng['ftp']['editpassdescription']}</font></td>
<td class="main_field_display" nowrap="nowrap"><input type="password" name="ftp_password" maxlength="50" /></td>
</tr>
<tr>
<td class="main_field_confirm" colspan="2"><input type="hidden" name="send" value="send" /><input type="submit" class="bottom" value="{$lng['menue']['main']['changepassword']}" /></td>
<td class="main_field_confirm" colspan="2"><input type="hidden" name="send" value="send" /><input type="submit" class="bottom" value="{$lng['panel']['save']}" /></td>
</tr>
</table>
</form>