Update webpagetool.php
This commit is contained in:
parent
9e3442f623
commit
e25ea2331a
|
@ -54,7 +54,7 @@ if(!function_exists("get_web_cmd")) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if($method == "get") {
|
if($method == "get") {
|
||||||
$args[] = sprintf("-A '%s'", make_safe_argument($ua)); // set agent
|
$args[] = sprintf("-A '%s'", get_web_user_agent($ua)); // set agent
|
||||||
$args[] = "-k"; // allow self-signed certificate (the same as --insecure)
|
$args[] = "-k"; // allow self-signed certificate (the same as --insecure)
|
||||||
foreach($headers as $k=>$v) {
|
foreach($headers as $k=>$v) {
|
||||||
// the same as --header
|
// the same as --header
|
||||||
|
@ -65,7 +65,7 @@ if(!function_exists("get_web_cmd")) {
|
||||||
|
|
||||||
if($method == "post") {
|
if($method == "post") {
|
||||||
$args[] = "-X POST"; // set post request (the same as --request)
|
$args[] = "-X POST"; // set post request (the same as --request)
|
||||||
$args[] = sprintf("-A '%s'", make_safe_argument($ua)); // set agent
|
$args[] = sprintf("-A '%s'", get_web_user_agent($ua)); // set agent
|
||||||
$args[] = "-k"; // allow self-signed certificate (the same as --insecure)
|
$args[] = "-k"; // allow self-signed certificate (the same as --insecure)
|
||||||
foreach($headers as $k=>$v) {
|
foreach($headers as $k=>$v) {
|
||||||
// the same as --header
|
// the same as --header
|
||||||
|
@ -85,7 +85,7 @@ if(!function_exists("get_web_cmd")) {
|
||||||
if($method == "jsondata") {
|
if($method == "jsondata") {
|
||||||
$data_string = json_encode($data);
|
$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'", get_web_user_agent($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);
|
$headers['Content-Length'] = strlen($data_string);
|
||||||
|
@ -243,7 +243,7 @@ if(!function_exists("get_web_curl")) {
|
||||||
);
|
);
|
||||||
|
|
||||||
if(empty($options[CURLOPT_USERAGENT])) {
|
if(empty($options[CURLOPT_USERAGENT])) {
|
||||||
$ua = "ReasonableFramework/1.1 (https://github.com/gnh1201/reasonableframework)";
|
$ua = get_web_user_agent($ua);
|
||||||
$options[CURLOPT_USERAGENT] = $ua;
|
$options[CURLOPT_USERAGENT] = $ua;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -310,9 +310,7 @@ if(!function_exists("get_web_page")) {
|
||||||
$req_method = $method;
|
$req_method = $method;
|
||||||
|
|
||||||
// set user agent
|
// set user agent
|
||||||
if(empty($ua)) {
|
$ua = get_web_user_agent($ua);
|
||||||
$ua = "ReasonableFramework/1.1 (https://github.com/gnh1201/reasonableframework)";
|
|
||||||
}
|
|
||||||
|
|
||||||
// redefine data
|
// redefine data
|
||||||
$headers = array();
|
$headers = array();
|
||||||
|
@ -546,3 +544,14 @@ if(!function_exists("get_webproxy_url")) {
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!function_exists("get_web_user_agent")) {
|
||||||
|
function get_web_user_agent($ua="") {
|
||||||
|
if(empty($ua)) {
|
||||||
|
$ua = "ReasonableFramework/1.1 (https://github.com/gnh1201/reasonableframework)";
|
||||||
|
} else {
|
||||||
|
$ua = make_safe_argument($ua);
|
||||||
|
}
|
||||||
|
return $ua;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user