modules/vhosts/edit.php
72518278
 <?php
 
 require_once('inc/debug.php');
 require_once('inc/security.php');
 
 require_once('vhosts.php');
 
709c9ea2
 $title = "Subdomain bearbeiten";
8d92bc6d
 $section = 'vhosts_vhosts';
72518278
 
 require_role(ROLE_SYSTEMUSER);
 
8d92bc6d
 $id = (int) $_GET['vhost'];
 $vhost = empty_vhost();
 
 if ($id != 0)
   $vhost = get_vhost_details($id);
72518278
 
 DEBUG($vhost);
709c9ea2
 if ($id == 0) {
   output("<h3>Neue Subdomain anlegen</h3>");
   $title = "Subdomain anlegen";
 }
 else {
   output("<h3>Subdomain bearbeiten</h3>");
 }
72518278
 
33c1bcb0
 html_header("<script type=\"text/javascript\">
7fb0aeba
  
8d92bc6d
   function selectedDomain() {
     var selected;
     selected=document.getElementById('domain').options.selectedIndex;
     return document.getElementById('domain').options.item(selected).text;
     }
   
   function defaultDocumentRoot() {
     var hostname;
     if (document.getElementById('hostname').value == '') 
       hostname = selectedDomain();
     else
       hostname = document.getElementById('hostname').value + '.' + selectedDomain();
33c1bcb0
     var default_docroot = hostname + '/htdocs';
     useDefaultDocroot(default_docroot);
8d92bc6d
   }
   
33c1bcb0
   function useDefaultDocroot( default_docroot ) {
8d92bc6d
     var do_it = (document.getElementById('use_default_docroot').checked == true);
     var inputfield = document.getElementById('docroot');
     inputfield.disabled = do_it;
     if (do_it) {
7fb0aeba
       document.getElementById('docroot').value = default_docroot;
8d92bc6d
     }
   }
9476de83
   
   function showAppropriateLines() {
     if (document.getElementById('vhost_type_regular').checked == true) {
f0f3361f
       document.getElementById('options_docroot').style.display = 'block';
       document.getElementById('options_scriptlang').style.display = 'block';
832d06da
       document.getElementById('options_webapp').style.display = 'none';
9476de83
     }
f0f3361f
     else if (document.getElementById('vhost_type_dav').checked == true) { 
       document.getElementById('options_docroot').style.display = 'block';
       document.getElementById('options_scriptlang').style.display = 'none';
       document.getElementById('options_webapp').style.display = 'none';
     }
     else if (document.getElementById('vhost_type_svn').checked == true) {
       document.getElementById('options_docroot').style.display = 'none';
       document.getElementById('options_scriptlang').style.display = 'none';
832d06da
       document.getElementById('options_webapp').style.display = 'none';
9476de83
     }
     else if (document.getElementById('vhost_type_webapp').checked == true) {
f0f3361f
       document.getElementById('options_docroot').style.display = 'none';
       document.getElementById('options_scriptlang').style.display = 'none';
832d06da
       document.getElementById('options_webapp').style.display = 'block';
9476de83
     }
   }
8d92bc6d
   </script>");
 
 $defaultdocroot = $vhost['domain'];
f1d119a9
 if (! $vhost['domain'])
   $defaultdocroot = $_SESSION['userinfo']['username'].'.schokokeks.org';
8d92bc6d
 if ($vhost['hostname'])
   $defaultdocroot = $vhost['hostname'].'.'.$defaultdocroot;
 
33c1bcb0
 $defaultdocroot = $defaultdocroot.'/htdocs';
8d92bc6d
 
33c1bcb0
 $is_default_docroot = ($vhost['docroot'] == NULL) || ($vhost['homedir'].'/websites/'.$defaultdocroot == $vhost['docroot']);
 
 if ($vhost['docroot'] != '' && ! strstr($vhost['docroot'], '/websites/'))
 {
   warning("Sie verwenden einen Speicherplatz außerhalb von »~/websites/«. Diese Einstellung ist momentan nicht mehr gestattet. Ihre Einstellung wurde daher auf die Standardeinstellung zurückgesetzt. Prüfen Sie dies bitte und verschieben Sie ggf. ihre Dateien.");
   $is_default_docroot = True;
 }
8d92bc6d
 
 $docroot = '';
33c1bcb0
 if ($is_default_docroot)
8d92bc6d
   $docroot = $defaultdocroot;
 else
33c1bcb0
   $docroot = substr($vhost['docroot'], strlen($vhost['homedir'].'/websites/'));
8d92bc6d
 
72518278
 $s = (strstr($vhost['options'], 'aliaswww') ? ' checked="checked" ' : '');
2b282fad
 $errorlog = (strstr($vhost['errorlog'], 'on') ? ' checked="checked" ' : '');
832d06da
 
 $vhost_type = 'regular';
 if ($vhost['is_dav'])
   $vhost_type = 'dav';
 elseif ($vhost['is_svn'])
   $vhost_type = 'svn';
 elseif ($vhost['is_webapp'])
   $vhost_type = 'webapp';
 
3c2fddca
 $applist = list_available_webapps();
 $webapp_options = '';
 foreach ($applist as $app)
   $webapp_options .= "<option value=\"{$app['id']}\">{$app['displayname']}</option>\n";
 
 
72518278
 $form = "
832d06da
 <h4 style=\"margin-top: 2em;\">Name des VHost</h4>
54fcfe5c
     <div style=\"margin-left: 2em;\"><input type=\"text\" name=\"hostname\" id=\"hostname\" size=\"10\" value=\"{$vhost['hostname']}\" onkeyup=\"defaultDocumentRoot()\"  onchange=\"defaultDocumentRoot()\" /><strong>.</strong>".domainselect($vhost['domain_id'], 'onchange="defaultDocumentRoot()"');
832d06da
 $form .= "<br /><input type=\"checkbox\" name=\"options[]\" id=\"aliaswww\" value=\"aliaswww\" {$s}/> <label for=\"aliaswww\">Auch mit <strong>www</strong> davor.</label></div>
 
7fb0aeba
 <div class=\"vhostsidebyside\">
f0f3361f
 <div class=\"vhostoptions\" id=\"options_docroot\" ".($vhost_type=='regular' || $vhost_type=='dav' ? '' : 'style="display: none;"').">
832d06da
   <h4>Optionen</h4>
   <h5>Speicherort für Dateien (»Document Root«)</h5>
   <div style=\"margin-left: 2em;\">
070ded17
     <input type=\"checkbox\" id=\"use_default_docroot\" name=\"use_default_docroot\" value=\"1\" onclick=\"defaultDocumentRoot()\" ".($is_default_docroot ? 'checked="checked" ' : '')."/>&#160;<label for=\"use_default_docroot\">Standardeinstellung benutzen</label><br />
33c1bcb0
     <strong>".$vhost['homedir']."/websites/</strong>&#160;<input type=\"text\" id=\"docroot\" name=\"docroot\" size=\"30\" value=\"".$docroot."\" ".($is_default_docroot ? 'disabled="disabled" ' : '')."/>
832d06da
   </div>
f0f3361f
 </div>
33c1bcb0
 ";
f0f3361f
 
33c1bcb0
 if ($vhost['php'] == 'mod_php')
 {
 $form .= "
f0f3361f
 <div class=\"vhostoptions\" id=\"options_scriptlang\" ".($vhost_type=='regular' ? '' : 'style="display: none;"').">
33c1bcb0
   <h5>PHP</h5>
832d06da
   <div style=\"margin-left: 2em;\">
     <select name=\"php\" id=\"php\">
33c1bcb0
       <option value=\"none\" ".($vhost['php'] == NULL ? 'selected="selected"' : '')." >ausgeschaltet</option>
       <option value=\"mod_php\" ".($vhost['php'] == 'mod_php' ? 'selected="selected"' : '')." >Eingeschaltet als Apache-Modul (veraltet)</option>
       <option value=\"fastcgi\" ".($vhost['php'] == 'fastcgi' ? 'selected="selected"' : '')." >Eingeschaltet</option>
7fb0aeba
       <!--  <option value=\"rubyonrails\" ".($vhost['php'] == 'rubyonrails' ? 'selected="selected"' : '')." >Ruby-on-Rails</option> -->
8d92bc6d
     </select>
832d06da
   </div>
 </div>
33c1bcb0
 ";
 }
 else
 {
 $form .= "
 <div class=\"vhostoptions\" id=\"options_scriptlang\" ".($vhost_type=='regular' ? '' : 'style="display: none;"').">
   <h5>PHP</h5>
   <div style=\"margin-left: 2em;\">
     <input type=\"checkbox\" name=\"php\" id=\"php\" value=\"fastcgi\" ".($vhost['php'] == 'fastcgi' ? 'checked="checked" ' : '')." />&#160;<label for=\"php\">PHP aktivieren</label>
   </div>
 </div>
 ";
 }
832d06da
 
33c1bcb0
 $form .= "
7fb0aeba
 <div class=\"vhostoptions\" id=\"options_webapp\" ".($vhost_type=='webapp' ? '' : 'style="display: none;"').">
832d06da
   <h4>Optionen</h4>
   <h5>Anwendung</h5>
7fb0aeba
   <select name=\"webapp\" id=\"webapp\" size=\"1\">
3c2fddca
     {$webapp_options}
7fb0aeba
   </select>
14f0fd75
   <p>Wenn Sie diese Option wählen, wird die Anwendung automatisch eingerichtet. Sie erhalten dann ihre Zugangsdaten per E-Mail.</p>
832d06da
 </div>
 
 <h4>Verwendung</h4>
         <div style=\"margin-left: 2em;\">
 	  <input class=\"usageoption\" onclick=\"showAppropriateLines()\" type=\"radio\" name=\"vhost_type\" id=\"vhost_type_regular\" value=\"regular\" ".(($vhost_type=='regular') ? 'checked="checked" ' : '')."/><label for=\"vhost_type_regular\">&#160;Normal (selbst Dateien hinterlegen)</label><br />
0ef79ba8
 	  <input class=\"usageoption\" onclick=\"showAppropriateLines()\" type=\"radio\" name=\"vhost_type\" id=\"vhost_type_webapp\" value=\"webapp\" ".(($vhost_type=='webapp') ? 'checked="checked" ' : '')."/><label for=\"vhost_type_webapp\">&#160;Eine vorgefertigte Applikation nutzen</label><br />
832d06da
 	  <input class=\"usageoption\" onclick=\"showAppropriateLines()\" type=\"radio\" name=\"vhost_type\" id=\"vhost_type_dav\" value=\"dav\" ".(($vhost_type=='dav') ? 'checked="checked" ' : '')."/><label for=\"vhost_type_dav\">&#160;WebDAV</label><br />
0ef79ba8
 	  <input class=\"usageoption\" onclick=\"showAppropriateLines()\" type=\"radio\" name=\"vhost_type\" id=\"vhost_type_svn\" value=\"svn\" ".(($vhost_type=='svn') ? 'checked="checked" ' : '')."/><label for=\"vhost_type_svn\">&#160;Subversion-Server</label>
832d06da
 	</div>
7fb0aeba
 <br />
 </div>
832d06da
 
 <h4 style=\"margin-top: 3em;\">Allgemeine Optionen</h4>
 <div style=\"margin-left: 2em;\">
     <h5>SSL-Verschlüsselung</h5>
     <div style=\"margin-left: 2em;\">
     <select name=\"ssl\" id=\"ssl\">
fc35e698
       <option value=\"none\" ".($vhost['ssl'] == NULL ? 'selected="selected"' : '')." >SSL optional anbieten</option>
       <option value=\"http\" ".($vhost['ssl'] == 'http' ? 'selected="selected"' : '')." >kein SSL</option>
       <option value=\"https\" ".($vhost['ssl'] == 'https' ? 'selected="selected"' : '')." >nur SSL</option>
       <option value=\"forward\" ".($vhost['ssl'] == 'forward' ? 'selected="selected"' : '')." >Immer auf SSL umleiten</option>
     </select>
832d06da
     </div>
     <h5>Logfiles <span class=\"warning\">*</span></h5>
     <div style=\"margin-left: 2em;\">
       <select name=\"logtype\" id=\"logtype\">
         <option value=\"none\" ".($vhost['logtype'] == NULL ? 'selected="selected"' : '')." >keine Logfiles</option>
         <option value=\"anonymous\" ".($vhost['logtype'] == 'anonymous' ? 'selected="selected"' : '')." >anonymisiert</option>
         <option value=\"default\" ".($vhost['logtype'] == 'default' ? 'selected="selected"' : '')." >vollständige Logfile</option>
       </select><br />
       <input type=\"checkbox\" id=\"errorlog\" name=\"errorlog\" value=\"1\" ".($vhost['errorlog'] == 1 ? ' checked="checked" ' : '')." />&#160;<label for=\"errorlog\">Fehlerprotokoll (error_log) einschalten</label>
     </div>
 </div>
8d92bc6d
     ";
72518278
 
832d06da
 $form .= '
63a0529b
   <p><input type="submit" value="Speichern" />&#160;&#160;&#160;&#160;'.internal_link('vhosts', 'Abbrechen').'</p>
33c1bcb0
   <p class="warning"><span class="warning">*</span>Es ist im Moment fraglich, ob die Speicherung von Logfiles mit IP-Adressen auf Webservern
587b3b88
   zulässig ist. Wir weisen alle Nutzer darauf hin, dass sie selbst dafür verantwortlich sind, bei geloggten Nutzerdaten die
   Seitenbesucher darauf hinzuweisen. Wir empfehlen, wenn möglich, Logfiles abzuschalten oder anonymes Logging einzusetzen.</p>
8d92bc6d
 ';
63a0529b
 output(html_form('vhosts_edit_vhost', 'save', 'action=edit&vhost='.$vhost['id'], $form));
72518278
 
 
 ?>