function deleteBook($index) { $books = getBooks(); if (!isset($books[$index])) { return false; } unset($books[$index]); return saveBooks($books); }
<?php $books = getBooks(); $authors = getAuthors(); ?> <div class="container"> <h2> Libri presenti </h2> <table class="tableAuthor" id="tableAuthor"> <thead> <th> Id Libro </th> <th> Titolo </th> <th> ISBN </th> <th colspan="2"> Autore </th> <th> N.Pagine </th> <th> Disponibilità </th> <th> Prezzo
$book_id = $dbConn->lastInsertId(); // Add book categories. foreach ($_POST['categories'] as $category_id) { $sql = "INSERT INTO book_categories (book_id, category_id) \n VALUES (:book_id, :category_id);"; $stmt = $dbConn->prepare($sql); $stmt->execute(array(":book_id" => $book_id, ":category_id" => $category_id)); } $book_added = true; } /* Check for form submission for filtering results. If submitted, filter results by category. */ $min_set = isset($_POST['filter_min_date']) && !empty($_POST['filter_min_date']); $max_set = isset($_POST['filter_max_date']) && !empty($_POST['filter_max_date']); $book_list = getBooks(); if (isset($_POST['filter_submit']) && !empty($_POST['filter'])) { $new_list = implode(", ", $_POST['filter']); $sql = "SELECT books.*,\n authors.name AS author, \n publishers.name AS publisher\n FROM books\n LEFT JOIN authors ON authors.id = books.author_id\n LEFT JOIN publishers ON publishers.id = books.publisher_id\n INNER JOIN book_categories ON books.id = book_categories.book_id \n INNER JOIN categories ON categories.id = book_categories.category_id\n WHERE categories.id IN (" . $new_list . ");"; $stmt = $dbConn->prepare($sql); $stmt->execute(); $book_list = $stmt->fetchAll(); } elseif (isset($_POST['filter_author_submit']) && isset($_POST['filter_author'])) { $sql = "SELECT books.*,\n authors.name AS author, \n publishers.name AS publisher\n FROM books\n LEFT JOIN authors ON authors.id = books.author_id\n LEFT JOIN publishers ON publishers.id = books.publisher_id\n WHERE " . $_POST['filter_author'] . " = books.author_id;"; $stmt = $dbConn->prepare($sql); $stmt->execute(); $book_list = $stmt->fetchAll(); } elseif (isset($_POST['filter_date_submit']) && ($min_set == true || $max_set == true)) { $condition = ""; if ($min_set && $max_set) { $condition = "WHERE books.release_date > '" . $_POST['filter_min_date'] . "' AND books.release_date < '" . $_POST['filter_max_date'] . "'";
function createXmlFromPersons($persons) { $count = 0; foreach ($persons as $person) { $persObj = new Person(); if (property_exists($person, "preferredName")) { $persObj->name = $person->preferredName; } else { continue; } $path = "collectedData/" . $persObj->name . ".xml"; if (file_exists($path)) { continue; } if (property_exists($person, "variantName")) { $persObj->variantName = $person->variantName; } if (property_exists($person, "thumbnail")) { $persObj->thumbnail = $person->thumbnail; } else { continue; } if (property_exists($person, "dateOfBirth_en")) { $persObj->birthEN = $person->dateOfBirth_en; } if (property_exists($person, "dateOfBirth_de")) { $persObj->birthDE = $person->dateOfBirth_de; } if (property_exists($person, "dateOfDeath_en")) { $persObj->deathEN = $person->dateOfDeath_en; } if (property_exists($person, "dateOfDeath_de")) { $persObj->deathDE = $person->dateOfDeath_de; } if (property_exists($person, "placeOfBirth")) { $persObj->birthPlace = $person->placeOfBirth; } if (property_exists($person, "placeOfDeath")) { $persObj->deathPlace = $person->placeOfDeath; } if (property_exists($person, "professionOrOccupation")) { $persObj->professionOrOccupation = $person->professionOrOccupation; } $metadata = getPersonMetaData($persObj->name); if ($metadata == null) { continue; } $persObj->dbpResource = $metadata->person->value; $persObj->abstract = $metadata->abstract->value; $persObj->wikilink = $metadata->wikilink->value; $persObj->artworks = getArtworks($persObj->wikilink); $persObj->buildings = getBuildings($persObj->dbpResource); $persObj->books = getBooks($persObj->dbpResource); $xml = obj_to_xml($persObj); if ($xml != null) { $file = fopen($path, "w"); fwrite($file, $xml); fclose($file); } else { continue; } $GLOBALS['personCount']++; $GLOBALS['artworkCount'] += count($persObj->artworks); $GLOBALS['buildingCount'] += count($persObj->buildings); $GLOBALS['bookCount'] += count($persObj->books); } }
$dueKeys[] = $key; } //Echo the items to screen in date order. rewind($fp); foreach($dueKeys as $value) { while(!feof($fp)) { $line = fgets($fp); $element = split("\|", $line); if(strcmp(trim($element[0]), trim($value)) == 0) { echoLine($element); } } rewind($fp); } } getBooks(); ?> </table> </body> </html>
</li> <li> <a href="/lesuirely/php_pages/book.php?tag=cultural">cultural-studies</a> </li> <li> <a href="/lesuirely/php_pages/book.php">All Categories</a> </li> </ul> </div> <div class="right"> <table> <?php $itempage = 1; $tag = ''; $people = ''; $jsonData = getBooks($itempage, $tag, $people); $json = json_decode($jsonData); ?> <tr class="movie"> <?php $count = 0; for ($i = 0; $i < count($json); $i++) { $data = $json[$i]; if ($count < 4) { $count++; ?> <td class="item center"><img class="book" src = "<?php echo $data->imgurl; ?> "><h5><a name="<?php echo $data->id;
session_destroy(); header('Location: login.php'); die; } ?> <html> <head> <title>Hallo <?php echo getTeamName($_SESSION['user_id']); ?> </title> </head> <body> <?php echo getTeamName($_SESSION['user_id']); $books = getBooks($_SESSION['user_id']); ?> <form method="post" action="welcome.php"> <table> <tr><td> <select name="book"> <?php foreach ($books as $book) { ?> <option> <?php echo $book['name']; ?> </option> <?php }
case 'Save': if ($_SESSION['table'] == 'book') { newBook(); } if ($_SESSION['table'] == 'category') { newCategory(); } header("Location: http://" . $_SERVER['HTTP_HOST'] . "/"); exit; } } if (!$_SESSION['user_id']) { $error['{ERROR}'] = isset($_SESSION['error_login']) ? "<font color='#a52a2a'>" . $_SESSION['error_login'] . "</font>" : ""; $params['{LOGIN}'] = getTpl("login", $error); login(); } else { $userName = getUserName(); $params['{LOGIN}'] = "<p id=\"logout\">You enter as: " . $userName . "<br><a href=\"?logout\"> logout</a></p>"; } if (isset($_GET['category'])) { $_SESSION['table'] = 'category'; } if (isset($_GET['book'])) { $_SESSION['table'] = 'book'; } if (isset($_SESSION['table'])) { $params['{CONTENT}'] = $_SESSION['table'] == 'category' ? getCategory() : getBooks(); } else { $params['{CONTENT}'] = getBooks(); } echo getTpl("main", $params);
<?php $id = "113720634485746776434"; $shelf = "3"; $maxResults = 10; getShelves($id); getBooks($id, $shelf, $maxResults); function getShelves($id) { $url = "https://www.googleapis.com/books/v1/users/" . $id . "/bookshelves/"; // Set up cURL $ch = curl_init(); // Set the URL curl_setopt($ch, CURLOPT_URL, $url); // don't verify SSL certificate curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); // Return the contents of the response as a string curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // Follow redirects curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); // Do the request $json = curl_exec($ch); curl_close($ch); $bookshelves = json_decode($json); foreach ($bookshelves->items as $bookshelf) { //var_dump($bookshelf); if (!empty($bookshelf)) { $results[] = array('id' => $bookshelf->id, 'title' => $bookshelf->title); } } echo "<select>";