ILIAS  release_7 Revision v7.30-3-g800a261c036
info.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 2019 ILIAS open source, Extended GPL, see docs/LICENSE */
3
10define("HASH_ALGO", "sha1");
11define("COMPOSER_LOCK_PATH", __DIR__."/composer.lock");
12define("VENDOR_PATH", __DIR__."/vendor");
13
14header("Content-Type: text/plain");
15
16echo "composer.lock: ".composer_lock_hash()."\n";
17echo "vendor: ".vendor_hash()."\n";
18
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
26function 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
33function hash_directory($algo, $path, $exclude = []) {
34 $content = scandir($path);
35 sort($content);
36 return hash(
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}
if(! $in) $exclude
An exception for terminatinating execution or to throw for unit testing.
const COMPOSER_LOCK_PATH
Definition: info.php:11
hash_directory($algo, $path, $exclude=[])
Definition: info.php:33
vendor_hash()
Definition: info.php:26
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
const VENDOR_PATH
Definition: info.php:12