QwikClock is an employee time tracking app.
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 8.0KB

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