时间:2021-07-01 10:21:17 帮助过:4人阅读
if($_POST['submit'] != NULL){
$url=$_POST['url'];
去掉上面的if判断,直接使用$url = $GET['url']
你自己判断下$GET['url']的合法性就OK了。
function modify_build_url($params = array(), $url = NULL) { //my_debug(current_url()); if (! $url) { $url = $_SERVER ['REQUEST_URI']; } $parts = parse_url ( $url ); if (! is_array ( $parts )) { $parts = array (); } if (! array_key_exists ( 'host', $parts )) { $parts ['host'] = $_SERVER ['HTTP_HOST']; } $gets = array (); if (array_key_exists ( 'query', $parts )) { $query = $parts ['query']; parse_str ( $query, $gets ); } if (! is_array ( $params )) { $params = array (); } if (! is_array ( $gets )) { $gets = array (); } foreach ( $params as $k => $v ) { $gets [$k] = $v; } $path = null; if (array_key_exists ( 'path', $parts )) { $path = $parts ['path']; } if (! $path) { $path = "/"; } $ret = sprintf ( "http://%s%s?%s", $parts ['host'], $path, http_build_query ( $gets ) ); return $ret; }