1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
5
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
6
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
7
|
|
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
8
|
|
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
9
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
10
|
|
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
11
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
12
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
13
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
14
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
15
|
|
|
* |
16
|
|
|
* This software consists of voluntary contributions made by many individuals |
17
|
|
|
* and is licensed under the LGPL. For more information please see |
18
|
|
|
* <http://phing.info>. |
19
|
|
|
*/ |
20
|
|
|
|
21
|
|
|
namespace Phing\Task\Ext\Ioncube; |
22
|
|
|
|
23
|
|
|
use Phing\Exception\BuildException; |
24
|
|
|
use Phing\Io\FileSystem; |
25
|
|
|
use Phing\Io\IOException; |
26
|
|
|
use Phing\Task; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* Invokes the ionCube Encoder (PHP4 or PHP5) |
30
|
|
|
* |
31
|
|
|
* @author Michiel Rook <[email protected]> |
32
|
|
|
* @author Andrew Eddie <[email protected]> |
33
|
|
|
* @author Domenico Sgarbossa <[email protected]> |
34
|
|
|
* @package phing.tasks.ext.ioncube |
35
|
|
|
* @since 2.2.0 |
36
|
|
|
*/ |
37
|
|
|
class IoncubeEncoderTask extends Task |
38
|
|
|
{ |
39
|
|
|
private $ionSwitches = []; |
40
|
|
|
|
41
|
|
|
private $ionOptions = []; |
42
|
|
|
|
43
|
|
|
private $ionOptionsXS = []; |
44
|
|
|
|
45
|
|
|
private $comments = []; |
46
|
|
|
|
47
|
|
|
private $encoderName = 'ioncube_encoder'; |
48
|
|
|
|
49
|
|
|
private $fromDir = ''; |
50
|
|
|
|
51
|
|
|
private $ioncubePath = '/usr/local/ioncube'; |
52
|
|
|
|
53
|
|
|
private $phpVersion = '5'; |
54
|
|
|
|
55
|
|
|
private $targetOption = ''; |
56
|
|
|
|
57
|
|
|
private $toDir = ''; |
58
|
|
|
|
59
|
|
|
private $showCommandLine = false; |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* Sets whether to show command line before it is executed |
63
|
|
|
* |
64
|
|
|
* @param $value |
65
|
|
|
*/ |
66
|
|
|
public function setShowCommandLine($value) |
67
|
|
|
{ |
68
|
|
|
$this->showCommandLine = $value; |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* Adds a comment to be used in encoded files |
73
|
|
|
* |
74
|
|
|
* @param IoncubeComment $comment |
75
|
|
|
*/ |
76
|
|
|
public function addComment(IoncubeComment $comment) |
77
|
|
|
{ |
78
|
|
|
$this->comments[] = $comment; |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* Sets the allowed server |
83
|
|
|
* |
84
|
|
|
* @param $value |
85
|
|
|
*/ |
86
|
|
|
public function setAllowedServer($value) |
87
|
|
|
{ |
88
|
|
|
$this->ionOptionsXS['allowed-server'] = $value; |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* Returns the allowed server setting |
93
|
|
|
*/ |
94
|
|
|
public function getAllowedServer() |
95
|
|
|
{ |
96
|
|
|
return $this->ionOptionsXS['allowed-server']; |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* Sets the binary option |
101
|
|
|
* |
102
|
|
|
* @param $value |
103
|
|
|
*/ |
104
|
|
|
public function setBinary($value) |
105
|
|
|
{ |
106
|
|
|
$this->ionSwitches['binary'] = $value; |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
/** |
110
|
|
|
* Returns the binary option |
111
|
|
|
*/ |
112
|
|
|
public function getBinary() |
113
|
|
|
{ |
114
|
|
|
return $this->ionSwitches['binary']; |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
/** |
118
|
|
|
* Sets files or folders to copy (separated by space) |
119
|
|
|
* |
120
|
|
|
* @param $value |
121
|
|
|
*/ |
122
|
|
|
public function setCopy($value) |
123
|
|
|
{ |
124
|
|
|
$this->ionOptionsXS['copy'] = $value; |
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
/** |
128
|
|
|
* Returns the copy setting |
129
|
|
|
*/ |
130
|
|
|
public function getCopy() |
131
|
|
|
{ |
132
|
|
|
return $this->ionOptionsXS['copy']; |
133
|
|
|
} |
134
|
|
|
|
135
|
|
|
/** |
136
|
|
|
* Sets additional file patterns, files or directories to encode, |
137
|
|
|
* or to reverse the effect of copy (separated by space) |
138
|
|
|
* |
139
|
|
|
* @param $value |
140
|
|
|
*/ |
141
|
|
|
public function setEncode($value) |
142
|
|
|
{ |
143
|
|
|
$this->ionOptionsXS['encode'] = $value; |
144
|
|
|
} |
145
|
|
|
|
146
|
|
|
/** |
147
|
|
|
* Returns the encode setting |
148
|
|
|
*/ |
149
|
|
|
public function getEncode() |
150
|
|
|
{ |
151
|
|
|
return $this->ionOptionsXS['encode']; |
152
|
|
|
} |
153
|
|
|
|
154
|
|
|
/** |
155
|
|
|
* Sets regexps of additional files to encrypt (separated by space) |
156
|
|
|
* |
157
|
|
|
* @param $value |
158
|
|
|
*/ |
159
|
|
|
public function setEncrypt($value) |
160
|
|
|
{ |
161
|
|
|
$this->ionOptionsXS['encrypt'] = $value; |
162
|
|
|
} |
163
|
|
|
|
164
|
|
|
/** |
165
|
|
|
* Returns regexps of additional files to encrypt (separated by space) |
166
|
|
|
*/ |
167
|
|
|
public function getEncrypt() |
168
|
|
|
{ |
169
|
|
|
return $this->ionOptionsXS['encrypt']; |
170
|
|
|
} |
171
|
|
|
|
172
|
|
|
/** |
173
|
|
|
* Sets a period after which the files expire |
174
|
|
|
* |
175
|
|
|
* @param $value |
176
|
|
|
*/ |
177
|
|
|
public function setExpirein($value) |
178
|
|
|
{ |
179
|
|
|
$this->ionOptions['expire-in'] = $value; |
180
|
|
|
} |
181
|
|
|
|
182
|
|
|
/** |
183
|
|
|
* Returns the expireIn setting |
184
|
|
|
*/ |
185
|
|
|
public function getExpirein() |
186
|
|
|
{ |
187
|
|
|
return $this->ionOptions['expire-in']; |
188
|
|
|
} |
189
|
|
|
|
190
|
|
|
/** |
191
|
|
|
* Sets a YYYY-MM-DD date to expire the files |
192
|
|
|
* |
193
|
|
|
* @param $value |
194
|
|
|
*/ |
195
|
|
|
public function setExpireon($value) |
196
|
|
|
{ |
197
|
|
|
$this->ionOptions['expire-on'] = $value; |
198
|
|
|
} |
199
|
|
|
|
200
|
|
|
/** |
201
|
|
|
* Returns the expireOn setting |
202
|
|
|
*/ |
203
|
|
|
public function getExpireon() |
204
|
|
|
{ |
205
|
|
|
return $this->ionOptions['expire-on']; |
206
|
|
|
} |
207
|
|
|
|
208
|
|
|
/** |
209
|
|
|
* Sets the source directory |
210
|
|
|
* |
211
|
|
|
* @param $value |
212
|
|
|
*/ |
213
|
|
|
public function setFromDir($value) |
214
|
|
|
{ |
215
|
|
|
$this->fromDir = $value; |
216
|
|
|
} |
217
|
|
|
|
218
|
|
|
/** |
219
|
|
|
* Returns the source directory |
220
|
|
|
*/ |
221
|
|
|
public function getFromDir() |
222
|
|
|
{ |
223
|
|
|
return $this->fromDir; |
224
|
|
|
} |
225
|
|
|
|
226
|
|
|
/** |
227
|
|
|
* Set files and directories to ignore entirely and exclude from the target directory |
228
|
|
|
* (separated by space). |
229
|
|
|
* |
230
|
|
|
* @param $value |
231
|
|
|
*/ |
232
|
|
|
public function setIgnore($value) |
233
|
|
|
{ |
234
|
|
|
$this->ionOptionsXS['ignore'] = $value; |
235
|
|
|
} |
236
|
|
|
|
237
|
|
|
/** |
238
|
|
|
* Returns the ignore setting |
239
|
|
|
*/ |
240
|
|
|
public function getIgnore() |
241
|
|
|
{ |
242
|
|
|
return $this->ionOptionsXS['ignore']; |
243
|
|
|
} |
244
|
|
|
|
245
|
|
|
/** |
246
|
|
|
* Sets the path to the ionCube encoder |
247
|
|
|
* |
248
|
|
|
* @param $value |
249
|
|
|
*/ |
250
|
|
|
public function setIoncubePath($value) |
251
|
|
|
{ |
252
|
|
|
$this->ioncubePath = $value; |
253
|
|
|
} |
254
|
|
|
|
255
|
|
|
/** |
256
|
|
|
* Returns the path to the ionCube encoder |
257
|
|
|
*/ |
258
|
|
|
public function getIoncubePath() |
259
|
|
|
{ |
260
|
|
|
return $this->ioncubePath; |
261
|
|
|
} |
262
|
|
|
|
263
|
|
|
/** |
264
|
|
|
* Set files and directories not to be ignored (separated by space). |
265
|
|
|
* |
266
|
|
|
* @param $value |
267
|
|
|
*/ |
268
|
|
|
public function setKeep($value) |
269
|
|
|
{ |
270
|
|
|
$this->ionOptionsXS['keep'] = $value; |
271
|
|
|
} |
272
|
|
|
|
273
|
|
|
/** |
274
|
|
|
* Returns the ignore setting |
275
|
|
|
*/ |
276
|
|
|
public function getKeep() |
277
|
|
|
{ |
278
|
|
|
return $this->ionOptionsXS['keep']; |
279
|
|
|
} |
280
|
|
|
|
281
|
|
|
/** |
282
|
|
|
* Sets the path to the license file to use |
283
|
|
|
* |
284
|
|
|
* @param $value |
285
|
|
|
*/ |
286
|
|
|
public function setLicensePath($value) |
287
|
|
|
{ |
288
|
|
|
$this->ionOptions['with-license'] = $value; |
289
|
|
|
} |
290
|
|
|
|
291
|
|
|
/** |
292
|
|
|
* Returns the path to the license file to use |
293
|
|
|
*/ |
294
|
|
|
public function getLicensePath() |
295
|
|
|
{ |
296
|
|
|
return $this->ionOptions['with-license']; |
297
|
|
|
} |
298
|
|
|
|
299
|
|
|
/** |
300
|
|
|
* Sets the no-doc-comments option |
301
|
|
|
* |
302
|
|
|
* @param $value |
303
|
|
|
*/ |
304
|
|
|
public function setNoDocComments($value) |
305
|
|
|
{ |
306
|
|
|
$this->ionSwitches['no-doc-comment'] = $value; |
307
|
|
|
} |
308
|
|
|
|
309
|
|
|
/** |
310
|
|
|
* Returns the no-doc-comments option |
311
|
|
|
*/ |
312
|
|
|
public function getNoDocComments() |
313
|
|
|
{ |
314
|
|
|
return $this->ionSwitches['no-doc-comment']; |
315
|
|
|
} |
316
|
|
|
|
317
|
|
|
/** |
318
|
|
|
* Sets the obfuscate option |
319
|
|
|
* |
320
|
|
|
* @param $value |
321
|
|
|
*/ |
322
|
|
|
public function setObfuscate($value) |
323
|
|
|
{ |
324
|
|
|
$this->ionOptionsXS['obfuscate'] = $value; |
325
|
|
|
} |
326
|
|
|
|
327
|
|
|
/** |
328
|
|
|
* Returns the optimize option |
329
|
|
|
*/ |
330
|
|
|
public function getObfuscate() |
331
|
|
|
{ |
332
|
|
|
return $this->ionOptionsXS['obfuscate']; |
333
|
|
|
} |
334
|
|
|
|
335
|
|
|
/** |
336
|
|
|
* Sets the obfuscation key (required if using the obfuscate option) |
337
|
|
|
* |
338
|
|
|
* @param $value |
339
|
|
|
*/ |
340
|
|
|
public function setObfuscationKey($value) |
341
|
|
|
{ |
342
|
|
|
$this->ionOptions['obfuscation-key'] = $value; |
343
|
|
|
} |
344
|
|
|
|
345
|
|
|
/** |
346
|
|
|
* Returns the optimize option |
347
|
|
|
*/ |
348
|
|
|
public function getObfuscationKey() |
349
|
|
|
{ |
350
|
|
|
return $this->ionOptions['obfuscation-key']; |
351
|
|
|
} |
352
|
|
|
|
353
|
|
|
/** |
354
|
|
|
* Sets the optimize option |
355
|
|
|
* |
356
|
|
|
* @param $value |
357
|
|
|
*/ |
358
|
|
|
public function setOptimize($value) |
359
|
|
|
{ |
360
|
|
|
$this->ionOptions['optimize'] = $value; |
361
|
|
|
} |
362
|
|
|
|
363
|
|
|
/** |
364
|
|
|
* Returns the optimize option |
365
|
|
|
*/ |
366
|
|
|
public function getOptimize() |
367
|
|
|
{ |
368
|
|
|
return $this->ionOptions['optimize']; |
369
|
|
|
} |
370
|
|
|
|
371
|
|
|
/** |
372
|
|
|
* Sets the passphrase to use when encoding files |
373
|
|
|
* |
374
|
|
|
* @param $value |
375
|
|
|
*/ |
376
|
|
|
public function setPassPhrase($value) |
377
|
|
|
{ |
378
|
|
|
$this->ionOptions['passphrase'] = $value; |
379
|
|
|
} |
380
|
|
|
|
381
|
|
|
/** |
382
|
|
|
* Returns the passphrase to use when encoding files |
383
|
|
|
*/ |
384
|
|
|
public function getPassPhrase() |
385
|
|
|
{ |
386
|
|
|
return $this->ionOptions['passphrase']; |
387
|
|
|
} |
388
|
|
|
|
389
|
|
|
/** |
390
|
|
|
* Sets the version of PHP to use (defaults to 5) |
391
|
|
|
* |
392
|
|
|
* @param $value |
393
|
|
|
*/ |
394
|
|
|
public function setPhpVersion($value) |
395
|
|
|
{ |
396
|
|
|
$this->phpVersion = $value; |
397
|
|
|
} |
398
|
|
|
|
399
|
|
|
/** |
400
|
|
|
* Returns the version of PHP to use (defaults to 5) |
401
|
|
|
*/ |
402
|
|
|
public function getPhpVersion() |
403
|
|
|
{ |
404
|
|
|
return $this->phpVersion; |
405
|
|
|
} |
406
|
|
|
|
407
|
|
|
/** |
408
|
|
|
* Sets the target directory |
409
|
|
|
* |
410
|
|
|
* @param $value |
411
|
|
|
*/ |
412
|
|
|
public function setToDir($value) |
413
|
|
|
{ |
414
|
|
|
$this->toDir = $value; |
415
|
|
|
} |
416
|
|
|
|
417
|
|
|
/** |
418
|
|
|
* Returns the target directory |
419
|
|
|
*/ |
420
|
|
|
public function getToDir() |
421
|
|
|
{ |
422
|
|
|
return $this->toDir; |
423
|
|
|
} |
424
|
|
|
|
425
|
|
|
/** |
426
|
|
|
* Sets the without-runtime-loader-support option |
427
|
|
|
* |
428
|
|
|
* @param $value |
429
|
|
|
*/ |
430
|
|
|
public function setWithoutRuntimeLoaderSupport($value) |
431
|
|
|
{ |
432
|
|
|
$this->ionSwitches['without-runtime-loader-support'] = $value; |
433
|
|
|
} |
434
|
|
|
|
435
|
|
|
/** |
436
|
|
|
* Returns the without-runtime-loader-support option |
437
|
|
|
*/ |
438
|
|
|
public function getWithoutRuntimeLoaderSupport() |
439
|
|
|
{ |
440
|
|
|
return $this->ionSwitches['without-runtime-loader-support']; |
441
|
|
|
} |
442
|
|
|
|
443
|
|
|
/** |
444
|
|
|
* Sets the no-short-open-tags option |
445
|
|
|
* |
446
|
|
|
* @param $value |
447
|
|
|
*/ |
448
|
|
|
public function setNoShortOpenTags($value) |
449
|
|
|
{ |
450
|
|
|
$this->ionSwitches['no-short-open-tags'] = $value; |
451
|
|
|
} |
452
|
|
|
|
453
|
|
|
/** |
454
|
|
|
* Returns the no-short-open-tags option |
455
|
|
|
*/ |
456
|
|
|
public function getNoShortOpenTags() |
457
|
|
|
{ |
458
|
|
|
return $this->ionSwitches['no-short-open-tags']; |
459
|
|
|
} |
460
|
|
|
|
461
|
|
|
/** |
462
|
|
|
* Sets the ignore-deprecated-warnings option |
463
|
|
|
* |
464
|
|
|
* @param $value |
465
|
|
|
*/ |
466
|
|
|
public function setIgnoreDeprecatedWarnings($value) |
467
|
|
|
{ |
468
|
|
|
$this->ionSwitches['ignore-deprecated-warnings'] = $value; |
469
|
|
|
} |
470
|
|
|
|
471
|
|
|
/** |
472
|
|
|
* Returns the ignore-deprecated-warnings option |
473
|
|
|
*/ |
474
|
|
|
public function getIgnoreDeprecatedWarnings() |
475
|
|
|
{ |
476
|
|
|
return $this->ionSwitches['ignore-deprecated-warnings']; |
477
|
|
|
} |
478
|
|
|
|
479
|
|
|
/** |
480
|
|
|
* Sets the ignore-strict-warnings option |
481
|
|
|
* |
482
|
|
|
* @param $value |
483
|
|
|
*/ |
484
|
|
|
public function setIgnoreStrictWarnings($value) |
485
|
|
|
{ |
486
|
|
|
$this->ionSwitches['ignore-strict-warnings'] = $value; |
487
|
|
|
} |
488
|
|
|
|
489
|
|
|
/** |
490
|
|
|
* Returns the ignore-strict-warnings option |
491
|
|
|
*/ |
492
|
|
|
public function getIgnoreStrictWarnings() |
493
|
|
|
{ |
494
|
|
|
return $this->ionSwitches['ignore-strict-warnings']; |
495
|
|
|
} |
496
|
|
|
|
497
|
|
|
/** |
498
|
|
|
* Sets the allow-encoding-into-source option |
499
|
|
|
* |
500
|
|
|
* @param $value |
501
|
|
|
*/ |
502
|
|
|
public function setAllowEncodingIntoSource($value) |
503
|
|
|
{ |
504
|
|
|
$this->ionSwitches['allow-encoding-into-source'] = $value; |
505
|
|
|
} |
506
|
|
|
|
507
|
|
|
/** |
508
|
|
|
* Returns the allow-encoding-into-source option |
509
|
|
|
*/ |
510
|
|
|
public function getAllowEncodingIntoSource() |
511
|
|
|
{ |
512
|
|
|
return $this->ionSwitches['allow-encoding-into-source']; |
513
|
|
|
} |
514
|
|
|
|
515
|
|
|
/** |
516
|
|
|
* Sets the message-if-no-loader option |
517
|
|
|
* |
518
|
|
|
* @param $value |
519
|
|
|
*/ |
520
|
|
|
public function setMessageIfNoLoader($value) |
521
|
|
|
{ |
522
|
|
|
$this->ionOptions['message-if-no-loader'] = $value; |
523
|
|
|
} |
524
|
|
|
|
525
|
|
|
/** |
526
|
|
|
* Returns the message-if-no-loader option |
527
|
|
|
*/ |
528
|
|
|
public function getMessageIfNoLoader() |
529
|
|
|
{ |
530
|
|
|
return $this->ionOptions['message-if-no-loader']; |
531
|
|
|
} |
532
|
|
|
|
533
|
|
|
/** |
534
|
|
|
* Sets the action-if-no-loader option |
535
|
|
|
* |
536
|
|
|
* @param $value |
537
|
|
|
*/ |
538
|
|
|
public function setActionIfNoLoader($value) |
539
|
|
|
{ |
540
|
|
|
$this->ionOptions['action-if-no-loader'] = $value; |
541
|
|
|
} |
542
|
|
|
|
543
|
|
|
/** |
544
|
|
|
* Returns the action-if-no-loader option |
545
|
|
|
*/ |
546
|
|
|
public function getActionIfNoLoader() |
547
|
|
|
{ |
548
|
|
|
return $this->ionOptions['action-if-no-loader']; |
549
|
|
|
} |
550
|
|
|
|
551
|
|
|
/** |
552
|
|
|
* Sets the option to use when encoding target directory already exists (defaults to none) |
553
|
|
|
* |
554
|
|
|
* @param $targetOption |
555
|
|
|
*/ |
556
|
|
|
public function setTargetOption($targetOption) |
557
|
|
|
{ |
558
|
|
|
$this->targetOption = $targetOption; |
559
|
|
|
} |
560
|
|
|
|
561
|
|
|
/** |
562
|
|
|
* Returns the option to use when encoding target directory already exists (defaults to none) |
563
|
|
|
*/ |
564
|
|
|
public function getTargetOption() |
565
|
|
|
{ |
566
|
|
|
return $this->targetOption; |
567
|
|
|
} |
568
|
|
|
|
569
|
|
|
/** |
570
|
|
|
* Sets the callback-file option |
571
|
|
|
* |
572
|
|
|
* @param $value |
573
|
|
|
*/ |
574
|
|
|
public function setCallbackFile($value) |
575
|
|
|
{ |
576
|
|
|
$this->ionOptions['callback-file'] = $value; |
577
|
|
|
} |
578
|
|
|
|
579
|
|
|
/** |
580
|
|
|
* Returns the callback-file option |
581
|
|
|
*/ |
582
|
|
|
public function getCallbackFile() |
583
|
|
|
{ |
584
|
|
|
return $this->ionOptions['callback-file']; |
585
|
|
|
} |
586
|
|
|
|
587
|
|
|
/** |
588
|
|
|
* Sets the obfuscation-exclusions-file option |
589
|
|
|
* |
590
|
|
|
* @param $value |
591
|
|
|
*/ |
592
|
|
|
public function setObfuscationExclusionFile($value) |
593
|
|
|
{ |
594
|
|
|
$this->ionOptions['obfuscation-exclusion-file'] = $value; |
595
|
|
|
} |
596
|
|
|
|
597
|
|
|
/** |
598
|
|
|
* Returns the obfuscation-exclusions-file option |
599
|
|
|
*/ |
600
|
|
|
public function getObfuscationExclusionFile() |
601
|
|
|
{ |
602
|
|
|
return $this->ionOptions['obfuscation-exclusion-file']; |
603
|
|
|
} |
604
|
|
|
|
605
|
|
|
/** |
606
|
|
|
* The main entry point |
607
|
|
|
* |
608
|
|
|
* @throws BuildException |
609
|
|
|
* @throws IOException |
610
|
|
|
*/ |
611
|
|
|
public function main() |
612
|
|
|
{ |
613
|
|
|
$arguments = $this->constructArguments(); |
614
|
|
|
$encoder = FileSystem::getFileSystem()->resolve($this->ioncubePath, $this->encoderName . $this->phpVersion); |
615
|
|
|
|
616
|
|
|
$this->log("Running ionCube Encoder..."); |
617
|
|
|
|
618
|
|
|
if ($this->showCommandLine) { |
619
|
|
|
$this->log("Command line: " . $encoder . ' ' . $arguments); |
620
|
|
|
} |
621
|
|
|
|
622
|
|
|
exec($encoder . ' ' . $arguments . " 2>&1", $output, $return); |
623
|
|
|
|
624
|
|
|
if ($return != 0) { |
625
|
|
|
throw new BuildException("Could not execute ionCube Encoder: " . implode(' ', $output)); |
626
|
|
|
} |
627
|
|
|
} |
628
|
|
|
|
629
|
|
|
/** |
630
|
|
|
* Constructs an argument string for the ionCube encoder |
631
|
|
|
* |
632
|
|
|
* @throws BuildException |
633
|
|
|
*/ |
634
|
|
|
private function constructArguments(): string |
635
|
|
|
{ |
636
|
|
|
$arguments = ''; |
637
|
|
|
|
638
|
|
|
foreach ($this->ionSwitches as $name => $value) { |
639
|
|
|
if ($value) { |
640
|
|
|
$arguments .= "--$name "; |
641
|
|
|
} |
642
|
|
|
} |
643
|
|
|
|
644
|
|
|
foreach ($this->ionOptions as $name => $value) { |
645
|
|
|
/** |
646
|
|
|
* action-if-no-loader value is a php source snippet so it is |
647
|
|
|
* better to handle it this way to prevent quote problems! |
648
|
|
|
*/ |
649
|
|
|
if ($name == 'action-if-no-loader') { |
650
|
|
|
$arguments .= "--$name \"$value\" "; |
651
|
|
|
} else { |
652
|
|
|
$arguments .= "--$name '$value' "; |
653
|
|
|
} |
654
|
|
|
} |
655
|
|
|
|
656
|
|
|
foreach ($this->ionOptionsXS as $name => $value) { |
657
|
|
|
foreach (explode(' ', $value) as $arg) { |
658
|
|
|
$arguments .= "--$name '$arg' "; |
659
|
|
|
} |
660
|
|
|
} |
661
|
|
|
|
662
|
|
|
foreach ($this->comments as $comment) { |
663
|
|
|
$arguments .= "--add-comment '" . $comment->getValue() . "' "; |
664
|
|
|
} |
665
|
|
|
|
666
|
|
|
if (!empty($this->targetOption)) { |
667
|
|
|
switch ($this->targetOption) { |
668
|
|
|
case "replace": |
669
|
|
|
case "merge": |
670
|
|
|
case "update": |
671
|
|
|
case "rename": |
672
|
|
|
$arguments .= "--" . $this->targetOption . "-target "; |
673
|
|
|
break; |
674
|
|
|
default: |
675
|
|
|
throw new BuildException("Unknown target option '" . $this->targetOption . "'"); |
676
|
|
|
} |
677
|
|
|
} |
678
|
|
|
|
679
|
|
|
if ($this->fromDir != '') { |
680
|
|
|
$arguments .= $this->fromDir . ' '; |
681
|
|
|
} |
682
|
|
|
|
683
|
|
|
if ($this->toDir != '') { |
684
|
|
|
$arguments .= "-o " . $this->toDir . ' '; |
685
|
|
|
} |
686
|
|
|
|
687
|
|
|
return $arguments; |
688
|
|
|
} |
689
|
|
|
} |
690
|
|
|
|