Skip to content

Good tiny PHP Script that downloads recent WordPress and unzips it.

A simple PHP script that automatically downloads and unzips the latest version of WordPress in the current directory (./), so that I don’t have to download it and upload it to my server through FTP manually.


	echo '<pre>';
	echo '<span style="color:blue">DOWNLOADING...</span>'.PHP_EOL;

	// Download file
	file_put_contents('', file_get_contents(''));
	$zip = new ZipArchive();
	$res = $zip->open('');
	if ($res === TRUE) {
		// Extract ZIP file
		// Copy files from wordpress dir to current dir
		$files = find_all_files("wordpress");
		$source = "wordpress/";
		foreach ($files as $file) {
			$file = substr($file, strlen("wordpress/"));
			if (in_array($file, array(".",".."))) continue;
			if (!is_dir($source.$file)){
				echo '[FILE] '.$source.$file .' -> '.$file . PHP_EOL;
				rename($source.$file, $file);
				echo '[DIR]  '.$file . PHP_EOL;
		// Remove wordpress dir
		foreach ($files as $file) {
			if (in_array($file, array(".",".."))) continue;
			if (is_dir($file)){
				echo '[REM]  '.$file . PHP_EOL;
		// Check if copy was successful
			// Redirect to WP installation page
			echo '<meta http-equiv="refresh" content="1;url=index.php" />';
			echo 'Oops, that didn\'t work...';
	} else {
		echo 'Oops, that didn\'t work...';
	function find_all_files($dir) { 
    $root = scandir($dir); 
    foreach($root as $value) { 
        if($value === '.' || $value === '..') {continue;} 
        if(is_file("$dir/$value")) {continue;} 
        foreach(find_all_files("$dir/$value") as $value) 
    return $result; 

Dieser Beitrag hat 0 Kommentare

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert

An den Anfang scrollen