Esempio n. 1
0
 /** @return array of VcardAddress objects */
 static function parse($data)
 {
     if (is_url($data)) {
         $http = new HttpClient($data);
         $data = $http->getBody();
         //FIXME check http client return code for 404
         if (strpos($data, 'BEGIN:VCARD') === false) {
             throw new \Exception('VcardReader->parse FAIL: cant parse vcard from ' . $http->getUrl());
             return false;
         }
     }
     $res = array();
     do {
         $m1 = 'BEGIN:VCARD';
         $m2 = 'END:VCARD';
         $p1 = strpos($data, $m1);
         $p2 = strpos($data, $m2);
         if ($p1 === false || $p2 === false) {
             break;
         }
         $part = substr($data, $p1, $p2 - $p1 + strlen($m2));
         $res[] = self::parseVcard($part);
         $data = substr($data, $p2 + strlen($m2));
     } while ($data);
     return $res;
 }
Esempio n. 2
0
 function parse($raw)
 {
     // TODO XmlReader should not handle HTTP protocol details
     if (is_url($raw)) {
         $url = $raw;
         $h = new HttpClient($url);
         //            $h->setCacheTime('30m');
         $raw = $h->getBody();
         //            d( $h->getResponseHeaders() );
         if ($h->getStatus() == 404) {
             // not found
             return false;
         }
         if ($h->getStatus() == 302) {
             $redir = $h->getResponseHeader('location');
             // echo "REDIRECT: ".$redir."\n";
             $h = new HttpClient($redir);
             //XXX: reuse previous client?
             $h->setCacheTime('30m');
             $url = $redir;
             $raw = $h->getBody();
         }
         // prepend XML header if nonexistent
         if (strpos($raw, '<?xml ') === false) {
             $raw = '<?xml version="1.0"?>' . $raw;
         }
     }
     if (!$this->xml($raw)) {
         if (isset($url)) {
             throw new \Exception("Failed to parse XML from " . $url);
         }
         throw new \Exception("Failed to parse XML");
     }
 }
Esempio n. 3
0
 static function reverse($latitude, $longitude)
 {
     if (!$latitude || !$longitude) {
         throw new \Exception('no coords set');
     }
     $temp = TempStore::getInstance();
     $key = 'GeonamesClient//' . $latitude . '/' . $longitude;
     $data = $temp->get($key);
     if ($data) {
         return unserialize($data);
     }
     $url = 'http://ws.geonames.org/timezone?lat=' . $latitude . '&lng=' . $longitude;
     $http = new HttpClient($url);
     $data = $http->getBody();
     $xml = simplexml_load_string($data);
     //d($xml);
     $res = new GeoLookupResult();
     $res->country_code = strval($xml->timezone->countryCode);
     $res->country_name = strval($xml->timezone->countryName);
     $res->timezone = strval($xml->timezone->timezoneId);
     $res->sunrise = strval($xml->timezone->sunrise);
     $res->sunset = strval($xml->timezone->sunset);
     $temp->set($key, serialize($res), '1h');
     return $res;
 }
 public static function getRate($from, $to)
 {
     $url = 'http://rate-exchange.appspot.com/currency?from=' . strtoupper($from) . '&to=' . strtoupper($to);
     $http = new HttpClient($url);
     $res = $http->getBody();
     $json = json_decode($res);
     return $json->rate;
 }
 static function shorten($input_url)
 {
     $url = 'http://is.gd/api.php?longurl=' . urlencode($input_url);
     $http = new HttpClient($url);
     $http->setCacheTime(86400);
     //24 hours
     $res = $http->getBody();
     if (substr($res, 0, 4) == 'http') {
         return trim($res);
     }
     throw new \Exception('Error: ' . $res);
 }
Esempio n. 6
0
 function parse($data)
 {
     if (is_url($data)) {
         $u = new HttpClient($data);
         $data = $u->getBody();
         //FIXME check http client return code for 404
         if (strpos($data, '<feed ') === false) {
             //dp('AtomReader->parse FAIL: cant parse feed from '.$u->getUrl() );
             throw new \Exception('AtomReader->parse FAIL: cant parse feed from ' . $u->getUrl());
             return false;
         }
     }
     $this->reader = new \XMLReader();
     $this->reader->xml($data);
     while ($this->reader->read()) {
         if ($this->reader->nodeType != \XMLReader::ELEMENT) {
             continue;
         }
         switch ($this->reader->name) {
             case 'feed':
                 if ($this->reader->getAttribute('xmlns') != 'http://www.w3.org/2005/Atom') {
                     throw new \Exception('Unknown atom xmlns: ' . $this->reader->getAttribute('xmlns'));
                 }
                 break;
             case 'entry':
                 $this->parseEntry();
                 break;
             case 'id':
                 break;
             case 'title':
                 $this->reader->read();
                 $this->title = html_entity_decode($this->reader->value, ENT_QUOTES, 'UTF-8');
                 break;
             case 'category':
                 // <category term="Nyheter" />
                 $this->category = $this->reader->getAttribute('term');
                 break;
             case 'link':
                 break;
             case 'generator':
                 break;
             case 'updated':
                 break;
             default:
                 //XXX: may include openSearch:itemsPerPage (twitter does for example)
                 // echo 'bad top entry '.$this->reader->name.ln();
                 break;
         }
     }
     $this->reader->close();
     return true;
 }
 static function shorten($url)
 {
     $url = 'http://tinyurl.com/api-create.php?url=' . urlencode($url);
     $http = new HttpClient($url);
     $http->setCacheTime(86400);
     //24 hours
     $res = $http->getBody();
     if (substr($res, 0, 4) == 'http') {
         return trim($res);
     }
     list($error_code, $error_message) = explode('|', $res);
     throw new \Exception('Error: ' . $error_message . ' (' . $error_code . ')');
 }
 public static function getRate($from, $to)
 {
     $api_key = 'RFJGV-fViGD-R3FGa';
     //  api key for martin@ubique.se
     $url = 'http://www.exchangerate-api.com/' . strtoupper($from) . '/' . strtoupper($to) . '?k=' . $api_key;
     $http = new HttpClient($url);
     $res = $http->getBody();
     if ($res == '-2') {
         throw new \Exception('unsupported currency:' . $from . ' or ' . $to);
     }
     if ($res == '-3') {
         throw new \Exception('need api key, register your own at http://www.exchangerate-api.com/api-key');
     }
     if ($res < 0) {
         throw new \Exception('error ' . $res);
     }
     return $res;
 }
 static function shorten($input_url)
 {
     /*
             $login = '******';
             $key = 'R_0da49e0a9118ff35f52f629d2d71bf07';
     */
     $login = '******';
     $key = 'R_f37747e06a18173096b714827c76b567';
     $url = 'http://api.bit.ly/v3/shorten?format=json&login='******'&apiKey=' . $key . '&longUrl=' . urlencode($input_url);
     $http = new HttpClient($url);
     $http->setCacheTime(86400);
     //24 hours
     $res = Json::decode($http->getBody());
     if ($res->status_code != 200) {
         throw new \Exception('Error code ' . $res->status_code . ': ' . $res->status_txt);
     }
     return $res->data->url;
 }
Esempio n. 10
0
 private function query($method, $params)
 {
     $url = 'http://ws.audioscrobbler.com/2.0/?method=' . $method . '&api_key=' . $this->api_key;
     $http = new HttpClient($url);
     $http->setCacheTime('12h');
     foreach ($params as $key => $val) {
         $http->Url->setParam($key, $val);
     }
     echo "QUERYING " . $http->getUrl() . "\n";
     $data = $http->getBody();
     //d($data);
     $x = simplexml_load_string($data);
     /*
             $attrs = $x->attributes();
             if ($attrs['status'] == 'failed')
                 throw new \Exception ('last.fm api error: '.$x->error);
     */
     return $x;
 }
Esempio n. 11
0
 function getByISBN($isbn)
 {
     if (!Isbn::isValid($isbn)) {
         throw new \Exception('invalid isbn');
     }
     $isbn = str_replace(' ', '', $isbn);
     $isbn = str_replace('-', '', $isbn);
     if ($this->use_cache) {
         $temp = TempStore::getInstance();
         $key = 'IsbnDbClient/isbn/' . $isbn;
         $res = $temp->get($key);
         if ($res) {
             return unserialize($res);
         }
     }
     $url = 'http://isbndb.com/api/books.xml' . '?access_key=' . $this->api_key . '&index1=isbn' . '&value1=' . $isbn;
     $http = new HttpClient($url);
     $data = $http->getBody();
     $xml = simplexml_load_string($data);
     $attrs = $xml->BookList;
     if ($attrs['total_results'] == 0) {
         return false;
     }
     $d = $xml->BookList->BookData;
     $attrs = $d->attributes();
     if (!$attrs) {
         throw new \Exception('no attrs');
     }
     $book = new BookResource();
     $book->title = strval($d->Title);
     $book->authors = strval($d->AuthorsText);
     $book->publisher = strval($d->PublisherText);
     $book->isbn10 = strval($attrs['isbn']);
     $book->isbn13 = strval($attrs['isbn13']);
     if ($this->use_cache) {
         $temp->set($key, serialize($book), '24h');
     }
     return $book;
 }
Esempio n. 12
0
 static function getNasdaq($symbol)
 {
     $format = 'n' . 's' . 'b2' . 'b3' . 'j' . 'k' . 'o' . 'p' . 'h' . 'g';
     // Day's low
     $url = 'http://download.finance.yahoo.com/d/quotes.csv' . '?s=' . urlencode($symbol) . '&f=' . $format;
     $http = new HttpClient($url);
     $data = $http->getBody();
     $csv = CsvReader::parse($data);
     if (count($csv) != 1) {
         throw new \Exception('unhandled number of stock results: ' . count($csv));
     }
     $stock = new StockQuoteResult();
     $stock->name = $csv[0][0];
     $stock->symbol = $csv[0][1];
     $stock->ask_realtime = $csv[0][2];
     $stock->bid_realtime = $csv[0][3];
     $stock->low_52w = $csv[0][4];
     $stock->hi_52w = $csv[0][5];
     $stock->open = $csv[0][6];
     $stock->previous_close = $csv[0][7];
     $stock->day_high = $csv[0][8];
     $stock->day_low = $csv[0][9];
     return $stock;
 }
Esempio n. 13
0
 /**
  * @param $album_id spotify uri
  */
 function getAlbumDetails($album_id)
 {
     if (!is_spotify_uri($album_id)) {
         return false;
     }
     $url = 'http://ws.spotify.com/lookup/1/?uri=' . $album_id . '&extras=trackdetail';
     $http = new HttpClient($url);
     //        $http->setCacheTime(60*60*24); //24 hours
     $data = $http->getBody();
     if ($http->getStatus() != 200) {
         d('SpotifyMetadata->getAlbumDetails server error: ' . $http->getStatus());
         d($http->getResponseHeaders());
         return false;
     }
     return $this->parseAlbumDetails($data);
 }
Esempio n. 14
0
 /**
  * Loads input data from ASX playlists into VideoResource entries
  */
 function load($data)
 {
     if (is_url($data)) {
         $u = new HttpClient($data);
         $data = $u->getBody();
     }
     if (strpos($data, '<asx ') !== false) {
         $asx = new AsxReader();
         $asx->parse($data);
         $this->addItems($asx->getItems());
         return true;
     }
     echo "Playlist->load error: unhandled feed: " . substr($data, 0, 200) . " ..." . ln();
     return false;
 }
Esempio n. 15
0
 function connectURL($msg)
 {
     $httpclient = new HttpClient("true", HOST_IP);
     $this->printLog("Start INImx_APPL");
     $this->printLog("Start HTTP Connect:" . HOST_IP . $this->m_serviceurl);
     if ($httpclient->HttpConnect()) {
         $this->printLog("HTTP CONNECTION SUCCESS");
         if ($httpclient->HttpRequest($this->m_serviceurl, $msg)) {
             $this->printLog("RECV REQUEST:" . trim($httpclient->getBody()));
             // ���� �� �Ľ�
             parse_str(trim($httpclient->getBody()), $resultString);
             //����
             $this->m_tid = $resultString['P_TID'];
             $this->m_resultCode = $resultString['P_STATUS'];
             $this->m_resultMsg = $resultString['P_RMESG1'];
             $this->m_payMethod = $resultString['P_TYPE'];
             $this->m_mid = $resultString['P_MID'];
             $this->m_moid = $resultString['P_OID'];
             $this->m_resultprice = $resultString['P_AMT'];
             $this->m_buyerName = $resultString['P_UNAME'];
             $this->m_noti = $resultString['P_NOTI'];
             $this->m_nextUrl = $resultString['P_NEXT_URL'];
             $this->m_notiUrl = $resultString['P_NOTEURL'];
             //�ſ�ī��
             $this->m_pgAuthDate = substr($resultString['P_AUTH_DT'], '0', '8');
             $this->m_pgAuthTime = substr($resultString['P_AUTH_DT'], '8', '6');
             $this->m_authCode = $resultString['P_AUTH_NO'];
             $this->m_cardQuota = $resultString['P_RMESG2'];
             $this->m_cardCode = $resultString['P_FN_CD1'];
             $this->m_cardIssuerCode = $resultString['P_CARD_ISSUER_CODE'];
             $this->m_cardNumber = $resultString['P_CARD_NUM'];
             $this->m_cardMember = $resultString['P_CARD_MEMBER_NUM'];
             $this->m_cardpurchase = $resultString['P_CARD_PURCHASE_CODE'];
             $this->m_prtc = $resultString['P_CARD_PRTC_CODE'];
             //�޴���
             $this->m_codegw = $resultString['P_HPP_CORP'];
             //�������
             $this->m_vacct = $resultString['P_VACT_NUM'];
             $this->m_dtinput = $resultString['P_VACT_DATE'];
             $this->m_tminput = $resultString['P_VACT_TIME'];
             $this->m_nmvacct = $resultString['P_VACT_NAME'];
             $this->m_vcdbank = $resultString['P_VACT_BANK_CODE'];
         } else {
             $this->printLog("HTTP REQUEST FAIL:" . $httpclient->getErrorCode() . ":" . $httpclient->getErrorMsg());
             // �� ���� ��û ����
             $this->m_resultCode = "05";
             $this->m_resultmsg = "HTTP REQUEST FAIL";
         }
     } else {
         $this->printLog("HTTP CONNECTION FAIL:" . $httpclient->getErrorCode() . ":" . $httpclient->getErrorMsg());
         // ���� ���� ����
         $this->m_resultCode = "05";
         $this->m_resultmsg = "HTTP CONNECTION FAIL";
     }
     $this->printLog("P_STATUS:" . $this->m_resultCode);
     $this->printLog("P_RMESG1:" . $this->m_resultMsg);
     $this->printLog("P_TYPE:" . $this->m_payMethod);
     $this->printLog("P_TID:" . $this->m_tid);
     $this->printLog("P_MID:" . $this->m_mid);
     $this->printLog("P_OID:" . $this->m_moid);
     $this->printLog("P_UNAME:" . $this->m_buyerName);
     $this->printLog("P_AMT:" . $this->m_resultprice);
     $this->printLog("P_AUTH_DT:" . $this->m_pgAuthDate);
     $this->printLog("P_AUTH_TM:" . $this->m_pgAuthTime);
     $this->printLog("P_AUTH_NO:" . $this->m_authCode);
     $this->printLog("P_RMESG2:" . $this->m_cardQuota);
     $this->printLog("P_FN_CD1:" . $this->m_cardCode);
     $this->printLog("P_CARD_ISSUER_CODE:" . $this->m_cardIssuerCode);
     $this->printLog("P_CARD_PURCHASE_CODE:" . $this->m_cardpurchase);
     $this->printLog("P_CARD_PRTC_CODE:" . $this->m_prtc);
     $this->printLog("P_VACT_NUM:" . $this->m_vacct);
     $this->printLog("P_VACT_BANK_CODE:" . $this->m_vcdbank);
     $this->printLog("P_VACT_DATE:" . $this->m_dtinput);
     $this->printLog("P_VACT_TIME:" . $this->m_tminput);
     $this->printLog("P_VACT_NAME:" . $this->m_nmvacct);
     $this->printLog("P_NEXT_URL:" . $this->m_nextUrl);
     $this->printLog("P_NOTEURL:" . $this->m_notiUrl);
     $this->printLog("APPL Transaction End");
 }
Esempio n. 16
0
 /**
  * Returns details on a movie
  *
  * @param $movie_id TMDB id
  */
 public function getInfo($movie_id)
 {
     if (!self::probeId($movie_id)) {
         throw new \Exception('not a tmdb id');
     }
     if ($this->cache_results) {
         $temp = TempStore::getInstance();
         $key = 'TheMovieDbClient/info//' . $movie_id;
         $data = $temp->get($key);
         if ($data) {
             return unserialize($data);
         }
     }
     $url = 'http://api.themoviedb.org/3/movie/' . $movie_id . '?language=' . $this->language . '&api_key=' . $this->api_key;
     $http = new HttpClient($url);
     $data = $http->getBody();
     if ($http->getStatus() != 200) {
         d('TheMovieDbClient getInfo server error: ' . $http->getStatus());
         d($http->getResponseHeaders());
         return false;
     }
     $res = Json::decode($data);
     if ($this->cache_results) {
         $temp->set($key, serialize($res), '24h');
     }
     return $res;
 }
Esempio n. 17
0
 function parse($data)
 {
     if (is_url($data)) {
         $u = new HttpClient($data);
         $u->setCacheTime(60 * 60);
         //1h
         $data = $u->getBody();
         //FIXME check http client return code for 404
         if (substr($data, 0, 5) != '<asx ') {
             dp('input_asx->parse FAIL: cant parse playlist from ' . $u->getUrl());
             return false;
         }
     }
     $reader = new XMLReader();
     if ($this->getDebug()) {
         echo 'Parsing ASX: ' . $data . ln();
     }
     $reader->xml($data);
     $item = new VideoResource();
     while ($reader->read()) {
         if ($reader->nodeType == XMLReader::END_ELEMENT && $reader->name == 'asx') {
             $this->items[] = $item;
             $item = new VideoResource();
         }
         if ($reader->nodeType != XMLReader::ELEMENT) {
             continue;
         }
         switch ($reader->name) {
             case 'asx':
                 if ($reader->getAttribute('version') != '3.0') {
                     die('XXX FIXME unsupported ASX version ' . $reader->getAttribute('version'));
                 }
                 break;
             case 'entry':
                 while ($reader->read()) {
                     if ($reader->nodeType == XMLReader::END_ELEMENT && $reader->name == 'entry') {
                         break;
                     }
                     if ($reader->nodeType != XMLReader::ELEMENT) {
                         continue;
                     }
                     switch ($reader->name) {
                         case 'author':
                             break;
                             //<author>svt.se</author>
                         //<author>svt.se</author>
                         case 'copyright':
                             break;
                             //<copyright>Sveriges Television AB 2009</copyright>
                         //<copyright>Sveriges Television AB 2009</copyright>
                         case 'starttime':
                             break;
                             //<starttime value="00:00:00.00"/>
                         //<starttime value="00:00:00.00"/>
                         case 'ref':
                             //<ref href="mms://wm0.c90901.cdn.qbrick.com/90901/kluster/20091026/aekonomi920.wmv"/>
                             $item->setUrl($reader->getAttribute('href'));
                             break;
                         case 'duration':
                             //<duration value="00:03:39.00"/>
                             $item->setDuration($reader->getAttribute('value'));
                             break;
                         default:
                             echo "bad entry " . $reader->name . ln();
                     }
                 }
                 break;
             default:
                 echo "unknown " . $reader->name . ln();
                 break;
         }
     }
     $reader->close();
     return true;
 }
Esempio n. 18
0
 function startAction()
 {
     if (trim($this->m_ActionType) == "") {
         $this->MakeErrorMsg(ERR_WRONG_ACTIONTYPE, "actionType 설정이 잘못되었습니다.");
         return;
     }
     $NICELog = new NICELog($this->m_log, $this->m_debug, $this->m_ActionType);
     if (!$NICELog->StartLog($this->m_NicepayHome, $this->m_MID)) {
         $this->MakeErrorMsg(ERR_OPENLOG, "로그파일을 열수가 없습니다.");
         return;
     }
     // 취소인 경우,
     if (trim($this->m_ActionType) == "CLO") {
         if (trim($this->m_TID) == "") {
             $this->MakeErrorMsg(ERR_WRONG_PARAMETER, "요청페이지 파라메터가 잘못되었습니다. [TID]");
             return;
         } else {
             if (trim($this->m_CancelAmt) == "") {
                 $this->MakeErrorMsg(ERROR_WRONG_PARAMETER, "요청페이지 파라메터가 잘못되었습니다. [CancelAmt]");
                 return;
             } else {
                 if (trim($this->m_CancelMsg) == "") {
                     $this->MakeErrorMsg(ERROR_WRONG_PARAMETER, "요청페이지 파라메터가 잘못되었습니다. [CancelMsg]");
                     return;
                 }
             }
         }
         $this->m_uri = "/lite/cancelProcess.jsp";
         unset($this->m_queryString);
         $this->m_queryString = $_POST;
         $this->m_queryString["MID"] = substr($this->m_TID, 0, 10);
         $this->m_queryString["TID"] = $this->m_TID;
         $this->m_queryString["CancelAmt"] = $this->m_CancelAmt;
         $this->m_queryString["CancelMsg"] = $this->m_CancelMsg;
         $this->m_queryString["CancelPwd"] = $this->m_CancelPwd;
         $this->m_queryString["PartialCancelCode"] = $this->m_PartialCancelCode;
         $NICELog->WriteLog($this->m_queryString["TID"]);
         //입금 후 취소
     } else {
         if (trim($this->m_ActionType) == "DPO") {
             if (trim($this->m_TID) == "") {
                 $this->MakeErrorMsg(ERR_WRONG_PARAMETER, "요청페이지 파라메터가 잘못되었습니다. [TID]");
                 return;
             } else {
                 if (trim($this->m_CancelAmt) == "") {
                     $this->MakeErrorMsg(ERROR_WRONG_PARAMETER, "요청페이지 파라메터가 잘못되었습니다. [CancelAmt]");
                     return;
                 } else {
                     if (trim($this->m_CancelMsg) == "") {
                         $this->MakeErrorMsg(ERROR_WRONG_PARAMETER, "요청페이지 파라메터가 잘못되었습니다. [CancelMsg]");
                         return;
                     }
                 }
             }
             $this->m_uri = "/lite/setOffProcess.jsp";
             unset($this->m_queryString);
             $this->m_queryString["MID"] = substr($this->m_TID, 0, 10);
             $this->m_queryString["TID"] = $this->m_TID;
             $this->m_queryString["CancelAmt"] = $this->m_CancelAmt;
             $this->m_queryString["CancelMsg"] = $this->m_CancelMsg;
             $this->m_queryString["PartialCancelCode"] = $this->m_PartialCancelCode;
             $this->m_queryString["ExpDate"] = $this->m_ExpDate;
             $this->m_queryString["ReqName"] = $this->m_ReqName;
             $this->m_queryString["ReqTel"] = $this->m_ReqTel;
             $NICELog->WriteLog($this->m_queryString["TID"]);
             // 빌링 승인
         } else {
             if (trim($this->m_ActionType) == "PYO" && trim($this->m_PayMethod) == "BILL") {
                 $this->m_uri = "/lite/billingProcess.jsp";
                 unset($this->m_queryString);
                 $this->m_queryString["BillKey"] = $this->m_BillKey;
                 // new
                 $this->m_queryString["BuyerName"] = $this->m_BuyerName;
                 $this->m_queryString["Amt"] = $this->m_Amt;
                 $this->m_queryString["MID"] = $this->m_MID;
                 $this->m_TID = genTID($this->m_MID, "01", "16");
                 $this->m_queryString["TID"] = $this->m_TID;
                 $this->m_queryString["EncodeKey"] = $this->m_LicenseKey;
                 $this->m_queryString["MallIP"] = $_SERVER['SERVER_NAME'];
                 $this->m_queryString["actionType"] = $this->m_ActionType;
                 $this->m_queryString["PayMethod"] = $this->m_PayMethod;
                 $this->m_queryString["Moid"] = $this->m_Moid;
                 $this->m_queryString["GoodsName"] = $this->m_GoodsName;
                 if ($this->m_charSet == "UTF8") {
                     $this->m_queryString["BuyerName"] = iconv("UTF-8", "EUC-KR", $this->m_queryString["BuyerName"]);
                     $this->m_queryString["GoodsName"] = iconv("UTF-8", "EUC-KR", $this->m_queryString["GoodsName"]);
                 }
                 $NICELog->WriteLog($this->m_queryString["TID"]);
                 // 빌키 발급
             } else {
                 if (trim($this->m_ActionType) == "PYO" && trim($this->m_PayMethod) == "BILLKEY") {
                     $this->m_uri = "/lite/billkeyProcess.jsp";
                     unset($this->m_queryString);
                     $this->m_queryString["CardNo"] = $this->m_CardNo;
                     // new
                     $this->m_queryString["ExpYear"] = $this->m_ExpYear;
                     $this->m_queryString["ExpMonth"] = $this->m_ExpMonth;
                     $this->m_queryString["IDNo"] = $this->m_IDNo;
                     $this->m_queryString["CardPw"] = $this->m_CardPw;
                     $this->m_queryString["MID"] = $this->m_MID;
                     $this->m_queryString["EncodeKey"] = $this->m_LicenseKey;
                     $this->m_queryString["MallIP"] = $_SERVER['SERVER_NAME'];
                     $this->m_queryString["actionType"] = $this->m_ActionType;
                     $this->m_queryString["PayMethod"] = $this->m_PayMethod;
                     // 지급 대행 서브몰 등록
                 } else {
                     if (trim($this->m_ActionType) == "PYO" && trim($this->m_PayMethod) == "OM_SUB_INS") {
                         $this->m_uri = "/lite/payproxy/subMallSetProcess.jsp";
                         unset($this->m_queryString);
                         $this->m_queryString = $_POST;
                         $this->m_queryString["EncodeKey"] = $this->m_LicenseKey;
                         // 서브몰 이체
                     } else {
                         if (trim($this->m_ActionType) == "PYO" && trim($this->m_PayMethod) == "OM_SUB_PAY") {
                             $this->m_uri = "/lite/payproxy/subMallIcheProcess.jsp";
                             unset($this->m_queryString);
                             $this->m_queryString = $_POST;
                             $this->m_queryString["EncodeKey"] = $this->m_LicenseKey;
                             // SMS
                         } else {
                             if (trim($this->m_ActionType) == "PYO" && trim($this->m_PayMethod) == "SMS_REQ") {
                                 $this->m_uri = "/api/sendSmsForETAX.jsp";
                                 unset($this->m_queryString);
                                 $this->m_queryString = $_POST;
                                 $this->m_queryString["EncodeKey"] = $this->m_LicenseKey;
                                 // 현금영수증,
                             } else {
                                 if (trim($this->m_ActionType) == "PYO" && trim($this->m_PayMethod) == "RECEIPT") {
                                     $this->m_uri = "/lite/cashReceiptProcess.jsp";
                                     unset($this->m_queryString);
                                     $this->m_queryString["MID"] = $this->m_MID;
                                     $this->m_queryString["TID"] = $this->m_MID . "04" . "01" . SetTimestamp1();
                                     $this->m_queryString["GoodsName"] = $this->m_GoodsName;
                                     $this->m_queryString["BuyerName"] = $this->m_BuyerName;
                                     $this->m_queryString["Amt"] = $this->m_Amt;
                                     $this->m_queryString["ReceiptAmt"] = $this->m_ReceiptAmt;
                                     $this->m_queryString["ReceiptSupplyAmt"] = $this->m_ReceiptSupplyAmt;
                                     $this->m_queryString["ReceiptVAT"] = $this->m_ReceiptVAT;
                                     $this->m_queryString["ReceiptServiceAmt"] = $this->m_ReceiptServiceAmt;
                                     $this->m_queryString["ReceiptType"] = $this->m_ReceiptType;
                                     $this->m_queryString["ReceiptTypeNo"] = $this->m_ReceiptTypeNo;
                                     $this->m_queryString["EncodeKey"] = $this->m_LicenseKey;
                                     $this->m_queryString["actionType"] = $this->m_ActionType;
                                     $this->m_queryString["PayMethod"] = $this->m_PayMethod;
                                     $this->m_queryString["CancelPwd"] = $this->m_CancelPwd;
                                     $this->m_queryString["CancelAmt"] = $this->m_Amt;
                                     $this->m_queryString["MallIP"] = $_SERVER['SERVER_NAME'];
                                     // 승인인 경우,
                                 } else {
                                     if (trim($this->m_ActionType) == "PYO" && trim($this->m_PayMethod) != "RECEIPT") {
                                         if (trim($_POST["MID"]) == "") {
                                             $this->MakeErrorMsg(ERROR_WRONG_PARAMETER, "요청페이지 파라메터가 잘못되었습니다. [MID]");
                                             return;
                                         } else {
                                             if (trim($_POST["Amt"]) == "") {
                                                 $this->MakeErrorMsg(ERROR_WRONG_PARAMETER, "요청페이지 파라메터가 잘못되었습니다. [Amt]");
                                                 return;
                                             }
                                         }
                                         $this->m_uri = "/lite/payProcess.jsp";
                                         unset($this->m_queryString);
                                         $this->m_queryString = $_POST;
                                         $this->m_queryString["EncodeKey"] = $this->m_LicenseKey;
                                         $this->m_queryString["TID"] = "";
                                         if ($this->m_charSet == "UTF8") {
                                             $this->m_queryString["BuyerName"] = iconv("UTF-8", "EUC-KR", $this->m_queryString["BuyerName"]);
                                             $this->m_queryString["GoodsName"] = iconv("UTF-8", "EUC-KR", $this->m_queryString["GoodsName"]);
                                             $this->m_queryString["BuyerAddr"] = iconv("UTF-8", "EUC-KR", $this->m_queryString["BuyerAddr"]);
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     $httpclient = new HttpClient($this->m_ssl);
     //connect
     if (!$httpclient->HttpConnect($NICELog)) {
         $NICELog->WriteLog('Server Connect Error!!' . $httpclient->getErrorMsg());
         $resultMsg = $httpclient->getErrorMsg() . "서버연결을 할 수가 없습니다.";
         if ($this->m_ssl == "true") {
             $resultMsg .= "<br>귀하의 서버는 SSL통신을 지원하지 않습니다. 결제처리파일에서 m_ssl=false로 셋팅하고 시도하세오.";
             $this->MakeErrorMsg(ERR_SSLCONN, $resultMsg);
         } else {
             $this->MakeErrorMsg(ERR_CONN, $resultMsg);
         }
         $NICELog->CloseNiceLog("");
         return;
     }
     //request
     if (!$httpclient->HttpRequest($this->m_uri, $this->m_queryString, $NICELog)) {
         // 요청 오류시 처리
         $NICELog->WriteLog('POST Error!!' . $httpclient->getErrorMsg());
         $this->MakeErrorMsg(ERR_NO_RESPONSE, "서버 응답 오류");
         //NET CANCEL Start---------------------------------
         if ($httpclient->getErrorCode() == READ_TIMEOUT_ERR) {
             $NICELog->WriteLog("Net Cancel Start");
             $this->m_uri = "/lite/cancelProcess.jsp";
             unset($this->m_queryString);
             $this->m_queryString["MID"] = substr($this->m_TID, 0, 10);
             $this->m_queryString["TID"] = $this->m_TID;
             $this->m_queryString["CancelAmt"] = $this->m_NetCancelAmt;
             $this->m_queryString["CancelMsg"] = "NICE_NET_CANCEL";
             $this->m_queryString["CancelPwd"] = $this->m_NetCancelPW;
             $this->m_queryString["NetCancelCode"] = "1";
             $NICELog->WriteLog($this->m_queryString["TID"]);
             if (!$httpclient->HttpConnect($NICELog)) {
                 $NICELog->WriteLog('Server Connect Error!!' . $httpclient->getErrorMsg());
                 $resultMsg = $httpclient->getErrorMsg() . "서버연결을 할 수가 없습니다.";
                 $this->MakeErrorMsg(ERR_CONN, $resultMsg);
                 $NICELog->CloseNiceLog($this->m_resultMsg);
                 return;
             }
             if (!$httpclient->HttpRequest($this->m_uri, $this->m_queryString, $NICELog) && $httpclient->getErrorCode() == READ_TIMEOUT_ERR) {
                 $NICELog->WriteLog("Net Cancel FAIL");
                 if ($this->m_ActionType == "PYO") {
                     $this->MakeErrorMsg(ERR_NO_RESPONSE, "승인여부 확인요망");
                 } else {
                     if ($this->m_ActionType == "CLO") {
                         $this->MakeErrorMsg(ERR_NO_RESPONSE, "취소여부 확인요망");
                     }
                 }
             } else {
                 $NICELog->WriteLog("Net Cancel SUCESS");
             }
         }
         //NET CANCEL End---------------------------------
         $this->ParseMsg($httpclient->getBody(), $NICELog);
         $NICELog->CloseNiceLog($this->m_resultMsg);
         return;
     }
     if ($httpclient->getStatus() == "200") {
         $this->ParseMsg($httpclient->getBody(), $NICELog);
         $NICELog->WriteLog("TID -> " . "[" . $this->m_ResultData['TID'] . "]");
         $NICELog->WriteLog($this->m_ResultData['ResultCode'] . "[" . $this->m_ResultData['ResultMsg'] . "]");
         $NICELog->CloseNiceLog("");
     } else {
         $NICELog->WriteLog('SERVER CONNECT FAIL:' . $httpclient->getStatus() . $httpclient->getErrorMsg() . $httpclient->getHeaders());
         $resultMsg = $httpclient->getStatus() . "서버에러가 발생했습니다.";
         $this->MakeErrorMsg(ERR_NO_RESPONSE, $resultMsg);
         //NET CANCEL Start---------------------------------
         if ($httpclient->getStatus() != 200) {
             $NICELog->WriteLog("Net Cancel Start");
             //Set Field
             $this->m_uri = "/lite/cancelProcess.jsp";
             unset($this->m_queryString);
             $this->m_queryString["MID"] = substr($this->m_TID, 0, 10);
             $this->m_queryString["TID"] = $this->m_TID;
             $this->m_queryString["CancelAmt"] = $this->m_NetCancelAmt;
             $this->m_queryString["CancelMsg"] = "NICE_NET_CANCEL";
             $this->m_queryString["CancelPwd"] = $this->m_NetCancelPW;
             $this->m_queryString["NetCancelCode"] = "1";
             if (!$httpclient->HttpConnect($NICELog)) {
                 $NICELog->WriteLog('Server Connect Error!!' . $httpclient->getErrorMsg());
                 $resultMsg = $httpclient->getErrorMsg() . "서버연결을 할 수가 없습니다.";
                 $this->MakeErrorMsg(ERR_CONN, $resultMsg);
                 $NICELog->CloseNiceLog($this->m_resultMsg);
                 return;
             }
             if (!$httpclient->HttpRequest($this->m_uri, $this->m_queryString, $NICELog)) {
                 $NICELog->WriteLog("Net Cancel FAIL");
                 if ($this->m_ActionType == "PYO") {
                     $this->MakeErrorMsg(ERR_NO_RESPONSE, "승인여부 확인요망");
                 } else {
                     if ($this->m_ActionType == "CLO") {
                         $this->MakeErrorMsg(ERR_NO_RESPONSE, "취소여부 확인요망");
                     }
                 }
             } else {
                 $NICELog->WriteLog("Net Cancel SUCESS");
             }
         }
         //NET CANCEL End---------------------------------
         $this->ParseMsg($httpclient->getBody(), $NICELog);
         $NICELog->CloseNiceLog("");
         return;
     }
 }
Esempio n. 19
0
 /**
  * Loads input data from RSS or Atom feeds into NewsItem entries
  */
 function load($data)
 {
     if (is_array($data)) {
         $this->addItems($data);
         return;
     }
     if (is_url($data)) {
         $http = new HttpClient($data);
         if ($this->getDebug()) {
             $http->setDebug();
         }
         $data = $http->getBody();
     }
     if (strpos($data, '<rss ') !== false) {
         $feed = new RssReader();
     } else {
         if (strpos($data, '<feed ') !== false) {
             $feed = new AtomReader();
         } else {
             echo 'NewsFeed->load error: unhandled feed: ' . substr($data, 0, 100) . ' ...' . ln();
             return false;
         }
     }
     if ($this->getDebug()) {
         $feed->setDebug();
     }
     $feed->parse($data);
     $this->title = $feed->getTitle();
     $this->addItems($feed->getItems());
 }
Esempio n. 20
0
 function parse($data)
 {
     $base_url = '';
     if (is_url($data)) {
         //d($data);
         $http = new HttpClient($data);
         $http->setCacheTime(60 * 60);
         //1h
         $data = $http->getBody();
         if (strpos($data, '#EXTM3U') === false) {
             throw new \Exception('M3uReader->parse FAIL: cant parse feed from ' . $http->getUrl());
             return false;
         }
         $base_url = dirname($http->getUrl());
     }
     $this->items = array();
     $rows = explode("\n", $data);
     $ent = new VideoResource();
     //echo '<pre>';
     foreach ($rows as $row) {
         $row = trim($row);
         $p = explode(':', $row, 2);
         switch ($p[0]) {
             case '#EXTM3U':
             case '':
                 break;
                 /*
                 #EXT-X-VERSION:2
                 #EXT-X-ALLOW-CACHE:YES
                 #EXT-X-TARGETDURATION:10
                 #EXT-X-MEDIA-SEQUENCE:0
                 */
             /*
             #EXT-X-VERSION:2
             #EXT-X-ALLOW-CACHE:YES
             #EXT-X-TARGETDURATION:10
             #EXT-X-MEDIA-SEQUENCE:0
             */
             case '#EXTINF':
                 $x = explode(',', $p[1], 2);
                 $ent->setDuration($x[0] != '-1' ? $x[0] : '');
                 $ent->setTitle($x[1]);
                 break;
                 // multiple quality streams for same media can exist
             // multiple quality streams for same media can exist
             case '#EXT-X-STREAM-INF':
                 // #EXT-X-STREAM-INF:PROGRAM-ID=1, BANDWIDTH=294332
                 $x = explode(',', $p[1]);
                 foreach ($x as $kv) {
                     $x2 = explode('=', trim($kv), 2);
                     if ($x2[0] == 'PROGRAM-ID') {
                         $ent->track_id = $x2[1];
                     }
                     if ($x2[0] == 'BANDWIDTH') {
                         // XXX BITRATE???
                         $ent->bitrate = $x2[1];
                     }
                 }
                 break;
             default:
                 if (substr($row, 0, 1) == '#') {
                     break;
                 }
                 if ($base_url && strpos($row, '://') === false) {
                     $row = $base_url . '/' . $row;
                 }
                 $ent->setUrl($row);
                 $this->items[] = $ent;
                 $ent = new VideoResource();
                 break;
         }
     }
 }