-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.php
More file actions
68 lines (47 loc) · 1.7 KB
/
install.php
File metadata and controls
68 lines (47 loc) · 1.7 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
<?php
if (PHP_SAPI != 'cli')
exit('command line run only!');
exit('Not implemented');
define('FS_ROOT', dirname(__FILE__).'/');
require_once(FS_ROOT.'setup.php');
function skipExcess($filename) {
$newContent = array();
$skipping = false;
foreach (file($filename) as $row) {
if (strpos($row, '<generation-skip>') !== FALSE)
$skipping = TRUE;
elseif (strpos($row, '</generation-skip>') !== FALSE)
$skipping = FALSE;
elseif (!$skipping)
$newContent[] = $row;
}
file_put_contents($filename, implode('', $newContent));
}
echo "This script helps you to create new application skeleton\n";
$args = Cmd::parseArgs(array('dir'));
if (!isset($args['dir']))
$args['dir'] = Cmd::readLn('Enter target directory');
if (empty($args['dir']))
exit("ERROR: target dir is not specified\n");
elseif (!is_dir($args['dir']))
exit("ERROR: target dir is not exists\n");
elseif (!is_writeable($args['dir']))
exit("ERROR: target dir is not writeable\n");
elseif (count(scandir($args['dir'])) > 2)
exit("ERROR: target dir is not empty\n");
$trgDir = rtrim($args['dir'], '/').'/';
echo "copy files\n";
foreach (array('config.php', 'func.php', 'index.php', 'setup.php') as $tpl)
copy(FS_ROOT.$tpl, $trgDir.$tpl);
echo "copy classes\n";
exec('cp -r '.FS_ROOT.'classes '.escapeshellarg($trgDir));
echo "copy templates\n";
mkdir($trgDir.'templates');
foreach (array('layout.php', 'index.php') as $tpl)
copy(FS_ROOT.'templates/'.$tpl, $trgDir.'templates/'.$tpl);
echo "copy _sql\n";
exec('cp -r '.FS_ROOT.'_sql '.escapeshellarg($trgDir));
echo "clear excess content\n";
foreach (array('classes/FrontController.class.php', 'templates/index.php', '_sql/structure.sql') as $file)
skipExcess($trgDir.$file);
echo "\nCOMPLETE!\n";