Skip to content

Commit

Permalink
Update index.php
Browse files Browse the repository at this point in the history
  • Loading branch information
gnh1201 committed Nov 25, 2024
1 parent 9a6b68c commit 24e0506
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions assets/php/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@
* Updated at: 2024-11-26
*/

define("PHP_HTTPPROXY_VERSION", "0.1.6.4");
define("PHP_HTTPPROXY_VERSION", "0.1.6.5");
define("DEFAULT_SOCKET_TIMEOUT", 1);
define("STATEFUL_SOCKET_TIMEOUT", 30);
define("MAX_EXECUTION_TIME", 0);
define("ALLOW_INVOKE_INSECURE_METHOD", false);
define("ALLOW_LOAD_INSECURE_SCRIPT", true);
define("DEFAULT_USER_AGENT", 'php-httpproxy/' . PHP_HTTPPROXY_VERSION . ' (Server; PHP ' . phpversion() . '; Caterpillar; [email protected])');

error_reporting(E_ALL);
Expand Down Expand Up @@ -88,6 +90,10 @@ function fatal_handler() {

function load_script($data) {
$loaded_script = false;

if (!ALLOW_LOAD_INSECURE_SCRIPT) {
return $loaded_script;
}

$fh = tmpfile();
if ($fh !== false) {
Expand Down Expand Up @@ -514,7 +520,21 @@ function relay_invoke_method($params) {
$callback = $params['callback'];
$requires = jsonrpc2_cast_to_array($params['requires']);
$args = jsonrpc2_cast_to_array($params['args']);


if (!ALLOW_INVOKE_INSECURE_METHOD) {
$allow_callbacks = array("idn_to_ascii", "idn_to_utf8", "load_script");
if (!in_array($callback, $allow_callbacks)) {
return array(
"success" => false,
"error" => array(
"status" => 403,
"code" => -1,
"message" => $callback . " is not allowed"
)
);
}
}

foreach($requires as $required_url) {
try {
$result = relay_fetch_url(array(
Expand Down

0 comments on commit 24e0506

Please sign in to comment.