1515}
1616
1717//load composer.json and get the "name" of pack
18- $ namespace = @json_decode (file_get_contents (__DIR__ .'/composer.json ' ))->name ;
18+ $ name = @json_decode (file_get_contents (__DIR__ .'/composer.json ' ))->name ;
1919
20- $ namespace = explode ('/ ' , $ namespace );
20+ $ namespace = explode ('/ ' , $ name );
2121
2222$ appConfig = $ composer ['Config \\' ][0 ].'/ ' ;
2323
2626}
2727
2828$ thisConfig = __DIR__ .'/Config/ ' ;
29- //exit("\n\n\---> $appConfig\n");
3029
3130if (!is_dir ($ thisConfig )) {
3231 ret ("I can't find 'Config' directory in this pack! " );
4039$ copy = copyDirectoryContents ($ thisConfig , $ appConfig );
4140
4241//Return to application installer
43- ret ($ copy === true ? " $ namespace instaled! " : $ copy );
42+ ret ($ copy === true ? " $ name instaled! " : $ copy );
4443
4544// THE END ...
4645
5554 *
5655 * @return bool status of directory (exists/created = false or true)
5756 */
58- function checkAndOrCreateDir ($ dir , $ create = false , $ perm = 0777 )
59- {
60- if (is_dir ($ dir ) && is_writable ($ dir )) {
61- return true ;
62- } elseif ($ create === false ) {
63- return false ;
64- }
6557
66- @mkdir ($ dir , $ perm , true );
67- @chmod ($ dir , $ perm );
58+ if (!function_exists ('checkAndOrCreateDir ' )) {
59+ function checkAndOrCreateDir ($ dir , $ create = false , $ perm = 0777 )
60+ {
61+ if (is_dir ($ dir ) && is_writable ($ dir )) {
62+ return true ;
63+ } elseif ($ create === false ) {
64+ return false ;
65+ }
6866
69- if (is_writable ($ dir )) {
70- return true ;
67+ @mkdir ($ dir , $ perm , true );
68+ @chmod ($ dir , $ perm );
69+
70+ if (is_writable ($ dir )) {
71+ return true ;
72+ }
73+ return false ;
7174 }
72- return false ;
73- }
7475
7576/**
7677 * Copy entire content of the $dir[ectory]
@@ -80,37 +81,37 @@ function checkAndOrCreateDir($dir, $create = false, $perm = 0777)
8081 *
8182 * @return bool True/false success
8283 */
83- function copyDirectoryContents ($ dir , $ target )
84- {
85- $ dir = rtrim ($ dir , "\\/ " ).'/ ' ;
86- $ target = rtrim ($ target , "\\/ " ).'/ ' ;
87-
88- if (!checkAndOrCreateDir ($ target , true , 0777 )) {
89- return "ERROR: can't create directory ' $ taget'! " ;
90- }
84+ function copyDirectoryContents ($ dir , $ target )
85+ {
86+ $ dir = rtrim ($ dir , "\\/ " ).'/ ' ;
87+ $ target = rtrim ($ target , "\\/ " ).'/ ' ;
9188
92- foreach (scandir ($ dir ) as $ file ) {
93- if ($ file == '. ' || $ file == '.. ' ) {
94- continue ;
89+ if (!checkAndOrCreateDir ($ target , true , 0777 )) {
90+ return "ERROR: can't create directory ' $ taget'! " ;
9591 }
9692
97- if (is_dir ($ dir .$ file )) {
98- if (!checkAndOrCreateDir ($ target .$ file , true , 0777 )) {
99- return "ERROR: can't create directory ' $ taget$ file'! " ;
100- } else {
101- $ copy = copyDirectoryContents ($ dir .$ file , $ target .$ file );
102- if ($ copy !== true ) {
103- return $ copy ;
104- }
93+ foreach (scandir ($ dir ) as $ file ) {
94+ if ($ file == '. ' || $ file == '.. ' ) {
95+ continue ;
10596 }
106- } elseif (is_file ($ dir .$ file )) {
107- if (!copy ($ dir .$ file , $ target .$ file )) {
108- echo "\n ERROR: can't copy ' $ target$ file'! " ;
97+
98+ if (is_dir ($ dir .$ file )) {
99+ if (!checkAndOrCreateDir ($ target .$ file , true , 0777 )) {
100+ return "ERROR: can't create directory ' $ taget$ file'! " ;
101+ } else {
102+ $ copy = copyDirectoryContents ($ dir .$ file , $ target .$ file );
103+ if ($ copy !== true ) {
104+ return $ copy ;
105+ }
106+ }
107+ } elseif (is_file ($ dir .$ file )) {
108+ if (!copy ($ dir .$ file , $ target .$ file )) {
109+ echo "\n ERROR: can't copy ' $ target$ file'! " ;
110+ }
109111 }
110112 }
113+ return true ;
111114 }
112- return true ;
113- }
114115
115116/**
116117 * Return with message
@@ -119,8 +120,9 @@ function copyDirectoryContents($dir, $target)
119120 *
120121 * @return void print and exit
121122 */
122- function ret ($ msg )
123- {
124- echo "\n - $ msg " ;
125- return true ;
123+ function ret ($ msg )
124+ {
125+ echo "\n - $ msg " ;
126+ return true ;
127+ }
126128}
0 commit comments