/
subject_new.php
344 lines (272 loc) · 11.1 KB
/
subject_new.php
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
<?php
/*
//p2 - スレッドサブジェクト表示スクリプト
//フレーム分割画面、右上部分
無理矢理だが、板メニューで新着数を知るために使用している // $shinchaku_num, $_newthre_num をセット
subject.php と兄弟なので一緒に面倒をみる
$host, $bbs, $spmode をあらかじめ準備しておく
*/
$shinchaku_num = 0;
$_newthre_num = 0;
//require_once './conf/conf.inc.php';
require_once P2_LIB_DIR . '/ThreadList.php';
require_once P2_LIB_DIR . '/Thread.php';
require_once P2_LIB_DIR . '/subject.funcs.php';
if (!empty($aThreadList)) {
unset($aThreadList);
}
//============================================================
// 変数設定
//============================================================
if (isset($_GET['from'])) { $sb_disp_from = $_GET['from']; }
if (isset($_POST['from'])) { $sb_disp_from = $_POST['from']; }
if (!isset($sb_disp_from)) { $sb_disp_from = 1; }
// p2_setting 設定
if ($spmode) {
$p2_setting_txt = $_conf['pref_dir'] . "/p2_setting_" . $spmode . ".txt";
} else {
$idx_bbs_dir_s = P2Util::idxDirOfHostBbs($host, $bbs);
$p2_setting_txt = $idx_bbs_dir_s . "p2_setting.txt";
$sb_keys_b_txt = $idx_bbs_dir_s . "p2_sb_keys_b.txt";
$sb_keys_txt = $idx_bbs_dir_s . "p2_sb_keys.txt";
if (!empty($_REQUEST['norefresh']) || !empty($_REQUEST['word'])) {
if ($prepre_sb_cont = @file_get_contents($sb_keys_b_txt)) {
$prepre_sb_keys = unserialize($prepre_sb_cont);
}
} else {
if ($pre_sb_cont = @file_get_contents($sb_keys_txt)) {
$pre_sb_keys = unserialize($pre_sb_cont);
}
}
}
// p2_setting 読み込み
$p2_setting = sbLoadP2SettingTxt($p2_setting_txt);
$p2_setting = sbSetP2SettingWithQuery($p2_setting);
if (isset($_GET['sb_view'])) { $sb_view = $_GET['sb_view']; }
if (isset($_POST['sb_view'])) { $sb_view = $_POST['sb_view']; }
if (empty($sb_view)) {$sb_view = "normal";}
// 表示スレッド数 ====================================
$threads_num_max = 2000;
if (!$spmode || $spmode=="news") {
$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") { $threads_num = $threads_num_max; }
elseif ($sb_view == "shinchaku") { $threads_num = $threads_num_max; }
elseif ($sb_view == "edit") { $threads_num = $threads_num_max; }
elseif (isset($_GET['word'])) { $threads_num = $threads_num_max; }
elseif ($_conf['ktai']) { $threads_num = $threads_num_max; }
//============================================================
// メイン
//============================================================
$aThreadList = new ThreadList;
// 板とモードのセット ===================================
if ($spmode) {
if ($spmode == "taborn" or $spmode == "soko") {
$aThreadList->setIta($host, $bbs, P2Util::getItaName($host, $bbs));
}
$aThreadList->setSpMode($spmode);
} else {
// if (!$p2_setting['itaj']) { $p2_setting['itaj'] = P2Util::getItaName($host, $bbs); }
$itaj = isset($p2_setting['itaj']) ? $p2_setting['itaj'] : null;
$aThreadList->setIta($host, $bbs, $itaj);
// スレッドあぼーんリスト読込
$ta_keys = P2Util::getThreadAbornKeys($aThreadList->host, $aThreadList->bbs);
//$ta_num = sizeOf($ta_keys);
}
// ソースリスト読込
$lines = $aThreadList->readList();
// お気にスレリスト 読込
if (file_exists($_conf['favlist_file'])) {
$favlines = file($_conf['favlist_file']);
if (is_array($favlines)) {
foreach ($favlines as $l) {
$data = explode('<>', rtrim($l));
$fav_keys[ $data[1] ] = true;
}
}
}
//============================================================
// それぞれの行解析
//============================================================
$nowtime = time();
$linesize = sizeof($lines);
for ($x = 0; $x < $linesize ; $x++) {
$l = rtrim($lines[$x]);
$aThread = new Thread;
if ($aThreadList->spmode != "taborn" and $aThreadList->spmode != "soko") {
$aThread->torder = $x + 1;
}
// ラインからスレッドデータを読み込んでセット
$aThread->setThreadInfoFromLineWithThreadList($l, $aThreadList);
// hostかbbsかkeyが不明ならスキップ
if (!($aThread->host && $aThread->bbs && $aThread->key)) {
unset($aThread);
continue;
}
// {{{ 新しいかどうか(for subject)
if (!$aThreadList->spmode) {
if (!empty($_REQUEST['norefresh']) || !empty($_REQUEST['word'])) {
if (empty($prepre_sb_keys[$aThread->key])) {
$aThread->new = true;
}
} else {
if (empty($pre_sb_keys[$aThread->key])) {
$aThread->new = true;
}
$subject_keys[$aThread->key] = true;
}
}
// }}}
// {{{ スレッドあぼーんチェック
if ($aThreadList->spmode != 'taborn' and !empty($ta_keys[$aThread->key])) {
unset($ta_keys[$aThread->key]);
continue; //あぼーんスレはスキップ
}
$aThread->setThreadPathInfo($aThread->host, $aThread->bbs, $aThread->key);
$aThread->getThreadInfoFromIdx(); // 既得スレッドデータをidxから取得
// }}}
// {{{ favlistチェック
!empty($debug) && $profiler->enterSection('favlist_check');
// if ($x <= $threads_num) {
if ($aThreadList->spmode != 'taborn' and !empty($fav_keys[$aThread->key])) {
$aThread->fav = 1;
unset($fav_keys[$aThread->key]);
}
// }
!empty($debug) && $profiler->leaveSection('favlist_check');
// }}}
// ■ spmode(殿堂入り、newsを除く)なら ====================================
if ($aThreadList->spmode && $aThreadList->spmode!="news" && $sb_view!="edit") {
// {{{ subject.txtが未DLなら落としてデータを配列に格納する
if (empty($subject_txts["$aThread->host/$aThread->bbs"])) {
require_once P2_LIB_DIR . '/SubjectTxt.php';
$aSubjectTxt = new SubjectTxt($aThread->host, $aThread->bbs);
!empty($debug) && $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["$aThread->host/$aThread->bbs"][$akey]['ttitle'] = rtrim($matches[4]);
$subject_txts["$aThread->host/$aThread->bbs"][$akey]['rescount'] = $matches[6];
$subject_txts["$aThread->host/$aThread->bbs"][$akey]['torder'] = $it;
}
$it++;
}
}
} else {
$subject_txts["$aThread->host/$aThread->bbs"] = $aSubjectTxt->subject_lines;
}
!empty($debug) && $profiler->leaveSection('subthre_read');//
}
// }}}
!empty($debug) && $profiler->enterSection('subthre_check');//
// ■スレ情報取得 =============================
if ($aThreadList->spmode == "soko" or $aThreadList->spmode == "taborn") {
if ($subject_txts[$aThread->host.'/'.$aThread->bbs][$aThread->key]) {
// 倉庫はオンラインを含まない
if ($aThreadList->spmode == "soko") {
!empty($debug) && $profiler->leaveSection('subthre_check'); //
unset($aThread);
continue;
} elseif ($aThreadList->spmode == "taborn") {
// subject.txt からスレ情報取得
// $aThread->setThreadInfoFromSubjectTxtLine($l);
$aThread->isonline = true;
$ttitle = $subject_txts["$aThread->host/$aThread->bbs"][$aThread->key]['ttitle'];
$aThread->setTtitle($ttitle);
$aThread->rescount = $subject_txts["$aThread->host/$aThread->bbs"][$aThread->key]['rescount'];
if ($aThread->readnum) {
$aThread->unum = $aThread->rescount - $aThread->readnum;
// machi bbs はsageでsubjectの更新が行われないそうなので調整しておく
if ($aThread->unum < 0) { $aThread->unum = 0; }
}
$aThread->torder = $subject_txts["$aThread->host/$aThread->bbs"][$aThread->key]['torder'];
}
}
} else {
if ($subject_txts[$aThread->host.'/'.$aThread->bbs]) {
$it = 1;
foreach ($subject_txts[$aThread->host.'/'.$aThread->bbs] as $l) {
if (@preg_match("/^{$aThread->key}/", $l)) {
// subject.txt からスレ情報取得
$aThread->setThreadInfoFromSubjectTxtLine($l);
break;
}
$it++;
}
}
}
!empty($debug) && $profiler->leaveSection('subthre_check'); //
if ($aThreadList->spmode == 'taborn') {
if (!$aThread->torder) { $aThread->torder = '-'; }
}
// 新着のみ(for spmode)
if ($sb_view == 'shinchaku' and !$_GET['word']) {
if ($aThread->unum < 1) {
unset($aThread);
continue;
}
}
}
// subjectからrescountが取れなかった場合は、gotnumを利用する。
if ((!$aThread->rescount) and $aThread->gotnum) {
$aThread->rescount = $aThread->gotnum;
}
if (!$aThread->ttitle_ht) {
$aThread->ttitle_ht = $aThread->ttitle;
}
if ($aThread->unum > 0) { // 新着あり
$shinchaku_num += $aThread->unum; // 新着数set
} elseif ($aThread->fav) { // お気にスレ
;
} elseif ($aThread->new) { // 新規スレ
$_newthre_num++; // ※ShowBrdMenuPc.php
} else {
// 携帯とニュースチェック以外で
if ($_conf['ktai'] or $spmode != "news") {
// 指定数を越えていたらカット
if($x >= $threads_num){
unset($aThread);
continue;
}
}
}
/*
// 新着ソートの便宜上 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);
}
// $shinchaku_num
/*
* 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: