Guest User

Untitled

a guest
Oct 4th, 2018
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.34 KB | None | 0 0
  1. <?php
  2. if (!isset($layout_context))
  3. {
  4. $layout_context = "public";
  5. }
  6. ?>
  7. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/html4/loose.dtd">
  8. <html lang="en">
  9. <head>
  10. <title>Widget Corp <?php if ($layout_context == "admin") { echo "Admin"; } ?></title>
  11. <link href="stylesheets/public.css" media="all" rel="stylesheet" type="text/css" />
  12. </head>
  13. <body>
  14. <div id="header">
  15. <h1>Widget Corp <?php if ($layout_context == "admin") { echo "Admin"; } ?></h1>
  16. </div>
  17.  
  18. @charset "utf-8";
  19. /*
  20. #EEE489 - Light Tan
  21. #8D0D19 - Burgundy
  22. #1A446C - Blue Grey
  23. #D4E6F4 - Very Light Blue
  24. #689DC1 - Light Blue
  25. *
  26. {
  27. margin: 0;
  28. padding: 0;
  29. }
  30.  
  31. */
  32.  
  33. body
  34. {
  35. height: 100%;
  36. width: 100%;
  37. margin: 0;
  38. padding: 0;
  39. border: 0;
  40. font-family: Verdana, Arial, Helvetica, sans-serif;
  41. font-size: 13px;
  42. line-height: 15px;
  43. background: #EEE489;
  44. }
  45.  
  46. img
  47. {
  48. border: none;
  49. }
  50.  
  51. a
  52. {
  53. color: #8D0D19;
  54. }
  55.  
  56. a:hover
  57. {
  58. color: #1A446C;
  59. }
  60.  
  61. #header
  62. {
  63. height: 70px;
  64. margin: 0;
  65. padding: 0;
  66. text-align: left;
  67. background: #1A446C;
  68. color: #D4E6F4;
  69. }
  70.  
  71. #header h1
  72. {
  73. padding: 1em;
  74. margin: 0;
  75. }
  76.  
  77. #main
  78. {
  79. height: 600px;
  80. width: 100%;
  81. margin: 0;
  82. padding: 0;
  83. background: #EEE4899;
  84. position: relative;
  85. }
  86.  
  87. #footer
  88. {
  89. clear: both;
  90. height: 2em;
  91. margin: 0;
  92. padding: 1em;
  93. text-align: center;
  94. background: #1A446C;
  95. color: #D4E6F4;
  96. }
  97.  
  98. /* Navigation */
  99. #navigation
  100. {
  101. float: left;
  102. width: 150px;
  103. height: 100%;
  104. margin: 0;
  105. color: #D4E6F4;
  106. background: #8D0D19;
  107. padding-top: 0;
  108. padding-right: 2em;
  109. padding-bottom: 0;
  110. padding-left: 2em;
  111. position: relative;
  112. }
  113.  
  114. #navigation a
  115. {
  116. color: #D4E6F4;
  117. text-decoration: none;
  118. }
  119.  
  120. #navigation a:hover
  121. {
  122. color: #FFFFFF;
  123. }
  124.  
  125. ul.subjects
  126. {
  127. margin: 1em 0;
  128. padding-left: 0;
  129. list-style: none;
  130. }
  131.  
  132. ul.pages
  133. {
  134. padding-left: 2em;
  135. list-style: square;
  136. font-weight: normal;
  137. }
  138.  
  139. .selected
  140. {
  141. font-weight: bold;
  142. }
  143.  
  144. /* Page Content */
  145. #page
  146. {
  147. float: left;
  148. height: 100%;
  149. padding-left: 2em;
  150. vertical-align: top;
  151. background: #EEE489;
  152. /*position: relative; */
  153. }
  154.  
  155. #page h2
  156. {
  157. color: #8D0D19;
  158. margin-top: 1em;
  159. }
  160.  
  161. #page h3
  162. {
  163. color: #8D0D19;
  164. }
  165.  
  166. .view-content
  167. {
  168. margin: 1em;
  169. padding: 1em;
  170. border: 1px solid #999999;
  171. }
  172.  
  173.  
  174. div.message
  175. {
  176. border: 2px solid #8D0D19;
  177. color: #8D0D19;
  178. font-weight: bold;
  179. margin: 1em 0;
  180. padding: 1em;
  181. }
  182.  
  183. .error
  184. {
  185. color: #8D0D19;
  186. border: 2px solid #8D0D19;
  187. margin = 1em 0;
  188. padding = 1em;
  189. }
  190.  
  191. .error ul
  192. {
  193. padding-left: 2em;
  194. }
  195.  
  196. <?php require_once("../includes/session.php") ?>
  197. <?php require_once("../includes/db_connection.php") ?>
  198. <?php require_once("../includes/functions.php") ?>
  199. <?php $layout_context = "public"; ?>
  200. <?php include("../includes/layouts/header.php") ?>
  201. <?php find_selected_page(true); ?>
  202. <div id="main">
  203. <div id="navigation">
  204. <?php echo public_navigation($current_subject, $current_page); ?>
  205. <a href="new_subject.php">+ Add a subject</a>
  206. </div>
  207. <div id="page">
  208. <?php if ($current_page) { ?>
  209. <h2><?php echo htmlentities($current_page["menu_name"]); ?></h2>
  210. <?php echo nl2br(htmlentities($current_page["content"])); ?>
  211. <?php } else { ?>
  212. <p>Welcome!</p>
  213. <?php } ?>
  214. <br />
  215. <a href="login.php">Login</a>
  216. </div>
  217. </div>
  218. <?php include("../includes/layouts/footer.php") ?>
  219.  
  220. <?php require_once("../includes/session.php"); ?>
  221. <?php require_once("../includes/db_connection.php"); ?>
  222. <?php require_once("../includes/functions.php"); ?>
  223. <?php require_once("../includes/validation_functions.php"); ?>
  224. <?php
  225. $username = "";
  226.  
  227. if (isset($_POST['submit']))
  228. {
  229. // validations
  230. $required_fields = array("username", "password");
  231. validate_presences($required_fields);
  232.  
  233. if (empty($errors))
  234. {
  235. // Attempt Login
  236. $username = $_POST["username"];
  237. $password = $_POST["password"];
  238.  
  239. $found_admin = attempt_login($username, $password);
  240.  
  241. if ($found_admin)
  242. {
  243. // Success
  244. // Mark user as logged in
  245. $_SESSION["admin_id"] = $found_admin["id"];
  246. $_SESSION["username"] = $found_admin["username"];
  247. redirect_to("admin.php");
  248. }
  249. else
  250. {
  251. // Failure
  252. $_SESSION["message"] = "Username/Password not found.";
  253. }
  254. }
  255. }
  256. else
  257. {
  258. }
  259. ?>
  260. <?php $layout_context = "admin"; ?>
  261. <?php include("../includes/layouts/header.php"); ?>
  262. <div id="main">
  263. <div id="navigation">
  264. &nbsp;
  265. </div>
  266. <div id="page">
  267. <br />
  268. <?php echo message(); ?>
  269. <?php echo form_errors($errors); ?>
  270.  
  271. <h2>Login</h2>
  272. <form action="login.php" method="post">
  273.  
  274. <p>Username:
  275. <input type="text" name="username" value="<?php echo htmlentities($username); ?>" />
  276. </p>
  277.  
  278. <p>Password:
  279. <input type="password" name="password" value="" />
  280. </p>
  281.  
  282. <input type="submit" name="submit" value="Submit" />
  283. </form>
  284. </div>
  285. </div>
  286. <?php include("../includes/layouts/footer.php"); ?>
Add Comment
Please, Sign In to add comment