Prześlij pliki do ''

This commit is contained in:
Piotr Szefler 2021-03-27 17:14:05 +01:00
parent 1daf0bd313
commit 3f080f6692
5 changed files with 290 additions and 0 deletions

76
add_event.php Normal file
View File

@ -0,0 +1,76 @@
<?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">
DODAJ SWOJE WYDARZENIE !<br /><br />
<form action="add.php" method="post">
Tytul: <br><input type="text" name="title3" /> <br />
Opis: <br> <textarea rows="4" cols="50" name="description3"></textarea> <br />
Data rozp.: <br> <input type="date" name="date_start3" /> <br />
Data zako.: <br /> <input type="date" name="date_stop3" /> <br />
Godzina rozp.: <br /> <input type="time" name="time_start3" /> <br />
Godzina zako.: <br /> <input type="time" name="time_stop3" /> <br />
Lokalizacja: <br /> <select name="location3">
<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="quantity3" min="1" max="20" /> <br />
Ilość miejsc min: <br /> <input type="number" name="quantity_min3" min="1" max="20" /> <br /> <br />
<input type="submit" value="Dodaj" />
<br /> <br />
</form>
<?php
if(isset($_SESSION['add_log'])){
echo "<span style='color:red'>".$_SESSION['add_log']."</span>";
unset($_SESSION['add_log']);
}
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>

41
calendar.php Normal file
View File

@ -0,0 +1,41 @@
<?PHP
$filename='event_cal.ics';
header('Content-type: text/calendar; charset=utf-8');
header('Content-Disposition: attachment; filename=' . $filename);
$arg1 = $_GET['arg1']; //TITLE
$arg2 = $_GET['arg2']; //DESCRIPTION
$arg3 = $_GET['arg3']; //DATE_START
$arg4 = $_GET['arg4']; //DATE_STOP
$arg5 = $_GET['arg5']; //TIME_START
$arg6 = $_GET['arg6']; //TIME_STOP
$arg7 = $_GET['arg7']; //LOCATION
function escape_String($string) {
return $string;
}
function date_convert($string1,$string2) {
$date_conv = str_replace("-", "", $string1);
$time_conv = str_replace(":", "", $string2);
return $date_conv."T".$time_conv."00";
}
?>
BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//hacksw/handcal//NONSGML v1.0//EN
CALSCALE:GREGORIAN
BEGIN:VEVENT
DTEND;TZID="Central European Standard Time":<?= date_convert($arg3,$arg5) ?><?php echo PHP_EOL;?>
UID:<?= uniqid() ?><?php echo PHP_EOL;?>
DTSTAMP:20181031T105919Z
LOCATION:<?= escape_String($arg7) ?><?php echo PHP_EOL;?>
DESCRIPTION:<?= escape_String($arg2) ?><?php echo PHP_EOL;?>
URL;VALUE=URI:http://127.0.0.1/event/events.php
SUMMARY:<?= escape_String($arg1) ?><?php echo PHP_EOL;?>
DTSTART;TZID="Central European Standard Time":<?= date_convert($arg4,$arg6) ?><?php echo PHP_EOL;?>
END:VEVENT
END:VCALENDAR

60
controller.php Normal file
View File

@ -0,0 +1,60 @@
<?php
session_start();
if (!isset($_SESSION['zalogowany']))
{
header('Location: index.php');
exit();
}
$_SESSION['numevent'] = $_GET['info'];
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);
$query = "SELECT events.id_events, events.quantity FROM manager, events WHERE events.id_events = manager.id_events AND manager.id_events = '".$_SESSION['numevent']."'";
$rezultat = mysqli_query($polaczenie, $query);
$ile = mysqli_num_rows($rezultat);
require_once "dbconnect.php";
$polaczenie = @new mysqli($host, $db_user, $db_password, $db_name);
if ($polaczenie->connect_errno!=0)
{
echo "Error: ".$polaczenie->connect_errno;
}
else
{
#$login = $_SESSION['employeeID'];
$login = htmlentities($login, ENT_QUOTES, "UTF-8");
if ($rezultat = @$polaczenie->query(
sprintf("SELECT events.id_events, events.quantity FROM manager, events WHERE events.id_events = manager.id_events AND manager.id_events = '".$_SESSION['numevent']."' AND manager.employeeID='".$_SESSION['login']."'",
mysqli_real_escape_string($polaczenie,$login))))
{
$ilu_userow = $rezultat->num_rows;
if($ilu_userow>0)
{
$wiersz = $rezultat->fetch_assoc();
$_SESSION['controller'] = "true";
$rezultat->free_result();
header('Location: join_page_style.php');
}
else
{
$_SESSION['controller'] = "false";
//Osoby które nie sa w wydarzeniu
header('Location: join_page_style.php');
}
}
$polaczenie->close();
}
?>

10
dbconnect.php Normal file
View File

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

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'];
}
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']);
?>