diff --git a/install/lib/installer_base.lib.php b/install/lib/installer_base.lib.php index 8dfd88fe8ba6d1aba4626f64f788b1c28c9a0c87..ed9153a34be41ff8bcd6ca1805516127088a96cc 100644 --- a/install/lib/installer_base.lib.php +++ b/install/lib/installer_base.lib.php @@ -544,7 +544,9 @@ maildrop unix - n n - - pipe // Copy the ISPConfig vhost for the controlpanel copy('tpl/apache_ispconfig.vhost.master',$conf["dist_apache_vhost_conf_dir"].'/ispconfig.vhost'); // and create the symlink - exec('ln -s '.$conf["dist_apache_vhost_conf_dir"].'/ispconfig.vhost '.$conf["dist_apache_vhost_conf_enabled_dir"].'/ispconfig.vhost'); + if(!is_link($conf["dist_apache_vhost_conf_enabled_dir"].'/ispconfig.vhost')) { + exec('ln -s '.$conf["dist_apache_vhost_conf_dir"].'/ispconfig.vhost '.$conf["dist_apache_vhost_conf_enabled_dir"].'/ispconfig.vhost'); + } } diff --git a/interface/web/admin/lib/lang/en_server_list.lng b/interface/web/admin/lib/lang/en_server_list.lng index 0160993d41397edd7823441d82a5ca441349bda6..799a52e4c3b19a13a5c0c787512c990b2841cf7a 100644 --- a/interface/web/admin/lib/lang/en_server_list.lng +++ b/interface/web/admin/lib/lang/en_server_list.lng @@ -13,4 +13,5 @@ $wb["page_next_txt"] = 'Next'; $wb["page_back_txt"] = 'Back'; $wb["delete_txt"] = 'Delete'; $wb["filter_txt"] = 'Filter'; +$wb["add_new_record_txt"] = 'Add new Server'; ?> \ No newline at end of file diff --git a/interface/web/admin/lib/lang/en_users_list.lng b/interface/web/admin/lib/lang/en_users_list.lng index e0249585895a2e40ea44be81d67ea2837ebbd02d..d1397a07888591052c2944b65b46113fa3ad4274 100644 --- a/interface/web/admin/lib/lang/en_users_list.lng +++ b/interface/web/admin/lib/lang/en_users_list.lng @@ -1,14 +1,15 @@ -<?php -$wb["list_head_txt"] = 'Users'; -$wb["username_txt"] = 'Username'; -$wb["name_txt"] = 'Name'; -$wb["vorname_txt"] = 'Forename'; -$wb["ort_txt"] = 'city'; - -$wb["page_txt"] = 'Page'; -$wb["page_of_txt"] = 'of'; -$wb["page_next_txt"] = 'Next'; -$wb["page_back_txt"] = 'Back'; -$wb["delete_txt"] = 'Delete'; -$wb["filter_txt"] = 'Filter'; +<?php +$wb["list_head_txt"] = 'Users'; +$wb["username_txt"] = 'Username'; +$wb["name_txt"] = 'Name'; +$wb["vorname_txt"] = 'Forename'; +$wb["ort_txt"] = 'city'; + +$wb["page_txt"] = 'Page'; +$wb["page_of_txt"] = 'of'; +$wb["page_next_txt"] = 'Next'; +$wb["page_back_txt"] = 'Back'; +$wb["delete_txt"] = 'Delete'; +$wb["filter_txt"] = 'Filter'; +$wb["add_new_record_txt"] = 'Add new User'; ?> \ No newline at end of file diff --git a/interface/web/admin/lib/module.conf.php b/interface/web/admin/lib/module.conf.php index 0471b785e4a351db5618b8e3ccf036e4b63caf4f..8e60c74739bcaf98dfca1aaa024577d44e8486cf 100644 --- a/interface/web/admin/lib/module.conf.php +++ b/interface/web/admin/lib/module.conf.php @@ -40,19 +40,19 @@ $module["nav"][] = array( 'title' => 'Groups', // aufräumen unset($items); - +/* $items[] = array( 'title' => "Add server", 'target' => 'content', 'link' => 'admin/server_edit.php'); - +*/ $items[] = array( 'title' => "Edit server", 'target' => 'content', 'link' => 'admin/server_list.php'); - +/* $items[] = array( 'title' => "Add Server IP", 'target' => 'content', 'link' => 'admin/server_ip_edit.php'); - +*/ $items[] = array( 'title' => "Edit Server IP", 'target' => 'content', 'link' => 'admin/server_ip_list.php'); diff --git a/interface/web/sites/lib/lang/en_ftp_user_list.lng b/interface/web/sites/lib/lang/en_ftp_user_list.lng index 582940c4b95175f02f8b6fca19e3dc74ff00f46f..e3403ef98ac3abca986dea3aeacc92324ca000c1 100644 --- a/interface/web/sites/lib/lang/en_ftp_user_list.lng +++ b/interface/web/sites/lib/lang/en_ftp_user_list.lng @@ -10,4 +10,5 @@ $wb["page_next_txt"] = 'Next'; $wb["page_back_txt"] = 'Back'; $wb["delete_txt"] = 'Delete'; $wb["filter_txt"] = 'Filter'; +$wb["add_new_record_txt"] = 'Add new FTP-User'; ?> \ No newline at end of file diff --git a/interface/web/sites/lib/lang/en_web_aliasdomain_list.lng b/interface/web/sites/lib/lang/en_web_aliasdomain_list.lng index 90fe1ea167c9a5b67a9575274490632300b694f9..957f2d5524ca82c3d90eef149bff7a0454ebdcc3 100644 --- a/interface/web/sites/lib/lang/en_web_aliasdomain_list.lng +++ b/interface/web/sites/lib/lang/en_web_aliasdomain_list.lng @@ -10,4 +10,5 @@ $wb["page_next_txt"] = 'Next'; $wb["page_back_txt"] = 'Back'; $wb["delete_txt"] = 'Delete'; $wb["filter_txt"] = 'Filter'; +$wb["add_new_record_txt"] = 'Add new aliasdomain'; ?> \ No newline at end of file diff --git a/interface/web/sites/lib/lang/en_web_subdomain_list.lng b/interface/web/sites/lib/lang/en_web_subdomain_list.lng index 720b428759ab0b54be3c43d63724be1b77c21aa2..5efcbbb0dc183776087bff48ca96677a4b791322 100644 --- a/interface/web/sites/lib/lang/en_web_subdomain_list.lng +++ b/interface/web/sites/lib/lang/en_web_subdomain_list.lng @@ -10,4 +10,5 @@ $wb["page_next_txt"] = 'Next'; $wb["page_back_txt"] = 'Back'; $wb["delete_txt"] = 'Delete'; $wb["filter_txt"] = 'Filter'; +$wb["add_new_record_txt"] = 'Add new subdomain'; ?> \ No newline at end of file diff --git a/interface/web/sites/web_domain_list.php b/interface/web/sites/web_domain_list.php index edc7e7febf6c0b109a5e61e38ee6066eb2cb4927..03a3cb2769e2395180b8001504dd09270b91494d 100644 --- a/interface/web/sites/web_domain_list.php +++ b/interface/web/sites/web_domain_list.php @@ -50,7 +50,7 @@ if(!stristr($_SESSION["s"]["user"]["modules"],'sites')) { $app->uses('listform_actions'); // Limit the results to alias domains -// $app->listform_actions->SQLExtWhere = "type = 'local'"; +$app->listform_actions->SQLExtWhere = "type = 'vhost'"; $app->listform_actions->onLoad(); diff --git a/server/conf/vhost.conf.master b/server/conf/vhost.conf.master index 79ea7d724a1cfcb650a60538cec536ae1ed4398a..4053d5ed484964171bdbb3a41de2a56cd8b87615 100644 --- a/server/conf/vhost.conf.master +++ b/server/conf/vhost.conf.master @@ -1,26 +1,46 @@ # NameVirtualHost *:80 <VirtualHost <tmpl_var name='ip_address'>:80> - DocumentRoot <tmpl_var name='document_root'> + DocumentRoot <tmpl_var name='web_document_root'> ServerName <tmpl_var name='domain'> - ServerAlias <tmpl_var name='alias'> + ServerAlias <tmpl_var name='alias'> + RewriteEngine on <tmpl_if name='cgi'> - # cgi enabled + # cgi enabled + ScriptAlias /cgi-bin/ <tmpl_var name='document_root'>/cgi-bin/ + AddHandler cgi-script .cgi + AddHandler cgi-script .pl </tmpl_if> <tmpl_if name='ssi'> - # ssi enabled + # ssi enabled + AddType text/html .shtml + AddOutputFilter INCLUDES .shtml </tmpl_if> <tmpl_if name='suexec'> # suexec enabled + SuexecUserGroup <tmpl_var name='system_user'> <tmpl_var name='system_group'> </tmpl_if> <tmpl_if name='php' op='==' value='mod'> - # mod_php enabled + # mod_php enabled + AddType application/x-httpd-php .php .php3 .php4 .php5 </tmpl_if> <tmpl_if name='php' op='==' value='suphp'> - # suphp enabled + # suphp enabled + suPHP_Engine on + suPHP_UserGroup <tmpl_var name='system_user'> <tmpl_var name='system_group'> + AddHandler x-httpd-php .php .php3 .php4 .php5 + suPHP_AddHandler x-httpd-php </tmpl_if> <tmpl_if name='php' op='==' value='cgi'> - # php as cgi enabled + # php as cgi enabled + AddType application/x-httpd-php .php .php3 .php4 .php5 </tmpl_if> + + +<tmpl_loop name="redirects"> + RewriteCond %{HTTP_HOST} ^<tmpl_var name='rewrite_domain'> [NC] + RewriteRule ^/(.*)$ <tmpl_var name='rewrite_target'>$1 [<tmpl_var name='rewrite_type'>] +</tmpl_loop> + </VirtualHost> \ No newline at end of file diff --git a/server/plugins-enabled/apache2_plugin.inc.php b/server/plugins-enabled/apache2_plugin.inc.php index 3d01fd621da124a72a49a754b35306fd9c94b643..c02bc3cd1be038e16bf326bc12ab582d7f237078 100644 --- a/server/plugins-enabled/apache2_plugin.inc.php +++ b/server/plugins-enabled/apache2_plugin.inc.php @@ -64,6 +64,16 @@ class apache2_plugin { function update($event_name,$data) { global $app, $conf; + + if($data["new"]["type"] != "vhost" && $data["new"]["parent_domain_id"] > 0) { + // This is not a vhost, so we need to update the parent record instead. + $parent_domain_id = intval($data["new"]["parent_domain_id"]); + $tmp = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".$parent_domain_id); + $data["new"] = $tmp; + $data["old"] = $tmp; + } + + // load the server configuration options $app->uses("getconf"); $web_config = $app->getconf->get_server_config($conf["server_id"], 'web'); @@ -72,6 +82,10 @@ class apache2_plugin { $app->log("document_root not set",LOGLEVEL_WARN); return 0; } + if($data["new"]["system_user"] == 'root' or $data["new"]["system_group"] == 'root') { + $app->log("Websites can not be owned by the root user or group.",LOGLEVEL_WARN); + return 0; + } //print_r($data); @@ -99,6 +113,20 @@ class apache2_plugin { $app->log("Adding the user: $username",LOGLEVEL_DEBUG); } + // Set the quota for the user + if($username != '' && $app->system->is_user($username)) { + if($data["new"]["hd_quota"] > 0){ + $blocks_soft = $data["new"]["hd_quota"] * 1024; + $blocks_hard = $blocks_soft + 1024; + } else { + $blocks_soft = $blocks_hard = 0; + } + exec("setquota -u $username $blocks_soft $blocks_hard 0 0 -a &> /dev/null"); + exec("setquota -T -u $username 604800 604800 -a &> /dev/null"); + } + + + // Chown and chmod the directories exec("chown -R $username:$groupname ".escapeshellcmd($data["new"]["document_root"])); @@ -109,16 +137,35 @@ class apache2_plugin { $tpl->newTemplate("vhost.conf.master"); $vhost_data = $data["new"]; - $vhost_data["document_root"] = $data["new"]["document_root"]."/web"; + $vhost_data["web_document_root"] = $data["new"]["document_root"]."/web"; + //$vhost_data["document_root"] = $data["new"]["document_root"]."/web"; $tpl->setVar($vhost_data); - // get alias domains + // Rewrite rules + $rewrite_rules = array(); + if($data["new"]["redirect_type"] != '') { + $rewrite_rules[] = array( 'rewrite_domain' => $data["new"]["domain"], + 'rewrite_type' => $data["new"]["redirect_type"], + 'rewrite_target' => $data["new"]["redirect_path"]); + } + + // get alias domains (co-domains and subdomains) $aliases = $app->db->queryAllRecords("SELECT * FROM web_domain WHERE parent_domain_id = ".$data["new"]["domain_id"]); $server_alias = ''; - foreach($aliases as $alias) { - $server_alias .= $alias["domain"].' '; + if(is_array($aliases)) { + foreach($aliases as $alias) { + $server_alias .= $alias["domain"].' '; + $app->log("Add server alias: $alias[domain]",LOGLEVEL_DEBUG); + // Rewriting + if($alias["redirect_type"] != '') { + $rewrite_rules[] = array( 'rewrite_domain' => $alias["domain"], + 'rewrite_type' => $alias["redirect_type"], + 'rewrite_target' => $alias["redirect_path"]); + } + } } $tpl->setVar('alias',trim($server_alias)); + $tpl->setLoop('redirects',$rewrite_rules); $vhost_file = escapeshellcmd($web_config["vhost_conf_dir"].'/'.$data["new"]["domain"].'.vhost'); file_put_contents($vhost_file,$tpl->grab());