mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-02-01 01:29:58 +09:00
rss reader PEAR로 변경하고, user,pass를 통한 basic auth가능하도록 수정
git-svn-id: http://xe-core.googlecode.com/svn/sandbox@3809 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
66314a24d8
commit
b12f2704bc
1 changed files with 18 additions and 14 deletions
|
|
@ -5,6 +5,10 @@
|
||||||
* @brief RSS Reader
|
* @brief RSS Reader
|
||||||
**/
|
**/
|
||||||
|
|
||||||
|
set_include_path("./libs/PEAR");
|
||||||
|
require_once('PEAR.php');
|
||||||
|
require_once('HTTP/Request.php');
|
||||||
|
|
||||||
class rss_reader extends WidgetHandler {
|
class rss_reader extends WidgetHandler {
|
||||||
/**
|
/**
|
||||||
* @brief 위젯의 실행 부분
|
* @brief 위젯의 실행 부분
|
||||||
|
|
@ -31,23 +35,23 @@
|
||||||
|
|
||||||
if ($URL_parsed["query"] != "") $path .= "?".$URL_parsed["query"];
|
if ($URL_parsed["query"] != "") $path .= "?".$URL_parsed["query"];
|
||||||
|
|
||||||
$out = "GET $path HTTP/1.0\r\nHost: $host\r\n\r\n";
|
$oReqeust = new HTTP_Request($path);
|
||||||
|
$oReqeust->addHeader('Content-Type', 'application/xml');
|
||||||
|
$oReqeust->setMethod('GET');
|
||||||
|
|
||||||
$fp = @fsockopen($host, $port, $errno, $errstr, 30);
|
$user = $URL_parsed["user"];
|
||||||
if(!$fp) return new Object(-1, 'msg_fail_to_socket_open');
|
$pass = $URL_parsed["pass"];
|
||||||
|
|
||||||
fputs($fp, $out);
|
|
||||||
|
|
||||||
$buff = '';
|
if($user)
|
||||||
|
$oReqeust->setBasicAuth($user, $pass);
|
||||||
while (!feof($fp)) {
|
|
||||||
$str = fgets($fp, 1024);
|
|
||||||
if ( $start ) $buff .= $str;
|
|
||||||
if ( $str == "\r\n" ) $start = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
fclose($fp);
|
|
||||||
|
|
||||||
|
$oResponse = $oReqeust->sendRequest();
|
||||||
|
if (PEAR::isError($oResponse))
|
||||||
|
{
|
||||||
|
debugPrint("error");
|
||||||
|
return new Object(-1, 'msg_fail_to_request_open');
|
||||||
|
}
|
||||||
|
$buff = $oReqeust->getResponseBody();
|
||||||
$encoding = preg_match("/<\?xml.*encoding=\"(.+)\".*\?>/i", $buff, $matches);
|
$encoding = preg_match("/<\?xml.*encoding=\"(.+)\".*\?>/i", $buff, $matches);
|
||||||
if($encoding && !preg_match("/UTF-8/i", $matches[1])) $buff = trim(iconv($matches[1]=="ks_c_5601-1987"?"EUC-KR":$matches[1], "UTF-8", $buff));
|
if($encoding && !preg_match("/UTF-8/i", $matches[1])) $buff = trim(iconv($matches[1]=="ks_c_5601-1987"?"EUC-KR":$matches[1], "UTF-8", $buff));
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue