Single-sign-on and self-serve account management. https://netsyms.biz/apps/accounthub
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

app.php 7.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. <?php
  2. require_once __DIR__ . "/required.php";
  3. if ($_SESSION['loggedin'] != true) {
  4. header('Location: index.php');
  5. die("Session expired. Log in again to continue.");
  6. }
  7. require_once __DIR__ . "/pages.php";
  8. $pageid = "home";
  9. if (!is_empty($_GET['page'])) {
  10. $pg = strtolower($_GET['page']);
  11. $pg = preg_replace('/[^0-9a-z_]/', "", $pg);
  12. if (array_key_exists($pg, PAGES) && file_exists(__DIR__ . "/pages/" . $pg . ".php")) {
  13. $pageid = $pg;
  14. } else {
  15. $pageid = "404";
  16. }
  17. }
  18. header("Link: <static/css/bootstrap.min.css>; rel=preload; as=style", false);
  19. header("Link: <static/css/material-color/material-color.min.css>; rel=preload; as=style", false);
  20. header("Link: <static/css/app.css>; rel=preload; as=style", false);
  21. header("Link: <static/css/fa-svg-with-js.css>; rel=preload; as=style", false);
  22. header("Link: <static/js/fontawesome-all.min.js>; rel=preload; as=script", false);
  23. header("Link: <static/js/jquery-3.3.1.min.js>; rel=preload; as=script", false);
  24. header("Link: <static/js/bootstrap.min.js>; rel=preload; as=script", false);
  25. ?>
  26. <!DOCTYPE html>
  27. <html>
  28. <head>
  29. <meta charset="UTF-8">
  30. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  31. <meta name="viewport" content="width=device-width, initial-scale=1">
  32. <title><?php echo SITE_TITLE; ?></title>
  33. <link rel="icon" href="static/img/logo.svg">
  34. <link href="static/css/bootstrap.min.css" rel="stylesheet">
  35. <link href="static/css/material-color/material-color.min.css" rel="stylesheet">
  36. <link href="static/css/app.css" rel="stylesheet">
  37. <link href="static/css/fa-svg-with-js.css" rel="stylesheet">
  38. <script nonce="<?php echo $SECURE_NONCE; ?>">
  39. FontAwesomeConfig = {autoAddCss: false}
  40. </script>
  41. <script src="static/js/fontawesome-all.min.js"></script>
  42. <?php
  43. // custom page styles
  44. if (isset(PAGES[$pageid]['styles'])) {
  45. foreach (PAGES[$pageid]['styles'] as $style) {
  46. echo "<link href=\"$style\" rel=\"stylesheet\">\n";
  47. header("Link: <$style>; rel=preload; as=style", false);
  48. }
  49. }
  50. ?>
  51. </head>
  52. <body>
  53. <?php
  54. // Alert messages
  55. if (!is_empty($_GET['msg']) && array_key_exists($_GET['msg'], MESSAGES)) {
  56. // optional string generation argument
  57. if (is_empty($_GET['arg'])) {
  58. $alertmsg = lang(MESSAGES[$_GET['msg']]['string'], false);
  59. } else {
  60. $alertmsg = lang2(MESSAGES[$_GET['msg']]['string'], ["arg" => strip_tags($_GET['arg'])], false);
  61. }
  62. $alerttype = MESSAGES[$_GET['msg']]['type'];
  63. $alerticon = "square-o";
  64. switch (MESSAGES[$_GET['msg']]['type']) {
  65. case "danger":
  66. $alerticon = "times";
  67. break;
  68. case "warning":
  69. $alerticon = "exclamation-triangle";
  70. break;
  71. case "info":
  72. $alerticon = "info-circle";
  73. break;
  74. case "success":
  75. $alerticon = "check";
  76. break;
  77. }
  78. echo <<<END
  79. <div class="row justify-content-center" id="msg-alert-box">
  80. <div class="col-11 col-sm-6 col-md-5 col-lg-4 col-xl-4">
  81. <div class="alert alert-dismissible alert-$alerttype">
  82. <button type="button" class="close">&times;</button>
  83. <i class="fas fa-$alerticon"></i> $alertmsg
  84. </div>
  85. </div>
  86. </div>
  87. END;
  88. }
  89. ?>
  90. <?php
  91. // Adjust as needed
  92. $navbar_breakpoint = "sm";
  93. // For mobile app
  94. echo "<script nonce=\"$SECURE_NONCE\">var navbar_breakpoint = \"$navbar_breakpoint\";</script>"
  95. ?>
  96. <nav class="navbar navbar-expand-<?php echo $navbar_breakpoint; ?> navbar-dark bg-blue fixed-top">
  97. <button class="navbar-toggler my-0 py-0" type="button" data-toggle="collapse" data-target="#navbar-collapse" aria-controls="navbar-collapse" aria-expanded="false" aria-label="Toggle navigation">
  98. <!--<i class="fas fa-bars"></i>-->
  99. <span class="navbar-toggler-icon"></span>
  100. </button>
  101. <a class="navbar-brand py-0 mr-auto" href="app.php">
  102. <img src="static/img/logo.svg" alt="" class="d-none d-<?php echo $navbar_breakpoint; ?>-inline brand-img py-0" />
  103. <?php echo SITE_TITLE; ?>
  104. </a>
  105. <div class="collapse navbar-collapse py-0" id="navbar-collapse">
  106. <div class="navbar-nav mr-auto py-0">
  107. <?php
  108. $curpagefound = false;
  109. foreach (PAGES as $id => $pg) {
  110. if ($pg['navbar'] === TRUE) {
  111. if ($pageid == $id) {
  112. $curpagefound = true;
  113. ?>
  114. <span class="nav-item py-<?php echo $navbar_breakpoint; ?>-0 active">
  115. <?php
  116. } else {
  117. ?>
  118. <span class="nav-item py-<?php echo $navbar_breakpoint; ?>-0">
  119. <?php
  120. }
  121. ?>
  122. <a class="nav-link py-<?php echo $navbar_breakpoint; ?>-0" href="app.php?page=<?php echo $id; ?>">
  123. <?php
  124. if (isset($pg['icon'])) {
  125. ?><i class="<?php echo $pg['icon']; ?> fa-fw"></i> <?php
  126. }
  127. lang($pg['title']);
  128. ?>
  129. </a>
  130. </span>
  131. <?php
  132. }
  133. }
  134. ?>
  135. </div>
  136. <div class="navbar-nav ml-auto py-0" id="navbar-right">
  137. <span class="nav-item py-<?php echo $navbar_breakpoint; ?>-0">
  138. <a class="nav-link py-<?php echo $navbar_breakpoint; ?>-0" href="<?php echo PORTAL_URL; ?>">
  139. <i class="fas fa-user fa-fw"></i><span>&nbsp;<?php echo $_SESSION['realname'] ?></span>
  140. </a>
  141. </span>
  142. <span class="nav-item mr-auto py-<?php echo $navbar_breakpoint; ?>-0">
  143. <a class="nav-link py-<?php echo $navbar_breakpoint; ?>-0" href="action.php?action=signout">
  144. <i class="fas fa-sign-out-alt fa-fw"></i><span>&nbsp;<?php lang("sign out") ?></span>
  145. </a>
  146. </span>
  147. </div>
  148. </div>
  149. </nav>
  150. <div class="container" id="main-content">
  151. <div>
  152. <?php
  153. include_once __DIR__ . '/pages/' . $pageid . ".php";
  154. ?>
  155. </div>
  156. <div class="footer">
  157. <?php echo FOOTER_TEXT; ?><br />
  158. Copyright &copy; <?php echo date('Y'); ?> <?php echo COPYRIGHT_NAME; ?>
  159. </div>
  160. </div>
  161. <script src="static/js/jquery-3.3.1.min.js"></script>
  162. <script src="static/js/bootstrap.min.js"></script>
  163. <script src="static/js/app.js"></script>
  164. <?php
  165. // custom page scripts
  166. if (isset(PAGES[$pageid]['scripts'])) {
  167. foreach (PAGES[$pageid]['scripts'] as $script) {
  168. echo "<script src=\"$script\"></script>\n";
  169. header("Link: <$script>; rel=preload; as=script", false);
  170. }
  171. }
  172. ?>
  173. </body>
  174. </html>