Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $dir = 'www/posts';
- $exclude = array('.','..','.htaccess');
- $q = (isset($_GET['q']))? strtolower($_GET['q']) : '';
- if (!empty($q)) {
- $res = opendir($dir);
- while(false!== ($file = readdir($res))) {
- if(strpos(strtolower($file),$q)!== false &&!in_array($file,$exclude)) {
- $last_dot_index = strrpos($file, ".");
- $withoutExt = substr($file, 0, $last_dot_index);
- $fpath = 'posts/'.$file;
- if (file_exists($fpath)) {
- echo "<a href='/search.php?post=$withoutExt'>$withoutExt</a>" . " on " . date ("d F Y ", filemtime($fpath)) ;
- echo "<br>";
- }
- }
- }
- closedir($res);
- }
- else {
- echo "";
- }
Add Comment
Please, Sign In to add comment