Commit a3576476 authored by tbrehm's avatar tbrehm
Browse files

Several website related fixes.

parent cb1d8ba6
......@@ -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');
}
}
......
......@@ -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
<?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
......@@ -40,19 +40,19 @@ $module["nav"][] = array( 'title' => 'Groups',
// aufrumen
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');
......
......@@ -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
......@@ -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
......@@ -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
......@@ -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();
......
# 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
......@@ -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());
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment