2018-02-20 12:13:43 +01:00
#!/usr/bin/env php
< ? php
/*
Copyright 2016 - 2018 Daniil Gentili
( https :// daniil . it )
This file is part of MadelineProto .
MadelineProto is free software : you can redistribute it and / or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation , either version 3 of the License , or ( at your option ) any later version .
MadelineProto is distributed in the hope that it will be useful , but WITHOUT ANY WARRANTY ; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE .
See the GNU Affero General Public License for more details .
You should have received a copy of the GNU General Public License along with MadelineProto .
If not , see < http :// www . gnu . org / licenses />.
*/
2018-02-20 15:49:54 +01:00
if ( ! isset ( $argv [ 3 ])) {
2018-02-20 15:50:16 +01:00
echo 'Usage: ' . $argv [ 0 ] . ' inputDir output.phar ref' . PHP_EOL ;
2018-02-20 15:49:54 +01:00
die ( 1 );
2018-02-20 12:13:43 +01:00
}
2018-02-20 15:49:54 +01:00
@ unlink ( $argv [ 2 ]);
2018-02-20 12:13:43 +01:00
2018-02-20 15:49:54 +01:00
$p = new Phar ( __DIR__ . '/' . $argv [ 2 ], 0 , $argv [ 2 ]);
2019-05-31 00:27:47 +02:00
$p -> buildFromDirectory ( realpath ( $argv [ 1 ]), '/^((?!tests).)*(\.php|\.py|\.tl|\.json|\.dat)$/i' );
2018-02-25 17:17:28 +01:00
$p -> addFromString ( 'vendor/danog/madelineproto/.git/refs/heads/master' , $argv [ 3 ]);
2018-02-20 15:49:54 +01:00
$p -> addFromString ( '.git/refs/heads/master' , $argv [ 3 ]);
2018-02-20 12:13:43 +01:00
2018-02-25 17:17:28 +01:00
$p -> setStub ( ' < ? php
$backtrace = debug_backtrace ();
2019-05-11 02:17:57 +02:00
if ( ! isset ( $backtrace [ 0 ][ " file " ]) || ! in_array ( basename ( $backtrace [ 0 ][ " file " ]), [ " madeline.php " , " phar.php " ])) {
die ( " madeline.phar cannot be required manually: use the automatic loader, instead: https://docs.madelineproto.xyz/docs/INSTALLATION.html#simple " . PHP_EOL );
}
if ( isset ( $backtrace [ 1 ][ " file " ])) {
2019-05-22 17:35:16 +02:00
@ chdir ( dirname ( $backtrace [ 1 ][ " file " ]));
2019-05-11 02:17:57 +02:00
}
if ( $contents = file_get_contents ( " https://phar.madelineproto.xyz/phar.php?v=new " )) {
file_put_contents ( $backtrace [ 0 ][ " file " ], $contents );
2018-02-25 17:17:28 +01:00
}
2018-03-01 13:28:16 +01:00
2018-02-25 17:17:28 +01:00
Phar :: interceptFileFuncs ();
Phar :: mapPhar ( " '. $argv[2] .' " );
require_once " phar://'. $argv[2] .'/vendor/autoload.php " ;
__HALT_COMPILER (); ?> ');