ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
build_phar.php
Go to the documentation of this file.
1 <?php
2 $dist = dirname(__DIR__).'/dist';
3 if (!is_dir($dist)) {
4  mkdir($dist, 0755);
5 }
6 if (file_exists($dist.'/random_compat.phar')) {
7  unlink($dist.'/random_compat.phar');
8 }
9 $phar = new Phar(
10  $dist.'/random_compat.phar',
11  FilesystemIterator::CURRENT_AS_FILEINFO | \FilesystemIterator::KEY_AS_FILENAME,
12  'random_compat.phar'
13 );
14 rename(
15  dirname(__DIR__).'/lib/random.php',
16  dirname(__DIR__).'/lib/index.php'
17 );
18 $phar->buildFromDirectory(dirname(__DIR__).'/lib');
19 rename(
20  dirname(__DIR__).'/lib/index.php',
21  dirname(__DIR__).'/lib/random.php'
22 );
23 
30 if ($argc > 1) {
31  if (!@is_readable($argv[1])) {
32  echo 'Could not read the private key file:', $argv[1], "\n";
33  exit(255);
34  }
35  $pkeyFile = file_get_contents($argv[1]);
36 
37  $private = openssl_get_privatekey($pkeyFile);
38  if ($private !== false) {
39  $pkey = '';
40  openssl_pkey_export($private, $pkey);
41  $phar->setSignatureAlgorithm(Phar::OPENSSL, $pkey);
42 
46  if (!@is_readable($dist.'/random_compat.phar.pubkey')) {
47  $details = openssl_pkey_get_details($private);
48  file_put_contents(
49  $dist.'/random_compat.phar.pubkey',
50  $details['key']
51  );
52  }
53  } else {
54  echo 'An error occurred reading the private key from OpenSSL.', "\n";
55  exit(255);
56  }
57 }
global $argv
Definition: svg-scanner.php:41
$dist
Definition: build_phar.php:2
if(!is_dir($dist)) if(file_exists($dist.'/random_compat.phar')) $phar
Definition: build_phar.php:9
exit
Definition: backend.php:16