-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathPatchCollector.php
executable file
·44 lines (39 loc) · 1.07 KB
/
PatchCollector.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/php
<?php
require('PatchObject.php');
require('PatchBase.php');
require('Database.php');
$list = array();
foreach (new \DirectoryIterator(__DIR__ . '/modules') as $file) {
if ($file->isFile() && $file->getExtension() == 'php') {
if ((include __DIR__ . '/modules/' . $file->getFilename()) == TRUE) {
$name = $file->getBasename('.php');
array_push($list, new $name());
}
}
}
//shuffle($list);
$db = new Database(__DIR__ . '/db.json');
echo 'Time: ' . date('c', $db->time()) . PHP_EOL;
if (!$db->load()) {
exit(1);
}
foreach ($list as $patch) {
$oldVer = $db->find($patch->id())->getVersion();
echo $patch->id() . ': ';
if ($patch->check()) {
$newVer = $patch->getPatch()->getVersion();
echo 'Version \'' . $newVer . '\' is ';
if (!empty($newVer) && $newVer != $oldVer) {
echo "\033[32m" . 'newer than \'' . $oldVer . '\'' . "\033[39m";
$db->addOrUpdate($patch->getPatch());
}
else
echo "\033[90m" . 'up to date' . "\033[39m";
echo '.' . PHP_EOL;
}
else
fwrite(STDERR, "\033[31m" . 'CHECK FAILED' . "\033[39m" . '!' . PHP_EOL);
}
$db->save();
?>