,

WordPress Installer

web updates kmu GmbH-wuk-WordPress und SEO Agentur WordPress Installer

Um WordPress auf einem Hosting zu installieren, muss dieses imemr zuerst heruntergeladen und entpackt werden. Dies ist Zeitraubend und unnötig.

Um hier Zeit zu sparen, habe ich eine PHP Datei geschrieben, welche nicht nur WordPress, sondern auch direkt nützliche Plugins oder Templates mit installiert.

Welche Sprachen, Templates oder Plugins mit installiert werden können, ist per Array definier bar. Ist dies einmalig erledigt, hat man so sehr schnell einen eigenen Installer nach eigenen Wünschen.

PHP Script hochladen und aufrufen. Warten und WordPRess zu Ende konfigurieren.

Viel Spass mit dem Script:

<!doctype html>
<html lang="de">
<head>
  <meta charset="utf-8">
  <title>WordPress AutoInstaller</title>
  <meta name="description" content="Installiert WordPress automatisch auf einem Hosting">
  <meta name="author" content="web updates kmu GmbH">
  <meta name="author_url" content="http://wuk.ch/">
</head>

<body><?php
/*
   Version: 1.0.0
   Datum:   22.06.2017
   Copyright (c) 2017 web updates kmu <stefan@wuk.ch>
   All rights reserved.
*/

set_time_limit(300);
error_reporting(E_ALL ^ E_NOTICE);

$pfad = pathinfo(realpath(__FILE__), PATHINFO_DIRNAME);
if ( ! is_writeable($pfad) ) { exit("Verzeichnis nicht beschreibbar."); }

$sprachen = array(
		array('Deutsch (Schweiz)','ch-de','https://de-ch.wordpress.org/wordpress-latest-de_CH.zip'),
		array('Deutsch','de','https://de.wordpress.org/wordpress-latest-de_DE.zip'),
		array('Englisch','en','https://wordpress.org/latest.zip')
	);
	
$plugins = array(
		array('Autoptimize','https://downloads.wordpress.org/plugin/autoptimize.zip'),
		array('NoSpam NX','http://downloads.wordpress.org/plugin/nospamnx.zip'),
		array('Yoast SEO','http://downloads.wordpress.org/plugin/wordpress-seo.latest-stable.zip'),
		array('Ninja Firewall','https://downloads.wordpress.org/plugin/ninjafirewall.zip')
	);

function recurse_copy($src,$dst) {
	$dir = opendir($src);
	while(false !== ( $file = readdir($dir)) ) {
		if (( $file != '.' ) && ( $file != '..' )) {
			if ( is_dir($src . '/' . $file) ) {
				recurse_copy($src . '/' . $file,$dst . '/' . $file);
			}
			else {
				copy($src . '/' . $file,$dst . '/' . $file);
			}
		}
	}
	closedir($dir);
} 
function delTree($dir) {
	$files = array_diff(scandir($dir), array('.','..'));
	foreach ($files as $file) {
		(is_dir($dir.DIRECTORY_SEPARATOR .$file)) ? delTree($dir.DIRECTORY_SEPARATOR .$file) : unlink($dir.DIRECTORY_SEPARATOR .$file);
	}
	return rmdir($dir);
}
function dlundunzip($name,$url,$sympfad='') {
	global $sprachen, $plugins;
	$datei = basename($url);
	$pfad = pathinfo(realpath(__FILE__), PATHINFO_DIRNAME).$sympfad;
	$ziel = $pfad .DIRECTORY_SEPARATOR .$datei;

	$ch = curl_init();
	curl_setopt($ch, CURLOPT_URL, "https://de-ch.wordpress.org/".$datei);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
	curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
	curl_setopt($ch, CURLOPT_TIMEOUT, 60);
	$inhalt = curl_exec($ch);
	if(curl_errno($ch)){ echo 'Fehler: ' . curl_error($ch); }
	curl_close($ch);

	$fp = fopen($ziel, "w");
	fputs($fp, $inhalt);
	fclose($fp);

	$zip = new ZipArchive;
	$ressource = $zip->open($ziel);
	if ($ressource === TRUE) {
		$zip->extractTo($pfad);
		$zip->close();
		
		if ($name == 'WordPress') {
			recurse_copy($pfad.DIRECTORY_SEPARATOR ."wordpress", $pfad.DIRECTORY_SEPARATOR);
			delTree($pfad.DIRECTORY_SEPARATOR ."wordpress");
		}
		echo $name." wurde entpackt.<br>";
			
	}
	else {
		echo $name." konnte nicht entpackt werden.<br>";
	}
	unlink($ziel);
}
	
if ($sprachen[$_POST['wpversion']][1] != '') { $step = 'install'; }

switch($step) {
	case 'install':
		set_time_limit(300);
		
		dlundunzip('WordPress',$sprachen[$_POST['wpversion']][2]);
		
		foreach ($plugins as $plu => $gins) {
			if ($_POST['plugin'.$plu] == '1' AND $plugins[$_POST['plugin'.$plu]][0] != '') {
				dlundunzip($plugins[$_POST['plugin'.$plu]][0],$plugins[$_POST['plugin'.$plu]][1],'/wp-content/plugins');
			}
		}

		unlink(__FILE__);
		echo "Tempor&auml;re Dateien und Installer wurde entfernt.<br>Redirekt zur Installation in 5 Sekunden.<br><meta http-equiv=\"refresh\" content=\"5; URL=".(isset($_SERVER['HTTPS']) ? "https" : "http") . "://".$_SERVER['HTTP_HOST'].str_replace(basename($_SERVER['PHP_SELF']),"",$_SERVER['REQUEST_URI'])."\">";
	break;
	
	default:
		echo '<form action="'.$_SERVER['PHP_SELF'].'" method="POST">
			<h3>WordPress Core:</h3>
			<b>WordPress Version:</b> <select name="wpversion">';
				foreach ($sprachen as $spr => $ache) {
					echo '<option value="'.$spr.'"'.($spr == '0' ? ' selected' : '').'>'.$ache[0].'</option>';
				}
			echo '</select>
			<h3>Plugins:</h3>';
				foreach ($plugins as $plu => $gins) {
					echo '<input type="checkbox" name="plugin'.$plu.'" value="1">'.$gins[0].'</option>';
				}
			echo '<br><input type="submit" name="Installation starten" value="Installation starten">
		</form>';
	break;
}

?></body>
</html>

Oder gerne auch gleich hier als Download: wpunzip.php (bitte aus Zip entpacken vor dem hochladen)