Browse Source

Add original code

Frans Bergman 7 years ago
parent
commit
4591002b3c

+ 2 - 0
.gitignore

@@ -0,0 +1,2 @@
+download/
+images/

+ 58 - 0
.htaccess

@@ -0,0 +1,58 @@
+AddDefaultCharset UTF-8
+
+# Do not remove this line, otherwise mod_rewrite rules will stop working
+RewriteEngine On
+
+RewriteCond %{REQUEST_FILENAME} !-f
+RewriteCond %{REQUEST_FILENAME} !-d
+RewriteRule ^([^/]+)/?$ index.php?p=$1 [L,QSA]
+
+ErrorDocument 404 https://tankernn.eu/?p=404
+
+## EXPIRES CACHING ##
+<IfModule mod_expires.c>
+ExpiresActive On
+ExpiresByType image/jpg "access plus 1 week"
+ExpiresByType image/jpeg "access plus 1 week"
+ExpiresByType image/gif "access plus 1 week"
+ExpiresByType image/png "access plus 1 week"
+ExpiresByType text/css "access plus 1 week"
+ExpiresByType application/pdf "access plus 1 week"
+ExpiresByType text/x-javascript "access plus 1 week"
+ExpiresByType application/x-shockwave-flash "access plus 1 week"
+ExpiresByType image/x-icon "access plus 1 week"
+ExpiresByType text/javascript "access plus 1 week"
+ExpiresDefault "access"
+</IfModule>
+## EXPIRES CACHING ##
+
+<IfModule mod_deflate.c>
+  # Compress HTML, CSS, JavaScript, Text, XML and fonts
+  AddOutputFilterByType DEFLATE application/javascript
+  AddOutputFilterByType DEFLATE application/rss+xml
+  AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
+  AddOutputFilterByType DEFLATE application/x-font
+  AddOutputFilterByType DEFLATE application/x-font-opentype
+  AddOutputFilterByType DEFLATE application/x-font-otf
+  AddOutputFilterByType DEFLATE application/x-font-truetype
+  AddOutputFilterByType DEFLATE application/x-font-ttf
+  AddOutputFilterByType DEFLATE application/x-javascript
+  AddOutputFilterByType DEFLATE application/xhtml+xml
+  AddOutputFilterByType DEFLATE application/xml
+  AddOutputFilterByType DEFLATE font/opentype
+  AddOutputFilterByType DEFLATE font/otf
+  AddOutputFilterByType DEFLATE font/ttf
+  AddOutputFilterByType DEFLATE image/svg+xml
+  AddOutputFilterByType DEFLATE image/x-icon
+  AddOutputFilterByType DEFLATE text/css
+  AddOutputFilterByType DEFLATE text/html
+  AddOutputFilterByType DEFLATE text/javascript
+  AddOutputFilterByType DEFLATE text/plain
+  AddOutputFilterByType DEFLATE text/xml
+
+  # Remove browser bugs (only needed for really old browsers)
+  BrowserMatch ^Mozilla/4 gzip-only-text/html
+  BrowserMatch ^Mozilla/4\.0[678] no-gzip
+  BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
+  Header append Vary User-Agent
+</IfModule>

+ 60 - 0
admin/actions/activate.php

@@ -0,0 +1,60 @@
+<?php
+  require 'app.php';
+
+  if (isset($_GET['key'])) {
+    $key = $_GET['key'];
+
+    $sql = "SELECT * FROM Activations WHERE Activation_key='$key'";
+    $query = $conn->query($sql);
+    if (!($row = $query->fetch_array())) {
+      die("No such key in database.");
+    }
+
+    $type = $row['Type'];
+    $value = $row['Val'];
+    $user = $row['User'];
+    if ($type == "Addresses") {
+      $values = json_decode($conn->query("SELECT * FROM Users WHERE User='$user'")->fetch_array()['Addresses'], true);
+      array_push($values, $value);
+      $value = json_encode($values);
+    }
+
+    $sql = "UPDATE Users SET $type='$value' WHERE User='$user'";
+    if ($conn->query($sql)) {
+      queue_message(new Message("Successfully activated $type.", "success"));
+      $sql = "DELETE FROM Activations WHERE Activation_key='$key'";
+      $conn->query($sql);
+      header("Location: ../index.php");
+    } else {
+      echo "Failed to activate $type. Error: " . $conn->error;
+    }
+  } else { ?>
+    <!DOCTYPE html>
+    <html>
+      <?php include '../pageparts/head.php'; ?>
+      <body>
+        <div class="container" style="margin-top: 100px;">
+          <div class="row">
+            <div class="col-lg-6 col-md-offset-3">
+              <div class="panel panel-default">
+                <div class="panel-heading">
+                  <i class="glyphicon glyphicon-lock"></i> No key specified
+                </div>
+                <div class="panel-body">
+                  <form role="form" action="" method="get">
+                    <div class="input-group" style="margin-bottom: 10px;">
+                      <span class="input-group-addon">Key:</span>
+                      <input class="form-control" placeholder="Activation key" name="key" autofocus="" type="text">
+                    </div>
+                    <input class="btn btn-primary btn-block" type="submit" value="Activate"/>
+	                </form>
+                </div>
+              </div>
+            </div>
+          </div>
+        </div>
+      </body>
+    </html>
+    <?php
+  }
+?>

+ 21 - 0
admin/actions/delete.php

@@ -0,0 +1,21 @@
+<?php
+require 'app.php';
+
+if (isset($_GET['uid']) and isset($_GET['type'])) {
+		$uid = $_GET['uid'];
+		$type = $_GET['type'];
+		if (!hasPermission("delete.$type")) {
+			die("Not enough permissions.");
+		}
+
+		$sql = "DELETE FROM $type WHERE UID='$uid'";
+		if ($conn->query($sql)) {
+			echo "Successfully deleted $type.";
+		} else {
+			echo "Error deleting record: " . $conn->error;
+		}
+		echo $conn->error;
+} else {
+	echo 'Something went wrong! (No type or no UID provided.)';
+}
+?>

+ 27 - 0
admin/actions/edit_user.php

@@ -0,0 +1,27 @@
+<?php
+  require 'app.php';
+
+  if (isset($_SESSION['user'])) { // Update account info
+    $username = $_SESSION['user'];
+    $userid = $_SESSION['userid'];
+    if (isset($_POST['newPass'])) {
+      changePassword($userid, $_POST['newPass'], $_POST['repeatNewPass'], $_POST['oldPass']);
+    } else if (isset($_POST['email'])) {
+      $mail = $_POST['email'];
+      if ($mail === $_POST['repeatEmail']) {
+        new_activation($username, "Email", $mail);
+      } else {
+        queue_message(new Message("Addresses do not match.", "danger"));
+      }
+    }
+    // TODO Admin can edit other users' permissions
+    if (isset($_POST['permissions'])) {
+      $object = (object) ['property' => 'Here we go'];
+    }
+
+    header("Location: ../account_settings");
+  } else {
+    echo "Not logged in.";
+  }
+
+?>

+ 65 - 0
admin/actions/getList.php

@@ -0,0 +1,65 @@
+<?php
+  require 'app.php';
+
+  $type = "";
+  if (isset($_GET['type']))
+    $type = $_GET['type'];
+  else
+    die("No type specified.");
+
+  if (!hasPermission("list.$type")) {
+		die("Not enough permissions.");
+	}
+?>
+    <?php
+    $result = $conn->query("SELECT * FROM $type ORDER BY listId");
+
+    if ($result === FALSE) {
+      $result = $conn->query("SELECT * FROM $type ORDER BY UID");
+    }
+
+    while($row = $result->fetch_array()) {
+      if (isset($row['name'])) {
+        $name = $row['name'];
+      } else {
+        $name = $row['User'];
+      }
+    	?>
+    	<tr id="<?php echo "Item_" . $row['UID'] ?>">
+    		<td><?php echo $name ?></td>
+    		<td>
+    			<!--Delete button-->
+    			<form>
+    				<input type="hidden" class="uid" name="uid" value="<?php echo $row['UID'] ?>"/>
+    				<button class="btn delete btn-danger" data-target="#delete-modal-<?php echo $row['UID'] ?>" data-toggle="modal" type="button"><i class="fa fa-trash-o"></i> Delete</button>
+            <!-- Modal -->
+            <div id="delete-modal-<?php echo $row['UID'] ?>" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="delete-modal-<?php echo $row['UID'] ?>">
+              <div class="modal-dialog" role="document">
+                <div class="modal-content">
+                  <div class="modal-header">
+                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
+                    <h4 class="modal-title" id="delete-modal-<?php echo $row['UID'] ?>">Confirm deletion</h4>
+                  </div>
+                  <div class="modal-body">
+                    Clicking 'Delete' will permanently delete the <?php echo strtolower($type) . " '$name'" ?>. Are you sure you want to do this?
+                  </div>
+                  <div class="modal-footer">
+                    <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
+                    <button data="<?php echo $row['UID'] ?>" data-dismiss="modal" type="button" class="delete-confirm btn btn-danger">Delete</button>
+                  </div>
+                </div>
+              </div>
+            </div>
+    			</form>
+    			<!--Edit button-->
+    			<form action="" method="get">
+    				<input type="hidden" name="p" value="edit"/>
+    				<input type="hidden" name="type" value="<?php echo $type; ?>"/>
+    				<input type="hidden" name="uid" value="<?php echo $row['UID'] ?>"/>
+    				<button class="btn btn-primary" type="submit"><i class="fa fa-pencil"></i> Edit</button>
+    			</form>
+    		</td>
+    	</tr>
+    	<?php
+    }
+?>

+ 34 - 0
admin/actions/get_sections.php

@@ -0,0 +1,34 @@
+<?php
+  require "app.php";
+
+  if (!hasPermission("edit.Page")) {
+		die("Not enough permissions.");
+	}
+
+  if (isset($_GET['listall'])) {
+    $query = $conn->query("SELECT UID, name FROM Section");
+    $sectionlist = array();
+
+    while ($row = $query->fetch_array()) {
+      $sectionlist[$row['UID']] = $row['name'];
+    }
+
+    echo json_encode($sectionlist);
+  } else if (isset($_GET['getids'])) {
+    $sectionnames = json_decode($_GET['getids']);
+
+    $sectionids = array();
+
+    foreach ($sectionnames as $sectionname)
+      array_push($sectionids, $conn->query("SELECT UID FROM Section WHERE name='$sectionname'")->fetch_array()['UID']);
+
+    echo json_encode($sectionids);
+  } else {
+    $sections = json_decode($_GET['sections']);
+
+    $app = new App(true);
+    foreach ($sections as $section) {
+      $app->addSection($section);
+    }
+  }
+?>

+ 17 - 0
admin/actions/new.php

@@ -0,0 +1,17 @@
+<?php
+	require 'app.php';
+
+	$type = $_GET['type'];
+	$name = $_POST['name'];
+
+	if (!hasPermission("new.$type")) {
+		die("Not enough permissions.");
+	}
+
+	$sql = "INSERT INTO $type SET name='$name'";
+	if($conn->query($sql)) {
+		echo "Successfully created new $type!";
+	} else {
+		echo $conn->error;
+	}
+?>

+ 24 - 0
admin/actions/updateListOrder.php

@@ -0,0 +1,24 @@
+<?php
+  require "app.php";
+
+  $type = "";
+  if (isset($_GET['type']))
+    $type = $_GET['type'];
+  else
+    die("No type specified.");
+
+  if (!hasPermission("list.$type")) {
+		die("Not enough permissions.");
+	}
+
+  $updateRecordsArray = $_POST['Item'];
+
+  $listingCounter = 1;
+  foreach ($updateRecordsArray as $recordIDValue) {
+  	$query = "UPDATE $type SET listId='$listingCounter' WHERE UID='$recordIDValue'";
+  	$conn->query($query) or die('Error, insert query failed');
+  	$listingCounter = $listingCounter + 1;
+  }
+
+  echo "Successfully saved order!";
+?>

+ 28 - 0
admin/actions/updatePermissions.php

@@ -0,0 +1,28 @@
+<?php
+  require("app.php");
+
+  if (!hasPermission("edit.User")) {
+		die("Not enough permissions.");
+	}
+
+  $uid = $_GET['uid'];
+
+  $custom = $_POST['custom'];
+  $level = $_POST['level'];
+
+  $level = intval($level);
+
+  $permissions = new StdClass();
+
+  $permissions->permission_level = $level;
+  $permissions->custom_permissions = json_decode($custom);
+
+  $permissionString = json_encode($permissions);
+
+  if ($conn->query("UPDATE Users SET Permissions='$permissionString' WHERE UID='$uid'")) {
+    echo "Successfully updated permissions.";
+  } else {
+    echo "Error updating database: " . $conn->error;
+  }
+
+?>

+ 68 - 0
admin/css/Style.css

@@ -0,0 +1,68 @@
+body {
+    background-color: #0089ff;
+}
+
+/* #### Forms ##### */
+
+div.CodeMirror {
+  font-family: Arial;
+  border: 1px solid;
+}
+
+#preview {
+  border-left: 1px dotted gray;
+  background-color: #00a4e1;
+}
+
+#preview * {
+  max-width: 100%;
+}
+
+.input-group {
+  margin-bottom: 5px;
+}
+
+.alert {
+  margin-top: 10px;
+  margin-bottom: 10px;
+}
+
+/* #### Lists ##### */
+
+table.list tbody tr td form {
+	display: inline;
+}
+
+/* #### Sortable permission list #### */
+
+div.sort {
+  display: inline;
+  margin-right: 10px;
+  float:left;
+  width: 45%;
+}
+
+div.sort ul {
+  height:200px;
+  width:100%;
+  padding: 0;
+}
+
+div.sort ul li {
+  list-style: none;
+  margin: 0;
+  padding: 5px;
+  border: 1px solid rgba(0, 0, 0, 0.2);
+}
+
+div#allow ul {
+  background-color: lightgreen;
+}
+
+div#forbid ul {
+  background-color: red;
+}
+
+.permlist {
+  overflow-y: scroll;
+}

+ 354 - 0
admin/css/sb-admin-2.css

@@ -0,0 +1,354 @@
+/*!
+ * Start Bootstrap - SB Admin 2 Bootstrap Admin Theme (http://startbootstrap.com)
+ * Code licensed under the Apache License v2.0.
+ * For details, see http://www.apache.org/licenses/LICENSE-2.0.
+ */
+
+body {
+    background-color: #f8f8f8;
+}
+
+#wrapper {
+    width: 100%;
+}
+
+#page-wrapper {
+    padding: 0 15px;
+    min-height: 568px;
+    background-color: #fff;
+}
+
+@media(min-width:768px) {
+    #page-wrapper {
+        position: inherit;
+        margin: 0 0 0 250px;
+        padding: 0 30px;
+        border-left: 1px solid #e7e7e7;
+    }
+}
+
+.navbar-top-links {
+    margin-right: 0;
+}
+
+.navbar-top-links li {
+    display: inline-block;
+}
+
+.navbar-top-links li:last-child {
+    margin-right: 15px;
+}
+
+.navbar-top-links li a {
+    padding: 15px;
+    min-height: 50px;
+}
+
+.navbar-top-links .dropdown-menu li {
+    display: block;
+}
+
+.navbar-top-links .dropdown-menu li:last-child {
+    margin-right: 0;
+}
+
+.navbar-top-links .dropdown-menu li a {
+    padding: 3px 20px;
+    min-height: 0;
+}
+
+.navbar-top-links .dropdown-menu li a div {
+    white-space: normal;
+}
+
+.navbar-top-links .dropdown-messages,
+.navbar-top-links .dropdown-tasks,
+.navbar-top-links .dropdown-alerts {
+    width: 310px;
+    min-width: 0;
+}
+
+.navbar-top-links .dropdown-messages {
+    margin-left: 5px;
+}
+
+.navbar-top-links .dropdown-tasks {
+    margin-left: -59px;
+}
+
+.navbar-top-links .dropdown-alerts {
+    margin-left: -123px;
+}
+
+.navbar-top-links .dropdown-user {
+    right: 0;
+    left: auto;
+}
+
+.sidebar .sidebar-nav.navbar-collapse {
+    padding-right: 0;
+    padding-left: 0;
+}
+
+.sidebar .sidebar-search {
+    padding: 15px;
+}
+
+.sidebar ul li {
+    border-bottom: 1px solid #e7e7e7;
+}
+
+.sidebar ul li a.active {
+    background-color: #eee;
+}
+
+.sidebar .arrow {
+    float: right;
+}
+
+.sidebar .fa.arrow:before {
+    content: "\f104";
+}
+
+.sidebar .active>a>.fa.arrow:before {
+    content: "\f107";
+}
+
+.sidebar .nav-second-level li,
+.sidebar .nav-third-level li {
+    border-bottom: 0!important;
+}
+
+.sidebar .nav-second-level li a {
+    padding-left: 37px;
+}
+
+.sidebar .nav-third-level li a {
+    padding-left: 52px;
+}
+
+@media(min-width:768px) {
+    .sidebar {
+        z-index: 1;
+        position: absolute;
+        width: 250px;
+        margin-top: 51px;
+    }
+
+    .navbar-top-links .dropdown-messages,
+    .navbar-top-links .dropdown-tasks,
+    .navbar-top-links .dropdown-alerts {
+        margin-left: auto;
+    }
+}
+
+.btn-outline {
+    color: inherit;
+    background-color: transparent;
+    transition: all .5s;
+}
+
+.btn-primary.btn-outline {
+    color: #428bca;
+}
+
+.btn-success.btn-outline {
+    color: #5cb85c;
+}
+
+.btn-info.btn-outline {
+    color: #5bc0de;
+}
+
+.btn-warning.btn-outline {
+    color: #f0ad4e;
+}
+
+.btn-danger.btn-outline {
+    color: #d9534f;
+}
+
+.btn-primary.btn-outline:hover,
+.btn-success.btn-outline:hover,
+.btn-info.btn-outline:hover,
+.btn-warning.btn-outline:hover,
+.btn-danger.btn-outline:hover {
+    color: #fff;
+}
+
+.chat {
+    margin: 0;
+    padding: 0;
+    list-style: none;
+}
+
+.chat li {
+    margin-bottom: 10px;
+    padding-bottom: 5px;
+    border-bottom: 1px dotted #999;
+}
+
+.chat li.left .chat-body {
+    margin-left: 60px;
+}
+
+.chat li.right .chat-body {
+    margin-right: 60px;
+}
+
+.chat li .chat-body p {
+    margin: 0;
+}
+
+.panel .slidedown .glyphicon,
+.chat .glyphicon {
+    margin-right: 5px;
+}
+
+.chat-panel .panel-body {
+    height: 350px;
+    overflow-y: scroll;
+}
+
+.login-panel {
+    margin-top: 25%;
+}
+
+.flot-chart {
+    display: block;
+    height: 400px;
+}
+
+.flot-chart-content {
+    width: 100%;
+    height: 100%;
+}
+
+.dataTables_wrapper {
+    position: relative;
+    clear: both;
+}
+
+table.dataTable thead .sorting,
+table.dataTable thead .sorting_asc,
+table.dataTable thead .sorting_desc,
+table.dataTable thead .sorting_asc_disabled,
+table.dataTable thead .sorting_desc_disabled {
+    background: 0 0;
+}
+
+table.dataTable thead .sorting_asc:after {
+    content: "\f0de";
+    float: right;
+    font-family: fontawesome;
+}
+
+table.dataTable thead .sorting_desc:after {
+    content: "\f0dd";
+    float: right;
+    font-family: fontawesome;
+}
+
+table.dataTable thead .sorting:after {
+    content: "\f0dc";
+    float: right;
+    font-family: fontawesome;
+    color: rgba(50,50,50,.5);
+}
+
+.btn-circle {
+    width: 30px;
+    height: 30px;
+    padding: 6px 0;
+    border-radius: 15px;
+    text-align: center;
+    font-size: 12px;
+    line-height: 1.428571429;
+}
+
+.btn-circle.btn-lg {
+    width: 50px;
+    height: 50px;
+    padding: 10px 16px;
+    border-radius: 25px;
+    font-size: 18px;
+    line-height: 1.33;
+}
+
+.btn-circle.btn-xl {
+    width: 70px;
+    height: 70px;
+    padding: 10px 16px;
+    border-radius: 35px;
+    font-size: 24px;
+    line-height: 1.33;
+}
+
+.show-grid [class^=col-] {
+    padding-top: 10px;
+    padding-bottom: 10px;
+    border: 1px solid #ddd;
+    background-color: #eee!important;
+}
+
+.show-grid {
+    margin: 15px 0;
+}
+
+.huge {
+    font-size: 40px;
+}
+
+.panel-green {
+    border-color: #5cb85c;
+}
+
+.panel-green .panel-heading {
+    border-color: #5cb85c;
+    color: #fff;
+    background-color: #5cb85c;
+}
+
+.panel-green a {
+    color: #5cb85c;
+}
+
+.panel-green a:hover {
+    color: #3d8b3d;
+}
+
+.panel-red {
+    border-color: #d9534f;
+}
+
+.panel-red .panel-heading {
+    border-color: #d9534f;
+    color: #fff;
+    background-color: #d9534f;
+}
+
+.panel-red a {
+    color: #d9534f;
+}
+
+.panel-red a:hover {
+    color: #b52b27;
+}
+
+.panel-yellow {
+    border-color: #f0ad4e;
+}
+
+.panel-yellow .panel-heading {
+    border-color: #f0ad4e;
+    color: #fff;
+    background-color: #f0ad4e;
+}
+
+.panel-yellow a {
+    color: #f0ad4e;
+}
+
+.panel-yellow a:hover {
+    color: #df8a13;
+}

+ 180 - 0
admin/css/timeline.css

@@ -0,0 +1,180 @@
+.timeline {
+    position: relative;
+    padding: 20px 0 20px;
+    list-style: none;
+}
+
+.timeline:before {
+    content: " ";
+    position: absolute;
+    top: 0;
+    bottom: 0;
+    left: 50%;
+    width: 3px;
+    margin-left: -1.5px;
+    background-color: #eeeeee;
+}
+
+.timeline > li {
+    position: relative;
+    margin-bottom: 20px;
+}
+
+.timeline > li:before,
+.timeline > li:after {
+    content: " ";
+    display: table;
+}
+
+.timeline > li:after {
+    clear: both;
+}
+
+.timeline > li:before,
+.timeline > li:after {
+    content: " ";
+    display: table;
+}
+
+.timeline > li:after {
+    clear: both;
+}
+
+.timeline > li > .timeline-panel {
+    float: left;
+    position: relative;
+    width: 46%;
+    padding: 20px;
+    border: 1px solid #d4d4d4;
+    border-radius: 2px;
+    -webkit-box-shadow: 0 1px 6px rgba(0,0,0,0.175);
+    box-shadow: 0 1px 6px rgba(0,0,0,0.175);
+}
+
+.timeline > li > .timeline-panel:before {
+    content: " ";
+    display: inline-block;
+    position: absolute;
+    top: 26px;
+    right: -15px;
+    border-top: 15px solid transparent;
+    border-right: 0 solid #ccc;
+    border-bottom: 15px solid transparent;
+    border-left: 15px solid #ccc;
+}
+
+.timeline > li > .timeline-panel:after {
+    content: " ";
+    display: inline-block;
+    position: absolute;
+    top: 27px;
+    right: -14px;
+    border-top: 14px solid transparent;
+    border-right: 0 solid #fff;
+    border-bottom: 14px solid transparent;
+    border-left: 14px solid #fff;
+}
+
+.timeline > li > .timeline-badge {
+    z-index: 100;
+    position: absolute;
+    top: 16px;
+    left: 50%;
+    width: 50px;
+    height: 50px;
+    margin-left: -25px;
+    border-radius: 50% 50% 50% 50%;
+    text-align: center;
+    font-size: 1.4em;
+    line-height: 50px;
+    color: #fff;
+    background-color: #999999;
+}
+
+.timeline > li.timeline-inverted > .timeline-panel {
+    float: right;
+}
+
+.timeline > li.timeline-inverted > .timeline-panel:before {
+    right: auto;
+    left: -15px;
+    border-right-width: 15px;
+    border-left-width: 0;
+}
+
+.timeline > li.timeline-inverted > .timeline-panel:after {
+    right: auto;
+    left: -14px;
+    border-right-width: 14px;
+    border-left-width: 0;
+}
+
+.timeline-badge.primary {
+    background-color: #2e6da4 !important;
+}
+
+.timeline-badge.success {
+    background-color: #3f903f !important;
+}
+
+.timeline-badge.warning {
+    background-color: #f0ad4e !important;
+}
+
+.timeline-badge.danger {
+    background-color: #d9534f !important;
+}
+
+.timeline-badge.info {
+    background-color: #5bc0de !important;
+}
+
+.timeline-title {
+    margin-top: 0;
+    color: inherit;
+}
+
+.timeline-body > p,
+.timeline-body > ul {
+    margin-bottom: 0;
+}
+
+.timeline-body > p + p {
+    margin-top: 5px;
+}
+
+@media(max-width:767px) {
+    ul.timeline:before {
+        left: 40px;
+    }
+
+    ul.timeline > li > .timeline-panel {
+        width: calc(100% - 90px);
+        width: -moz-calc(100% - 90px);
+        width: -webkit-calc(100% - 90px);
+    }
+
+    ul.timeline > li > .timeline-badge {
+        top: 16px;
+        left: 15px;
+        margin-left: 0;
+    }
+
+    ul.timeline > li > .timeline-panel {
+        float: right;
+    }
+
+    ul.timeline > li > .timeline-panel:before {
+        right: auto;
+        left: -15px;
+        border-right-width: 15px;
+        border-left-width: 0;
+    }
+
+    ul.timeline > li > .timeline-panel:after {
+        right: auto;
+        left: -14px;
+        border-right-width: 14px;
+        border-left-width: 0;
+    }
+}

+ 26 - 0
admin/index.php

@@ -0,0 +1,26 @@
+<?php
+	require_once('app.php');
+?>
+<!DOCTYPE html>
+<html>
+<?php include 'pageparts/head.php'; ?>
+<body>
+	<?php
+		if (isset($_SESSION['user'])) {
+			include 'pageparts/sidemenu.php';
+			echo '<div id="page-wrapper">';
+			echo '<div class="alert-wrapper">';
+			list_messages();
+			echo '</div>';
+
+			if(isset($_GET['p']))
+				include "pages/" . $_GET['p'] . ".php";
+			else
+				include "pages/dashboard.php";
+			echo '</div>';
+		} else {
+			header("Location: https://login.tankernn.eu?redirect=https://tankernn.eu/admin");
+		}
+	?>
+	</body>
+</html>

+ 22 - 0
admin/pageparts/head.php

@@ -0,0 +1,22 @@
+<head>
+<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
+<?php
+foreach (glob("css/*.css") as $filename)
+     echo "<link rel='Stylesheet' type='text/css' href='$filename'/>";
+?>
+<link rel="shortcut icon" href="favicon.ico"/>
+<meta charset='utf-8'/>
+<script type="text/javascript" src="https://code.jquery.com/jquery-latest.min.js"></script>
+<script type="text/javascript" src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
+<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.min.js" integrity="sha256-VazP97ZCwtekAsvgPBSUwPFKdrwD3unUfSGVYrahUqU=" crossorigin="anonymous"></script>
+<script src="https://cdn.jsdelivr.net/npm/metismenu@2.7.4/dist/metisMenu.min.js"></script>
+<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
+<?php
+//Import scripts
+foreach (glob("scripts/*.js") as $filename)
+{
+  echo "<script src='$filename'></script>";
+}
+?>
+<title><?php echo Config::$sitename ?> - Administration</title>
+</head>

+ 44 - 0
admin/pageparts/sidemenu.php

@@ -0,0 +1,44 @@
+<nav class="navbar navbar-default navbar-static-top" role="navigation" style="margin-bottom: 0">
+  <div class="navbar-header">
+      <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
+          <span class="sr-only">Toggle navigation</span>
+          <span class="icon-bar"></span>
+          <span class="icon-bar"></span>
+          <span class="icon-bar"></span>
+      </button>
+      <a class="navbar-brand" href="index.php">Tankernn Administration</a>
+  </div>
+
+  <ul class="nav navbar-top-links navbar-right">
+    <li class="dropdown">
+      <a aria-expanded="false" class="dropdown-toggle" data-toggle="dropdown" href="#">
+        <i class="fa fa-user fa-fw"></i>  <i class="fa fa-caret-down"></i>
+      </a>
+      <ul class="dropdown-menu dropdown-user">
+        <li><a href="?p=account_settings"><i class="fa fa-cog"></i> Account Settings</a></li>
+        <li class="divider"></li>
+        <li><a href="http://login.tankernn.eu/logout.php"><i class="fa fa-sign-out fa-fw"></i> Logout</a></li>
+      </ul>
+    </li>
+  </ul>
+
+  <div class="navbar-default sidebar" role="navigation">
+    <div class="sidebar-nav navbar-collapse">
+      <ul id="side-menu" class="nav in">
+        <li><a href="?p=dashboard"><i class="fa fa-dashboard"></i> Dashboard</a></li>
+        <li <?php if ($_GET['p'] === "list") echo "class='active'"; ?>>
+            <a href="#"><i class="fa fa-edit"></i> Edit<span class="fa arrow"></span></a>
+            <ul class="nav nav-second-level collapse">
+              <li><a href="?p=list&type=Menu"><i class="fa fa-bars"></i> Edit Menu</a></li>
+              <li><a href="?p=list&type=Component"><i class="fa fa-puzzle-piece"></i> Edit Component</a></li>
+              <li><a href="?p=list&type=Page"><i class="fa fa-file"></i> Edit Pages</a></li>
+              <li><a href="?p=list&type=Section"><i class="fa fa-file-code-o"></i> Edit Sections</a></li>
+              <li><a href="?p=list&type=Users"><i class="fa fa-user"></i> Edit User Permissions</a></li>
+            </ul>
+            <!-- /.nav-second-level -->
+        </li>
+        <li><a href="?p=edit&type=CSS"><i class="fa fa-file-text"></i> Edit CSS</a></li>
+      </ul>
+    </div>
+  </div>
+</nav>

+ 58 - 0
admin/pages/account_settings.php

@@ -0,0 +1,58 @@
+<?php
+if (!isset($_SESSION['user'])) {
+  die("Not logged in");
+}
+?>
+
+<div class="row">
+	<div class="col-lg-12">
+      <h1 class="page-header">Account Settings</h1>
+  </div>
+  <!-- /.col-lg-12 -->
+</div>
+<div class="row">
+  <div class="col-lg-6">
+    <div class="panel panel-default">
+    	<div class="panel-heading"><i class="fa fa-lock"></i> Change password</div>
+      <form action="actions/edit_user.php" method="post">
+      	<div class="panel-body">
+            <div class="input-group">
+          		<span class="input-group-addon" id="old-addon">Old password</span>
+          		<input name="oldPass" type="password" class="form-control" placeholder="Your current password" aria-describedby="old-addon">
+          	</div>
+            <div class="input-group">
+          		<span class="input-group-addon" id="new-addon">New password</span>
+          		<input name="newPass" type="password" class="form-control" placeholder="Your desired new password" aria-describedby="new-addon">
+          	</div>
+            <div class="input-group">
+          		<span class="input-group-addon" id="repeat-new-addon">Repeat new password</span>
+          		<input name="repeatNewPass" type="password" class="form-control" placeholder="Repeat your new password" aria-describedby="repeat-new-addon">
+          	</div>
+        </div>
+        <div class="panel-footer"><input class="btn btn-primary" type="submit"/></div>
+      </form>
+    </div>
+  </div>
+  <!-- /.col-lg-6 -->
+  <div class="col-lg-6">
+    <div class="panel panel-default">
+      <div class="panel-heading"><i class="fa fa-envelope"></i> Change E-mail</div>
+      <form action="actions/edit_user.php" method="post">
+        <div class="panel-body">
+            <div class="input-group">
+              <span class="input-group-addon" id="mail-addon">New E-mail address</span>
+              <input name="email" type="email" class="form-control" placeholder="Your new E-mail" aria-describedby="mail-addon">
+            </div>
+            <div class="input-group">
+              <span class="input-group-addon" id="repeat-mail-addon">Repeat new E-mail</span>
+              <input name="repeatEmail" type="email" class="form-control" placeholder="Repeat your new Email" aria-describedby="repeat-mail-addon">
+            </div>
+        </div>
+        <div class="panel-footer">
+          <input class="btn btn-primary" type="submit"/>
+        </div>
+      </form>
+    </div>
+  </div>
+  <!-- /.col-lg-6 -->
+</div>

+ 14 - 0
admin/pages/dashboard.php

@@ -0,0 +1,14 @@
+<div class="row">
+	<div class="col-lg-12">
+		<h1 class="page-header">Dashboard</h1>
+	</div>
+</div>
+
+<div class="row">
+	<div class="col-lg-12">
+		<div class="panel panel-default">
+			<div class="panel-heading">Dashboard panel</div>
+			<div class="panel-body">Content will go here, maybe.</div>
+		</div>
+	</div>
+</div>

+ 266 - 0
admin/pages/edit.php

@@ -0,0 +1,266 @@
+<?php
+	$type = "";
+	$uid = "";
+	if (isset($_GET['uid'])) {
+		$uid = $_GET['uid'];
+	}
+	if (isset($_GET['type'])) {
+		$type = $_GET['type'];
+	} else {
+		die("Missing arguments.");
+	}
+
+	if (!hasPermission("edit.$type")) {
+		die("Not enough permissions.");
+	}
+
+	//Save to database script:
+
+	if (isset($_POST['name']) and $type !== "CSS") {
+		$name = addslashes($_POST['name']);
+		$uid = $_POST['uid'];
+		$sql = "";
+
+		if (isset($_POST['content']) and ($type === "Section" or $type === "Component")) {
+			$content = addslashes($_POST['content']);
+			$sql = "UPDATE $type SET name='$name', content='$content' WHERE UID='$uid'";
+
+		} else if (isset($_POST['sections']) and $type === "Page") {
+			$css = $_POST['css'];
+			$sections = $_POST['sections'];
+			$sql = "UPDATE Page SET name='$name', sections='$sections', CSS='$css' WHERE UID='$uid'";
+		} else if ($type === "Menu") {
+			$value = addslashes($_POST['value']);
+			$valuetype = $_POST['type'];
+
+			$sql = "UPDATE Menu SET name='$name', valuetype='$valuetype', value='$value' WHERE UID='$uid'";
+		}
+
+		if ($conn->query($sql)) {
+			echo "<script>display_message('Successfully saved $type.')</script>";
+		} else {
+			echo "<script>display_message('Something broke: $conn->error', 'danger')</script>";
+		}
+	} else if (isset($_POST['css'])) {
+		$file = fopen("../stylesheets/StyleSheet.css", "w");
+		fwrite($file, $_POST['css']);
+		fclose($file);
+	}
+
+	//View building script:
+
+	if ($type !== "CSS") {
+		$query = $conn->query("SELECT * FROM $type WHERE UID='$uid'");
+		$row = $query->fetch_array();
+		$name = isset($row['name']) ? $row['name'] : $row['User'];
+	}
+
+	$inputs = array();
+	switch ($type) {
+		case "Section":
+		case "Component":
+			$content = $row['content'];
+			$inputs = array("<label>Section content:</label> <br /> <textarea id='code' name='content'>$content</textarea><div id='editor' style='height: 500px; width: 100%;'></div>");
+			break;
+		case "Page":
+			$sections = $row['sections'];
+			$css = $row['CSS'];
+			$inputs = array(
+				"<div class='input-group'><span class='input-group-addon' id='section-addon'>Page setions</span><input class='form-control' type='text' readonly id='sections' name='sections' value='$sections' aria-describedby='section-addon' data-toggle='tooltip' title='Drag the sections around in the preview to change the order. Use the dropdown below to add sections.'/><div class='input-group-btn'><button class='btn btn-primary' id='clean-json' type='button'>Cleanup JSON <span class='fa fa-code'></span></button></div></div>",
+				"<div class='input-group'><span class='input-group-addon' id='add-section-addon'>Add section</span><select class='form-control' id='sectionselect' name='sectionselect' aria-describedby='add-section-addon'/></select><div class='input-group-btn'><button class='btn btn-primary' id='add-section' type='button'>Add <span class='fa fa-plus'></span></button></div></div>",
+				"<label>Custom CSS:</label> <br /> <textarea id='code' name='css'>$css</textarea><div id='editor' style='height: 500px; width: 100%;'></div>"
+			);
+			break;
+		case "CSS":
+			$name = "StyleSheet.css";
+			$filename = "../stylesheets/$name";
+			$readfile = fopen($filename, "r");
+			$css = fread($readfile, filesize($filename));
+			$inputs = array(
+				"<label>CSS:</label> <br /> <textarea id='code' name='css'>$css</textarea><div id='editor' style='height: 500px; width: 100%;'></div>"
+			);
+			break;
+		case "Menu":
+			$itemtype = $row['valuetype'];
+			$isPage = ""; $isLink = "";
+
+			if ($itemtype == "page") {
+				$isPage = "selected";
+			} else {
+				$isLink = "selected";
+			}
+
+			$page_options = "";
+			$pagequery = $conn->query("SELECT * FROM Page ORDER BY ListId");
+			while ($pagerow = $pagequery->fetch_array()) {
+				$page_name = $pagerow['name'];
+				$page_selected = "";
+				if ($row['value'] == $page_name) {
+					$page_selected = "selected";
+				}
+				$page_options .= "<option value='$page_name' $page_selected>$page_name</option>";
+			}
+
+			$menu_value = $row['value'];
+
+			$inputs = array("<div class='input-group'><span class='input-group-addon' id='type-addon'>Menuitem type:</span>
+								<select class='form-control' name='type' id='typeselect' aria-describedby='type-addon'>
+									<option value='page' $isPage>Page</option>
+									<option value='link' $isLink>Link</option>
+								</select></div>",
+								"<div class='input-group' id='pageselect'><span class='input-group-addon' id='value-addon'>Value:</span>
+								<select class='form-control' name='value' aria-describedby='value-addon'>
+									$page_options
+								</select></div>" .
+								"<div class='input-group' id='linkselect'><span class='input-group-addon' id='link-addon'>Link:</span><input class='form-control' name='value' type='text' value='$menu_value'/></div>",
+								"<script>updateSelect();</script>");
+			break;
+		case "Users":
+			ob_start();
+			include "pages/edit/user.php";
+			$inputs = array(ob_get_clean());
+			break;
+	}
+?>
+
+<div class="row">
+	<div class="col-lg-12">
+      <h1 class="page-header"><?php echo "Edit $type"; ?></h1>
+  </div>
+  <!-- /.col-lg-12 -->
+</div>
+<div class="row">
+	<div class="col-lg-6">
+		<form action="" method="POST">
+			<input name="uid" type="hidden" value="<?php echo $uid; ?>"/>
+			<div class="input-group"><span class="input-group-addon" id="name-addon"><?php echo $type; ?> name:</span><input class="form-control" aria-describedby="name-addon" name="name" type="text" value="<?php echo $name ?>"/></div> <br />
+			<?php
+				foreach ($inputs as $input) {
+					echo $input . "<br />";
+				}
+				?>
+		<button class="btn btn-lg btn-primary" style="float: left;" type="submit"><i class="fa fa-floppy-o"></i> Save</button>
+		</form>
+	</div>
+	<!-- /.col-lg-6 -->
+	<div class="col-lg-6">
+		<?php
+		if (isset($row['CSS']))
+			echo "<style>".$row['CSS']."</style>";
+
+		echo "<div id='preview' class='$type'>";
+		if ($type === "Page") {
+			$sections = json_decode($row['sections']);
+			if ($sections === NULL)
+				$sections = explode(',', $row['sections']);
+
+			$app = new App(true);
+			foreach ($sections as $section) {
+				$app->addSection($section);
+			}
+		} else if ($type === "Section") {
+			echo $row['content'];
+		}
+		echo '</div>';
+		?>
+	</div>
+	<!-- /.col-lg-6 -->
+</div>
+
+<script src='https://cdnjs.cloudflare.com/ajax/libs/ace/1.3.1/ace.js'></script>
+<script src='https://cdnjs.cloudflare.com/ajax/libs/ace/1.3.1/mode-html.js'></script>
+<script src='https://cdnjs.cloudflare.com/ajax/libs/ace/1.3.1/mode-css.js'></script>
+<script src='https://cdnjs.cloudflare.com/ajax/libs/ace/1.3.1/theme-monokai.js'></script>
+
+<script>
+	var code = $("#code").hide();
+	var editor = ace.edit("editor");
+	editor.setTheme("ace/theme/monokai");
+	editor.getSession().setMode("ace/mode/html");
+	if (code.prop('name') === "css") {
+		editor.getSession().setMode("ace/mode/css");
+	}
+	editor.getSession().setValue(code.val());
+	editor.getSession().on('change', function() {
+		code.val(editor.getSession().getValue());
+		refreshPreview(editor.getSession().getValue());
+	});
+
+	function makeSortable() {
+		$("#preview").sortable({ opacity: 0.6, cursor: 'move', update: function() {
+			var order = $(this).sortable("toArray");
+			$("#sections").val(JSON.stringify(order));
+		}}).disableSelection();
+	}
+
+	function refreshPreview(str) {
+		var preview = $("#preview");
+		if (preview.hasClass("Section")) {
+			$("#preview").html(str);
+		} else if (preview.hasClass("Page")) {
+			$.get( "actions/get_sections.php", { sections: $("#sections").val() } )
+			.done(function( data ) {
+				$("#preview").html(data);
+			});
+		}
+	}
+
+	function updateSelectBox() {
+		$.get( "actions/get_sections.php", { listall: true } )
+		.done(function(data) {
+			var allsections = JSON.parse(data);
+
+			var usedsections = JSON.parse($("#sections").val());
+
+			usedsections.forEach( function (element, index, array) {
+				delete allsections[element];
+			});
+
+			var selectBox = $('#sectionselect');
+			selectBox.empty();
+			$.each(allsections, function(key, value) {
+     		selectBox
+         .append($("<option></option>")
+                    .attr("value",key)
+                    .text(value));
+			});
+		});
+	}
+
+	$(document).ready(function() {
+		if ($("#preview").attr('class') == "Page") {
+			makeSortable();
+			updateSelectBox();
+		}
+		$("#add-section").click(function() {
+			var sections = JSON.parse($("#sections").val());
+			sections.push($("#sectionselect").val());
+			sections = sections.map(function (uid) {
+				return parseInt(uid);
+			});
+			$("#sections").val(JSON.stringify(sections));
+			refreshPreview();
+			updateSelectBox();
+		});
+
+		$("#clean-json").click(function () {
+			var sectionsString = $("#sections").val();
+			var sections;
+			try {
+				sections = JSON.parse(sectionsString);
+				sections = sections.map(function (uid) {
+					return parseInt(uid);
+				});
+				$("#sections").val(JSON.stringify(sections));
+			} catch (e) {
+				sections = sectionsString.split(",");
+				$.get( "actions/get_sections.php", { getids: JSON.stringify(sections) } )
+				.done(function( data ) {
+					console.log(data);
+					$("#sections").val(data);
+				});
+			}
+		});
+	});
+
+</script>

+ 66 - 0
admin/pages/edit/user.php

@@ -0,0 +1,66 @@
+<?php
+  $permissions = json_decode($row['Permissions']);
+
+  $available = array("edit.Page", "edit.Users", "edit.Section", "edit.Menu", "edit.CSS",
+                      "new.Page", "new.Users", "new.Section", "new.Menu",
+                      "delete.Page", "delete.Users", "delete.Section", "delete.Menu",
+                      "list.Page", "list.Users", "list.Section", "list.Menu", "rsps");
+  $forbidden = array_diff($available, $permissions->custom_permissions);
+
+?>
+
+Permission level: <input id="level" value="<?php echo $permissions->permission_level ?>">
+
+<br />
+
+<div class="sort permlist" id="forbid">
+  <h3>Forbidden</h3>
+  <ul class="permlist">
+    <?php
+      foreach ($forbidden as $permission) {
+        echo "<li id='$permission'>$permission</li>";
+      }
+    ?>
+  </ul>
+</div>
+<div class="sort" id="allow">
+  <h3>Allowed</h3>
+  <ul class="permlist">
+    <?php
+      foreach ($permissions->custom_permissions as $permission) {
+        echo "<li id='$permission'>$permission</li>";
+      }
+    ?>
+  </ul>
+</div>
+
+<script>
+function updatePermissions() {
+  var allowed = $('#allow ul').sortable("toArray");
+
+  console.log($("#level").val());
+
+  $.post("actions/updatePermissions.php?uid=<?php echo $uid ?>", {level: $("#level").val(), custom: JSON.stringify(allowed)}, function(theResponse){
+    display_message(theResponse);
+  });
+}
+
+$(document).ready(function() {
+  $('div.sort li').disableSelection();
+
+  $('#forbid ul').sortable({
+      revert: 'invalid',
+      connectWith: "#allow ul",
+      cursor: 'move'
+  });
+
+  $('#allow ul').sortable({
+      revert: 'invalid',
+      connectWith: "#forbid ul",
+      cursor: 'move',
+      update: updatePermissions
+  });
+
+  $('#level').spinner().change(updatePermissions);
+});
+</script>

+ 78 - 0
admin/pages/list.php

@@ -0,0 +1,78 @@
+<?php
+	if (!hasPermission("list")) {
+		die("Not enough permissions.");
+	}
+
+	$type = "";
+	if (isset($_GET['type']))
+		$type = $_GET['type'];
+	else
+		die("No type specified.");
+?>
+
+<div class="row">
+	<div class="col-lg-12">
+      <h1 class="page-header"><?php echo "List $type"; ?></h1>
+  </div>
+  <!-- /.col-lg-12 -->
+</div>
+
+<form id="new">
+	<div class="input-group">
+		<span class="input-group-addon" id="name-addon">Name</span>
+		<input name="name" id="name" type="text" class="form-control" placeholder="New entry name" aria-describedby="name-addon">
+		<span class="input-group-btn">
+      <button class="btn btn-primary" type="button">Add new entry <span class="fa fa-plus"></span></button>
+    </span>
+	</div>
+</form>
+
+<div class="panel panel-default">
+	<div class="panel-heading">List of entries</div>
+	<div class="panel-body table-panel">
+		<table class="list table table-striped table-bordered table-hover dataTable no-footer"><thead><tr><th>Name</th><th>Actions</th></tr></thead>
+			<tbody>
+
+			</tbody>
+		</table>
+	</div>
+</div>
+
+<script type="text/javascript">
+
+function refreshTable() {
+	$.get("actions/getList.php?type=<?php echo $type ?>", function(data) {
+	 $(".list tbody").html(data);
+	});
+
+	$(".list tbody").sortable({ opacity: 0.6, cursor: 'move', update: function() {
+		var order = $(this).sortable("serialize");
+		$.post("actions/updateListOrder.php?type=<?php echo $type ?>", order, function(theResponse){
+			display_message(theResponse);
+		});
+	}}).disableSelection();
+}
+
+$(document).ready(function(){
+	refreshTable();
+	$(function() {
+		$("#new button").click(function(){
+			$.post("actions/new.php?type=<?php echo $type ?>", $("#new").serialize(), function(theResponse){
+				display_message(theResponse);
+				refreshTable();
+			});
+			refreshTable();
+		});
+		$(".list").on('click', '.delete-confirm', function(){
+			var deleteUID = parseInt($(this).attr("data"), 10);
+			$('#delete-modal-' + deleteUID).modal('hide');
+			$('body').removeClass('modal-open');
+			$('.modal-backdrop').remove();
+			$.get("actions/delete.php?type=<?php echo $type ?>", {uid: deleteUID}, function(theResponse) {
+				display_message(theResponse);
+			});
+			refreshTable();
+		});
+ });
+});
+</script>

+ 73 - 0
admin/scripts/Script.js

@@ -0,0 +1,73 @@
+function display_message(message, type="info") {
+	if ($(".alert-wrapper").is(":empty")) {
+		var flag = true;
+	}
+
+	$(".alert-wrapper").html("<div class='alert'><button type='button' class='close' data-dismiss='alert' aria-label='Close'><span aria-hidden='true'>&times;</span></button>"+message+"</div>");
+	$(".alert").addClass("alert-" + type);
+
+	if (flag) {
+		$(".alert").css('display', 'none');
+	}
+
+	if ($(".alert").css("display") == "none")
+		$(".alert").slideToggle();
+}
+
+var updateSelect = function() {
+	if ($("#typeselect").val() == "page") {
+		$("#linkselect").css("display", "none");
+		$("#linkselect input").attr("name", "inactive");
+		$("#pageselect").css("display", "table");
+		$("#pageselect select").attr("name", "value");
+	} else if ($("#typeselect").val() == "link") {
+		$("#linkselect").css("display", "table");
+		$("#linkselect input").attr("name", "value");
+		$("#pageselect").css("display", "none");
+		$("#pageselect select").attr("name", "inactive");
+	}
+}
+
+$(document).ready(function(){
+	$("#typeselect").change(function(){
+		updateSelect();
+	});
+	$('[data-toggle="tooltip"]').tooltip();
+});
+
+$(function() {
+
+    $('#side-menu').metisMenu();
+
+});
+
+//Loads the correct sidebar on window load,
+//collapses the sidebar on window resize.
+// Sets the min-height of #page-wrapper to window size
+$(function() {
+    $(window).bind("load resize", function() {
+        topOffset = 50;
+        width = (this.window.innerWidth > 0) ? this.window.innerWidth : this.screen.width;
+        if (width < 768) {
+            $('div.navbar-collapse').addClass('collapse');
+            topOffset = 100; // 2-row-menu
+        } else {
+            $('div.navbar-collapse').removeClass('collapse');
+        }
+
+        height = ((this.window.innerHeight > 0) ? this.window.innerHeight : this.screen.height) - 1;
+        height = height - topOffset;
+        if (height < 1) height = 1;
+        if (height > topOffset) {
+            $("#page-wrapper").css("min-height", (height) + "px");
+        }
+    });
+
+    var url = window.location;
+    var element = $('ul.nav a').filter(function() {
+        return this.href == url || url.href.indexOf(this.href) == 0;
+    }).addClass('active').parent().parent().addClass('in').parent();
+    if (element.is('li')) {
+        element.addClass('active');
+    }
+});

+ 30 - 0
index.php

@@ -0,0 +1,30 @@
+<?php
+  require "app.php";
+  $site = new App();
+?>
+
+<!DOCTYPE html>
+<html lang="en" charset="utf-8">
+    <head>
+      <?php
+        echo $site->components['Head'];
+        echo "<style>".$site->pageRow['CSS']."</style>";
+        echo $site->styles;
+        echo "<title>".Config::$sitename."</title>";
+      ?>
+    </head>
+    <body>
+        <?php echo $site->components['Navbar']; ?>
+        <main>
+        	<?php
+            $site->printPage();
+          ?>
+        </main>
+        <footer>
+          <?php echo $site->components['Footer']; ?>
+        </footer>
+        <?php
+          echo $site->scripts;
+        ?>
+    </body>
+</html>

+ 24 - 0
scripts/Script.js

@@ -0,0 +1,24 @@
+function moveMenuSelector(menuItem) {
+	var offset = menuItem.offset();
+
+	$("#menuselector").width(menuItem.width());
+	$("#menuselector").offset(offset);
+
+	$("nav ul li").find("a").css("color", "#337ab7");
+
+	menuItem.find("a").css("color", "white");
+}
+
+$(document).ready(function() {
+	$("#menuselector").height($("#menuselector").parent().height());
+
+	$("nav ul li").mouseenter(function() {
+		moveMenuSelector($(this));
+	});
+
+	$("nav ul li").mouseleave(function() {
+		moveMenuSelector($(".active"));
+	});
+
+	moveMenuSelector($(".active"));
+});

+ 175 - 0
stylesheets/StyleSheet.css

@@ -0,0 +1,175 @@
+/*
+Main CSS file for tankernn.eu
+Backgrund from http://www.facets.la/wallpapers/
+*/
+@font-face {
+  font-family: "Open Sans";
+  src:  url(https://mozorg.cdn.mozilla.net/media/fonts/OpenSans-Regular-webfont.eot?#iefix) format("embedded-opentype"),
+        url(https://mozorg.cdn.mozilla.net/media/fonts/OpenSans-Regular-webfont.woff) format("woff"),
+        url(https://mozorg.cdn.mozilla.net/media/fonts/OpenSans-Regular-webfont.ttf) format("truetype");
+  font-weight: normal;
+  font-style: normal;
+}
+@font-face {
+  font-family: "Open Sans";
+  src:  url(https://mozorg.cdn.mozilla.net/media/fonts/OpenSans-Bold-webfont.eot#iefix) format("embedded-opentype"),
+        url(https://mozorg.cdn.mozilla.net/media/fonts/OpenSans-Bold-webfont.woff) format("woff"),
+        url(https://mozorg.cdn.mozilla.net/media/fonts/OpenSans-Bold-webfont.ttf) format("truetype");
+  font-weight: bold;
+  font-style: normal;
+}
+
+@keyframes goRight {
+  0% {left: -500px}
+  100% {left: 100%}
+}
+
+body {
+  font-family: "Open Sans", sans-serif;
+  font-size: 20px;
+  background-color: #00a4e1;
+  color: #777;
+  border-collapse: collapse;
+}
+
+body * {
+  transition: 0.5s;
+}
+
+main .container {
+  padding-top: 40px;
+  padding-bottom: 40px;
+}
+
+.meta > div > div {
+  background: #FFF;
+  border-radius: 10px;
+  border: 1px solid transparent;
+  padding: 0 20px 20px;
+  margin-bottom: 20px;
+}
+
+/*#### Header styling ####*/
+
+nav {
+  background-color: white;
+  border-bottom: 3px solid #337AB7;
+}
+
+.navbar-toggle .icon-bar {
+  background-color: darkgray;
+}
+
+.login {
+  float: right;
+  padding-top: 5px;
+  padding-right: 10px;
+}
+
+/*#### Menu ####*/
+
+nav ul li:hover a {
+  background-color: transparent !important;
+}
+
+nav ul li a {
+  z-index: 5;
+}
+
+#menuselector {
+  background-color: #337AB7;
+  position: absolute;
+  z-index: 4;
+  display: none;
+}
+
+/*#### Structural Styling ####*/
+
+h1, h2, h3, h4, h5, h6 {
+  color: black;
+}
+
+footer {
+  font-family: Arial, inherit;
+  font-size: 18px;
+  background-color: #393939;
+  color: white;
+  padding-top: 20px;
+  padding-bottom: 20px;
+}
+
+footer a, footer a:hover {
+  color: white;
+}
+
+footer ul li {
+  list-style: none;
+}
+
+/*#### Various Styling ###*/
+
+#snakeCanvas {
+  border: 1px solid black;
+}
+
+.coral {
+  animation: goRight linear 3s 1;
+  position: fixed;
+  left: -500px;
+}
+
+.error {
+  background-color: #D9534F;
+  color: white;
+}
+
+li.L0, li.L1, li.L2, li.L3,
+li.L5, li.L6, li.L7, li.L8
+{ list-style-type: decimal !important }
+
+.prettyprint {
+  background-color: #fdfdfd;
+  font-family: Courier;
+  padding: 2px;
+  border-radius: 5px;
+  white-space: pre-wrap;
+
+  -moz-tab-size:  4;
+  -o-tab-size:  4;
+  tab-size:  4;
+}
+
+.download-button {
+  font-size: 26px;
+  padding: 15px 100px;
+  font-weight: bold;
+  background-color: #0085B7;
+  color: white;
+  transition: 0.5s;
+
+  text-decoration: none;
+
+  margin-top: 5px;
+  margin-bottom: 5px;
+  display: inline-block;
+
+  border: 2px solid #0085B7;
+  border-radius: 10px;
+}
+
+.download-button:hover {
+  background-color: transparent;
+
+  text-decoration: none;
+  color: #0085B7;
+}
+
+@media screen and (min-width: 765px) {
+  .navbar-nav {
+  	float: right;
+  }
+  
+  #menuselector {
+  	display: block;
+  }
+}