PageRenderTime 782ms CodeModel.GetById 595ms app.highlight 7ms RepoModel.GetById 175ms app.codeStats 0ms

/scripts/compact.php

https://gitlab.com/nabble/semalt-blocker
PHP | 31 lines | 20 code | 7 blank | 4 comment | 0 complexity | 3d8fa910c533e918c1560b6b8fc00dda MD5 | raw file
 1<?php
 2/**
 3 * Compact semalt-blocker for non-composer installs
 4 */
 5
 6require_once('./../vendor/technosophos/PHPCompressor/src/lib/compactor.php');
 7
 8$source = "./sources.php";
 9$target = "./../compact/semaltblocker.php";
10
11print "Compacting semalt-blocker";
12
13$compactor = new Compactor($target);
14
15// Use filters like this (Useable for things like stripping debug-only logging):
16$compactor->setFilter(function ($in)
17{
18    $in = str_replace('require "./../vendor/true/punycode/src/Punycode.php";', '', $in);
19    $in = str_replace('require "./../src/SemaltBlocker/Domainparser.php";', '', $in);
20    $in = str_replace('require "./../src/SemaltBlocker/Updater.php";', '', $in);
21    $in = str_replace('require "./../src/SemaltBlocker/Blocker.php";', '', $in);
22    $in = str_replace("'./../../domains/blocked'", "'blocked'", $in);
23    return $in;
24});
25$compactor->compactAll($source);
26
27$compactor->report();
28$compactor->close();
29
30print "Testing test.php output:" . PHP_EOL;
31passthru('php ./../compact/test.php');