This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
start [2021.12.16., 22:06] lattilad |
start [2022.01.05., 20:22] (current) |
||
---|---|---|---|
Line 2: | Line 2: | ||
<phpwikify> | <phpwikify> | ||
$s=$_SERVER['REQUEST_URI']; | $s=$_SERVER['REQUEST_URI']; | ||
+ | if(strpos($s, '&fbclid')) | ||
+ | $s=substr($s, 0, strpos($s, '&fbclid')); | ||
$s=explode('?', $s.'?'); | $s=explode('?', $s.'?'); | ||
$s=urldecode($s[1]); | $s=urldecode($s[1]); | ||
if($s=="") {die;} | if($s=="") {die;} | ||
- | |||
- | echo $s."\n"; | ||
if(substr($s, 0, 1)=='>') | if(substr($s, 0, 1)=='>') | ||
Line 13: | Line 13: | ||
$fullmode=true; | $fullmode=true; | ||
} | } | ||
+ | |||
+ | $deacs=deaccent($s); | ||
$root='data/pages/'; | $root='data/pages/'; | ||
Line 23: | Line 25: | ||
); | ); | ||
- | foreach($pagesfolders as $folder=>$foldername) | + | 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); | + | $files=array_diff(scandir($root.$folder), array('.', '..')); |
- | if(match(title($text), $s) | + | foreach($files as $file) |
- | ||($fullmode&&match($text, $s))) | + | { |
- | { | + | $text=file_get_contents($root.$folder.'/'.$file); |
- | if($foldername!=$prevfoldername) | + | if(match(title($text), $deacs) |
+ | ||($fullmode&&match($text, $s))) | ||
{ | { | ||
- | echo '======= '.$foldername." =======\n"; | + | if($foldername!=$prevfoldername) |
- | $prevfoldername=$foldername; | + | { |
+ | 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"; | echo '{{page>'.str_replace('/', ':', $folder).':'.str_replace('.txt', "", $file)."}}\n----\n"; | ||
- | } | ||
} | } | ||
- | } | + | |
function match($text, $s) | function match($text, $s) | ||
{ | { | ||
- | return strpos(strtolower($text), strtolower($s)); | + | return strpos(' '.strtolower($text), strtolower($s)); |
} | } | ||
function title($text) | function title($text) | ||
{ | { | ||
preg_match('/\[(.*?)\]/', $text, $match); | preg_match('/\[(.*?)\]/', $text, $match); | ||
- | $m=preg_replace('/&([a-z]{1,2})(acute|cedil|circ|grave|lig|orn|ring|slash|th|tilde|uml|caron);/i','$1',htmlentities($match[1])); | + | $m=deaccent($match[1]); |
- | echo $m."\n"; | + | |
return $m; | return $m; | ||
+ | } | ||
+ | function deaccent($text) | ||
+ | { | ||
+ | setlocale(LC_ALL, "en_US.UTF-8"); | ||
+ | $text = strtolower(iconv('UTF-8', 'US-ASCII/'.'/TRANSLIT', $text)); | ||
+ | return $text; | ||
} | } | ||
</phpwikify> | </phpwikify> | ||