Skip to content

Commit a357647

Browse files
committed
Several website related fixes.
1 parent cb1d8ba commit a357647

File tree

10 files changed

+104
-30
lines changed

10 files changed

+104
-30
lines changed

install/lib/installer_base.lib.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,9 @@ function install_ispconfig() {
544544
// Copy the ISPConfig vhost for the controlpanel
545545
copy('tpl/apache_ispconfig.vhost.master',$conf["dist_apache_vhost_conf_dir"].'/ispconfig.vhost');
546546
// and create the symlink
547-
exec('ln -s '.$conf["dist_apache_vhost_conf_dir"].'/ispconfig.vhost '.$conf["dist_apache_vhost_conf_enabled_dir"].'/ispconfig.vhost');
547+
if(!is_link($conf["dist_apache_vhost_conf_enabled_dir"].'/ispconfig.vhost')) {
548+
exec('ln -s '.$conf["dist_apache_vhost_conf_dir"].'/ispconfig.vhost '.$conf["dist_apache_vhost_conf_enabled_dir"].'/ispconfig.vhost');
549+
}
548550

549551
}
550552

interface/web/admin/lib/lang/en_server_list.lng

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@ $wb["page_next_txt"] = 'Next';
1313
$wb["page_back_txt"] = 'Back';
1414
$wb["delete_txt"] = 'Delete';
1515
$wb["filter_txt"] = 'Filter';
16+
$wb["add_new_record_txt"] = 'Add new Server';
1617
?>
Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1-
<?php
2-
$wb["list_head_txt"] = 'Users';
3-
$wb["username_txt"] = 'Username';
4-
$wb["name_txt"] = 'Name';
5-
$wb["vorname_txt"] = 'Forename';
6-
$wb["ort_txt"] = 'city';
7-
8-
$wb["page_txt"] = 'Page';
9-
$wb["page_of_txt"] = 'of';
10-
$wb["page_next_txt"] = 'Next';
11-
$wb["page_back_txt"] = 'Back';
12-
$wb["delete_txt"] = 'Delete';
13-
$wb["filter_txt"] = 'Filter';
1+
<?php
2+
$wb["list_head_txt"] = 'Users';
3+
$wb["username_txt"] = 'Username';
4+
$wb["name_txt"] = 'Name';
5+
$wb["vorname_txt"] = 'Forename';
6+
$wb["ort_txt"] = 'city';
7+
8+
$wb["page_txt"] = 'Page';
9+
$wb["page_of_txt"] = 'of';
10+
$wb["page_next_txt"] = 'Next';
11+
$wb["page_back_txt"] = 'Back';
12+
$wb["delete_txt"] = 'Delete';
13+
$wb["filter_txt"] = 'Filter';
14+
$wb["add_new_record_txt"] = 'Add new User';
1415
?>

interface/web/admin/lib/module.conf.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,19 +40,19 @@
4040

4141
// aufräumen
4242
unset($items);
43-
43+
/*
4444
$items[] = array( 'title' => "Add server",
4545
'target' => 'content',
4646
'link' => 'admin/server_edit.php');
47-
47+
*/
4848
$items[] = array( 'title' => "Edit server",
4949
'target' => 'content',
5050
'link' => 'admin/server_list.php');
51-
51+
/*
5252
$items[] = array( 'title' => "Add Server IP",
5353
'target' => 'content',
5454
'link' => 'admin/server_ip_edit.php');
55-
55+
*/
5656
$items[] = array( 'title' => "Edit Server IP",
5757
'target' => 'content',
5858
'link' => 'admin/server_ip_list.php');

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ $wb["page_next_txt"] = 'Next';
1010
$wb["page_back_txt"] = 'Back';
1111
$wb["delete_txt"] = 'Delete';
1212
$wb["filter_txt"] = 'Filter';
13+
$wb["add_new_record_txt"] = 'Add new FTP-User';
1314
?>

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ $wb["page_next_txt"] = 'Next';
1010
$wb["page_back_txt"] = 'Back';
1111
$wb["delete_txt"] = 'Delete';
1212
$wb["filter_txt"] = 'Filter';
13+
$wb["add_new_record_txt"] = 'Add new aliasdomain';
1314
?>

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ $wb["page_next_txt"] = 'Next';
1010
$wb["page_back_txt"] = 'Back';
1111
$wb["delete_txt"] = 'Delete';
1212
$wb["filter_txt"] = 'Filter';
13+
$wb["add_new_record_txt"] = 'Add new subdomain';
1314
?>

interface/web/sites/web_domain_list.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
$app->uses('listform_actions');
5151

5252
// Limit the results to alias domains
53-
// $app->listform_actions->SQLExtWhere = "type = 'local'";
53+
$app->listform_actions->SQLExtWhere = "type = 'vhost'";
5454

5555
$app->listform_actions->onLoad();
5656

server/conf/vhost.conf.master

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,46 @@
11
# NameVirtualHost *:80
22

33
<VirtualHost <tmpl_var name='ip_address'>:80>
4-
DocumentRoot <tmpl_var name='document_root'>
4+
DocumentRoot <tmpl_var name='web_document_root'>
55
ServerName <tmpl_var name='domain'>
6-
ServerAlias <tmpl_var name='alias'>
6+
ServerAlias <tmpl_var name='alias'>
7+
RewriteEngine on
78

89
<tmpl_if name='cgi'>
9-
# cgi enabled
10+
# cgi enabled
11+
ScriptAlias /cgi-bin/ <tmpl_var name='document_root'>/cgi-bin/
12+
AddHandler cgi-script .cgi
13+
AddHandler cgi-script .pl
1014
</tmpl_if>
1115
<tmpl_if name='ssi'>
12-
# ssi enabled
16+
# ssi enabled
17+
AddType text/html .shtml
18+
AddOutputFilter INCLUDES .shtml
1319
</tmpl_if>
1420
<tmpl_if name='suexec'>
1521
# suexec enabled
22+
SuexecUserGroup <tmpl_var name='system_user'> <tmpl_var name='system_group'>
1623
</tmpl_if>
1724
<tmpl_if name='php' op='==' value='mod'>
18-
# mod_php enabled
25+
# mod_php enabled
26+
AddType application/x-httpd-php .php .php3 .php4 .php5
1927
</tmpl_if>
2028
<tmpl_if name='php' op='==' value='suphp'>
21-
# suphp enabled
29+
# suphp enabled
30+
suPHP_Engine on
31+
suPHP_UserGroup <tmpl_var name='system_user'> <tmpl_var name='system_group'>
32+
AddHandler x-httpd-php .php .php3 .php4 .php5
33+
suPHP_AddHandler x-httpd-php
2234
</tmpl_if>
2335
<tmpl_if name='php' op='==' value='cgi'>
24-
# php as cgi enabled
36+
# php as cgi enabled
37+
AddType application/x-httpd-php .php .php3 .php4 .php5
2538
</tmpl_if>
39+
40+
41+
<tmpl_loop name="redirects">
42+
RewriteCond %{HTTP_HOST} ^<tmpl_var name='rewrite_domain'> [NC]
43+
RewriteRule ^/(.*)$ <tmpl_var name='rewrite_target'>$1 [<tmpl_var name='rewrite_type'>]
44+
</tmpl_loop>
45+
2646
</VirtualHost>

server/plugins-enabled/apache2_plugin.inc.php

Lines changed: 51 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,16 @@ function insert($event_name,$data) {
6464
function update($event_name,$data) {
6565
global $app, $conf;
6666

67+
68+
if($data["new"]["type"] != "vhost" && $data["new"]["parent_domain_id"] > 0) {
69+
// This is not a vhost, so we need to update the parent record instead.
70+
$parent_domain_id = intval($data["new"]["parent_domain_id"]);
71+
$tmp = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".$parent_domain_id);
72+
$data["new"] = $tmp;
73+
$data["old"] = $tmp;
74+
}
75+
76+
6777
// load the server configuration options
6878
$app->uses("getconf");
6979
$web_config = $app->getconf->get_server_config($conf["server_id"], 'web');
@@ -72,6 +82,10 @@ function update($event_name,$data) {
7282
$app->log("document_root not set",LOGLEVEL_WARN);
7383
return 0;
7484
}
85+
if($data["new"]["system_user"] == 'root' or $data["new"]["system_group"] == 'root') {
86+
$app->log("Websites can not be owned by the root user or group.",LOGLEVEL_WARN);
87+
return 0;
88+
}
7589

7690
//print_r($data);
7791

@@ -99,6 +113,20 @@ function update($event_name,$data) {
99113
$app->log("Adding the user: $username",LOGLEVEL_DEBUG);
100114
}
101115

116+
// Set the quota for the user
117+
if($username != '' && $app->system->is_user($username)) {
118+
if($data["new"]["hd_quota"] > 0){
119+
$blocks_soft = $data["new"]["hd_quota"] * 1024;
120+
$blocks_hard = $blocks_soft + 1024;
121+
} else {
122+
$blocks_soft = $blocks_hard = 0;
123+
}
124+
exec("setquota -u $username $blocks_soft $blocks_hard 0 0 -a &> /dev/null");
125+
exec("setquota -T -u $username 604800 604800 -a &> /dev/null");
126+
}
127+
128+
129+
102130
// Chown and chmod the directories
103131
exec("chown -R $username:$groupname ".escapeshellcmd($data["new"]["document_root"]));
104132

@@ -109,16 +137,35 @@ function update($event_name,$data) {
109137
$tpl->newTemplate("vhost.conf.master");
110138

111139
$vhost_data = $data["new"];
112-
$vhost_data["document_root"] = $data["new"]["document_root"]."/web";
140+
$vhost_data["web_document_root"] = $data["new"]["document_root"]."/web";
141+
//$vhost_data["document_root"] = $data["new"]["document_root"]."/web";
113142
$tpl->setVar($vhost_data);
114143

115-
// get alias domains
144+
// Rewrite rules
145+
$rewrite_rules = array();
146+
if($data["new"]["redirect_type"] != '') {
147+
$rewrite_rules[] = array( 'rewrite_domain' => $data["new"]["domain"],
148+
'rewrite_type' => $data["new"]["redirect_type"],
149+
'rewrite_target' => $data["new"]["redirect_path"]);
150+
}
151+
152+
// get alias domains (co-domains and subdomains)
116153
$aliases = $app->db->queryAllRecords("SELECT * FROM web_domain WHERE parent_domain_id = ".$data["new"]["domain_id"]);
117154
$server_alias = '';
118-
foreach($aliases as $alias) {
119-
$server_alias .= $alias["domain"].' ';
155+
if(is_array($aliases)) {
156+
foreach($aliases as $alias) {
157+
$server_alias .= $alias["domain"].' ';
158+
$app->log("Add server alias: $alias[domain]",LOGLEVEL_DEBUG);
159+
// Rewriting
160+
if($alias["redirect_type"] != '') {
161+
$rewrite_rules[] = array( 'rewrite_domain' => $alias["domain"],
162+
'rewrite_type' => $alias["redirect_type"],
163+
'rewrite_target' => $alias["redirect_path"]);
164+
}
165+
}
120166
}
121167
$tpl->setVar('alias',trim($server_alias));
168+
$tpl->setLoop('redirects',$rewrite_rules);
122169

123170
$vhost_file = escapeshellcmd($web_config["vhost_conf_dir"].'/'.$data["new"]["domain"].'.vhost');
124171
file_put_contents($vhost_file,$tpl->grab());

0 commit comments

Comments
 (0)