-
Notifications
You must be signed in to change notification settings - Fork 4
/
pakrun.php
109 lines (82 loc) · 2.42 KB
/
pakrun.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
<?php
// PAK - OpenCart Extension Packer v0.4.4
require_once '_pak/conf.php';
require_once '_pak/func.php';
require_once '_pak/reqd.php';
/*
set_error_handler(function ($errno, $errstr, $errfile, $errline) {
// error was suppressed with the @-operator
if (@error_reporting() === 0) {
return false;
}
throw new ErrorException($errstr, 0, $errno, $errfile, $errline);
});
*/
$clo = get_clo();
$basename = strtolower(basename(getcwd()));
if (isset($clo[MAKEZIP]) && $clo[MAKEZIP] !== false) {
require_once 'pakdef.php';
$workdir = getWd($clo[MAKEZIP]);
if ($workdir) {
$srcdir = getConcatPath($workdir, SRCDIR);
$zipdir = getConcatPath($workdir, ZIPDIR);
if (strpos($workdir, ADIR) === 0) {
$part = explode(DIRECTORY_SEPARATOR, $workdir);
$basename .= '--' . end($part);
unset($part);
}
define('MODFILE', $basename);
$zipfile = getConcatPath($zipdir, $basename . ZIPEXT);
$mod_code = str_replace('--', '|', $basename);
define('MODCODE', $mod_code);
$mod_name = str_replace('|', ' ', $mod_code);
$mod_name = ucwords($mod_name);
$mod_name = str_replace(' ', '|', $mod_name);
$mod_name = str_replace('-', ' ', $mod_name);
$mod_name = ucwords($mod_name);
define('MODNAME', $mod_name);
if (chkdir($srcdir) && chkdir($zipdir)) {
if (is_file($zipfile)) {
unlink($zipfile);
}
mkzip($srcdir, $zipfile, true);
} else {
output('Can not create dir: ' . $zipdir, true);
}
} else {
output('There is no directory corresponding to number ' . $clo[MAKEZIP], true);
}
} elseif (isset($clo[MAKEFCL]) || isset($clo[EXTRFCL]) || isset($clo[LISTFCL])) {
$fclfile = getConcatPath(FCLDIR, $basename . '.fcl');
if (isset($clo[MAKEFCL])) {
chkdir(FCLDIR);
output(fcl('make', $fclfile, '-f' . fclignore(FCLIGNORE)));
output(hideg($fclfile));
} elseif (isset($clo[EXTRFCL]) || isset($clo[LISTFCL])) {
if (is_file($fclfile . '.g')) {
output(hideg($fclfile . '.g'));
if (is_file($fclfile)) {
if (isset($clo[EXTRFCL])) {
output(fcl('extr', $fclfile, '-f'));
}
if (isset($clo[LISTFCL])) {
output(fcl('list', $fclfile));
}
} else {
output('file "' . $fclfile . '" is missing!', true);
}
} else {
output('file "' . $fclfile . '.g' . '" is missing!', true);
}
}
if (is_file($fclfile)) {
unlink($fclfile);
}
} else {
include '_pak/help.php';
output('Numbers:');
foreach (numbered() as $idx => $name) {
output('[' . $idx . '] - ' . $name);
}
}
exit(0);