Skip to content

Instantly share code, notes, and snippets.

@polprog
Created January 6, 2022 12:14
Show Gist options
  • Save polprog/b86a6658e7e4797471e1899f48557945 to your computer and use it in GitHub Desktop.
Save polprog/b86a6658e7e4797471e1899f48557945 to your computer and use it in GitHub Desktop.
/* PDFsearch - PDF indexing script
This script will search and generate a list of links for matching filenames inside a
given directory in the WWW root. Change the target directory inside the exec() call.
polrog, rue_mohr 2022
*/
<html>
<head>
<title>Datasheet Search Results</title>
<style type="text/css">
.result {
line-height: 1.5;
padding-left: 10px;
padding-right: 10px;
font-size: 125%;
font-family: monospace;
}
.result:nth-of-type(odd){
background-color: #eee;
}
input[type=text]{
border:none;
border-bottom: 1px solid black;
font-family: monospace; font-size: 150%;
}
input[type=submit] {
border: 1px solid black;
padding-top: 5px;
padding-bottom: 5px;
}
</style>
</head>
<body>
<h3>PDF Search</h3>
<a href="/">up...</a>
<form name="input" action="pdfsearch.php" method="get">
<?php
echo 'Filename Keyword: <input type="text" name="pn" value="'.$_GET["pn"].'">';
?>
<input type="submit" value="Search">
</form>
<?php
if(isset($_GET['pn'])){
$partNum = escapeshellarg("*".$_GET['pn']."*.pdf");
print("<br>********** SEARCH RESULTS FOR: <b>".$_GET['pn']."</b> **********<br><br>");
exec("find ./kartykat/ -ipath ".$partNum, $retval);
if (!$retval) {
printf("<span class=\"result\">I dunt found you nun result, master. :-(</span><br>");
} else {
foreach($retval as $line) {
$link = $line;
print("<a target=\"_blank\" class=\"result\" href=\"$link\">".$line."</a><br>");
}
}
echo "<br>********** END OF RESULTS ********** <br>";
?>
<br>
<form name="input" action="pdfsearch.php" method="get">
<?php
echo('Filename Keyword: <input type="text" name="pn" value="'.$_GET["pn"].'">');
?>
<input type="submit" value="Search">
</form>
<?php }
?>
<a href="./kartykat/">Dir listing...</a><br><br>
Search external services:<br>
<?php
echo "<a target=\"_blank\" href=\"https://www.digchip.com/datasheets/search.php?pn=".$_GET["pn"]."\"> DIGCHIP </a><br>";
echo "<a target=\"_blank\" href=\"https://www.alldatasheet.com/view.jsp?Searchword=".$_GET["pn"]."\"> AllDatasheet.com </a><br>";
echo "<a target=\"_blank\" href=\"http://search.datasheetcatalog.net/key/".$_GET["pn"]."\"> Datasheetcatalog.net </a>";
?>
<br>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment