137 行
3.5 KiB
PHP
137 行
3.5 KiB
PHP
<?php
|
||
//直接アクセスしちゃだめ
|
||
require $d_root.'/hide_php/conf/c.php';
|
||
require $d_root.'/hide_php/conf/bbs.php';
|
||
$bbs_dir = $d_root.'/sqlike/bbs';
|
||
|
||
|
||
|
||
//表示調整
|
||
if (isset($_GET['q'])){
|
||
$w = h($_GET['q']);
|
||
} else {
|
||
$w = '';
|
||
}
|
||
|
||
$thread_count = 0;
|
||
if (isset($_GET['Split'])){
|
||
$split_len = (int)$_GET['Split'];
|
||
} else {
|
||
$split_len = 30;
|
||
}
|
||
if ($split_len < 1){
|
||
$split_len = 1;
|
||
}
|
||
|
||
if (isset($_GET['View']) && !empty($_GET['View'])){
|
||
$view_list = (int)$_GET['View'];
|
||
} else {
|
||
$view_list = 1;
|
||
}
|
||
if ($view_list < 1){
|
||
$view_list = 1;
|
||
}
|
||
|
||
$start = ($view_list -1) * $split_len;
|
||
$end = $start + $split_len;
|
||
|
||
|
||
|
||
#########html開始
|
||
$html_file = $d_root.'/sqlike/html/form/search.html';
|
||
if (file_exists($html_file)){
|
||
$html = explode('{RESULT}', file_get_contents($html_file));
|
||
} else {
|
||
not_found();
|
||
}
|
||
html_head('検索-', '', $d_root.'/sqlike/css/form/bbs.css', true);
|
||
|
||
foreach (['{SEARCH_WORD}' => $w, '{SPLIT_LEN}' => $split_len] as $point => $replace){
|
||
$html[0] = str_replace($point, $replace, $html[0]);
|
||
}
|
||
echo $html[0];
|
||
unset($html[0]);
|
||
|
||
|
||
//頑張って並び替える
|
||
$comment_list = [];
|
||
$fols = scandir($bbs_dir);
|
||
foreach ($fols as $b){
|
||
if (preg_match('/^[0-9]+$/', $b) === 1){
|
||
|
||
if ($b < 200){
|
||
$b_data = get($bbs_dir.'/boards.txt', $b);
|
||
} else {
|
||
$b_data = get($bbs_dir.'/user_board/'.$b.'.txt', 1);
|
||
}
|
||
if (($b_data === false) || empty($b_data)){
|
||
continue;
|
||
}
|
||
if (explode("'", $b_data)[3] !== ''){
|
||
continue;
|
||
}
|
||
|
||
$thread_files = scandir($bbs_dir.'/'.$b);
|
||
foreach ($thread_files as $thread_file){
|
||
if (preg_match('/^[0-9]+\.txt$/', $thread_file) === 1){
|
||
$thread_title = get($bbs_dir.'/'.$b.'/'.$thread_file, 1);
|
||
$rows = get_rows($bbs_dir.'/'.$b.'/'.$thread_file, 2);
|
||
foreach ($rows as $row){
|
||
$d = explode("'", $row);
|
||
$t = str_replace('.txt', '', $thread_file);
|
||
$c_id = $d[0] +1;
|
||
$comment_list[preg_replace('/(年|月|日|時|分| | )/', '', $d[3]).'.'.$b.$t.$d[0]] = [$b, $t, $c_id, $thread_title];
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
krsort($comment_list, SORT_NUMERIC);
|
||
|
||
|
||
//頑張って一つずつ出力
|
||
//これは配列の配列の配列
|
||
foreach ($comment_list as $date => $areas){
|
||
if ($areas[0] >= 10){
|
||
$area = $areas[0].'-'.$areas[1];
|
||
} else {
|
||
$area = $areas[0].$areas[1];
|
||
}
|
||
$thread_file = $bbs_dir.'/'.$areas[0].'/'.$areas[1].'.txt';
|
||
$comment = get($thread_file, $areas[2]);
|
||
$td = explode("'", $comment);
|
||
if ((stripos($areas[3], $w) !== false) || (stripos($td[1], $w) !== false) || (stripos($td[5], $w) !== false)){
|
||
if (($thread_count >= $start) && ($thread_count < $end)){
|
||
view_comment($td, '<a href="/thread.php?Area='.$area.'#'.$td[0].'">'.$areas[3].'</a> - ', '');
|
||
}
|
||
++$thread_count;
|
||
}
|
||
}
|
||
|
||
echo '<p style="position:absolute;top:0;">'.$thread_count.'件が該当します。</p>';
|
||
|
||
//ページ分けしないといけない場合
|
||
if ($thread_count > $split_len){
|
||
echo '<p><br></p><p>複数ページに分けられました。</p><p><br></p>';
|
||
if ($start === 0){
|
||
echo '<span class="split" style="background:transparent;color:#000;">1</span>';
|
||
} else {
|
||
echo '<a href="/search.php?q='.$w.'&Split='.$split_len.'" class="split">1</a>';
|
||
}
|
||
$split = 0;
|
||
$split_count = 2;
|
||
while ($split + $split_len < $thread_count){
|
||
if ($end / $split_len === $split_count){
|
||
echo ' <span class="split" style="background:transparent;color:#000;">'.$split_count.'</span>';
|
||
} else {
|
||
echo ' <a href="/search.php?q='.$w.'&Split='.$split_len.'&View='.$split_count.'" class="split">'.$split_count.'</a>';
|
||
}
|
||
$split = $split + $split_len;
|
||
$split_count++;
|
||
}
|
||
}
|
||
|
||
echo $html[1];
|
||
|
||
html_foot('', '');
|