Merge remote-tracking branch 'origin/m2_Robert' into dev/m2_safak

This commit is contained in:
S170H
2023-11-10 13:42:06 +01:00
26 changed files with 745 additions and 0 deletions

21
M2/Beispiele/Test.php Normal file
View File

@@ -0,0 +1,21 @@
<!DOCTYPE html>
<html>
<body>
<?php
$anweisung = 3;
switch ($anweisung) {
case 1:
echo "catch _1_ !";
break;
case 2:
echo "catch _2_ !";
break;
case 3:
echo "catch _3_ !";
default:
echo "nothing to catch!";
break;
}
?>
</body>
</html>

View File

@@ -0,0 +1 @@
07.11.2023 - 13:02 | 127.0.0.1 | Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/119.0

4
M2/Beispiele/en.txt Normal file
View File

@@ -0,0 +1,4 @@
Bewertung;Rating
Name;Name
Begründung;Reason
Senden;Send

View File

@@ -0,0 +1,3 @@
<?php
echo "Erstes PHP-Skript <br>";
phpinfo();

View File

@@ -0,0 +1,12 @@
<?php
/**
* Praktikum DBWT. Autoren:
* Şafak, Hazinedar, 3108590
* Robert, Joel, 3672729
*/
function addieren(int $number1,int $number2=0){
return $number1+$number2;
}
?>

View File

@@ -0,0 +1,13 @@
<?php
/**
* Praktikum DBWT. Autoren:
* Şafak, Hazinedar, 3108590
* Robert, Joel, 3672729
*/
include "m2_5a_standardparameter.php";
echo addieren(2,3)."<br>";
echo addieren(50,10)."<br>";
echo addieren(-2,3);
?>

View File

@@ -0,0 +1,53 @@
<?php
/**
* Praktikum DBWT. Autoren:
* Şafak, Hazinedar, 3108590
* Robert, Joel, 3672729
*/
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
if ($_POST['rechnen'] == 'Addieren') {
$number1 = $_POST['number1'];
$number2 = $_POST['number2'];
$ergebnis = $number1 + $number2;
} elseif ($_POST['rechnen'] == "Multiplizieren") {
$number1 = $_POST['number1'];
$number2 = $_POST['number2'];
$ergebnis = $number1 * $number2;
}
}
?>
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="UTF-8"/>
<title>Addform</title>
<style>
* {
font-family: Arial, serif;
}
.rating {
color: darkgray;
}
</style>
</head>
<body>
<form action="m2_5c_addform.php" method="post">
<label for="number1">Erste Zahl:</label>
<input id="number1" type="text" name="number1"/>
<label for="number2">Zweite Zahl:</label>
<input id="number2" type="text" name="number2"/>
<input type="Submit" name="rechnen" value="Addieren" />
<input type="Submit" name="rechnen" value="Multiplizieren" />
<?php
if(!empty($ergebnis))
{
echo "<br><br>Ergebnis: ".$ergebnis;
}
?>
</body>
</html>

View File

@@ -0,0 +1,67 @@
<?php
/**
* Praktikum DBWT. Autoren:
* Şafak, Hazinedar, 3108590
* Robert, Joel, 3672729
*/
function missingYear($famousMeals){
$years = [];
$winneryears = [];
$ergebniss = [];
for ($i = 0;$i <= 23; $i++){
$years[] = 2000+$i;
}
foreach ($famousMeals as $meal){
if(gettype($meal["winner"])== "array"){
foreach ($meal["winner"]as $year){
$winneryears[] = $year;
}
}else{
$winneryears[] = $year;
}
}
foreach ($years as $year){
$a=0;
foreach ($winneryears as $winners){
if ($year == $winners){
$a = 1;
break;
}
}
if($a==0){
$ergebniss[]=$year;
}
}
echo var_dump($ergebniss);
}
$famousMeals = [
1 => ['name' => 'Currywurst mit Pommes',
'winner' => [2001, 2003, 2007, 2010, 2020]],
2 => ['name' => 'Hähnchencrossies mit Paprikareis',
'winner' => [2002, 2004, 2008]],
3 => ['name' => 'Spaghetti Bolognese',
'winner' => [2011, 2012, 2017]],
4 => ['name' => 'Jägerschnitzel mit Pommes',
'winner' => 2019]
];
echo "<ol>";
foreach ($famousMeals as $meal){
echo "<li>". $meal['name']."<br>";
if(gettype($meal["winner"])== "array"){
foreach ($meal["winner"]as $year){
$dump[] = $year;
}
}else{
$dump[] = $year;
}
echo implode( ', ', $dump);
$dump = null;
echo "</li><br>";
}
echo "</ol>";
missingYear($famousMeals);
?>

View File

@@ -0,0 +1,16 @@
<?php
/**
* Praktikum DBWT. Autoren:
* Şafak, Hazinedar, 3108590
* Robert, Joel, 3672729
*/
$ip = $_SERVER['REMOTE_ADDR'];
$agent = $_SERVER['HTTP_USER_AGENT'];
$logFile = fopen("accesslog.txt", "a");
$time = time();
$datum = date("d.m.Y - H:i", $time);
$write = $datum." | ".$ip." | ".$agent."\n";
fwrite($logFile, $write);
?>

View File

@@ -0,0 +1,41 @@
<?php
/**
* Praktikum DBWT. Autoren:
* Şafak, Hazinedar, 3108590
* Robert, Joel, 3672729
*/
const GET_PARAM_SEARCH_TEXT = 'search_text';
$searchTerm = "";
if (!empty($_GET[GET_PARAM_SEARCH_TEXT])) {
$searchTerm = $_GET[GET_PARAM_SEARCH_TEXT];
}
$enFile = fopen("en.txt", "r");
$fileLines = [];
while ($line = fgets($enFile)) {
$fileLines[] = $line;
}
foreach ($fileLines as $line){
$lineArray[] = explode(' ', $line);
//echo var_dump($lineArray);
$deutsch = $lineArray[0][0];
echo $line."|";
if($deutsch==$searchTerm){
echo "ja";
}
}
?>
<form method="get">
<label for="search_text">Suche:</label>
<input id="search_text" type="text" name="search_text" value=<?php echo $searchTerm?>>
<input type="submit" value="Suchen">
</form>

206
M2/Beispiele/meal.php Normal file
View File

@@ -0,0 +1,206 @@
<?php
const GET_PARAM_MIN_STARS = 'search_min_stars';
const GET_PARAM_SEARCH_TEXT = 'search_text';
const GET_PARAM_SHOW_DESCRIPTION = 'show_description';
const GET_PARAM_SPRACHE = 'sprache';
const GET_PARAM_TOP_FLOPP = 'top_flopp';
/**
* List of all allergens.
*/
$allergens = [
11 => 'Gluten',
12 => 'Krebstiere',
13 => 'Eier',
14 => 'Fisch',
17 => 'Milch'
];
$meal = [
'name' => 'Süßkartoffeltaschen mit Frischkäse und Kräutern gefüllt',
'description' => 'Die Süßkartoffeln werden vorsichtig aufgeschnitten und der Frischkäse eingefüllt.',
'price_intern' => 2.90,
'price_extern' => 3.90,
'allergens' => [11, 13],
'amount' => 42 // Number of available meals
];
$ratings = [
[ 'text' => 'Die Kartoffel ist einfach klasse. Nur die Fischstäbchen schmecken nach Käse. ',
'author' => 'Ute U.',
'stars' => 2 ],
[ 'text' => 'Sehr gut. Immer wieder gerne',
'author' => 'Gustav G.',
'stars' => 4 ],
[ 'text' => 'Der Klassiker für den Wochenstart. Frisch wie immer',
'author' => 'Renate R.',
'stars' => 4 ],
[ 'text' => 'Kartoffel ist gut. Das Grüne ist mir suspekt.',
'author' => 'Marta M.',
'stars' => 3 ]
];
$dic = [
[ "Gericht" => "Gericht",
"Allergien" => "Allergien",
"Bewertungen" => "Bewertungen (Insgesamt: ",
"Text" => "Text",
"Sterne" => "Sterne",
"Author" => "Author",
"Preis" => "Preis",
"Gaeste" => "Gäste"
],
[ "Gericht" => "Meal",
"Allergien" => "Allergies",
"Bewertungen" => "Review (overall: ",
"Text" => "Text",
"Sterne" => "Stars",
"Author" => "Author",
"Preis" => "Price",
"Gaeste" => "Guests"
]
];
$translation = $dic[0];
$language = "de";
if (!empty($_GET[GET_PARAM_SPRACHE])){
$language = $_GET[GET_PARAM_SPRACHE];
}
if($language == "en"){$translation = $dic[1];}
if (empty($_GET[GET_PARAM_SHOW_DESCRIPTION])){
$meal['description'] = "";
}
$searchTerm = "";
$showRatings = [];
if (!empty($_GET[GET_PARAM_SEARCH_TEXT])) {
$searchTerm = $_GET[GET_PARAM_SEARCH_TEXT];
foreach ($ratings as $rating) {
if (strpos(strtolower($rating['text']), strtolower($searchTerm) )!== false) {
$showRatings[] = $rating;
}
}
} else if (!empty($_GET[GET_PARAM_MIN_STARS])) {
$minStars = $_GET[GET_PARAM_MIN_STARS];
foreach ($ratings as $rating) {
if ($rating['stars'] >= $minStars) {
$showRatings[] = $rating;
}
}
} else {
$showRatings = $ratings;
}
if (!empty($_GET[GET_PARAM_TOP_FLOPP])){
$flopp = $_GET[GET_PARAM_TOP_FLOPP];
if($flopp == "flopp"){
unset($showRatings);
$showRatings=[];
$stars=[];
foreach ($ratings as $rating) {
$stars[] = $rating["stars"];
}
$min = min($stars);
foreach ($ratings as $rating) {
if ($rating['stars'] == $min) {
$showRatings[] = $rating;
}
}
}
elseif ($flopp == "top"){
unset($showRatings);
$showRatings=[];
$stars=[];
foreach ($ratings as $rating) {
$stars[] = $rating["stars"];
}
$min = max($stars);
foreach ($ratings as $rating) {
if ($rating['stars'] == $min) {
$showRatings[] = $rating;
}
}
}
}
/**
*:float gibt den return value der Funktion an
*/
function calcMeanStars (array $ratings) : float {
$sum = 0;
foreach ($ratings as $rating) {
$sum += $rating['stars'] / count($ratings);
}
return $sum;
}
/**
*
*/
?>
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="UTF-8"/>
<title><?php echo $translation["Gericht"].": ". $meal['name']; ?></title>
<style>
* {
font-family: Arial, serif;
}
.rating {
color: darkgray;
}
</style>
</head>
<body>
<h1><?php echo $translation["Gericht"].": ". $meal['name']; ?></h1>
<p><?php echo $meal['description']; ?>
</p>
<h4><?php echo $translation["Preis"].":"?></h4>
<p>
<?php echo $translation["Preis"]." intern: ".$meal["price_intern"]."€";?> <br>
<?php echo $translation["Preis"]." ".$translation["Gaeste"].": ".$meal["price_extern"]."€";?>
</p>
<h4><?php echo $translation["Allergien"].":"?> </h4>
<ul>
<?php
foreach ($meal['allergens'] as $all) {
echo "<li>$allergens[$all]</li>";
}
?>
</ul>
<h1><?php echo $translation["Bewertungen"].calcMeanStars($ratings); ?>)</h1>
<!--Such form in den Bewertungen für den User -->
<form method="get">
<label for="search_text">Filter:</label>
<input id="search_text" type="text" name="search_text" value=<?php echo $searchTerm?>>
<input type="submit" value="Suchen">
</form>
<table class="rating">
<thead>
<tr>
<td><?php echo $translation["Text"]?></td>
<td><?php echo $translation["Sterne"]?></td>
<td><?php echo $translation["Author"]?></td>
</tr>
</thead>
<tbody>
<?php
foreach ($showRatings as $rating) {
echo "<tr><td class='rating_text'>{$rating['text']}</td>
<td class='rating_stars'>{$rating['stars']}</td>
<td class='rating_author'>{$rating['author']}</td>
</tr>";
}
?>
</tbody>
</table>
<br>
<br>
<a href="?sprache=de">Deutsch</a> oder <a href="?sprache=en">English</a>
</body>
</html>

View File

@@ -0,0 +1 @@
10

BIN
M2/Werbeseite/fh-logo.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

View File

@@ -0,0 +1,31 @@
<?php
/**
* Praktikum DBWT. Autoren:
* Şafak, Hazinedar, 3108590
* Robert, Joel, 3672729
*/
$gerichte = [
1 => ['name' => 'Rindfleich mit Bambus, Kaiserschoten und roter Paprika, dazu Mie Nudeln',
'priceint' => 3.50,
"priceex" => 6.20,
"img" =>"img/bambus.jpg"
],
2 => ['name' => 'Spinatrisotto mit kleinen Samosateigecken und gemischter Salat',
'priceint' => 2.90,
"priceex" => 5.30,
"img" =>"img/risotto.jpg"
],
3 => ['name' => 'Spaghetti Bolognese',
'priceint' => 3,
"priceex" => 5,
"img" =>"img/bolo.jpg"
],
4 => ['name' => 'Spaghetti Carbonara',
'priceint' => 3,
"priceex" => 5,
"img" =>"img/carbonara.jpg"
]
]
?>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 MiB

BIN
M2/Werbeseite/img/bolo.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 139 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 103 KiB

226
M2/Werbeseite/index.php Normal file
View File

@@ -0,0 +1,226 @@
<?php
/**
* Praktikum DBWT. Autoren:
* Şafak, Hazinedar, 3108590
* Robert, Joel, 3672729
*/
include "gerichte.php";
$besucherCount = 0;
if(file_exists("besucher.txt")){
$besucherFile = fopen("besucher.txt", "r");
$besucherCount = fgets($besucherFile) +1;
fclose($besucherFile);
$besucherFile = fopen("besucher.txt", "w");
fwrite($besucherFile, $besucherCount);
fclose($besucherFile);
}else{
$besucherFile = fopen("besucher.txt", "w");
fwrite($besucherFile, 1);
fclose($besucherFile);
}
?>
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/html">
<head>
<meta charset="UTF-8">
<title>Ihre E-Mensa</title>
<style>
* {
font-family: Arial;
}
.grid {
display: grid;
grid-template-columns: 200px auto 200px;
}
img {
width: 100%;
height: auto;
}
.speisen {
border: solid;
border-collapse: collapse;
}
.speisen td {
border: solid;
border-collapse: collapse;
border-radius: 4px;
padding: 5px;
width: 150px;
}
.speisen td:not(:first-of-type) {
text-align: center;
}
p {
text-align: justify;
}
.zahlen {
list-style-type: none;
display: grid;
grid-template-columns: auto auto auto;
gap: 10px;
}
.zahlen p {
text-align: center;
font-weight: bold;
}
.formular {
display: grid;
grid-template-columns: auto auto auto;
justify-content: start;
gap: 10px;
}
.wichtig {
text-align: center;
}
.wichtigListe {
display: inline-block;
text-align: left;
}
.freude {
text-align: center;
}
footer {
border-top: 1px solid;
}
.fusszeile {
padding-top: 20px;
padding-bottom: 20px;
margin-left: auto;
margin-right: auto;
border: none;
}
.fusszeile td:first-child {
border-left: none;
padding-left: 20px;
padding-right: 20px;
}
.fusszeile td {
border-left: 3px solid;
padding-left: 20px;
padding-right: 20px;
}
</style>
</head>
<body>
<div class="grid">
<div>
<img src="fh-logo.jpg" alt="FH-Logo">
</div>
<div>
<a href="#ankündigung">Ankündigung</a>
<a href="#speisen">Speisen</a>
<a href="#zahlen">Zahlen</a>
<a href="#kontakt">Kontakt</a>
<a href="#wichtig">Wichtig für uns</a>
</div>
</div>
<hr>
<div class="grid">
<div></div>
<div>
<img src="mensa21.jpg" alt="Essen">
<h1 id="ankündigung">Bald gibt es auch Essen online ;)</h1>
<p>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et
dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet
clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet,
consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat,
sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no
sea takimata sanctus est Lorem ipsum dolor sit amet.</p>
<h1 id="speisen">Köstlichkeiten die Sie erwarten</h1>
<table class="speisen">
<tr class="speisen">
<td>Gerichte</td>
<td>Preis intern</td>
<td>Preis extern</td>
<td>Bild</td>
</tr>
<?php
/**
* Speisekarte
*/
foreach ($gerichte as $gericht){
echo "<tr class=\"speisen\"><td>".$gericht["name"]."</td><td>".$gericht["priceint"]."</td><td>".$gericht["priceex"]."</td><td><img src=".$gericht["img"]." alt=".$gericht["name"].">";
}
?>
</table>
<h1 id="zahlen">E-Mensa in Zahlen</h1>
<div class="zahlen">
<p><?php echo $besucherCount;?> Besuche</p>
<p>Y Anmeldungen zum Newsletter</p>
<p><?php echo count($gerichte);?> Speisen</p>
</div>
<h1 id="kontakt">Interesse geweckt? Wir informieren</h1>
<div class="formular">
<div>
<label for="name">Name</label> <br>
<input type="text" name="name" id="name" placeholder="Bitte geben Sie Ihren Namen ein">
</div>
<div>
<label for="mail">E-Mail</label> <br>
<input type="text" name="name" id="mail" placeholder="Bitte geben Sie Ihren Namen ein">
</div>
<div>
<label for="sprache">Newsletter bitte in</label> <br>
<select name="sprache" id="sprache">
<option value="deutsch">Deutsch</option>
<option value="englisch">Englisch</option>
</select>
</div>
</div>
<br>
<input required type="checkbox" name="datenschutz" id="datenschutz"
placeholder="Bitte geben Sie Ihren Namen ein">
<label for="datenschutz">Den Datenschutzbestimmungen stimme ich zu</label>
<button type="submit">Zum Newsletter anmelden</button>
<h1 id="wichtig">Das ist uns wichtig</h1>
<div class="wichtig">
<ul class="wichtigListe">
<li>Beste frische saisonale Zutaten</li>
<li>Ausgewogen abwechslungsreiche Gerichte</li>
<li>Sauberkeit</li>
</ul>
</div>
<h1 class="freude">Wir freuen uns auf Ihren Besuch!</h1>
</div>
</div>
<footer>
<table class="fusszeile">
<tr>
<td>(c) E-Mensa GmbH</td>
<td>Şafak Hazinedar & Robert Joel</td>
<td><a href="">Impressum</a></td>
</tr>
</table>
</footer>
</body>
</html>

BIN
M2/Werbeseite/mensa21.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 153 KiB

BIN
M2/dossier.xlsx Normal file

Binary file not shown.