forked from stuporglue/TreeTrumpet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
unbuild.php
executable file
·125 lines (109 loc) · 4.19 KB
/
unbuild.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#!/usr/bin/env php
<?php
# This is the unbuild script for TreeTrumpet
# It is meant to be run from the command line, but should work from a browser
# if the server has write permissions to the current folder
function recurse_copy($src,$dst) {
$dir = opendir($src);
@mkdir($dst,'01777',TRUE);
while(false !== ( $file = readdir($dir)) ) {
if (( $file != '.' ) && ( $file != '..' )) {
if ( is_dir($src . '/' . $file) ) {
recurse_copy($src . '/' . $file,$dst . '/' . $file);
}
else {
@copy($src . '/' . $file,$dst . '/' . $file);
}
}
}
closedir($dir);
}
// Destination directories
$destdir = 'treetrumpet';
$directories = Array(
"$destdir/model",
"$destdir/view",
"$destdir/controller",
"$destdir/css/3rdparty/ui",
"$destdir/js/3rdparty/ui",
"$destdir/img",
"$destdir/lib/3rdparty",
"$destdir/lib/3rdparty/phpmailer",
"$destdir/lib/licenses",
"$destdir/cache",
"$destdir/media"
);
// @copy files
{
// @copy base TreeTrumpet files
$base = glob("$destdir/*.php");
foreach($base as $i => $file){
if($file == 'build.php'){
continue;
}else if(is_file($file)){
@copy($file,"$file");
}
}
recurse_copy("$destdir/model","model");
recurse_copy("$destdir/view","view");
recurse_copy("$destdir/controller","controller");
recurse_copy("$destdir/img","img");
// Other root-dir files
@copy("$destdir/php.ini",'php.ini');
@copy("$destdir/.htaccess",'htaccess');
@copy("$destdir/favicon.ico",'favicon.ico');
@copy("$destdir/config.php.example",'config.php.example');
@copy("$destdir/family.ged.sample",'lib/ged2json/examples/moore.ged');
$base_dirs = Array('./img/','./lib/','./css/','./js/');
foreach($base_dirs as $src){
foreach(glob("$destdir/$src/*") as $file){
if(is_file($file)){
@copy($file,"$src/" . basename($file));
}
}
}
// } jQRangeSlider files
@copy("$destdir/js/3rdparty/jQEditRangeSlider-min.js","js/jQRangeSlider/dest/jQEditRangeSlider-min.js");
@copy("$destdir/js/3rdparty/jquery.mousewheel.min.js","js/jQRangeSlider/lib/jquery.mousewheel.min.js");
@copy("$destdir/lib/licenses/jquery.mousewheel.txt","js/jQRangeSlider/lib/jquery.mousewheel.license.txt");
@copy("$destdir/css/3rdparty/iThing.css","js/jQRangeSlider/css/iThing.css");
// Leaflet.markercluster
@copy("$destdir/js/3rdparty/leaflet.markercluster.js","js/Leaflet.markercluster/dist/leaflet.markercluster.js");
@copy("$destdir/css/3rdparty/MarkerCluster.css","js/Leaflet.markercluster/dist/MarkerCluster.css");
@copy("$destdir/css/3rdparty/MarkerCluster.Default.css","js/Leaflet.markercluster/dist/MarkerCluster.Default.css");
@copy("$destdir/lib/licenses/Leaflet.markercluster.txt","js/Leaflet.markercluster/MIT-LICENCE.txt");
// ged2json
foreach(glob("lib/ged2json/examples/php/lib/*") as $file){
if(is_file($file)){
$destfile = basename($file);
@copy("$destdir/lib/3rdparty/$destfile",$file);
}
}
@copy("$destdir/lib/3rdparty/ssgeocoder.php","lib/ged2json/examples/php/lib/ssgeocoder/ssgeocoder.php");
recurse_copy("$destdir/lib/3rdparty/php-gedcom/library","lib/ged2json/examples/php/lib/php-gedcom/library");
recurse_copy("$destdir/lib/php-gedcom-custom","lib/php-gedcom-sqlite");
// Pedigree Viewer
foreach(glob("js/Pedigree-Viewer/js/*") as $file){
if(is_file($file)){
@copy("$destdir/js/3rdparty/" . basename($file),$file);
}
}
foreach(glob("js/Pedigree-Viewer/css/*") as $file){
if(is_file($file)){
@copy("$destdir/css/3rdparty/" . basename($file),$file);
}
}
foreach(glob("js/Pedigree-Viewer/css/ui/*") as $file){
if(is_file($file)){
@copy("$destdir/css/3rdparty/ui/" . basename($file),$file);
}
}
// PHPMailer
foreach(glob("lib/phpmailer/*.php") as $file){
if(is_file($file)){
@copy("$destdir/lib/3rdparty/phpmailer/" . basename($file),$file);
}
}
// version file
@unlink("lib/version.txt");
}