Update webpagetool.php
This commit is contained in:
parent
0ebf442442
commit
2ef66e681c
|
@ -83,14 +83,16 @@ if(!function_exists("get_web_cmd")) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if($method == "jsondata") {
|
if($method == "jsondata") {
|
||||||
|
$data_string = json_encode($data);
|
||||||
$args[] = "-X POST"; // set post request (the same as -X)
|
$args[] = "-X POST"; // set post request (the same as -X)
|
||||||
$args[] = sprintf("-A '%s'", make_safe_argument($ua)); // set agent
|
$args[] = sprintf("-A '%s'", make_safe_argument($ua)); // set agent
|
||||||
$args[] = "-k"; // allow self-signed certificate (the same as --insecure)
|
$args[] = "-k"; // allow self-signed certificate (the same as --insecure)
|
||||||
$headers['Content-Type'] = "application/json";
|
$headers['Content-Type'] = "application/json";
|
||||||
|
$headers['Content-Length'] = strlen($data_string);
|
||||||
foreach($headers as $k=>$v) {
|
foreach($headers as $k=>$v) {
|
||||||
$args[] = sprintf("--header '%s: %s'", make_safe_argument($k), make_safe_argument($v));
|
$args[] = sprintf("--header '%s: %s'", make_safe_argument($k), make_safe_argument($v));
|
||||||
}
|
}
|
||||||
$args[] = sprintf("--data '%s'", json_encode($data));
|
$args[] = sprintf("--data '%s'", $data_string);
|
||||||
$args[] = $url;
|
$args[] = $url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -215,6 +217,7 @@ if(!function_exists("get_web_wget")) {
|
||||||
if(!function_exists("get_web_curl")) {
|
if(!function_exists("get_web_curl")) {
|
||||||
function get_web_curl($url, $method="get", $data=array(), $proxy="", $ua="", $ct_out=45, $t_out=45, $headers=array()) {
|
function get_web_curl($url, $method="get", $data=array(), $proxy="", $ua="", $ct_out=45, $t_out=45, $headers=array()) {
|
||||||
$content = false;
|
$content = false;
|
||||||
|
$req_headers = array();
|
||||||
|
|
||||||
if(!in_array("curl", get_loaded_extensions())) {
|
if(!in_array("curl", get_loaded_extensions())) {
|
||||||
$error_msg = "cURL extension needs to be installed.";
|
$error_msg = "cURL extension needs to be installed.";
|
||||||
|
@ -265,7 +268,10 @@ if(!function_exists("get_web_curl")) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if(count($headers) > 0) {
|
if(count($headers) > 0) {
|
||||||
$options[CURLOPT_HTTPHEADER] = $headers;
|
foreach($headers as $k=>$v) {
|
||||||
|
$req_headers[] = sprintf("%s: %s", make_safe_argument($k), make_safe_argument($v));
|
||||||
|
}
|
||||||
|
$options[CURLOPT_HTTPHEADER] = $req_headers;
|
||||||
}
|
}
|
||||||
|
|
||||||
$ch = curl_init();
|
$ch = curl_init();
|
||||||
|
@ -325,6 +331,9 @@ if(!function_exists("get_web_page")) {
|
||||||
$status = $curl_result['status'];
|
$status = $curl_result['status'];
|
||||||
$resno = $curl_result['resno'];
|
$resno = $curl_result['resno'];
|
||||||
$errno = $curl_result['errno'];
|
$errno = $curl_result['errno'];
|
||||||
|
|
||||||
|
var_dump($curl_result);
|
||||||
|
exit;
|
||||||
|
|
||||||
if($content !== false) {
|
if($content !== false) {
|
||||||
// nothing
|
// nothing
|
||||||
|
|
Loading…
Reference in New Issue
Block a user