home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2004 December / PCpro_2004_12.ISO / files / webserver / xampp / xampp-tomcat-addon-1.4.9-installer.exe / javaaddon.php < prev    next >
Encoding:
PHP Script  |  2004-10-02  |  10.2 KB  |  432 lines

  1. <?php
  2.  
  3. /* 
  4. #### Installer PHP  1.4 RC2  #### 
  5. #### Author: Kay Vogelgesang for www.apachefriends.org 2004 ####  
  6. */    
  7.  
  8. print "\r\n  ########################################################################\n
  9.   # ApacheFriends XAMPP Java add-on win32 Version 1.5 rc1                #\r\n
  10.   #----------------------------------------------------------------------#\r\n
  11.   # Copyright (c) 2002-2004 Apachefriends                                #\r\n
  12.   #----------------------------------------------------------------------#\r\n
  13.   # Authors: Kay Vogelgesang <kvo@apachefriends.org>                     #\r\n
  14.   #          Oswald Kai Seidler <oswald@apachefriends.org>               #\r\n
  15.   ########################################################################\r\n\r\n"; 
  16.  
  17.  
  18. echo "  Checking status for setup (checke Status) ...\r\n\r\n";
  19.  
  20. /// Where I stand? ///
  21. $curdir = getcwd();
  22. list ($partition, $nonpartition) = split (':', $curdir);
  23. list ($partwampp, $directorwampp) = spliti ('\\\install', $curdir);
  24. $awkpart = eregi_replace ("\\\\","\\\\",$partwampp);
  25. $awkpartslash = ereg_replace ("\\\\","/",$partwampp);
  26. $phpdir = $partwampp;
  27. $dir = ereg_replace ("\\\\","/",$partwampp);
  28. $ppartition="$partition:";
  29. $tomcatpath=$partwampp."\\tomcat";
  30. $tomcatstartbat=$partwampp."\\tomcat_start.bat";
  31. $tomcatstopbat=$partwampp."\\tomcat_stop.bat";
  32.  
  33.  
  34.  
  35.  
  36. /// Some addon|update.sys files 
  37. $perlupdatesys="perlupdate.sys";
  38. $pythonupdatesys="pythonupdate.sys";
  39. $serverupdatesys="serverupdate.sys";
  40. $utilsupdatesys="utilsupdate.sys";
  41. $javaupdatesys="javaupdate.sys";
  42. $otherupdatesys="otherupdate.sys";
  43. $installsys="install.sys";
  44. $installsysroot=$partwampp."\install\\".$installsys;
  45. $javasysroot=$partwampp."\install\\".$javaupdatesys;
  46.  
  47. /// XAMPP main directrory is ... 
  48. $substit="\\\\\\\\xampp";
  49. $substitslash="/xampp";
  50.  
  51. /// Globale variables
  52. global $javayes; 
  53. $javayes = 0;
  54. global $javasubmitdir; 
  55. $javasubmitdir = 0;
  56. global $slashi;
  57. $slashi=1;
  58. global $bslashi;
  59. $bslashi=1;
  60. $awkexe=".\install\awk.exe";
  61. $awk=".\install\config.awk";
  62. $javahometmp="$partwampp\javapath.ini";
  63. $javasearch="JavaHome";
  64. // $awkexe="$partwampp\install\awk.exe";
  65. // $awk="$partwampp\install\config.awk";
  66. $awknewdir="\"".$awkpart."\"";
  67. $awkslashdir="\"".$awkpartslash."\"";
  68. global $xamppversion;
  69. if (file_exists("$partwampp\install\.version")) 
  70. { include_once("$partwampp\install\.version"); }
  71. $confhttpdroot=$partwampp."\apache\\conf\\httpd.conf";
  72. $javapathstatus=0;
  73. global $javapath;
  74.  
  75. function read ($length='255')
  76. {
  77. global $line;
  78.    if (!isset ($GLOBALS['StdinPointer']))
  79.    {
  80.      $GLOBALS['StdinPointer'] = fopen ("php://stdin","r");
  81.    }
  82.    $line = fgets ($GLOBALS['StdinPointer'],$length);
  83.    return trim ($line);
  84. }
  85.  
  86.  
  87.  
  88.  if (file_exists($javasysroot))
  89. {
  90.     // echo "  Sorry, but the Java add-on seems to be installed ...\r\n";
  91.     // echo "  Setup exit now!\r\n\r\n";
  92.     // exit;
  93.     echo "  Java add-on seems to be installed ... starting for a reconfiguration.\r\n";
  94.     $javaexexists=1;
  95. else
  96. {
  97.     $javaexexists=0;
  98. }
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111. // Find the install status for xampp basic package in the install.sys file
  112. global $javapathstatus;
  113. $javapathstatus=0;
  114. if (file_exists($javahometmp)) 
  115. {
  116. $i=0;
  117.  
  118.  
  119.  
  120.  
  121. $datei = fopen($javahometmp,'r');
  122. while(!feof($datei)) 
  123.     {
  124. $zeile = fgets($datei,255);
  125.  
  126. $newzeile[]=$zeile; 
  127.  
  128.     }
  129. fclose($datei);
  130.  
  131. $jcount=count($newzeile);
  132.  
  133.  for($z=1;$z<=$jcount;$z++) 
  134.                 { 
  135.                 if ($newzeile[$z]!="")
  136.                     {    
  137.                         if (eregi($javasearch,$newzeile[$z]))
  138.                         {
  139.                         list ($left, $right) = split ('=', $newzeile[$z]);
  140.                         $right = eregi_replace ("\"","",$right);
  141.                         $right = eregi_replace ("\r\n","",$right);
  142.                         $javapath = eregi_replace ("\\\\\\\\","\\",$right);
  143.                         $javapathstatus=1;
  144.                      
  145.                         }
  146.         
  147.                     }
  148.                     else
  149.                     {
  150.                     //    $javapathstatus=0;
  151.                     }
  152.                 }
  153. }
  154. else { $javapathstatus=0; };
  155.  
  156.  
  157.  
  158.  
  159.  
  160.  
  161.  
  162.  
  163.  
  164.  
  165.  
  166.  
  167.  
  168. // Java addon configure
  169.  
  170. $javaclasspath=$javapath."\lib\\tools.jar";
  171. $setline.="@echo off\r\n\r\n";
  172. $setline.="set JAVA_HOME=".$javapath."\r\n";
  173. $setline.="set workers.catalina_home=".$tomcatpath."\r\n";
  174. $setline.="set workers.java_home=".$javapath."\r\n";
  175. $setline.="set TOMCAT_HOME=".$tomcatpath."\r\n";
  176. $setline.="set TOMCAT_BASE=".$tomcatpath."\r\n";
  177. $setline.="set CLASSPATH=".$tomcatpath.";".$javaclasspath."\r\n";
  178. $setline.="set CATALINA_BASE=".$tomcatpath."\r\n";
  179. $setline.="set CATALINA_HOME=".$tomcatpath."\r\n";
  180. $catalinastart="\r\ntomcat\bin\catalina.bat start";
  181. $catalinastop="\r\ntomcat\bin\catalina.bat stop";
  182.  
  183.  
  184.  
  185.  
  186. // if (file_exists($tomcatstartbat)) 
  187. // {
  188. $datei = fopen($tomcatstartbat,'w+');
  189. fputs($datei,$setline); 
  190. fputs($datei,$catalinastart); 
  191. fclose($datei);
  192. echo "\r\n\r\n  Create \"tomcat_start.bat\" ... ok";
  193. sleep(1);
  194.  
  195. // }
  196. // if (file_exists($tomcatstopbat)) 
  197. // {
  198. $datei = fopen($tomcatstopbat,'w+');
  199. fputs($datei,$setline); 
  200. fputs($datei,$catalinastop); 
  201. fclose($datei);
  202. // }
  203. echo "\r\n  Create \"tomcat_stop.bat\" ... ok";
  204. sleep(1);
  205.  
  206.  
  207. if ($javaexexists==0)
  208. {
  209. //// Adapting absolute paths in java config files /////////
  210. if (file_exists("$partwampp\install\\xamppjava.inc")) 
  211. { include_once("$partwampp\install\\xamppjava.inc"); }
  212.  
  213. $scount=count($slash);
  214. $bcount=count($backslash);
  215.  
  216. $substit="\"".$substit."\"";
  217. for ($i=1;$i<=$bcount;$i++)
  218. {
  219.  
  220.  
  221.  
  222.  
  223. $temp=$backslash[$i];
  224. $awkconfig=$backslashrootawk[$temp].$backslash[$i]."\"";
  225. $awkconfigtemp=$backslashrootawk[$temp].$backslash[$i]."temp\"";
  226. $configreal=$backslashrootreal[$temp].$backslash[$i];
  227. $configtemp=$backslashrootreal[$temp].$backslash[$i]."temp";
  228.  
  229.  
  230. ///////////// Section SET  NEW configfiles for addons/update OR DELETE /////////////
  231. $configrealnew=$backslashrootreal[$temp].$backslash[$i].".new";
  232. if (!file_exists($configreal) && file_exists($configrealnew))
  233.     { 
  234.             
  235.             if (!@copy($configrealnew, $configreal)) 
  236.                 {}            
  237.             else { unlink ($configrealnew); }
  238.         
  239.     }
  240.     elseif (file_exists($configrealnew))
  241.     { unlink ($configrealnew); }
  242.  
  243. if ($updatemake=="doppelt")
  244.     { break; }
  245.  
  246.  
  247. $awkrealm=$awkexe." -v DIR=".$awknewdir." -v CONFIG=".$awkconfig. " -v CONFIGNEW=".$awkconfigtemp. "  -v SUBSTIT=".$substit." -f ".$awk;  
  248.  
  249.  
  250.  
  251. if (file_exists($awk) && file_exists($awkexe) && file_exists($configreal)) 
  252. {        
  253.     shell_exec("$awkrealm");
  254.  
  255.     if (file_exists($configtemp) && file_exists($configreal))
  256.     {
  257.     if (!@copy($configtemp, $configreal)) 
  258.         {
  259.         // echo "\r\n\r\n$configtemp could not be copied to $configreal";
  260.         }
  261.         else { unlink ($configtemp); }
  262.     } 
  263. }
  264.  
  265.  
  266. $substitslash="\"".$substitslash."\"";
  267. for ($i=1;$i<=$scount;$i++)
  268. {
  269. $temp=$slash[$i];
  270. $awkconfig=$slashrootawk[$temp].$slash[$i]."\"";
  271. $awkconfigtemp=$slashrootawk[$temp].$slash[$i]."temp\"";
  272. $configreal=$slashrootreal[$temp].$slash[$i];
  273. $configtemp=$slashrootreal[$temp].$slash[$i]."temp";
  274.  
  275. ///////////// Section SET  NEW configfiles for addons/update OR DELETE /////////////
  276. $configrealnew=$slashrootreal[$temp].$slash[$i].".new";
  277. if (!file_exists($configreal) && file_exists($configrealnew))
  278.     { 
  279.             
  280.             if (!@copy($configrealnew, $configreal)) 
  281.                 {}            
  282.             else { unlink ($configrealnew); }
  283.         
  284.     }
  285.     elseif (file_exists($configrealnew))
  286.     { unlink ($configrealnew); }
  287.  
  288.     if ($updatemake=="doppelt")
  289.     { break; }
  290.  
  291. $awkrealm=$awkexe." -v DIR=".$awkslashdir." -v CONFIG=".$awkconfig. " -v CONFIGNEW=".$awkconfigtemp. "  -v SUBSTIT=".$substitslash." -f ".$awk;  
  292.  
  293.  
  294. if (file_exists($awk) && file_exists($awkexe) && file_exists($configreal)) 
  295. {
  296.     shell_exec("$awkrealm");
  297.  
  298.     if (file_exists($configtemp) && file_exists($configreal))
  299.     {
  300.     if (!@copy($configtemp, $configreal)) 
  301.         {
  302.         // echo "\r\n\r\n$configtemp could not be copied to $configreal";
  303.         }
  304.         else { unlink ($configtemp); }
  305.     } 
  306. }
  307.  
  308.  
  309. //// Configure httpd.conf for JDK 
  310. unset($newzeile);
  311. $include = "\r\nInclude conf/java.conf"; 
  312.    $i=0;    
  313.     $datei = fopen($confhttpdroot,'r');
  314.     while(!feof($datei)) 
  315.     {
  316.     $zeile = fgets($datei,255);
  317.     $newzeile[]=$zeile; 
  318.     $i++; 
  319.     }
  320.     fclose($datei);
  321.  
  322. $datei = fopen($confhttpdroot,'w'); 
  323.         if($datei) 
  324.             { 
  325.                 for($z=0;$z<$i+1;$z++) 
  326.                 { 
  327.                     
  328.                     fputs($datei,$newzeile[$z]); 
  329.                     
  330.                 }
  331.             fputs($datei,$include);
  332.             }
  333. fclose($datei);
  334. echo "\r\n  Configure Apache-Java in the \"java.conf\" ... ok";
  335. sleep(1);
  336.  
  337.  
  338. //// Create a javaupdate.sys file
  339. $datei = fopen($javasysroot,'w+');
  340. $update = "java";
  341. $updateversion = "1.4.9";
  342. $setjava.="javaaddon=1.4.9\r\n";
  343. $setjava.="javadir=$javapath";
  344. fputs($datei,$setjava); 
  345. fclose($datei);
  346.  
  347. //// Checking the install.sys file
  348. unset($newzeile);
  349. if (file_exists($installsysroot)) 
  350. {
  351.     $datei = fopen($installsysroot,'r');
  352.     unset($newzeile);
  353.     $i=0;
  354.     while(!feof($datei)) 
  355.     {
  356.     $zeile = fgets($datei,255);
  357.     $newzeile[]=$zeile; 
  358.     $i++; 
  359.     }
  360.     fclose($datei);
  361. }
  362.  
  363. $datei = fopen($installsysroot,'w'); 
  364.         if($datei) 
  365.             { 
  366.                 for($z=0;$z<$i+1;$z++) 
  367.                 { 
  368.                     if (eregi($update,$newzeile[$z]))
  369.                     {
  370.                         list ($left, $right) = split ('=', $newzeile[$z]);
  371.                         
  372.                         $left = eregi_replace (" ","",$left);
  373.                         $left = eregi_replace ("\r\n","",$left);
  374.                         $right = eregi_replace ("\r\n","",$right);
  375.                         $currentversionzahl = eregi_replace ("\.","",$right);
  376.                         if ($currentversionzahl == 0 )
  377.                         {
  378.                             $updatemake="makenew"; // New installation
  379.                             $putnew="$update = $updateversion\r\n";
  380.                             fputs($datei, $putnew);
  381.                         }
  382.                         elseif ($currentversionzahl < $updateversionzahl)
  383.                         {
  384.                             $updatemake="update";  // Update installation
  385.                             $putnew="perl = $updateversion\r\n";
  386.                             fputs($datei, $putnew);
  387.                         }
  388.                         else
  389.                         {
  390.                             $updatemake="doppelt"; // Installation is current
  391.                             fputs($datei,$newzeile[$z]); 
  392.                         }
  393.  
  394.                     }
  395.                     else 
  396.                     { 
  397.                     fputs($datei,$newzeile[$z]); 
  398.                     }
  399.                 }
  400.             }
  401.     fclose($datei);
  402.  
  403.  
  404. }
  405.  
  406.  
  407.  
  408. if (file_exists($javahometmp)) 
  409.     {
  410.      unlink ($javahometmp); 
  411.     } 
  412.  
  413.  
  414.  
  415.  
  416.  
  417.  
  418.  
  419. echo "\r\n\r\n  SETUP COMPLETE. ALL DONE!";
  420. echo "\r\n\r\n  --- For loading all new setting (re)start the Apache ---";
  421. echo "\r\n  --- Do not forget to start the Tomcat with the \"tomcat_start.bat\" ---\r\n";
  422. sleep(1);
  423. echo "\r\n\r\n  :-) Kay Vogelgesang (www.apachefriends.org) (-: \r\n\r\n";
  424.  
  425.  
  426.  
  427. exit();
  428. ?>
  429.