marknl
2011-09-09 552178ef07915f15c03af82cc46c320ff067208f
FS#1491 - Option to use relative symlinks for websites
25 files modified
75 ■■■■■ changed files
interface/web/admin/form/server_config.tform.php 6 ●●●●● patch | view | raw | blame | history
interface/web/admin/lib/lang/ar_server_config.lng 1 ●●●● patch | view | raw | blame | history
interface/web/admin/lib/lang/bg_server_config.lng 1 ●●●● patch | view | raw | blame | history
interface/web/admin/lib/lang/br_server_config.lng 1 ●●●● patch | view | raw | blame | history
interface/web/admin/lib/lang/cz_server_config.lng 1 ●●●● patch | view | raw | blame | history
interface/web/admin/lib/lang/de_server_config.lng 1 ●●●● patch | view | raw | blame | history
interface/web/admin/lib/lang/el_server_config.lng 1 ●●●● patch | view | raw | blame | history
interface/web/admin/lib/lang/en_server_config.lng 1 ●●●● patch | view | raw | blame | history
interface/web/admin/lib/lang/es_server_config.lng 1 ●●●● patch | view | raw | blame | history
interface/web/admin/lib/lang/fi_server_config.lng 1 ●●●● patch | view | raw | blame | history
interface/web/admin/lib/lang/fr_server_config.lng 1 ●●●● patch | view | raw | blame | history
interface/web/admin/lib/lang/hu_server_config.lng 1 ●●●● patch | view | raw | blame | history
interface/web/admin/lib/lang/id_server_config.lng 1 ●●●● patch | view | raw | blame | history
interface/web/admin/lib/lang/it_server_config.lng 1 ●●●● patch | view | raw | blame | history
interface/web/admin/lib/lang/ja_server_config.lng 1 ●●●● patch | view | raw | blame | history
interface/web/admin/lib/lang/nl_server_config.lng 1 ●●●● patch | view | raw | blame | history
interface/web/admin/lib/lang/pl_server_config.lng 1 ●●●● patch | view | raw | blame | history
interface/web/admin/lib/lang/pt_server_config.lng 1 ●●●● patch | view | raw | blame | history
interface/web/admin/lib/lang/ro_server_config.lng 1 ●●●● patch | view | raw | blame | history
interface/web/admin/lib/lang/ru_server_config.lng 1 ●●●● patch | view | raw | blame | history
interface/web/admin/lib/lang/se_server_config.lng 1 ●●●● patch | view | raw | blame | history
interface/web/admin/lib/lang/sk_server_config.lng 1 ●●●● patch | view | raw | blame | history
interface/web/admin/lib/lang/tr_server_config.lng 1 ●●●● patch | view | raw | blame | history
interface/web/admin/templates/server_config_web_edit.htm 6 ●●●●● patch | view | raw | blame | history
server/plugins-available/apache2_plugin.inc.php 41 ●●●●● patch | view | raw | blame | history
interface/web/admin/form/server_config.tform.php
@@ -354,6 +354,12 @@
            'width' => '40',
            'maxlength' => '255'
        ),
        'website_symlinks_rel' => array (
            'datatype' => 'VARCHAR',
            'formtype' => 'CHECKBOX',
            'default' => 'n',
            'value' => array(0 => 'n',1 => 'y')
        ),
        'vhost_conf_dir' => array(
            'datatype' => 'VARCHAR',
            'formtype' => 'TEXT',
interface/web/admin/lib/lang/ar_server_config.lng
@@ -5,6 +5,7 @@
$wb['jailkit_chroot_cron_programs_txt'] = 'Jailkit cron chrooted applications';
$wb['website_path_txt'] = 'Website path';
$wb['website_symlinks_txt'] = 'Website symlinks';
$wb['website_symlinks_rel_txt'] = 'Make relative symlinks';
$wb['website_basedir_txt'] = 'Website basedir';
$wb['vhost_conf_dir_txt'] = 'Vhost config dir';
$wb['vhost_conf_enabled_dir_txt'] = 'Vhost config enabled dir';
interface/web/admin/lib/lang/bg_server_config.lng
@@ -4,6 +4,7 @@
$wb['jailkit_chroot_app_programs_txt'] = 'Jailkit chrooted applications';
$wb['website_path_txt'] = 'Website path';
$wb['website_symlinks_txt'] = 'Website symlinks';
$wb['website_symlinks_rel_txt'] = 'Make relative symlinks';
$wb['vhost_conf_dir_txt'] = 'Vhost config dir';
$wb['vhost_conf_enabled_dir_txt'] = 'Vhost config enabled dir';
$wb['getmail_config_dir_txt'] = 'Getmail config dir';
interface/web/admin/lib/lang/br_server_config.lng
@@ -4,6 +4,7 @@
$wb['jailkit_chroot_app_programs_txt'] = 'Aplicações Jailkit em ambiente chroot';
$wb['website_path_txt'] = 'Caminho do Website';
$wb['website_symlinks_txt'] = 'Website symlinks: link simbólico';
$wb['website_symlinks_rel_txt'] = 'Make relative symlinks';
$wb['website_basedir_txt'] = 'Website basedir: Diretório base ';
$wb['vhost_conf_dir_txt'] = 'Vhost config dir';
$wb['vhost_conf_enabled_dir_txt'] = 'Vhost diretório de configuração ativo';
interface/web/admin/lib/lang/cz_server_config.lng
@@ -5,6 +5,7 @@
$wb['jailkit_chroot_cron_programs_txt'] = 'Jailkit cron chrootované aplikace';
$wb['website_path_txt'] = 'Website cesta';
$wb['website_symlinks_txt'] = 'Website symlinky';
$wb['website_symlinks_rel_txt'] = 'Make relative symlinks';
$wb['website_basedir_txt'] = 'Website config adresář';
$wb['vhost_conf_dir_txt'] = 'Vhost config adresář';
$wb['vhost_conf_enabled_dir_txt'] = 'Vhost config enabled adresář';
interface/web/admin/lib/lang/de_server_config.lng
@@ -5,6 +5,7 @@
$wb['jailkit_chroot_cron_programs_txt'] = 'Jailkit cron chrooted Anwendungen';
$wb['website_path_txt'] = 'Website Pfad';
$wb['website_symlinks_txt'] = 'Website Symlinks';
$wb['website_symlinks_rel_txt'] = 'Make relative symlinks';
$wb['vhost_conf_dir_txt'] = 'Vhost config dir';
$wb['vhost_conf_enabled_dir_txt'] = 'Vhost config enabled dir';
$wb['getmail_config_dir_txt'] = 'Getmail config dir';
interface/web/admin/lib/lang/el_server_config.lng
@@ -5,6 +5,7 @@
$wb['jailkit_chroot_cron_programs_txt'] = 'Jailkit cron chrooted applications';
$wb['website_path_txt'] = 'Διαδρομή Website';
$wb['website_symlinks_txt'] = 'Website symlinks';
$wb['website_symlinks_rel_txt'] = 'Make relative symlinks';
$wb['website_basedir_txt'] = 'Βασικός φάκελος Website';
$wb['vhost_conf_dir_txt'] = 'Φάκελος ρυθμίσεων Vhost';
$wb['vhost_conf_enabled_dir_txt'] = 'Φάκελος ρυθμίσεων (ενεργών) Vhost';
interface/web/admin/lib/lang/en_server_config.lng
@@ -13,6 +13,7 @@
$wb["jailkit_chroot_cron_programs_txt"] = 'Jailkit cron chrooted applications';
$wb["website_path_txt"] = 'Website path';
$wb["website_symlinks_txt"] = 'Website symlinks';
$wb['website_symlinks_rel_txt'] = 'Make relative symlinks';
$wb["website_basedir_txt"] = 'Website basedir';
$wb["vhost_conf_dir_txt"] = 'Vhost config dir';
$wb["vhost_conf_enabled_dir_txt"] = 'Vhost config enabled dir';
interface/web/admin/lib/lang/es_server_config.lng
@@ -4,6 +4,7 @@
$wb['jailkit_chroot_app_programs_txt'] = 'Aplicaciones Jailkit chrooted';
$wb['website_path_txt'] = 'Ruta del sitio web';
$wb['website_symlinks_txt'] = 'Enlaces simbólicos del sitio web';
$wb['website_symlinks_rel_txt'] = 'Make relative symlinks';
$wb['vhost_conf_dir_txt'] = 'Directorio de configuración de vhost';
$wb['vhost_conf_enabled_dir_txt'] = 'Directorio de configuración de vhost activados';
$wb['getmail_config_dir_txt'] = 'Directorio de configuración de Getmail';
interface/web/admin/lib/lang/fi_server_config.lng
@@ -4,6 +4,7 @@
$wb['jailkit_chroot_app_programs_txt'] = 'Jailkit chrooted-ohjelmat';
$wb['website_path_txt'] = 'Verkkotunnuksen kotihakemisto';
$wb['website_symlinks_txt'] = 'Verkkotunnuksen symmetriset linkit';
$wb['website_symlinks_rel_txt'] = 'Make relative symlinks';
$wb['vhost_conf_dir_txt'] = 'Virtuaalipalvelimen asetuskansio';
$wb['vhost_conf_enabled_dir_txt'] = 'Virtuaalipalvelimen käyttöönottokansio';
$wb['getmail_config_dir_txt'] = 'Getmail-asetuskansio';
interface/web/admin/lib/lang/fr_server_config.lng
@@ -4,6 +4,7 @@
$wb['jailkit_chroot_app_programs_txt'] = 'Applications chrootées Jailkit';
$wb['website_path_txt'] = 'Chemin du site web';
$wb['website_symlinks_txt'] = 'Liens symboliques du site web';
$wb['website_symlinks_rel_txt'] = 'Make relative symlinks';
$wb['vhost_conf_dir_txt'] = 'Répertoire de configuration des VHosts';
$wb['vhost_conf_enabled_dir_txt'] = 'Répertoire de configuration des VHosts actifs';
$wb['getmail_config_dir_txt'] = 'Répertoire de configuration de Getmail';
interface/web/admin/lib/lang/hu_server_config.lng
@@ -4,6 +4,7 @@
$wb['jailkit_chroot_app_programs_txt'] = 'Jailkit chrooted applications';
$wb['website_path_txt'] = 'Website path';
$wb['website_symlinks_txt'] = 'Website symlinks';
$wb['website_symlinks_rel_txt'] = 'Make relative symlinks';
$wb['vhost_conf_dir_txt'] = 'Vhost config dir';
$wb['vhost_conf_enabled_dir_txt'] = 'Vhost config enabled dir';
$wb['getmail_config_dir_txt'] = 'Getmail config dir';
interface/web/admin/lib/lang/id_server_config.lng
@@ -5,6 +5,7 @@
$wb['jailkit_chroot_cron_programs_txt'] = 'Jailkit aplikasi cron yang ter-chroot';
$wb['website_path_txt'] = 'Path situs web';
$wb['website_symlinks_txt'] = 'Symlink Situs web';
$wb['website_symlinks_rel_txt'] = 'Make relative symlinks';
$wb['website_basedir_txt'] = 'Basedir Situs web';
$wb['vhost_conf_dir_txt'] = 'Direktori konfigurasi vhost';
$wb['vhost_conf_enabled_dir_txt'] = 'Direktori konfigurasi vhost yang aktif';
interface/web/admin/lib/lang/it_server_config.lng
@@ -4,6 +4,7 @@
$wb['jailkit_chroot_app_programs_txt'] = 'Jailkit chrooted applications';
$wb['website_path_txt'] = 'Website path';
$wb['website_symlinks_txt'] = 'Website symlinks';
$wb['website_symlinks_rel_txt'] = 'Make relative symlinks';
$wb['vhost_conf_dir_txt'] = 'Vhost config dir';
$wb['vhost_conf_enabled_dir_txt'] = 'Vhost config enabled dir';
$wb['getmail_config_dir_txt'] = 'Getmail config dir';
interface/web/admin/lib/lang/ja_server_config.lng
@@ -5,6 +5,7 @@
$wb['jailkit_chroot_cron_programs_txt'] = 'cron での利用可能アプリケーション';
$wb['website_path_txt'] = 'ウェブサイトのパス';
$wb['website_symlinks_txt'] = 'ウェブサイトのシンボリックリンク';
$wb['website_symlinks_rel_txt'] = 'Make relative symlinks';
$wb['website_basedir_txt'] = 'ウェブサイトのベースディレクトリ';
$wb['vhost_conf_dir_txt'] = 'バーチャルホスト設定ディレクトリ';
$wb['vhost_conf_enabled_dir_txt'] = 'バーチャルホスト設定ディレクトリ(有効)';
interface/web/admin/lib/lang/nl_server_config.lng
@@ -5,6 +5,7 @@
$wb['jailkit_chroot_cron_programs_txt'] = 'Jailkit cron chrooted applicaties';
$wb['website_path_txt'] = 'Website pad';
$wb['website_symlinks_txt'] = 'Website symlinks';
$wb['website_symlinks_rel_txt'] = 'Maak relative symlinks';
$wb['website_basedir_txt'] = 'Website basedir';
$wb['vhost_conf_dir_txt'] = 'Vhost config dir';
$wb['vhost_conf_enabled_dir_txt'] = 'Vhost config enabled dir';
interface/web/admin/lib/lang/pl_server_config.lng
@@ -5,6 +5,7 @@
$wb['jailkit_chroot_cron_programs_txt'] = 'Aplikacje cron roota Jailkit';
$wb['website_path_txt'] = 'Adres strony WWW';
$wb['website_symlinks_txt'] = 'Symulowany link strony WWW';
$wb['website_symlinks_rel_txt'] = 'Make relative symlinks';
$wb['website_basedir_txt'] = 'Ścieżka bazowa strony WWW';
$wb['vhost_conf_dir_txt'] = 'Ścieżka do konfiguracyji wirtualnego serwera';
$wb['vhost_conf_enabled_dir_txt'] = 'Ścieżka do aktywnej konfiguracyji Vhost';
interface/web/admin/lib/lang/pt_server_config.lng
@@ -4,6 +4,7 @@
$wb['jailkit_chroot_app_programs_txt'] = 'Aplicações Jailkit em ambiente chroot';
$wb['website_path_txt'] = 'Pasta do Website';
$wb['website_symlinks_txt'] = 'Website symlinks: link simbólico';
$wb['website_symlinks_rel_txt'] = 'Make relative symlinks';
$wb['website_basedir_txt'] = 'Website basedir: pasta base ';
$wb['vhost_conf_dir_txt'] = 'Vhost config dir';
$wb['vhost_conf_enabled_dir_txt'] = 'Vhost pasta de configuração activo';
interface/web/admin/lib/lang/ro_server_config.lng
@@ -4,6 +4,7 @@
$wb['jailkit_chroot_app_programs_txt'] = 'Jailkit chrooted applications';
$wb['website_path_txt'] = 'Website path';
$wb['website_symlinks_txt'] = 'Website symlinks';
$wb['website_symlinks_rel_txt'] = 'Make relative symlinks';
$wb['website_basedir_txt'] = 'Website basedir';
$wb['vhost_conf_dir_txt'] = 'Vhost config dir';
$wb['vhost_conf_enabled_dir_txt'] = 'Vhost config enabled dir';
interface/web/admin/lib/lang/ru_server_config.lng
@@ -4,6 +4,7 @@
$wb['jailkit_chroot_app_programs_txt'] = 'Программы Jailkit chrooted';
$wb['website_path_txt'] = 'Путь web-сайта';
$wb['website_symlinks_txt'] = 'Симлинки Web-сайта';
$wb['website_symlinks_rel_txt'] = 'Make relative symlinks';
$wb['vhost_conf_dir_txt'] = 'Папка конфига Vhost';
$wb['vhost_conf_enabled_dir_txt'] = 'Папка конфига включенного Vhost';
$wb['getmail_config_dir_txt'] = 'Папка конфига Getmail';
interface/web/admin/lib/lang/se_server_config.lng
@@ -4,6 +4,7 @@
$wb['jailkit_chroot_app_programs_txt'] = 'Jailkit chrooted applications';
$wb['website_path_txt'] = 'Website path';
$wb['website_symlinks_txt'] = 'Website symlinks';
$wb['website_symlinks_rel_txt'] = 'Make relative symlinks';
$wb['vhost_conf_dir_txt'] = 'Vhost config dir';
$wb['vhost_conf_enabled_dir_txt'] = 'Vhost config enabled dir';
$wb['getmail_config_dir_txt'] = 'Getmail config dir';
interface/web/admin/lib/lang/sk_server_config.lng
@@ -5,6 +5,7 @@
$wb['jailkit_chroot_cron_programs_txt'] = 'Jailkit cron chrooted aplikácia';
$wb['website_path_txt'] = 'Website cesta';
$wb['website_symlinks_txt'] = 'Website symlinky';
$wb['website_symlinks_rel_txt'] = 'Make relative symlinks';
$wb['website_basedir_txt'] = 'Website základny adresár';
$wb['vhost_conf_dir_txt'] = 'Vhost konfig adresár';
$wb['vhost_conf_enabled_dir_txt'] = 'Vhost konfig odblokovaný adresár';
interface/web/admin/lib/lang/tr_server_config.lng
@@ -5,6 +5,7 @@
$wb['jailkit_chroot_cron_programs_txt'] = 'Jailkit cron chrooted applications';
$wb['website_path_txt'] = 'Website yolu';
$wb['website_symlinks_txt'] = 'Website symlinks';
$wb['website_symlinks_rel_txt'] = 'Make relative symlinks';
$wb['website_basedir_txt'] = 'Website klasörü';
$wb['vhost_conf_dir_txt'] = 'Vhost config dir';
$wb['vhost_conf_enabled_dir_txt'] = 'Vhost config enabled dir';
interface/web/admin/templates/server_config_web_edit.htm
@@ -18,6 +18,12 @@
        <input name="website_symlinks" id="website_symlinks" value="{tmpl_var name='website_symlinks'}" size="40" maxlength="255" type="text" class="textInput" />
      </div>
      <div class="ctrlHolder">
          <label for="website_symlinks_rel">{tmpl_var name='website_symlinks_rel_txt'}</label>
            <div class="multiField">
                {tmpl_var name='website_symlinks_rel'}
            </div>
      </div>
      <div class="ctrlHolder">
          <label for="vhost_conf_dir">{tmpl_var name='vhost_conf_dir_txt'}</label>
        <input name="vhost_conf_dir" id="vhost_conf_dir" value="{tmpl_var name='vhost_conf_dir'}" size="40" maxlength="255" type="text" class="textInput" />
            </div>
server/plugins-available/apache2_plugin.inc.php
@@ -357,7 +357,13 @@
        // Create the symlink for the logfiles
        if(!is_dir('/var/log/ispconfig/httpd/'.$data['new']['domain'])) exec('mkdir -p /var/log/ispconfig/httpd/'.$data['new']['domain']);
        if(!is_link($data['new']['document_root'].'/log')) {
            exec('ln -s /var/log/ispconfig/httpd/'.$data['new']['domain'].' '.$data['new']['document_root'].'/log');
//            exec("ln -s /var/log/ispconfig/httpd/".$data["new"]["domain"]." ".$data["new"]["document_root"]."/log");
            if ($web_config["website_symlinks_rel"] == 'y') {
                $this->create_relative_link("/var/log/ispconfig/httpd/".$data["new"]["domain"], $data["new"]["document_root"]."/log");
            } else {
                exec("ln -s /var/log/ispconfig/httpd/".$data["new"]["domain"]." ".$data["new"]["document_root"]."/log");
            }
            $app->log('Creating symlink: ln -s /var/log/ispconfig/httpd/'.$data['new']['domain'].' '.$data['new']['document_root'].'/log',LOGLEVEL_DEBUG);
        }
        /*
@@ -413,7 +419,13 @@
                }
                // create the symlinks, if not exist
                if(!is_link($tmp_symlink)) {
                    exec('ln -s '.escapeshellcmd($data['new']['document_root']).'/ '.escapeshellcmd($tmp_symlink));
//                    exec("ln -s ".escapeshellcmd($data["new"]["document_root"])."/ ".escapeshellcmd($tmp_symlink));
                    if ($web_config["website_symlinks_rel"] == 'y') {
                        $this->create_relative_link(escapeshellcmd($data["new"]["document_root"]), escapeshellcmd($tmp_symlink));
                    } else {
                        exec("ln -s ".escapeshellcmd($data["new"]["document_root"])."/ ".escapeshellcmd($tmp_symlink));
                    }
                    $app->log('Creating symlink: ln -s '.$data['new']['document_root'].'/ '.$tmp_symlink,LOGLEVEL_DEBUG);
                }
            }
@@ -1458,6 +1470,31 @@
        }
    }
    public function create_relative_link($f, $t) {
        // $from already exists
        $from = realpath($f);
        // realpath requires the traced file to exist - so, lets touch it first, then remove
        @unlink($t); touch($t);
        $to = realpath($t);
        @unlink($t);
        // Remove from the left side matching path elements from $from and $to
        // and get path elements counts
        $a1 = explode('/', $from); $a2 = explode('/', $to);
        for ($c = 0; $a1[$c] == $a2[$c]; $c++) {
            unset($a1[$c]); unset($a2[$c]);
        }
        $cfrom = implode('/', $a1);
        // Check if a path is fully a subpath of another - no way to create symlink in the case
        if (count($a1) == 0 || count($a2) == 0) return false;
        // Add ($cnt_to-1) number of "../" elements to left side of $cfrom
        for ($c = 0; $c < (count($a2)-1); $c++) { $cfrom = '../'.$cfrom; }
        return symlink($cfrom, $to);
    }
} // end class