[ PHPXref.com ] [ Generated: Sun Jul 20 18:16:01 2008 ] [ ISPConfig 2.2.1 ]
[ Index ]     [ Variables ]     [ Functions ]     [ Classes ]     [ Constants ]     [ Statistics ]

title

Body

[close]

/ -> install.php (source)

   1  <?php
   2  /*
   3  Copyright (c) 2005, projektfarm Gmbh, Till Brehm, Falko Timme
   4  All rights reserved.
   5  
   6  Redistribution and use in source and binary forms, with or without modification,
   7  are permitted provided that the following conditions are met:
   8  
   9      * Redistributions of source code must retain the above copyright notice,
  10        this list of conditions and the following disclaimer.
  11      * Redistributions in binary form must reproduce the above copyright notice,
  12        this list of conditions and the following disclaimer in the documentation
  13        and/or other materials provided with the distribution.
  14      * Neither the name of ISPConfig nor the names of its contributors
  15        may be used to endorse or promote products derived from this software without
  16        specific prior written permission.
  17  
  18  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  19  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  20  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  21  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
  22  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  23  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  24  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
  25  OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  26  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  27  EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  28  
  29  */
  30  
  31  $FILE = realpath("../install_ispconfig/install.php");
  32  
  33  function ilog($msg){
  34    $logfile = "/var/log/ispconfig_install.log";
  35    exec("echo `date` \"- [ISPConfig] - \"".$msg." >> ".$logfile);
  36  }
  37  
  38  function error($msg){
  39    ilog($msg);
  40    die($msg."\n");
  41  }
  42  
  43  function caselog($command, $file = '', $line = '', $success = '', $failure = ''){
  44    exec($command,$arr,$ret_val);
  45    $arr = NULL;
  46    if(!empty($file) && !empty($line)){
  47      $pre = $file.", Line ".$line.": ";
  48    } else {
  49      $pre = "";
  50    }
  51    if($ret_val != 0){
  52      if($failure == "") $failure = "could not ".$command;
  53      ilog($pre."WARNING: ".$failure);
  54    } else {
  55      if($success == "") $success = $command;
  56      ilog($pre.$success);
  57    }
  58  }
  59  
  60  function phpcaselog($ret_val, $msg, $file = '', $line = ''){
  61    if(!empty($file) && !empty($line)){
  62      $pre = $file.", Line ".$line.": ";
  63    } else {
  64      $pre = "";
  65    }
  66    if($ret_val == true){
  67      ilog($pre.$msg);
  68    } else {
  69      ilog($pre."WARNING: could not ".$msg);
  70    }
  71    return $ret_val;
  72  }
  73  
  74  function mkdirs($strPath, $mode = '0755'){
  75    if(isset($strPath) && $strPath != ""){
  76      // Verzeichnisse rekursiv erzeugen
  77      if(is_dir($strPath)) return true;
  78      $pStrPath = dirname($strPath);
  79      if(!mkdirs($pStrPath, $mode)) return false;
  80      $old_umask = umask(0);
  81      $ret_val = mkdir($strPath, octdec($mode));
  82      umask($old_umask);
  83      return $ret_val;
  84    } else {
  85      return false;
  86    }
  87  }
  88  
  89  function rf($file){
  90    clearstatcache();
  91    if(!$fp = fopen ($file, "rb")) ilog("WARNING: could not open file ".$file);
  92    if(filesize($file) > 0){
  93      $content = fread($fp, filesize($file));
  94    } else {
  95      $content = "";
  96    }
  97    fclose($fp);
  98    return $content;
  99  }
 100  
 101  function wf($file, $content){
 102    mkdirs(dirname($file));
 103    if(!$fp = fopen ($file, "wb")) ilog("WARNING: could not open file ".$file);
 104    fwrite($fp,$content);
 105    fclose($fp);
 106  }
 107  
 108  function af($file, $content){
 109    mkdirs(dirname($file));
 110    if(!$fp = fopen ($file, "ab")) ilog("WARNING: could not open file ".$file);
 111    fwrite($fp,$content);
 112    fclose($fp);
 113  }
 114  
 115  function aftsl($file, $content){
 116    if(!$fp = fopen ($file, "ab")) ilog("WARNING: could not open file ".$file);
 117    fwrite($fp,$content);
 118    fclose($fp);
 119  }
 120  
 121  function unix_nl($input){
 122    $output = str_replace("\r\n", "\n", $input);
 123    $output = str_replace("\r", "\n", $output);
 124    return $output;
 125  }
 126  
 127  function remove_blank_lines($input, $file = 1){
 128    //Leerzeilen löschen
 129    if($file){
 130      $content = unix_nl(rf($input));
 131    } else {
 132      $content = $input;
 133    }
 134    $lines = explode("\n", $content);
 135    if(!empty($lines)){
 136      foreach($lines as $line){
 137        if(trim($line) != "") $new_lines[] = $line;
 138      }
 139    }
 140    if(is_array($new_lines)){
 141      $content = implode("\n", $new_lines);
 142    } else {
 143      $content = "";
 144    }
 145    if($file){
 146      wf($input, $content);
 147    } else {
 148      return $content;
 149    }
 150  }
 151  
 152  function no_comments($file, $comment = '#'){
 153    $content = unix_nl(rf($file));
 154    $lines = explode("\n", $content);
 155    if(!empty($lines)){
 156      foreach($lines as $line){
 157        if(strstr($line, $comment)){
 158          $pos = strpos($line, $comment);
 159          if($pos != 0){
 160            $new_lines[] = substr($line,0,$pos);
 161          } else {
 162            $new_lines[] = "";
 163          }
 164        } else {
 165          $new_lines[] = $line;
 166        }
 167      }
 168    }
 169    if(is_array($new_lines)){
 170      $content_without_comments = implode("\n", $new_lines);
 171      $new_lines = NULL;
 172      return $content_without_comments;
 173    } else {
 174      return "";
 175    }
 176  }
 177  
 178  function find_includes($file){
 179    global $httpd_root;
 180    clearstatcache();
 181    if(is_file($file) && filesize($file) > 0){
 182      $includes[] = $file;
 183      $inhalt = unix_nl(no_comments($file));
 184      $lines = explode("\n", $inhalt);
 185      if(!empty($lines)){
 186        foreach($lines as $line){
 187          if(stristr($line, "include ")){
 188            $include_file = str_replace("\n", "", trim(shell_exec("echo \"$line\" | awk '{print \$2}'")));
 189            if(substr($include_file,0,1) != "/"){
 190              $include_file = $httpd_root."/".$include_file;
 191            }
 192            if(is_file($include_file)){
 193              if($further_includes = find_includes($include_file)){
 194                $includes = array_merge($includes, $further_includes);
 195              }
 196            } else {
 197              if(strstr($include_file, "*")){
 198                $more_files = explode("\n", shell_exec("ls -l $include_file | awk '{print \$9}'"));
 199                if(!empty($more_files)){
 200                  foreach($more_files as $more_file){
 201                    if(is_file($more_file)){
 202                      if($further_includes = find_includes($more_file)){
 203                        $includes = array_merge($includes, $further_includes);
 204                      }
 205                    }
 206                  }
 207                }
 208                unset($more_files);
 209                $more_files = explode("\n", shell_exec("ls -l $include_file | awk '{print \$10}'"));
 210                if(!empty($more_files)){
 211                  foreach($more_files as $more_file){
 212                    if(is_file($more_file)){
 213                      if($further_includes = find_includes($more_file)){
 214                        $includes = array_merge($includes, $further_includes);
 215                      }
 216                    }
 217                  }
 218                }
 219              }
 220            }
 221          }
 222        }
 223      }
 224    }
 225    if(is_array($includes)){
 226      $includes = array_unique($includes);
 227      return $includes;
 228    } else {
 229      return false;
 230    }
 231  }
 232  
 233  function comment_out($file, $string){
 234    $inhalt = no_comments($file);
 235    $gesamt_inhalt = rf($file);
 236    $modules = explode(",",$string);
 237    foreach($modules as $val){
 238      $val = trim($val);
 239      if(strstr($inhalt, $val)){
 240        $gesamt_inhalt = str_replace($val, "##ISPConfig INSTALL## ".$val, $gesamt_inhalt);
 241      }
 242    }
 243    wf($file, $gesamt_inhalt);
 244  }
 245  
 246  function is_word($string, $text, $params = ''){
 247    // params: i
 248    if(preg_match("/\b$string\b/$params", $text)) {
 249      return true;
 250    } else {
 251      return false;
 252    }
 253  }
 254  
 255  function grep($content, $string, $params = ''){
 256    // params: i, v, w
 257    $content = unix_nl($content);
 258    $lines = explode("\n", $content);
 259    foreach($lines as $line){
 260      if(!strstr($params, 'w')){
 261        if(strstr($params, 'i')){
 262          if(strstr($params, 'v')){
 263            if(!stristr($line, $string)) $find[] = $line;
 264          } else {
 265            if(stristr($line, $string)) $find[] = $line;
 266          }
 267        } else {
 268          if(strstr($params, 'v')){
 269            if(!strstr($line, $string)) $find[] = $line;
 270          } else {
 271            if(strstr($line, $string)) $find[] = $line;
 272          }
 273        }
 274      } else {
 275        if(strstr($params, 'i')){
 276          if(strstr($params, 'v')){
 277            if(!is_word($string, $line, 'i')) $find[] = $line;
 278          } else {
 279            if(is_word($string, $line, 'i')) $find[] = $line;
 280          }
 281        } else {
 282          if(strstr($params, 'v')){
 283            if(!is_word($string, $line)) $find[] = $line;
 284          } else {
 285            if(is_word($string, $line)) $find[] = $line;
 286          }
 287        }
 288      }
 289    }
 290    if(is_array($find)){
 291      $ret_val = implode("\n", $find);
 292      if(substr($ret_val,-1) != "\n") $ret_val .= "\n";
 293      $find = NULL;
 294      return $ret_val;
 295    } else {
 296      return false;
 297    }
 298  }
 299  
 300  function edit_xinetd_conf($service){
 301    $xinetd_conf = "/etc/xinetd.conf";
 302    $contents = unix_nl(rf($xinetd_conf));
 303    $lines = explode("\n", $contents);
 304    $j = sizeof($lines);
 305    for($i=0;$i<sizeof($lines);$i++){
 306      if(grep($lines[$i], $service, "w")){
 307        $fundstelle_anfang = $i;
 308        $j = $i;
 309        $parts = explode($lines[$i], $contents);
 310      }
 311      if($j < sizeof($lines)){
 312        if(strstr($lines[$i], "}")){
 313          $fundstelle_ende = $i;
 314          $j = sizeof($lines);
 315        }
 316      }
 317    }
 318    if(isset($fundstelle_anfang) && isset($fundstelle_ende)){
 319      for($i=$fundstelle_anfang;$i<=$fundstelle_ende;$i++){
 320        if(strstr($lines[$i], "disable")){
 321          $disable = explode("=", $lines[$i]);
 322          $disable[1] = " yes";
 323          $lines[$i] = implode("=", $disable);
 324        }
 325      }
 326    }
 327    $fundstelle_anfang = NULL;
 328    $fundstelle_ende = NULL;
 329    $contents = implode("\n", $lines);
 330    wf($xinetd_conf, $contents);
 331  }
 332  
 333  $current_date = time();
 334  $datum = date("d-m-y_H-i-s", $current_date);
 335  $conf_datei_temp = "config.inc.php.tmp";
 336  $sql_file = "db_ispconfig.sql";
 337  $pfad = "/home/admispconfig";
 338  
 339  $mysql = rf("mysql_config");
 340  list($db_server,$db_user,$db_password,$new_db,$ip,$server_host,$server_domain,$procmail,$lang,$install_art,$server_ispconfigprotocol) = explode("\n",$mysql);
 341  $server_ispconfigprotocol = strtolower(trim($server_ispconfigprotocol));
 342  
 343  $conf = rf("/root/ispconfig/dist.info");
 344  
 345  $conf = str_replace("dist", "\$dist", $conf);
 346  $conf = str_replace("=", " = \"", $conf);
 347  $conf = str_replace(" ##", "\";", $conf);
 348  $conf_lines = explode("\n", $conf);
 349  foreach($conf_lines as $conf_line){
 350    if(substr($conf_line,0,6) != "export") $new_conf_lines[] = $conf_line;
 351  }
 352  $conf = implode("\n", $new_conf_lines);
 353  $conf = "<?\n".$conf."\n?>";
 354  unset($conf_lines);
 355  unset($new_conf_lines);
 356  
 357  wf("/root/ispconfig/dist.inc.php", $conf);
 358  
 359  include("/root/ispconfig/dist.inc.php");
 360  $dist_passwd = trim($dist_passwd);
 361  $dist_shadow = trim($dist_shadow);
 362  $dist_group = trim($dist_group);
 363  
 364  /////////////// Apache-Init-Skript finden ////////////////
 365  ob_start();
 366  system("ls ".$dist_init_scripts." | grep apache");
 367  system("ls ".$dist_init_scripts." | grep httpd");
 368  $tmp_output = trim(ob_get_contents());
 369  ob_end_clean();
 370  
 371  if($tmp_output != ""){
 372    $tmp_httpd_daemon = explode("\n", $tmp_output);
 373  } else {
 374    $tmp_httpd_daemon = array();
 375  }
 376  unset($tmp_output);
 377  
 378  if(sizeof($tmp_httpd_daemon) == 1 && !empty($tmp_httpd_daemon)) $dist_httpd_daemon = trim($tmp_httpd_daemon[0]);
 379  unset($tmp_httpd_daemon);
 380  /////////////// Apache-Init-Skript finden ENDE ////////////////
 381  
 382  /////////////////////////////////
 383  function is_user($user){
 384    global $dist_passwd;
 385    $user_datei = $dist_passwd;
 386    $users = no_comments($user_datei);
 387    $lines = explode("\n", $users);
 388    if(is_array($lines)){
 389      foreach($lines as $line){
 390        if(trim($line) != ""){
 391          list($f1, $f2, $f3, $f4, $f5, $f6, $f7) = explode(":", $line);
 392          if($f1 == $user) return true;
 393        }
 394      }
 395    }
 396    return false;
 397  }
 398  
 399  function is_group($group){
 400    global $dist_group;
 401    $group_datei = $dist_group;
 402    $groups = no_comments($group_datei);
 403    $lines = explode("\n", $groups);
 404    if(is_array($lines)){
 405      foreach($lines as $line){
 406        if(trim($line) != ""){
 407          list($f1, $f2, $f3, $f4) = explode(":", $line);
 408          if($f1 == $group) return true;
 409        }
 410      }
 411    }
 412    return false;
 413  }
 414  
 415  function root_group(){
 416    global $dist_group;
 417    $group_datei = $dist_group;
 418    $groups = no_comments($group_datei);
 419    $lines = explode("\n", $groups);
 420    if(is_array($lines)){
 421      foreach($lines as $line){
 422        if(trim($line) != ""){
 423          list($f1, $f2, $f3, $f4) = explode(":", $line);
 424          if($f3 == 0) return $f1;
 425        }
 426      }
 427    }
 428    return false;
 429  }
 430  
 431  function adduser($user_username, $uid, $gid, $username, $homedir, $shell, $passwort = '*'){
 432    global $dist_passwd, $dist_shadow, $FILE;
 433    if(is_user($user_username)){
 434      return false;
 435    } else {
 436      $user_datei = $dist_passwd;
 437      $shadow_datei = $dist_shadow;
 438      $shell = realpath($shell);
 439      if(trim($passwort) == "") $passwort = '*';
 440      $new_user = "\n$user_username:x:$uid:$gid:$username:$homedir:$shell\n";
 441      af($user_datei, $new_user);
 442      remove_blank_lines($user_datei);
 443      if($shadow_datei == "/etc/shadow"){
 444        $datum = time();
 445        $tage = floor($datum/86400);
 446        $new_passwd = "\n$user_username:$passwort:$tage:0:99999:7:::\n";
 447      } else {
 448        $new_passwd = "\n$user_username:$passwort:$uid:$gid::0:0:$username:$homedir:$shell\n";
 449      }
 450      af($shadow_datei, $new_passwd);
 451      remove_blank_lines($shadow_datei);
 452      if($shadow_datei != "/etc/shadow"){
 453        af($shadow_datei, "\n");
 454        caselog("pwd_mkdb $shadow_datei &> /dev/null", $FILE, __LINE__);
 455      }
 456      return true;
 457    }
 458  }
 459  
 460  function addgroup($group, $gid, $members = ''){
 461    global $dist_group, $dist_shadow, $FILE;
 462    if(is_group($group)){
 463      return false;
 464    } else {
 465      $group_datei = $dist_group;
 466      $shadow_datei = $dist_shadow;
 467      $new_group = "\n$group:x:$gid:$members\n";
 468      af($group_datei, $new_group);
 469      remove_blank_lines($group_datei);
 470      if($shadow_datei != "/etc/shadow"){
 471        af($group_datei, "\n");
 472        caselog("pwd_mkdb $shadow_datei &> /dev/null", $FILE, __LINE__);
 473      }
 474      return true;
 475    }
 476  }
 477  
 478  function find_uid_gid($min, $max){
 479    global $dist_passwd, $dist_group;
 480    if($min < $max && $min >= 0 && $max >= 0 && $min <= 65536 && $max <= 65536 && is_int($min) && is_int($max)){
 481      $user_datei = $dist_passwd;
 482      $group_datei = $dist_group;
 483  
 484      $users = no_comments($user_datei);
 485      $lines = explode("\n", $users);
 486      if(is_array($lines)){
 487        foreach($lines as $line){
 488          if(trim($line) != ""){
 489            list($f1, $f2, $f3, $f4, $f5, $f6, $f7) = explode(":", $line);
 490            if($f3 >= $min && $f3 <= $max) $uids[] = $f3;
 491          }
 492        }
 493        if(is_array($uids)){
 494          $max_uid = max($uids);
 495        } else {
 496          $max_uid = $min - 1;
 497        }
 498      }
 499  
 500      $groups = no_comments($group_datei);
 501      $lines = explode("\n", $groups);
 502      if(is_array($lines)){
 503        foreach($lines as $line){
 504          if(trim($line) != ""){
 505            list($f1, $f2, $f3, $f4) = explode(":", $line);
 506            if($f3 >= $min && $f3 <= $max) $gids[] = $f3;
 507          }
 508        }
 509        if(is_array($gids)){
 510          $max_gid = max($gids);
 511        } else {
 512          $max_gid = $min - 1;
 513        }
 514      }
 515  
 516      $new_id = (max($max_uid, $max_gid) + 1);
 517      if($new_id <= $max){
 518        return $new_id;
 519      } else {
 520        return false;
 521      }
 522    } else {
 523      return false;
 524    }
 525  }
 526  
 527  function rc_edit($service, $rl, $action){
 528    // $action = "on|off";
 529    global $dist_init_scripts, $dist_runlevel;
 530    if(trim($dist_runlevel) == ""){ // falls es keine runlevel gibt (FreeBSD)
 531      if($action == "on"){
 532        @symlink($dist_init_scripts."/".$service, $dist_init_scripts."/".$service.".sh");
 533      }
 534      if($action == "off"){
 535        if(is_link($dist_init_scripts."/".$service.".sh")){
 536          unlink($dist_init_scripts."/".$service.".sh");
 537        } else {
 538          exec("mv -f ".$dist_init_scripts."/".$service.".sh ".$dist_init_scripts."/".$service." &> /dev/null");
 539        }
 540      }
 541    } else { // Linux
 542      $runlevels = explode(",", $rl);
 543      foreach($runlevels as $runlevel){
 544        $runlevel = trim($runlevel);
 545        if($runlevel != "" && is_dir($dist_runlevel."/rc".$runlevel.".d")){
 546          $handle=opendir($dist_runlevel."/rc".$runlevel.".d");
 547          while($file = readdir($handle)){
 548            if($file != "." && $file != ".."){
 549              $target = @readlink($dist_runlevel."/rc".$runlevel.".d/".$file);
 550              if(strstr($file, $service) && strstr($target, $service) && substr($file,0,1) == "S") $ln_arr[$runlevel][] = $dist_runlevel."/rc".$runlevel.".d/".$file;
 551            }
 552          }
 553          closedir($handle);
 554        }
 555        if($action == "on"){
 556          if(!is_array($ln_arr[$runlevel])) @symlink($dist_init_scripts."/".$service, $dist_runlevel."/rc".$runlevel.".d/S99".$service);
 557        }
 558        if($action == "off"){
 559          if(is_array($ln_arr[$runlevel])){
 560            foreach($ln_arr[$runlevel] as $link){
 561              unlink($link);
 562            }
 563          }
 564        }
 565      }
 566    }
 567  }
 568  
 569  function daemon_init($daemon, $action){
 570    // $action = start|stop|restart|reload
 571    global $dist, $dist_init_scripts, $FILE;
 572    if(!strstr($dist, "freebsd")){
 573      caselog("$dist_init_scripts/$daemon $action &> /dev/null", $FILE, __LINE__);
 574    } else {
 575      if(is_file($dist_init_scripts."/".$daemon.".sh") || is_link($dist_init_scripts."/".$daemon.".sh")){
 576        if($action == "start" || $action == "stop"){
 577          caselog($dist_init_scripts."/".$daemon.".sh ".$action." &> /dev/null", $FILE, __LINE__);
 578        } else {
 579          caselog($dist_init_scripts."/".$daemon.".sh stop &> /dev/null", $FILE, __LINE__);
 580          sleep(3);
 581          caselog($dist_init_scripts."/".$daemon.".sh start &> /dev/null", $FILE, __LINE__);
 582        }
 583      } else {
 584        if(is_file($dist_init_scripts."/".$daemon) || is_link($dist_init_scripts."/".$daemon)){
 585          if($action == "start" || $action == "stop"){
 586            caselog($dist_init_scripts."/".$daemon." ".$action." &> /dev/null", $FILE, __LINE__);
 587          } else {
 588            caselog($dist_init_scripts."/".$daemon." stop &> /dev/null", $FILE, __LINE__);
 589            sleep(3);
 590            caselog($dist_init_scripts."/".$daemon." start &> /dev/null", $FILE, __LINE__);
 591          }
 592        } else {
 593          if(is_file("/etc/rc.d/".$daemon) || is_link("/etc/rc.d/".$daemon)){
 594            if($action == "start" || $action == "stop"){
 595              caselog("/etc/rc.d/".$daemon." ".$action." &> /dev/null", $FILE, __LINE__);
 596            } else {
 597              caselog("/etc/rc.d/".$daemon." stop &> /dev/null", $FILE, __LINE__);
 598              sleep(3);
 599              caselog("/etc/rc.d/".$daemon." start &> /dev/null", $FILE, __LINE__);
 600            }
 601          }
 602        }
 603      }
 604    }
 605  }
 606  /////////////////////////////////
 607  /////////////////////////////////
 608  /////////////////////////////////
 609  
 610  $root_gruppe = root_group();
 611  $directory_mode = '0755';
 612  
 613  $admispconfig_uid = $admispconfig_gid = find_uid_gid(100, 3000);
 614  if(!is_group("admispconfig")) phpcaselog(addgroup("admispconfig", $admispconfig_gid, "admispconfig"), 'create group admispconfig', $FILE, __LINE__);
 615  if(!is_user("admispconfig")) phpcaselog(adduser("admispconfig", $admispconfig_uid, $admispconfig_gid, "Administrator ISPConfig", "/home/admispconfig", "/bin/bash", '!'), 'create user admispconfig', $FILE, __LINE__);
 616  
 617  /////////// Symlink von /var/spool/mail auf /var/mail ////////////
 618  if(is_dir("/var/mail") && !file_exists("/var/spool/mail")){
 619    phpcaselog(@symlink("/var/mail", "/var/spool/mail"), 'create symlink from /var/spool/mail to /var/mail', $FILE, __LINE__);
 620  }
 621  /////////// Symlink von /var/spool/mail auf /var/mail ENDE ////////////
 622  
 623  if($dist == "Trustix30") {
 624    /////////// Trustix 30 ///////////
 625    if(is_dir("/home/mail") && !is_file("/home/mail/admispconfig")){
 626      phpcaselog(touch("/home/mail/admispconfig"), "create /home/mail/admispconfig", $FILE, __LINE__);
 627      caselog("chown admispconfig:mail /home/mail/admispconfig &> /dev/null", $FILE, __LINE__);
 628      caselog("chmod 600 /home/mail/admispconfig", $FILE, __LINE__);
 629    }
 630    elseif(is_dir("/var/spool/postfix") && !is_file("/var/spool/postfix/admispconfig")){
 631      phpcaselog(touch("/var/spool/postfix/admispconfig"), "create /var/spool/postfix/admispconfig", $FILE, __LINE__);
 632      caselog("chown admispconfig:mail /var/spool/postfix/admispconfig &> /dev/null", $FILE, __LINE__);
 633      caselog("chmod 600 /var/spool/postfix/admispconfig", $FILE, __LINE__);
 634    }
 635    /////////// Trustix 30 end ///////////
 636  } else {
 637    if(!is_file("/var/spool/mail/admispconfig")){
 638      phpcaselog(touch("/var/spool/mail/admispconfig"), "create /var/spool/mail/admispconfig", $FILE, __LINE__);
 639      caselog("chown admispconfig:mail /var/spool/mail/admispconfig &> /dev/null", $FILE, __LINE__);
 640      caselog("chmod 600 /var/spool/mail/admispconfig", $FILE, __LINE__);
 641    }
 642  }
 643  
 644  if($install_art == "upgrade"){
 645    include("config.inc.php");
 646    $old_version = str_pad(str_replace(".", "", $go_info["server"]["version"]), 4, "0", STR_PAD_RIGHT);
 647    $server_url = $go_info["server"]["server_url"];
 648    $server_ispconfigprotocol = parse_url($server_url);
 649    $server_ispconfigprotocol = $server_ispconfigprotocol["scheme"];
 650    $url = str_replace(":81", "", $server_url);
 651    $db_server = $go_info["server"]["db_host"];
 652    $db_user = $go_info["server"]["db_user"];
 653    $db_password = $go_info["server"]["db_password"];
 654    $new_db = $go_info["server"]["db_name"];
 655    $link = mysql_connect($db_server, $db_user, $db_password)
 656      or error("Could not connect to db ".$new_db);
 657    echo "Connected successfully to db ".$new_db."\n";
 658    ilog("Connected successfully to db ".$new_db);
 659    mysql_select_db($new_db, $link);
 660    ///////////// admispconfig zum Mitglied aller Webgruppen machen /////////
 661    $conn = mysql_query("SELECT * FROM isp_isp_web");
 662    while($row = mysql_fetch_array($conn)){
 663      $web_groups[] = "web".$row["doc_id"];
 664    }
 665    if(is_array($web_groups)){
 666      $group_file = rf($dist_group);
 667      $group_file_lines = explode("\n", $group_file);
 668      foreach($group_file_lines as $group_file_line){
 669        list($group_name,$group_x,$group_id,$group_users) = explode(":",$group_file_line);
 670        if(in_array($group_name, $web_groups)){
 671          $group_users = explode(",", str_replace(" ", "", $group_users));
 672          if(!in_array("admispconfig", $group_users)){
 673            $group_users[] = "admispconfig";
 674          }
 675          $group_users = implode(",", $group_users);
 676          if(substr($group_users,0,1) == ",") $group_users = substr($group_users,1);
 677          $group_file_line = $group_name.":".$group_x.":".$group_id.":".$group_users;
 678        }
 679        $new_group_file[] = $group_file_line;
 680      }
 681      $new_group_file = implode("\n", $new_group_file);
 682      wf($dist_group, $new_group_file);
 683      remove_blank_lines($dist_group);
 684    }
 685    //////////// admispconfig zum Mitglied aller Webgruppen machen ENDE ////////
 686    $conn = mysql_query("SELECT * FROM isp_server WHERE doc_id = '1'");
 687    if($row = mysql_fetch_array($conn)){
 688      $ip = $row["server_ip"];
 689      $server_host = $row["server_host"];
 690      $server_domain = $row["server_domain"];
 691      $translate = array(
 692                         "dist" => "dist",
 693                         "dist_init_scripts" => "dist_init_scripts",
 694                         "server_ftp_typ" => "dist_ftp",
 695                         "server_proftpd_conf_datei" => "dist_ftp_conf",
 696                         "dist_ftp_version" => "dist_ftp_version",
 697                         "server_proftpd_log" => "dist_ftp_log",
 698                         "dist_pop3" => "dist_pop3",
 699                         "dist_pop3_version" => "dist_pop3_version",
 700                         "dist_runlevel" => "dist_runlevel",
 701                         "dist_smrsh" => "dist_smrsh",
 702                         "dist_shells" => "dist_shells",
 703                         "server_httpd_user" => "dist_http_user",
 704                         "server_httpd_group" => "dist_http_group",
 705                         "server_mta" => "dist_mail",
 706                         "dist_mail_log" => "dist_mail_log",
 707                         "server_sendmail_virtuser_datei" => "dist_mail_virtusertable",
 708                         "server_sendmail_cw" => "dist_mail_local_host_names",
 709                         "server_bind_user" => "dist_bind_user",
 710                         "server_bind_group" => "dist_bind_group",
 711                         "server_bind_named_conf" => "dist_bind_conf",
 712                         "server_bind_zonefile_dir" => "dist_bind_dir",
 713                         "dist_bind_pidfile" => "dist_bind_pidfile",
 714                         "dist_bind_hintfile" => "dist_bind_hintfile",
 715                         "dist_bind_localfile" => "dist_bind_localfile",
 716                         "passwd_datei" => "dist_passwd",
 717                         "shadow_datei" => "dist_shadow",
 718                         "group_datei" => "dist_group",
 719                         "dist_cron_daemon" => "dist_cron_daemon",
 720                         "dist_cron_tab" => "dist_cron_tab",
 721                         "dist_mysql_group" => "dist_mysql_group",
 722                         "dist_httpd_daemon" => "dist_httpd_daemon",
 723                         "server_path_httpd_conf" => "dist_httpd_dir",
 724                         "server_ip" => "dist_ip",
 725                         "server_path_httpd_root" => "dist_path_httpd_root",
 726                         "dist_httpd_conf" => "dist_httpd_conf"
 727                         );
 728      foreach($row as $key => $value){
 729        if(isset($translate[$key])){
 730          $dist_append = $translate[$key]."=".$value." ##\nexport ".$translate[$key]."\n";
 731          af("/root/ispconfig/dist.info", $dist_append);
 732        }
 733      }
 734    }
 735    $tables = mysql_list_tables($new_db);
 736  
 737    while (list($table_name) = mysql_fetch_array($tables)) {
 738      $old_tables_array[] = $table_name;
 739    }
 740    unset($tables);
 741  
 742    if(empty($db_password)){
 743      caselog("mysqldump -h $db_server -u $db_user -c -t --add-drop-table --add-locks --all --quick --lock-tables $new_db > existing_db.sql", $FILE, __LINE__, "dumped old db to file existing_db.sql","could not dump old db to file existing_db.sql");
 744    } else {
 745      caselog("mysqldump -h $db_server -u $db_user -p$db_password -c -t --add-drop-table --add-locks --all --quick --lock-tables $new_db > existing_db.sql", $FILE, __LINE__,"dumped old db to file existing_db.sql","could not dump old db to file existing_db.sql");
 746    }
 747    caselog("mv -f root_ispconfig.tar.gz /tmp/root_ispconfig_".date("m_d_Y__H_i_s", $current_date).".tar.gz", $FILE, __LINE__,"moved root_ispconfig.tar.gz to /tmp/root_ispconfig_".date("m_d_Y__H_i_s", $current_date).".tar.gz","could not move root_ispconfig.tar.gz to /tmp/root_ispconfig_".date("m_d_Y__H_i_s", $current_date).".tar.gz");
 748    caselog("mv -f home_admispconfig.tar.gz /tmp/home_admispconfig_".date("m_d_Y__H_i_s", $current_date).".tar.gz", $FILE, __LINE__,"moved home_admispconfig.tar.gz to /tmp/home_admispconfig_".date("m_d_Y__H_i_s", $current_date).".tar.gz","could not move home_admispconfig.tar.gz to /tmp/home_admispconfig_".date("m_d_Y__H_i_s", $current_date).".tar.gz");
 749    caselog("cp -f existing_db.sql /tmp/existing_db_".date("m_d_Y__H_i_s", $current_date).".sql", $FILE, __LINE__,"copied existing_db.sql to /tmp/existing_db_".date("m_d_Y__H_i_s", $current_date).".sql","could not copy existing_db.sql to /tmp/existing_db_".date("m_d_Y__H_i_s", $current_date).".sql");
 750  
 751    @mysql_query("DROP DATABASE ".$new_db);
 752    @mysql_query("CREATE DATABASE ".$new_db);
 753    mysql_select_db($new_db, $link);
 754    exec("chmod 444 $sql_file");
 755    if(empty($db_password)){
 756      caselog("mysql -h $db_server -u $db_user $new_db < $sql_file &> /dev/null", $FILE, __LINE__,"read in $sql_file","could not read in $sql_file");
 757      $tables = mysql_list_tables($new_db);
 758  
 759      while(list($table_name) = mysql_fetch_array($tables)){
 760        if(in_array($table_name, $old_tables_array) && $table_name != "doctype" && $table_name != "sys_dep" && $table_name != "sys_modules" && $table_name != "sys_nodes") mysql_query("DELETE FROM $table_name");
 761      }
 762      unset($tables);
 763      caselog("mysql -f -s -h $db_server -u $db_user $new_db < existing_db.sql &> /dev/null", $FILE, __LINE__,"imported existing_db.sql","could not import existing_db.sql");
 764    } else {
 765      caselog("mysql -h $db_server -u $db_user -p$db_password $new_db < $sql_file &> /dev/null", $FILE, __LINE__,"read in $sql_file","could not read in $sql_file");
 766      $tables = mysql_list_tables($new_db);
 767  
 768      while (list($table_name) = mysql_fetch_array($tables)) {
 769        if(in_array($table_name, $old_tables_array) && $table_name != "doctype" && $table_name != "sys_dep" && $table_name != "sys_modules" && $table_name != "sys_nodes") mysql_query("DELETE FROM $table_name");
 770      }
 771      unset($tables);
 772      caselog("mysql -f -s -h $db_server -u $db_user -p$db_password $new_db < existing_db.sql &> /dev/null", $FILE, __LINE__,"imported existing_db.sql","could not import existing_db.sql");
 773    }
 774    //////////// Nachträge in neuer DB machen /////////////
 775    $conn = mysql_query("SELECT * FROM sys_user WHERE doc_id > 1");
 776    while($row = mysql_fetch_array($conn)){
 777      mysql_query("INSERT INTO sys_nodes (userid,groupid,type,doctype_id,status,modul,doc_id) VALUES ('1','0','a','1','1','sys','".$row["doc_id"]."')");
 778    }
 779  
 780    $conn = mysql_query("SELECT * FROM isp_firewall WHERE doc_id > 10");
 781    while($row = mysql_fetch_array($conn)){
 782      $result = mysql_query("SELECT * FROM sys_nodes WHERE userid = '1' AND groupid = '0' AND type = 'a' AND doctype_id = '1025' AND status = '1' AND doc_id = '".$row["doc_id"]."'");
 783      $num_rows = @mysql_num_rows($result);
 784      if(!$num_rows){
 785        mysql_query("INSERT INTO sys_nodes (userid,groupid,type,doctype_id,status,modul,doc_id) VALUES ('1','0','a','1025','1','','".$row["doc_id"]."')");
 786        mysql_query("INSERT INTO sys_dep (userid,groupid,parent_doc_id,parent_doctype_id,parent_tree_id,child_doc_id,child_doctype_id,child_tree_id,status) VALUES ('1','0','1','1023','15','".$row["doc_id"]."','1025','".mysql_insert_id()."','1')");
 787      }
 788    }
 789  
 790    $conn = mysql_query("SELECT * FROM isp_monitor");
 791    while($row = mysql_fetch_array($conn)){
 792      mysql_query("UPDATE isp_monitor SET status = 'u' WHERE doc_id = '".$row["doc_id"]."'");
 793      $result = mysql_query("SELECT * FROM sys_nodes WHERE userid = '1' AND groupid = '0' AND type = 'a' AND doctype_id = '1024' AND status = '1' AND doc_id = '".$row["doc_id"]."'");
 794      $num_rows = @mysql_num_rows($result);
 795      if(!$num_rows){
 796        mysql_query("INSERT INTO sys_nodes (userid,groupid,type,doctype_id,status,modul,doc_id) VALUES ('1','0','a','1024','1','','".$row["doc_id"]."')");
 797        mysql_query("INSERT INTO sys_dep (userid,groupid,parent_doc_id,parent_doctype_id,parent_tree_id,child_doc_id,child_doctype_id,child_tree_id,status) VALUES ('1','0','1','1023','15','".$row["doc_id"]."','1024','".mysql_insert_id()."','1')");
 798      }
 799    }
 800  
 801    mysql_query("UPDATE sys_user SET modules = CONCAT(modules, ',isp_file') WHERE modules NOT LIKE '%isp_file%'");
 802    mysql_query("UPDATE sys_user SET modules = CONCAT(modules, ',isp_fakt') WHERE doc_id = '1' AND modules NOT LIKE '%isp_fakt%'");
 803    mysql_query("UPDATE sys_user SET modules = CONCAT(modules, ',help') WHERE modules NOT LIKE '%help%'");
 804    mysql_query("UPDATE isp_isp_web SET optionen_directory_index = 'index.html\nindex.htm\nindex.php\nindex.php5\nindex.php4\nindex.php3\nindex.shtml\nindex.cgi\nindex.pl\nindex.jsp\nDefault.htm\ndefault.htm' WHERE optionen_directory_index IS NULL");
 805    mysql_query("UPDATE isp_server SET server_ftp_typ = 'proftpd' WHERE server_ftp_typ = 'proftp'");
 806    mysql_query("UPDATE isp_server SET server_ftp_typ = 'vsftpd' WHERE server_ftp_typ = 'vsftp'");
 807    $conn = mysql_query("SELECT * FROM isp_traffic");
 808    while($row = mysql_fetch_array($conn)){
 809      if(empty($row["datum"])){
 810        list($traffic_monat, $traffic_jahr) = explode("/", $row["monat"]);
 811        if(substr($traffic_monat,0,1) == "0") $traffic_monat = substr($traffic_monat,1,1);
 812        $traffic_datum = mktime(0,0,0,1,$traffic_monat,$traffic_jahr);
 813        mysql_query("UPDATE isp_traffic SET datum = '$traffic_datum' WHERE doc_id = '".$row["doc_id"]."'");
 814      }
 815    }
 816  
 817    if($old_version < 1200){
 818      // Anlegen der Faktura Records
 819      $sql = "SELECT * FROM isp_nodes, isp_isp_web WHERE isp_nodes.doc_id = isp_isp_web.doc_id AND isp_nodes.doctype_id = isp_isp_web.doctype_id";
 820      $conn = mysql_query($sql);
 821  
 822      while($web = mysql_fetch_array($conn)){
 823  
 824          $web_id = $web["doc_id"];
 825          $beschreibung = $web["web_host"].".".$web["web_domain"];
 826  
 827          // Web Record hinzufügen
 828          $sql = "INSERT INTO isp_fakt_record (web_id,doc_id,doctype_id,typ,notiz) VALUES ('$web_id','$web_id','1013','Web','$beschreibung')";
 829          mysql_query($sql);
 830          // Traffic Record hinzufügen
 831          $sql = "INSERT INTO isp_fakt_record (web_id,typ,notiz) VALUES ('$web_id','Traffic','$beschreibung')";
 832          mysql_query($sql);
 833  
 834          // User zu Web holen
 835          $sql = "SELECT * FROM isp_dep, isp_isp_user WHERE isp_dep.parent_doc_id = $web_id AND isp_dep.parent_doctype_id = 1013 AND isp_dep.child_doc_id = isp_isp_user.doc_id AND isp_dep.child_doctype_id = isp_isp_user.doctype_id";
 836          $conn2 = mysql_query($sql);
 837          while($user = mysql_fetch_array($conn2)) {
 838                  $beschreibung = $user["user_username"];
 839                  $doc_id = $user["doc_id"];
 840                  $sql = "INSERT INTO isp_fakt_record (web_id,doc_id,doctype_id,typ,notiz) VALUES ('$web_id','$doc_id','1014','Email','$beschreibung')";
 841                  mysql_query($sql);
 842          }
 843      }
 844    }
 845    /*
 846    if($old_version < 2000){
 847      $conn3 = mysql_query("SELECT isp_isp_web.doc_id FROM isp_isp_web, isp_nodes WHERE isp_isp_web.doc_id = isp_nodes.doc_id AND isp_nodes.doctype_id = '1013' AND isp_isp_web.status = '' and isp_isp_web.server_id = '1' and isp_nodes.status = '1' LIMIT 0,1");
 848      while($row = mysql_fetch_array($conn3)){
 849        mysql_query("UPDATE isp_isp_web SET status = 'u' WHERE doc_id = ".$row["doc_id"]);
 850      }
 851    }
 852    */
 853    //////////// Nachträge in neuer DB machen ENDE /////////////
 854    caselog("rm -f $sql_file", $FILE, __LINE__,"deleted $sql_file","could not delete $sql_file");
 855    caselog("rm -f existing_db.sql", $FILE, __LINE__,"deleted existing_db.sql","could not delete existing_db.sql");
 856  }
 857  
 858  $httpd_configuration = rf("httpd2");
 859  
 860  list($httpd_root,$server_config_file) = explode("\n",$httpd_configuration);
 861  
 862  if(substr($server_config_file,0,1) == "/"){
 863    $httpd_conf = $server_config_file;
 864  } else {
 865    $httpd_conf = $httpd_root."/".$server_config_file;
 866  }
 867  $httpd_conf_array = explode("/", $httpd_conf);
 868  $count = sizeof($httpd_conf_array);
 869  $httpd_conf_dir = "";
 870  for($i=0; $i<$count-1; $i++){
 871    $httpd_conf_dir .= $httpd_conf_array[$i]."/";
 872  }
 873  $httpd_conf_dir = substr($httpd_conf_dir, 0, -1);
 874  
 875  if(!empty($server_host)){
 876    $server_name = $server_host.".".$server_domain;
 877  } else {
 878    $server_name = $server_domain;
 879  }
 880  if(!isset($url)) $url = $server_ispconfigprotocol."://".$server_name;
 881  
 882  
 883  $conf = rf("/root/ispconfig/httpd/conf/httpd.conf_".$server_ispconfigprotocol);
 884  $conf = str_replace("{SERVER_NAME}", $server_name, $conf);
 885  wf("/root/ispconfig/httpd/conf/httpd.conf", $conf);
 886  
 887  $conf = rf("isp/conf/forward.master");
 888  $conf = str_replace("{PROCMAIL}", $procmail, $conf);
 889  wf("isp/conf/forward.master", $conf);
 890  
 891  $conf = rf("isp/conf/named.conf.master");
 892  
 893  $conf = str_replace("{PIDFILE}", $dist_bind_pidfile, $conf);
 894  $conf = str_replace("{HINTFILE}", $dist_bind_hintfile, $conf);
 895  $conf = str_replace("{LOCALFILE}", $dist_bind_localfile, $conf);
 896  wf("isp/conf/named.conf.master", $conf);
 897  
 898  $conf = rf("ispconfig_server");
 899  $conf = str_replace("{INITDIR}", $dist_init_scripts, $conf);
 900  wf("ispconfig_server", $conf);
 901  
 902  $dist_info_add = "
 903  dist_httpd_dir=".$httpd_conf_dir." ##
 904  export dist_httpd_dir
 905  
 906  dist_ip=".$ip." ##
 907  export dist_ip
 908  ";
 909  
 910  af("/root/ispconfig/dist.info", $dist_info_add);
 911  remove_blank_lines("/root/ispconfig/dist.info");
 912  
 913  $dist_inc_content = rf("/root/ispconfig/dist.inc.php");
 914  $dist_inc_content = str_replace("?>", "", $dist_inc_content);
 915  $dist_inc_add = '
 916  $dist_httpd_dir = "'.$httpd_conf_dir.'";
 917  $dist_httpd_conf = "'.$httpd_conf.'";
 918  $dist_ip = "'.$ip.'";
 919  ?>
 920  ';
 921  
 922  wf("/root/ispconfig/dist.inc.php", $dist_inc_content.$dist_inc_add);
 923  remove_blank_lines("/root/ispconfig/dist.inc.php");
 924  
 925  ////////////////////////////////
 926  exec("cp -f uninstall /root/ispconfig");
 927  exec("chmod 700 /root/ispconfig/uninstall");
 928  exec("chown root:".$root_gruppe." /root/ispconfig/uninstall");
 929  //////////////////////////////////
 930  
 931  caselog("cp -fr scripts /root/ispconfig", $FILE, __LINE__,"copied directory scripts to /root/ispconfig/","could not copy directory scripts to /root/ispconfig/");
 932  caselog("cp -fr sv /root/ispconfig", $FILE, __LINE__,"copied directory sv to /root/ispconfig/","could not copy directory sv to /root/ispconfig/");
 933  exec("chown root:".$root_gruppe." /root/ispconfig/sv/ispconfig_wconf");
 934  exec("chmod 700 /root/ispconfig/sv/ispconfig_wconf");
 935  caselog("cp -fr isp /root/ispconfig", $FILE, __LINE__,"copied directory isp to /root/ispconfig/","could not copy directory isp to /root/ispconfig/");
 936  caselog("cp -f cronolog /root/ispconfig", $FILE, __LINE__,"copied cronolog to /root/ispconfig/","could not copy cronolog to /root/ispconfig/");
 937  caselog("cp -f cronosplit /root/ispconfig", $FILE, __LINE__,"copied cronosplit to /root/ispconfig/","could not copy cronosplit to /root/ispconfig/");
 938  exec("chmod 755 /root/ispconfig/cronolog");
 939  exec("chmod 755 /root/ispconfig/cronosplit");
 940  
 941  mkdirs("/root/ispconfig/standard_cgis");
 942  mkdirs("/root/ispconfig/standard_cgis/cgi-bin");
 943  mkdirs("/root/ispconfig/standard_cgis/web");
 944  
 945  caselog("cp -f ispconfig_server $dist_init_scripts", $FILE, __LINE__,"copied ispconfig_server to $dist_init_scripts","could not copy ispconfig_server to $dist_init_scripts");
 946  exec("chown root:$root_gruppe $dist_init_scripts/ispconfig_server");
 947  exec("chmod 700 $dist_init_scripts/ispconfig_server");
 948  rc_edit("ispconfig_server", "2,3,5", "on");
 949  
 950  if(!is_dir($pfad)) mkdir($pfad, octdec($directory_mode));
 951  
 952  $conf = rf("mailstats/.forward");
 953  $conf = str_replace("{PROCMAIL}", $procmail, $conf);
 954  wf($pfad."/.forward", $conf);
 955  
 956  exec("cp -f mailstats/.procmailrc $pfad");
 957  mkdirs($pfad."/mailstats");
 958  mkdirs($pfad."/ispconfig");
 959  caselog("cp -fr ispconfig/* $pfad/ispconfig/", $FILE, __LINE__,"copied directory ispconfig to $pfad/ispconfig","could not copy directory ispconfig to $pfad/ispconfig");
 960  caselog("chown -R admispconfig:admispconfig $pfad", $FILE, __LINE__);
 961  exec("rm -fr ispconfig");
 962  exec("chmod -R 755 $pfad");
 963  caselog("chown -R admispconfig:$dist_mysql_group $pfad/ispconfig/backup", $FILE, __LINE__);
 964  caselog("chmod -R 770 $pfad/ispconfig/backup", $FILE, __LINE__);
 965  exec("chmod 700 $pfad/ispconfig/tools/tcpserver/ispconfig_tcpserver");
 966  exec("chown root:$root_gruppe $pfad/ispconfig/tools/tcpserver/ispconfig_tcpserver");
 967  
 968  if($dist_smrsh != "" && $dist_mail == "sendmail"){
 969    if(!is_link($dist_smrsh."/procmail")) phpcaselog(@symlink($procmail, $dist_smrsh."/procmail"), 'create symlink', $FILE, __LINE__);
 970  }
 971  
 972  if($install_art == "install"){
 973    $bin_bash = realpath("/bin/bash");
 974    $shells = no_comments($dist_shells);
 975    if(!strstr($shells, $bin_bash)) af($dist_shells, "\n".$bin_bash."\n");
 976    remove_blank_lines($dist_shells);
 977  
 978    $bin_false = realpath("/bin/false");
 979    $shells = no_comments($dist_shells);
 980    if(!strstr($shells, $bin_false)) af($dist_shells, "\n".$bin_false."\n");
 981    remove_blank_lines($dist_shells);
 982  
 983    #####################
 984    $sendmail_shell = "/SENDMAIL/ANY/SHELL/\n";
 985    $shells = no_comments($dist_shells);
 986    if(!strstr($shells, $sendmail_shell)) af($dist_shells, "\n".$sendmail_shell);
 987    remove_blank_lines($dist_shells);
 988    ######################
 989  }
 990  
 991  $conf = rf("ip_addresses");
 992  $ip_addresses = explode("\n", $conf);
 993  
 994  if($dist_ftp == "proftpd"){
 995    $default_root = "DefaultRoot ~";
 996    caselog("cp -f $dist_ftp_conf $dist_ftp_conf.orig", $FILE, __LINE__);
 997    $proftp = rf($dist_ftp_conf);
 998  
 999    $fp = fopen ($dist_ftp_conf, "w");
1000    $proftp_array = explode("\n", $proftp);
1001    foreach($proftp_array as $key => $val){
1002      if(strstr($val, $default_root)) $val = $default_root;
1003      fwrite($fp,$val."\n");
1004    }
1005    if(!strstr($proftp,$default_root)) fwrite($fp,$default_root."\n");
1006    fclose($fp);
1007    if(!strstr($proftp,"Include /etc/proftpd_ispconfig.conf")){
1008      af($dist_ftp_conf, "\nInclude /etc/proftpd_ispconfig.conf");
1009    }
1010    if(!is_file("/etc/proftpd_ispconfig.conf")) phpcaselog(touch("/etc/proftpd_ispconfig.conf"), 'create /etc/proftpd_ispconfig.conf', $FILE, __LINE__);
1011  }
1012  
1013  if($dist_ftp == "vsftpd"){
1014    caselog("cp -f ispconfig_tcpserver $dist_init_scripts", $FILE, __LINE__);
1015    caselog("chown root:$root_gruppe $dist_init_scripts/ispconfig_tcpserver", $FILE, __LINE__);
1016    caselog("chmod 700 $dist_init_scripts/ispconfig_tcpserver", $FILE, __LINE__);
1017    rc_edit("ispconfig_tcpserver", "2,3,5", "on");
1018  
1019    foreach($ip_addresses as $ip_address){
1020      if($ip_address != ""){
1021        if(!is_file("/etc/vsftpd_".$ip_address.".conf")) exec("cp -f vsftpd.conf /etc/vsftpd_".$ip_address.".conf");
1022      }
1023    }
1024    if($dist_ftp_version == "inetd"){
1025      caselog("mv -f /etc/inetd.conf /etc/inetd.conf.backup_".date("m_d_Y__H_i_s", $current_date)." &> /dev/null", $FILE, __LINE__);
1026      exec("cat /etc/inetd.conf.backup_".date("m_d_Y__H_i_s", $current_date)." | grep -v vsftpd > /etc/inetd.conf");
1027      daemon_init($dist_ftp_version, "restart");
1028    }
1029    if($dist_ftp_version == "xinetd"){
1030      if(is_file("/etc/xinetd.conf")) edit_xinetd_conf("vsftpd");
1031      if(is_file("/etc/xinetd.d/vsftpd")) caselog("mv -f /etc/xinetd.d/vsftpd /etc/vsftpd_xinetd.backup_".date("m_d_Y__H_i_s", $current_date)." &> /dev/null", $FILE, __LINE__);
1032      daemon_init($dist_ftp_version, "restart");
1033    }
1034    if($dist_ftp_version == "standalone"){
1035      daemon_init($dist_ftp, "stop");
1036      rc_edit($dist_ftp, "2,3,5", "off");
1037    }
1038    $vsftpd_change = rf("/root/ispconfig/dist.inc.php");
1039    $vsftpd_change = str_replace("\$dist_ftp_version = \"".$dist_ftp_version."\";", "\$dist_ftp_version = \"ispconfig_tcpserver\";", $vsftpd_change);
1040    wf("/root/ispconfig/dist.inc.php", $vsftpd_change);
1041  
1042    $vsftpd_change = rf("/root/ispconfig/dist.info");
1043    $vsftpd_change = str_replace("dist_ftp_version=".$dist_ftp_version." ##", "dist_ftp_version=ispconfig_tcpserver ##", $vsftpd_change);
1044    wf("/root/ispconfig/dist.info", $vsftpd_change);
1045    $vsftpd_change = NULL;
1046    $dist_ftp_version = "ispconfig_tcpserver";
1047  }
1048  
1049  if(isset($dist_path_httpd_root) && $dist_path_httpd_root != ""){
1050    if(!is_dir($dist_path_httpd_root) && !is_link($dist_path_httpd_root)) mkdirs($dist_path_httpd_root);
1051  }
1052  
1053  if($install_art == "install"){
1054    $link = mysql_connect($db_server, $db_user, $db_password)
1055      or error("Could not connect to MySQL server");
1056    echo "Connected successfully to MySQL server\n";
1057    ilog("Connected successfully to MySQL server");
1058    $db_list = mysql_list_dbs();
1059    $i = 0;
1060    $cnt = mysql_num_rows($db_list);
1061    while ($i < $cnt) {
1062      if(mysql_db_name($db_list, $i) == $new_db){
1063        $new_db_exists = 1;
1064        $i = $cnt;
1065      }
1066      $i++;
1067    }
1068    if(!$new_db_exists){
1069      mysql_query("CREATE DATABASE ".$new_db);
1070      mysql_select_db($new_db, $link);
1071      exec("chmod 444 $sql_file");
1072      if(empty($db_password)){
1073        caselog("mysql -h $db_server -u $db_user $new_db < $sql_file", $FILE, __LINE__,"read in $sql_file","could not read in $sql_file");
1074      } else {
1075        caselog("mysql -h $db_server -u $db_user -p$db_password $new_db < $sql_file", $FILE, __LINE__,"read in $sql_file","could not read in $sql_file");
1076      }
1077      caselog("rm -f $sql_file", $FILE, __LINE__);
1078  
1079      mysql_query("INSERT INTO isp_server_ip VALUES (1, 1, '$ip')");
1080  
1081      foreach($ip_addresses as $ip_address){
1082        if($ip_address != "127.0.0.1" && $ip_address != $ip && $ip_address != ""){
1083          mysql_query("INSERT INTO isp_server_ip (server_id, server_ip) VALUES('1', '$ip_address')");
1084          $server_ip_liste .= $ip_address."\n";
1085        }
1086      }
1087      $server_ip_liste = substr($server_ip_liste,0,-1);
1088      unlink("ip_addresses");
1089  
1090      if(substr($httpd_conf_dir,-1) == "/") $httpd_conf_dir = substr($httpd_conf_dir,0,-1);
1091      if(substr($dist_path_httpd_root,-1) == "/") $dist_path_httpd_root = substr($dist_path_httpd_root,0,-1);
1092      if(substr($dist_bind_dir,-1) == "/") $dist_bind_dir = substr($dist_bind_dir,0,-1);
1093      if(substr($dist_init_scripts,-1) == "/") $dist_init_scripts = substr($dist_init_scripts,0,-1);
1094      if(substr($dist_runlevel,-1) == "/") $dist_runlevel = substr($dist_runlevel,0,-1);
1095      if(substr($dist_smrsh,-1) == "/") $dist_smrsh = substr($dist_smrsh,0,-1);
1096  
1097      if(!is_link($httpd_conf_dir)) $httpd_conf_dir = realpath($httpd_conf_dir);
1098      if(!is_link($dist_path_httpd_root)) $dist_path_httpd_root = realpath($dist_path_httpd_root);
1099      if(!is_link($dist_bind_dir)) $dist_bind_dir = realpath($dist_bind_dir);
1100      if(!is_link($dist_init_scripts)) $dist_init_scripts = realpath($dist_init_scripts);
1101      if(!is_link($dist_runlevel)) $dist_runlevel = realpath($dist_runlevel);
1102      if(!is_link($dist_smrsh)) $dist_smrsh = realpath($dist_smrsh);
1103  
1104      mysql_query("INSERT INTO isp_server (doc_id, doctype_id, server_host, server_domain, server_ip, server_netzmaske, server_sprache, server_db_type, server_db_user, server_db_passwort, server_path_httpd_conf, server_path_httpd_root, server_httpd_user, server_httpd_group, server_path_frontpage, server_path_httpd_error, server_name, server_mta, server_sendmail_virtuser_datei, server_sendmail_cw, server_ftp_typ, server_proftpd_conf_datei, server_proftpd_log, server_bind_user, server_bind_group, server_bind_named_conf, server_bind_zonefile_dir, userid_von, groupid_von, passwd_datei, group_datei, server_ipliste, shadow_datei, server_bind_ns1_default, server_bind_ns2_default, server_path_httpd_log, server_soap_ip, server_soap_port, server_soap_encoding, server_admin_email, server_enable_frontpage, server_bind_standard_mx, server_bind_adminmail_default, server_mail_log_save, server_ftp_log_save, server_httpd_suexec, dist, dist_init_scripts, dist_runlevel, dist_smrsh, dist_shells, dist_bind_init_script, dist_bind_pidfile, dist_bind_hintfile, dist_bind_localfile, dist_cron_daemon, dist_cron_tab, dist_mysql_group, dist_httpd_daemon, dist_pop3, dist_pop3_version, dist_ftp_version, dist_httpd_conf, dist_mail_log) VALUES (1, 1010, '$server_host', '$server_domain', '$ip', '255.255.255.0', 'de', 'mysql', '', '', '$httpd_conf_dir', '$dist_path_httpd_root', '$dist_http_user', '$dist_http_group', '/usr/local/frontpage/version5.0/bin/owsadm.exe', '".$dist_path_httpd_root."/error', 'Server 1', '$dist_mail', '$dist_mail_virtusertable', '$dist_mail_local_host_names', '$dist_ftp', '$dist_ftp_conf', '$dist_ftp_log', '$dist_bind_user', '$dist_bind_group', '$dist_bind_conf', '$dist_bind_dir', '10000', '10000', '$dist_passwd', '$dist_group', '$server_ip_liste', '$dist_shadow', '$server_name', '$server_name', '/var/log/httpd/ispconfig_access_log', '', '', '', 'root@localhost', '0', '0', 'root@localhost', '0', '0', '0', '$dist', '$dist_init_scripts', '$dist_runlevel', '$dist_smrsh', '$dist_shells', '$dist_bind_init_script', '$dist_bind_pidfile', '$dist_bind_hintfile', '$dist_bind_localfile', '$dist_cron_daemon', '$dist_cron_tab', '$dist_mysql_group', '$dist_httpd_daemon', '$dist_pop3', '$dist_pop3_version', '$dist_ftp_version', '$httpd_conf', '$dist_mail_log')");
1105  
1106  
1107    } else {
1108      echo "Es ist schon eine Datenbank mit dem Namen ".$new_db." vorhanden!\n";
1109      ilog("db ".$new_db." already exists!");
1110    }
1111  } else {
1112    $dist_httpd_conf = $httpd_conf;
1113    $conn = mysql_query("SELECT * FROM isp_server WHERE doc_id = '1'");
1114    if($row = mysql_fetch_array($conn)){
1115      foreach($row as $key => $value){
1116        if((!isset($value) || $value == "") && isset($$key)){
1117          mysql_query("UPDATE isp_server SET $key = '".$$key."' WHERE doc_id = '1'");
1118        }
1119      }
1120    }
1121    mysql_query("ALTER TABLE sys_user CHANGE passwort passwort VARCHAR( 255 ), CHANGE pwcl pwcl VARCHAR( 255 )");
1122  }
1123  
1124  $conf_datei = $pfad."/ispconfig/lib/config.inc.php";
1125  $conf = rf($conf_datei_temp);
1126  
1127  $conf = str_replace("{DB_SERVER}", $db_server, $conf);
1128  $conf = str_replace("{DB_USER}", $db_user, $conf);
1129  $conf = str_replace("{DB_PASSWORD}", $db_password, $conf);
1130  $conf = str_replace("{DB_NAME}", $new_db, $conf);
1131  $conf = str_replace("{URL}", $url, $conf);
1132  $conf = str_replace("{PROTOCOL}", $server_ispconfigprotocol."://", $conf);
1133  $conf = str_replace("{LANG}", $lang, $conf);
1134  if($install_art == "upgrade"){
1135    if($old_version < 2000){
1136      $conf = str_replace('$go_info["theme"]["page"]["nav_color"] = "025CCA";', '$go_info["theme"]["page"]["nav_color"] = "E0E0E0";', $conf);
1137    }
1138  }
1139  wf($conf_datei, $conf);
1140  caselog("chmod 600 $conf_datei", $FILE, __LINE__);
1141  caselog("chown admispconfig:admispconfig $conf_datei", $FILE, __LINE__);
1142  
1143  if($install_art == "install"){
1144    $vhost = "
1145  <Directory /var/www/sharedip>
1146      Options +Includes -Indexes
1147      AllowOverride None
1148      AllowOverride Indexes AuthConfig Limit FileInfo
1149      Order allow,deny
1150      Allow from all
1151      <Files ~ \"^\\.ht\">
1152      Deny from all
1153      </Files>
1154  </Directory>
1155  
1156  ###############ispconfig_log###############
1157  LogFormat \"%v||||%b||||%h %l %u %t \\\"%r\\\" %>s %b \\\"%{Referer}i\\\" \\\"%{User-Agent}i\\\"\" combined_ispconfig
1158  CustomLog \"|/root/ispconfig/cronolog --symlink=/var/log/httpd/ispconfig_access_log /var/log/httpd/ispconfig_access_log_%Y_%m_%d\" combined_ispconfig
1159  
1160  <Directory ".$dist_path_httpd_root."/*/web>
1161      Options +Includes -Indexes
1162      AllowOverride None
1163      AllowOverride Indexes AuthConfig Limit FileInfo
1164      Order allow,deny
1165      Allow from all
1166      <Files ~ \"^\\.ht\">
1167      Deny from all
1168      </Files>
1169  </Directory>
1170  
1171  <Directory ".$dist_path_httpd_root."/*/user/*/web>
1172      Options +Includes -Indexes
1173      AllowOverride None
1174      AllowOverride Indexes AuthConfig Limit FileInfo
1175      Order allow,deny
1176      Allow from all
1177      <Files ~ \"^\\.ht\">
1178      Deny from all
1179      </Files>
1180  </Directory>
1181  
1182  <Directory ".$dist_path_httpd_root."/*/cgi-bin>
1183      Options ExecCGI -Indexes
1184      AllowOverride None
1185      AllowOverride Indexes AuthConfig Limit FileInfo
1186      Order allow,deny
1187      Allow from all
1188      <Files ~ \"^\\.ht\">
1189      Deny from all
1190      </Files>
1191  </Directory>
1192  
1193  Include ".$httpd_conf_dir."/vhosts/Vhosts_ispconfig.conf
1194  
1195  ";
1196  
1197    caselog("cp -f $httpd_conf $httpd_conf.orig", $FILE, __LINE__);
1198    af($httpd_conf, $vhost);
1199  
1200    ///////// Auskommentieren: PHP, SSI, CGI ///////////////
1201    if($includes = find_includes($httpd_conf)){
1202      $mime_types = trim(shell_exec('httpd -V | awk -F"\"" \'$1==" -D TYPES_CONFIG_FILE="{print $2}\''));
1203      if(empty($mime_types)) $mime_types = trim(shell_exec('httpd -V | awk -F"\"" \'$1==" -D AP_TYPES_CONFIG_FILE="{print $2}\''));
1204      if(!empty($mime_types)){
1205        if(substr($mime_types,0,1) != "/"){
1206          $mime_types = $httpd_root."/".$mime_types;
1207        }
1208        $mime_types = realpath($mime_types);
1209        if(is_file($mime_types)) $includes[] = $mime_types;
1210      }
1211      if($mime_types != '/etc/mime.types'){
1212        if(is_file('/etc/mime.types')) $includes[] = '/etc/mime.types';
1213      }
1214      foreach($includes as $include){
1215        if(!strstr($include, "Vhosts_ispconfig.conf")){
1216          exec("cp -f ".$include." ".$include.".".$datum);
1217          comment_out($include, "AddType application/x-httpd-php,SetOutputFilter,SetInputFilter,AddType text/html .shtml,AddHandler server-parsed .shtml,AddOutputFilter INCLUDES .shtml,AddHandler cgi-script,application/x-httpd-php,application/x-perl,application/x-php,AddHandler php5-script .php,AddType text/html .php,text/x-perl");
1218        }
1219      }
1220    }
1221    ///////// Auskommentieren ENDE /////////////
1222  }
1223  
1224  if($install_art == "upgrade"){
1225    if($old_version < 2000){
1226      wf($httpd_conf, str_replace('CustomLog /var/log/httpd/ispconfig_access_log combined_ispconfig', 'CustomLog "|/root/ispconfig/cronolog --symlink=/var/log/httpd/ispconfig_access_log /var/log/httpd/ispconfig_access_log_%Y_%m_%d" combined_ispconfig', rf($httpd_conf)));
1227    }
1228  }
1229  
1230  $vhosts_dir = $httpd_conf_dir."/vhosts";
1231  if(!is_dir($vhosts_dir)) mkdir($vhosts_dir, octdec($directory_mode));
1232  exec("chmod 755 $vhosts_dir");
1233  phpcaselog(touch($vhosts_dir."/Vhosts_ispconfig.conf"), "create ".$vhosts_dir."/Vhosts_ispconfig.conf", $FILE, __LINE__);
1234  if(!is_dir("/var/log/httpd")) mkdir("/var/log/httpd", octdec($directory_mode));
1235  phpcaselog(touch("/var/log/httpd/ispconfig_access_log"), "create /var/log/httpd/ispconfig_access_log", $FILE, __LINE__);
1236  exec("chmod 644 /var/log/httpd/ispconfig_access_log");
1237  
1238  //////////// Cron Jobs //////////////////
1239  if($dist == "Trustix30"){
1240  $cron_tsl_file = "/home/fcronisp";
1241  if(is_file($cron_tsl_file)) unlink($cron_tsl_file);
1242      exec("$dist_cron_tab -l > $cron_tsl_file");
1243      exec("chmod 777 $cron_tsl_file");
1244  $cron_job_tsl = array('30 00 * * * /root/ispconfig/php/php /root/ispconfig/scripts/shell/logs.php &> /dev/null','59 23 * * * /root/ispconfig/php/php /root/ispconfig/scripts/shell/ftp_logs.php &> /dev/null','59 23 * * * /root/ispconfig/php/php /root/ispconfig/scripts/shell/mail_logs.php &> /dev/null','59 23 * * * /root/ispconfig/php/php /root/ispconfig/scripts/shell/cleanup.php &> /dev/null','0 4 * * * /root/ispconfig/php/php /root/ispconfig/scripts/shell/webalizer.php &> /dev/null','0,30 * * * * /root/ispconfig/php/php /root/ispconfig/scripts/shell/check_services.php &> /dev/null','15 3,15 * * * /root/ispconfig/php/php /root/ispconfig/scripts/shell/quota_msg.php &> /dev/null','40 00 * * * /root/ispconfig/php/php /root/ispconfig/scripts/shell/traffic.php &> /dev/null','05 02 * * * /root/ispconfig/php/php /root/ispconfig/scripts/shell/backup.php &> /dev/null');
1245  foreach($cron_job_tsl as $cron_tsl){
1246      aftsl($cron_tsl_file, "\n".$cron_tsl."\n");
1247    }
1248    exec("$dist_cron_tab $cron_tsl_file");
1249    if(is_file($cron_tsl_file)) unlink($cron_tsl_file);
1250  }
1251  else{
1252  if(is_file($dist_cron_tab)){
1253    $existing_cron_jobs = rf($dist_cron_tab);
1254  } else {
1255    $existing_cron_jobs = "";
1256  }
1257  $cron_jobs = array('30 00 * * * /root/ispconfig/php/php /root/ispconfig/scripts/shell/logs.php &> /dev/null','59 23 * * * /root/ispconfig/php/php /root/ispconfig/scripts/shell/ftp_logs.php &> /dev/null','59 23 * * * /root/ispconfig/php/php /root/ispconfig/scripts/shell/mail_logs.php &> /dev/null','59 23 * * * /root/ispconfig/php/php /root/ispconfig/scripts/shell/cleanup.php &> /dev/null','0 4 * * * /root/ispconfig/php/php /root/ispconfig/scripts/shell/webalizer.php &> /dev/null','0,30 * * * * /root/ispconfig/php/php /root/ispconfig/scripts/shell/check_services.php &> /dev/null','15 3,15 * * * /root/ispconfig/php/php /root/ispconfig/scripts/shell/quota_msg.php &> /dev/null','40 00 * * * /root/ispconfig/php/php /root/ispconfig/scripts/shell/traffic.php &> /dev/null','05 02 * * * /root/ispconfig/php/php /root/ispconfig/scripts/shell/backup.php &> /dev/null');
1258  foreach($cron_jobs as $cron_job){
1259    if(!strstr($existing_cron_jobs, $cron_job)){
1260      af($dist_cron_tab, "\n".$cron_job."\n");
1261    }
1262  }
1263  if($install_art == "upgrade"){
1264    if($old_version < 2000){
1265      wf($dist_cron_tab, str_replace('59 23 * * * /root/ispconfig/php/php /root/ispconfig/scripts/shell/logs.php &> /dev/null', '', rf($dist_cron_tab)));
1266    }
1267  }
1268  if(is_file($dist_cron_tab)) remove_blank_lines($dist_cron_tab);
1269  }
1270  daemon_init($dist_cron_daemon, "restart");
1271  ////////// Cron Jobs ENDE ///////////////
1272  
1273  if($install_art == "install"){
1274    exec("cat $dist_passwd | cut -f1 -d: > $pfad/ispconfig/users");
1275  } else {
1276    exec("cp -f users $pfad/ispconfig");
1277  }
1278  
1279  if($install_art == "install"){
1280    wf($pfad."/ispconfig/adminmail.txt", "root@localhost");
1281  } else {
1282    caselog("cp -f adminmail.txt $pfad/ispconfig", $FILE, __LINE__);
1283  }
1284  exec("chown admispconfig:admispconfig ".$pfad."/ispconfig/adminmail.txt");
1285  exec("chmod 644 ".$pfad."/ispconfig/adminmail.txt");
1286  
1287  //////////////// POSTFIX //////////////////////
1288  if($dist_mail == "postfix"){
1289    $pf_main_cf = "/etc/postfix/main.cf";
1290    caselog("cp -f $pf_main_cf $pf_main_cf.orig", $FILE, __LINE__);
1291    $postfix_main_cf = no_comments($pf_main_cf);
1292    if(strstr($postfix_main_cf,"virtual_maps = hash:$dist_mail_virtusertable")){
1293      ilog("virtusertable entry already in $pf_main_cf");
1294    } else {
1295      wf($pf_main_cf, str_replace("virtual_maps", "#virtual_maps", rf($pf_main_cf)));
1296      af($pf_main_cf, "\nvirtual_maps = hash:$dist_mail_virtusertable\n");
1297      ilog("created virtusertable entry in $pf_main_cf");
1298      if(!is_file($dist_mail_virtusertable)) phpcaselog(touch($dist_mail_virtusertable), "create ".$dist_mail_virtusertable, $FILE, __LINE__);
1299      caselog("postmap $dist_mail_virtusertable", $FILE, __LINE__);
1300    }
1301    if(strstr($postfix_main_cf, "mydestination = $dist_mail_local_host_names")){
1302      ilog("mydestination entry already in $pf_main_cf");
1303    } else {
1304      wf($pf_main_cf, str_replace("mydestination", "#mydestination", rf($pf_main_cf)));
1305      af($pf_main_cf, "\nmydestination = $dist_mail_local_host_names\n");
1306      ilog("created mydestination entry in $pf_main_cf");
1307      if(!is_file($dist_mail_local_host_names)) phpcaselog(touch($dist_mail_local_host_names), "create ".$dist_mail_local_host_names, $FILE, __LINE__);
1308    }
1309    if(strstr($postfix_main_cf, "virtual_alias_maps")){
1310      wf($pf_main_cf, str_replace("virtual_alias_maps", "#virtual_alias_maps", rf($pf_main_cf)));
1311      ilog("commented out virtual_alias_maps entry in $pf_main_cf");
1312    }
1313  }
1314  /////////////// POSTFIX ENDE //////////////////
1315  
1316  //Firewall-Setup
1317  if(!strstr($dist, "freebsd")){
1318    if(is_dir("/etc/Bastille")) caselog("mv -f /etc/Bastille /etc/Bastille.backup_".date("m_d_Y__H_i_s", $current_date), $FILE, __LINE__);
1319    @mkdir("/etc/Bastille", octdec($directory_mode));
1320    caselog("cp -f isp/conf/bastille-firewall.cfg.master /etc/Bastille/bastille-firewall.cfg", $FILE, __LINE__);
1321    caselog("chmod 644 /etc/Bastille/bastille-firewall.cfg", $FILE, __LINE__);
1322    $conf = rf("/etc/Bastille/bastille-firewall.cfg");
1323    $conf = str_replace("{DNS_SERVERS}", "", $conf);
1324  
1325    $tcp_public_services = '';
1326    $udp_public_services = '';
1327    if($conn = mysql_query("SELECT dienst_port, dienst_typ FROM isp_firewall WHERE dienst_aktiv = 'ja'")){
1328      while($row = mysql_fetch_array($conn)){
1329        if($row['dienst_typ'] == 'tcp') $tcp_public_services .= $row['dienst_port'].' ';
1330        if($row['dienst_typ'] == 'udp') $udp_public_services .= $row['dienst_port'].' ';
1331      }
1332      $tcp_public_services = trim($tcp_public_services);
1333      $udp_public_services = trim($udp_public_services);
1334    } else {
1335      $tcp_public_services = '21 22 25 53 80 81 110 443 10000';
1336      $udp_public_services = '53';
1337    }
1338    $conf = str_replace("{TCP_PUBLIC_SERVICES}", $tcp_public_services, $conf);
1339    $conf = str_replace("{UDP_PUBLIC_SERVICES}", $udp_public_services, $conf);
1340  
1341    wf("/etc/Bastille/bastille-firewall.cfg", $conf);
1342  
1343    if(is_file($dist_init_scripts."/bastille-firewall")) caselog("mv -f $dist_init_scripts/bastille-firewall $dist_init_scripts/bastille-firewall.backup_".date("m_d_Y__H_i_s", $current_date), $FILE, __LINE__);
1344    caselog("cp -f security/bastille-firewall $dist_init_scripts", $FILE, __LINE__);
1345    caselog("chmod 700 $dist_init_scripts/bastille-firewall", $FILE, __LINE__);
1346  
1347    if(is_file("/sbin/bastille-ipchains")) caselog("mv -f /sbin/bastille-ipchains /sbin/bastille-ipchains.backup_".date("m_d_Y__H_i_s", $current_date), $FILE, __LINE__);
1348    caselog("cp -f security/bastille-ipchains /sbin", $FILE, __LINE__);
1349    caselog("chmod 700 /sbin/bastille-ipchains", $FILE, __LINE__);
1350  
1351    if(is_file("/sbin/bastille-netfilter")) caselog("mv -f /sbin/bastille-netfilter /sbin/bastille-netfilter.backup_".date("m_d_Y__H_i_s", $current_date), $FILE, __LINE__);
1352    caselog("cp -f security/bastille-netfilter /sbin", $FILE, __LINE__);
1353    caselog("chmod 700 /sbin/bastille-netfilter", $FILE, __LINE__);
1354  
1355    exec("which ipchains &> /dev/null", $ipchains_location, $ret_val);
1356    if(!is_file("/sbin/ipchains") && !is_link("/sbin/ipchains") && $ret_val == 0) phpcaselog(@symlink(shell_exec("which ipchains"), "/sbin/ipchains"), 'create symlink', $FILE, __LINE__);
1357    unset($ipchains_location);
1358    exec("which iptables &> /dev/null", $iptables_location, $ret_val);
1359    if(!is_file("/sbin/iptables") && !is_link("/sbin/iptables") && $ret_val == 0) phpcaselog(@symlink(trim(shell_exec("which iptables")), "/sbin/iptables"), 'create symlink', $FILE, __LINE__);
1360    unset($iptables_location);
1361  } else {
1362    if(is_file("/etc/rc.d/bastille-firewall")) caselog("mv -f /etc/rc.d/bastille-firewall /etc/rc.d/bastille-firewall.backup_".date("m_d_Y__H_i_s", $current_date), $FILE, __LINE__);
1363    caselog("cp -f isp/conf/freebsd_firewall.master /etc/rc.d/bastille-firewall", $FILE, __LINE__);
1364    $conf = rf("/etc/rc.d/bastille-firewall");
1365    $conf = str_replace("{TCP_PUBLIC_SERVICES_COMMENT}", "", $conf);
1366    $conf = str_replace("{TCP_PUBLIC_SERVICES}", "21,22,25,53,80,81,110,443,10000", $conf);
1367    $conf = str_replace("{UDP_PUBLIC_SERVICES_COMMENT}", "", $conf);
1368    $conf = str_replace("{UDP_PUBLIC_SERVICES}", "53", $conf);
1369    wf("/etc/rc.d/bastille-firewall", $conf);
1370    caselog("chmod 700 /etc/rc.d/bastille-firewall", $FILE, __LINE__);
1371  }
1372  
1373  //////////// trashscan anlegen ////////////////////
1374  if(!is_file("/home/admispconfig/ispconfig/tools/clamav/bin/trashscan")){
1375    $conf = rf("isp/conf/trashscan.master");
1376    $conf = str_replace("{VIRUSADMIN}", "admispconfig@localhost", $conf);
1377    wf("/home/admispconfig/ispconfig/tools/clamav/bin/trashscan", $conf);
1378    caselog("chmod 755 /home/admispconfig/ispconfig/tools/clamav/bin/trashscan", $FILE, __LINE__);
1379    caselog("chown admispconfig:admispconfig /home/admispconfig/ispconfig/tools/clamav/bin/trashscan", $FILE, __LINE__);
1380  }
1381  //////////// trashscan anlegen ENDE ////////////////////
1382  
1383  //////////// LOG-FILE ANLEGEN ////////////////
1384  include($pfad."/ispconfig/lib/config.inc.php");
1385  if(!is_file($go_info["server"]["log_file"])) touch($go_info["server"]["log_file"]);
1386  exec("chown admispconfig:admispconfig ".$go_info["server"]["log_file"]);
1387  exec("chmod 644 ".$go_info["server"]["log_file"]);
1388  //////////// LOG-FILE ANLEGEN ENDE ////////////////
1389  
1390  exec("pwconv &> /dev/null");
1391  exec("grpconv &> /dev/null");
1392  
1393  phpcaselog(unlink("/root/ispconfig/dist.inc.php"), "delete /root/ispconfig/dist.inc.php", $FILE, __LINE__);
1394  if($install_art == "upgrade"){
1395    touch($pfad."/ispconfig/.run");
1396  }
1397  ?>


[ Powered by PHPXref - Served by Debian GNU/Linux ]