GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — p2-php/subject.php at master · thermon/p2-php Expand file tree/ Copy pathsubject.phpMore file actions 1097 lines (906 loc) · 35.2 KB / Copy pathsubject.phpFile metadata and controls1097 lines (906 loc) · 35.2 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 <?php /** * rep2 - スレッドサブジェクト表示スクリプト * フレーム分割画面、右上部分 * * lib/subject_new.inc.php と兄弟なので、一緒に面倒をみること */ require_once './conf/conf.inc.php'; require_once P2_LIB_DIR . '/Thread.php'; require_once P2_LIB_DIR . '/ThreadList.php'; // +Wiki require_once P2_LIB_DIR . '/wiki/subject.inc.php'; //$GLOBALS['debug'] && $GLOBALS['profiler']->enterSection('HEAD'); $_login->authorize(); // ユーザ認証 //============================================================ // 変数設定 //============================================================ $newtime = date('gis'); $nowtime = time(); $abornoff_st = 'あぼーん解除'; $deletelog_st = 'ログを削除'; $kitoku_only = false; $online_num = 0; $shinchaku_num = 0; $shinchaku_attayo = false; $sb_disp_from = !empty($_REQUEST['from']) ? $_REQUEST['from'] : 1; // {{{ ホスト、板、モード設定 $host = isset($_REQUEST['host']) ? $_REQUEST['host'] : null; $bbs = isset($_REQUEST['bbs']) ? $_REQUEST['bbs'] : null; $spmode = isset($_REQUEST['spmode']) ? $_REQUEST['spmode'] : null; if (!($host && $bbs) && !$spmode) { p2die('必要な引数が指定されていません'); } // }}} // {{{ p2_setting, sb_keys 設定 if ($spmode) { if ($_conf['expack.misc.multi_favs'] && ($spmode == 'fav' || $spmode == 'merge_favita')) { $favset_key = ($spmode == 'fav') ? 'm_favlist_set' : 'm_favita_set'; $favset_suffix = (empty($_conf[$favset_key])) ? '' : $_conf[$favset_key]; $p2_setting_txt = $_conf['pref_dir'] . '/p2_setting_' . $spmode . $favset_suffix . '.txt'; } else { $p2_setting_txt = $_conf['pref_dir'] . '/p2_setting_' . $spmode . '.txt'; } } else { $idx_host_bbs_dir_s = P2Util::idxDirOfHostBbs($host, $bbs); $p2_setting_txt = $idx_host_bbs_dir_s . 'p2_setting.txt'; $sb_keys_b_txt = $idx_host_bbs_dir_s . 'p2_sb_keys_b.txt'; $sb_keys_txt = $idx_host_bbs_dir_s . 'p2_sb_keys.txt'; $pre_subject_keys = getSubjectKeys($sb_keys_txt, $sb_keys_b_txt); $subject_keys = array(); } // }}} // {{{ p2_setting 読み込み、セット $p2_setting = array('viewnum' => null, 'sort' => null, 'itaj' => null); if ($p2_setting_cont = FileCtl::file_read_contents($p2_setting_txt)) { $p2_setting = array_merge($p2_setting, unserialize($p2_setting_cont)); } $pre_setting['viewnum'] = isset($p2_setting['viewnum']) ? $p2_setting['viewnum'] : null; $pre_setting['sort'] = isset($p2_setting['sort']) ? $p2_setting['sort'] : null; $pre_setting['itaj'] = isset($p2_setting['itaj']) ? $p2_setting['itaj'] : null; $sb_view = !empty($_REQUEST['sb_view']) ? $_REQUEST['sb_view'] : 'normal'; if (!empty($_REQUEST['viewnum'])) { $p2_setting['viewnum'] = $_REQUEST['viewnum']; } elseif (!$p2_setting['viewnum']) { $p2_setting['viewnum'] = $_conf['display_threads_num']; // デフォルト値 } if (isset($_GET['itaj_en'])) { $p2_setting['itaj'] = base64_decode($_GET['itaj_en']); } // }}} // {{{ ソートの指定 if (!empty($_REQUEST['sort'])) { $now_sort = $_REQUEST['sort']; } else { if ($p2_setting['sort']) { $now_sort = $p2_setting['sort']; } else { if (!$spmode) { $now_sort = !empty($_conf['sb_sort_ita']) ? $_conf['sb_sort_ita'] : 'ikioi'; // 勢い } else { $now_sort = 'midoku'; // 新着 } } } // }}} // {{{ 表示スレッド数設定 $threads_num_max = 2000; if (!$spmode || $spmode == 'merge_favita') { $threads_num = $p2_setting['viewnum']; } elseif ($spmode == 'recent') { $threads_num = $_conf['rct_rec_num']; } elseif ($spmode == 'res_hist') { $threads_num = $_conf['res_hist_rec_num']; } else { $threads_num = 2000; } if ($p2_setting['viewnum'] == 'all' or $sb_view == 'shinchaku' or $sb_view == 'edit' or isset($_GET['word']) or $_conf['ktai']) { $threads_num = $threads_num_max; } // }}} // {{{ ワードフィルタ設定 $word = ''; $do_filtering = false; $GLOBALS['sb_mikke_num'] = 0; // デフォルトオプション, $sb_filter は global @see sb_print.inc.php $sb_filter = array('method' => 'and'); // 検索指定があれば if (empty($_REQUEST['submit_refresh']) or !empty($_REQUEST['submit_kensaku'])) { if (isset($_GET['word'])) { $GLOBALS['word'] = $_GET['word']; } elseif (isset($_POST['word'])) { $GLOBALS['word'] = $_POST['word']; } if (isset($_GET['method'])) { $sb_filter['method'] = $_GET['method']; } elseif (isset($_POST['method'])) { $sb_filter['method'] = $_POST['method']; } if ($sb_filter['method'] == 'similar') { $GLOBALS['wakati_word'] = $GLOBALS['word']; $GLOBALS['wakati_words'] = p2_wakati($GLOBALS['word']); if (!$GLOBALS['wakati_words']) { unset($GLOBALS['wakati_word'], $GLOBALS['wakati_words']); } else { $GLOBALS['wakati_hl_regex'] = p2_get_highlighting_regex($GLOBALS['wakati_words']); $GLOBALS['wakati_length'] = mb_strlen($GLOBALS['wakati_word'], 'CP932'); $GLOBALS['wakati_score'] = getSbScore($GLOBALS['wakati_words'], $GLOBALS['wakati_length']); if (!isset($_conf['expack.min_similarity'])) { $_conf['expack.min_similarity'] = 0.05; } elseif ($_conf['expack.min_similarity'] > 1) { $_conf['expack.min_similarity'] /= 100; } $_conf['expack.min_similarity'] = (float) $_conf['expack.min_similarity']; } $word = ''; } elseif (substr_count($word, '.') == strlen($word)) { $word = ''; } if (strlen($word) > 0) { if (p2_set_filtering_word($word, $sb_filter['method']) !== null) { $do_filtering = true; } } } // }}} //============================================================ // 特殊な前処理 //============================================================ // {{{ 削除 if (!empty($_GET['dele']) || (isset($_POST['submit']) && $_POST['submit'] == $deletelog_st)) { if ($host && $bbs) { require_once P2_LIB_DIR . '/dele.inc.php'; if ($_POST['checkedkeys']) { $dele_keys = $_POST['checkedkeys']; } else { $dele_keys = array($_GET['key']); } deleteLogs($host, $bbs, $dele_keys); } // }}} // お気に入りスレッド } elseif (isset($_GET['setfav']) && !empty($_GET['key']) && $host && $bbs) { require_once P2_LIB_DIR . '/setfav.inc.php'; setFav($host, $bbs, $_GET['key'], $_GET['setfav'], isset($_GET['ttitle_en']) ? base64_decode($_GET['ttitle_en']) : null); // 殿堂入り } elseif (isset($_GET['setpal']) && $_GET['key'] && $host && $bbs) { require_once P2_LIB_DIR . '/setpalace.inc.php'; setPal($host, $bbs, $_GET['key'], $_GET['setpal']); // あぼーんスレッド解除 } elseif ((isset($_POST['submit']) && $_POST['submit'] == $abornoff_st) && $host && $bbs && $_POST['checkedkeys']) { require_once P2_LIB_DIR . '/settaborn_off.inc.php'; settaborn_off($host, $bbs, $_POST['checkedkeys']); // スレッドあぼーん } elseif (isset($_GET['taborn']) && !is_null($_GET['key']) && $host && $bbs) { require_once P2_LIB_DIR . '/settaborn.inc.php'; settaborn($host, $bbs, $_GET['key'], $_GET['taborn']); } // お気に板をマージ if ($spmode == 'merge_favita') { $favitas = array(); $pre_subject_keys = array(); $subject_keys = array(); $sb_key_txts = array(); if (file_exists($_conf['favita_brd'])) { foreach (file($_conf['favita_brd']) as $l) { if (preg_match("/^\t?(.+?)\t(.+?)\t.+?\$/", rtrim($l), $matches)) { $_host = $matches[1]; $_bbs = $matches[2]; $_id = $_host . '/' . $_bbs; $_idx_host_bbs_dir_s = P2Util::idxDirOfHostBbs($_host, $_bbs); $_sb_keys_txt = $_idx_host_bbs_dir_s . 'p2_sb_keys.txt'; $_sb_keys_txt_a = $_idx_host_bbs_dir_s . 'p2_sb_keys_m.txt'; $_sb_keys_txt_b = $_idx_host_bbs_dir_s . 'p2_sb_keys_m_b.txt'; $favitas[$_id] = array('host' => $_host, 'bbs' => $_bbs); $pre_subject_keys[$_id] = getSubjectKeys($_sb_keys_txt, $_sb_keys_txt); foreach (getSubjectKeys($_sb_keys_txt_a, $_sb_keys_txt_b) as $_key => $_value) { $pre_subject_keys[$_id][$_key] = $_value; } $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) { require_once P2_LIB_DIR . '/P2HttpExt.php'; 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); $GLOBALS['expack.subject.multi-threaded-download.done'] = true; break; } } elseif ($_conf['expack.use_pecl_http'] == 2) { require_once P2_CLI_DIR . '/P2CommandRunner.php'; if (P2CommandRunner::fetchSubjectTxt($spmode, $_conf)) { $GLOBALS['expack.subject.multi-threaded-download.done'] = true; } } } //============================================================ // メイン //============================================================ $aThreadList = new ThreadList(); // {{{ 板とモードのセット $spmode_without_palace_or_favita = false; $ta_keys = array(); $ta_num = 0; if ($spmode) { if ($spmode == 'taborn' or $spmode == 'soko') { $aThreadList->setIta($host, $bbs, P2Util::getItaName($host, $bbs)); } if ($spmode != 'palace' && $spmode != 'merge_favita') { $spmode_without_palace_or_favita = true; } $aThreadList->setSpMode($spmode); } else { // if(!$p2_setting['itaj']){$p2_setting['itaj'] = P2Util::getItaName($host, $bbs);} $aThreadList->setIta($host, $bbs, $p2_setting['itaj']); // スレッドあぼーんリスト読込 $taborn_file = $aThreadList->getIdxDir() . 'p2_threads_aborn.idx'; if ($tabornlines = FileCtl::file_read_lines($taborn_file, FILE_IGNORE_NEW_LINES)) { $ta_num = sizeof($tabornlines); foreach ($tabornlines as $l) { $data = explode('<>', $l); $ta_keys[ $data[1] ] = true; } } } // }}} // ソースリスト読込 $lines = $aThreadList->readList(); // {{{ お気にスレリスト 読込 if ($favlines = FileCtl::file_read_lines($_conf['favlist_idx'], FILE_IGNORE_NEW_LINES)) { foreach ($favlines as $l) { $data = explode('<>', $l); $fav_keys[ $data[1] ] = $data[11]; } } // }}} //$GLOBALS['debug'] && $GLOBALS['profiler']->leaveSection('HEAD'); //============================================================ // それぞれの行解析 //============================================================ //$GLOBALS['debug'] && $GLOBALS['profiler']->enterSection('FORLOOP'); $linesize = sizeof($lines); $subject_txts = array(); for ($x = 0; $x < $linesize; $x++) { $aThread = new Thread(); if ($aThreadList->spmode == 'merge_favita') { $l = $lines[$x]; } else { $l = rtrim($lines[$x]); if ($aThreadList->spmode != 'soko' && $aThreadList->spmode != 'taborn') { $aThread->torder = $x + 1; } } // データ読み込み // spmode if ($aThreadList->spmode) { switch ($aThreadList->spmode) { case "recent": // 履歴 $aThread->getThreadInfoFromExtIdxLine($l); $aThread->itaj = P2Util::getItaName($aThread->host, $aThread->bbs); if (!$aThread->itaj) {$aThread->itaj = $aThread->bbs;} break; case "res_hist": // 書き込み履歴 $aThread->getThreadInfoFromExtIdxLine($l); $aThread->itaj = P2Util::getItaName($aThread->host, $aThread->bbs); if (!$aThread->itaj) {$aThread->itaj= $aThread->bbs;} break; case "fav": // お気に $aThread->getThreadInfoFromExtIdxLine($l); $aThread->itaj = P2Util::getItaName($aThread->host, $aThread->bbs); if (!$aThread->itaj) {$aThread->itaj = $aThread->bbs;} break; case "taborn": // スレッドあぼーん $la = explode('<>', $l); $aThread->key = $la[1]; $aThread->host = $aThreadList->host; $aThread->bbs = $aThreadList->bbs; break; case "soko": // dat倉庫 $la = explode('<>', $l); $aThread->key = $la[1]; $aThread->host = $aThreadList->host; $aThread->bbs = $aThreadList->bbs; break; case "palace": // スレの殿堂 $aThread->getThreadInfoFromExtIdxLine($l); $aThread->itaj = P2Util::getItaName($aThread->host, $aThread->bbs); if (!$aThread->itaj) {$aThread->itaj = $aThread->bbs;} break; case "merge_favita": // お気に板をマージ $aThread->isonline = true; $aThread->key = $l['key']; $aThread->setTtitle($l['ttitle']); $aThread->rescount = $l['rescount']; $aThread->host = $l['host']; $aThread->bbs = $l['bbs']; $aThread->torder = $l['torder']; $aThread->itaj = P2Util::getItaName($aThread->host, $aThread->bbs); if (!$aThread->itaj) {$aThread->itaj = $aThread->bbs;} break; } // subject (not spmode つまり普通の板) } else { $aThread->getThreadInfoFromSubjectTxtLine($l); $aThread->host = $aThreadList->host; $aThread->bbs = $aThreadList->bbs; } // メモリ節約(特にmerge_favita)のため $lines[$x] = null; // hostかbbsかkeyが不明ならスキップ if (!($aThread->host && $aThread->bbs && $aThread->key)) { unset($aThread); continue; } $subject_id = $aThread->host . '/' . $aThread->bbs; // ここで一旦スレッドリストにまとめて、キャッシュもさせようかと思ったが、メモリ消費(750K→2M)が激しかったのでやめておいた。 // {{{ 新しいかどうか(for subject) if (!$aThreadList->spmode) { if (!isset($pre_subject_keys[$aThread->key])) { $aThread->new = true; } $subject_keys[$aThread->key] = true; } elseif ($aThreadList->spmode == 'merge_favita') { if (!isset($pre_subject_keys[$subject_id][$aThread->key])) { $aThread->new = true; } $subject_keys[$subject_id][$aThread->key] = true; } // }}} // {{{ ■ワードフィルタ(for subject) //$GLOBALS['debug'] && $GLOBALS['profiler']->enterSection('word_filter_for_sb'); if ($do_filtering && !$spmode_without_palace_or_favita) { $aThread->setThreadPathInfo($aThread->host, $aThread->bbs, $aThread->key); // マッチしなければスキップ if (!matchSbFilter($aThread)) { unset($aThread); //$GLOBALS['debug'] && $GLOBALS['profiler']->leaveSection('word_filter_for_sb'); continue; // マッチした時 } else { $GLOBALS['sb_mikke_num']++; if ($_conf['ktai']) { if (is_string($_conf['k_filter_marker'])) { $aThread->ttitle_ht = StrCtl::filterMarking($GLOBALS['word_fm'], $aThread->ttitle_hd, $_conf['k_filter_marker']); } else { $aThread->ttitle_ht = $aThread->ttitle_hd; } } else { $aThread->ttitle_ht = StrCtl::filterMarking($GLOBALS['word_fm'], $aThread->ttitle_hd); } } } elseif (!$aThreadList->spmode && !empty($GLOBALS['wakati_words'])) { // 類似スレ検索 if (!setSbSimilarity($aThread) || $aThread->similarity < $_conf['expack.min_similarity']) { unset($aThread); //$GLOBALS['debug'] && $GLOBALS['profiler']->leaveSection('word_filter_for_sb'); continue; } if ($_conf['ktai']) { if (is_string($_conf['k_filter_marker'])) { $aThread->ttitle_ht = StrCtl::filterMarking($GLOBALS['wakati_hl_regex'], $aThread->ttitle_ht, $_conf['k_filter_marker']); } } else { $aThread->ttitle_ht = StrCtl::filterMarking($GLOBALS['wakati_hl_regex'], $aThread->ttitle_ht); } } //$GLOBALS['debug'] && $GLOBALS['profiler']->leaveSection('word_filter_for_sb'); // }}} // {{{ ■スレッドあぼーんチェック //$GLOBALS['debug'] && $GLOBALS['profiler']->enterSection('taborn_check_continue'); if ($aThreadList->spmode != "taborn" && !empty($ta_keys[$aThread->key])) { unset($ta_keys[$aThread->key]); //$GLOBALS['debug'] && $GLOBALS['profiler']->leaveSection('taborn_check_continue'); continue; // あぼーんスレはスキップ } //$GLOBALS['debug'] && $GLOBALS['profiler']->leaveSection('taborn_check_continue'); // }}} $aThread->setThreadPathInfo($aThread->host, $aThread->bbs, $aThread->key); // 既得スレッドデータをidxから取得 $aThread->getThreadInfoFromIdx(); // {{{ ■+Wiki:NGスレッドチェック if (isset($ngaborns)) if ($ngaborns->check($aThread)) continue; // }}} if ($kitoku_only && !$aThread->isKitoku()) { unset($aThread); if ($do_filtering) { $GLOBALS['sb_mikke_num']--; } continue; } // {{{ ■ favlistチェック //$GLOBALS['debug'] && $GLOBALS['profiler']->enterSection('favlist_check'); // if ($x <= $threads_num) { if ($aThreadList->spmode != 'taborn' and isset($fav_keys[$aThread->key]) && $fav_keys[$aThread->key] == $aThread->bbs) { $aThread->fav = 1; unset($fav_keys[$aThread->key]); } // } //$GLOBALS['debug'] && $GLOBALS['profiler']->leaveSection('favlist_check'); // }}} // spmode(殿堂入り、merge_favitaを除く)なら ==================================== if ($spmode_without_palace_or_favita && $sb_view != 'edit') { // subject.txt が未DLなら落としてデータを配列に格納 if (!isset($subject_txts[$subject_id])) { $subject_txts[$subject_id] = array(); require_once P2_LIB_DIR . '/SubjectTxt.php'; $aSubjectTxt = new SubjectTxt($aThread->host, $aThread->bbs); //$GLOBALS['debug'] && $GLOBALS['profiler']->enterSection('subthre_read'); if ($aThreadList->spmode == 'soko' or $aThreadList->spmode == 'taborn') { if (is_array($aSubjectTxt->subject_lines)) { $it = 1; foreach ($aSubjectTxt->subject_lines as $asbl) { if (preg_match("/^([0-9]+)\.(?:dat|cgi)(?:,|<>)(.+) ?(?:\(|()([0-9]+)(?:\)|))/", $asbl, $matches)) { $akey = $matches[1]; $subject_txts[$subject_id][$akey] = array( 'ttitle' => rtrim($matches[2]), 'rescount' => (int)$matches[3], 'torder' => $it, ); } $it++; } } } else { $subject_txts[$subject_id] = $aSubjectTxt->subject_lines; } //$GLOBALS['debug'] && $GLOBALS['profiler']->leaveSection('subthre_read'); } //$GLOBALS['debug'] && $GLOBALS['profiler']->enterSection('subthre_check'); // スレ情報取得 ============================= if ($aThreadList->spmode == "soko" or $aThreadList->spmode == "taborn") { if (isset($subject_txts[$subject_id][$aThread->key])) { // 倉庫はオンラインを含まない if ($aThreadList->spmode == "soko") { unset($aThread); continue; } elseif ($aThreadList->spmode == "taborn") { // $aThread->getThreadInfoFromSubjectTxtLine($l); // subject.txt からスレ情報取得 $aThread->isonline = true; $ttitle = $subject_txts[$subject_id][$aThread->key]['ttitle']; $aThread->setTtitle($ttitle); $aThread->rescount = $subject_txts[$subject_id][$aThread->key]['rescount']; if ($aThread->readnum) { $aThread->unum = $aThread->rescount - $aThread->readnum; // machi bbs はsageでsubjectの更新が行われないそうなので調整しておく if ($aThread->unum < 0) { $aThread->unum = 0; } $aThread->nunum = $aThread->unum; } $aThread->torder = $subject_txts[$subject_id][$aThread->key]['torder']; } } } else { if (isset($subject_txts[$subject_id])) { $it = 1; $thread_key = (string)$aThread->key; $thread_key_len = strlen($thread_key); foreach ($subject_txts[$subject_id] as $l) { if (strncmp($l, $thread_key, $thread_key_len) == 0) { // subject.txt からスレ情報取得 $aThread->getThreadInfoFromSubjectTxtLine($l); break; } $it++; } } } //$GLOBALS['debug'] && $GLOBALS['profiler']->leaveSection('subthre_check'); if ($aThreadList->spmode == "taborn") { if (!$aThread->torder) { $aThread->torder = '-'; } } // {{{ ■新着のみ(for spmode) if ($sb_view == 'shinchaku' and !isset($_REQUEST['word'])) { if ($aThread->unum < 1) { unset($aThread); continue; } } // }}} // {{{ ■ワードフィルタ(for spmode) if ($do_filtering) { // マッチしなければスキップ if (!matchSbFilter($aThread)) { unset($aThread); continue; // マッチした時 } else { $GLOBALS['sb_mikke_num']++; if ($_conf['ktai']) { $aThread->ttitle_ht = $aThread->ttitle_hd; } else { $aThread->ttitle_ht = StrCtl::filterMarking($GLOBALS['word_fm'], $aThread->ttitle_hd); } } } // }}} } //$GLOBALS['debug'] && $GLOBALS['profiler']->enterSection('FORLOOP_HIP'); // subjexctからrescountが取れなかった場合は、gotnumを利用する。 if ((!$aThread->rescount) and $aThread->gotnum) { $aThread->rescount = $aThread->gotnum; } // マーキング等の処理をしない場合 ttitle_hc, ttitle_hd, ttitle_ht はJITで設定される //if (!$aThread->ttitle_ht) { $aThread->ttitle_ht = $aThread->ttitle_hd; } // 新着あり if ($aThread->unum > 0) { $shinchaku_attayo = true; $shinchaku_num = $shinchaku_num + $aThread->unum; // 新着数set /* // お気にスレ } elseif ($aThread->fav) { ; // 新規スレ } elseif ($aThread->new) { ; */ } // {{{ 新着ソートの便宜上 (未取得スレッドの)unum をセット調整 if (!isset($aThread->unum)) { if ($aThreadList->spmode == "recent" or $aThreadList->spmode == "res_hist" or $aThreadList->spmode == "taborn") { $aThread->unum = -0.1; } else { $aThread->unum = $_conf['sort_zero_adjust']; } } // }}} // 勢いのセット $aThread->setDayRes($nowtime); // 生存数set if ($aThread->isonline) { $online_num++; } // リストに追加 $aThreadList->addThread($aThread); unset($aThread); //$GLOBALS['debug'] && $GLOBALS['profiler']->leaveSection('FORLOOP_HIP'); } unset($lines); //$GLOBALS['debug'] && $GLOBALS['profiler']->leaveSection('FORLOOP'); //$GLOBALS['debug'] && $GLOBALS['profiler']->enterSection('FOOT'); // 既にdat落ちしているスレは自動的にあぼーんを解除する autoTAbornOff($aThreadList, $ta_keys); // ソート if (!empty($GLOBALS['wakati_words'])) { $now_sort = 'title'; $sort_mode = 'similarity'; } else { $sort_mode = $now_sort; } $aThreadList->sort($sort_mode, !empty($_REQUEST['rsort'])); // ソート後、お気に板の既得スレidxを作成 (新着まとめ読みの効率を良くするためのキャッシュ) if ($spmode == 'merge_favita') { if ($_conf['expack.misc.multi_favs'] && !empty($_conf['m_favita_set'])) { $merged_faivta_read_idx = $_conf['pref_dir'] . '/p2_favita' . $_conf['m_favita_set'] . '_read.idx'; } else { $merged_faivta_read_idx = $_conf['pref_dir'] . '/p2_favita_read.idx'; } FileCtl::make_datafile($merged_faivta_read_idx, $_conf['p2_perm']); $fp = fopen($merged_faivta_read_idx, 'wb'); if (!$fp || !flock($fp, LOCK_EX)) { p2die("cannot write file {$merged_faivta_read_idx}."); } foreach ($aThreadList->threads as $aThread) { if ($aThread->isKitoku()) { fwrite($fp, sprintf("%s<>%d<><><><>%d<><><><>%d<>%s<>%s\n", $aThread->ttitle, $aThread->key, $aThread->readnum, $aThread->readnum + 1, // newline 旧互換のため $aThread->host, $aThread->bbs ) ); } } flock($fp, LOCK_UN); fclose($fp); } //=============================================================== // プリント //=============================================================== // 携帯 if ($_conf['ktai']) { // {{{ 倉庫にtorder付与 if ($aThreadList->spmode == "soko") { if ($aThreadList->threads) { $soko_torder = 1; foreach ($aThreadList->threads as $at) { $at->torder = $soko_torder++; } } } // }}} // {{{ 表示数制限 // 念のため、補正しておく $aThreadList->num = count($aThreadList->threads); $sb_disp_all_num = $aThreadList->num; $disp_navi = P2Util::getListNaviRange($sb_disp_from , $_conf['mobile.sb_disp_range'], $sb_disp_all_num); if ($aThreadList->threads) { $aThreadList->threads = array_slice($aThreadList->threads, $disp_navi['offset'], $disp_navi['limit']); } $aThreadList->num = sizeof($aThreadList->threads); // }}} // ヘッダプリント require_once P2_LIB_DIR . '/sb_header_k.inc.php'; // メインプリント require_once P2_LIB_DIR . '/sb_print_k.inc.php'; sb_print_k($aThreadList); // フッタプリント require_once P2_LIB_DIR . '/sb_footer_k.inc.php'; // PC } else { // {{{ 表示数制限 // 念のため、補正しておく $aThreadList->num = count($aThreadList->threads); $threads_num = max(1, (int)$threads_num); if ($_conf['viewall_kitoku']) { if (!$kitoku_only) { $read_threads = array(); while ($aThreadList->num > $threads_num) { $x = --$aThreadList->num; if ($aThreadList->threads[$x]->isKitoku()) { $read_threads[] = $aThreadList->threads[$x]; } unset($aThreadList->threads[$x]); } foreach ($read_threads as $aThread) { $aThreadList->threads[] = $aThread; } unset($read_threads); } } else { while ($aThreadList->num > $threads_num) { unset($aThreadList->threads[--$aThreadList->num]); } } // }}} // ヘッダHTMLを表示 //$GLOBALS['debug'] && $GLOBALS['profiler']->enterSection('sb_header'); require_once P2_LIB_DIR . '/sb_header.inc.php'; flush(); //$GLOBALS['debug'] && $GLOBALS['profiler']->leaveSection('sb_header'); // スレッドサブジェクトメイン部分HTML表示 require_once P2_LIB_DIR . '/sb_print.inc.php'; sb_print($aThreadList); // フッタHTML表示 //$GLOBALS['debug'] && $GLOBALS['profiler']->enterSection('sb_footer'); require_once P2_LIB_DIR . '/sb_footer.inc.php'; //$GLOBALS['debug'] && $GLOBALS['profiler']->leaveSection('sb_footer'); } //============================================================== // 後処理 //============================================================== // p2_setting(sb設定) 記録 saveSbSetting($p2_setting_txt, $p2_setting, $pre_setting); // $subject_keys をシリアライズして保存する if (!$spmode) { saveSubjectKeys($subject_keys, $sb_keys_txt, $sb_keys_b_txt); } elseif ($spmode == 'merge_favita') { foreach ($sb_key_txts as $id => $txts) { saveSubjectKeys($subject_keys[$id], $txts[0], $txts[1]); } } //$GLOBALS['debug'] && $GLOBALS['profiler']->leaveSection('FOOT'); // +Wiki:NGスレッド //if (isset($ngaborns)) $ngaborns->save(); // ここまで exit; // {{{ 関数 // {{{ autoTAbornOff() /** * 既にdat落ちしているスレは自動的にあぼーんを解除する * $ta_keys はあぼーんリストに入っていたけれど、あぼーんされずに残ったスレたち */ function autoTAbornOff($aThreadList, $ta_keys) { global $_info_msg_ht; //$GLOBALS['debug'] && $GLOBALS['profiler']->enterSection('abornoff'); if (!$aThreadList->spmode && !empty($GLOBALS['word']) && !empty($GLOBALS['wakati_word']) && $aThreadList->threads && $ta_keys) { require_once P2_LIB_DIR . '/settaborn_off.inc.php'; // echo sizeof($ta_keys)."*<br>"; $ta_vkeys = array_keys($ta_keys); settaborn_off($aThreadList->host, $aThreadList->bbs, $ta_vkeys); foreach ($ta_vkeys as $k) { $ta_num--; if ($k) { $ks .= "key:$k "; } } $ks && $_info_msg_ht .= "<div class=\"info\"> p2 info: DAT落ちしたスレッドあぼーんを自動解除しました - $ks</div>"; } //$GLOBALS['debug'] && $GLOBALS['profiler']->leaveSection('abornoff'); return true; } // }}} // {{{ saveSbSetting() /** * p2_setting 記録する */ function saveSbSetting($p2_setting_txt, $p2_setting, $pre_setting) { global $_conf; //$GLOBALS['debug'] && $GLOBALS['profiler']->enterSection('save_p2_setting'); if ($pre_setting['viewnum'] != $p2_setting['viewnum'] or $pre_setting['sort'] != $GLOBALS['now_sort'] or $pre_setting['itaj'] != $p2_setting['itaj']) { if (!empty($_POST['sort'])) { $p2_setting['sort'] = $_POST['sort']; } elseif (!empty($_GET['sort'])) { $p2_setting['sort'] = $_GET['sort']; } FileCtl::make_datafile($p2_setting_txt, $_conf['p2_perm']); if ($p2_setting) { if ($p2_setting_cont = serialize($p2_setting)) { if (FileCtl::file_write_contents($p2_setting_txt, $p2_setting_cont) === false) { p2die('cannot write file.'); } } } } //$GLOBALS['debug'] && $GLOBALS['profiler']->leaveSection('save_p2_setting'); return true; } // }}} // {{{ getSubjectKeys() /** * $subject_keys を取得する */ function getSubjectKeys($sb_keys_txt, $sb_keys_b_txt) { // 更新しない場合は、2つ前のと1つ前のを比べて、新規スレを調べる if (!empty($_REQUEST['norefresh']) || (empty($_REQUEST['refresh']) && isset($_REQUEST['word']))) { $file = $sb_keys_b_txt; } else { $file = $sb_keys_txt; } if (file_exists($file) && $cont = FileCtl::file_read_contents($file)) { if (is_array($subject_keys = @unserialize($cont))) { return $subject_keys; } } return array(); } // }}} // {{{ saveSubjectKeys() /** * $subject_keys をシリアライズして保存する */ function saveSubjectKeys($subject_keys, $sb_keys_txt, $sb_keys_b_txt) { global $_conf; //$GLOBALS['debug'] && $GLOBALS['profiler']->enterSection('saveSubjectKeys()'); //if (file_exists($sb_keys_b_txt)) { unlink($sb_keys_b_txt); } if (empty($_REQUEST['norefresh']) && !empty($subject_keys)) { if (file_exists($sb_keys_txt)) { FileCtl::make_datafile($sb_keys_b_txt, $_conf['p2_perm']); copy($sb_keys_txt, $sb_keys_b_txt); } else { FileCtl::make_datafile($sb_keys_txt, $_conf['p2_perm']); } if ($sb_keys_cont = serialize($subject_keys)) { if (FileCtl::file_write_contents($sb_keys_txt, $sb_keys_cont) === false) { p2die('cannot write file.'); } } } //$GLOBALS['debug'] && $GLOBALS['profiler']->leaveSection('saveSubjectKeys()'); return true; } // }}} // {{{ matchSbFilter() /** * スレタイ(と本文)でマッチしたらtrueを返す */ function matchSbFilter(Thread $aThread) { // 全文検索でdatがあれば、内容を読み込む if (!empty($_REQUEST['find_cont'])) { |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |