it works! (findKatalog)
This commit is contained in:
parent
9069b58ae2
commit
cbcc2d9217
5 changed files with 204 additions and 81 deletions
61
add.php
Normal file
61
add.php
Normal file
|
@ -0,0 +1,61 @@
|
|||
<?php
|
||||
if(isset($_GET['test'])) {
|
||||
$link = "https://localhost:5000/api/katalog/42";
|
||||
|
||||
//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 $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">
|
||||
<input type="submit" name="list">
|
||||
</form>
|
||||
<button method= "get" type="button" name="test">Don't!!</button>
|
||||
</body>
|
||||
</html>
|
|
@ -14,7 +14,7 @@
|
|||
?>
|
||||
|
||||
<?php
|
||||
fsockopen('www.google.com', 80);
|
||||
/*fsockopen('www.google.com', 80);
|
||||
|
||||
//Zugriff auf API
|
||||
if(isset($_POST["go"]))
|
||||
|
@ -42,7 +42,7 @@
|
|||
// 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);
|
||||
}
|
||||
}*/
|
||||
?>
|
||||
|
||||
<?php /*
|
||||
|
@ -64,6 +64,42 @@
|
|||
}*/
|
||||
?>
|
||||
|
||||
<?php
|
||||
if(isset($_POST["go"]))
|
||||
{
|
||||
|
||||
$url = 'localhost:5000/api/katalog';
|
||||
$form = array(
|
||||
"Title"=>$_POST["Title"],
|
||||
"Author"=>$_POST["Author"],
|
||||
"Country"=>$_POST["Country"],
|
||||
"Link"=>$_POST["Link"],
|
||||
"Language"=>$_POST["Language"],
|
||||
"Pages"=>$_POST["Pages"],
|
||||
"Year"=>$_POST["Year"],
|
||||
"LendTime"=>$_POST["LendTime"],
|
||||
"Category"=>$_POST["Category"],
|
||||
"ImageLink"=>$_POST["ImageLink"],
|
||||
"LendType"=>$_POST["LendType"]);
|
||||
$json = json_encode($form);
|
||||
$data = $form;
|
||||
|
||||
// use key 'http' even if you send the request to https://...
|
||||
$options = array(
|
||||
'http' => array(
|
||||
'header' => "Content-type: application/json\r\n",
|
||||
'method' => 'POST',
|
||||
'content' => http_build_query($data),
|
||||
),
|
||||
);
|
||||
$context = stream_context_create($options);
|
||||
//echo $context;
|
||||
$result = file_get_contents('http://localhost:5000/api/katalog/');
|
||||
echo $result;
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
|
@ -96,7 +132,7 @@
|
|||
</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">
|
||||
<select class="input" name="LendType">
|
||||
<option>Physical</option>
|
||||
<option>Virtual</option>
|
||||
</select>
|
||||
|
|
|
@ -1,76 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Katalog</title>
|
||||
<link rel="stylesheet" type="text/css" href="scss/style.css" media="screen" />
|
||||
</head>
|
||||
<body>
|
||||
<div class="Titel">
|
||||
<a href="index.html"><button id= "zurueck">zurück</button></a>
|
||||
<h1>Katalog</h1>
|
||||
</div>
|
||||
<div class="Eingabe">
|
||||
<h2>Eingabe</h2>
|
||||
<form action="catalogue_search.php">
|
||||
<input type="number" name="ProductId" class="input" placeholder="Geben Sie die gesuchte ProduktId an" min= "0">
|
||||
<input type="submit" name="go" id="go">
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div class="Ausgabe">
|
||||
<h2>Ausgabe</h2>
|
||||
<table>
|
||||
<tr>
|
||||
<td class ="fix">ProductId</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="fix">Titel</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="fix">Autor</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="fix">Erscheinungsland</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="fix">Link</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="fix">Sprache</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="fix">Seitenzahl</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="fix">Erscheinungsjahr</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="fix">Kategorie</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="fix">Bildlink</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="fix">Verleihdauer</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="fix">Verleihart</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
102
findKatalog.php
Normal file
102
findKatalog.php
Normal file
|
@ -0,0 +1,102 @@
|
|||
<?php
|
||||
if(isset($_POST["go"]))
|
||||
{
|
||||
|
||||
$url = 'localhost:5000/api/katalog';
|
||||
|
||||
|
||||
// use key 'http' even if you send the request to https://...
|
||||
$options = array(
|
||||
'http' => array(
|
||||
'header' => "Content-type: application/json\r\n",
|
||||
'method' => 'POST'
|
||||
),
|
||||
);
|
||||
$context = stream_context_create($options);
|
||||
//echo $context;
|
||||
$id= $_POST["ProductId"];
|
||||
$result = file_get_contents('http://localhost:5000/api/katalog/'.$id);
|
||||
//echo $result;
|
||||
$json= json_decode($result, true);
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Katalog</title>
|
||||
<link rel="stylesheet" type="text/css" href="scss/style.css" media="screen" />
|
||||
</head>
|
||||
<body>
|
||||
<div class="Titel">
|
||||
<a href="index.html"><button id= "zurueck">zurück</button></a>
|
||||
<h1>Katalog</h1>
|
||||
</div>
|
||||
<div class="Eingabe">
|
||||
<h2>Eingabe</h2>
|
||||
<form method="post">
|
||||
<input type="number" name="ProductId" class="input" placeholder="Geben Sie die gesuchte ProduktId an" min= "1" required>
|
||||
<input type="submit" name="go" id="go">
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div class="Ausgabe">
|
||||
<h2>Ausgabe</h2>
|
||||
<table>
|
||||
<tr>
|
||||
<td class ="fix">ProductId</td>
|
||||
<td><?php if(isset($_POST["go"])) echo $json['productId']; ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="fix">Titel</td>
|
||||
<td><?php if(isset($_POST["go"])) echo $json['title']; ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="fix">Autor</td>
|
||||
<td><?php if(isset($_POST["go"])) echo $json['author']; ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="fix">Erscheinungsland</td>
|
||||
<td><?php if(isset($_POST["go"])) echo $json['country']; ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="fix">Link</td>
|
||||
<td><?php if(isset($_POST["go"])) echo $json['link']; ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="fix">Sprache</td>
|
||||
<td><?php if(isset($_POST["go"])) echo $json['language']; ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="fix">Seitenzahl</td>
|
||||
<td><?php if(isset($_POST["go"])) echo $json['pages']; ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="fix">Erscheinungsjahr</td>
|
||||
<td><?php if(isset($_POST["go"])) echo $json['year']; ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="fix">Kategorie</td>
|
||||
<td><?php if(isset($_POST["go"])) echo $json['category']; ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="fix">Bildlink</td>
|
||||
<td><?php if(isset($_POST["go"])) echo $json['imageLink']; ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="fix">Verleihdauer</td>
|
||||
<td><?php if(isset($_POST["go"])) echo $json['lendTime']; ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="fix">Verleihart</td>
|
||||
<td><?php if(isset($_POST["go"])) echo $json['lendType']; ?></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
|
@ -19,8 +19,8 @@
|
|||
|
||||
<select name="selection" id="selection" onchange="location.assign(this.value);">
|
||||
<option></option>
|
||||
<option value=findKatalog.htm>Finden</option>
|
||||
<Option value="addKatalog.htm">Hinzufügen</Option>
|
||||
<option value=findKatalog.php>Finden</option>
|
||||
<Option value="addKatalog.php">Hinzufügen</Option>
|
||||
<option value="changeKatalog.htm">Bearbeiten</option>
|
||||
<option value="deleteKatalog.htm">Löschen</option>
|
||||
</select>
|
||||
|
|
Loading…
Reference in a new issue