/** * ページ遷移用のHTML要素を取得する */ function get_read_jump(ThreadRead $aThread, $label, $use_onchange) { global $_conf; $resFilter = ResFilter::getFilter(); if ($resFilter && $resFilter->hasWord()) { $jump = _get_read_jump_filter($aThread, $resFilter, $use_onchange); } else { $jump = _get_read_jump($aThread, $use_onchange); } if ($use_onchange) { return $jump; } else { return "<form method=\"get\" action=\"{$_conf['read_php']}\" accept-charset=\"{$_conf['accept_charset']}\">{$label}{$jump}</form>"; } }
function _read_filter_setup() { $host = $_GET['host']; $bbs = $_GET['bbs']; $key = $_GET['key']; $resnum = (int) $_GET['resnum']; $field = $_GET['field']; $aThread = new ThreadRead(); $aThread->setThreadPathInfo($host, $bbs, $key); $aThread->readDat($aThread->keydat); $i = $resnum - 1; if (!($i >= 0 && $i < count($aThread->datlines) && isset($_GET['rf']) && is_array($_GET['rf']))) { P2Util::pushInfoHtml('<p>フィルタリングの指定が変です。</p>'); unset($_GET['rf'], $_REQUEST['rf']); return; } $ares = $aThread->datlines[$i]; $resar = $aThread->explodeDatLine($ares); $name = $resar[0]; $mail = $resar[1]; $date_id = $resar[2]; $msg = $resar[3]; $params = $_GET['rf']; $include = ResFilter::INCLUDE_NONE; $fields = explode(':', $field); $field = array_shift($fields); if (in_array('refs', $fields)) { $include |= ResFilter::INCLUDE_REFERENCES; } if (in_array('refed', $fields)) { $include |= ResFilter::INCLUDE_REFERENCED; } $params['field'] = $field; $params['include'] = $include; $resFilter = ResFilter::configure($params); $target = $resFilter->getTarget($ares, $resnum, $name, $mail, $date_id, $msg); if ($field == 'date') { $date_part = explode(' ', trim($target)); $word = $date_part[0]; } else { $word = $target; } $params['word'] = $word; $_REQUEST['rf'] = $params; }
/** * DatをHTMLに変換して表示する * * @param bool $capture trueなら変換結果を出力せずに返す * @param bool $is_fragment trueなら<div class="thread"></div>で囲まない * @return bool|string */ public function datToHtml($capture = false, $is_fragment = false) { global $_conf, $filter_hits, $last_hit_resnum; $aThread = $this->thread; // 表示レス範囲が指定されていなければ if (!$aThread->resrange) { $error = '<p><b>p2 error: {$this->resrange} is FALSE at datToHtml()</b></p>'; if ($capture) { return $error; } else { echo $error; return false; } } $start = $aThread->resrange['start']; $to = $aThread->resrange['to']; $nofirst = $aThread->resrange['nofirst']; $is_ktai = $_conf['ktai']; $resFilter = ResFilter::getFilter(); if ($resFilter && $resFilter->hasWord()) { $do_filtering = true; $nofirst = true; } else { $do_filtering = false; } $datlines = $aThread->datlines; $count = count($datlines); $buf['body'] = $is_fragment ? '' : "<div class=\"thread\">\n"; $buf['q'] = ''; // まず 1 を表示 if (!$nofirst) { $res = $this->transRes($datlines[0], 1); if (is_array($res)) { $buf['body'] .= $res['body']; $buf['q'] .= $res['q'] ? $res['q'] : ''; } else { $buf['body'] .= $res; } } // 連鎖のため、範囲外のNGあぼーんチェック if ($_conf['ngaborn_chain_all'] && empty($_GET['nong'])) { $pre = min($count, $start); for ($i = $nofirst ? 0 : 1; $i < $pre; $i++) { $n = $i + 1; list($name, $mail, $date_id, $msg) = $aThread->explodeDatLine($datlines[$i]); if (($id = $aThread->ids[$n]) !== null) { $date_id = str_replace($aThread->idp[$n] . $id, "ID:{$id}", $date_id); } $this->_ngAbornCheck($n, strip_tags($name), $mail, $date_id, $id, $msg); } } // フィルタリング if ($do_filtering) { $datlines = $resFilter->apply($this); $filter_hits = $resFilter->hits; $last_hit_resnum = $resFilter->last_hit_resnum; } // 指定範囲を表示 $i = 0; $n = 0; $rn = 0; if ($do_filtering) { if (!empty($resFilter->range)) { $start = $resFilter->range['start']; $to = $resFilter->range['to']; } $pattern = $resFilter->getPattern(); } else { $pattern = null; } foreach ($datlines as $i => $ares) { if ($ares === null) { continue; } $n++; if ($i === 0 && !$nofirst) { continue; } if ($n < $start) { continue; } if ($n > $to) { break; } $rn = $i + 1; $res = $this->transRes($ares, $rn, $pattern); if (is_array($res)) { $buf['body'] .= $res['body']; $buf['q'] .= $res['q'] ? $res['q'] : ''; } else { $buf['body'] .= $res; } if (!$capture && $n % 10 == 0) { echo $buf['body']; if ($do_filtering && !$is_ktai) { echo "<script type=\"text/javascript\">filterCount({$n});</script>\n"; } flush(); $buf['body'] = ''; } } if ($this->thread->readnum < $rn) { $this->thread->readnum = $rn; } if ($do_filtering && !$is_ktai) { $buf['body'] .= "<script type=\"text/javascript\">filterCount({$filter_hits});</script>\n"; } if (!$is_fragment) { $buf['body'] .= "</div>\n"; } if ($capture) { return $buf['body'] . $buf['q']; } else { echo $buf['body']; echo $buf['q']; flush(); return true; } }
/** * 連想配列からResFilterオブジェクトを作成し、保持する * * @param array $params * @return ResFilter */ public static function configure(array $params) { $level = error_reporting(E_ALL & ~E_NOTICE); $word = $params['word']; $field = $params['field']; $method = $params['method']; $match = $params['match']; $include = $params['include']; error_reporting($level); self::$_instance = new ResFilter($word, $field, $method, $match, $include); return self::$_instance; }
} // スレが板サーバになければ if ($aThread->diedat) { echo '<div class="info">'; if ($aThread->getdat_error_msg_ht) { echo $aThread->getdat_error_msg_ht; } else { echo $aThread->getDefaultGetDatErrorMessageHTML(); } echo "<p><a href=\"{$motothre_url}\" target=\"_blank\">{$motothre_url}</a></p>"; echo '</div>'; } // フィルタヒット数 if ($do_filtering) { $htm['rf_field_names'] = array(ResFilter::FIELD_NUMBER => 'レス番号', ResFilter::FIELD_HOLE => '全体', ResFilter::FIELD_MESSAGE => '本文', ResFilter::FIELD_NAME => '名前', ResFilter::FIELD_MAIL => 'メール', ResFilter::FIELD_DATE => '日付', ResFilter::FIELD_ID => 'ID'); $hd['word'] = ResFilter::getWord('htmlspecialchars', array(ENT_QUOTES, 'Shift_JIS')); echo "<div class=\"hits\">{$htm['rf_field_names'][$resFilter->field]}に"{$hd['word']}"を"; echo $resFilter->match == ResFilter::MATCH_ON ? '含む' : '含まない'; if ($resFilter->include & ResFilter::INCLUDE_REFERENCES) { echo '+参照'; } if ($resFilter->include & ResFilter::INCLUDE_REFERENCED) { echo '+逆参照'; } echo ': <span id="searching">n</span>hit!</div>'; } // }}} echo '</div>'; // end toolbar // }}} /*
} if (($aThread->rescount or $_GET['one'] && !$aThread->diedat) && empty($_GET['renzokupop'])) { echo <<<EOP <div class="navi">{$htm['read_navi_range']} {$read_navi_previous} {$read_navi_next} {$read_navi_latest} <a href="#footer"{$_conf['k_accesskey_at']['bottom']}>{$_conf['k_accesskey_st']['bottom']}▼</a></div> EOP; } echo "<hr>"; echo "<h3><font color=\"{$STYLE['mobile_read_ttitle_color']}\">{$aThread->ttitle_hd}</font></h3>\n"; $filter_fields = array(ResFilter::FIELD_HOLE => '', ResFilter::FIELD_MESSAGE => 'メッセージが', ResFilter::FIELD_NAME => '名前が', ResFilter::FIELD_MAIL => 'メールが', ResFilter::FIELD_DATE => '日付が', ResFilter::FIELD_ID => 'IDが'); if ($do_filtering) { $resFilter = ResFilter::getFilter(); echo "検索結果: {$filter_fields[$resFilter->field]}"; echo ""{$hd['word']}"を"; echo $resFilter->match == ResFilter::MATCH_ON ? '含む' : '含まない'; } echo '<hr>'; /* * Local Variables: * mode: php * coding: cp932 * tab-width: 4 * c-basic-offset: 4 * indent-tabs-mode: nil * End: */ // vim: set syn=php fenc=cp932 ai et ts=4 sw=4 sts=4 fdm=marker:
<?php /** * rep2 - 検索結果のページ遷移用に変数を設定する */ // 検索クエリ $_conf['filter_q'] = '?host=' . $aThread->host . $bbs_q . $key_q . $offline_q . '&' . ResFilter::getQuery('&') . '&ls=all&page='; $filter_hits = $resFilter->hits; $filter_range = $resFilter->range; if ($filter_range['page'] > 1) { $read_navi_previous_url = $_conf['read_php'] . $_conf['filter_q'] . ($filter_range['page'] - 1) . $_conf['k_at_a']; } else { $read_navi_previous_url = null; } if ($filter_range['to'] < $filter_hits) { $read_navi_next_url = $_conf['read_php'] . $_conf['filter_q'] . ($filter_range['page'] + 1) . $_conf['k_at_a']; } else { $read_navi_next_url = null; } if (!$_conf['iphone']) { if ($read_navi_previous_url) { $read_navi_previous = "<a href=\"{$read_navi_previous_url}\">{$prev_st}</a>"; $read_navi_previous_btm = "<a href=\"{$read_navi_previous_url}\"{$_conf['k_accesskey_at']['prev']}>{$_conf['k_accesskey_st']['prev']}{$prev_st}</a>"; } else { $read_navi_previous = ''; $read_navi_previous_btm = ''; } if ($read_navi_next_url) { $read_navi_next = "<a href=\"{$read_navi_next_url}\"{$_conf['k_accesskey_at']['next']}>{$_conf['k_accesskey_st']['next']}{$next_st}</a>"; $read_navi_next_btm = "<a href=\"{$read_navi_next_url}\"{$_conf['k_accesskey_at']['next']}>{$_conf['k_accesskey_st']['next']}{$next_st}</a>"; } else {
/** * マッチ結果以外に表示するレスを選択する要素を生成する * * @param string $id_suffix * @param boolean $xhtml */ public static function getIncludeField($id_suffix = null, $xhtml = false) { $filter = parent::getFilter(); $fields = parent::$_includes; $default = is_object($filter) ? $filter->include : self::INCLUDE_DEFAULT; $key = 'include'; return self::_getSelectField($fields, $default, $key, $id_suffix, $xhtml); }
//================================================= $do_filtering = false; if (array_key_exists('rf', $_REQUEST) && is_array($_REQUEST['rf'])) { $resFilter = ResFilter::configure($_REQUEST['rf']); if ($resFilter->hasWord()) { $do_filtering = true; if ($_conf['ktai']) { $page = isset($_REQUEST['page']) ? $_REQUEST['page'] : 1; $resFilter->setRange($_conf['mobile.rnum_range'], $page); } if (empty($popup_filter) && isset($_REQUEST['submit_filter'])) { $resFilter->save(); } } } else { $resFilter = ResFilter::restore(); } //================================================= // あぼーん&NGワード設定読み込み //================================================= $GLOBALS['ngaborns'] = NgAbornCtl::loadNgAborns(); //================================================================== // メイン //================================================================== if (!isset($aThread)) { $aThread = new ThreadRead(); } // lsのセット if (!empty($ls)) { $aThread->ls = mb_convert_kana($ls, 'a'); }
/** * $lsを分解してstartとtoとnofirstを求める */ public function lsToPoint() { global $_conf; $start = 1; $to = false; $nofirst = false; // nを含んでいる場合は、>>1を表示しない($nofirst) if (strpos($this->ls, 'n') !== false) { $nofirst = true; $this->ls = str_replace('n', '', $this->ls); } // 範囲指定で分割 $n = explode('-', $this->ls); // 範囲指定がなければ if (sizeof($n) == 1) { // l指定があれば if (substr($n[0], 0, 1) == "l") { $ln = intval(substr($n[0], 1)); if ($_conf['ktai']) { if ($ln > $_conf['mobile.rnum_range']) { $ln = $_conf['mobile.rnum_range']; } } $start = $this->rescount - $ln + 1; if ($start < 1) { $start = 1; } $to = $this->rescount; // all指定なら } elseif ($this->ls == "all") { $start = 1; $to = $this->rescount; } else { // レス番指定 if (intval($this->ls) > 0) { $this->ls = intval($this->ls); $start = $this->ls; $to = $this->ls; $nofirst = true; // 指定がない or 不正な場合は、allと同じ表示にする } else { $start = 1; $to = $this->rescount; } } // 範囲指定があれば } else { if (!($start = intval($n[0]))) { $start = 1; } if (!($to = intval($n[1]))) { $to = $this->rescount; } } // 新着まとめ読みの表示数制限 if (isset($GLOBALS['rnum_all_range']) and $GLOBALS['rnum_all_range'] > 0) { /* ■携帯の新着まとめ読みが、ちょっきしで終わった時に、の「続きor更新」判定問題 リミット < スレの表示範囲 次リミットは 0 スレの表示範囲を終える前にリミット数消化 →続き リミット > スレの表示範囲 次リミットは + リミット数が残っている間に、スレの表示範囲を終えた →更新 リミット = スレの表示範囲 次リミットは 0 スレの表示範囲丁度でリミットを消化した →続き? 更新? 続きの場合も更新の場合もある。逐次処理のため、 他のスレの残り新着数があるかどうかが不明で判定できない。 */ // リミットがスレの表示範囲より小さい場合は、スレの表示範囲をリミットに合わせる $limit_to = $start + $GLOBALS['rnum_all_range'] - 1; if ($limit_to < $to) { $to = $limit_to; // スレの表示範囲丁度でリミットを消化した場合 } elseif ($limit_to == $to) { $GLOBALS['limit_to_eq_to'] = TRUE; } // 次のリミットは、今回のスレの表示範囲分を減らした数 $GLOBALS['rnum_all_range'] = $GLOBALS['rnum_all_range'] - ($to - $start) - 1; //print_r("$start, $to, {$GLOBALS['rnum_all_range']}"); } else { // 携帯用 if ($_conf['ktai']) { // 表示数制限 /* if ($start + $_conf['mobile.rnum_range'] -1 <= $to) { $to = $start + $_conf['mobile.rnum_range'] -1; } */ // 次X件では、前一つを含み、実質+1となるので、1つおまけする if ($start + $_conf['mobile.rnum_range'] <= $to) { $to = $start + $_conf['mobile.rnum_range']; } if (ResFilter::getWord() !== null) { $start = 1; $to = $this->rescount; $nofirst = false; } } } $this->resrange = compact('start', 'to', 'nofirst'); return $this->resrange; }
} // スレが板サーバになければ if ($aThread->diedat) { echo '<div class="info">'; if ($aThread->getdat_error_msg_ht) { echo $aThread->getdat_error_msg_ht; } else { echo $aThread->getDefaultGetDatErrorMessageHTML(); } echo "<p><a href=\"{$motothre_url}\" target=\"_blank\">{$motothre_url}</a></p>"; echo '</div>'; } // フィルタヒット数 if ($do_filtering) { $htm['rf_field_names'] = array(ResFilter::FIELD_NUMBER => 'レス番号', ResFilter::FIELD_HOLE => '全体', ResFilter::FIELD_MESSAGE => '本文', ResFilter::FIELD_NAME => '名前', ResFilter::FIELD_MAIL => 'メール', ResFilter::FIELD_DATE => '日付', ResFilter::FIELD_ID => 'ID'); $hd['word'] = ResFilter::getWord('p2h'); echo "<div class=\"hits\">{$htm['rf_field_names'][$resFilter->field]}に"{$hd['word']}"を"; echo $resFilter->match == ResFilter::MATCH_ON ? '含む' : '含まない'; if ($resFilter->include & ResFilter::INCLUDE_REFERENCES) { echo '+参照'; } if ($resFilter->include & ResFilter::INCLUDE_REFERENCED) { echo '+逆参照'; } echo ': <span id="searching">n</span>hit!</div>'; } // }}} if ($_GET['showbl']) { echo '<div class="hits">' . p2h($aThread->resrange['start']) . 'へのレス</div>'; } echo '</div>';