2018-11-27 18:56:59 +01:00
|
|
|
<?php
|
|
|
|
session_start();
|
2018-12-30 17:26:18 +01:00
|
|
|
?>
|
2018-12-30 23:53:11 +01:00
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
2018-12-30 17:32:07 +01:00
|
|
|
<title>ToDoList</title>
|
2018-12-30 17:26:18 +01:00
|
|
|
<link rel="stylesheet" type="text/css" href="style.css">
|
2018-12-30 23:53:11 +01:00
|
|
|
<style>
|
|
|
|
.header {
|
|
|
|
overflow: hidden;
|
|
|
|
background-color: #000;
|
|
|
|
padding: 20px 10px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.header a {
|
|
|
|
float: left;
|
|
|
|
color: #ddd;
|
|
|
|
text-align: center;
|
|
|
|
padding: 12px;
|
|
|
|
text-decoration: none;
|
|
|
|
font-size: 18px;
|
|
|
|
line-height: 25px;
|
|
|
|
border-radius: 4px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.header a.logo {
|
|
|
|
font-size: 25px;
|
|
|
|
font-weight: bold;
|
|
|
|
}
|
|
|
|
|
|
|
|
.header a:hover {
|
|
|
|
background-color: #ddd;
|
|
|
|
color: black;
|
|
|
|
}
|
|
|
|
|
|
|
|
.header a.active {
|
|
|
|
background-color: #fb2525;
|
|
|
|
color: white;
|
|
|
|
}
|
|
|
|
|
|
|
|
.header a.active:hover {
|
|
|
|
cursor: pointer;
|
|
|
|
background: #ffc107;
|
|
|
|
color: #000;
|
|
|
|
}
|
|
|
|
|
|
|
|
.header-right {
|
|
|
|
float: right;
|
|
|
|
}
|
|
|
|
|
|
|
|
.addform {
|
|
|
|
overflow: hidden;
|
|
|
|
background-color: black;
|
|
|
|
padding: 0px 10px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.addform input {
|
|
|
|
width: 100%;
|
|
|
|
margin-bottom: 20px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.addform input[type="text"] {
|
|
|
|
border: none;
|
|
|
|
border-bottom: 1px solid #fff;
|
|
|
|
background: transparent;
|
|
|
|
outline: none;
|
|
|
|
height: 40px;
|
|
|
|
color: #fff;
|
|
|
|
font-size: 16px;
|
|
|
|
text-align: center;
|
|
|
|
}
|
|
|
|
|
|
|
|
.addform input[type="submit"] {
|
|
|
|
border: none;
|
|
|
|
outline: none;
|
|
|
|
height: 40px;
|
|
|
|
background: #fb2525;
|
|
|
|
color: #fff;
|
|
|
|
font-size: 18px;
|
|
|
|
border-radius: 20px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.addform input[type="submit"]:hover {
|
|
|
|
cursor: pointer;
|
|
|
|
background: #ffc107;
|
|
|
|
color: #000;
|
|
|
|
}
|
|
|
|
|
|
|
|
.done-button {
|
|
|
|
display: inline-block;
|
|
|
|
font-size: 0.8em;
|
|
|
|
background-color: #d9dfe1;
|
|
|
|
color: #363639;
|
|
|
|
padding: 2px 4px;
|
|
|
|
border: 0;
|
|
|
|
opacity: 0.4;
|
|
|
|
}
|
|
|
|
|
|
|
|
.delete-button {
|
|
|
|
display: inline-block;
|
|
|
|
font-size: 0.8em;
|
|
|
|
background-color: #FF6666;
|
|
|
|
color: #CC0000;
|
|
|
|
padding: 2px 4px;
|
|
|
|
border: 0;
|
|
|
|
opacity: 0.4;
|
|
|
|
}
|
|
|
|
|
|
|
|
.todo {
|
|
|
|
left: 10%;
|
|
|
|
position: absolute;
|
|
|
|
background-color: #fff;
|
|
|
|
margin: 20px auto;
|
|
|
|
width: 100%;
|
|
|
|
max-width: 500px;
|
|
|
|
padding: 20px;
|
|
|
|
border-radius: 4px;
|
|
|
|
box-shadow: 3px 3px 0 rgba(0, 0, 0, .1);
|
|
|
|
box-sizing: border-box;
|
|
|
|
}
|
|
|
|
|
|
|
|
.done {
|
|
|
|
right: 10%;
|
|
|
|
position: absolute;
|
|
|
|
background-color: #fff;
|
|
|
|
margin: 20px auto;
|
|
|
|
width: 100%;
|
|
|
|
max-width: 500px;
|
|
|
|
padding: 20px;
|
|
|
|
border-radius: 4px;
|
|
|
|
box-shadow: 3px 3px 0 rgba(0, 0, 0, .1);
|
|
|
|
box-sizing: border-box;
|
|
|
|
}
|
|
|
|
|
|
|
|
.tasks {
|
|
|
|
margin:0;
|
|
|
|
padding0;
|
|
|
|
list-style-type: none;
|
|
|
|
}
|
|
|
|
|
|
|
|
.tasks li {
|
|
|
|
border:0;
|
|
|
|
border-bottom:1px dashed #ccc;
|
|
|
|
padding: 15px 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
@media screen and (max-width: 999px) {
|
|
|
|
.todo {
|
|
|
|
position: relative;
|
|
|
|
left: 0.5%;
|
|
|
|
top: 5%;
|
|
|
|
background-color: #fff;
|
|
|
|
margin: auto;
|
|
|
|
width: 90%;
|
|
|
|
max-width: 500px;
|
|
|
|
padding: 20px;
|
|
|
|
border-radius: 4px;
|
|
|
|
box-shadow: 3px 3px 0 rgba(0, 0, 0, .1);
|
|
|
|
box-sizing: border-box;
|
|
|
|
}
|
|
|
|
|
|
|
|
.done {
|
|
|
|
position: relative;
|
|
|
|
left: 0.5%;
|
|
|
|
top: 5%;
|
|
|
|
background-color: #fff;
|
|
|
|
margin: 20px auto;
|
|
|
|
width: 90%;
|
|
|
|
max-width: 500px;
|
|
|
|
padding: 20px;
|
|
|
|
border-radius: 4px;
|
|
|
|
box-shadow: 3px 3px 0 rgba(0, 0, 0, .1);
|
|
|
|
box-sizing: border-box;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
</head>
|
2018-12-30 17:26:18 +01:00
|
|
|
<?php
|
|
|
|
|
2018-12-30 01:29:37 +01:00
|
|
|
include 'sql/db_login.php';
|
2018-12-28 20:12:00 +01:00
|
|
|
|
2018-11-27 18:56:59 +01:00
|
|
|
mysql_connect("$db_servername", "$db_login", "$db_password");
|
|
|
|
mysql_select_db("$db_name");
|
|
|
|
|
2018-12-28 20:12:00 +01:00
|
|
|
$db = mysqli_connect("$db_servername", "$db_login_tasks", "$db_password_tasks", "$db_name_tasks");
|
|
|
|
|
2018-11-27 18:56:59 +01:00
|
|
|
function filter($variable)
|
|
|
|
{
|
|
|
|
if(get_magic_quotes_gpc())
|
|
|
|
$variable = stripslashes($variable);
|
|
|
|
|
|
|
|
return mysql_real_escape_string(htmlspecialchars(trim($variable)));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isset($_GET['wyloguj'])==1)
|
|
|
|
{
|
|
|
|
$_SESSION['zalogowany'] = false;
|
|
|
|
session_destroy();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isset($_POST['loguj']))
|
|
|
|
{
|
2018-12-28 20:57:43 +01:00
|
|
|
$login = filter($_POST['login']);
|
|
|
|
$password = filter($_POST['password']);
|
2018-11-27 18:56:59 +01:00
|
|
|
if (mysql_num_rows(mysql_query("SELECT * FROM `users` WHERE `user_login`='$login' && `user_pass`='$password' && `aktywne`='1'")) > 0)
|
|
|
|
{
|
|
|
|
$_SESSION['zalogowany'] = true;
|
2018-12-28 20:23:07 +01:00
|
|
|
$_SESSION['login'] = strtolower($login);
|
2018-11-27 18:56:59 +01:00
|
|
|
}
|
2018-12-30 20:52:52 +01:00
|
|
|
else if (mysql_num_rows(mysql_query("SELECT * FROM `users` WHERE `user_login`='$login' && `user_pass`='$password' && `aktywne`='0'")) > 0)
|
|
|
|
{ $error = "Konto nieaktywne.";}
|
|
|
|
else { $error = "Zły login lub hasło"; }
|
2018-11-27 18:56:59 +01:00
|
|
|
}
|
|
|
|
|
2018-12-30 23:53:11 +01:00
|
|
|
|
2018-11-27 18:56:59 +01:00
|
|
|
if ($_SESSION['zalogowany']==true)
|
|
|
|
{
|
2018-12-28 20:57:43 +01:00
|
|
|
?>
|
2018-12-28 20:12:00 +01:00
|
|
|
|
2018-12-30 23:53:11 +01:00
|
|
|
<div class="header">
|
|
|
|
|
|
|
|
<a class="logo">ToDoList</a>
|
|
|
|
<div class="header-right">
|
|
|
|
<a>Zalogowano jako <b><?php echo $_SESSION['login']; ?></b></a>
|
|
|
|
<a class="active" href="?wyloguj=1">Wyloguj</a>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="addform">
|
|
|
|
<form method="POST" action="add.php">
|
|
|
|
<input type="text" name="task" class="task_input" placeholder="Nowe zadanie" required>
|
|
|
|
<input type="submit" value="Dodaj" name="submit">
|
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
2018-12-28 20:12:00 +01:00
|
|
|
<?php
|
2018-12-30 23:53:11 +01:00
|
|
|
|
2018-12-28 20:12:00 +01:00
|
|
|
$login = $_SESSION['login'];
|
2018-12-30 23:53:11 +01:00
|
|
|
|
2018-12-30 01:32:43 +01:00
|
|
|
$query = "SELECT * FROM `tasks_$login` WHERE done = 0";
|
|
|
|
$tasks = mysqli_query($db, $query);
|
|
|
|
|
|
|
|
$query_done = "SELECT * FROM `tasks_$login` WHERE done = 1";
|
|
|
|
$tasks_done = mysqli_query($db, $query_done);
|
2018-12-30 23:53:11 +01:00
|
|
|
|
2018-12-28 20:12:00 +01:00
|
|
|
?>
|
2018-12-30 01:32:43 +01:00
|
|
|
|
2018-12-30 23:53:11 +01:00
|
|
|
<div class="todo">
|
|
|
|
<h4 class="todo-header">Do zrobienia</h4>
|
|
|
|
<ul class="tasks">
|
|
|
|
<?php while ($row = mysqli_fetch_array($tasks)) { ?>
|
|
|
|
<li> <span class="task"><?php echo $row['task']; ?>
|
|
|
|
<a class="done-button" href="mark.php?mark_task=<?php echo $row['ID'];?>">Zrobione</a>
|
|
|
|
<a class="delete-button" href="delete.php?del_task=<?php echo $row['ID'];?>">Usuń</a>
|
|
|
|
</span> </li>
|
|
|
|
<?php } ?>
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="done">
|
|
|
|
<h4 class="todo-header">Zrobione</h4>
|
|
|
|
<ul class="tasks">
|
2018-12-30 02:09:12 +01:00
|
|
|
<?php $i=1; while ($row = mysqli_fetch_array($tasks_done)) { ?>
|
2018-12-30 23:53:11 +01:00
|
|
|
<li> <span class="task"><?php echo $row['task']; ?>
|
|
|
|
<a class="delete-button" href="delete.php?del_task=<?php echo $row['ID'];?>">Usuń</a>
|
|
|
|
</span> </li>
|
|
|
|
<?php } ?>
|
|
|
|
</ul>
|
2018-12-28 20:12:00 +01:00
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
|
2018-12-30 23:53:11 +01:00
|
|
|
</div>
|
|
|
|
|
2018-12-28 20:12:00 +01:00
|
|
|
<?php
|
2018-11-27 18:56:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if ($_SESSION['zalogowany']==false): ?>
|
|
|
|
|
2018-12-30 17:26:18 +01:00
|
|
|
<div class="loginbox">
|
|
|
|
<img src="img/avatar.png" class="avatar">
|
2018-12-30 23:53:11 +01:00
|
|
|
<h1>Logowanie</h1>
|
2018-12-30 17:26:18 +01:00
|
|
|
<form method="POST" action="index.php">
|
|
|
|
<p>Login</p>
|
|
|
|
<input type="text" name="login" placeholder="Wpisz swój login" required>
|
|
|
|
<p>Hasło</p>
|
|
|
|
<input type="password" name="password" placeholder="Wpisz swoje hasło" required>
|
|
|
|
<input type="submit" name="loguj" value="Zaloguj">
|
2018-12-30 23:53:11 +01:00
|
|
|
<h2><?php echo $error; ?></h2>
|
2018-12-30 17:26:18 +01:00
|
|
|
<a href="nowe_konto.php">Zarejestruj się</a>
|
|
|
|
</form>
|
|
|
|
|
|
|
|
</div>
|
2018-11-27 18:56:59 +01:00
|
|
|
|
|
|
|
<?php
|
|
|
|
endif;
|
|
|
|
mysql_close();
|
2018-12-30 23:53:11 +01:00
|
|
|
?>
|
|
|
|
</html>
|