modules/vhosts/aliasoptions.php
8b88a1e2
 <?php
c208bd90
 /*
 This file belongs to the Webinterface of schokokeks.org Hosting
 
cf54502a
 Written 2008-2018 by schokokeks.org Hosting, namely
c208bd90
   Bernd Wurst <bernd@schokokeks.org>
   Hanno Böck <hanno@schokokeks.org>
 
 To the extent possible under law, the author(s) have dedicated all copyright and related and neighboring rights to this software to the public domain worldwide. This software is distributed without any warranty.
 
2626dd47
 You should have received a copy of the CC0 Public Domain Dedication along with this software. If not, see
c208bd90
 http://creativecommons.org/publicdomain/zero/1.0/
 
 Nevertheless, in case you use a significant part of this code, we ask (but not require, see the license) that you keep the authors' names in place and return your changes to the public. We would be especially happy if you tell us what you're going to do with this code.
 */
8b88a1e2
 
 require_once('inc/base.php');
 require_once('vhosts.php');
 
 require_once('inc/debug.php');
 global $debugmode;
 
 check_form_token('aliases_toggle', $_GET['formtoken']);
 
 if (isset($_GET['aliaswww'])) {
2626dd47
     $aliaswww = (bool) ((int) $_GET['aliaswww']);
 
     $alias = get_alias_details($_GET['alias']);
     DEBUG($alias);
     $old_options = explode(',', $alias['options']);
     $new_options = array();
     foreach ($old_options as $op) {
2d13e1de
         if ($op !== '' && $op != 'aliaswww') {
2626dd47
             array_push($new_options, $op);
         }
     }
     if ($aliaswww) {
         array_push($new_options, 'aliaswww');
     }
9086c9ad
 
2626dd47
     DEBUG($old_options);
     DEBUG($new_options);
     $alias['options'] = implode(',', $new_options);
93bdb988
     DEBUG('New options: '.$alias['options']);
8b88a1e2
 
2626dd47
     $alias['domainid'] = $alias['domain_id'];
     save_alias($alias);
8b88a1e2
 
2626dd47
     if (! $debugmode) {
         header('Location: aliases?vhost='.$alias['vhost']);
     }
8b88a1e2
 }
 if (isset($_GET['forward'])) {
2626dd47
     $forward = (bool) ((int) $_GET['forward']);
 
     $alias = get_alias_details($_GET['alias']);
     DEBUG($alias);
     $old_options = explode(',', $alias['options']);
     $new_options = array();
     foreach ($old_options as $op) {
2d13e1de
         if ($op !== '' && $op != 'forward') {
2626dd47
             array_push($new_options, $op);
         }
     }
     if ($forward) {
         array_push($new_options, 'forward');
     }
9086c9ad
 
2626dd47
     DEBUG($old_options);
     DEBUG($new_options);
     $alias['options'] = implode(',', $new_options);
48789d72
     DEBUG('New options: '.$alias['options']);
8b88a1e2
 
2626dd47
     $alias['domainid'] = $alias['domain_id'];
     save_alias($alias);
8b88a1e2
 
2626dd47
     if (! $debugmode) {
         header('Location: aliases?vhost='.$alias['vhost']);
     }
8b88a1e2
 }