Last active
May 12, 2019 11:33
-
-
Save sergeycherepanov/f5a64ff0695db906650b7aa5bf34b3fa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
Extension url: https://github.com/runkit7/runkit7 | |
*/ | |
runkit_function_copy('curl_exec', 'curl_exec_orig'); | |
function curl_exec_redefined($ch) { | |
if (!is_resource($ch)) { | |
debug_print_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); | |
throw new \Exception(); | |
} | |
$response = curl_exec_orig($ch); | |
$dir = '/tmp/curl/' . date('Ymd_His') . '_' . getmypid(); | |
if (!is_dir($dir)) { | |
mkdir($dir, 0777, true); | |
} | |
ob_start(); | |
debug_print_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); | |
$trace = ob_get_clean(); | |
file_put_contents($dir . '/curl_exec_result_' . microtime(true) . '.log', $response . PHP_EOL .PHP_EOL .$trace); | |
return $response; | |
} | |
runkit_function_redefine('curl_exec', '', 'return curl_exec_redefined(func_get_arg(0));'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment