Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <link rel="stylesheet" type="text/css" href="css.css" />
- </head>
- <body>
- <form action="str.php" method="POST">
- <ul>
- <li><input type="text" name="keyword" placeholder="Jouw zoekterm" /></li>
- <li><input type="submit" name="submit" value="Zoek" /></li>
- </ul>
- </form>
- <br />
- <br />
- </body>
- </html>
- <?php
- if(isset($_POST['submit']))
- {
- $path = '../search';
- $findThisString = $_POST['keyword'];
- $dir = dir($path);
- // Get next file/dir name in directory
- if(empty($findThisString) == true)
- {
- echo "<hr>";
- echo "Jouw zoekveld is leeg!! <br>";
- }
- else
- {
- {
- while (false !== ($file = $dir->read()))
- {
- if ($file != '.' && $file != '..')
- {
- // Is this entry a file or directory?
- if (is_file($path . '/' . $file))
- {
- // Its a file, yay! Lets get the file's contents
- $data = file_get_contents($path . '/' . $file);
- // Is the str in the data (case-insensitive search)
- if (stripos($data, $findThisString) !== false)
- {
- // sw00t! we have a match
- echo "<div id='sfield'><h3>Zoekterm: ".$findThisString."</h3>";
- echo "Gevonden in <a href='".$file."' target='new'>" . $file . "</a><br>\n</div>";
- }
- }
- }
- }
- echo "<hr>";
- /*$filearr = array($fdata[] = 'filevalue');
- $fdata = file_get_contents($file);
- $pattern = preg_quote($findThisString, '/');
- $pattern = "/^.*$pattern.*\$/m";
- if(preg_match_all($pattern, $fdata, $matchs[] = 'filename'))
- {
- echo "Gevonden zoektermen <br>";
- echo implode("<br>", $matchs['filename']."<b>".$findThisString."<b><br>");
- echo "Gevonden zoeklinks: <a href='".$fdata."' target='new'>".$filearr['filevalue']."</a>";
- }
- else
- {
- echo "Geen match gevonden!!";
- }*/
- }
- }
- $lines = file($dir);
- $find = false;
- foreach($lines as $line)
- {
- if(strpos($lines, $findThisString) !== false)
- {
- $find = true;
- echo $line;
- }
- }
- if(!$find)
- {
- echo "Geen match gevonden!!";
- }
- closedir($dir); #This is meant to close the connection with the database!!
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement