diff --git a/customer_extras.php b/customer_extras.php index 3c35251a..a6b1d3f9 100644 --- a/customer_extras.php +++ b/customer_extras.php @@ -49,7 +49,7 @@ elseif($page == 'htpasswds') 'path' => $lng['panel']['path'] ); $paging = new paging($userinfo, $db, TABLE_PANEL_HTPASSWDS, $fields, $settings['panel']['paging'], $settings['panel']['natsorting']); - $result = $db->query("SELECT `id`, `username`, `path` FROM `" . TABLE_PANEL_HTPASSWDS . "` WHERE `customerid`='" . (int)$userinfo['customerid'] . "' " . $paging->getSqlWhere(true) . " " . $paging->getSqlOrderBy() . " " . $paging->getSqlLimit()); + $result = $db->query("SELECT * FROM `" . TABLE_PANEL_HTPASSWDS . "` WHERE `customerid`='" . (int)$userinfo['customerid'] . "' " . $paging->getSqlWhere(true) . " " . $paging->getSqlOrderBy() . " " . $paging->getSqlLimit()); $paging->setEntries($db->num_rows($result)); $sortcode = $paging->getHtmlSortCode($lng); $arrowcode = $paging->getHtmlArrowCode($filename . '?page=' . $page . '&s=' . $s); @@ -81,7 +81,7 @@ elseif($page == 'htpasswds') elseif($action == 'delete' && $id != 0) { - $result = $db->query_first("SELECT `id`, `customerid`, `username`, `path` FROM `" . TABLE_PANEL_HTPASSWDS . "` WHERE `customerid`='" . (int)$userinfo['customerid'] . "' AND `id`='" . (int)$id . "'"); + $result = $db->query_first("SELECT * FROM `" . TABLE_PANEL_HTPASSWDS . "` WHERE `customerid`='" . (int)$userinfo['customerid'] . "' AND `id`='" . (int)$id . "'"); if(isset($result['username']) && $result['username'] != '') @@ -114,6 +114,7 @@ elseif($page == 'htpasswds') $userpath = $path; $path = makeCorrectDir($userinfo['documentroot'] . '/' . $path); $username = validate($_POST['username'], 'username', '/^[a-zA-Z0-9][a-zA-Z0-9\-_]+\$?$/'); + $authname = validate($_POST['directory_authname'], 'directory_authname', '/^[a-zA-Z0-9][a-zA-Z0-9\-_ ]+\$?$/'); validate($_POST['directory_password'], 'password'); $username_path_check = $db->query_first("SELECT `id`, `username`, `path` FROM `" . TABLE_PANEL_HTPASSWDS . "` WHERE `username`='" . $db->escape($username) . "' AND `path`='" . $db->escape($path) . "' AND `customerid`='" . (int)$userinfo['customerid'] . "'"); @@ -151,7 +152,7 @@ elseif($page == 'htpasswds') } else { - $db->query("INSERT INTO `" . TABLE_PANEL_HTPASSWDS . "` (`customerid`, `username`, `password`, `path`) VALUES ('" . (int)$userinfo['customerid'] . "', '" . $db->escape($username) . "', '" . $db->escape($password) . "', '" . $db->escape($path) . "')"); + $db->query("INSERT INTO `" . TABLE_PANEL_HTPASSWDS . "` (`customerid`, `username`, `password`, `path`, `authname`) VALUES ('" . (int)$userinfo['customerid'] . "', '" . $db->escape($username) . "', '" . $db->escape($password) . "', '" . $db->escape($path) . "', '" . $db->escape($authname) . "')"); $log->logAction(USR_ACTION, LOG_INFO, "added htpasswd for '" . $username . " (" . $path . ")'"); inserttask('1'); redirectTo($filename, Array('page' => $page, 's' => $s)); @@ -166,7 +167,7 @@ elseif($page == 'htpasswds') elseif($action == 'edit' && $id != 0) { - $result = $db->query_first("SELECT `id`, `username`, `path` FROM `" . TABLE_PANEL_HTPASSWDS . "` WHERE `customerid`='" . (int)$userinfo['customerid'] . "' AND `id`='" . (int)$id . "'"); + $result = $db->query_first("SELECT * FROM `" . TABLE_PANEL_HTPASSWDS . "` WHERE `customerid`='" . (int)$userinfo['customerid'] . "' AND `id`='" . (int)$id . "'"); if(isset($result['username']) && $result['username'] != '') @@ -175,6 +176,7 @@ elseif($page == 'htpasswds') && $_POST['send'] == 'send') { validate($_POST['directory_password'], 'password'); + $authname = validate($_POST['directory_authname'], 'directory_authname', '/^[a-zA-Z0-9][a-zA-Z0-9\-_ ]+\$?$/'); if(CRYPT_STD_DES == 1) { @@ -186,13 +188,25 @@ elseif($page == 'htpasswds') $password = crypt($_POST['directory_password']); } - if($_POST['directory_password'] == '') + $pwd_sql = ''; + if($_POST['directory_password'] != '') { - standard_error(array('stringisempty', 'mypassword')); + $pwd_sql = "`password`='" . $db->escape($password) . "' "; } - else + + $auth_sql = ''; + if($authname != $result['authname']) { - $db->query("UPDATE `" . TABLE_PANEL_HTPASSWDS . "` SET `password`='" . $db->escape($password) . "' WHERE `customerid`='" . (int)$userinfo['customerid'] . "' AND `id`='" . (int)$id . "'"); + $auth_sql = "`authname`='" . $db->escape($authname) . "' "; + } + + if($pwd_sql != '' || $auth_sql != '') + { + if($pwd_sql !='' && $auth_sql != '') { + $pwd_sql.= ', '; + } + + $db->query("UPDATE `" . TABLE_PANEL_HTPASSWDS . "` SET ".$pwd_sql.$auth_sql." WHERE `customerid`='" . (int)$userinfo['customerid'] . "' AND `id`='" . (int)$id . "'"); $log->logAction(USR_ACTION, LOG_INFO, "edited htpasswd for '" . $result['username'] . " (" . $result['path'] . ")'"); inserttask('1'); redirectTo($filename, Array('page' => $page, 's' => $s)); diff --git a/install/froxlor.sql b/install/froxlor.sql index 76864f20..6f3ad834 100644 --- a/install/froxlor.sql +++ b/install/froxlor.sql @@ -380,6 +380,7 @@ CREATE TABLE `panel_htpasswds` ( `path` varchar(255) NOT NULL default '', `username` varchar(255) NOT NULL default '', `password` varchar(255) NOT NULL default '', + `authname` varchar(255) NOT NULL default 'Restricted Area', PRIMARY KEY (`id`), KEY `customerid` (`customerid`) ) TYPE=MyISAM ; @@ -455,7 +456,7 @@ INSERT INTO `panel_settings` (`settingid`, `settinggroup`, `varname`, `value`) V INSERT INTO `panel_settings` (`settingid`, `settinggroup`, `varname`, `value`) VALUES (18, 'system', 'vmail_homedir', '/var/customers/mail/'); INSERT INTO `panel_settings` (`settingid`, `settinggroup`, `varname`, `value`) VALUES (19, 'system', 'bindconf_directory', '/etc/bind/'); INSERT INTO `panel_settings` (`settingid`, `settinggroup`, `varname`, `value`) VALUES (20, 'system', 'bindreload_command', '/etc/init.d/bind9 reload'); -INSERT INTO `panel_settings` (`settingid`, `settinggroup`, `varname`, `value`) VALUES (22, 'panel', 'version', '0.9.12-svn5'); +INSERT INTO `panel_settings` (`settingid`, `settinggroup`, `varname`, `value`) VALUES (22, 'panel', 'version', '0.9.12-svn6'); INSERT INTO `panel_settings` (`settingid`, `settinggroup`, `varname`, `value`) VALUES (23, 'system', 'hostname', 'SERVERNAME'); INSERT INTO `panel_settings` (`settingid`, `settinggroup`, `varname`, `value`) VALUES (24, 'login', 'maxloginattempts', '3'); INSERT INTO `panel_settings` (`settingid`, `settinggroup`, `varname`, `value`) VALUES (25, 'login', 'deactivatetime', '900'); diff --git a/install/updates/froxlor/0.9/update_0.9.inc.php b/install/updates/froxlor/0.9/update_0.9.inc.php index 892a5ffb..b8be0f06 100644 --- a/install/updates/froxlor/0.9/update_0.9.inc.php +++ b/install/updates/froxlor/0.9/update_0.9.inc.php @@ -1008,3 +1008,14 @@ if(isFroxlorVersion('0.9.12-svn4')) updateToVersion('0.9.12-svn5'); } + +if(isFroxlorVersion('0.9.12-svn5')) +{ + showUpdateStep("Updating from 0.9.12-svn5 to 0.9.12-svn6", false); + + showUpdateStep("Adding new field to table 'panel_htpasswds'"); + $db->query("ALTER TABLE `".TABLE_PANEL_HTPASSWDS."` ADD `authname` varchar(255) NOT NULL default 'Restricted Area' AFTER `password`;"); + lastStepStatus(0); + + updateToVersion('0.9.12-svn6'); +} diff --git a/lib/tables.inc.php b/lib/tables.inc.php index 8944bede..5f19662d 100644 --- a/lib/tables.inc.php +++ b/lib/tables.inc.php @@ -72,7 +72,7 @@ define('PACKAGE_ENABLED', 2); // VERSION INFO -$version = '0.9.12-svn5'; +$version = '0.9.12-svn6'; $dbversion = '2'; $branding = ''; diff --git a/lng/english.lng.php b/lng/english.lng.php index 514105b9..9dd6abc9 100644 --- a/lng/english.lng.php +++ b/lng/english.lng.php @@ -1490,4 +1490,8 @@ $lng['admin']['templates']['USR_PATH'] = 'FTP homedir (relative to customer-docr // ADDED IN FROXLOR 0.9.12-svn4 $lng['serversettings']['awstats_awstatspath'] = 'Path to AWStats \'awstats.pl\''; +// ADDED IN FROXLOR 0.9.12-svn6 +$lng['extras']['htpasswdauthname'] = 'Authentication reason (AuthName)'; +$lng['extras']['directoryprotection_edit'] = 'edit directory protection'; + ?> diff --git a/lng/german.lng.php b/lng/german.lng.php index e9c47165..20bac866 100644 --- a/lng/german.lng.php +++ b/lng/german.lng.php @@ -1473,4 +1473,8 @@ $lng['admin']['templates']['USR_PATH'] = 'FTP Heimatverzeichnis (relativ zum Kun // ADDED IN FROXLOR 0.9.12-svn4 $lng['serversettings']['awstats_awstatspath'] = 'Pfad zu AWStats \'awstats.pl\''; +// ADDED IN FROXLOR 0.9.12-svn6 +$lng['extras']['htpasswdauthname'] = 'Authentifizierungs-Grund (AuthName)'; +$lng['extras']['directoryprotection_edit'] = 'Verzeichnisschutz bearbeiten'; + ?> diff --git a/scripts/jobs/cron_tasks.inc.http.10.apache.php b/scripts/jobs/cron_tasks.inc.http.10.apache.php index 9a51dff0..5877db86 100644 --- a/scripts/jobs/cron_tasks.inc.http.10.apache.php +++ b/scripts/jobs/cron_tasks.inc.http.10.apache.php @@ -965,7 +965,7 @@ class apache } $this->diroptions_data[$diroptions_filename].= ' AuthType Basic' . "\n"; - $this->diroptions_data[$diroptions_filename].= ' AuthName "Restricted Area"' . "\n"; + $this->diroptions_data[$diroptions_filename].= ' AuthName "'.$row_htpasswd['authname'].'"' . "\n"; $this->diroptions_data[$diroptions_filename].= ' AuthUserFile ' . $htpasswd_filename . "\n"; $this->diroptions_data[$diroptions_filename].= ' require valid-user' . "\n"; } diff --git a/scripts/jobs/cron_tasks.inc.http.20.lighttpd.php b/scripts/jobs/cron_tasks.inc.http.20.lighttpd.php index eb34ad7c..688cd110 100644 --- a/scripts/jobs/cron_tasks.inc.http.20.lighttpd.php +++ b/scripts/jobs/cron_tasks.inc.http.20.lighttpd.php @@ -219,7 +219,7 @@ class lighttpd $htaccess_text.= ' "' . $htaccess_path . '" =>' . "\n"; $htaccess_text.= ' (' . "\n"; $htaccess_text.= ' "method" => "basic",' . "\n"; - $htaccess_text.= ' "realm" => "Restricted Area",' . "\n"; + $htaccess_text.= ' "realm" => "'.$row_htpasswds['authname'].'",' . "\n"; $htaccess_text.= ' "require" => "valid-user"' . "\n"; $htaccess_text.= ' )' . "\n"; $htaccess_text.= ' )' . "\n"; @@ -606,7 +606,7 @@ class lighttpd $diroption_text.= '"' . $row_htpasswds['path'] . '" =>' . "\n"; $diroption_text.= '(' . "\n"; $diroption_text.= ' "method" => "basic",' . "\n"; - $diroption_text.= ' "realm" => "Restricted Area",' . "\n"; + $diroption_text.= ' "realm" => "'.$row_htpasswds['authname'].'",' . "\n"; $diroption_text.= ' "require" => "valid-user"' . "\n"; $diroption_text.= ')' . "\n"; diff --git a/templates/customer/extras/htpasswds_add.tpl b/templates/customer/extras/htpasswds_add.tpl index 79680143..37ad1ff2 100644 --- a/templates/customer/extras/htpasswds_add.tpl +++ b/templates/customer/extras/htpasswds_add.tpl @@ -22,6 +22,10 @@ $header {$lng['login']['password']}: + + {$lng['extras']['htpasswdauthname']}: + + diff --git a/templates/customer/extras/htpasswds_edit.tpl b/templates/customer/extras/htpasswds_edit.tpl index 799e7945..3dbd0aed 100644 --- a/templates/customer/extras/htpasswds_edit.tpl +++ b/templates/customer/extras/htpasswds_edit.tpl @@ -6,7 +6,7 @@ $header - + @@ -21,7 +21,11 @@ $header - + + + + +
 {$lng['menue']['main']['changepassword']} {$lng['extras']['directoryprotection_edit']}
{$lng['panel']['path']}:
{$lng['extras']['htpasswdauthname']}:
diff --git a/templates/customer/extras/htpasswds_htpasswd.tpl b/templates/customer/extras/htpasswds_htpasswd.tpl index 38f5ec89..57cecb7a 100644 --- a/templates/customer/extras/htpasswds_htpasswd.tpl +++ b/templates/customer/extras/htpasswds_htpasswd.tpl @@ -1,6 +1,6 @@ {$row['username']} {$row['path']} - {$lng['menue']['main']['changepassword']} + {$lng['panel']['edit']} {$lng['panel']['delete']}