Skip to content

Commit eed36bd

Browse files
committed
Added password protection of website statistics.
1 parent 0239acd commit eed36bd

File tree

6 files changed

+71
-1
lines changed

6 files changed

+71
-1
lines changed

install/sql/ispconfig3.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -982,6 +982,7 @@ CREATE TABLE `web_domain` (
982982
`ssl_cert` mediumtext NULL,
983983
`ssl_bundle` mediumtext NULL,
984984
`ssl_action` varchar(16) NULL,
985+
`stats_password` varchar(255) default NULL,
985986
`apache_directives` text,
986987
`active` enum('n','y') NOT NULL default 'y',
987988
PRIMARY KEY (`domain_id`)

interface/web/sites/form/web_domain.tform.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,31 @@
322322
)
323323
);
324324

325+
//* Statistics
326+
$form["tabs"]['stats'] = array (
327+
'title' => "Stats",
328+
'width' => 100,
329+
'template' => "templates/web_domain_stats.htm",
330+
'readonly' => false,
331+
'fields' => array (
332+
##################################
333+
# Begin Datatable fields
334+
##################################
335+
'stats_password' => array (
336+
'datatype' => 'VARCHAR',
337+
'formtype' => 'PASSWORD',
338+
'encryption' => 'CRYPT',
339+
'default' => '',
340+
'value' => '',
341+
'width' => '30',
342+
'maxlength' => '255'
343+
),
344+
##################################
345+
# ENDE Datatable fields
346+
##################################
347+
)
348+
);
349+
325350
if($_SESSION["s"]["user"]["typ"] == 'admin') {
326351

327352
$form["tabs"]['advanced'] = array (

interface/web/sites/lib/lang/en.lng

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
$wb['Database'] = 'Database';
33
$wb['Options'] = 'Options';
44
$wb['Shell User'] = 'Shell User';
5-
$wb['Domain'] = 'Domain';
5+
$wb['Domain'] = 'Website';
66
$wb['Redirect'] = 'Redirect';
77
$wb['SSL'] = 'SSL';
88
$wb['Subdomain'] = 'Subdomain';
@@ -13,4 +13,5 @@ $wb['FTP'] = 'FTP';
1313
$wb['Shell-User'] = 'Shell-User';
1414
$wb['Shell'] = 'Shell';
1515
$wb['Websites'] = 'Websites';
16+
$wb["Stats"] = 'Statistics';
1617
?>

interface/web/sites/lib/lang/en_web_domain.lng

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,6 @@ $wb['error_ssl_organisation_empty'] = 'SSL Organisation is empty.';
4545
$wb['error_ssl_organisation_unit_empty'] = 'SSL Organisation Unit is empty.';
4646
$wb['error_ssl_country_empty'] = 'SSL Country is empty.';
4747
$wb["client_group_id_txt"] = 'Client';
48+
$wb["stats_password_txt"] = 'Webstatistics password';
49+
4850
?>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<h2><tmpl_var name="list_head_txt"></h2>
2+
<p><tmpl_var name="list_desc_txt"></p>
3+
4+
<div class="panel panel_web_domain">
5+
6+
<div class="pnl_formsarea">
7+
<fieldset class="inlineLabels">
8+
<div class="ctrlHolder">
9+
<label for="redirect_path">{tmpl_var name='stats_password_txt'}</label>
10+
<input name="stats_password" id="stats_password" value="{tmpl_var name='stats_password'}" size="30" maxlength="255" type="text" class="textInput" />
11+
</div>
12+
</fieldset>
13+
14+
<input type="hidden" name="id" value="{tmpl_var name='id'}">
15+
16+
<div class="buttonHolder buttons">
17+
<button class="positive iconstxt icoPositive" type="button" value="{tmpl_var name='btn_save_txt'}" onClick="submitForm('pageForm','sites/web_domain_edit.php');"><span>{tmpl_var name='btn_save_txt'}</span></button>
18+
<button class="negative iconstxt icoNegative" type="button" value="{tmpl_var name='btn_cancel_txt'}" onClick="loadContent('sites/web_domain_list.php');"><span>{tmpl_var name='btn_cancel_txt'}</span></button>
19+
</div>
20+
</div>
21+
22+
</div>

server/plugins-available/apache2_plugin.inc.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -670,6 +670,25 @@ function update($event_name,$data) {
670670
$app->log("Removing File $vhost_file",LOGLEVEL_DEBUG);
671671
}
672672

673+
//* Create .htaccess and .htpasswd file for website statistics
674+
if(!is_file($data["new"]["document_root"].'/web/stats/.htaccess') {
675+
$ht_file = "AuthType Basic\nAuthName \"Members Only\"\nAuthUserFile ".$data["new"]["document_root"]."/.htpasswd_stats\n<limit GET PUT POST>\nrequire valid-user\n</limit>";
676+
file_put_contents($data["new"]["document_root"].'/web/stats/.htaccess',$ht_file);
677+
chmod($data["new"]["document_root"].'/web/stats/.htaccess',0664);
678+
unset($ht_file);
679+
}
680+
681+
if(!is_file($data["new"]["document_root"].'/.htpasswd_stats') || $data["new"]["stats_password"] != $data["old"]["stats_password"]) {
682+
if(trim($data["new"]["stats_password"]) != '') {
683+
$htp_file = 'admin:'.trim($data["new"]["stats_password"]);
684+
file_put_contents($data["new"]["document_root"].'/.htpasswd_stats',$htp_file);
685+
chmod($data["new"]["document_root"].'/.htpasswd_stats',0664);
686+
unset($htp_file);
687+
}
688+
}
689+
690+
691+
673692
// request a httpd reload when all records have been processed
674693
$app->services->restartServiceDelayed('httpd','reload');
675694

0 commit comments

Comments
 (0)