Skip to content

Instantly share code, notes, and snippets.

@iamcsharper
Created September 23, 2021 10:46
Show Gist options
  • Save iamcsharper/038b31694a17b172624e43cfc40bd178 to your computer and use it in GitHub Desktop.
Save iamcsharper/038b31694a17b172624e43cfc40bd178 to your computer and use it in GitHub Desktop.
install mediawiki to current folder
<?php
set_time_limit(0);
// Function to remove folders and files
function rrmdir($dir) {
if (is_dir($dir)) {
$files = scandir($dir);
foreach ($files as $file)
if ($file != "." && $file != "..") rrmdir("$dir/$file");
rmdir($dir);
}
else if (file_exists($dir)) unlink($dir);
}
// Function to Copy folders and files
function rcopy($src, $dst) {
// if (file_exists ( $dst ))
// rrmdir ( $dst );
if (is_dir ( $src )) {
mkdir ( $dst );
$files = scandir ( $src );
foreach ( $files as $file )
if ($file != "." && $file != "..")
rcopy ( "$src/$file", "$dst/$file" );
} else if (file_exists ( $src ))
copy ( $src, $dst );
}
function downloadMediaWiki() {
$fp = fopen('./test.zip', 'w');
$ch = curl_init('https://releases.wikimedia.org/mediawiki/1.36/mediawiki-1.36.1.zip');
curl_setopt($ch, CURLOPT_TIMEOUT, 120);
// write curl response to file
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_exec($ch);
curl_close($ch);
fclose($fp);
}
downloadMediaWiki();
$zip = new ZipArchive;
if ($zip->open('test.zip') === TRUE) {
$zip->extractTo('./');
$zip->close();
unlink('test.zip');
echo 'готово';
} else {
echo 'ошибка';
}
rcopy('./mediawiki-1.36.1', './');
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment