Prześlij pliki do ''

This commit is contained in:
Piotr Szefler 2021-03-26 14:15:14 +01:00
parent e7ca42b98f
commit 37a915b8d8
5 changed files with 464 additions and 0 deletions

9
dbconnect.php Normal file
View File

@ -0,0 +1,9 @@
<?php
$host="localhost"; // Nazwa hosta
$db_user="events"; // Nazwa uzytkownika mysql
$db_password="Hx8hWQfe"; // Haslo do bazy
$db_name="events"; // Nazwa bazy
$table1="events"; //Nazwa tabeli
//$table2="users"; //Nazwa tabeli
$table2="manager"; //Nazwa tabeli
?>

103
edit.php Normal file
View File

@ -0,0 +1,103 @@
<?php
session_start();
if (!isset($_SESSION['zalogowany']) || $_SESSION['perm']=='normal')
{
$_SESSION['blad_perm'] = '<span style="color:red">Brak uprawnien!</span>';
header('Location: index.php');
exit();
}
ini_set("display_errors", 0);
require_once "dbconnect.php";
$polaczenie = mysqli_connect($host, $db_user, $db_password);
mysqli_query($polaczenie, "SET CHARSET utf8");
mysqli_query($polaczenie, "SET NAMES 'utf8' COLLATE 'utf8_polish_ci'");
mysqli_select_db($polaczenie, $db_name);
$controller = $_SESSION['quantity_controller'];
$stopdate = $_SESSION['e_dtstp'];
if($_POST['title2'] == NULL )
{
$g1 = $_SESSION['e_title'];
}
else
{
$g1 = $_POST['title2'];
}
if($_POST['description2'] == NULL)
{
$g2 = $_SESSION['e_descr'];
}
else
{
$g2 = $_POST['description2'];
echo "elo".$g2;
}
if($_POST['date_start2'] == NULL || ($_POST['date_start2'] >= $stopdate))
{
$g3 = $_SESSION['e_dtstr']; //domyślna poprzednia
}
elseif(($_POST['date_start2'] < $stopdate))
{
$g3 = $_POST['date_start2']; //nowa data
}
if($_POST['date_stop2'] == NULL || ($_POST['date_start2'] >= $_POST['date_stop2']))
{
$g4 = $_SESSION['e_dtstp'];
}
elseif(($_POST['date_start2'] < $_POST['date_stop2']))
{
$g4 = $_POST['date_stop2'];
}
if($_POST['time_start2'] == NULL || ($_POST['time_start2'] >= $_POST['time_stop2']))
{
$g5 = $_SESSION['e_tmstr'];
}
elseif(($_POST['time_start2'] < $_POST['time_stop2']))
{
$g5 = $_POST['time_start2'];
}
if($_POST['time_stop2'] == NULL || ($_POST['time_start2'] >= $_POST['time_stop2']))
{
$g6 = $_SESSION['e_tmstp'];
}
elseif(($_POST['time_start2'] < $_POST['time_stop2']))
{
$g6 = $_POST['time_stop2'];
}
if($_POST['location2'] == NULL)
{
$g7 = $_SESSION['e_loc'];
}
else
{
$g7 = $_POST['location2'];
}
if($_POST['quantity2'] == NULL || $controller > $_POST['quantity2'])
{
$g8 = $_SESSION['e_slots'];
}
elseif($controller <= $_POST['quantity2'])
{
$g8 = $_POST['quantity2'];
}
if($_POST['quantity_min2'] == NULL)
{
$g9 = $_SESSION['e_slots'];
}
else
{
$g9 = $_POST['quantity2_min'];
}
$zapytanietxt = "UPDATE `events` SET `title` = '".$g1."', `description` = '".$g2."', `date_start` = '".$g3."', `date_stop` = '".$g4."', `time_start` = '".$g5."', `time_stop` = '".$g6."', `location` = '".$g7."', `quantity` = '".$g8."', `quantity_min` = '".$g9."' WHERE `events`.`id_events` =".$_SESSION['id_eve'];
$rezultat = mysqli_query($polaczenie, $zapytanietxt);
$ile = mysqli_num_rows($rezultat);
header('Location: events.php');
unset($_SESSION['controller']);
?>

72
edit_page.php Normal file
View File

@ -0,0 +1,72 @@
<?php
session_start();
if (!isset($_SESSION['zalogowany']) || $_SESSION['perm']=='normal')
{
$_SESSION['blad_perm'] = '<span style="color:red">Brak uprawnien!</span>';
header('Location: index.php');
exit();
}
?>
<!DOCTYPE HTML>
<html lang="pl">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>Event Manager</title>
<meta name="author" content="Piotr Szefler">
<meta http-equiv="X-Ua-Compatible" content="IE=edge">
<link rel="stylesheet" href="style/style.css">
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="main.css">
<link href="https://fonts.googleapis.com/css?family=Open+Sans:400,700&amp;subset=latin-ext" rel="stylesheet">
</head>
<body id="form">
<div class="container-form">
Uaktualnij wydarzenie<br /><br />
<form action="edit.php" method="post">
Tytul: <br /> <input type="text" name="title2" /> <br />
Opis: <br /> <textarea rows="4" cols="50" name="description2" ></textarea> <br />
Data rozp.: <br /> <input type="date" name="date_start2" /> <br />
Data zako.: <br /> <input type="date" name="date_stop2" /> <br />
Godzina rozp.: <br /> <input type="time" name="time_start2" /> <br />
Godzina zako.: <br /> <input type="time" name="time_stop2" /> <br />
Lokalizacja: <br /> <select name="location2">
<option value=""></option>
<option value="Salka Zielona">Salka Zielona</option>
<option value="Salka Niebieska">Salka Niebieska</option>
<option value="Salka Błękitna">Salka Błękitna</option>
<option value="Salka Operacyjna">Salka Operacyjna</option>
<option value="Salka Biała">Salka Biała</option>
<option value="Salka Czerwona">Salka Czerwona</option>
<option value="Salka Akwarium">Salka Akwarium</option>
</select> <br />
Ilość miejsc max: <br /> <input type="number" name="quantity2" min="1" max="20" /> <br />
Ilość miejsc min: <br /> <input type="number" name="quantity_min2" min="1" max="20" /> <br /> <br />
<input type="submit" value="Uaktualnij" />
<br /> <br />
</form>
<?php
echo '</br><p><a href="events.php">Powrót</a></p>';
unset($_SESSION['controller']);
?>
</div>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
<script src="js/bootstrap.min.js"></script>
</body>
</html>

143
events.php Normal file
View File

@ -0,0 +1,143 @@
<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">
<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"pl-PL\">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>Event Manager</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="author" content="Piotr Szefler">
<meta http-equiv="X-Ua-Compatible" content="IE=edge">
<link rel="stylesheet" href="style/style.css">
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="main.css">
<link href="https://fonts.googleapis.com/css?family=Open+Sans:400,700&amp;subset=latin-ext" rel="stylesheet">
<style>
th, td {
border-bottom: 1px solid #ddd;
padding: 15px;
}
tr:hover {
background-color: #f5f5f5;
}
</style>
</head>
<body>
<div class="container">
<div class="table-responsive" >
<table class="tabel" style="margin:auto; border:">
<thead>
<?php
ini_set("display_errors", 0);
session_start();
/*echo '<pre>';
print_r($_SESSION);
echo '</pre>';
*/
if (!isset($_SESSION['zalogowany']))
{
header('Location: index.php');
exit();
}
require_once "dbconnect.php";
$polaczenie = mysqli_connect($host, $db_user, $db_password);
mysqli_query($polaczenie, "SET CHARSET utf8");
mysqli_query($polaczenie, "SET NAMES 'utf8' COLLATE 'utf8_polish_ci'");
mysqli_select_db($polaczenie, $db_name);
$zapytanietxt = "SELECT * FROM events";
$rezultat = mysqli_query($polaczenie, $zapytanietxt);
$ile = mysqli_num_rows($rezultat);
echo "</br></br>Witaj ".$_SESSION['login'].'! [ <a href="logout.php">Wyloguj się!</a> ';echo "] [";
echo '<a href="events_arch.php"> Archiwalne</a>]</p>';
if(isset($_SESSION['blad_perm'])){
echo "<span style='color:red'>".$_SESSION['blad_perm']."</span>";unset($_SESSION['blad_perm']);
}
elseif(isset($_SESSION['id_log'])){
echo "<span style='color:red'>".$_SESSION['id_log']."</span>";unset($_SESSION['id_log']);
}
elseif(isset($_SESSION['slots_log'])){
echo "<span style='color:red'>".$_SESSION['slots_log']."</span>";unset($_SESSION['slots_log']);
}
if ($ile>=1)
{
if($_SESSION['perm']=='modder' || $_SESSION['perm']=='admin'){
echo '<tr onclick=location.href="add_event.php"><td width="60" align="center" bgcolor="#f8f8f8" ><i class="demo-icon icon-doc-new"></i></td>';
}
else{
echo '<tr><td width="60" align="center" bgcolor="#f8f8f8">ID Eventu</td>';
}
echo<<<END
<td class="header_tabler" width="350" align="center" bgcolor="#f8f8f8" padding=5px>Nazwa Eventu</td>
<td class="header_tabler" width="100" align="center" bgcolor="#f8f8f8" padding=5px>Data rozpoczecia</td>
<td class="header_tabler" width="50" align="center" bgcolor="#f8f8f8" padding=5px>Godzina rozpoczecia</td>
<td class="header_tabler" width="100" align="center" bgcolor="#f8f8f8" padding=5px>Ilość godzin</td>
<td class="header_tabler" width="100" align="center" bgcolor="#f8f8f8" padding=5px>Lokalizacja</td>
</tr></thead><tbody>
END;
}
$akt_date = date("Y-m-d");
for ($i = 1; $i <= $ile; $i++)
{
$row = mysqli_fetch_assoc($rezultat);
$a4 = $row['date_stop'];
if($a4 >= $akt_date){
$a1 = $row['title'];
$a2 = $row['description'];
$a3 = $row['date_start'];
$a5 = $row['time_start'];
$a6 = $row['time_stop'];
$a7 = $row['location'];
$a8 = $row['id_events'];
$a9 = $a6 - $a5;
$a5 = substr($a5,0,strlen($a5)-3);
$a6 = substr($a6,0,strlen($a6)-3);
echo<<<END
<tr onclick="location.href='controller.php?info=$a8'">
<td width="50" align="center"><i class="demo-icon icon-plus"></i></td>
<td width="100" align="center" padding=2px><h3>$a1</h3></td>
<td width="100" align="center" padding=5px>$a3</td>
<td width="100" align="center" padding=5px>$a5</td>
<td width="100" align="center" padding=5px>$a9</td>
<td width="100" align="center" padding=5px>$a7</td>
</tr>
END;
}
}
echo "</tr><br/>";
?>
</tr></tbody></table>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
<script src="js/bootstrap.min.js"></script>
</body>
</html>

137
events_arch.php Normal file
View File

@ -0,0 +1,137 @@
<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">
<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"pl-PL\">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>Event Manager</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="author" content="Piotr Szefler">
<meta http-equiv="X-Ua-Compatible" content="IE=edge">
<link rel="stylesheet" href="style/style.css">
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="main.css">
<link href="https://fonts.googleapis.com/css?family=Open+Sans:400,700&amp;subset=latin-ext" rel="stylesheet">
<style>
th, td {
border-bottom: 1px solid #ddd;
padding: 15px;
}
tr:hover {
background-color: #f5f5f5;
}
</style>
</head>
<body>
<div class="container">
<div class="table-responsive" >
<table class="tabel" style="margin:auto; border:">
<thead>
<?php
ini_set("display_errors", 0);
session_start();
if (!isset($_SESSION['zalogowany']))
{
header('Location: index.php');
exit();
}
ini_set("display_errors", 0);
require_once "dbconnect.php";
$polaczenie = mysqli_connect($host, $db_user, $db_password);
mysqli_query($polaczenie, "SET CHARSET utf8");
mysqli_query($polaczenie, "SET NAMES 'utf8' COLLATE 'utf8_polish_ci'");
mysqli_select_db($polaczenie, $db_name);
$zapytanietxt = "SELECT * FROM events";
$rezultat = mysqli_query($polaczenie, $zapytanietxt);
$ile = mysqli_num_rows($rezultat);
echo "</br></br>Witaj ".$_SESSION['login'].'! [ <a href="logout.php">Wyloguj się!</a> ';echo "] [";
echo '<a href="events.php"> Powrót</a>]</p>';
if(isset($_SESSION['blad_perm'])){
echo "<span style='color:red'>".$_SESSION['blad_perm']."</span>";unset($_SESSION['blad_perm']);
}
elseif(isset($_SESSION['id_log'])){
echo "<span style='color:red'>".$_SESSION['id_log']."</span>";unset($_SESSION['id_log']);
}
elseif(isset($_SESSION['slots_log'])){
echo "<span style='color:red'>".$_SESSION['slots_log']."</span>";unset($_SESSION['slots_log']);
}
if ($ile>=1)
{
if($_SESSION['perm']=='modder' || $_SESSION['perm']=='admin'){
echo '<tr onclick=location.href="add_event.php"><td width="60" align="center" bgcolor="#f8f8f8" ><i class="demo-icon icon-doc-new"></i></td>';
}
else{
echo '<tr><td width="60" align="center" bgcolor="#f8f8f8">ID Eventu</td>';
}
echo<<<END
<td class="header_tabler" width="350" align="center" bgcolor="#f8f8f8" padding=5px>Nazwa Eventu</td>
<td class="header_tabler" width="100" align="center" bgcolor="#f8f8f8" padding=5px>Data rozpoczecia</td>
<td class="header_tabler" width="50" align="center" bgcolor="#f8f8f8" padding=5px>Godzina rozpoczecia</td>
<td class="header_tabler" width="100" align="center" bgcolor="#f8f8f8" padding=5px>Ilość godzin</td>
<td class="header_tabler" width="100" align="center" bgcolor="#f8f8f8" padding=5px>Lokalizacja</td>
</tr></thead><tbody>
END;
}
$akt_date = date("Y-m-d");
for ($i = 1; $i <= $ile; $i++)
{
$row = mysqli_fetch_assoc($rezultat);
$a4 = $row['date_stop'];
if($a4 < $akt_date){
$a1 = $row['title'];
$a2 = $row['description'];
$a3 = $row['date_start'];
$a5 = $row['time_start'];
$a6 = $row['time_stop'];
$a7 = $row['location'];
$a8 = $row['id_events'];
$a9 = $a6 - $a5;
$a5 = substr($a5,0,strlen($a5)-3);
$a6 = substr($a6,0,strlen($a6)-3);
echo<<<END
<tr onclick="location.href='controller.php?info=$a8'">
<td width="50" align="center"><i class="demo-icon icon-plus"></i></td>
<td width="100" align="center" padding=2px><h3>$a1</h3></td>
<td width="100" align="center" padding=5px>$a3</td>
<td width="100" align="center" padding=5px>$a5</td>
<td width="100" align="center" padding=5px>$a9</td>
<td width="100" align="center" padding=5px>$a7</td>
</tr>
END;
}
}
echo "</tr><br/>";
?>
</tr></tbody></table>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
<script src="js/bootstrap.min.js"></script>
</body>
</html>