svnno****@sourc*****
svnno****@sourc*****
2010年 1月 5日 (火) 23:48:56 JST
Revision: 766 http://sourceforge.jp/projects/p2-php/svn/view?view=rev&revision=766 Author: rsk Date: 2010-01-05 23:48:56 +0900 (Tue, 05 Jan 2010) Log Message: ----------- expack: - rev.100105.2345. - RSSã®æ¦è¦ãªã³ã¯ãããã¦ããã®ãä¿®æ£ã Modified Paths: -------------- p2ex/trunk/conf/conf.inc.php p2ex/trunk/lib/P2Util.php p2ex/trunk/lib/expack/rss/parser.inc.php p2ex/trunk/lib/expack/rss/setrss.inc.php p2ex/trunk/lib/expack/rss/subject.inc.php p2ex/trunk/read_rss.php p2ex/trunk/subject_rss.php -------------- next part -------------- Modified: p2ex/trunk/conf/conf.inc.php =================================================================== --- p2ex/trunk/conf/conf.inc.php 2010-01-05 12:50:04 UTC (rev 765) +++ p2ex/trunk/conf/conf.inc.php 2010-01-05 14:48:56 UTC (rev 766) @@ -7,7 +7,7 @@ // o[Wîñ $_conf = array( 'p2version' => '1.7.29+1.8.x', // rep2Ìo[W - 'p2expack' => '100105.2130', // g£pbNÌo[W + 'p2expack' => '100105.2345', // g£pbNÌo[W 'p2name' => 'expack', // rep2̼O ); Modified: p2ex/trunk/lib/P2Util.php =================================================================== --- p2ex/trunk/lib/P2Util.php 2010-01-05 12:50:04 UTC (rev 765) +++ p2ex/trunk/lib/P2Util.php 2010-01-05 14:48:56 UTC (rev 766) @@ -62,7 +62,9 @@ /** * t@Cð_E[hÛ¶·é */ - static public function fileDownload($url, $localfile, $disp_error = true) + static public function fileDownload($url, $localfile, + $disp_error = true, + $trace_redirection = false) { global $_conf, $_info_msg_ht; @@ -88,6 +90,15 @@ } $wap_res = $wap_ua->request($wap_req); + // 1iK¾¯_CNgðÇÕ + if ($wap_res->isRedirect() && array_key_exists('Location', $wap_res->headers) && + ($trace_redirection === true || $trace_redirection == $wap_res->code)) + { + $wap_req->setUrl($wap_res->headers['Location']); + $wap_res = $wap_ua->request($wap_req); + } + + // G[bZ[WðÝè if ($wap_res->isError() && $disp_error) { $url_t = self::throughIme($wap_req->url); $_info_msg_ht .= "<div>Error: {$wap_res->code} {$wap_res->message}<br>"; Modified: p2ex/trunk/lib/expack/rss/parser.inc.php =================================================================== --- p2ex/trunk/lib/expack/rss/parser.inc.php 2010-01-05 12:50:04 UTC (rev 765) +++ p2ex/trunk/lib/expack/rss/parser.inc.php 2010-01-05 14:48:56 UTC (rev 766) @@ -34,7 +34,7 @@ /** * RSSð_E[hµAp[XÊðÔ· */ -function p2GetRSS($remotefile, $atom=0) +function p2GetRSS($remotefile, $atom = 0) { global $_conf, $_info_msg_ht; @@ -55,7 +55,7 @@ if (!file_exists($localpath) || $refresh || filemtime($localpath) < (time() - $_conf['expack.rss.check_interval'] * 60) ) { - $dl = P2Util::fileDownload($remotefile, $localpath); + $dl = P2Util::fileDownload($remotefile, $localpath, true, 301); if ($dl->isSuccess()) { chmod($localpath, $_conf['expack.rss.setting_perm']); } Modified: p2ex/trunk/lib/expack/rss/setrss.inc.php =================================================================== --- p2ex/trunk/lib/expack/rss/setrss.inc.php 2010-01-05 12:50:04 UTC (rev 765) +++ p2ex/trunk/lib/expack/rss/setrss.inc.php 2010-01-05 14:48:56 UTC (rev 766) @@ -4,6 +4,7 @@ */ require_once P2_LIB_DIR . '/FileCtl.php'; +require_once P2EX_LIB_DIR . '/rss/parser.inc.php'; // {{{ Ï @@ -58,21 +59,41 @@ $site_en = isset($_REQUEST['site_en']) ? trim($_REQUEST['site_en']) : ''; $atom = empty($_REQUEST['atom']) ? 0 : 1; +// feedXL[ðhttpXL[Åu· +$xml = preg_replace('|^feed://|', 'http://', $xml); + // RSSÌ^CgÝè if ($site === '') { if ($site_en !== '') { $site = base64_decode($site_en); } else { + $purl = @parse_url($xml); + if (is_array($purl)) { + if (array_key_exists('host', $purl)) { + $site .= $purl['host']; + } + if (array_key_exists('path', $purl)) { + $site .= '.' . basename($purl['path']); + } + if (array_key_exists('query', $purl)) { + $site .= '?' . $purl['query']; + } + } $site = basename($xml); + + $rss = p2GetRSS($xml); + if ($rss instanceof XML_RSS) { + $channelInfo = $rss->getChannelInfo(); + if (is_array($channelInfo) && array_key_exists('title', $channelInfo)) { + $site = mb_convert_encoding($channelInfo['title'], 'CP932', 'UTF-8,CP51932,CP932,ASCII'); + } + } } } -// feedXL[ðhttpXL[Åu· -$xml = preg_replace('|^feed://|', 'http://', $xml); - // OÉL^·éÏðÅáÀÌTj^CY $xml = preg_replace_callback('/\\s/', 'rawurlencode', $xml); -$site = preg_replace('/\\s/', ' ', $site); +$site = preg_replace('/\\s+/', ' ', $site); $site = htmlspecialchars($site, ENT_QUOTES); // }}} Modified: p2ex/trunk/lib/expack/rss/subject.inc.php =================================================================== --- p2ex/trunk/lib/expack/rss/subject.inc.php 2010-01-05 12:50:04 UTC (rev 765) +++ p2ex/trunk/lib/expack/rss/subject.inc.php 2010-01-05 14:48:56 UTC (rev 766) @@ -141,7 +141,7 @@ $target_ht = ''; $preview_one = ''; // ôñ©ïñ© - $r = (++$i % 2) ? 'r1' : 'r2'; + $r = ($i % 2) ? 'r2' : 'r1'; // Tv if ($description_column_ht) { if (isset($item['content:encoded']) || isset($item['description'])) { @@ -180,6 +180,7 @@ echo <<<EOP <tr class="{$r}">{$description_ht}<td class="tl">{$preview_one}<a id="tt{$i}" class="thre_title" href="{$link_orig}">{$item_title}</a></td>{$subject_ht}{$creator_ht}{$date_ht}</tr>\n EOP; + $i++; } // }}} Modified: p2ex/trunk/read_rss.php =================================================================== --- p2ex/trunk/read_rss.php 2010-01-05 12:50:04 UTC (rev 765) +++ p2ex/trunk/read_rss.php 2010-01-05 14:48:56 UTC (rev 766) @@ -42,7 +42,7 @@ if ($xml) { $rss = p2GetRSS($xml, $atom); - if ($rss instanceof XML_Parser) { + if ($rss instanceof XML_RSS) { clearstatcache(); $rss_parse_success = true; $xml_path = rss_get_save_path($xml); Modified: p2ex/trunk/subject_rss.php =================================================================== --- p2ex/trunk/subject_rss.php 2010-01-05 12:50:04 UTC (rev 765) +++ p2ex/trunk/subject_rss.php 2010-01-05 14:48:56 UTC (rev 766) @@ -39,7 +39,7 @@ if ($xml) { $rss = p2GetRSS($xml, $atom); - if ($rss instanceof XML_Parser) { + if ($rss instanceof XML_RSS) { clearstatcache(); $rss_parse_success = true; $xml_path = rss_get_save_path($xml);