diff --git a/customer_ftp.php b/customer_ftp.php index c98f8085..0b91151a 100644 --- a/customer_ftp.php +++ b/customer_ftp.php @@ -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,22 +215,74 @@ 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($password == '') + if($_setnewpass) { - standard_error(array('stringisempty', 'mypassword')); - exit; + if($password == '') + { + standard_error(array('stringisempty', 'mypassword')); + exit; + } + 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 . "'"); + } } - else + + if($path != '') { - $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)); + $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") . "\";"); } } diff --git a/lib/functions/filedir/function.makePathfield.php b/lib/functions/filedir/function.makePathfield.php index 3cca7572..c183089b 100644 --- a/lib/functions/filedir/function.makePathfield.php +++ b/lib/functions/filedir/function.makePathfield.php @@ -38,7 +38,7 @@ function makePathfield($path, $uid, $gid, $fieldType, $value = '') if($fieldType == 'Manual') { - $field = ''; + $field = ''; } elseif($fieldType == 'Dropdown') { @@ -65,7 +65,7 @@ function makePathfield($path, $uid, $gid, $fieldType, $value = '') else { $field = $lng['panel']['toomanydirs']; - $field.= ''; + $field.= ''; } } else diff --git a/lng/english.lng.php b/lng/english.lng.php index 1fc2518d..425e18cd 100644 --- a/lng/english.lng.php +++ b/lng/english.lng.php @@ -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.'; + ?> diff --git a/lng/german.lng.php b/lng/german.lng.php index 32efc548..d8e96f07 100644 --- a/lng/german.lng.php +++ b/lng/german.lng.php @@ -1328,4 +1328,8 @@ $lng['cron']['changewarning'] = 'Änderungen an diesen Werten kann einen neg $lng['serversettings']['stdsubdomainhost']['title'] = 'Kunden Standard-Subdomain'; $lng['serversettings']['stdsubdomainhost']['description'] = 'Welcher Hostname soll fü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ür keine Änderung.'; + ?> diff --git a/templates/customer/ftp/accounts_account.tpl b/templates/customer/ftp/accounts_account.tpl index 8f8f901d..3c479abf 100644 --- a/templates/customer/ftp/accounts_account.tpl +++ b/templates/customer/ftp/accounts_account.tpl @@ -1,6 +1,6 @@ {$row['username']} {$row['documentroot']} - {$lng['menue']['main']['changepassword']} + {$lng['panel']['edit']} {$lng['panel']['delete']} diff --git a/templates/customer/ftp/accounts_edit.tpl b/templates/customer/ftp/accounts_edit.tpl index 4f208462..c4baec55 100644 --- a/templates/customer/ftp/accounts_edit.tpl +++ b/templates/customer/ftp/accounts_edit.tpl @@ -6,18 +6,32 @@ $header - + + - + + + + + + + + + + + + + + - +
 {$lng['menue']['main']['changepassword']} {$lng['ftp']['account_edit']}
{$lng['login']['username']}: {$result['username']}
{$lng['login']['password']}:{$lng['login']['username']}:
{$lng['domains']['domainname']}:
{$lng['panel']['path']}:
{$lng['panel']['pathDescription']}
{$pathSelect}
{$lng['login']['password']}:
{$lng['ftp']['editpassdescription']}