Пример #1
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");
     }
 }
Пример #2
0
 /**
  *  获取校验结果
  * @param $ssid
  * @param $result
  * @param int $diff
  * @return type
  */
 public static function sendVerifyRemoteRequest($ssid, $result, $diff = 0)
 {
     $client = new HttpClient(App::getConfig('YUC_SERVICE_NAME'), App::getConfig('YUC_SERVICE_PORT'));
     $client->setTimeout(App::getConfig('YUC_CLIENT_TIMEOUT'));
     //设置超时
     $client->post(App::getConfig('YUC_VERIFY_PATH'), array('site_key' => App::getConfig('YUC_SITE_KEY'), 'ssid' => $ssid, 'result' => $result, 'diffsec_client' => $diff));
     $post_req = json_decode($client->getContent(), TRUE);
     Log::Write('远程验证完成,输入结果为:' . $result . ',返回状态 :' . $client->getStatus() . ';' . 'POST 验证码正确性请求返回的数据:' . $client->getContent(), Log::DEBUG);
     if ($client->getStatus() == 200 && is_array($post_req)) {
         //200状态 正常返回数据 且返回数据格式正常
         self::$_yuc_code = $post_req['code'];
         self::$_yuc_details = $post_req['details'];
         self::$_yuc_result = $post_req['result'];
     } else {
         self::$_yuc_code = 'E_SEVERVALID_001';
         self::$_yuc_details = '服务器请求失败!';
         self::$_yuc_result = 0;
     }
     return array('code' => self::$_yuc_code, 'result' => self::$_yuc_result, 'details' => self::$_yuc_details);
 }
Пример #3
0
/**
 * Takes some work orders from the process queue and performs them
 */
function processQueue()
{
    global $db, $config;
    //Only allows a few work orders being executed at once, so we can do this very often
    if (TaskQueue::getTaskQueueStatusCnt(ORDER_EXECUTING) >= $config['process']['process_limit']) {
        echo "TOO MUCH ACTIVE WORK, ABORTING\n";
        return;
    }
    $job = TaskQueue::getOldestEntry();
    if (!$job) {
        return;
    }
    //mark current job as "IN PROGRESS" so another process won't start on it aswell
    TaskQueue::markTask($job['entryId'], ORDER_EXECUTING);
    echo "\n\n-------------\n";
    switch ($job['orderType']) {
        case TASK_IMAGE_RECODE:
            echo 'IMAGE RECODE<br/>';
            if (!in_array($job['orderParams'], $h->files->image_mime_types)) {
                echo 'error: invalid mime type<br/>';
                $h->session->log('Process queue error - image conversion destination mimetype not supported: ' . $job['orderParams'], LOGLEVEL_ERROR);
                break;
            }
            $newId = $h->files->cloneFile($job['referId'], FILETYPE_CLONE_CONVERTED);
            $exec_start = microtime(true);
            $check = convertImage($h->files->findUploadPath($job['referId']), $h->files->findUploadPath($newId), $job['orderParams']);
            $exec_time = microtime(true) - $exec_start;
            echo 'Execution time: ' . shortTimePeriod($exec_time) . '<br/>';
            if (!$check) {
                $h->session->log('#' . $job['entryId'] . ': IMAGE CONVERT failed! format=' . $job['orderParams'], LOGLEVEL_ERROR);
                echo 'Error: Image convert failed!<br/>';
                break;
            }
            $h->files->updateFile($newId, $job['orderParams']);
            markQueueCompleted($job['entryId'], $exec_time);
            break;
        case TASK_AUDIO_RECODE:
            //Recodes source audio file into orderParams destination format
            $dst_audio_ok = array('ogg', 'wma', 'mp3');
            //FIXME: config item or $h->files->var
            if (!in_array($job['orderParams'], $dst_audio_ok)) {
                echo 'error: invalid mime type<br/>';
                $h->session->log('Process queue error - audio conversion destination mimetype not supported: ' . $job['orderParams'], LOGLEVEL_ERROR);
                break;
            }
            $file = $h->files->getFileInfo($job['referId']);
            if (!$file) {
                echo 'Error: no fileentry existed for fileId ' . $job['referId'];
                break;
            }
            $newId = $h->files->cloneFile($job['referId'], FILETYPE_CLONE_CONVERTED);
            echo 'Recoding source audio of "' . $file['fileName'] . '" (' . $file['fileMime'] . ') to format ' . $job['orderParams'] . " ...\n";
            switch ($job['orderParams']) {
                case 'application/x-ogg':
                    //FIXME hur anger ja dst-format utan filändelse? tvingas göra det i 2 steg nu
                    $dst_file = 'tmpfile.ogg';
                    $c = '/usr/local/bin/ffmpeg -i "' . $h->files->findUploadPath($job['referId']) . '" ' . $dst_file;
                    break;
                case 'audio/x-ms-wma':
                    $dst_file = 'tmpfile.wma';
                    $c = '/usr/local/bin/ffmpeg -i "' . $h->files->findUploadPath($job['referId']) . '" ' . $dst_file;
                    break;
                case 'audio/mpeg':
                case 'audio/x-mpeg':
                    //fixme: source & destination should not be able to be the same!
                    $dst_file = 'tmpfile.mp3';
                    $c = '/usr/local/bin/ffmpeg -i "' . $h->files->findUploadPath($job['referId']) . '" ' . $dst_file;
                    break;
                default:
                    die('unknown destination audio format: ' . $job['orderParams']);
            }
            echo 'Executing: ' . $c . "\n";
            $exec_time = exectime($c);
            echo 'Execution time: ' . shortTimePeriod($exec_time) . "\n";
            if (!file_exists($dst_file)) {
                echo '<b>FAILED - dst file ' . $dst_file . " dont exist!\n";
                break;
            }
            //FIXME: behöver inget rename-steg. kan skriva till rätt output fil i första steget
            rename($dst_file, $h->files->upload_dir . $newId);
            $h->files->updateFile($newId);
            markQueueCompleted($job['entryId'], $exec_time);
            break;
        case TASK_VIDEO_RECODE:
            echo "VIDEO RECODE:\n";
            $exec_start = microtime(true);
            if (convertVideo($job['referId'], $job['orderParams']) === false) {
                markQueue($job['entryId'], ORDER_FAILED);
            } else {
                markQueueCompleted($job['entryId'], microtime(true) - $exec_start);
            }
            break;
        case TASK_FETCH:
            echo "FETCH CONTENT\n";
            $fileName = basename($job['orderParams']);
            //extract filename part of url, used as "filename" in database
            $http = new HttpClient($job['orderParams']);
            $http->getHead();
            if ($http->getStatus() != 200) {
                // retry in 20 seconds if file is not yet ready
                retryQueueEntry($job['entryId'], 20);
                break;
            }
            $newFileId = FileList::createEntry(FILETYPE_PROCESS, 0, 0, $fileName);
            $c = 'wget ' . escapeshellarg($job['orderParams']) . ' -O ' . FileInfo::getUploadPath($newFileId);
            echo "\$ " . $c . "\n";
            $retval = 0;
            $exec_time = exectime($c, $retval);
            if (!$retval) {
                //TODO: process html document for media links if it is a html document
                TaskQueue::markTaskCompleted($job['entryId'], $exec_time, $newFileId);
                FileInfo::updateData($newFileId);
            } else {
                //wget failed somehow, delay work for 1 minute
                retryQueueEntry($job['entryId'], 60);
                $files->deleteFile($newFileId, 0, true);
                //remove failed local file entry
            }
            break;
        case TASK_CONVERT_TO_DEFAULT:
            echo "CONVERT TO DEFAULT\n";
            //referId is entryId of previous proccess queue order
            $params = unserialize($job['orderParams']);
            $prev_job = TaskQueue::getEntry($job['referId']);
            if ($prev_job['orderStatus'] != ORDER_COMPLETED) {
                retryQueueEntry($job['entryId'], 60);
                break;
            }
            $file = $files->getFileInfo($prev_job['referId']);
            $exec_start = microtime(true);
            $newId = false;
            switch ($file['mediaType']) {
                case MEDIATYPE_VIDEO:
                    $newId = convertVideo($prev_job['referId'], $h->files->default_video, !empty($params['callback']) ? false : true, !empty($params['watermark']) ? $params['watermark'] : '');
                    break;
                case MEDIATYPE_AUDIO:
                    $newId = convertAudio($prev_job['referId'], $h->files->default_audio);
                    break;
                default:
                    echo "UNKNOWN MEDIA TYPE " . $file['mediaType'] . ", MIME TYPE " . $file['fileMime'] . ", CANNOT CONVERT MEDIA!!!\n";
                    break;
            }
            if (!$newId) {
                markQueue($job['entryId'], ORDER_FAILED);
                return false;
            }
            markQueueCompleted($job['entryId'], microtime(true) - $exec_start);
            if (empty($params['callback'])) {
                break;
            }
            //'uri' isnt known before the new file is created so it is added at this point
            $uri = $config['core']['full_url'] . 'api/file.php?id=' . $newId;
            $params['callback'] .= (strpos($params['callback'], '?') !== false ? '&' : '?') . 'uri=' . urlencode($uri);
            $data = file_get_contents($params['callback']);
            echo "Performing callback: " . $params['callback'] . "\n\n";
            echo "Callback script returned:\n" . $data;
            storeCallbackData($job['entryId'], $data, $params);
            break;
        default:
            echo "Unknown ordertype: " . $job['orderType'] . "\n";
            d($job);
            die;
    }
}
Пример #4
0
 function _upload($args, $path, $timeout)
 {
     global $request;
     $reaction = 'upload ';
     if ($args['noupload']) {
         return $reaction . _("skipped");
     }
     //$userid  = $request->_user->_userid;
     $url = $args['url'];
     $url = str_replace("/RPC2.php", "/index.php", $url);
     $server = parse_url($url);
     $http = new HttpClient($server['host'], $server['port']);
     $http->timeout = $timeout + 5;
     $success = $http->postfile($server['url'], $path);
     if ($success) {
         if ($http->getStatus() == 200) {
             $reaction .= _("OK");
         } else {
             $reaction .= _("FAILED") . ' ' . $http->getStatus();
         }
     } else {
         $reaction .= _("FAILED") . ' ' . $http->getStatus() . " " . $http->errormsg;
     }
     return $reaction;
 }
Пример #5
0
 public function ajaxcheckandsaveAction()
 {
     $this->_helper->layout->disableLayout();
     $code = urldecode($this->_request->getParam('code'));
     $config = Zend_Registry::get('config');
     $writer_host = $config->writer->host;
     $uri = "/sns/find_sns.json";
     //TODO: use config.ini
     $client = new HttpClient("localhost", "4000");
     $access_token = NULL;
     $access_token_secret = NULL;
     $refresh_access_token = NULL;
     $expires_at = NULL;
     $expires_in = NULL;
     $username = NULL;
     $user = NULL;
     $nick = NULL;
     $profile_img_path = NULL;
     $big_profile_img_path = NULL;
     $small_profile_img_path = NULL;
     $client->get($uri, array('code' => $code));
     if ($client->getStatus() == "200") {
         $rs = json_decode($client->getContent());
         if (isset($rs->access_token_secret)) {
             $access_token_secret = $rs->access_token_secret;
         }
         if (isset($rs->refresh_access_token)) {
             $refresh_access_token = $rs->refresh_access_token;
         }
         if (isset($rs->expires_at)) {
             $expires_at = $rs->expires_at;
         }
         if (isset($rs->expires_in)) {
             $expires_in = $rs->expires_in;
         }
         if (isset($rs->username)) {
             $username = $rs->username;
         }
         if (isset($rs->user)) {
             $user = $rs->user;
         }
         if (isset($rs->nick)) {
             $nick = $rs->nick;
         }
         if (isset($rs->profile_img_path)) {
             $profile_img_path = $rs->profile_img_path;
         }
         if (isset($rs->big_profile_img_path)) {
             $big_profile_img_path = $rs->big_profile_img_path;
         }
         if (isset($rs->small_profile_img_path)) {
             $small_profile_img_path = $rs->small_profile_img_path;
         }
         $sns = new Sns();
         $row = $sns->fetchRow($sns->select()->where('access_token = ?', $rs->access_token));
         if (isset($row)) {
             $data = array('access_token' => $rs->access_token);
             $where = $sns->getAdapter()->quoteInto('id = ?', $row->id);
             $sns->update($data, $where);
         } else {
             try {
                 $data = array('code' => $code, 'access_token' => $rs->access_token, 'access_token_secret' => $access_token_secret, 'refresh_access_token' => $refresh_access_token, 'expires_at' => $expires_at, 'expires_in' => $expires_in, 'consumer' => (int) $this->_currentUser->id, 'source' => $rs->source, 'timestamp' => date("Y-m-d H:i:s"), 'username' => $username, 'user' => $user, 'nick' => $nick, 'profile_img_path' => $profile_img_path, 'big_profile_img_path' => $big_profile_img_path, 'small_profile_img_path' => $small_profile_img_path);
                 $sns->insert($data);
                 $this->_helper->json(1);
             } catch (Exception $e) {
                 print_r($e);
             }
         }
         $response = array("status" => 1);
     } else {
         $response = array("status" => 0);
     }
     $this->getHelper('json')->sendJson($response);
 }
Пример #6
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);
 }
Пример #7
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;
     }
 }
Пример #8
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;
 }