0
요,이 스크립트를 작동 시키려고하는데 작동하지 않습니다. 두 가지 기능을 가진 preg_replace_callback을 두 번 어떻게 수행합니까? 감사!preg_replace_callback - do 두 번
function prepend_proxy($matches) {
$url = (substr($_GET['url'], 0, 7) == 'http://') ? $_GET['url'] : "http://{$_GET['url']}";
$prepend = $matches[2] ? $matches[2] : $url;
$prepend = 'proxy2.php?url='. $prepend .'/';
return $matches[1] . $prepend . $matches[3];
}
function imgprepend_proxy($matches2) {
$url = (substr($_GET['url'], 0, 7) == 'http://') ? $_GET['url'] : "http://{$_GET['url']}";
$prepend2 = $matches2[2] ? $matches2[2] : $url;
$prepend2 = $prepend2 .'/';
return $matches2[1] . $prepend2 . $matches2[3];
}
$new_content = preg_replace_callback(
'|(href=[\'"]?)(https?://)?([^\'"\s]+[\'"]?)|i',
'prepend_proxy',
'|(src=[\'"]?)(https?://)?([^\'"\s]+[\'"]?)|i',
'imgprepend_proxy',
$content
);
감사합니다! 그게 효과가 있었어! –