Update webpagetool.php

This commit is contained in:
Namhyeon Go 2018-05-13 01:07:33 +09:00 committed by GitHub
parent 4ccf5b9d5c
commit b94bb65260
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -60,10 +60,13 @@ if(!function_exists("get_web_page")) {
$resno = "-1";
$errno = "-1";
if($method == "post.cmd" || $method == "get.cmd") {
$res_methods = explode(".", $method);
$res_methods = explode(".", $method);
if(in_array("cache", $res_methods)) {
$content = get_web_cache($url, $method, $data, $proxy, $ua, $ct_out, $t_out);
} elseif(in_array("cmd", $res_methods)) {
$content = get_web_cmd($url, $res_methods[0], $data, $proxy, $ua, $ct_out, $t_out);
} elseif($method == "get.fgc") {
} elseif(in_array("fgc", $res_methods)) {
$content = get_web_fgc($url);
} else {
if(!in_array("curl", get_loaded_extensions())) {
@ -134,6 +137,34 @@ if(!function_exists("get_web_page")) {
}
}
if(!function_exists("get_web_identifier")) {
function get_web_identifier($url, $method="get", $data=array()) {
$hash_data = (count($data) > 0) ? get_hashed_text(serialize($data)) : "*";
return get_hashed_text(sprintf("%s.%s.%s", $method, get_hashed_text($url), $hash_data));
}
}
if(!function_exists("get_web_cache") {
function get_web_cache($url, $method="get", $data=array(), $proxy="", $ua="", $ct_out=45, $t_out=45) {
$identifier = get_web_identifier($url, $method, $data);
$content = read_storage_file($identifier, array(
"storage_type" => "cache"
));
if($content === false) {
$content = get_web_page($url, $method, $data, $proxy, $ua, $ct_out, $t_out);
// save web page cache
write_storage_file($content, array(
"storage_type" => "cache",
"rename" => $identifier
));
}
return $content;
}
}
if(!function_exists("get_web_json")) {
function get_web_json($url, $method="get", $data=array(), $proxy="", $ua="", $ct_out=45, $t_out=45) {
$result = array();