Skip to content

Fixed install.php script

<?php


		/*
	#### Installer PHP  1.5 ####
	#### Author: Kay Vogelgesang & Carsten Wiedmann for www.apachefriends.org 2005 ####
	*/

	/// Where I stand? ///
	$curdir = getcwd();
  $usbstick="0";
  
  if ( $_SERVER["argv"][1] == "usb" ) {
            // echo   $_SERVER["argv"][1];
            $usbstick="1";
            echo "\r\n  ########################################################################\n";
	echo "  #                                                                      #\r\n";
	echo "  #                  XAMPP USB Stick Installation                        #\r\n";;
	echo "  #                                                                      #\r\n";
	echo "  ########################################################################\r\n\r\n";
  }



	list($partition, $nonpartition) = preg_split ("/:/", $curdir); //Fix by Wiedmann
	$partwampp = substr(realpath(__FILE__), 0, strrpos(dirname(realpath(__FILE__)), '\\'));

	$directorwampp = NULL;                                                  
	if ($usbstick == "1" ) {
	   $dirpartwampp=$nonpartition;
  } else {
  	$dirpartwampp=$partwampp;
  }
	
    //fix by Maxime: $awkpart = str_replace("&", "\\\\&", eregi_replace ("\\\\", "\\\\", $dirpartwampp)); //Fix by Wiedmann
	//fix by Maxime: $awkpartslash = str_replace("&", "\\\\&", ereg_replace ("\\\\", "/", $dirpartwampp)); //Fix by Wiedmann
	$awkpart = str_replace("&", "\\\\&", preg_replace ("/\\\\/i", "\\\\", $dirpartwampp)); //Fix by Wiedmann
	$awkpartslash = str_replace("&", "\\\\&", preg_replace ("/\\\\/", "/", $dirpartwampp)); //Fix by Wiedmann
	
	// Only debug
  // echo $partition."\n";
	// 	echo $nonpartition."\n";
	//		echo $partwampp."\n\n";
          // echo $awkpart."\n"; 
				    // echo $awkpartslash."\n";
				          // exit;			
				
  $phpdir = $partwampp;
	//fix by Maxime: $dir = ereg_replace("\\\\", "/", $partwampp);
	$dir = preg_replace("/\\\\/", "/", $partwampp);
	
	$ppartition = "$partition:";

	/// I need the install.sys + update.sys for more xampp informations
	$installsys = "install.sys";
	$installsysroot = $partwampp."\install\\".$installsys;

	/// Some addon|update.sys files
	$perlupdatesys = "perlupdate.sys";
	$pythonupdatesys = "pythonupdate.sys";
	$serverupdatesys = "serverupdate.sys";
	$utilsupdatesys = "utilsupdate.sys";
	$javaupdatesys = "javaupdate.sys";
	$otherupdatesys = "otherupdate.sys";

	/// XAMPP main directrory is ...
	$substit = "\\\\\\\\xampp";
	$substitslash = "/xampp";

	/// Globale variables
	$BS = 0;
	$CS = 0;
	$slashi = 1;
	$bslashi = 1;
	$awkexe = ".\install\awk.exe";
	$awk = ".\install\config.awk";
	$awknewdir = "\"".$awkpart."\"";
	$awkslashdir = "\"".$awkpartslash."\"";
	if (file_exists("$partwampp\htdocs\\xampp\.version")) {
	$handle = fopen("$partwampp\htdocs\\xampp\.version","r");
  $xamppversion = fgets($handle);
  fclose($handle);
	} else {
		$xamppversion = "?.?.?";
    // include_once "$partwampp\install\.version";
  }
  date_default_timezone_set('UTC');
	echo "\r\n  ########################################################################\n";
	echo "  # ApacheFriends XAMPP setup win32 Version                              #\r\n";
	echo "  #----------------------------------------------------------------------#\r\n";
	echo "  # Copyright (c) 2002-".date("Y")." Apachefriends $xamppversion                          #\r\n";
	echo "  #----------------------------------------------------------------------#\r\n";
	echo "  # Authors: Kay Vogelgesang                      #\r\n";
	echo "  #          Carsten Wiedmann              #\r\n";
	echo "  ########################################################################\r\n\r\n";
	
	$confhttpdroot = $partwampp."\apache\\conf\\httpd.conf";

	// Find the install status for xampp basic package in the install.sys file
	if (file_exists($installsysroot)) {
		$i = 0;
		$datei = fopen($installsysroot, 'r');
		while (!feof($datei)) {
			$zeile = fgets($datei, 255);
			if ( $zeile == "usbstick = 1" ) {
        echo "  USB stick installation found! Using relative paths by default ($nonpartition).";
          $dirpartwampp=$nonpartition;
          $usbstick="1";
          $partwampp=$nonpartition;
        //exit;
      } 
			$sysroot[] = $zeile;
			$i += 1;
		}
		fclose($datei);

		$sysroot[2] = str_replace('perl', 'server', $sysroot[2]); // Fix by Wiedmann
		file_put_contents($installsysroot, implode('', $sysroot));

		list($left, $right) = preg_split ("/ = /", $sysroot[0]);
		//fix by Maxime:$right = eregi_replace ("\r\n", "", $right);
		$right = preg_replace ("/\r\n/i", "", $right);
		if (strtolower($partwampp) == strtolower($right)) {
			$xamppinstaller = "nothingtodo";
		} else {
			$xamppinstaller = "newpath";
			//fix by Maxime: $substit = eregi_replace ("\\\\", "\\\\\\\\", $right);
			//fix by Maxime: $substitslash = eregi_replace("\\\\", "/", $right);
			$substit = preg_replace ("/\\\\/i", "\\\\\\\\", $right);
			$substitslash = preg_replace("/\\\\/i", "/", $right);
		}
	} else {
		$installsys = fopen($installsysroot, 'w');
		if ( $usbstick == "1" ) {
		$wamppinfo = "DIR = $nonpartition\r\nxampp = $xamppversion\r\nserver = 0\r\nperl = 0\r\npython = 0\r\nutils = 0\r\njava = 0\r\nother = 0\r\nusbstick = $usbstick";
		} else {
    $wamppinfo = "DIR = $partwampp\r\nxampp = $xamppversion\r\nserver = 0\r\nperl = 0\r\npython = 0\r\nutils = 0\r\njava = 0\r\nother = 0\r\nusbstick = $usbstick";
    }
    fputs($installsys, $wamppinfo);
		fclose($installsys);
		$xamppinstaller = "newinstall";
	}

	/// Find some *update.sys files and modify the install.sys ...
	$path = $partwampp."\install\\";
	$hdl = opendir($path);
	while ($res = readdir($hdl)) { //Searching all xampp sys files
		$array[] = $res;
	 }
	closedir($hdl);
	$werte = count($array);
	for ($q = 2; $q  Must take old Section for addon functality
		$datei = fopen($installsysroot,'w'); 
        if($datei) 
            { 
                for($z=0;$z<$i+1;$z++) 
                { 
					if (0 === stripos(trim($newzeile[$z]), trim($update))) // Fix by Wiedmann

					{
						list ($left, $right) = preg_split ("/=/", $newzeile[$z]);
						
						//fix by Maxime: $left = eregi_replace (" ","",$left);
						//fix by Maxime: $left = eregi_replace ("\r\n","",$left);
						//fix by Maxime: $right = trim(eregi_replace ("\r\n","",$right));
						//fix by Maxime: $currentversionzahl = eregi_replace ("\.","",sprintf('%0-6s',$right)); // Fix by Wiedmann
						$left = preg_replace ("/ /i","",$left);
						$left = preg_replace ("/\r\n/i","",$left);
						$right = trim(preg_replace ("/\r\n/i","",$right));
						$currentversionzahl = preg_replace ("/\./i","",sprintf('%0-6s',$right)); // Fix by Wiedmann
						if ($currentversionzahl == 0 )
						{
							$updatemake="makenew"; // New installation
							$putnew="$update = $updateversion\r\n";
							fputs($datei, $putnew);
						}
						elseif ($currentversionzahl  Old Section for addon functality end here

				
					if (($updatemake == "makenew") || ($updatemake=="doppelt")) {
						include_once "$partwampp\install\\$updateinc";
					}
				}
				// httpd.conf modification for Perl, Python or Java (only single)
				////// PATH CHANGING SINCE APACHE 2.2 
				/* if ($update == "perl") {
					$includehttpdconf = "\r\n\r\nInclude conf/extra/perl.conf";
				} */
				if ($update == "python") {
					$includehttpdconf = "\r\n\r\nInclude conf/extra/python.conf";
				}
				/* if ($update == "java") {
					$includehttpdconf = "\r\n\r\nInclude conf/extra/java.conf";
				} */
		if ((($update == "perl") || ($update == "python") || ($update == "java")) && ($updatemake == "makenew")) {
					$datei = fopen($confhttpdroot, 'a');
					if ($datei) {
						fputs($datei, $includehttpdconf);
					}
					@fclose($datei);
					/* $datei = fopen($confhttpd2root, 'a');
					if ($datei) {
						fputs($datei, $includehttpdconf);
					}
					fclose($datei);
					$datei = fopen($confhttpd3root, 'a');
					if ($datei) {
						fputs($datei, $includehttpdconf);
					}
					fclose($datei); */ //Vogelgesang 28.12.06 because obsolet
				}

				unlink($updatesysroot);
			}
		}
	}

	if (($xamppinstaller == "newinstall") || ($xamppinstaller == "newpath")) {
		if ($xamppinstaller == "newinstall") {
			/// First initialization only main packages
			if (file_exists("$partwampp\install\\xamppbasic.inc")) {
				include_once "$partwampp\install\\xamppbasic.inc";
			}
			if (file_exists("$partwampp\install\\xamppserver.inc")) { // Fix by Wiedmann
				include_once "$partwampp\install\\xamppserver.inc";
			}
		} else {
			/// Find all the packages
			if (file_exists("$partwampp\install\\xamppbasic.inc")) {
				include_once "$partwampp\install\\xamppbasic.inc";
			}
			if (file_exists("$partwampp\install\\xamppserver.inc")) {
				include_once "$partwampp\install\\xamppserver.inc";
			}
			if (file_exists("$partwampp\install\\xamppperl.inc")) {
				include_once "$partwampp\install\\xamppperl.inc";
			}
			if (file_exists("$partwampp\install\\xampppython.inc")) {
				include_once "$partwampp\install\\xampppython.inc";
			}
			if (file_exists("$partwampp\install\\xampputils.inc")) {
				include_once "$partwampp\install\\xampputils.inc";
			}
			if (file_exists("$partwampp\install\\xamppjava.inc")) {
				include_once "$partwampp\install\\xamppjava.inc";
			}
			if (file_exists("$partwampp\install\\xamppother.inc")) {
				include_once "$partwampp\install\\xamppother.inc";
			}
			$updatemake = "nothingtodo";
		}
	}

	$scount = count($slashrootreal);
	$bcount = count($backslashrootreal);

	/////////////////// xampp path is changing ///////////////////
	if ($xamppinstaller == "newpath") {
		set_time_limit(0);
		define('NEWSTDIN', fopen("php://stdin", "r")); // Fix by Wiedmann
		while ($BS == "0") {
			echo "\n  Do you want to refresh the XAMPP installation?\n";
			echo "  Soll die XAMPP Installation jetzt aktualisiert werden?\n\n";
			echo "  1) Refresh now! (Jetzt aktualisieren!)\n";
			echo "  x) Exit (Beenden)\n";

			switch (trim(fgets(NEWSTDIN, 256))) { // Fix by Wiedmann
				case 1:
					$BS = 1;
					echo "\r\n  XAMPP is refreshing now ...\r\n";
					echo "  XAMPP wird nun aktualisiert ...\r\n\r\n";
					sleep(1);
					break;

				case "x":
					echo "\r\n  The refresh is terminating on demand ...  exit\r\n";
					echo "  Die Aktualisierung wurde auf Wunsch abgebrochen ...\r\n";
					sleep(3);
					exit;

				default:
					exit;
			}
		}
		fclose(NEWSTDIN); // Fix by Wiedmann
	}

	/////////////////// You can configure the addon modules for httpd ///////////////////
	if (file_exists($installsysroot)) {
		$datei = fopen($installsysroot, 'r');
		unset($newzeile);
		$i = 0;
		while (!feof($datei)) {
			$zeile = fgets($datei, 255);
			@list($left, $right) = preg_split ("/=/", $zeile);
			//fix by Maxime: $left = eregi_replace(" ", "", $left);
			//fix by Maxime: $left = eregi_replace("\r\n", "", $left);
			//fix by Maxime: $right = eregi_replace("\r\n", "", $right);
			//fix by Maxime: $right = eregi_replace("\.", "", $right);
			
			$left = preg_replace("/ /i", "", $left);
			$left = preg_replace("/\r\n/i", "", $left);
			$right = preg_replace("/\r\n/i", "", $right);
			$right = preg_replace("/\./i", "", $right);
			if (strtolower($right) > 0) {
				if (strtolower($left) == "perl") {
					$perlactive = "yes";
				}
				if (strtolower($left) == "python") {
					$pythonactive = "yes";
				}
				if (strtolower($left) == "java") {
					$javaactive = "yes";
				}
			}
		}
		fclose($datei);
	}

	/////////////////// Case new install ///////////////////
	if (($xamppinstaller == "newinstall") || ($BS == 1) || ($updatemake == "makenew") || ($updatemake == "doppelt")) {
		if ($BS == "1") {
			echo "  Refreshing all paths in config files ... \r\n\r\n";
		}

		echo "  Configure XAMPP with awk for ";
		$system = system("echo '%os%'");
		if ($system != "'Windows_NT'") {
			$system = "Windows";
			echo "  $system 98/ME/HOME";
		}
		echo "  Updating configuration files ... please wait ...";
		if ($xamppinstaller == "newinstall") {
			if ($system == "Windows") {
				$confhttpdroot = $partwampp."\apache\\conf\\httpd.conf";
				$includewin = "Win32DisableAcceptEx\r\n";
				echo "\r\n  Disable AcceptEx Winsocks v2 support";
				$datei = fopen($confhttpdroot, 'r');
				unset($newzeile);
				$i = 0;
				while (!feof($datei)) {
					$zeile = fgets($datei, 255);
					$newzeile[] = $zeile;
					$i++;
				}
				fclose($datei);
				$datei = fopen($confhttpdroot, 'w');
				if ($datei) {
					for ($z = 0; $z < $i + 1; $z++) {
						//fix by Maxime: if (eregi("Win32DisableAcceptEx", $newzeile[$z])) {
						if (preg_match("/Win32DisableAcceptEx/i", $newzeile[$z])) {
							fputs($datei, $includewin);
						} else {
							fputs($datei, $newzeile[$z]);
						}
					}
				}
				fclose($datei);
			} else {
				$confhttpdroot = $partwampp."\apache\\conf\\httpd.conf";
				$includewin = "# Win32DisableAcceptEx\r\n";
				// echo "\r\n  Enable AcceptEx Winsocks v2 support";
				$datei = fopen($confhttpdroot, 'r');
				$i = 0;
				unset($newzeile);
				while (!feof($datei)) {
					$zeile = fgets($datei, 255);
					$newzeile[] = $zeile;
					$i++;
				}
				fclose($datei);
				$datei = fopen($confhttpdroot, 'w');
				if ($datei) {
					for ($z = 0; $z  "\\\\^",
			"." => "\\\\.",
			"[" => "\\\\[",
			"$" => "\\\\$",
			"(" => "\\\\(",
			")" => "\\\\)",
			"+" => "\\\\+",
			"{" => "\\\\{"
		);
		$substit = strtr($substit, $trans);
		for ($i = 0; $i  "\\\\^",
			"." => "\\\\.",
			"[" => "\\\\[",
			"$" => "\\\\$",
			"(" => "\\\\(",
			")" => "\\\\)",
			"+" => "\\\\+",
			"{" => "\\\\{"
		);
		$substitslash = strtr($substitslash, $trans);
		for ($i = 0; $i <= $scount; $i++) {
			///// 08.08.05 Vogelgesang: For all files with identical file names /////
			if ($slash[$i] == "") {
				$upslashrootreal = $slashrootreal[$i];
			} else {
				$configname = $slash[$i];
				$upslashrootreal = $slashrootreal[$configname].$configname;
			}
			//fix by Maxime: $slashawk = eregi_replace("\\\\", "\\\\", $upslashrootreal);
			$slashawk = preg_replace("/\\\\/i", "\\\\", $upslashrootreal);
			$slashawk = "\"".$slashawk;
			$awkconfig = $slashawk."\"";
			$awkconfigtemp = $slashawk."temp\"";
			$configreal = $upslashrootreal;
			$configtemp=$upslashrootreal."temp";

			///////////// Section SET  NEW configfiles for addons/update OR DELETE /////////////
			$configrealnew = $upslashrootreal.".new";
			if (!file_exists($configreal) && file_exists($configrealnew)) {
				if (!@copy($configrealnew, $configreal)) {
				} else {
					unlink($configrealnew);
				}
			} elseif (file_exists($configrealnew)) {
				unlink($configrealnew);
			}

			if ($updatemake == "doppelt") {
				break;
			}
      // echo "DEBUG: Working with $awkconfig now ... \r\n";
			$awkrealm = $awkexe." -v DIR=".$awkslashdir." -v CONFIG=".$awkconfig. " -v CONFIGNEW=".$awkconfigtemp. "  -v SUBSTIT=".$substitslash." -f ".$awk;

			if (file_exists($awk) && file_exists($awkexe) && file_exists($configreal)) {
				$handle = popen($awkrealm, 'w'); // Fix by Wiedmann
				pclose($handle);
			}

			if (file_exists($configtemp) && file_exists($configreal)) {
				if (!@copy($configtemp, $configreal)) {
				} else {
					unlink($configtemp);
				}
			}
		}

		if (($xamppinstaller == "newpath") || ($BS == 1)) {
			if (file_exists($installsysroot)) {
				$datei = fopen($installsysroot, 'r');
				unset($newzeile);
				$i = 0;
				while (!feof($datei)) {
					$zeile = fgets($datei, 255);
					$newzeile[] = $zeile;
					$i++;
				}
				fclose($datei);
			}

			$datei = fopen($installsysroot, 'w');
			if ($datei) {
				for ($z = 0; $z  0) {
			$i = 0;
			$datei = fopen($confhttpdroot, 'r');
			while (!feof($datei)) {
				$zeile = fgets($datei, 255);
				$newzeile[] = $zeile;
				$i++;
			}
			fclose($datei);
			$datei = fopen($confhttpdroot, 'w');
			if ($datei) {
				for ($z = 0; $z < $i + 1; $z++) {
					//fix by Maxime: if (eregi($searchstring, $newzeile[$z])) {
					if (preg_match("/" . $searchstring . "/i", $newzeile[$z])) {
						fputs($datei, $include);
					} else {
						fputs($datei, $newzeile[$z]);
					}
				}
			}
			fclose($datei);
			unset($newzeile);
			
			/// Vogelgesang 28.12.06 because obsolet since 1.51
			/* $i = 0;
			$datei = fopen($confhttpd2root, 'r');
			while (!feof($datei)) {
				$zeile = fgets($datei, 255);
				$newzeile[] = $zeile;
				$i++;
			}
			fclose($datei);
			$datei = fopen($confhttpd2root, 'w');
			if ($datei) {
				for($z = 0; $z < $i + 1; $z++) {
					if (eregi($searchstring, $newzeile[$z])) {
						fputs($datei, $include);
					} else {
						fputs($datei, $newzeile[$z]);
					}
				}
			}
			fclose($datei);
			unset($newzeile);
			$i = 0;
			$datei = fopen($confhttpd3root, 'r');
			while (!feof($datei)) {
				$zeile = fgets($datei, 255);
				$newzeile[] = $zeile;
				$i++;
			}
			fclose($datei);
			$datei = fopen($confhttpd3root, 'w');
			if ($datei) {
				for ($z = 0; $z < $i + 1; $z++) {
					if (eregi($searchstring, $newzeile[$z])) {
						fputs($datei, $include);
					} else {
						fputs($datei, $newzeile[$z]);
					}
				}
			}
			fclose($datei);
			unset($newzeile);*/ 
			echo "  Done!\r\n\r\n";
		}
	}

	if (file_exists($partwampp.'\install\serverupdate.inc')) { // Fix by Wiedmann
		include $partwampp.'\install\serverupdate.inc';
		unlink($partwampp.'\install\serverupdate.inc');
		echo "\r\n".'Ready.'."\r\n";
	}

	if ($updatemake == "") {
		$updatemake="nothingtodo";
	}

	if (($updatemake == "nothingtodo") && ($xamppinstaller == "nothingtodo") && (($CS 
Laisser un commentaire

Laisser un commentaire

Entrez vos coordonnées ci-dessous ou cliquez sur une icône pour vous connecter:

Logo WordPress.com

Vous commentez à l'aide de votre compte WordPress.com. Déconnexion / Changer )

Image Twitter

Vous commentez à l'aide de votre compte Twitter. Déconnexion / Changer )

Photo Facebook

Vous commentez à l'aide de votre compte Facebook. Déconnexion / Changer )

Photo Google+

Vous commentez à l'aide de votre compte Google+. Déconnexion / Changer )

Connexion à %s

%d blogueurs aiment cette page :