Skip to content

Instantly share code, notes, and snippets.

@Rejkowicz
Created December 8, 2017 22:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Rejkowicz/e70499cf15cf5f126da9873b2793cf4d to your computer and use it in GitHub Desktop.
Save Rejkowicz/e70499cf15cf5f126da9873b2793cf4d to your computer and use it in GitHub Desktop.
<?php
function mvdir($oldfolder, $newfolder)
{
$files = scandir($oldfolder);
$oldfolder = "$oldfolder/";
$newfolder = "$newfolder/";
foreach($files as $fname) {
if($fname != '.' && $fname != '..' && "$fname/" != $newfolder) {
rename($oldfolder.$fname, $newfolder.$fname);
}
}
}
if ($_SERVER['REQUEST_METHOD'] === 'POST')
{
unlink(__FILE__);
$backup = '_backup2';
mkdir($backup);
mvdir('.', $backup);
rename($backup, '_backup');
file_put_contents("latest.zip", fopen("https://wordpress.org/latest.zip", 'r'));
$zip = new ZipArchive;
$res = $zip->open('latest.zip');
if ($res === TRUE)
{
$zip->extractTo('.');
$zip->close();
mvdir('wordpress', '.');
unlink('latest.zip');
rmdir('wordpress');
header("Location: wp-admin/setup-config.php");
}
else
{
echo phpinfo();
}
die();
}
?>
<html>
<head>
</head>
<body>
<form action="<?php echo basename(__FILE__); ?>" method="post">
<button name="go">Instaluj</button>
</form>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment