|
2 | 2 | use Nette\Utils\Helpers;
|
3 | 3 | use Melbahja\Http2\Pusher;
|
4 | 4 |
|
| 5 | +use function Webfan\Codebase\Server\init; |
| 6 | + |
5 | 7 | //broken version quick patch
|
6 | 8 | if(isset($_GET['version']) && 'latest' !== $_GET['version']){
|
7 | 9 | unset($_GET['version']);
|
@@ -37,9 +39,9 @@ function cleanArray($didYouMeans){
|
37 | 39 | $content='';
|
38 | 40 |
|
39 | 41 | require __DIR__.'/../vendor/autoload.php';
|
40 |
| - //ClassMapsLoaderBundle.php |
41 |
| - |
| 42 | + |
42 | 43 |
|
| 44 | +init(); |
43 | 45 |
|
44 | 46 | $pub_key_file = __DIR__ . ''. \DIRECTORY_SEPARATOR. '..' . \DIRECTORY_SEPARATOR. '.api-keys'. \DIRECTORY_SEPARATOR. 'pub.key';
|
45 | 47 | $priv_key_file = __DIR__ . ''. \DIRECTORY_SEPARATOR. '..'. \DIRECTORY_SEPARATOR. '.api-keys'. \DIRECTORY_SEPARATOR. 'priv.key';
|
@@ -210,13 +212,55 @@ function cleanArray($didYouMeans){
|
210 | 212 |
|
211 | 213 |
|
212 | 214 |
|
213 |
| - $classMaps = require $cacheFile; |
214 |
| - |
| 215 | + $ExportHelper = new \Webfan\Codebase\Server\BundleExportHelper($loader, |
| 216 | + file_get_contents($pub_key_file), |
| 217 | + file_get_contents($priv_key_file), |
| 218 | + $password); |
215 | 219 |
|
216 |
| - $Helper = new \Wehowski\Helpers\ArrayHelper($classMaps); |
217 |
| - $classes=$Helper->keys(); |
| 220 | + |
| 221 | + $classMaps = $ExportHelper->classmap(true, true); |
| 222 | + $classes=$ExportHelper->classes(true, true); |
218 | 223 |
|
219 | 224 |
|
| 225 | + |
| 226 | + |
| 227 | + |
| 228 | +//deprecatipons @ToDo: better API e.g. PSR-15 |
| 229 | +if(empty($content) && !isset($_REQUEST['bundle']) && isset($_REQUEST['source']) && '*'!==$_REQUEST['source']){ |
| 230 | + // $file = $ExportHelper->classfile($source); |
| 231 | + |
| 232 | + $classCode = $ExportHelper->code($_REQUEST['source'], |
| 233 | + isset($_REQUEST['version']) ? $_REQUEST['version'] : null, |
| 234 | + true, |
| 235 | + ( |
| 236 | + (isset($_SERVER['HTTP_X_SOURCE_ENCODING']) && 'b64' === $_SERVER['HTTP_X_SOURCE_ENCODING']) |
| 237 | + || (isset($_REQUEST['source-encoding']) && 'b64' === $_REQUEST['source-encoding']) |
| 238 | + ) |
| 239 | + ); |
| 240 | + if(false!==$classCode){ |
| 241 | + |
| 242 | + $outPut = $classCode; |
| 243 | + header('Content-Type: text/plain'); |
| 244 | + |
| 245 | + $hash_check = strlen($outPut).'.'.sha1($outPut); |
| 246 | + $userHash_check = sha1(((isset($_REQUEST['salt']))?$_REQUEST['salt']:null) .$hash_check); |
| 247 | + header('X-Content-Hash: '.$hash_check); |
| 248 | + header('X-User-Hash: '.$userHash_check); |
| 249 | + |
| 250 | + header('Content-Md5: '.md5($outPut)); |
| 251 | + header('Content-Sha1: '.sha1($outPut)); |
| 252 | + |
| 253 | + echo $outPut; |
| 254 | + die(); |
| 255 | + }//$classCode |
| 256 | +} |
| 257 | + |
| 258 | + |
| 259 | + |
| 260 | + |
| 261 | + |
| 262 | + |
| 263 | +//deprecatipons @ToDo: better API e.g. PSR-15 |
220 | 264 | if(isset($_GET['bundle']) && !isset($_GET['source'])){
|
221 | 265 | $_GET['source'] = $_GET['bundle'];
|
222 | 266 | }elseif(isset($_GET['bundle']) && isset($_GET['source'])){
|
|
0 commit comments