Skip to content

Instantly share code, notes, and snippets.

@tschoffelen
Last active February 12, 2024 09:20
Show Gist options
  • Save tschoffelen/8087707 to your computer and use it in GitHub Desktop.
Save tschoffelen/8087707 to your computer and use it in GitHub Desktop.

Revisions

  1. tschoffelen revised this gist Nov 24, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion install.php
    Original file line number Diff line number Diff line change
    @@ -3,7 +3,7 @@
    echo '<span style="color:blue">DOWNLOADING...</span>'.PHP_EOL;

    // Download file
    file_put_contents('wp.zip', file_get_contents('http://wordpress.org/latest.zip'));
    file_put_contents('wp.zip', file_get_contents('https://wordpress.org/latest.zip'));

    $zip = new ZipArchive();
    $res = $zip->open('wp.zip');
  2. tschoffelen created this gist Dec 22, 2013.
    68 changes: 68 additions & 0 deletions install.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,68 @@
    <?php
    echo '<pre>';
    echo '<span style="color:blue">DOWNLOADING...</span>'.PHP_EOL;

    // Download file
    file_put_contents('wp.zip', file_get_contents('http://wordpress.org/latest.zip'));

    $zip = new ZipArchive();
    $res = $zip->open('wp.zip');
    if ($res === TRUE) {

    // Extract ZIP file
    $zip->extractTo('./');
    $zip->close();
    unlink('wp.zip');

    // 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);
    }else{
    echo '[DIR] '.$file . PHP_EOL;
    @mkdir($file);
    }
    }

    // Remove wordpress dir
    foreach ($files as $file) {
    if (in_array($file, array(".",".."))) continue;
    if (is_dir($file)){
    echo '[REM] '.$file . PHP_EOL;
    @rmdir($file);
    }
    }
    @rmdir('./wordpress');

    // Check if copy was successful
    if(file_exists('index.php')){

    // Redirect to WP installation page
    echo '<meta http-equiv="refresh" content="1;url=index.php" />';

    }else{
    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;}
    $result[]="$dir/$value";
    if(is_file("$dir/$value")) {continue;}
    foreach(find_all_files("$dir/$value") as $value)
    {
    $result[]=$value;
    }
    }
    return $result;
    }
    ?>