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 7.7KB

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