Moved to contrib/ in preperation for merge
[mailer.git] / contrib / install_svn.php
diff --git a/contrib/install_svn.php b/contrib/install_svn.php
new file mode 100644 (file)
index 0000000..3893665
--- /dev/null
@@ -0,0 +1,483 @@
+<?php
+/**
+ ******************************************************************************************************
+ ******************************************************************************************************
+ *** $HeadURL::                                                                                   $ ***
+ *** $Author::                                                                                    $ ***
+ *** $Revision::                                                                                  $ ***
+ *** $Date::                                                                                      $ ***
+ *** $Copyright:: ©2008, Profi-Concept aka Wolfgang Stelzhammer , All rights reserved.            $ ***
+ *** $ License:: The BSD License                                                                  $ ***
+ *** $ Redistribution and use in source and binary forms, with or without modification,           $ ***
+ *** $ are permitted provided that the following conditions are met:                              $ ***
+ *** $                                                                                            $ ***
+ *** $ - Redistributions of source code must retain the above copyright notice,                   $ ***
+ *** $   this list of conditions and the following disclaimer.                                    $ ***
+ *** $ - Redistributions in binary form must reproduce the above copyright notice,                $ ***
+ *** $   this list of conditions and the following disclaimer in the documentation and/or         $ ***
+ *** $   other materials provided with the distribution.                                          $ ***
+ *** $ - Neither the name "Profi-Concept" or "Wolfgang Stelzhammer" nor the names of its          $ ***
+ *** $   contributors may be used to endorse or promote products derived from this software       $ ***
+ *** $   without specific prior written permission.                                               $ ***
+ *** $                                                                                            $ ***
+ *** $ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY        $ ***
+ *** $ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF    $ ***
+ *** $ MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL     $ ***
+ *** $ THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,        $ ***
+ *** $ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT   $ ***
+ *** $ OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)  $ ***
+ *** $ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,      $ ***
+ *** $ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS      $ ***
+ *** $ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.                               $ ***
+ ******************************************************************************************************
+ *** With some XHTML hacks and mcedit ("Cool Edit") improvements by Roland Haeder                   ***
+ ******************************************************************************************************
+ ******************************************************************************************************
+ **/
+define('SVN_REPO_URL', "http://mxchange.org/repos/mailer/branches/0.2.1-FINAL");
+//define('SVN_REPO_URL', "file:///E:/Webscripte/MXChange/local_mirror/branches/0.2.1-FINAL");
+define('SVN_UUID', "");
+
+?>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+ "http://www.w3.org/TR/html4/loose.dtd">
+
+<html>
+<head>
+<title>SVN-Installer --&gt; [Mailer - Mail Exchange] v0.2.1-FINAL</title>
+<style type="text/css">
+<!--
+body {
+       background-color: #EEFFEE;
+       color: #000000;
+       font-family: Verdana, Arial, Geneva, Helvetica, sans-serif;
+       font-size: 12px;
+       letter-spacing: 1px;
+       scrollbar-base-color: #E9E4AE;
+       scrollbar-face-color: #CDEFCD;
+       scrollbar-highlight-color: #EEFFEE;
+       scrollbar-shadow-color: #CDEFCD;
+       scrollbar-3dlight-color: #DDDDDD;
+       scrollbar-arrow-color: #000000;
+       scrollbar-track-color: #CCEFCC;
+       scrollbar-darkshadow-color: #999999;
+       margin: 20px;
+}
+
+table {
+       table-layout: auto;
+       border-spacing: 0px;
+       overflow: auto;
+}
+
+td {
+       vertical-align: top;
+}
+
+A {
+       font-style: normal;
+       font-family: Verdana, Arial, Geneva, Helvetica, sans-serif;
+       text-decoration: none;
+}
+
+A:link {
+       color: #2e51a9;
+}
+
+A:visited {
+       color: #AA0044;
+}
+
+A:active {
+       color: #2e51a9;
+       background-color: transparent;
+}
+
+A:hover {
+       background-color: transparent;
+}
+
+input,textarea {
+       color: #009900;
+       background-color: #EEFFEE;
+       border: 1px solid #AA0044;
+       text-decoration: none;
+       border-style: groove;
+}
+
+select,option {
+       background-color: #EEFFEE;
+       border: solid 1px #009900;
+       color: #AA0044;
+       text-decoration: none;
+       border-style: groove;
+}
+
+ul,ol {
+       margin-top: 0px;
+       margin-bottom: 0px;
+}
+
+.hl {
+       font-weight: 900;
+}
+
+.pos {
+       color: #32cd32;
+       background-color: #fffff0;
+       padding: 10px;
+}
+
+.neg {
+       color: #ff0000;
+       background-color: #fffff0;
+       padding: 10px;
+}
+-->
+</style>
+
+
+</head>
+<body>
+<br />
+<h2>SVN-Installer --&gt; [Mailer - Mail Exchange] v0.2.1-FINAL<br />
+<span style="font-size: 8pt;">Installer-Version 0.1.1<br />
+&copy;2008, Profi-Concept aka Wolfgang Stelzhammer , All rights
+reserved.</span></h2>
+
+<span class="hl">Pr&uuml;fe SVN-Version: </span>
+...
+<br />
+<br />
+<?php
+function doSetup () {
+       $rev = '';
+       if ((isset($_GET['revision'])) && (!empty($_GET['revision']))) {
+               $rev = '-r '.$_GET['revision'];
+       } // END - if
+
+
+       switch ($_GET['type']) {
+               case 'checkout':
+                       $befehl = 'svn checkout '.$rev.$_GET['svn_url'].' '.$_GET['path'];
+                       break;
+               case 'export':
+                       $befehl = 'svn export --force '.$rev.$_GET['svn_url'].' '.$_GET['path'];
+                       break;
+       } // END - switch
+
+       $ausg = proc_get($befehl);
+       //echo '<pre>$befehl:'.print_r($befehl, true).'</pre>';
+
+       //echo '<pre>$ausg:'.print_r($ausg, true).'</pre>';
+       echo '<p class="hl">F&uuml;hre SVN-'.$_GET['type'].' durch ...</p>';
+
+       if (!isset($_GET['svn_detail']) || $_GET['svn_detail'] != '1') $t[] = $ausg[count($ausg)-1];
+       else $t = $ausg;
+
+
+       ?>
+<table border="1" cellpadding="5" cellspacing="1"
+       style="margin-left: 20px;">
+       <tr>
+               <td class="hl">SVN Ausgabe</td>
+               <td class="pos" style="border: #00000 1px solid;"><?php echo implode("<br />\n",$t) ?></td>
+       </tr>
+</table>
+<br />
+<br />
+       <?php
+
+       $owner = fileowner($_GET['path']);
+       $uid = uniqid();
+       mkdir($_GET['path']. $uid);
+       $nowner = fileowner($_GET['path']. $uid);
+       //$group = filegroup($_GET['path']);
+       rmdir($_GET['path']. $uid);
+
+
+       if ($owner != $nowner) {
+               //echo '<pre>$owner:'.print_r($owner, true).'</pre>';
+               //echo '<pre>$nowner:'.print_r($nowner, true).'</pre>';
+               echo '<span class="hl">Setze Dateirechte, da Webserver-Benuzter von Ordner-Eigent&uuml;ber abweicht ...</span>';
+               proc_get('chmod -R 0766 '.$_GET['path']);
+               echo '<span class="pos">Dateirechte auf 0766 gesetzt</span><br /><br />';
+       } // END - if
+
+
+       ?>
+<span class="pos">SVN-Installation erfolgreich abgeschlossen.</span>
+<br />
+<br />
+<br />
+<form action="<?php echo $_GET['mailer_url'] . "\"";  ?> method="GET">
+<div style="margin-left: 20px;"><input type="submit" name="submit"
+       value="Installations-Script von Mailer aufrufen" /></div>
+</form>
+       <?php
+       return $t;
+}
+
+function proc_get ($cmd) {
+
+       $res = popen($cmd, 'r');
+       $buffer = array();
+       while ($res && !feof($res)) {
+               $t = trim(fgets($res));
+               if (!empty($t)) {
+                       $buffer[] = t$t;
+               } // END - if
+               //echo $t;
+       } // END - while
+       pclose($res);
+       if (count($buffer) <= 0) {
+               return false;
+       } else {
+               return $buffer;
+       }
+}
+
+$ausg = proc_get('svn --version --quiet');
+
+if (!$ausg) {
+       echo '<h2 style="text-align:center; padding-top: 10px; padding-bottom: 10px;" class="neg">Fehler: Es konnte kein SVN-Client gefunden werden!<br />
+       Bitte installieren Sie SVN (<a href="http://http://subversion.tigris.org/">http://subversion.tigris.org/</a>).</h2>';
+       exit;
+} // END - if
+
+echo '<span class="hl">Installierte SVN Version: </span><span class="pos">'.$ausg[0].'</span><br />';
+//echo '<pre>$ausg:'.print_r($ausg, true).'</pre>';
+if (!isset($_GET['step'])) {
+       $step = 1;
+} else {
+       $step = $_GET['step'];
+}
+
+switch ($step) {
+       case '1':
+               ?>
+<br />
+<form action="" method="GET">
+<div style="margin-left: 20px;"><input type="hidden" name="step"
+       value="2" />
+<p class="hl">Installations-Parameter</p>
+<table border="1" cellpadding="5" cellspacing="1">
+       <tr>
+               <td class="hl" nowrap style="border-bottom: 0px solid;">Setup-Art:</td>
+               <td colspan="2"><select name="type">
+                       <option value="checkout">checkout (Standard)</option>
+                       <option value="export">export</option>
+               </select></td>
+       </tr>
+       <tr>
+               <td style="border-top: 0px solid; border-bottom: 0px solid;"></td>
+               <td class="hl" nowrap>Chekout:<br />
+               (Standard)</td>
+               <td width="400">Bei dieser Option wird ein Working-Direktory erstellt.
+               Hiermit kann ganz einfach mittels eines SVN-Updates das Script
+               geupdated werden.</td>
+       </tr>
+       <tr>
+               <td style="border-top: 0px solid;"></td>
+               <td class="hl" nowrap>Export:</td>
+               <td width="400">Hier wird nur ein &quot;einfacher&quot; Export
+               ausgef&uuml;hrt und keine Versions-Information gespeichert.</td>
+       </tr>
+       <tr>
+               <td class="hl" nowrap style="border-bottom: 0px solid;">Setup-Verzeichnis:</td>
+               <td colspan="2"><input size="80" maxlength="254" type="text"
+                       name="path"
+                       value="<?php echo str_replace("\\", '/', dirname(__FILE__)) . "/\"";  ?> /></td>
+</tr>
+<tr>
+       <td style="border-top: 0px solid;"></td>
+       <td class="hl" nowrap>Absoluter Pfad:</td>
+       <td width="400">Standardm&auml;&szlig;ig ist hier der Pfad des Scriptes angegeben. Ein nicht vorhandenes Verzeichniss wird erstellt.</td>
+</tr>
+<tr>
+       <td class="hl" nowrap style="border-bottom: 0px solid;">Mailer-URL:</td>
+       <td colspan="2"><input size="80" maxlength="254" type="text" name="mailer_url" value="<?php echo 'http://' . getenv('SERVER_NAME') . str_replace("\\", '/', dirname($_SERVER['PHP_SELF']))."/\"";  ?> /></td>
+</tr>
+<tr>
+       <td style="border-top: 0px solid;"></td>
+       <td class="hl" nowrap>Mailer-URL:</td>
+       <td width="400">Dies ist die URL von wo aus der Mailer aufgerufen werden kann. Standardm&auml;&szlig;ig ist hier die URL des Scriptes angegeben.</td>
+</tr>
+<tr>
+       <td class="hl" nowrap style="border-bottom: 0px solid;">SVN-Repository:</td>
+       <td colspan="2"><input size="80" maxlength="254" type="text" name="svn_url" value="<?php echo constant('SVN_REPO_URL') . "\"";  ?> /></td>
+</tr>
+<tr>
+       <td style="border-top: 0px solid;"></td>
+       <td class="hl" nowrap>SVN-Server-URL:</td>
+       <td width="400">URL zum SVN-Server von [Mailer - Mail Exchange] v0.2.1-FINAL. Standard-URL ist hier <span class="hl"><?php echo constant('SVN_REPO_URL');  ?></span>. Bitte nur &auml;ndern, wenn Sie einen lokalen SVN-Mirror erstellt haben oder eine andere Version von Mailer-Project installieren m&ouml;chten.</td>
+</tr>
+<tr>
+       <td class="hl" nowrap style="border-bottom: 0px solid;">Optionen:</td>
+       <td colspan="2" class="hl">
+               Head-Revision: <input type="checkbox" name="head_revision" value="1" checked="checked"><br />
+               SVN Detail-Ausgabe: <input type="checkbox" name="svn_detail" value="1">
+</tr>
+<tr>
+       <td style="border-top: 0px solid;border-bottom: 0px solid;"></td>
+       <td class="hl" nowrap>Head-Revision:</td>
+       <td width="400">Wird diese Option gew&auml;hlt, so wird automatisch die HEAD-Revision verwendet. Sonst kann in einem weiteren Schritt eine entsprechende Revision ausgew&auml;hlt werden.</td>
+</tr>
+<tr>
+       <td style="border-top: 0px solid;"></td>
+       <td class="hl" nowrap>SVN Detail-Ausgabe:</td>
+       <td width="400">Aktiviert zeigt es s&auml;mtliche SVN-Detail-Ausgaben an. Sollte nur zum Debuggen aktiviert werden.</td>
+</tr>
+
+</table>
+<br />
+<input type="submit" name="submit" value="Setup fortsetzen">
+
+</div>
+</form>
+<?php
+       break;
+       case '2':
+               if (!preg_match('@(.*)/$@',$_GET['path'],$match)) {
+                       $_GET['path'] = $_GET['path'].'/';
+                       //echo '<pre>$_GET:'.print_r($_GET, true).'</pre>';
+               } // END - if
+               //echo '<pre>$_GET:'.print_r($_GET, true).'</pre>';
+?>
+<br />
+<span class="hl">Pr&uuml;fe Setup-Verzeichniss <?php echo $_GET['path']; ?> ...<br /><br />
+<?php
+$t = uniqid();
+$erg = @mkdir($_GET['path']. $t.'/');
+if (file_exists($_GET['path']) && $erg) {
+       echo $_GET['path'].'</span><span class="pos">vorhanden und beschreibar</span>';
+       rmdir($_GET['path']. $t.'/');
+} elseif(file_exists($_GET['path']) && !$erg) {
+       echo '<span class="hl">'.$_GET['path'].' </span>';
+       echo '<span class="neg">Fehler</span><br /><br />';
+       echo '<h2 style="text-align:center; padding-top: 10px; padding-bottom: 10px;" class="neg">Fehler: Das Verzeichniss<br />'.$_GET['path'].'<br />hat Nicht gen&uuml;gende Schreibrechte.';
+       exit;
+
+} elseif (!file_exists($_GET['path'])) {
+       //echo '<span class="neg">nicht vorhanden</span><br /><br />';
+       $t = explode('/',$_GET['path']);
+       //echo '<pre>$t:'.print_r($t, true).'</pre>';
+       $dir = '';
+       foreach($t as $last) {
+               if (!empty($last)) {
+                       $tdir = $dir;
+                       $dir .= $last.'/';
+
+                       //echo '<pre>fileperms($tdir):'.print_r(fileperms($tdir), true).'</pre>';
+                       //echo '<pre>fileperms($dir):'.print_r(fileperms($dir), true).'</pre>';
+
+
+                       //echo '<pre>$dir:'.print_r($dir, true).'</pre>';
+
+                       if (!file_exists($dir)) {
+                               $erg = @mkdir($dir);
+                               if (!$erg) {
+                                       echo '<span class="hl">'.$dir.' </span>';
+                                       echo '<span class="neg">Fehler</span><br /><br />';
+                                       echo '<h2 style="text-align:center; padding-top: 10px; padding-bottom: 10px;" class="neg">Fehler: Das Verzeichniss<br />'.$tdir.'<br />hat Nicht gen&uuml;gende Schreibrechte.';
+                                       exit;
+                               } else {
+                                       echo '<span class="hl">'.$dir.' </span>';
+                                       echo '<span class="pos">erstellt</span><br /><br />';
+                               }
+                       }
+               } // END - if
+       } // END - foreach
+}
+echo '<p class="hl">Pr&uuml;fe SVN-Server '.$_GET['svn_url']. ' ...</p>';
+echo '<span class="hl">'.$_GET['svn_url'].' </span>';
+
+$svn_server_readable = proc_get('svn info '.$_GET['svn_url'].'');
+$svn_server = proc_get('svn info --xml '.$_GET['svn_url'].'');
+
+if (!$svn_server_readable) {
+       echo '<span class="neg">Fehler</span><br />';
+       echo '<h2 style="text-align:center; padding-top: 10px; padding-bottom: 10px;" class="neg">Fehler: Kann den SVN-Server<br />'.$_GET['svn_url'].'<br />nicht erreichen.';
+       exit;
+} // END - if
+
+$svn_ausg = implode('<br />',$svn_server_readable);
+$svn_server = implode("\n",$svn_server);
+?>
+<span class="pos">erreichbar</span><br /><br />
+<table border="1" cellpadding="5" cellspacing="1" style="margin-left: 20px;">
+<tr>
+       <td class="hl">SVN Informationen</td>
+       <td class="pos" style="border: #00000 1px solid;"><?php echo $svn_ausg ?></td>
+</tr>
+</table>
+<?php
+if (!isset($_GET['head_revision']) || $_GET['head_revision'] != '1') {
+?>
+<br />
+<form action="" method="GET">
+<div style="margin-left: 20px;">
+<input type="hidden" name="step" value="3" />
+<input type="hidden" name="past" value="<?php echo urlencode(serialize($_GET))."\""; ?> />
+<table border="1" cellpadding="5" cellspacing="1">
+<tr>
+       <td class="hl" nowrap style="border-bottom: 0px solid;">Revision:</td>
+       <td colspan="2"><input size="10" maxlength="10" type="text" name="revision" value="<?php
+//echo '<pre>$svn_server:<textarea cols="80" rows="20" name="fgsgfsdg">'.print_r($svn_server, true).'</textarea></pre>';
+
+
+$xml = new SimpleXMLElement($svn_server);
+//echo '<pre>$xml:'.print_r($xml, true).'</pre>';
+$t = $xml->entry[0]->commit[0]['revision'];
+echo $t."\"";
+?>></td>
+
+</tr>
+<tr>
+       <td style="border-top: 0px solid;"></td>
+       <td class="hl" nowrap>Revision:</td>
+       <td width="400">Revision von [Mailer-Project - Mail Exchange] v0.2.1-FINAL die installiert werden soll. Nach m&ouml;glichkeit immer die HEAD-Revison benutzen um alle Updates bereits includiert zu erhalten.</td>
+</tr>
+</table>
+<br />
+<input type="submit" name="submit" value="Setup fortsetzen">
+
+</div>
+</form>
+<?php
+} else {
+       $ausg = doSetup();
+}
+       break;
+
+       case '3':
+               $t = unserialize(urldecode($_GET['past']));
+               unset($_GET['past']);
+               $_GET = array_merge($t, $_GET);
+               echo '<p class="hl">Pr&uuml;fe SVN-Server '.$_GET['svn_url']. ' ...</p>';
+               echo '<span class="hl">'.$_GET['svn_url'].' </span>';
+
+               $svn_server_readable = proc_get('svn info '.$_GET['svn_url'].'');
+               $svn_server = proc_get('svn info --xml '.$_GET['svn_url'].'');
+               if (!$svn_server_readable) {
+                       echo '<span class="neg">Fehler</span><br />';
+                       echo '<h2 style="text-align:center; padding-top: 10px; padding-bottom: 10px;" class="neg">Fehler: Kann den SVN-Server<br />'.$_GET['svn_url'].'<br />nicht erreichen.';
+                       exit;
+               } // END - if
+               $svn_ausg = implode('<br />',$svn_server_readable);
+               $svn_server = implode("\n",$svn_server);
+?>
+<span class="pos">erreichbar</span><br /><br />
+<table border="1" cellpadding="5" cellspacing="1" style="margin-left: 20px;">
+<tr>
+       <td class="hl">SVN Informationen</td>
+       <td class="pos" style="border: #00000 1px solid;"><?php echo $svn_ausg ?></td>
+</tr>
+</table>
+<?php
+                       $ausg = doSetup();
+                       break;
+} // END - switch
+?>
+</body>
+</html>