Update webpagetool.php

This commit is contained in:
Namhyeon Go 2018-11-26 17:54:28 +09:00 committed by GitHub
parent d524fe30fc
commit 4a971e232a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -47,6 +47,12 @@ if(!function_exists("get_web_cmd")) {
$cmd_fin = "";
$cmd = "";
$headers = array();
if(is_array("headers", $data)) {
$headers = $data['headers'];
unset($data['headers']);
}
if(!loadHelper("exectool")) {
set_error("Helper exectool is required");
show_errors();
@ -73,9 +79,16 @@ if(!function_exists("get_web_cmd")) {
if($method == "jsondata") {
$cmd = "curl -A '%s' --header 'Content-Type: application/json' --request POST --data '%s' %s";
$cmd_fin = sprintf($cmd, make_safe_argument($ua), json_encode($data), $url);
$output = exec_command($cmd_fin, "shell_exec");
}
// process http headers
if(count($headers) > 0) {
foreach($headers as $k=>$v) {
$cmd_fin .= sprintf("-H '%s: %s' ", make_safe_argument($k), make_safe_argument($v));
}
}
// exec command
if(!empty($cmd_fin)) {
$output = exec_command($cmd_fin, "shell_exec");
}