コード例 #1
0
function cw_https_request_httpscli($method, $url, $data = "", $join = "&", $cookie = "", $conttype = "application/x-www-form-urlencoded", $referer = "", $cert = "", $kcert = "", $headers = "")
{
    if ($method != "POST" && $method != "GET") {
        return array("0", "HTTPS: Invalid method");
    }
    if (!preg_match("/^(https?:\\/\\/)(.*\\@)?([a-z0-9_\\.\\-]+):(\\d+)(\\/.*)\$/Ui", $url, $m)) {
        return array("0", "HTTPS: Invalid URL");
    }
    $ui = parse_url($url);
    $binary = cw_find_executable("https_cli");
    if (!$binary) {
        return array("0", "HTTPS: https_cli executable is not found");
    }
    if (!CW_IS_OS_WINDOWS) {
        putenv("LD_LIBRARY_PATH=" . getenv("LD_LIBRARY_PATH") . ":" . dirname($binary));
    }
    $request = cw_https_prepare_request($method, $ui, $data, $join, $cookie, $conttype, $referer, $headers);
    $tmpfile = cw_temp_store($request);
    if (empty($tmpfile)) {
        return array(0, "HTTPS: cannot create temporaly file");
    }
    $cmdline = cw_shellquote($binary) . " {$ui['host']} {$ui['port']} " . cw_shellquote($cert) . " " . cw_shellquote($kcert) . " < " . cw_shellquote($tmpfile);
    // make pipe
    $fp = popen($cmdline, "r");
    if (!$fp) {
        return array(0, "HTTPS: https_cli execution failed");
    }
    $res = cw_https_receive_result($fp);
    pclose($fp);
    @unlink($tmpfile);
    return $res;
}
コード例 #2
0
function cw_https_request_ssleay($method, $url, $data = "", $join = "&", $cookie = "", $conttype = "application/x-www-form-urlencoded", $referer = "", $cert = "", $kcert = "", $headers = "")
{
    global $config;
    global $app_main_dir;
    if ($method != "POST" && $method != "GET") {
        return array("0", "HTTPS: Invalid method");
    }
    if (!preg_match("/^(https?:\\/\\/)(.*\\@)?([a-z0-9_\\.\\-]+):(\\d+)(\\/.*)\$/Ui", $url, $m)) {
        return array("0", "HTTPS: Invalid URL");
    }
    $perl_exe = cw_find_executable("perl", $config['General']['perl_binary']);
    if ($perl_exec === false) {
        return array("0", "HTTPS: perl is not found");
    }
    $includes = " -I" . cw_shellquote($app_main_dir . '/payment');
    $includes .= " -I" . cw_shellquote($app_main_dir . '/payment/Net');
    $execline = cw_shellquote($perl_exe) . ' ' . $includes . ' ' . cw_shellquote($app_main_dir . "/payment/netssleay.pl");
    $ui = parse_url($url);
    if (empty($ui['port'])) {
        $ui['port'] = 443;
    }
    $request = cw_https_prepare_request($method, $ui, $data, $join, $cookie, $conttype, $referer, $headers);
    $tmpfile = cw_temp_store($request);
    if (empty($tmpfile)) {
        return array(0, "HTTPS: cannot create temporaly file");
    }
    $ignorefile = cw_temp_store("");
    $execline .= " {$ui['host']} {$ui['port']} " . cw_shellquote($cert) . ' ' . cw_shellquote($kcert) . ' < ' . cw_shellquote($tmpfile) . ' 2>' . cw_shellquote($ignorefile);
    $fp = popen($execline, "r");
    if (!$fp) {
        return array(0, "HTTPS: Net::SSLeay execution failed");
    }
    $res = cw_https_receive_result($fp);
    pclose($fp);
    @unlink($tmpfile);
    @unlink($ignorefile);
    return $res;
}
コード例 #3
0
function cw_https_tunnel_request($connection, $method, $parsed_url, $data = "", $join = "&", $cookie = "", $conttype = "application/x-www-form-urlencoded", $referer = "", $headers = "")
{
    $request = cw_https_prepare_request($method, $parsed_url, $data, $join, $cookie, $conttype, $referer, $headers);
    fputs($connection, $request);
    return cw_https_receive_result($connection);
}