Compare commits

...

10 Commits

11 changed files with 504 additions and 0 deletions

37
php/addKatalog.php Normal file
View File

@ -0,0 +1,37 @@
<?php
if(isset($_POST["go"]))
{
$form = array(
"Title"=>$_POST["Title"],
"Author"=>$_POST["Author"]);
$json = json_encode($form);
//echo $json;
// Dieser Schritt dient nur um die Daten wieder in der Ausgabe anzeigen zu lassen,
//muss später noch an eine andere Stelle gepackt werden 8z.B. nach dem Empfang von Daten aus der API)
$json2= json_decode($json, true);
}
?>
<h2>Eingabe</h2>
<form action="" method="post">
<input type="text" name="Title" class="input" placeholder="Titel">
<input type="text" name="Author" class="input" placeholder="Autor">
<input type="text" name="Country" class="input" placeholder="Herkunft">
<input type="url" name="Link" class="input" placeholder="Link">
<input type="text" name="Language" class="input" placeholder="Sprache">
<input type="number" name="Pages" class="input" placeholder="Seiten" min="0">
<input type="number" name="Year" class="input" placeholder="Erscheinungsjahr" min="0">
<select class="input" name="Category">
<option>Book</option>
<option>Magazin</option>
<option>EBook</option>
<option>EPaper</option>
</select>
<input type="url" name="ImageLink" class="input" placeholder="Bild">
<input type="number" name="LendTime" class="input" placeholder="Verteihdauer" min="0">
<select class="input" name="Category">
<option>Physical</option>
<option>Virtual</option>
</select>
<input type="submit" name="go" id="go">
</form>

11
php/catalogue_read.php Normal file
View File

@ -0,0 +1,11 @@
<html>
<?php
$obj = $_POST;
$form = json_decode($obj);
foreach($form as $key=>$value){
echo $key.": ".$value."[br]";
}
?>
</html>

9
php/catalogue_search.php Normal file
View File

@ -0,0 +1,9 @@
<html>
<body>
<?php
$form = array("Title"=>$_POST["Title"],"Author"=>$_POST["Author"]);
$form = json_encode($form);
// echo $form
?>
</body>
</html>

6
php/functions.php Normal file
View File

@ -0,0 +1,6 @@
<?php
$selection ="";
$response="";
$responseDoc="";
$status="";
?>

87
php/index.php Normal file
View File

@ -0,0 +1,87 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>API_Frontend Singlepage</title>
<link rel="stylesheet" type="text/css" href="../scss/main.css" media="screen" />
<?php include "functions.php"?>
</head>
<body><!--Das komplette Fenster incl. Hintergrund etc. -->
<div><!--Der Inhaltsblock. Mittig zentriert soll der sein, Breite soll sich dem Bildschirm anpassen.-->
<h1>Bibliotheksverwaltung Bücherwurm</h1>
<div><!--Der Navigationsblock. Auf großem Bildschirm immer sichtbar, fix links. auf kleinen Bildschirmen kann der theoretisch reduziert werden.-->
<h3>Menü</h3>
<dl> <!-- Muss noch dahingehend angepasst werden, dass es ner bestimmten php nur den Wert ändert, anstatt die Seite zu wechseln. -->
<form name="KatalogNav">
<dt>
<label for="choices">Katalog</label>
</dt>
<dd>
<select name="selection1" id="selection" onchange="this.form.submit()">
<option></option>
<option value=findKatalog.htm>Finden</option>
<Option value="addKatalog.php">Hinzufügen</Option>
<option value="changeKatalog.htm">Bearbeiten</option>
<option value="deleteKatalog.htm">Löschen</option>
</select>
</dd>
<dt>
<label for="choices">Inventar</label>
</dt>
<dd>
<select name="selection2" id="selection" onchange="location.assign(this.value);">
<option></option>
<option value=findInventar.htm>Finden</option>
<Option value="addInventar.htm">Hinzufügen</Option>
<option value="deleteInventar.htm">Löschen</option>
</select>
</dd>
<dt>
<label for="choices">Verleihvorgang</label>
</dt>
<dd>
<select name="selection3" id="selection" onchange="location.assign(this.value);">
<option></option>
<option value=findVerleih.htm>Finden</option>
<Option value="addVerleih.htm">Hinzufügen</Option>
<option value="changeVerleih.htm">Bearbeiten</option>
</select>
</dd>
</form>
</dl>
</div>
<div class="Eingabe"><!--Das wird der Inhaltsbereich. Zweigeteilt und leer.-->
<div><!--Der Eingabebereich. Der taucht auf, sobald in der Navigation was gewählt ist. Nimmt fix die Hälfte oder 2/5 des verfügbaren Platzes ein.-->
<?php
if(isset($_GET["selection1"]))
{
$selection1=$_GET["selection1"];
readfile($selection1);
}
elseif (isset($_GET["selection2"]))
{
$selection2=$_GET["selection2"];
echo $selection2;
}
elseif (isset($_GET["selection3"]))
{
$selection3=$_GET["selection3"];
echo $selection3;
}
?>
</div class="Ausgabe">
<div><!--Der Ausgabebereich. Taucht auf, sobald im Eingabebereich ein http-request gesendet wurde. Inhalt ist der Response. Größe von Anfang an 3/5.-->
<?php if($response !="")
include "$responseDoc";
?>
</div>
<div><!--Response Konsole. -->
<textarea cols="30" rows="10" readonly>
<?php echo $selection?>
</textarea>
</div>
</div>
</div>
</body>
</html>

61
php/katalog/add.php Normal file
View File

@ -0,0 +1,61 @@
<?php
if(isset($_GET['list'])) {
$link = "https://localhost:5000/api/katalog";
//remove protocol, we're assuming its http
if(strstr($link, '://') != false){
$link = substr($link, strpos($link,'://') + strlen('://'));
}
//split the url into host (www.example.com) and requested page (index.php) on the first slash
$host = substr($link, 0, strpos($link, '/'));
$request = substr($link, strpos($link, '/'));
//open a socket connection to the site on port 80 (http protocol port)
$fp = @fsockopen($host, 80, $errno, $errstr);
if($fp == false){
$response = $errno . " " . $errstr;
}
else {
//create the request headers
$headers = array();
$headers[] = 'HEAD ' . $request . ' HTTP/1.1';
$headers[] = 'Host: ' . $host;
//$headers[] = 'Content-Length: 0';
$headers[] = 'Connection: close';
$headers[] = 'Content-Type: text/html';
$headers = implode("\r\n", $headers) . "\r\n\r\n";
//send our request
if (!fwrite($fp, $headers)) {
fclose($fp);
$response = "Could not access webpage specified.";
}
else {
//read the response
$rsp = '';
while(!feof($fp)) { $rsp .= fgets($fp,8192); }
fclose($fp);
echo json_decode($rsp);
/*
$hunks = explode("\r\n\r\n",trim($rsp));
$headers = explode("\n", $hunks[count($hunks) - 1]);
$response = trim($headers[0]);
*/
}
}
}
?>
<html>
<head>
<title>Test Link</title>
</head>
<body>
<?php if(isset($response)) { echo $response; } ?>
<form method="get">
<label for="list">Link</label>
<input type="submit" name="list" value="list">
</form>
</body>
</html>

58
php/katalog/change.php Normal file
View File

@ -0,0 +1,58 @@
<?php
if(isset($_POST['link'])) {
$link = $_POST['link'];
//remove protocol, we're assuming its http
if(strstr($link, '://') != false){
$link = substr($link, strpos($link,'://') + strlen('://'));
}
//split the url into host (www.example.com) and requested page (index.php) on the first slash
$host = substr($link, 0, strpos($link, '/'));
$request = substr($link, strpos($link, '/'));
//open a socket connection to the site on port 80 (http protocol port)
$fp = @fsockopen($host, 80, $errno, $errstr);
if($fp == false){
$response = $errno . " " . $errstr;
}
else {
//create the request headers
$headers = array();
$headers[] = 'HEAD ' . $request . ' HTTP/1.1';
$headers[] = 'Host: ' . $host;
$headers[] = 'Content-Length: 0';
$headers[] = 'Connection: close';
$headers[] = 'Content-Type: text/html';
$headers = implode("\r\n", $headers) . "\r\n\r\n";
//send our request
if (!fwrite($fp, $headers)) {
fclose($fp);
$response = "Could not access webpage specified.";
}
else {
//read the response
$rsp = '';
while(!feof($fp)) { $rsp .= fgets($fp,8192); }
fclose($fp);
$hunks = explode("\r\n\r\n",trim($rsp));
$headers = explode("\n", $hunks[count($hunks) - 1]);
$response = trim($headers[0]);
}
}
}
?>
<html>
<head>
<title>Test Link</title>
</head>
<body>
<?php if(isset($response)) { echo $response; } ?>
<form method="post">
<label for="link">Link</label>
<input id="link" type="text" name="link" />
</form>
</body>
</html>

58
php/katalog/find.php Normal file
View File

@ -0,0 +1,58 @@
<?php
if(isset($_POST['link'])) {
$link = $_POST['link'];
//remove protocol, we're assuming its http
if(strstr($link, '://') != false){
$link = substr($link, strpos($link,'://') + strlen('://'));
}
//split the url into host (www.example.com) and requested page (index.php) on the first slash
$host = substr($link, 0, strpos($link, '/'));
$request = substr($link, strpos($link, '/'));
//open a socket connection to the site on port 80 (http protocol port)
$fp = @fsockopen($host, 80, $errno, $errstr);
if($fp == false){
$response = $errno . " " . $errstr;
}
else {
//create the request headers
$headers = array();
$headers[] = 'HEAD ' . $request . ' HTTP/1.1';
$headers[] = 'Host: ' . $host;
$headers[] = 'Content-Length: 0';
$headers[] = 'Connection: close';
$headers[] = 'Content-Type: text/html';
$headers = implode("\r\n", $headers) . "\r\n\r\n";
//send our request
if (!fwrite($fp, $headers)) {
fclose($fp);
$response = "Could not access webpage specified.";
}
else {
//read the response
$rsp = '';
while(!feof($fp)) { $rsp .= fgets($fp,8192); }
fclose($fp);
$hunks = explode("\r\n\r\n",trim($rsp));
$headers = explode("\n", $hunks[count($hunks) - 1]);
$response = trim($headers[0]);
}
}
}
?>
<html>
<head>
<title>Test Link</title>
</head>
<body>
<?php if(isset($response)) { echo $response; } ?>
<form method="post">
<label for="link">Link</label>
<input id="link" type="text" name="link" />
</form>
</body>
</html>

58
php/katalog/list.php Normal file
View File

@ -0,0 +1,58 @@
<?php
if(isset($_POST['link'])) {
$link = $_POST['link'];
//remove protocol, we're assuming its http
if(strstr($link, '://') != false){
$link = substr($link, strpos($link,'://') + strlen('://'));
}
//split the url into host (www.example.com) and requested page (index.php) on the first slash
$host = substr($link, 0, strpos($link, '/'));
$request = substr($link, strpos($link, '/'));
//open a socket connection to the site on port 80 (http protocol port)
$fp = @fsockopen($host, 80, $errno, $errstr);
if($fp == false){
$response = $errno . " " . $errstr;
}
else {
//create the request headers
$headers = array();
$headers[] = 'HEAD ' . $request . ' HTTP/1.1';
$headers[] = 'Host: ' . $host;
$headers[] = 'Content-Length: 0';
$headers[] = 'Connection: close';
$headers[] = 'Content-Type: text/html';
$headers = implode("\r\n", $headers) . "\r\n\r\n";
//send our request
if (!fwrite($fp, $headers)) {
fclose($fp);
$response = "Could not access webpage specified.";
}
else {
//read the response
$rsp = '';
while(!feof($fp)) { $rsp .= fgets($fp,8192); }
fclose($fp);
$hunks = explode("\r\n\r\n",trim($rsp));
$headers = explode("\n", $hunks[count($hunks) - 1]);
$response = trim($headers[0]);
}
}
}
?>
<html>
<head>
<title>Test Link</title>
</head>
<body>
<?php if(isset($response)) { echo $response; } ?>
<form method="post">
<label for="link">Link</label>
<input id="link" type="text" name="link" />
</form>
</body>
</html>

58
php/katalog/remove.php Normal file
View File

@ -0,0 +1,58 @@
<?php
if(isset($_POST['link'])) {
$link = $_POST['link'];
//remove protocol, we're assuming its http
if(strstr($link, '://') != false){
$link = substr($link, strpos($link,'://') + strlen('://'));
}
//split the url into host (www.example.com) and requested page (index.php) on the first slash
$host = substr($link, 0, strpos($link, '/'));
$request = substr($link, strpos($link, '/'));
//open a socket connection to the site on port 80 (http protocol port)
$fp = @fsockopen($host, 80, $errno, $errstr);
if($fp == false){
$response = $errno . " " . $errstr;
}
else {
//create the request headers
$headers = array();
$headers[] = 'HEAD ' . $request . ' HTTP/1.1';
$headers[] = 'Host: ' . $host;
$headers[] = 'Content-Length: 0';
$headers[] = 'Connection: close';
$headers[] = 'Content-Type: text/html';
$headers = implode("\r\n", $headers) . "\r\n\r\n";
//send our request
if (!fwrite($fp, $headers)) {
fclose($fp);
$response = "Could not access webpage specified.";
}
else {
//read the response
$rsp = '';
while(!feof($fp)) { $rsp .= fgets($fp,8192); }
fclose($fp);
$hunks = explode("\r\n\r\n",trim($rsp));
$headers = explode("\n", $hunks[count($hunks) - 1]);
$response = trim($headers[0]);
}
}
}
?>
<html>
<head>
<title>Test Link</title>
</head>
<body>
<?php if(isset($response)) { echo $response; } ?>
<form method="post">
<label for="link">Link</label>
<input id="link" type="text" name="link" />
</form>
</body>
</html>

61
test/test.php Normal file
View File

@ -0,0 +1,61 @@
<?php
if(isset($_POST['link'])) {
$link = $_POST['link'];
//remove protocol, we're assuming its http
if(strstr($link, '://') != false){
$link = substr($link, strpos($link,'://') + strlen('://'));
}
//split the url into host (www.example.com) and requested page (index.php) on the first slash
$host = substr($link, 0, strpos($link, '/'));
$request = substr($link, strpos($link, '/'));
//open a socket connection to the site on port 80 (http protocol port)
$fp = @fsockopen($host, 80, $errno, $errstr);
if($fp == false){
$response = $errno . " " . $errstr;
}
else {
//create the request headers
$headers = array();
$headers[] = 'HEAD ' . $request . ' HTTP/1.1';
$headers[] = 'Host: ' . $host;
$headers[] = 'Content-Length: 0';
$headers[] = 'Connection: close';
$headers[] = 'Content-Type: text/html';
$headers = implode("\r\n", $headers) . "\r\n\r\n";
//send our request
if (!fwrite($fp, $headers)) {
fclose($fp);
$response = "Could not access webpage specified.";
}
else {
//read the response
$rsp = '';
while(!feof($fp)) { $rsp .= fgets($fp,8192); }
fclose($fp);
/*
$hunks = explode("\r\n\r\n",trim($rsp)); //trennt header vom Body, der Body is dann weg. Nur nötig für Delete.
$headers = explode("\n", $hunks[count($hunks) - 1]);
$response = trim($headers[0]);
*/
$response = $rsp;
}
}
}
?>
<html>
<head>
<title>Test Link</title>
</head>
<body>
<?php if(isset($response)) { echo $response; } ?>
<form method="post">
<label for="link">Link</label>
<input id="link" type="text" name="link" />
</form>
</body>
</html>