This repository was archived by the owner on Dec 21, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCommented Source.php
More file actions
70 lines (52 loc) · 1.96 KB
/
Copy pathCommented Source.php
File metadata and controls
70 lines (52 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?php
// We're going to replace some common strings with variables to save space. This way, we can keep this file as small as possible
$h='http://';
$w='wordpress';
$z='.zip';
// We use $_SERVER variables a lot, so let's use $s instead and save a few bytes
$s=$_SERVER;
// $c = 'wordpress.zip';
$c=$w.$z;
// $n = the name of this file on the server
// $n = basename($_SERVER["SCRIPT_NAME"]);
$n=basename($s["SCRIPT_NAME"]);
// Now we'll delete this file from the server, and cross our fingers that installation goes as planned.
unlink($n);
// Let's download http://wordpress.org/latest.zip to the server as 'wordpress.zip'
copy($h.$w.'.org/latest'.$z,$c);
$b = new ZipArchive;
// Open wordpress.zip so that we can work with the directory structure
$b->open($c);
// The WordPress zip file puts all of the contents in a subdirectory called wordpress. We're going to loop through all the files in the zip, renaming them to the root directory of the zip file
for($i=0;$i<$b->numFiles;$i++) {
$f=$b->getNameIndex($i);
$b->renameName(
$f,
str_replace(
$w.'/',
'',
$f
)
);
}
$b->close();
// Here, we're just saving the changes and reopening the zip file. Yes, it seems stupid to me too, but the changes didn't seem to work unless this step was performed.
$b=new ZipArchive;
$b->open($c);
// Extact the contents of wordpress.zip to the current directory on the server
$b->extractTo('./');
$b->close();
// Now that everything is in place, we can delete wordpress.zip from the server
unlink($c);
/**
Finally, we can kick the user out of this script and over to WordPress setup.
Because we have made no changes to wp-config.php we need to direct the user to
setup-config.php instead of wp-install.php
'http://'.$_SERVER["HTTP_HOST"].
str_replace(
basename($_SERVER["SCRIPT_NAME"]),
'wp-admin/setup-config.php',
$_SERVER['REQUEST_URI']
)
**/
header('Location: '.$h.$s["HTTP_HOST"].str_replace($n,'wp-admin/setup-config.php',$s['REQUEST_URI']));