did some phps.
This commit is contained in:
parent
0a7d3c1f1f
commit
a6dbfbdc7f
8 changed files with 355 additions and 8 deletions
37
php/addKatalog.php
Normal file
37
php/addKatalog.php
Normal 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>
|
|
@ -18,10 +18,10 @@
|
||||||
<label for="choices">Katalog</label>
|
<label for="choices">Katalog</label>
|
||||||
</dt>
|
</dt>
|
||||||
<dd>
|
<dd>
|
||||||
<select name="selection" id="selection" onchange="location.assign(this.value);">
|
<select name="selection1" id="selection" onchange="this.form.submit()">
|
||||||
<option></option>
|
<option></option>
|
||||||
<option value=findKatalog.htm>Finden</option>
|
<option value=findKatalog.htm>Finden</option>
|
||||||
<Option value="addKatalog.htm">Hinzufügen</Option>
|
<Option value="addKatalog.php">Hinzufügen</Option>
|
||||||
<option value="changeKatalog.htm">Bearbeiten</option>
|
<option value="changeKatalog.htm">Bearbeiten</option>
|
||||||
<option value="deleteKatalog.htm">Löschen</option>
|
<option value="deleteKatalog.htm">Löschen</option>
|
||||||
</select>
|
</select>
|
||||||
|
@ -30,7 +30,7 @@
|
||||||
<label for="choices">Inventar</label>
|
<label for="choices">Inventar</label>
|
||||||
</dt>
|
</dt>
|
||||||
<dd>
|
<dd>
|
||||||
<select name="selection" id="selection" onchange="location.assign(this.value);">
|
<select name="selection2" id="selection" onchange="location.assign(this.value);">
|
||||||
<option></option>
|
<option></option>
|
||||||
<option value=findInventar.htm>Finden</option>
|
<option value=findInventar.htm>Finden</option>
|
||||||
<Option value="addInventar.htm">Hinzufügen</Option>
|
<Option value="addInventar.htm">Hinzufügen</Option>
|
||||||
|
@ -41,7 +41,7 @@
|
||||||
<label for="choices">Verleihvorgang</label>
|
<label for="choices">Verleihvorgang</label>
|
||||||
</dt>
|
</dt>
|
||||||
<dd>
|
<dd>
|
||||||
<select name="selection" id="selection" onchange="location.assign(this.value);">
|
<select name="selection3" id="selection" onchange="location.assign(this.value);">
|
||||||
<option></option>
|
<option></option>
|
||||||
<option value=findVerleih.htm>Finden</option>
|
<option value=findVerleih.htm>Finden</option>
|
||||||
<Option value="addVerleih.htm">Hinzufügen</Option>
|
<Option value="addVerleih.htm">Hinzufügen</Option>
|
||||||
|
@ -53,8 +53,22 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="Eingabe"><!--Das wird der Inhaltsbereich. Zweigeteilt und leer.-->
|
<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.-->
|
<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($selection != "")
|
<?php
|
||||||
include "$selection";
|
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 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.-->
|
<div><!--Der Ausgabebereich. Taucht auf, sobald im Eingabebereich ein http-request gesendet wurde. Inhalt ist der Response. Größe von Anfang an 3/5.-->
|
||||||
|
@ -63,8 +77,8 @@
|
||||||
?>
|
?>
|
||||||
</div>
|
</div>
|
||||||
<div><!--Response Konsole. -->
|
<div><!--Response Konsole. -->
|
||||||
<textarea cols="30" rows="10" readonly style="overflow-y:scroll">
|
<textarea cols="30" rows="10" readonly>
|
||||||
<?php $status?>
|
<?php echo $selection?>
|
||||||
</textarea>
|
</textarea>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
61
php/katalog/add.php
Normal file
61
php/katalog/add.php
Normal 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/find.php
Normal file
58
php/katalog/find.php
Normal 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
58
php/katalog/list.php
Normal 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
58
php/katalog/remove.php
Normal 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
61
test/test.php
Normal 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>
|
Loading…
Reference in a new issue