/** * 対象レスの対象フィールドから、検索ワードを取得する * * @return string 検索ワード */ function _getReadFilterWord($host, $bbs, $key, $resnum, $field) { $word = null; $aThread = new ThreadRead(); $aThread->setThreadPathInfo($host, $bbs, $key); $aThread->readDat(); $resar = $aThread->explodeDatLine($aThread->datlines[$resnum - 1]); $resar = array_map('trim', $resar); $resar = array_map('strip_tags', $resar); switch ($field) { case 'name': $word = $resar[0]; break; case 'mail': $word = $resar[1]; break; case 'date': $word = preg_replace("/^(.*)ID:([0-9a-zA-Z\\/\\.\\+]+)(.*)\$/", "\\1 \\3", $resar[2]); $word = preg_replace("/^.*(\\d{2,4}\\/\\d{1,2}\\/\\d{1,2}).*\$/", "\\1", $word); break; case 'id': $word = preg_replace("/^.*ID:([0-9a-zA-Z\\/\\.\\+]+).*\$/", "\\1", $resar[2]); break; case 'rres': $_GET['field'] = 'msg'; $_GET['method'] = 'regex'; //$word = '>' . $resnum . '[^\d]'; // [^\d-] //$word = "(>|>|<|<|)|〉|》|≫){1,2}\s*\.?(\d+,)*" . $resnum . "\D"; require_once P2_LIB_DIR . '/ShowThread.php'; $word = ShowThread::getAnchorRegex('%prefix%(.+%delimiter%)?' . $resnum . '(?!\\d|%range_delimiter%)'); } return $word; }
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; }
/** * レスデータを集計して$this->_quote_toと$this->_quote_fromに保存. */ protected function _make_quotes() { global $_conf; $this->_quote_to = array(); $this->_quote_from = array(); if (!$this->thread->datlines) { return; } foreach ($this->thread->datlines as $num => $line) { list($name, $mail, $date_id, $msg) = $this->thread->explodeDatLine($line); // NGあぼーんチェック if (($id = $this->thread->ids[$num + 1]) !== null) { $date_id = str_replace($this->thread->idp[$i] . $id, 'ID:' . $id, $date_id); } $ng_type = $this->_ngAbornCheck($num + 1, strip_tags($name), $mail, $date_id, $id, $msg); if ($ng_type == self::ABORN) { continue; } // 名前 if ($nmatches = $this->getQuoteResNumsName($name)) { foreach ($nmatches as $a_quote_res_num) { if ($a_quote_res_num) { if (!array_key_exists($a_quote_res_num, $this->_quote_from) || $this->_quote_from[$a_quote_res_num] === null) { $this->_quote_from[$a_quote_res_num] = array(); } if (!in_array($num + 1, $this->_quote_from[$a_quote_res_num])) { $this->_quote_from[$a_quote_res_num][] = $num + 1; } if (!array_key_exists($num + 1, $this->_quote_to) || $this->_quote_to[$num + 1] === null) { $this->_quote_to[$num + 1] = array(); } if (!in_array($a_quote_res_num, $this->_quote_to[$num + 1])) { $this->_quote_to[$num + 1][] = $a_quote_res_num; } } } } // >>1のリンクをいったん外す // <a href="../test/read.cgi/accuse/1001506967/1" target="_blank">>>1</a> $msg = preg_replace('{<[Aa] .+?>(>>[1-9][\\d\\-]*)</[Aa]>}', '$1', $msg); if (!preg_match_all(self::getAnchorRegex('/%full%/'), $msg, $out, PREG_PATTERN_ORDER)) { continue; } foreach ($out[2] as $numberq) { if (!preg_match_all(self::getAnchorRegex('/(?:%prefix%)?(%a_range%)/'), $numberq, $anchors, PREG_PATTERN_ORDER)) { continue; } foreach ($anchors[1] as $anchor) { if (preg_match(self::getAnchorRegex('/(%a_num%)%range_delimiter%(?:%prefix%)?(%a_num%)/'), $anchor, $matches)) { $from = intval(mb_convert_kana($matches[1], 'n')); $to = intval(mb_convert_kana($matches[2], 'n')); if ($from < 1 || $to < 1 || $from > $to || $to - $from + 1 > sizeof($this->thread->datlines)) { continue; } if ($_conf['backlink_list_range_anchor_limit'] != 0) { if ($to - $from >= $_conf['backlink_list_range_anchor_limit']) { continue; } } for ($i = $from; $i <= $to; $i++) { if ($i > sizeof($this->thread->datlines)) { break; } if ($_conf['backlink_list_future_anchor'] == 0) { if ($i >= $num + 1) { continue; } // レス番号以降のアンカーは無視する } if (!array_key_exists($i, $this->_quote_from) || $this->_quote_from[$i] === null) { $this->_quote_from[$i] = array(); } if (!in_array($num + 1, $this->_quote_from[$i])) { $this->_quote_from[$i][] = $num + 1; } } } else { if (preg_match(self::getAnchorRegex('/(%a_num%)/'), $anchor, $matches)) { $quote_num = intval(mb_convert_kana($matches[1], 'n')); if (!array_key_exists($num + 1, $this->_quote_to) || $this->_quote_to[$num + 1] === null) { $this->_quote_to[$num + 1] = array(); } if (!in_array($quote_num, $this->_quote_to[$num + 1])) { $this->_quote_to[$num + 1][] = $quote_num; } if ($_conf['backlink_list_future_anchor'] == 0) { if ($quote_num >= $num + 1) { continue; } // レス番号以降のアンカーは無視する } if (!array_key_exists($quote_num, $this->_quote_from) || $this->_quote_from[$quote_num] === null) { $this->_quote_from[$quote_num] = array(); } if (!in_array($num + 1, $this->_quote_from[$quote_num])) { $this->_quote_from[$quote_num][] = $num + 1; } } } } } } }
$bbs = $_GET['bbs']; $key = $_GET['key']; $resid = $_GET['copy']; $quote = !empty($_GET['inyou']); if (isset($_SERVER['HTTP_REFERER'])) { $back_link = '<a href="' . htmlspecialchars($_SERVER['HTTP_REFERER'], ENT_QUOTES) . '" title="戻る">戻る</a> '; } //================================================= // レス読み込み //================================================= $aThread = new ThreadRead(); $aThread->setThreadPathInfo($host, $bbs, $key); if (file_exists($aThread->keydat)) { // スレッド情報 $aThread->readDat($aThread->keydat); $one = $aThread->explodeDatLine($aThread->datlines[0]); $ttitle = trim($one[4]); $ttitle_en = UrlSafeBase64::encode($ttitle); $ttitle_ht = htmlspecialchars($ttitle, ENT_QUOTES); $url_txt = $aThread->getMotoThread(true); $url_k_txt = $aThread->getMotoThread(); if ($quote) { $url_txt .= $resid; $url_k_txt .= $resid; } if ($url_txt != $url_k_txt) { $url_k_ht = "<input type=\"text\" name=\"url_k_txt\" value=\"{$url_k_txt}\"><br>"; } // 投稿フォームへのリンク $post_url = "post_form.php?host={$host}&bbs={$bbs}&key={$key}"; $post_url .= "&rescount={$aThread->rescount}&ttitle_en={$ttitle_en}&b=k";
$target_edit_at = ''; $target_read_at = ''; $target_sb_at = ''; } //===================================================== // データファイルの読み書き //===================================================== if (preg_match('/^(aborn|ng)_/', $mode)) { $path = $_conf['pref_dir'] . '/p2_' . $mode . '.txt'; } if ($popup == 1 || $_conf['expack.spm.ngaborn_confirm'] == 0) { $_GET['popup'] = 2; $aThread = new ThreadRead(); $aThread->setThreadPathInfo($host, $bbs, $key); $aThread->readDat($aThread->keydat); $resar = $aThread->explodeDatLine($aThread->datlines[$resnum - 1]); $resar = array_map('trim', $resar); $resar = array_map('strip_tags', $resar); if (preg_match('/ID: ?([^ ]+?)(?= |$)/', $resar[2], $idar)) { $aborn_id = $idar[1]; } else { $aborn_id = ''; } // +Wiki:BEあぼーん $aborn_be = preg_match('/BE:(\\d+)/', $resar[2], $idar) ? P2UtilWiki::calcBeId($idar[1]) : ''; if ($_conf['expack.spm.ngaborn_confirm'] == 0 && !isset($aborn_str)) { if ($mode == 'aborn_res') { $aborn_str = $host . '/' . $bbs . '/' . $key . '/' . $resnum; } elseif (strpos($mode, '_name') !== false) { $aborn_str = $resar[0]; } elseif (strpos($mode, '_mail') !== false) {
/** * @return array */ function _getExplodedDatLine($host, $bbs, $key, $resnum) { require_once P2_LIB_DIR . '/Thread.php'; require_once P2_LIB_DIR . '/ThreadRead.php'; $ThreadRead = new ThreadRead(); $ThreadRead->setThreadPathInfo($host, $bbs, $key); $ThreadRead->readDat($ThreadRead->keydat); $explodedDatLine = $ThreadRead->explodeDatLine($ThreadRead->datlines[$resnum - 1]); return array_map('trim', $explodedDatLine); }
$moto_url_k = ''; $post_link_atag = ''; $moto_link_atag = ''; $name_txt = ''; $mail_txt = ''; $date_txt = ''; $msg_txt = ''; $id_txt = ''; $id_ht = ''; $form_id = P2_REQUEST_ID; if (!file_exists($aThread->keydat)) { p2die('スレッドの指定が変です。'); } // スレッド情報 $aThread->readDat($aThread->keydat); $first = $aThread->explodeDatLine($aThread->datlines[0]); $ttitle = trim($first[4]); $ttitle_en = base64_encode($ttitle); $moto_url = $aThread->getMotoThread(true); $moto_url_k = $aThread->getMotoThread(); if ($moto_url != $moto_url_k) { $moto_url_k_ht = sprintf('<input type="text" name="dummy_moto_url_k" value="%s"><br>', hs($moto_url_k)); } // 投稿フォーム <a> $post_link_atag = _getPostLinkATag($aThread, $ttitle_en); // 元スレへ <a> $moto_link_atag = P2View::tagA(P2Util::throughIme($moto_url_k), '元スレ'); // 指定番号のレスをパース $p = $resid - 1; if (isset($aThread->datlines[$p])) { $resar = $aThread->explodeDatLine($aThread->datlines[$p]);
} $inline = !empty($_GET['inline']); $rotate = !empty($_GET['rotate']); } // レス読み込み if (empty($errors) && $_SERVER['REQUEST_METHOD'] != 'POST') { $aThread = new ThreadRead(); $aThread->setThreadPathInfo($host, $bbs, $key); if (!$aThread->readDat()) { $errors[] = 'datが読み込めませんでした。'; } else { $offset = $resnum - 1; if (!isset($aThread->datlines[$offset])) { $errors[] = 'このスレッドの >>' . $resnum . ' は存在していないか、取得していません。'; } else { $parts = $aThread->explodeDatLine($aThread->datlines[$offset]); $text = $parts[3]; $text = strip_tags($text, '<br><hr>'); $text = preg_replace('/\\s*<br[^<>]*>\\s*/i', "\n", $text); $text = preg_replace('/\\s*<hr[^<>]*>\\s*/i', "\n------------------------\n", $text); $text = trim($text); } } } // エラーメッセージを表示して終了 if (count($errors) > 0) { P2Util::header_nocache(); echo '<html>'; echo '<head><title>AAS Error</title></head>'; echo '<body>'; echo '<p><b>AAS Error</b></p>';
$htm['dpreview_amona'] = <<<EOP <input type="checkbox" id="dp_mona" disabled><label for="dp_mona">mona</label> EOP; } } // }}} // {{{ ここにレス $htm['orig_msg'] = ''; if ((basename($_SERVER['SCRIPT_NAME']) == 'post_form.php' || !empty($_GET['inyou'])) && !empty($_GET['resnum'])) { $q_resnum = $_GET['resnum']; $hd['MESSAGE'] = ">>" . $q_resnum . "\r\n"; if (!empty($_GET['inyou'])) { $aThread = new ThreadRead(); $aThread->setThreadPathInfo($host, $bbs, $key); $aThread->readDat($aThread->keydat); $q_resar = $aThread->explodeDatLine($aThread->datlines[$q_resnum - 1]); $q_resar = array_map('trim', $q_resar); $q_resar[3] = strip_tags($q_resar[3], '<br>'); if ($_GET['inyou'] == 1 || $_GET['inyou'] == 3) { $hd['MESSAGE'] .= '> '; $hd['MESSAGE'] .= preg_replace('/\\s*<br>\\s*/', "\r\n> ", $q_resar[3]); $hd['MESSAGE'] .= "\r\n"; } if ($_GET['inyou'] == 2 || $_GET['inyou'] == 3) { if (!$_conf['ktai'] || $_conf['iphone']) { $htm['orig_msg'] = <<<EOM <fieldset id="original_msg"> <legend>Original Message:</legend> <div> <span class="prvw_resnum">{$q_resnum}</span> :<b class="prvw_name">{$q_resar[0]}</b>
readfile('./img/spacer.gif'); } exit; } else { if ($stalker->isEnabled()) { $id = null; if (!empty($_GET['id'])) { $id = $_GET['id']; } elseif (!empty($_GET['key']) && !empty($_GET['resnum'])) { $aThread = new ThreadRead(); $aThread->setThreadPathInfo($_GET['host'], $_GET['bbs'], $_GET['key']); $aThread->readDat(); $resnum = $_GET['resnum']; if (isset($aThread->datlines[$resnum - 1])) { $ares = $aThread->datlines[$resnum - 1]; $resar = $aThread->explodeDatLine($ares); $m = array(); if (preg_match('<(ID: ?| )([0-9A-Za-z/.+]{8,11})(?=[^0-9A-Za-z/.+]|$)>', $resar[2], $m)) { $id = $m[2]; } } } if ($id) { $stalker->id = $id; } else { P2Util::printSimpleHtml('何かが足りないようです。'); exit; } $_ime = new P2Ime(); header('Location: ' . $_ime->through($stalker->getIDURL(), null, false)); } else {