From b12f2704bce210939b7fb818363fb833f47cf124 Mon Sep 17 00:00:00 2001 From: haneul Date: Tue, 26 Feb 2008 00:02:05 +0000 Subject: [PATCH] =?UTF-8?q?rss=20reader=20PEAR=EB=A1=9C=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD=ED=95=98=EA=B3=A0,=20user,pass=EB=A5=BC=20=ED=86=B5?= =?UTF-8?q?=ED=95=9C=20basic=20auth=EA=B0=80=EB=8A=A5=ED=95=98=EB=8F=84?= =?UTF-8?q?=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: http://xe-core.googlecode.com/svn/sandbox@3809 201d5d3c-b55e-5fd7-737f-ddc643e51545 --- widgets/rss_reader/rss_reader.class.php | 32 ++++++++++++++----------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/widgets/rss_reader/rss_reader.class.php b/widgets/rss_reader/rss_reader.class.php index 695e5bcc2..3926d20a8 100644 --- a/widgets/rss_reader/rss_reader.class.php +++ b/widgets/rss_reader/rss_reader.class.php @@ -5,6 +5,10 @@ * @brief RSS Reader **/ + set_include_path("./libs/PEAR"); + require_once('PEAR.php'); + require_once('HTTP/Request.php'); + class rss_reader extends WidgetHandler { /** * @brief 위젯의 실행 부분 @@ -31,23 +35,23 @@ 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); - if(!$fp) return new Object(-1, 'msg_fail_to_socket_open'); - - fputs($fp, $out); + $user = $URL_parsed["user"]; + $pass = $URL_parsed["pass"]; - $buff = ''; - - while (!feof($fp)) { - $str = fgets($fp, 1024); - if ( $start ) $buff .= $str; - if ( $str == "\r\n" ) $start = true; - } - - fclose($fp); + if($user) + $oReqeust->setBasicAuth($user, $pass); + $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); 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));