ILIAS  trunk Revision v11.0_alpha-1749-g1a06bdef097
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
info.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 2019 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
10 define("HASH_ALGO", "sha1");
11 define("COMPOSER_LOCK_PATH", __DIR__."/composer.lock");
12 define("VENDOR_PATH", __DIR__."/vendor");
13 
14 header("Content-Type: text/plain");
15 
16 echo "composer.lock: ".composer_lock_hash()."\n";
17 echo "vendor: ".vendor_hash()."\n";
18 
19 function composer_lock_hash() {
20  if (!file_exists(COMPOSER_LOCK_PATH)) {
21  return "composer.lock does not exist";
22  }
23  return hash_file(HASH_ALGO, COMPOSER_LOCK_PATH);
24 }
25 
26 function vendor_hash() {
27  if(!file_exists(VENDOR_PATH)) {
28  return "vendor directory does not exist";
29  }
30  return hash_directory(HASH_ALGO, VENDOR_PATH, [VENDOR_PATH."/autoload.php", VENDOR_PATH."/composer"]);
31 }
32 
33 function hash_directory($algo, $path, $exclude = []) {
34  $content = scandir($path);
35  sort($content);
36  return hash(
37  HASH_ALGO,
38  implode(
39  "",
40  array_map(
41  function($o) use ($algo, $path, $exclude) {
42  if ($o === "." || $o === ".." || $o === ".git") {
43  return "";
44  }
45  $o = "$path/$o";
46  if (is_link($o) || in_array($o, $exclude)) {
47  return "";
48  }
49  if (is_dir($o)) {
50  return hash_directory($algo, $o);
51  }
52  return hash_file($algo, $o);
53  },
54  $content
55  )
56  )
57  );
58 }
hash_directory($algo, $path, $exclude=[])
Definition: info.php:33
vendor_hash()
Definition: info.php:26
const COMPOSER_LOCK_PATH
Definition: info.php:11
const VENDOR_PATH
Definition: info.php:12
sort()
description: > Example for rendering a Sort Glyph.
Definition: sort.php:41
$path
Definition: ltiservices.php:29
composer_lock_hash()
Definition: info.php:19
const HASH_ALGO
This script can be used to quickly compare the state of the vendor directory with some reference...
Definition: info.php:10
header()
expected output: > ILIAS shows the rendered Component.
Definition: header.php:29