/** * お気に板をプリントする */ public function printFavIta() { global $_conf, $matome_i, $STYLE; $menu_php_ht = p2h(isset($GLOBALS['menu_php_self']) ? $GLOBALS['menu_php_self'] : $_SERVER['SCRIPT_NAME']); echo <<<EOP <div class="menu_cate"> <b><a class="menu_cate" href="javascript:void(0);" onclick="showHide('c_favita');" target="_self">お気に板</a></b> [<a href="editfavita.php" target="subject">編集</a>] EOP; // お気に板切り替え if ($_conf['expack.misc.multi_favs']) { echo "<br>\n"; echo FavSetManager::makeFavSetSwitchElem('m_favita_set', 'お気に板', true, "replaceMenuItem('c_favita', 'm_favita_set', this.options[this.selectedIndex].value);"); } if ($_conf['expack.misc.multi_favs']) { $favset_title = FavSetManager::getFavSetPageTitleHt('m_favita_set', 'お気に板'); } else { $favset_title = 'お気に板'; } echo " <div class=\"itas\" id=\"c_favita\">\n"; if ($_conf['merge_favita']) { echo <<<EOP <a href="{$_conf['subject_php']}?spmode=merge_favita{$_conf['m_favita_set_at_a']}">{$favset_title} (まとめ)</a><br> EOP; } // favita読み込み $favitas = array(); if ($lines = FileCtl::file_read_lines($_conf['favita_brd'], FILE_IGNORE_NEW_LINES)) { foreach ($lines as $l) { if (preg_match("/^\t?(.+)\t(.+)\t(.+)\$/", $l, $matches)) { $favitas[] = array('host' => $matches[1], 'bbs' => $matches[2], 'itaj' => $matches[3]); } } } if ($favitas) { // 新着数を表示する場合・まとめてプリフェッチ if ($_conf['enable_menu_new'] && !empty($_GET['new'])) { if ($_conf['expack.use_pecl_http'] == 1) { P2HttpExt::activate(); P2HttpRequestPool::fetchSubjectTxt($favitas); $GLOBALS['expack.subject.multi-threaded-download.done'] = true; } elseif ($_conf['expack.use_pecl_http'] == 2) { if (P2CommandRunner::fetchSubjectTxt('merge_favita', $_conf)) { $GLOBALS['expack.subject.multi-threaded-download.done'] = true; } } } foreach ($favitas as $favita) { extract($favita); $itaj_view = p2h($itaj); $itaj_en = UrlSafeBase64::encode($itaj); $itaj_js = addslashes($itaj_view); $p_htm['star'] = <<<EOP <a href="{$menu_php_ht}?host={$host}&bbs={$bbs}&setfavita=0{$_conf['m_favita_set_at_a']}" target="_self" class="fav" title="「{$itaj_view}」をお気に板から外す" onclick="return window.confirm('「{$itaj_js}」をお気に板から外してよろしいですか?');">★</a> EOP; // onclick="return confirmSetFavIta('{$itaj_ht}');" // 新着数を表示する場合 if ($_conf['enable_menu_new'] && !empty($_GET['new'])) { $matome_i++; $spmode = null; // $shinchaku_num, $_newthre_num をセット include P2_LIB_DIR . '/subject_new.inc.php'; if ($shinchaku_num > 0) { $class_newres_num = ' class="newres_num"'; } else { $class_newres_num = ' class="newres_num_zero"'; } if ($_newthre_num) { $newthre_ht = "{$_newthre_num}"; } else { $newthre_ht = ''; } echo <<<EOP {$p_htm['star']} <a href="{$_conf['subject_php']}?host={$host}&bbs={$bbs}&itaj_en={$itaj_en}" onclick="chMenuColor({$matome_i});">{$itaj_view}</a> <span id="newthre{$matome_i}" class="newthre_num">{$newthre_ht}</span> (<a href="{$_conf['read_new_php']}?host={$host}&bbs={$bbs}" target="read" id="un{$matome_i}" onclick="chUnColor({$matome_i});"{$class_newres_num}>{$shinchaku_num}</a>)<br> EOP; // 新着数を表示しない場合 } else { echo <<<EOP {$p_htm['star']} <a href="{$_conf['subject_php']}?host={$host}&bbs={$bbs}&itaj_en={$itaj_en}">{$itaj_view}</a><br> EOP; } flush(); } // foreach // 空っぽなら } else { echo ' (空っぽ)'; } echo " </div>\n</div>\n"; }
} $subject_keys[$_id] = array(); $sb_key_txts[$_id] = array($_sb_keys_txt_a, $_sb_keys_txt_b); } } } if ($_conf['merge_favita'] == 2) { $kitoku_only = true; } } //============================================================ // 更新する場合、前もって一括&並列ダウンロード (要pecl_http) //============================================================ if (empty($_REQUEST['norefresh']) && !(empty($_REQUEST['refresh']) && isset($_REQUEST['word']))) { if ($_conf['expack.use_pecl_http'] == 1) { P2HttpExt::activate(); switch ($spmode) { case 'fav': P2HttpRequestPool::fetchSubjectTxt($_conf['favlist_idx']); $GLOBALS['expack.subject.multi-threaded-download.done'] = true; break; case 'recent': P2HttpRequestPool::fetchSubjectTxt($_conf['recent_idx']); $GLOBALS['expack.subject.multi-threaded-download.done'] = true; break; case 'res_hist': P2HttpRequestPool::fetchSubjectTxt($_conf['res_hist_idx']); $GLOBALS['expack.subject.multi-threaded-download.done'] = true; break; case 'merge_favita': P2HttpRequestPool::fetchSubjectTxt($favitas);
/** * ■ readList メソッド */ public function readList() { global $_conf; //$GLOBALS['debug'] && $GLOBALS['profiler']->enterSection('readList()'); switch ($this->spmode) { // ローカルの履歴ファイル 読み込み case 'recent': if ($lines = FileCtl::file_read_lines($_conf['recent_idx'])) { //P2Util::pushInfoHtml('<p>履歴は空っぽです</p>'); //return false; } break; // ローカルの書き込み履歴ファイル 読み込み // ローカルの書き込み履歴ファイル 読み込み case 'res_hist': if ($lines = FileCtl::file_read_lines($_conf['res_hist_idx'])) { //P2Util::pushInfoHtml('<p>書き込み履歴は空っぽです</p>'); //return false; } break; //ローカルのお気にファイル 読み込み //ローカルのお気にファイル 読み込み case 'fav': if ($lines = FileCtl::file_read_lines($_conf['favlist_idx'])) { //P2Util::pushInfoHtml('<p>お気にスレは空っぽです</p>'); //return false; } break; // お気に板をまとめて読み込み // お気に板をまとめて読み込み case 'merge_favita': $favitas = array(); if (file_exists($_conf['favita_brd'])) { foreach (file($_conf['favita_brd']) as $l) { if (preg_match("/^\t?(.+?)\t(.+?)\t.+?\$/", rtrim($l), $m)) { $favitas[] = array('host' => $m[1], 'bbs' => $m[2]); } } } if (empty($_REQUEST['norefresh']) && !(empty($_REQUEST['refresh']) && isset($_REQUEST['word']))) { if ($_conf['expack.use_pecl_http'] == 1) { P2HttpExt::activate(); P2HttpRequestPool::fetchSubjectTxt($favitas); $GLOBALS['expack.subject.multi-threaded-download.done'] = true; } elseif ($_conf['expack.use_pecl_http'] == 2) { if (P2CommandRunner::fetchSubjectTxt('merge_favita', $_conf)) { $GLOBALS['expack.subject.multi-threaded-download.done'] = true; } } } $lines = array(); $i = 0; foreach ($favitas as $ita) { $aSubjectTxt = new SubjectTxt($ita['host'], $ita['bbs']); $k = (double) sprintf('0.%d', ++$i); if (is_array($aSubjectTxt->subject_lines)) { $j = 0; foreach ($aSubjectTxt->subject_lines as $l) { if (preg_match('/^([0-9]+)\\.(?:dat|cgi)(?:,|<>)(.+) ?(?:\\(|()([0-9]+)(?:\\)|))/', $l, $m)) { $lines[] = array('key' => $m[1], 'ttitle' => rtrim($m[2]), 'rescount' => (int) $m[3], 'host' => $ita['host'], 'bbs' => $ita['bbs'], 'torder' => ++$j + $k); } } } } break; // p2_threads_aborn.idx 読み込み // p2_threads_aborn.idx 読み込み case 'taborn': $taborn_file = $this->getIdxDir() . 'p2_threads_aborn.idx'; $lines = FileCtl::file_read_lines($taborn_file); break; // spmodeがdat倉庫の場合 // spmodeがdat倉庫の場合 case 'soko': $dat_host_bbs_dir = $this->getDatDir(false); $idx_host_bbs_dir = $this->getIdxDir(false); $lines = array(); //$GLOBALS['debug'] && $GLOBALS['profiler']->enterSection('dat'); // datログディレクトリを走査して孤立datにidx付加 if ($cdir = dir($dat_host_bbs_dir)) { // or die ("ログディレクトリがないよ!"); // ディレクトリ走査 while ($entry = $cdir->read()) { if (preg_match('/([0-9]+)\\.dat$/', $entry, $matches)) { $theidx = $idx_host_bbs_dir . DIRECTORY_SEPARATOR . $matches[1] . '.idx'; if (!file_exists($theidx)) { $thedat = $dat_host_bbs_dir . DIRECTORY_SEPARATOR . $entry; if ($datlines = FileCtl::file_read_lines($thedat, FILE_IGNORE_NEW_LINES)) { $firstdatline = $datlines[0]; if (strpos($firstdatline, '<>') !== false) { $datline_sepa = '<>'; } else { $datline_sepa = ','; } $d = explode($datline_sepa, $firstdatline); $atitle = $d[4]; $gotnum = sizeof($datlines); $readnum = $gotnum; $anewline = $readnum + 1; $data = array($atitle, $matches[1], '', $gotnum, '', $readnum, '', '', '', $anewline, '', '', ''); P2Util::recKeyIdx($theidx, $data); } } // array_push($lines, $idl[0]); } } $cdir->close(); } //$GLOBALS['debug'] && $GLOBALS['profiler']->leaveSection('dat'); //$GLOBALS['debug'] && $GLOBALS['profiler']->enterSection('idx'); // {{{ idxログディレクトリを走査してidx情報を抽出してリスト化 if ($cdir = dir($idx_host_bbs_dir)) { // or die ("ログディレクトリがないよ!"); // ディレクトリ走査 while ($entry = $cdir->read()) { if (preg_match('/([0-9]+)\\.idx$/', $entry)) { $thedix = $idx_host_bbs_dir . DIRECTORY_SEPARATOR . $entry; $idl = FileCtl::file_read_lines($thedix); if (is_array($idl)) { array_push($lines, $idl[0]); } } } $cdir->close(); } // }}} //$GLOBALS['debug'] && $GLOBALS['profiler']->leaveSection('idx'); break; // スレの殿堂の場合 // p2_palace.idx 読み込み // スレの殿堂の場合 // p2_palace.idx 読み込み case 'palace': if ($lines = FileCtl::file_read_lines($_conf['palace_idx'])) { //P2Util::pushInfoHtml('<p>殿堂はがらんどうです</p>'); //return false; } break; // オンライン上の subject.txt を読み込む(spmodeでない場合) // オンライン上の subject.txt を読み込む(spmodeでない場合) default: if (!$this->spmode) { $aSubjectTxt = new SubjectTxt($this->host, $this->bbs); $lines = $aSubjectTxt->subject_lines; } } //$GLOBALS['debug'] && $GLOBALS['profiler']->leaveSection('readList()'); return $lines; }