function readNew($aThread) { global $_conf, $newthre_num, $STYLE; global $spmode, $word, $newtime; $orig_no_label = !empty($_conf['expack.iphone.toolbars.no_label']); $_conf['expack.iphone.toolbars.no_label'] = true; $newthre_num++; //========================================================== // idxの読み込み //========================================================== //hostを分解してidxファイルのパスを求める $aThread->setThreadPathInfo($aThread->host, $aThread->bbs, $aThread->key); //FileCtl::mkdirFor($aThread->keyidx); // 板ディレクトリが無ければ作る //この操作はおそらく不要 $aThread->itaj = P2Util::getItaName($aThread->host, $aThread->bbs); if (!$aThread->itaj) { $aThread->itaj = $aThread->bbs; } // idxファイルがあれば読み込む if ($lines = FileCtl::file_read_lines($aThread->keyidx, FILE_IGNORE_NEW_LINES)) { $data = explode('<>', $lines[0]); } else { $data = array_fill(0, 12, ''); } $aThread->getThreadInfoFromIdx(); //================================================================== // DATのダウンロード //================================================================== if (!($word and file_exists($aThread->keydat))) { $aThread->downloadDat(); } // DATを読み込み $aThread->readDat(); $aThread->setTitleFromLocal(); // ローカルからタイトルを取得して設定 //=========================================================== // 表示レス番の範囲を設定 //=========================================================== // 取得済みなら if ($aThread->isKitoku()) { $from_num = $aThread->readnum + 1 - $_conf['respointer'] - $_conf['before_respointer_new']; if ($from_num > $aThread->rescount) { $from_num = $aThread->rescount - $_conf['respointer'] - $_conf['before_respointer_new']; } if ($from_num < 1) { $from_num = 1; } //if (!$aThread->ls) { $aThread->ls = "{$from_num}-"; //} } $aThread->lsToPoint(); //================================================================== // ヘッダ 表示 //================================================================== $motothre_url = $aThread->getMotoThread(); $ttitle_en = UrlSafeBase64::encode($aThread->ttitle); $ttitle_en_q = '&ttitle_en=' . $ttitle_en; $bbs_q = '&bbs=' . $aThread->bbs; $key_q = '&key=' . $aThread->key; $host_bbs_key_q = 'host=' . $aThread->host . $bbs_q . $key_q; $popup_q = '&popup=1'; $itaj_hd = htmlspecialchars($aThread->itaj, ENT_QUOTES, 'Shift_JIS'); if ($spmode) { $read_header_itaj_ht = "({$itaj_hd})"; } else { $read_header_itaj_ht = ''; } if ($_conf['iphone']) { if ($read_header_itaj_ht !== '') { $read_header_itaj_ht = "<span class=\"btitle\">{$read_header_itaj_ht}</span>"; } $read_header_ht = <<<EOP <div class="ntoolbar mtoolbar mtoolbar_top" id="ntt{$newthre_num}"> <h2 class="ttitle">{$aThread->ttitle_hd} {$read_header_itaj_ht}</h2> EOP; $read_header_ht .= '<div class="mover">'; $read_header_ht .= toolbar_i_standard_button('img/gp2-down.png', '', sprintf('#ntt%d', $newthre_num + 1)); $read_header_ht .= '</div>'; $info_ht = P2Util::getInfoHtml(); if (strlen($info_ht)) { $read_header_ht .= "<div class=\"info\">{$info_ht}</div>"; } $read_header_ht .= '</div>'; } else { P2Util::printInfoHtml(); $read_header_ht = <<<EOP <hr><div id="ntt{$newthre_num}" name="ntt{$newthre_num}"><font color="{$STYLE['mobile_read_ttitle_color']}"><b>{$aThread->ttitle_hd}</b></font> {$read_header_itaj_ht} <a href="#ntt_bt{$newthre_num}">▼</a></div><hr> EOP; } //================================================================== // ローカルDatを読み込んでHTML表示 //================================================================== $aThread->resrange['nofirst'] = true; $GLOBALS['newres_to_show_flag'] = false; $read_cont_ht = ''; if ($aThread->rescount) { $aShowThread = new ShowThreadK($aThread, true); if ($_conf['iphone'] && $_conf['expack.spm.enabled']) { $read_cont_ht .= $aShowThread->getSpmObjJs(); } $read_cont_ht .= $aShowThread->getDatToHtml(); unset($aShowThread); } //================================================================== // フッタ 表示 //================================================================== // 表示範囲 if ($aThread->resrange['start'] == $aThread->resrange['to']) { $read_range_on = $aThread->resrange['start']; } else { $read_range_on = "{$aThread->resrange['start']}-{$aThread->resrange['to']}"; } $read_range_ht = "{$read_range_on}/{$aThread->rescount}"; // ツールバー部分HTML ======= if ($spmode) { $toolbar_itaj_ht = "(<a href=\"{$_conf['subject_php']}?{$host_bbs_key_q}{$_conf['k_at_a']}\">{$itaj_hd}</a>)"; } else { $toolbar_itaj_ht = ''; } if ($_conf['iphone']) { if ($toolbar_itaj_ht !== '') { $toolbar_itaj_ht = "<span class=\"btitle\">{$toolbar_itaj_ht}</span>"; } $read_footer_ht = <<<EOP <div class="ntoolbar mtoolbar mtoolbar_bottom" id="ntt_btm{$newthre_num}"> <table><tbody><tr> EOP; // 情報 $read_footer_ht .= '<td>'; $escaped_url = "info.php?{$host_bbs_key_q}{$ttitle_en_q}{$_conf['k_at_a']}"; $read_footer_ht .= toolbar_i_opentab_button('img/gp5-info.png', '', $escaped_url); $read_footer_ht .= '</td>'; // 表示範囲 $read_footer_ht .= "<td colspan=\"3\"><span class=\"large\">{$read_range_ht}</span></td>"; // ツール $read_footer_ht .= '<td>'; $escaped_url = "spm_k.php?{$host_bbs_key_q}&ls={$aThread->ls}&spm_default={$aThread->resrange['to']}{$_conf['k_at_a']}"; $read_footer_ht .= toolbar_i_opentab_button('img/glyphish/icons2/20-gear2.png', '', $escaped_url); $read_footer_ht .= '</td>'; // タイトル等 $read_footer_ht .= <<<EOP </tr></tbody></table> <div class="ttitle"><a href="{$_conf['read_php']}?{$host_bbs_key_q}&offline=1&rescount={$aThread->rescount}{$_conf['k_at_a']}" target="_blank">{$aThread->ttitle_hd}</a> {$toolbar_itaj_ht}</div> <div class="mover"> EOP; $read_footer_ht .= toolbar_i_standard_button('img/gp1-up.png', '', "#ntt{$newthre_num}"); $read_footer_ht .= '</div></div>'; } else { $read_footer_ht = <<<EOP <div id="ntt_bt{$newthre_num}" name="ntt_bt{$newthre_num}" class="read_new_toolbar"> {$read_range_ht} <a href="info.php?{$host_bbs_key_q}{$ttitle_en_q}{$_conf['k_at_a']}">情</a> <a href="spm_k.php?{$host_bbs_key_q}&ls={$aThread->ls}&spm_default={$aThread->resrange['to']}&from_read_new=1{$_conf['k_at_a']}">特</a> <br> <a href="{$_conf['read_php']}?{$host_bbs_key_q}&offline=1&rescount={$aThread->rescount}{$_conf['k_at_a']}#r{$aThread->rescount}">{$aThread->ttitle_hd}</a> {$toolbar_itaj_ht} <a href="#ntt{$newthre_num}">▲</a> </div> <hr> EOP; } // 透明あぼーんや表示数制限で新しいレス表示がない場合はスキップ if ($GLOBALS['newres_to_show_flag']) { echo $read_header_ht; echo $read_cont_ht; echo $read_footer_ht; } //================================================================== // key.idxの値設定 //================================================================== if ($aThread->rescount) { $aThread->readnum = min($aThread->rescount, max(0, $data[5], $aThread->resrange['to'])); $newline = $aThread->readnum + 1; // $newlineは廃止予定だが、旧互換用に念のため $sar = array($aThread->ttitle, $aThread->key, $data[2], $aThread->rescount, $aThread->modified, $aThread->readnum, $data[6], $data[7], $data[8], $newline, $data[10], $data[11], $aThread->datochiok); P2Util::recKeyIdx($aThread->keyidx, $sar); // key.idxに記録 } $_conf['expack.iphone.toolbars.no_label'] = $orig_no_label; }
// }}} // ImageCache2 if ($_conf['expack.ic2.enabled']) { if (!function_exists('ic2_loadconfig')) { include P2EX_LIB_DIR . '/ImageCache2/bootstrap.php'; } $ic2conf = ic2_loadconfig(); if ($ic2conf['Thumb1']['width'] > 80) { include P2EX_LIB_DIR . '/ImageCache2/templates/info-v.tpl.html'; } else { include P2EX_LIB_DIR . '/ImageCache2/templates/info-h.tpl.html'; } } // SPM if ($_conf['expack.spm.enabled']) { echo ShowThreadK::getSpmElementHtml(); } // 最終レス番号を更新 echo <<<EOS <script type="text/javascript"> //<![CDATA[ (function(n){ var ktool_value = document.getElementById('ktool_value'); if (ktool_value) { ktool_value.value = n; } })({$last_resnum}); //]]> </script> EOS; // フィルタヒット数を更新
/** * スレッドの新着部分を読み込んで表示する */ function _readNew(&$aThread) { global $_conf, $_newthre_num, $STYLE; global $spmode; $_newthre_num++; $hr = P2View::getHrHtmlK(); //========================================================== // idxの読み込み //========================================================== //hostを分解してidxファイルのパスを求める $aThread->setThreadPathInfo($aThread->host, $aThread->bbs, $aThread->key); //FileCtl::mkdirFor($aThread->keyidx); //板ディレクトリが無ければ作る //この操作はおそらく不要 $aThread->itaj = P2Util::getItaName($aThread->host, $aThread->bbs); if (!$aThread->itaj) { $aThread->itaj = $aThread->bbs; } // idxファイルがあれば読み込む if (is_readable($aThread->keyidx)) { $lines = file($aThread->keyidx); $data = explode('<>', rtrim($lines[0])); } $aThread->getThreadInfoFromIdx(); //$aThread->readDatInfoFromFile(); // DATのダウンロード if (!(strlen(geti($word)) and file_exists($aThread->keydat))) { $aThread->downloadDat(); } // DATを読み込み $aThread->readDat(); $aThread->setTitleFromLocal(); // ローカルからタイトルを取得して設定 //=========================================================== // 表示レス番の範囲を設定 //=========================================================== // 取得済みなら if ($aThread->isKitoku()) { $from_num = $aThread->readnum + 1 - $_conf['respointer'] - $_conf['before_respointer_new']; if ($from_num > $aThread->rescount) { $from_num = $aThread->rescount - $_conf['respointer'] - $_conf['before_respointer_new']; } if ($from_num < 1) { $from_num = 1; } //if (!$aThread->ls) { $aThread->ls = "{$from_num}-"; //} } $aThread->lsToPoint(); //================================================================== // ヘッダ 表示 //================================================================== $motothre_url = $aThread->getMotoThread(); $ttitle_en = base64_encode($aThread->ttitle); $ttitle_en_q = "&ttitle_en=" . $ttitle_en; $bbs_q = "&bbs=" . $aThread->bbs; $key_q = "&key=" . $aThread->key; $popup_q = "&popup=1"; // require_once P2_LIB_DIR . '/read_header.inc.php'; $prev_thre_num = $_newthre_num - 1; $next_thre_num = $_newthre_num + 1; if ($prev_thre_num != 0) { $prev_thre_ht = "<a href=\"#ntt{$prev_thre_num}\">▲</a>"; } //$next_thre_ht = "<a href=\"#ntt{$next_thre_num}\">▼</a> "; $next_thre_ht = "<a class=\"button\" href=\"#ntt_bt{$_newthre_num}\">▼</a> "; if ($spmode) { $read_header_itaj_ht = sprintf(' (%s)', hs($aThread->itaj)); if ($_conf['k_save_packet']) { $read_header_itaj_ht = mb_convert_kana($read_header_itaj_ht, 'rnsk'); } } // スマートポップアップメニュー JavaScriptコード if ($_conf['enable_spm']) { // フォントサイズ等 conf_user_style.inc.php をいじるとPCも変わるのでここで書き換え $STYLE['respop_color'] = "#FFFFFF"; // ("#000") レスポップアップのテキスト色 $STYLE['respop_bgcolor'] = ""; // ("#ffffcc") レスポップアップの背景色 $STYLE['respop_fontsize'] = '13px'; $aThread->showSmartPopUpMenuJs(); } P2Util::printInfoHtml(); $ttitle_hs = hs($aThread->ttitle_hc); if ($_conf['k_save_packet']) { $ttitle_hs = mb_convert_kana($ttitle_hs, 'rnsk'); } $read_header_ht = <<<EOP \t<p id="ntt{$_newthre_num}" name="ntt{$_newthre_num}"><font color="{$STYLE['read_k_thread_title_color']}"><b>{$ttitle_hs}</b></font>{$read_header_itaj_ht} {$next_thre_ht}</p> \t{$hr} EOP; // {{{ ローカルDatを読み込んでHTML表示 $aThread->resrange['nofirst'] = true; $GLOBALS['newres_to_show_flag'] = false; $read_cont_ht = ''; if ($aThread->rescount) { //$aThread->datToHtml(); // dat を html に変換表示 require_once P2_IPHONE_LIB_DIR . '/ShowThreadK.php'; $aShowThread = new ShowThreadK($aThread); $read_cont_ht = $aShowThread->getDatToHtml(); unset($aShowThread); } // }}} //================================================================== // フッタ 表示 //================================================================== // require_once P2_LIB_DIR . '/read_footer.inc.php'; //---------------------------------------------- // $read_footer_navi_new_ht 続きを読む 新着レスの表示 $newtime = date("gis"); // リンクをクリックしても再読込しない仕様に対抗するダミークエリー $info_st = "情"; $dele_st = "削"; $prev_st = "前"; $next_st = "次"; // 表示範囲 if ($aThread->resrange['start'] == $aThread->resrange['to']) { $read_range_on = $aThread->resrange['start']; } else { $read_range_on = "{$aThread->resrange['start']}-{$aThread->resrange['to']}"; } $read_range_ht = "{$read_range_on}/{$aThread->rescount}<br>"; /* $read_footer_navi_new_ht = P2View::tagA( UriUtil::buildQueryUri( $_conf['read_php'], array( 'host' => $aThread->host, 'bbs' => $aThread->bbs, 'key' => $aThread->key, 'ls' => "$aThread->rescount-", 'nt' => $newtime, UA::getQueryKey() => UA::getQueryValue() ) . "#r{$aThread->rescount}" ), '新着レスの表示' ); $dores_ht _getDoResATag($aThread, $motothre_url); */ // {{{ ツールバー部分HTML if ($spmode) { $ita_atag = _getItaATag($aThread); $toolbar_itaj_ht = " ({$ita_atag})"; if ($_conf['k_save_packet']) { $toolbar_itaj_ht = mb_convert_kana($toolbar_itaj_ht, 'rnsk'); } } /* $info_atag = _getInfoATag($aThread, $info_st); $dele_atag = _getDeleATag($aThread, $dele_st); $motothre_atag = P2View::tagA($motothre_url, '元スレ') $toolbar_right_ht = "{$info_atag} {$dele_atag} {$motothre_atag}\n"; */ // }}} $read_atag = _getReadATag($aThread); $read_footer_ht = <<<EOP <div id="ntt_bt{$_newthre_num}" name="ntt_bt{$_newthre_num}"> {$read_range_ht} {$read_atag}{$toolbar_itaj_ht} <a href="#ntt{$_newthre_num}">▲</a> </div> EOP; // 透明あぼーんや表示数制限で新しいレス表示がない場合はスキップ if ($GLOBALS['newres_to_show_flag']) { echo $read_header_ht; echo $read_cont_ht; echo $read_footer_ht; } // {{{ key.idxの値設定 if ($aThread->rescount) { $aThread->readnum = min($aThread->rescount, max(0, $data[5], $aThread->resrange['to'])); $newline = $aThread->readnum + 1; // $newlineは廃止予定だが、後方互換用に念のため $sar = array($aThread->ttitle, $aThread->key, $data[2], $aThread->rescount, '', $aThread->readnum, $data[6], $data[7], $data[8], $newline, $data[10], $data[11], $aThread->datochiok); P2Util::recKeyIdx($aThread->keyidx, $sar); // key.idxに記録 } // }}} unset($aThread); }
if (isset($GLOBALS['word']) && strlen($GLOBALS['word'])) { $GLOBALS['_filter_hits'] = 0; } // ヘッダプリント if (UA::isIPhoneGroup()) { require_once P2_IPHONE_LIB_DIR . '/read_header_k.inc.php'; } else { require_once P2_LIB_DIR . '/read_header_k.inc.php'; } if ($aThread->rescount) { if (UA::isIPhoneGroup()) { require_once P2_IPHONE_LIB_DIR . '/ShowThreadK.php'; } else { require_once P2_LIB_DIR . '/ShowThreadK.php'; } $aShowThread = new ShowThreadK($aThread); $aShowThread->datToHtml(); } // フッタプリント if ($GLOBALS['_filter_hits'] !== NULL) { $params = array('prev_st' => $prev_st, 'next_st' => $next_st, 'filter_page' => $filter_page, 'res_filter' => $res_filter); $ar = getResetReadNaviFooterK($aThread, $params); extract($ar); // $read_navi_previous_btm_ht, $read_navi_next_btm_ht, $read_footer_navi_new_btm_ht } if (UA::isIPhoneGroup()) { require_once P2_IPHONE_LIB_DIR . '/read_footer_k.inc.php'; } else { require_once P2_LIB_DIR . '/read_footer_k.inc.php'; } } else {
/** * >>1のみをプレビュー表示するためのHTMLを取得する(オンザフライに対応) * * @access public * @return string|false */ function previewOne() { global $_conf, $ptitle_ht; if (!($this->host && $this->bbs && $this->key)) { return false; } $first_line = ''; // ローカルdatから取得 if (is_readable($this->keydat)) { $fd = fopen($this->keydat, "rb"); $first_line = fgets($fd, 32800); fclose($fd); } if ($first_line) { // be.2ch.net ならEUC→SJIS変換 if (P2Util::isHostBe2chNet($this->host)) { $first_line = mb_convert_encoding($first_line, 'SJIS-win', 'eucJP-win'); } $first_datline = rtrim($first_line); if (strstr($first_datline, "<>")) { $datline_sepa = "<>"; } else { $datline_sepa = ","; $this->dat_type = "2ch_old"; } $d = explode($datline_sepa, $first_datline); $this->setTtitle($d[4]); // 便宜上 if (!$this->readnum) { $this->readnum = 1; } } // ローカルdatなければオンラインから if (!$first_line) { $url = $this->getDatUrl($this->host, $this->bbs, $this->key); $purl = parse_url($url); $purl['query'] = isset($purl['query']) ? '?' . $purl['query'] : ''; // プロキシ if ($_conf['proxy_use']) { $send_host = $_conf['proxy_host']; $send_port = $_conf['proxy_port']; $send_path = $url; } else { $send_host = $purl['host']; $send_port = isset($purl['port']) ? $purl['port'] : null; $send_path = $purl['path'] . $purl['query']; } // デフォルトを80 !$send_port and $send_port = 80; $request = 'GET ' . $send_path . " HTTP/1.0\r\n"; $request .= "Host: " . $purl['host'] . "\r\n"; $request .= 'User-Agent: ' . P2Util::getP2UA($withMonazilla = true) . "\r\n"; // $request .= "Range: bytes={$from_bytes}-\r\n"; // Basic認証用のヘッダ if (isset($purl['user']) && isset($purl['pass'])) { $request .= "Authorization: Basic " . base64_encode($purl['user'] . ":" . $purl['pass']) . "\r\n"; } $request .= "Connection: Close\r\n"; $request .= "\r\n"; // WEBサーバへ接続 $fp = fsockopen($send_host, $send_port, $errno, $errstr, $_conf['fsockopen_time_limit']); if (!$fp) { P2Util::pushInfoHtml(sprintf('<p>サーバ接続エラー: %s (%s)<br>p2 info - %s に接続できませんでした。</p>', $errstr, $errno, P2View::tagA(P2Util::throughIme($url), hs($url), array('target' => $_conf['ext_win_target'])))); $this->diedat = true; return false; } // HTTPリクエスト送信 fputs($fp, $request); // HTTPヘッダレスポンスを取得する $h = $this->freadHttpHeader($fp); if ($h === false) { fclose($fp); $this->_pushInfoHtmlFreadHttpHeaderError($url); $this->diedat = true; return false; } // {{{ HTTPコードをチェック $code = $h['code']; // Partial Content if ($code == "200") { // OK。何もしない // 予期しないHTTPコード。なかったと判断する } else { fclose($fp); $this->previewOneNotFound(); return false; } // }}} if (isset($h['headers']['Content-Length'])) { if (preg_match("/^([0-9]+)/", $h['headers']['Content-Length'], $matches)) { $onbytes = $h['headers']['Content-Length']; } } // bodyを一行目だけ読む $first_line = fgets($fp, 32800); fclose($fp); // be.2ch.net ならEUC→SJIS変換 if (P2Util::isHostBe2chNet($this->host)) { $first_line = mb_convert_encoding($first_line, 'SJIS-win', 'eucJP-win'); } $first_datline = rtrim($first_line); if (strstr($first_datline, '<>')) { $datline_sepa = '<>'; } else { $datline_sepa = ','; $this->dat_type = '2ch_old'; } $d = explode($datline_sepa, $first_datline); $this->setTtitle($d[4]); $this->onthefly = true; } // 厳密にはオンザフライではないが、個人にとっては(既読記録がされないという意味で)オンザフライ if (!$this->isKitoku()) { $this->onthefly = true; } $body = ''; if (!empty($this->onthefly)) { // PC if (UA::isPC()) { $body .= '<div><span class="onthefly">プレビュー</span></div>'; // 携帯 } else { $body .= '<div><font size="-1" color="#00aa00">プレビュー</font></div>'; } } UA::isPC() and $body .= '<dl>'; require_once P2_LIB_DIR . '/ShowThread.php'; // PC if (UA::isPC()) { require_once P2_LIB_DIR . '/ShowThreadPc.php'; $aShowThread = new ShowThreadPc($this); // 携帯 } else { require_once P2_LIB_DIR . '/ShowThreadK.php'; $aShowThread = new ShowThreadK($this); } $body .= $aShowThread->transRes($first_line, 1); // 1を表示 UA::isPC() and $body .= "</dl>\n"; return $body; }
// フィルタリングの時は、all固定とする if ($resFilter && $resFilter->hasWord()) { $aThread->ls = 'all'; } $aThread->lsToPoint(); //=============================================================== // プリント //=============================================================== $ptitle_ht = htmlspecialchars($aThread->itaj, ENT_QUOTES) . " / " . $aThread->ttitle_hd; if ($_conf['ktai']) { if ($resFilter && $resFilter->hasWord() && $aThread->rescount) { $GLOBALS['filter_hits'] = 0; } else { $GLOBALS['filter_hits'] = NULL; } $aShowThread = new ShowThreadK($aThread); if ($is_ajax) { $response = trim(mb_convert_encoding($aShowThread->getDatToHtml(true), 'UTF-8', 'CP932')); if (isset($_GET['respop_id'])) { $response = preg_replace('/<[^<>]+? id="/u', sprintf('$0_respop%d_', $_GET['respop_id']), $response); } /*if ($_conf['iphone']) { // HTMLの断片をXMLとして渡してもDOMでidやclassが期待通りに反映されない header('Content-Type: application/xml; charset=UTF-8'); //$responseId = 'ajaxResponse' . time(); $doc = new DOMDocument(); $err = error_reporting(E_ALL & ~E_WARNING); $html = '<html><head>' . '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">' . '</head><body>' . $response