tbrehm
2007-07-03 a3576476db51350970a77bf8127ed89b1d626851
Several website related fixes.
10 files modified
90 ■■■■■ changed files
install/lib/installer_base.lib.php 2 ●●●●● patch | view | raw | blame | history
interface/web/admin/lib/lang/en_server_list.lng 1 ●●●● patch | view | raw | blame | history
interface/web/admin/lib/lang/en_users_list.lng 1 ●●●● patch | view | raw | blame | history
interface/web/admin/lib/module.conf.php 8 ●●●● patch | view | raw | blame | history
interface/web/sites/lib/lang/en_ftp_user_list.lng 1 ●●●● patch | view | raw | blame | history
interface/web/sites/lib/lang/en_web_aliasdomain_list.lng 1 ●●●● patch | view | raw | blame | history
interface/web/sites/lib/lang/en_web_subdomain_list.lng 1 ●●●● patch | view | raw | blame | history
interface/web/sites/web_domain_list.php 2 ●●● patch | view | raw | blame | history
server/conf/vhost.conf.master 22 ●●●●● patch | view | raw | blame | history
server/plugins-enabled/apache2_plugin.inc.php 51 ●●●●● patch | view | raw | blame | history
install/lib/installer_base.lib.php
@@ -544,7 +544,9 @@
        // 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
        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');
        }
        
    }
    
interface/web/admin/lib/lang/en_server_list.lng
@@ -13,4 +13,5 @@
$wb["page_back_txt"] = 'Back';
$wb["delete_txt"] = 'Delete';
$wb["filter_txt"] = 'Filter';
$wb["add_new_record_txt"] = 'Add new Server';
?>
interface/web/admin/lib/lang/en_users_list.lng
@@ -11,4 +11,5 @@
$wb["page_back_txt"] = 'Back';
$wb["delete_txt"] = 'Delete';
$wb["filter_txt"] = 'Filter';
$wb["add_new_record_txt"] = 'Add new User';
?>
interface/web/admin/lib/module.conf.php
@@ -40,19 +40,19 @@
// 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');                  
interface/web/sites/lib/lang/en_ftp_user_list.lng
@@ -10,4 +10,5 @@
$wb["page_back_txt"] = 'Back';
$wb["delete_txt"] = 'Delete';
$wb["filter_txt"] = 'Filter';
$wb["add_new_record_txt"] = 'Add new FTP-User';
?>
interface/web/sites/lib/lang/en_web_aliasdomain_list.lng
@@ -10,4 +10,5 @@
$wb["page_back_txt"] = 'Back';
$wb["delete_txt"] = 'Delete';
$wb["filter_txt"] = 'Filter';
$wb["add_new_record_txt"] = 'Add new aliasdomain';
?>
interface/web/sites/lib/lang/en_web_subdomain_list.lng
@@ -10,4 +10,5 @@
$wb["page_back_txt"] = 'Back';
$wb["delete_txt"] = 'Delete';
$wb["filter_txt"] = 'Filter';
$wb["add_new_record_txt"] = 'Add new subdomain';
?>
interface/web/sites/web_domain_list.php
@@ -50,7 +50,7 @@
$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();
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'>
    RewriteEngine on
    
<tmpl_if name='cgi'>
    # 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
    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
    AddType application/x-httpd-php .php .php3 .php4 .php5
</tmpl_if>
<tmpl_if name='php' op='==' value='suphp'>
    # 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
    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>
server/plugins-enabled/apache2_plugin.inc.php
@@ -64,12 +64,26 @@
    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');
        
        if($data["new"]["document_root"] == '') {
            $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;
        }
        
@@ -99,6 +113,20 @@
            $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 @@
        $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 = '';
        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());