Simple Groupware PHP Cross Reference Groupware Applications

Source: /src/ext/update_unattended.php.txt - 94 lines - 3575 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)<5) {
  42    echo "Usage:\n";
  43    echo "php -d register_argc_argv=1 -q update_unattended.php.txt <url> <admin-user> <admin-pw> <release> <no-backup>\n\n";
  44    echo "url = http://<your-server>/<your-sgs-dir>/bin/index.php
  45  admin-user = super administrator username
  46  admin-pw = super administrator password
  47  release = e.g. 0.659 or latest
  48  no-backup = 1=don't backup files, 0=backup files";
  49    exit(1);
  50  }
  51  $url = $argv[1];
  52  $admin_user = $argv[2];
  53  $admin_pass = $argv[3];
  54  $release = $argv[4];
  55  $nobackup = (int)@$argv[5];
  56  
  57  out("Downloading update ...\n\n");
  58  $url = dirname($url)."/updater.php?release={$release}&username={$admin_user}&password={$admin_pass}&nobackup={$nobackup}";
  59  if (($fp = fopen($url,"r"))) {
  60    $data = "";
  61    while (!feof($fp)) $data .= fread($fp,8192);
  62    fclose($fp);
  63  } else exit(1);
  64  
  65  if (!strpos($data,"<finished>")) {
  66    echo "Error downloading update: ".$url."\n\n";
  67    if (($pos = strpos($data,"<body"))) $data = substr($data, $pos);
  68    echo strip_tags($data);
  69    exit(1);
  70  }
  71  
  72  out("Installing update ...\n\n");
  73  $url = dirname($url)."/index.php";
  74  if (($fp = fopen($url,"r"))) {
  75    $data = "";
  76    while (!feof($fp)) $data .= fread($fp,8192);
  77    fclose($fp);
  78  } else exit(1);
  79  
  80  if (($pos = strpos($data,"<error>"))) {
  81    $pos += 7;
  82    echo "Error running setup: ".$url."\n";
  83    echo substr($data,$pos,strpos($data,"</error>")-$pos);
  84    exit(1);
  85  }
  86  
  87  if (!strpos($data,"<finished>")) {
  88    echo "Error installing update: ".$url."\n\n";
  89    if (($pos = strpos($data,"<body"))) $data = substr($data, $pos);
  90    echo strip_tags($data);
  91    exit(1);
  92  }
  93  
  94  out("\n\nFinished.\n");

title

Description

title

Description

title

Description

title

title

Body