Repository navigation
Expand file tree
/
Copy pathprotected.php
More file actions
45 lines (40 loc) · 1.45 KB
/
Copy pathprotected.php
File metadata and controls
45 lines (40 loc) · 1.45 KB
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
<?php
// OTAgo
// - OTA App Distribution System
// - https://github.com/DaveWoodCom/OTAgo
// - Copyright 2020 Dave Wood, Cerebral Gardens Inc.
require_once('common.php');
if (file_exists('configuration.php')) {
require_once('configuration.php');
}
else {
require_once('configuration.default.php');
}
require_once($authFile);
resolveBaseURL();
preventCaching();
if (!isValidUser()) {
requestAuthentication();
exit(); // Backstop in case a custom auth provider's requestAuthentication() forgets to exit
}
$userAgent = $_SERVER['HTTP_USER_AGENT'] ?? '';
if ($enableAndroid && stripos($userAgent, 'android') !== false) {
// Android
// Entity-encoded separators: this URL is substituted into an HTML href.
$installURL = $baseURL . 'apk.php?' . makeURLQueryString(queryStringAuthParameters(), '&');
}
elseif ($enableIOS) {
// Sadly we can't detect iOS/iPadOS via the User-Agent, so for now, just assuming iOS
// TODO: Use a client side method to detect iPhone vs iPad (or macOS/Linux etc)
$manifestURL = $baseURL . 'manifest.php?' . makeURLQueryString(queryStringAuthParameters(), '&');
$installURL = 'itms-services://?action=download-manifest&url=' . urlencode($manifestURL);
}
else {
returnInvalidConfiguration();
exit();
}
resolveDeprecatedPlaceholderNames();
$html = file_get_contents($webTemplate);
$html = str_replace($installURLPlaceholder, $installURL, $html);
$html = str_replace(OTAGO_VERSION_PLACEHOLDER, OTAGO_VERSION, $html);
echo $html;