Guest User

Untitled

a guest
Feb 18th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. $dir = 'www/posts';
  2. $exclude = array('.','..','.htaccess');
  3. $q = (isset($_GET['q']))? strtolower($_GET['q']) : '';
  4. if (!empty($q)) {
  5. $res = opendir($dir);
  6. while(false!== ($file = readdir($res))) {
  7. if(strpos(strtolower($file),$q)!== false &&!in_array($file,$exclude)) {
  8. $last_dot_index = strrpos($file, ".");
  9. $withoutExt = substr($file, 0, $last_dot_index);
  10. $fpath = 'posts/'.$file;
  11. if (file_exists($fpath)) {
  12. echo "<a href='/search.php?post=$withoutExt'>$withoutExt</a>" . " on " . date ("d F Y ", filemtime($fpath)) ;
  13. echo "<br>";
  14. }
  15. }
  16. }
  17. closedir($res);
  18. }
  19. else {
  20. echo "";
  21. }
Add Comment
Please, Sign In to add comment