-
Notifications
You must be signed in to change notification settings - Fork 45
/
Copy pathsubject_rss.php
115 lines (91 loc) · 2.98 KB
/
subject_rss.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
<?php
/**
* rep2expack - 簡易RSSリーダ(記事一覧)
*/
// {{{ p2基本設定読み込み&認証
require_once './conf/conf.inc.php';
require_once P2EX_LIB_DIR . '/rss/parser.inc.php';
$_login->authorize();
// }}}
if ($_conf['view_forced_by_query']) {
output_add_rewrite_var('b', $_conf['b']);
}
//============================================================
// 変数の初期化
//============================================================
$channel = array();
$items = array();
$num = trim($_REQUEST['num']);
$xml = trim($_REQUEST['xml']);
$atom = empty($_REQUEST['atom']) ? 0 : 1;
$site_en = trim($_REQUEST['site_en']);
$xml_en = rawurlencode($xml);
$xml_ht = htmlspecialchars($xml, ENT_QUOTES, 'Shift_JIS', false);
//============================================================
// RSS読み込み
//============================================================
if ($xml) {
$rss = p2GetRSS($xml, $atom);
if ($rss instanceof XML_RSS) {
clearstatcache();
$rss_parse_success = true;
$xml_path = rss_get_save_path($xml);
$mtime = filemtime($xml_path);
$channel = $rss->getChannelInfo();
$items = $rss->getItems();
$fp = fopen($xml_path, 'rb');
$xmldec = fgets($fp, 1024);
fclose($fp);
if (preg_match('/^<\\?xml version="1.0" encoding="((?i:iso)-8859-(?:[1-9]|1[0-5]))" ?\\?>/', $xmldec, $matches)) {
$encoding = $matches[1];
} else {
$encoding = 'UTF-8,CP51932,CP932,JIS';
}
mb_convert_variables('CP932', $encoding, $channel, $items);
} else {
$rss_parse_success = false;
}
} else {
$rss_parse_success = false;
}
//===================================================================
// HTML表示用変数の設定
//===================================================================
//タイトル
$title = isset($channel['title']) ? htmlspecialchars($channel['title'], ENT_QUOTES, 'Shift_JIS', false) : '';
//更新時刻
$reloaded_time = date('m/d G:i:s');
//============================================================
// HTMLプリント
//============================================================
if ($_conf['ktai']) {
if (!$_conf['expack.rss.check_interval']) {
// キャッシュさせない
P2Util::header_nocache();
} else {
// 更新チェック間隔の1/3だけキャッシュさせる(端末orゲートウェイの実装依存)
header(sprintf('Cache-Control: max-age=%d', $_conf['expack.rss.check_interval'] * 60 / 3));
}
}
echo $_conf['doctype'];
include P2EX_LIB_DIR . '/rss/' . ($_conf['ktai'] ? 'subject_k' : 'subject') . '.inc.php';
// {{{ rss_link2ch_callback()
/**
* 2ch,bbspink内リンクをp2で読むためのコールバック関数
*/
function rss_link2ch_callback($s)
{
global $_conf;
return "{$_conf['read_php']}?host={$s[1]}&bbs={$s[3]}&key={$s[4]}&ls={$s[6]}";
}
// }}}
/*
* 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: