Simple Groupware PHP Cross Reference Groupware Applications

Source: /src/ext/install_unattended.php.txt - 105 lines - 4031 bytes - Summary - Text - Print

   1  <?php
   2      /**************************************************************************\
   3      * Simple Groupware 0.743                                                   *
   4      * http://www.simple-groupware.de                                           *
   5      * Copyright (C) 2002-2012 by Thomas Bley                                   *
   6      * ------------------------------------------------------------------------ *
   7      *  This program is free software; you can redistribute it and/or           *
   8      *  modify it under the terms of the GNU General Public License Version 2   *
   9      *  as published by the Free Software Foundation; only version 2            *
  10      *  of the License, no later version.                                       *
  11      *                                                                          *
  12      *  This program is distributed in the hope that it will be useful,         *
  13      *  but WITHOUT ANY WARRANTY; without even the implied warranty of          *
  14      *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the            *
  15      *  GNU General Public License for more details.                            *
  16      *                                                                          *
  17      *  You should have received a copy of the GNU General Public License       *
  18      *  Version 2 along with this program; if not, write to the Free Software   *
  19      *  Foundation, Inc., 59 Temple Place - Suite 330, Boston,                  *
  20      *  MA  02111-1307, USA.                                                    *
  21      \**************************************************************************/
  22  
  23  
  24  error_reporting(E_ALL);
  25  @set_time_limit(1800);
  26  $argv = $_SERVER["argv"];
  27  
  28  if (!function_exists("out")) {
  29    function out($str) {
  30      if (($pos = strpos($str,"<body"))) $str = substr($str,$pos);
  31      $str = preg_replace("|<[^>]+>|"," ",str_replace("<br>","\n",$str));
  32      $str = str_replace("\n ","\n",trim(preg_replace("| +|"," ",$str)," "));
  33      echo $str;
  34      if ($str!="" and $str[strlen($str)-1]!="\n") echo " ";
  35      @ob_flush();
  36      flush();
  37    }
  38  }
  39  
  40  echo "\n";
  41  if (count($argv)<10) {
  42    echo "Usage:\n";
  43    echo "php -d register_argc_argv=1 -q install_unattended.php.txt <url> <lang-code> <admin-user> <admin-pw> <db-type> <db-host> <db-name> <db-user> <db-pw> <demo-data>\n\n";
  44    echo "url = http://<your-server>/<your-sgs-dir>/src/index.php
  45  lang-code = ar, cz, cn, da, de, en, enUK, es, fr, gr, hr, hu, idn, it, nl, pl, ptBR, ru, se, sk, tr, uk
  46  admin-user = super administrator username
  47  admin-pw = super administrator password
  48  db-type = mysql, pgsql, sqlite
  49  db-host = database hostname / ip
  50  db-name = database name
  51  db-user = database username
  52  db-pw = database password (use '_' if empty)
  53  folder-structure = 0=full, <file>=path / folder template";
  54    exit(1);
  55  }
  56  $url = $argv[1];
  57  $lang = $argv[2];
  58  $folders = @$argv[10];
  59  
  60  out("Building translations ...\n\n");
  61  if (($fp = fopen($url."?lang=".$lang,"r"))) {
  62    $data = "";
  63    while (!feof($fp)) $data .= fread($fp,8192);
  64    fclose($fp);
  65  } else exit(1);
  66  
  67  if (!strpos($data,"Continue")) {
  68    echo "Error building translations: ".$url."?lang=".$lang."\n\n";
  69    if (($pos = strpos($data,"<body"))) $data = substr($data, $pos);
  70    echo strip_tags($data);
  71    exit(1);
  72  }
  73  
  74  $url = str_replace("/src/","/bin/",$url);
  75  $url .= "?install=yes";
  76  $url .= "&accept_gpl=yes";
  77  $url .= "&language=".$lang;
  78  $url .= "&admin_user=".urlencode($argv[3]);
  79  $url .= "&admin_pw=".urlencode($argv[4]);
  80  $url .= "&db_type=".$argv[5];
  81  $url .= "&db_host=".urlencode($argv[6]);
  82  $url .= "&db_name=".urlencode($argv[7]);
  83  $url .= "&db_user=".urlencode($argv[8]);
  84  $url .= "&db_pw=".urlencode(str_replace("_","",$argv[9]));
  85  $url .= "&folders=".urlencode($folders);
  86  
  87  out("Running setup ...\n\n");
  88  if (($fp = fopen($url,"r"))) {
  89    $data = "";
  90    while (!feof($fp)) {
  91      $line = fread($fp,8192);
  92      out(str_replace("\n"," ",$line));
  93      $data .= $line;
  94    }
  95    fclose($fp);
  96  } else exit(1);
  97  
  98  if (strpos($data,"<error>")) {
  99    $pos = strpos($data,"<error>")+7;
 100    echo "Error running setup: ".$url."\n";
 101    echo substr($data,$pos,strpos($data,"</error>")-$pos);
 102    exit(1);
 103  }
 104  
 105  out("\n\nFinished.\n");

title

Description

title

Description

title

Description

title

title

Body