~~NOCACHE~~ $s=$_SERVER['REQUEST_URI']; if(strpos($s, '&fbclid')) $s=substr($s, 0, strpos($s, '&fbclid')); $s=explode('?', $s.'?'); $s=urldecode($s[1]); if($s=="") {die;} if(substr($s, 0, 1)=='>') { $s=substr($s, 1); $fullmode=true; } $deacs=deaccent($s); $root='data/pages/'; $pagesfolders=array( 'blog'=>'LAttilaD-blog', 'hungarian'=>'Learn Hungarian', 'kissy'=>'Kissy', 'konyvtar'=>'Könyvtár', 'talema/blog'=>'Talema-blog', ); if($fullmode) foreach($pagesfolders as $folder=>$foldername) { $files=array_diff(scandir($root.$folder), array('.', '..')); foreach($files as $file) { $text=file_get_contents($root.$folder.'/'.$file); if(match(title($text), $deacs) ||($fullmode&&match($text, $s))) { if($foldername!=$prevfoldername) { echo '======= '.$foldername." =======\n"; $prevfoldername=$foldername; } /* echo '{{page>'.str_replace('/', ':', $folder).':'.str_replace('.txt', "", $file)."}}\n----\n";*/ echo ' * [['.str_replace('/', ':', $folder).':'.str_replace('.txt', "", $file)."]]\n"; } } } else foreach($pagesfolders as $folder=>$foldername) { $files=array_diff(scandir($root.$folder), array('.', '..')); foreach($files as $file) if($file==$deacs.'.txt') echo '{{page>'.str_replace('/', ':', $folder).':'.str_replace('.txt', "", $file)."}}\n----\n"; } function match($text, $s) { return strpos(' '.strtolower($text), strtolower($s)); } function title($text) { preg_match('/\[(.*?)\]/', $text, $match); $m=deaccent($match[1]); return $m; } function deaccent($text) { setlocale(LC_ALL, "en_US.UTF-8"); $text = strtolower(iconv('UTF-8', 'US-ASCII/'.'/TRANSLIT', $text)); return $text; }