function getData($searchString) { $newLink = getSubstring($searchString, "a-link-normal a-text-normal", "<a", "href=\"", "\""); $searchString = getXML($newLink); $imgLink = getSubstring($searchString, "imgBlkFront", "<img", "src=\"", "\"", "\""); $price = getSubstring($searchString, "offer-price", "<span", ">", "<", ">"); return array($imgLink, $price); }
function webifyFile($file, $toc, $editions) { $filename = basename($file); if (strpos('-book-', $filename)) { return; } $toc = str_replace('<a href="' . $filename . '">', '<a href="' . $filename . '" class="active">', $toc); $template = file_get_contents(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR . 'page.html'); $title = ''; $content = ''; $prev = ''; $next = ''; if ($filename !== 'index.html') { if (strpos($filename, 'appendixes') === 0) { $type = 'appendix'; } else { if (strpos($filename, 'preface') === 0) { $type = 'preface'; } else { if (strpos($filename, 'pt') === 0) { $type = 'part'; } else { $type = 'chapter'; } } } $buffer = file_get_contents($file); $title = getSubstring($buffer, '<title>', '</title>', FALSE, FALSE); $content = getSubstring($buffer, '<div class="' . $type . '"', '<div class="navfooter">', TRUE, FALSE); $prev = getSubstring($buffer, '<link rel="prev" href="', '" title', FALSE, FALSE); $next = getSubstring($buffer, '<link rel="next" href="', '" title', FALSE, FALSE); if (!empty($prev)) { $prev = '<a accesskey="p" href="' . $prev . '">Prev</a>'; } if (!empty($next)) { $next = '<a accesskey="n" href="' . $next . '">Next</a>'; } } else { $buffer = file_get_contents($file); $title = getSubstring($buffer, '<title>', '</title>', FALSE, FALSE); // $content = getSubstring($buffer, '<div class="titlepage"', '<div class="navfooter">', TRUE, FALSE); $content = getSubstring($buffer, '<div class="titlepage"', '<hr>', TRUE, FALSE) . "\n</div>\n"; $prev = ''; $next = getSubstring($buffer, '<link rel="next" href="', '" title', FALSE, FALSE); if (!empty($next)) { $next = '<a accesskey="n" href="' . $next . '">Next</a>'; } } $buffer = str_replace(array('{title}', '{content}', '{toc}', '{editions}', '{prev}', '{next}'), array($title, $content, $toc, $editions, $prev, $next), $template); if (function_exists('tidy_repair_string')) { $buffer = tidy_repair_string($buffer, array('indent' => TRUE, 'output-xhtml' => TRUE, 'wrap' => 0), 'utf8'); } file_put_contents($file, $buffer); }
function getWidth($style) { return getSubstring($style, "width: "); }
<html> <form> Feed meh sum ISBN!!! <input type="text" name="key" /> <br/> <input type="submit" /> </form> <?php include 'book-puller.php'; if (isset($_GET["key"])) { $keyword = $_GET["key"]; $theUrl = "http://www.amazon.com/s/keywords={$keyword}"; $searchString = getXML($theUrl); $newLink = getSubstring($searchString, "a-link-normal a-text-normal", "<a", "href=\"", "\""); $searchString = getXML($newLink); $imgLink = getSubstring($searchString, "imgBlkFront", "<img", "src=\"", "\"", "\""); $bookTittle = getSubstring($searchString, "productTitle", "<span", ">", "<", ">"); $author = getSubstring($searchString, "contributorNameID", "<a", ">", "<", ">"); echo "BLEH!<br/><br/>"; echo "<img src=\"{$imgLink}\" /><br/>"; echo "<h1>Title: {$bookTittle}</h1>"; echo "<p>Author: {$author}</p>"; } ?> </html>