-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
71 lines (65 loc) · 2.03 KB
/
index.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php
// Scaffolding for the html interface
use PhoneBocx\Packages;
use PhoneBocx\WebAuth;
include __DIR__ . "/php/boot.php";
$html = [
"favicon" => "/core/sendfax.ico",
"head" => [],
"styles" => [],
"headers" => [],
"body" => [],
"footer" => [],
"scripts" => ["/core/js/jquery-3.6.0.min.js"],
"end" => ["</html>"],
];
$packages = Packages::getLocalPackages();
$hookfiles = [];
foreach ($packages as $name => $dir) {
$g = glob("$dir/meta/*webhook.php");
foreach ($g as $hookfile) {
$f = basename($hookfile);
$id = str_replace('_webhook.php', '', $f);
if (!empty($hookfiles[$id])) {
print "Found a dupe hookfile $id in $hookfile, previously:\n";
print json_encode($hookfiles) . "\n";
exit;
}
$hookfiles[$id] = $hookfile;
include $hookfile;
}
}
$includes = [];
foreach ($hookfiles as $p => $f) {
if (strpos($f, "/origcore/") !== false) {
continue;
}
$mname = $p . "_mainhook";
if (function_exists($mname)) {
$includes[$mname] = $f;
$mname($html);
}
$fname = $p . "_footerhook";
if (function_exists($fname)) {
$fname($html, $hookfiles);
$includes[$fname] = $f;
}
}
print '<!doctype html><html lang="en"><head profile="http://www.w3.org/2005/10/profile">' . implode("\n", $html['head']) . "\n";
print "<!-- styles -->\n" . implode("\n", $html['styles']) . "\n</head>\n";
print "<body>\n";
if (WebAuth::isLoggedIn()) {
print "<script>window.isloggedin=true;</script>\n";
} else {
print "<script>window.isloggedin=false;</script>\n";
}
// print "<p><pre>" . json_encode($includes) . "</pre></p>\n";
print "<!-- headers -->\n" . implode("\n", $html['headers']) . "\n<!-- end headers -->\n";
print "<!-- start body -->\n" . implode("\n", $html['body']) . "\n<!-- end body -->\n";
print "<!-- start footers -->\n" . implode("\n", $html['footer']) . "\n<!-- end footers -->\n</body>\n";
print "<!-- start scripts -->\n";
foreach ($html['scripts'] as $js) {
print " <script src='$js'></script>\n";
}
print "<!-- end scripts -->\n";
print implode("\n", $html['end']) . "\n";