generate_package_xml.php ➔ getFilelist()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 6
nc 3
nop 1
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/**
3
 * package.xml generation script
4
 *
5
 * @package Intraface
6
 * @author  Lars Olesen <[email protected]>
7
 * @version @package-version@
8
 */
9
error_reporting(0);
10
11
if (isset($_SERVER['argv']) && !empty($_SERVER['argv'][2])) {
12
    $version = $_SERVER['argv'][2];
13
} else {
14
    $version = '2.0.7';
15
}
16
17
$stability = 'stable';
18
$notes = '
19
* many changes
20
';
21
$web_dir = 'src/intraface.dk';
22
23
// @todo make sure that there is not created an intraface.dk/intraface.dk on the server
24
// @todo make sure that there is not created an install dir on the server.
25
$ignore = array(
26
    'intraface.dk/config.local.php',
27
    'intraface.dk/config.local.default.php',
28
    'intraface.dk/demo/config.local.php',
29
    'intraface.dk/demo/config.local.example.php',
30
    'intraface.dk/install/',
31
    'intraface.dk/install/reset-staging-server.php',
32
    '.git/',
33
    '.settings/'
34
);
35
36
function getFilelist($dir) {
37
    global $rFiles;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
38
    $files = glob($dir.'/*');
39
    foreach ($files as $f) {
40
        if (is_dir($f)) { getFileList($f); continue; }
0 ignored issues
show
Coding Style introduced by
It is generally recommended to place each PHP statement on a line by itself.

Let’s take a look at an example:

// Bad
$a = 5; $b = 6; $c = 7;

// Good
$a = 5;
$b = 6;
$c = 7;
Loading history...
41
        $rFiles[] = $f;
42
    }
43
}
44
45
getFilelist($web_dir);
46
47
$web_files = $rFiles;
48
49
require_once 'PEAR/PackageFileManager2.php';
50
PEAR::setErrorHandling(PEAR_ERROR_DIE);
51
$pfm = new PEAR_PackageFileManager2();
52
$pfm->setOptions(
53
    array(
54
        'baseinstalldir'    => '/',
55
        'filelistgenerator' => 'file',
56
        'packagedirectory'  => dirname(__FILE__).'/src',
57
        'packagefile'       => 'package.xml',
58
        'ignore'            => $ignore,
59
        'dir_roles'        => array(
60
              'intraface.dk' => 'www'
61
        ),
62
        'exceptions' => array(
63
              'intraface.dk/*.*' => 'www'
64
        ),
65
        'simpleoutput'      => true,
66
        'addhiddenfiles' => true
67
    )
68
);
69
70
$pfm->setPackage('Intraface');
71
$pfm->setSummary('Intraface');
72
$pfm->setDescription('Intraface');
73
$pfm->setUri('http://localhost/');
74
$pfm->setLicense('LGPL License', 'http://www.gnu.org/licenses/lgpl.html');
75
$pfm->addMaintainer('lead', 'lsolesen', 'Lars Olesen', '[email protected]');
76
$pfm->addMaintainer('lead', 'sune.t.jensen', 'Sune Jensen', '[email protected]');
77
78
$pfm->setPackageType('php');
79
80
$pfm->setAPIVersion($version);
81
$pfm->setReleaseVersion($version);
82
$pfm->setAPIStability($stability);
83
$pfm->setReleaseStability($stability);
84
$pfm->setNotes($notes);
85
$pfm->addRelease();
86
87
$pfm->resetUsesRole();
88
$pfm->addPackageDepWithChannel('required', 'HTTP', 'pear.php.net', '1.4.1');
89
90
// $pfm->addGlobalReplacement('package-info', '@package-version@', 'version');
0 ignored issues
show
Unused Code Comprehensibility introduced by
72% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
91
$pfm->addReplacement('intraface.php', 'pear-config', '@php-dir@', 'php_dir');
92
$pfm->addReplacement('intraface.php', 'pear-config', '@web-dir@', 'www_dir');
93
$pfm->addReplacement('intraface.php', 'pear-config', '@data-dir@', 'data_dir');
94
95
$pfm->clearDeps();
96
$pfm->setPhpDep('5.2.0');
97
$pfm->setPearinstallerDep('1.8.1');
98
99
// installer
100
$pfm->addPackageDepWithChannel('required', 'Config', 'pear.php.net', '1.10.12');
101
$pfm->addPackageDepWithChannel('required', 'Swift', 'pear.swiftmailer.org', '4.0.7', '4.0.7');
102
103
// Kernel
104
$pfm->addPackageDepWithChannel('required', 'MDB2', 'pear.php.net', '2.4.1');
105
$pfm->addPackageDepWithChannel('required', 'MDB2_Driver_mysql', 'pear.php.net', '1.4.1');
106
$pfm->addPackageDepWithChannel('required', 'Translation2', 'pear.php.net', '2.0.4');
107
$pfm->addPackageDepWithChannel('required', 'Translation2_Decorator_LogMissingTranslation', 'public.intraface.dk', '0.1.3');
108
$pfm->addPackageDepWithChannel('required', 'Log', 'pear.php.net', '1.12.6');
109
$pfm->addPackageDepWithChannel('required', 'Validate', 'pear.php.net', '0.8.4');
110
$pfm->addPackageDepWithChannel('required', 'Net_IDNA', 'pear.php.net', '0.8.1');
111
$pfm->addPackageDepWithChannel('required', 'HTTP_Upload', 'pear.php.net', '0.9.1');
112
$pfm->addPackageDepWithChannel('required', 'Cache_Lite', 'pear.php.net', '1.7.11');
113
$pfm->addPackageDepWithChannel('required', 'Image_Transform', 'pear.php.net', '0.9.4');
114
$pfm->addPackageDepWithChannel('required', 'Ilib_ErrorHandler_Handler', 'public.intraface.dk', '1.0.2');
115
$pfm->addPackageDepWithChannel('required', 'MDB2_Debug_ExplainQueries', 'public.intraface.dk', '0.1.1');
116
$pfm->addPackageDepWithChannel('required', 'File', 'pear.php.net', '1.4.0');
117
$pfm->addPackageDepWithChannel('required', 'Ilib_RandomKeyGenerator', 'public.intraface.dk', '0.3.1');
118
$pfm->addPackageDepWithChannel('required', 'Ilib_Position', 'public.intraface.dk', '0.4.1');
119
$pfm->addPackageDepWithChannel('required', 'bucket', 'pearhub.org', '1.1.1');
120
121
// Doctrine
122
$pfm->addPackageDepWithChannel('required', 'Doctrine', 'pear.doctrine-project.org', '1.2.4');
123
$pfm->addPackageDepWithChannel('required', 'Doctrine_Validator_Nohtml', 'public.intraface.dk', '0.1.3');
124
$pfm->addPackageDepWithChannel('required', 'Doctrine_Validator_Greaterthan', 'public.intraface.dk', '0.1.3');
125
$pfm->addPackageDepWithChannel('required', 'Doctrine_Template_Positionable', 'public.intraface.dk', '0.2.2');
126
127
// Ilib
128
$pfm->addPackageDepWithChannel('required', 'Ilib_Category', 'public.intraface.dk', '0.1.5');
129
$pfm->addPackageDepWithChannel('required', 'Ilib_DBQuery', 'public.intraface.dk', '0.1.10');
130
$pfm->addPackageDepWithChannel('required', 'Ilib_Error', 'public.intraface.dk', '1.0.1');
131
$pfm->addPackageDepWithChannel('required', 'Ilib_Redirect', 'public.intraface.dk', '0.2.2');
132
$pfm->addPackageDepWithChannel('required', 'Ilib_FileImport', 'public.intraface.dk', '0.1.3');
133
$pfm->addPackageDepWithChannel('required', 'Ilib_Validator', 'public.intraface.dk', '0.0.2');
134
$pfm->addPackageDepWithChannel('required', 'Ilib_ClassLoader', 'public.intraface.dk', '0.1.2');
135
$pfm->addPackageDepWithChannel('required', 'Ilib_Variable', 'public.intraface.dk', '1.0.1');
136
137
// other intraface 3_Party packages
138
$pfm->addPackageDepWithChannel('required', 'DB_Sql', 'public.intraface.dk', '0.0.1');
139
140
// XMLRPC
141
$pfm->addPackageDepWithChannel('required', 'XML_RPC2', 'pear.php.net', '1.0.8');
142
// Bug fix for PEAR XML_RPC2 version 1.0.2
0 ignored issues
show
Unused Code Comprehensibility introduced by
43% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
143
// $pfm->addPackageDepWithChannel('required', 'XML_RPC2', 'public.intraface.dk', '0.0.1');
144
// Yet another bug fix for PEAR XML_RPC2 version 1.0.2
145
// $pfm->addPackageDepWithChannel('required', 'XML_RPC2_Backend_Php_ServerFixedEncodingObject', 'public.intraface.dk', '0.0.1');
146
147
// filehandler
148
$pfm->addPackageDepWithChannel('required', 'MIME_Type', 'pear.php.net', '1.2.1');
149
$pfm->addPackageDepWithChannel('required', 'System_Command', 'pear.php.net', '1.0.7');
150
$pfm->addPackageDepWithChannel('required', 'Ilib_Filehandler', 'public.intraface.dk', '0.4.0');
151
$pfm->addPackageDepWithChannel('required', 'Ilib_Keyword', 'public.intraface.dk', '0.4.0');
152
$pfm->addPackageDepWithChannel('required', 'Ilib_Filehandler_Controller', 'public.intraface.dk', '0.3.0');
153
$pfm->addPackageDepWithChannel('required', 'Ilib_Keyword_Controller', 'public.intraface.dk', '0.3.0');
154
$pfm->addPackageDepWithChannel('required', 'Ilib_Date', 'public.intraface.dk', '0.2.1');
155
156
// cms
157
$pfm->addPackageDepWithChannel('required', 'XML_Util', 'pear.php.net', '1.2.0');
158
$pfm->addPackageDepWithChannel('required', 'XML_Serializer', 'pear.php.net', '0.20.2');
159
$pfm->addPackageDepWithChannel('required', 'HTMLPurifier', 'htmlpurifier.org', '4.0.3');
160
$pfm->addPackageDepWithChannel('required', 'Text_Wiki', 'pear.php.net', '1.2.1');
161
$pfm->addPackageDepWithChannel('required', 'Markdown', 'pear.michelf.com', '1.0.1m');
162
163
$pfm->addPackageDepWithChannel('required', 'SmartyPants', 'pear.michelf.com', '1.5.1oo2');
164
$pfm->addPackageDepWithChannel('required', 'phpFlickr', 'public.intraface.dk', '1.6.1');
165
$pfm->addPackageDepWithChannel('required', 'IntrafacePublic_CMS_HTML', 'public.intraface.dk', '0.2.0');
166
167
// debtor
168
$pfm->addPackageDepWithChannel('required', 'Document_Cpdf', 'public.intraface.dk', '0.0.2');
169
$pfm->addPackageDepWithChannel('required', 'Console_Table', 'pear.php.net', '1.1.4');
170
171
// contact
172
$pfm->addPackageDepWithChannel('required', 'Services_Eniro', 'public.intraface.dk', '1.0.0');
173
$pfm->addPackageDepWithChannel('required', 'Contact_Vcard_Build', 'pear.php.net', '1.1.2');
174
$pfm->addPackageDepWithChannel('required', 'Date', 'pear.php.net', '1.4.7');
175
176
// onlinepayment
177
$pfm->addPackageDepWithChannel('required', 'Payment_Quickpay', 'public.intraface.dk', '1.18.3');
178
// $pfm->addPackageDepWithChannel('required', 'Validate_Finance_CreditCard', 'pear.php.net', '0.5.2');
0 ignored issues
show
Unused Code Comprehensibility introduced by
71% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
179
180
// accounting
181
$pfm->addPackageDepWithChannel('required', 'OLE', 'pear.php.net', '1.0.0RC1');
182
$pfm->addPackageDepWithChannel('required', 'Spreadsheet_Excel_Writer', 'pear.php.net', '0.9.2');
183
184
// modulepackage
185
$pfm->addPackageDepWithChannel('required', 'IntrafacePublic_Debtor_XMLRPC', 'public.intraface.dk', '0.1.0');
186
$pfm->addPackageDepWithChannel('required', 'Ilib_Payment_Authorize_Provider_Testing', 'public.intraface.dk', '1.0.0');
187
188
// shop
189
$pfm->addPackageDepWithChannel('required', 'Ilib_Countries', 'public.intraface.dk', '1.0.0');
190
191
// demo
192
$pfm->addPackageDepWithChannel('required', 'IntrafacePublic_CMS', 'public.intraface.dk', '0.1.7');
193
$pfm->addPackageDepWithChannel('required', 'IntrafacePublic_CMS_Client_XMLRPC', 'public.intraface.dk', '0.2.0');
194
$pfm->addPackageDepWithChannel('required', 'IntrafacePublic_CMS_Controller', 'public.intraface.dk', '2.1.1');
195
196
$pfm->addPackageDepWithChannel('required', 'IntrafacePublic_Admin_Client_XMLRPC', 'public.intraface.dk', '0.1.0');
197
$pfm->addPackageDepWithChannel('required', 'IntrafacePublic_OnlinePayment_Client_XMLRPC', 'public.intraface.dk', '1.0.0');
198
$pfm->addPackageDepWithChannel('required', 'IntrafacePublic_OnlinePayment_Controller', 'public.intraface.dk', '1.0.1');
199
$pfm->addPackageDepWithChannel('required', 'IntrafacePublic_Shop', 'public.intraface.dk', '1.0.0');
200
$pfm->addPackageDepWithChannel('required', 'IntrafacePublic_Shop_Client_XMLRPC', 'public.intraface.dk', '1.0.4');
201
$pfm->addPackageDepWithChannel('required', 'IntrafacePublic_Shop_Controller', 'public.intraface.dk', '1.2.2');
202
$pfm->addPackageDepWithChannel('required', 'IntrafacePublic_Newsletter_Client_XMLRPC', 'public.intraface.dk', '1.1.1');
203
$pfm->addPackageDepWithChannel('required', 'IntrafacePublic_Newsletter_Controller', 'public.intraface.dk', '1.0.1');
204
$pfm->addPackageDepWithChannel('required', 'konstrukt', 'pearhub.org', '2.3.1');
205
$pfm->addPackageDepWithChannel('required', 'ilib_recursive_array_map', 'public.intraface.dk', '0.1.0');
206
207
// tools
0 ignored issues
show
Unused Code Comprehensibility introduced by
65% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
208
// $pfm->addPackageDepWithChannel('required', 'Ilib_SimpleLogin', 'public.intraface.dk', '1.0.0');
209
// $pfm->addPackageDepWithChannel('required', 'Ilib_ErrorHandler_Observer_File_ErrorList', 'public.intraface.dk', '1.0.3');
210
// $pfm->addPackageDepWithChannel('required', 'Translation2_Frontend', 'public.intraface.dk', '2.0.0');
211
212
$pfm->addPackageDepWithChannel('required', 'Zend', 'zend.googlecode.com/svn', '1.11.7');
213
214
foreach ($ignore AS $file) {
0 ignored issues
show
Unused Code introduced by
This foreach statement is empty and can be removed.

This check looks for foreach loops that have no statements or where all statements have been commented out. This may be the result of changes for debugging or the code may simply be obsolete.

Consider removing the loop.

Loading history...
Coding Style introduced by
AS keyword must be lowercase; expected "as" but found "AS"
Loading history...
Coding Style introduced by
As per coding-style, PHP keywords should be in lowercase; expected as, but found AS.
Loading history...
215
    // $pfm->addIgnoreToRelease($file);
0 ignored issues
show
Unused Code Comprehensibility introduced by
75% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
216
}
217
218
/**
219
 * @todo: path_include_path: what to set it to?
220
 */
221
$post_install_script = $pfm->initPostinstallScript('intraface.php');
222
$post_install_script->addParamGroup('setup',
223
    array($post_install_script->getParam('db_user', 'User', 'string', 'root'),
224
          $post_install_script->getParam('db_pass', 'Password', 'string', ''),
225
          $post_install_script->getParam('db_host', 'Host', 'string', 'localhost'),
226
          $post_install_script->getParam('db_name', 'Database', 'string', 'intraface'),
227
          $post_install_script->getParam('net_scheme', 'Net scheme', 'string', 'http://'),
228
          $post_install_script->getParam('net_host', 'Net host', 'string', 'localhost'),
229
          $post_install_script->getParam('net_directory', 'Net directory', 'string', '/'),
230
          $post_install_script->getParam('path_root', 'Root path', 'string', '/home/intraface/'),
231
          $post_install_script->getParam('path_include_path', 'Include path', 'string', ''),
232
          $post_install_script->getParam('path_upload', 'Upload path', 'string', '/home/intraface/upload/'),
233
          $post_install_script->getParam('path_cache', 'Cache path', 'string', '/home/intraface/cache'),
234
          $post_install_script->getParam('connection_internet', 'Connection to intranet', 'boolean', true),
235
          $post_install_script->getParam('server_status', 'Server status', 'string', 'PRODUCTION'),
236
          $post_install_script->getParam('error_handle_level', 'Error handle error ', 'integer', E_ALL),
237
          $post_install_script->getParam('error_level_continue_script', 'Error level continue script', 'integer' ^ E_NOTICE),
238
          $post_install_script->getParam('error_report_email', 'Error report email', 'string', '[email protected]'),
239
          $post_install_script->getParam('error_log', 'Error log', 'string', 'log/error.log'),
240
          $post_install_script->getParam('timezone', 'Timezone', 'string', 'Europe/Copenhagen'),
241
          $post_install_script->getParam('country_local', 'Country local', 'string', 'da_DK'),
242
          $post_install_script->getParam('intraface_intranetmaintenance_intranet_private_key', 'Private key', 'string', ''),
243
          $post_install_script->getParam('intraface_onlinepayment_provider', 'Online payment provider', 'string', 'Quickpay'),
244
          $post_install_script->getParam('intraface_onlinepayment_merchant', 'Online payment merchant number', 'string', ''),
245
          $post_install_script->getParam('intraface_onlinepayment_md5secret', 'Online payment md5secret', 'string', '')
246
              ),
247
    '');
248
249
$pfm->addPostInstallTask($post_install_script, 'intraface.php');
250
251
foreach ($web_files AS $file) {
0 ignored issues
show
Coding Style introduced by
AS keyword must be lowercase; expected "as" but found "AS"
Loading history...
Coding Style introduced by
As per coding-style, PHP keywords should be in lowercase; expected as, but found AS.
Loading history...
252
    $src_file = substr($file, 4);
253
    $formatted_file = substr($file, strlen($web_dir . '/'));
254
    if (in_array($src_file, $ignore)) continue;
0 ignored issues
show
Coding Style Best Practice introduced by
It is generally a best practice to always use braces with control structures.

Adding braces to control structures avoids accidental mistakes as your code changes:

// Without braces (not recommended)
if (true)
    doSomething();

// Recommended
if (true) {
    doSomething();
}
Loading history...
255
    $pfm->addInstallAs($src_file, $formatted_file);
256
}
257
258
$pfm->generateContents();
259
260
if (isset($_GET['make']) || (isset($_SERVER['argv']) && @$_SERVER['argv'][1] == 'make')) {
261
    $res = $pfm->writePackageFile();
262
    if (PEAR::isError($res)) {
263
        echo $res->toString()."\n";
264
    }
265
266
    if ($res) {
267
        exit("Package file written\n");
268
    }
269
} else {
270
    $res = $pfm->debugPackageFile();
271
272
    if (PEAR::isError($res)) {
273
        echo $res->toString()."\n";
274
    }
275
}
276
277