Created
October 19, 2021 08:26
-
-
Save trueqap/71fd1d3d0054c601496668e9b953cb7a to your computer and use it in GitHub Desktop.
WordPress telepítése könnyedén, egy fájl segítségével
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//https://hellowp.club/hu/wordpress-telepitese-konnyeden-egy-telepito-fajl-segitsegevel/ | |
echo '<pre>'; | |
echo '<span style="color:blue">LETÖLTÉS...</span>'.PHP_EOL; | |
file_put_contents('wp.zip', file_get_contents('https://hu.wordpress.org/latest-hu_HU.zip')); | |
$zip = new ZipArchive(); | |
$res = $zip->open('wp.zip'); | |
if ($res === true) { | |
$zip->extractTo('./'); | |
$zip->close(); | |
unlink('wp.zip'); | |
$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 '[FÁJL] '.$source.$file .' -> '.$file . PHP_EOL; | |
rename($source.$file, $file); | |
} else { | |
echo '[KÖNYVTÁR] '.$file . PHP_EOL; | |
mkdir($file); | |
} | |
} | |
foreach ($files as $file) { | |
if (in_array($file, array(".",".."))) { | |
continue; | |
} | |
if (is_dir($file)) { | |
echo '[TÖRLÉS] '.$file . PHP_EOL; | |
recursive_rmdir($file); | |
} | |
} | |
recursive_rmdir('./wordpress'); | |
if (file_exists('index.php')) { | |
echo '<meta http-equiv="refresh" content="1;url=index.php" />'; | |
} else { | |
echo 'A telepítés sikertelen...'; | |
} | |
} else { | |
echo 'A telepítés sikertelen...'; | |
} | |
function find_all_files($dir) | |
{ | |
$root = scandir($dir); | |
foreach ($root as $value) { | |
if ($value === '.' || $value === '..') { | |
continue; | |
} | |
$result[]="$dir/$value"; | |
if (is_file("$dir/$value")) { | |
continue; | |
} | |
foreach (find_all_files("$dir/$value") as $value) { | |
$result[]=$value; | |
} | |
} | |
return $result; | |
} | |
function recursive_rmdir($src) | |
{ | |
$dir = opendir($src); | |
while (false !== ($file = readdir($dir))) { | |
if (($file != '.') && ($file != '..')) { | |
$full = $src . '/' . $file; | |
if (is_dir($full)) { | |
recursive_rmdir($full); | |
} else { | |
unlink($full); | |
} | |
} | |
} | |
closedir($dir); | |
rmdir($src); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment