This repository has been archived by the owner on May 31, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Luuk van Houdt
committed
Jan 25, 2016
1 parent
5521a2b
commit 5effe19
Showing
21 changed files
with
277 additions
and
143 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
.sass-cache | ||
.idea | ||
connect.php | ||
inc/connect.php |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<div class="block"> | ||
<h1>Beheerders paneel</h1> | ||
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> | ||
<button name="logout" type="submit">Uitloggen</button> | ||
</form> | ||
</div> | ||
<div class="block"> | ||
<h2>Domotica systemen</h2> | ||
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> | ||
<input name="city" type="text" placeholder="Stad" /> | ||
<input name="street" type="text" placeholder="Straat" /> | ||
<input name="house" type="text" placeholder="Huisnummer" /> | ||
<button name="search" type="submit">Zoeken</button> | ||
</form> | ||
<?php | ||
if (isset($_POST['search'])) { | ||
$q = $pdo->prepare('SELECT * | ||
FROM systems | ||
WHERE city LIKE :city AND | ||
street LIKE :street AND | ||
house LIKE :house | ||
'); | ||
$q->execute(array( | ||
':city' => '%'.$_POST['city'].'%', | ||
':street' => '%'.$_POST['street'].'%', | ||
':house' => '%'.$_POST['house'].'%', | ||
)); | ||
$rows = $q->fetchAll(); | ||
} else { | ||
$q = $pdo->prepare('SELECT * FROM systems LIMIT 0,10'); | ||
$q->execute(); | ||
$rows = $q->fetchAll(); | ||
} | ||
if ($rows) : | ||
foreach ($rows as $row) : | ||
?> | ||
<div class="row"> | ||
<span class="status <?php print ($row['status']) ? 'on' : 'off'; ?>"></span> | ||
<span class="city"><?php print $row['city']; ?></span> | ||
<span class="street"><?php print $row['street']; ?></span> | ||
<span class="house"><?php print $row['house']; ?></span> | ||
</div> | ||
<?php | ||
endforeach; | ||
else: | ||
?> | ||
<div class="no-results">Geen domotica systemenen gevonden.</div> | ||
<?php | ||
endif; | ||
?> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<div class="block"> | ||
<h1>Inloggen</h1> | ||
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> | ||
<p> | ||
<input type="text" name="username" placeholder="Gebruikersnaam" /> | ||
</p> | ||
<p> | ||
<input type="password" name="password" placeholder="Wachtwoord" /> | ||
</p> | ||
<p> | ||
<button type="reset">reset</button> | ||
<button name="login" type="submit">login</button> | ||
</p> | ||
</form> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<div class="block"> | ||
<h1>Gebruikerspaneel</h1> | ||
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> | ||
<section class="dotted"> | ||
<ul> | ||
<li><strong>Woonplaats:</strong><span><?php print $_SESSION['system']['city']; ?></span></li> | ||
<li><strong>Straatnaam:</strong><span><?php print $_SESSION['system']['street']; ?></span></li> | ||
<li><strong>Huisnummer:</strong><span><?php print $_SESSION['system']['house']; ?></span></li> | ||
</ul> | ||
</section> | ||
<section class="lights"> | ||
<h2>Verlichting</h2> | ||
<?php | ||
$lights = $_SESSION['system']['lights']; | ||
$lights_class = ($lights==1) ? ' active' : ''; | ||
?> | ||
<div class="switch<?php print $lights_class; ?>"> | ||
<a class="off">uit</a> | ||
<a class="on">aan</a> | ||
<input name="lights" type="hidden" value="<?php print $lights; ?>" /> | ||
</div> | ||
</section> | ||
<section class="camera"> | ||
<h2>Camera</h2> | ||
<?php | ||
$camera = $_SESSION['system']['camera']; | ||
$camera_class = ($camera==1) ? ' active' : ''; | ||
?> | ||
<div class="switch<?php print $camera_class; ?>"> | ||
<a class="off">uit</a> | ||
<a class="on">aan</a> | ||
<input name="camera" type="hidden" value="<?php print $camera; ?>" /> | ||
</div> | ||
</section> | ||
<button name="logout" type="submit">Uitloggen</button> | ||
<button name="save" type="submit">Opslaan</button> | ||
</form> | ||
</div> |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
session_start(); | ||
|
||
include 'connect.php'; | ||
|
||
if (isset($_POST['login'])) { | ||
if (!empty($_POST['username']) and !empty($_POST['password'])) { | ||
$q = $pdo->prepare('SELECT user_id, username, role FROM users WHERE username = :user AND password = :pass'); | ||
$q->execute(array( | ||
':user' => $_POST['username'], | ||
':pass' => md5($_POST['password']), | ||
)); | ||
$r = $q->fetch(); | ||
|
||
if ($r) { | ||
// Logged in successfully | ||
$_SESSION['user'] = $r; | ||
if ($r['role'] == 0) { | ||
$q = $pdo->prepare('SELECT * FROM systems WHERE user_id = :id'); | ||
$q->execute(array(':id' => $r['user_id'])); | ||
$r = $q->fetch(); | ||
if ($r) { | ||
// Open user panel | ||
$_SESSION['system'] = $r; | ||
header('Location: '.$_SERVER['PHP_SELF']); | ||
} else { | ||
$error = 'U account is niet gekoppeld aan een domotica systeem.'; | ||
} | ||
} else { | ||
// Open admin panel | ||
header('Location: '.$_SERVER['PHP_SELF']); | ||
} | ||
} else { | ||
$error = 'Verkeerde gebruikersnaam of wachtwoord.'; | ||
} | ||
} else { | ||
$error = 'Gebruikersnaam of wachtwoord is niet ingevuld.'; | ||
} | ||
} | ||
|
||
if (isset($_POST['logout'])) { | ||
session_destroy(); | ||
header('Location: '.$_SERVER['PHP_SELF']); | ||
} | ||
|
||
if (isset($_POST['save'])) { | ||
var_dump($_POST); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
require ABSPATH.'inc/functions.php'; | ||
?> | ||
<html> | ||
<head> | ||
<title>Alpha Domotica</title> | ||
<link rel="stylesheet" type="text/css" href="css/main.css" /> | ||
<script type="text/javascript" src="js/jquery.min.js"></script> | ||
<script type="text/javascript" src="js/main.js"></script> | ||
</head> | ||
<body> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,25 @@ | ||
<?php | ||
require 'functions.php'; | ||
require_once('header.php'); | ||
|
||
define('ABSPATH', getcwd().'/'); | ||
|
||
?> | ||
<div class="block"> | ||
<h1>Inloggen</h1> | ||
<form action="" method="post"> | ||
<input type="text" name="username" /> | ||
<button type="reset">reset</button> | ||
</form> | ||
<form action="" method="post"> | ||
<input type="password" name="password"/> | ||
<button type="submit">login</button> | ||
</form> | ||
</div> | ||
require_once(ABSPATH.'inc/header.php'); | ||
|
||
|
||
// Check if the user made an error | ||
if (!empty($error)) { | ||
print '<div class="status error">'.$error.'</div>'; | ||
} | ||
|
||
<?php | ||
require_once('footer.php'); | ||
// Check if the user is logged in | ||
if (isset($_SESSION['user'])) { | ||
// Check if the user is an admin | ||
if ($_SESSION['user']['role'] == 1) { | ||
include_once(ABSPATH.'html/admin.php'); | ||
} else { | ||
include_once(ABSPATH.'html/user.php'); | ||
} | ||
} else { | ||
include_once(ABSPATH.'html/login.php'); | ||
} | ||
|
||
require_once(ABSPATH.'inc/footer.php'); |
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.