-
Notifications
You must be signed in to change notification settings - Fork 61
/
Copy pathbuild.php
71 lines (54 loc) · 1.19 KB
/
build.php
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
if ($argc != 2) {
echo "必须指定版本号";
exit;
}
$version=$argv[1];
$dirs = array(".");
$ignores = array(
'README.md',
'build.php',
'install.php',
'install_template.txt',
'mc-debug'
);
$files = '';
build($dirs, $files);
$template = file_get_contents("install.txt");
$template = str_replace('/*MINICMS_VERSION*/', $version, $template);
$template = str_replace('/*MINICMS_FILES*/', $files, $template);
file_put_contents("install.php", $template);
function build($dirs, &$files) {
global $ignores;
foreach ($dirs as $dir) {
if (!is_dir($dir)) {
echo "目录\"$dir\"不存在";
exit;
}
if ($dh = opendir($dir)) {
$sub_dirs = array();
while (($item = readdir($dh)) !== false) {
if ($item[0] == '.')
continue;
if ($dir == '.')
$file = $item;
else
$file = $dir."/".$item;
if (in_array($file, $ignores))
continue;
if (is_dir($file)) {
$sub_dirs[] = $file;
} else {
$files .= "install('$file', '";
$files .= base64_encode(gzcompress(file_get_contents($file)));
$files .= "');\n";
}
}
closedir($dh);
build($sub_dirs, $files);
} else {
echo "目录\"$dir\"无法访问";
exit;
}
}
}