function meldPersistQuery($sQuery = "", $event = "", $asArray = false) { if (is_array($sQuery)) { $aQuery = $sQuery; } else { if (!empty($sQuery)) { // need an intermediate step here. $aQuery = Net_URL::_parseRawQuerystring($sQuery); } else { $aQuery = array(); } } // now try to grab each persisted entry // don't overwrite the existing values, if added. if (is_array($this->aPersistParams)) { foreach ($this->aPersistParams as $k) { if (!array_key_exists($k, $aQuery)) { $v = KTUtil::arrayGet($_REQUEST, $k); if (!empty($v)) { $aQuery[$k] = $v; } } // handle the case where action is passed in already. } } // if it isn't already set if (!array_key_exists($this->event_var, $aQuery) && !empty($event)) { $aQuery[$this->event_var] = urlencode($event); } //var_dump($aQuery); if ($asArray) { return $aQuery; } // encode and blend. $aQueryStrings = array(); foreach ($aQuery as $k => $v) { $aQueryStrings[] = urlencode($k) . "=" . urlencode($v); } $sQuery = join('&', $aQueryStrings); return $sQuery; }
/** * レスポンス変換. * * @param curl_handler $curl * @return string */ static function curl_result($curl) { $result = curl_exec($curl); $curl_info = curl_getinfo($curl); $status_code = curl_getinfo($curl, CURLINFO_HTTP_CODE); if ($status_code >= 400) { GC_Utils_Ex::gfPrintLog(print_r(compact("result"), true), DEBUG_LOG_REALFILE); SC_Utils_Ex::sfDispSiteError(FREE_ERROR_MSG, "", true, "サービス停止中です。(E0003)"); } $header_size = $curl_info["header_size"]; $result = array("head" => trim(substr($result, 0, $header_size)), "body" => trim(substr($result, $header_size)), "info" => $curl_info, "get" => $_GET, "post" => $_POST); $result["info"]["request_header"] = preg_split("/[\r\n]+/", $result["info"]["request_header"]); array_filter($result["info"]["request_header"], "strlen"); array_walk($result["info"]["request_header"], function ($value, $key) use(&$result) { if ($key == 0 || !is_numeric($key)) { return $value; } list($k, $v) = explode(":", $value, 2); $k = trim($k); if (strtolower($k) == "date") { $v = date("Y-m-d H:i:s T", strtotime($v)); } $result["info"]["request_header"][$k] = trim($v); unset($result["info"]["request_header"][$key]); }); $result["head_orig"] = $result["head"]; $result["head"] = preg_split("/[\r\n]+/", $result["head"]); array_filter($result["head"], "strlen"); array_walk($result["head"], function ($value, $key) use(&$result) { if ($key == 0 || !is_numeric($key)) { return $value; } list($k, $v) = explode(":", $value, 2); $k = trim($k); if (strtolower($k) == "date") { $v = date("Y-m-d H:i:s T", strtotime($v)); } $result["head"][$k] = trim($v); unset($result["head"][$key]); }); $result["body_orig"] = $result["body"]; if (preg_match("(body|xml|html)", $result["body"])) { // nop } else { $result["body"] = preg_split("/[\r\n]+/", $result["body"]); array_filter($result["body"], "strlen"); array_walk($result["body"], function ($value, $key) use(&$result) { if (!is_numeric($key)) { return $value; } $newUrl = new Net_URL(); $rows = $newUrl->_parseRawQuerystring($value); foreach ($rows as $k => $v) { $result["body"][$k] = trim($v); } unset($result["body"][$key]); }); } return $result; }