-
Notifications
You must be signed in to change notification settings - Fork 0
/
common.php
49 lines (44 loc) · 1.48 KB
/
common.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
<?php
session_start();
error_reporting(E_ALL);
ini_set('display_errors', '1');
const NEWLINE = '<br /><br />';
function findProtocol() {
if(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on')
$protocol = "https";
else
$protocol = "http";
return $protocol;
}
function findHostRoot() {
if(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on')
$protocol = "https://";
else
$protocol = "http://";
$thisFile = $_SERVER['REQUEST_URI'];
$thisFile = substr($thisFile, strrpos("/$thisFile", '/'));
$hostRoot = str_replace($thisFile, "", $_SERVER['REQUEST_URI']);
$hostRoot = $protocol . $_SERVER['HTTP_HOST'] . $hostRoot;
return $hostRoot;
}
function debugEcho($msg) {
global $debugMode;
if (isset($debugMode) && $debugMode == true) {
echo $msg;
}
}
function diePretty($msg) {
global $docRoot;
global $appTitle;
echo file_get_contents("https://www.webosarchive.org/app-template/header.php?docRoot=" . $docRoot . "&appTitle=" . $appTitle . "&protocol=" . findProtocol());
echo "<p align='center'><b>Error</b>: " . $msg . "</p>";
include ($docRoot . "inc/footer.php");
}
function succeedPretty($msg) {
global $docRoot;
global $appTitle;
echo file_get_contents("https://www.webosarchive.org/app-template/header.php?docRoot=" . $docRoot . "&appTitle=" . $appTitle . "&protocol=" . findProtocol());
echo "<p align='center'>" . $msg . "</p>";
include ($docRoot . "inc/footer.php");
}
?>