Debian Codegraph @

templates/manifest.php

raw
1 <?php
2 namespace LAM\PWA;
3 /*
4
5 This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
6 Copyright (C) 2019 - 2025 Roland Gruber
7
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21
22 */
23
24 /**
25 * Manifest for progressive web app.
26 *
27 * @author Roland Gruber
28 * @package tools
29 */
30
31 /** security functions */
32 include_once(__DIR__ . "/../lib/security.inc");
33 /** common functions */
34 include_once(__DIR__ . "/../lib/account.inc");
35
36 if (!headers_sent()) {
37 header('Content-Type: application/json; charset=utf-8');
38 }
39
40 $baseUrl = getCallingURL();
41 if (str_contains($baseUrl, '/templates/manifest.php')) {
42 $baseUrl = substr($baseUrl, 0, strpos($baseUrl, '/templates/manifest.php'));
43 $urlMatches = [];
44 if (preg_match('/http(s)?:\\/\\/[^\\/]+(\\/.*)$/m', $baseUrl, $urlMatches)) {
45 $baseUrl = htmlspecialchars($urlMatches[2]);
46 }
47 else {
48 logNewMessage(LOG_ERR,'Unable to get base URL from ' . getCallingURL());
49 exit();
50 }
51 }
52 else {
53 logNewMessage(LOG_ERR, 'Unable to get base URL from ' . getCallingURL());
54 exit();
55 }
56
57 echo '{
58 "short_name": "LAM",
59 "name": "LDAP Account Manager",
60 "description": "LDAP Account Manager is a webfrontend for managing entries stored in an LDAP directory.",
61 "icons": [
62 {
63 "src": "' . $baseUrl . '/graphics/logo_192x192.png",
64 "type": "image/png",
65 "sizes": "192x192"
66 },
67 {
68 "src": "' . $baseUrl . '/graphics/logo_512x512.png",
69 "type": "image/png",
70 "sizes": "512x512"
71 }
72 ],
73 "screenshots" : [
74 {
75 "src": "' . $baseUrl . '/graphics/pwa_wide.png",
76 "sizes": "1920x1080",
77 "type": "image/png",
78 "form_factor": "wide"
79 },
80 {
81 "src": "' . $baseUrl . '/graphics/pwa_mobile.png",
82 "sizes": "1170x2532",
83 "type": "image/png",
84 "form_factor": "narrow"
85 }
86 ],
87 "start_url": "' . $baseUrl . '/templates/login.php",
88 "display": "standalone",
89 "orientation": "any",
90 "theme_color": "#ffffff",
91 "background_color": "#ffffff",
92 "categories": [
93 "security",
94 "utilities"
95 ]
96 }';