FunctiongetUrl ($ address, $ myip) {ob_start (); $ mtime = explode ('', microtime ()); $ starttime = $ mtime [1] + $ mtime [0]; $ onoff = (function_exists ('ini _ get '))? I
Function getUrl ($ address, $ myip ){
Ob_start ();
$ Mtime = explode ('', microtime ());
$ Starttime = $ mtime [1] + $ mtime [0];
$ Onoff = (function_exists ('ini _ get '))? Ini_get ('register _ globals'): get_reg_var ('register _ globals ');
If ($ onoff! = 1 ){
@ Extract ($ _ POST, EXTR_SKIP );
@ Extract ($ _ GET, EXTR_SKIP );
}
$ Self = $ _ SERVER ['php _ SELF '];
$ Myaddress = 'http: // '. $ _ SERVER ['http _ host']. $ self;
$ Comm = '';
If (isset ($ url) & $ url ){
$ Url = str_replace ($ address, '', $ url );
}
/*
Foreach ($ _ POST as $ key => $ val ){
If ($ comm = ''){
$ Comm = $ key. '='. rawurlencode ($ val );
} Else {
$ Comm = $ comm. '&'. $ key. '='. rawurlencode ($ val );
}
}
*/
$ Pcomm = '';
Foreach ($ _ POST as $ key => $ val ){
If ($ pcomm = ''){
$ Pcomm. = $ key. ''. urlencode ($ val );
} Else {
$ Pcomm. = $ pcomm. '&'. $ key. '='. urlencode ($ val );
}
}
Foreach ($ _ GET as $ key => $ val ){
If ($ key! = 'URL '){
If ($ comm = ''){
$ Comm = $ key. '='. rawurlencode ($ val );
} Else {
$ Comm = $ comm. '&'. $ key. '='. rawurlencode ($ val );
}
}
}
If (! $ Url ){
$ Url = $ address;
} Else {
$ Url = $ address. $ url;
If ($ comm ){
If (strstr ($ url ,'? ')){
$ Url = $ url. '&'. $ comm;
} Else {
$ Url = $ url .'? '. $ Comm;
}
}
}
If ($ url ){
$ Cookies = '';
If (count ($ _ COOKIE )){
Foreach ($ _ COOKIE as $ cookie_name => $ cookie_var ){
$ Cookies. = $ cookies! = ''? ';'. $ Cookie_name. '='. $ cookie_var: $ cookie_name. '='. $ cookie_var;
}
}
$ Temp = @ parse_url ($ url );
$ Temp ['port'] = isset ($ temp ['port'])? $ Temp ['port']: 80;
$ Temp ['path'] = isset ($ temp ['path'])? $ Temp ['path']: '/';
$ Temp ['file'] = substr ($ temp ['path'], strrpos ($ temp ['path'], '/') + 1 );
$ Temp ['dir'] = substr ($ temp ['path'], 0, strrpos ($ temp ['path'], '/');
$ Temp ['base'] = $ temp ['scheme '].': // '. $ temp ['host']. ($ temp ['port']! = 80? ':'. $ Temp ['port']: ''). $ temp ['dir'];
$ Temp ['prev _ dir'] = $ temp ['path']! = '/'? Substr ($ temp ['base'], 0, strrpos ($ temp ['base'], '/') + 1): $ temp ['base']. '/';
$ Fp = @ fsockopen ($ temp ['host'], $ temp ['port'], $ errno, $ errstr, 30 );
If ($ fp ){
If ($ _ SERVER ['request _ method']! = 'Post '){
@ Fputs ($ fp, "GET $ temp [path]? $ Temp [query] HTTP/1.1 \ r \ n ");
} Else {
@ Fputs ($ fp, "POST $ temp [path]? $ Temp [query] HTTP/1.1 \ r \ n ");
}
@ Fputs ($ fp, "Host: $ temp [host] \ r \ n ");
@ Fputs ($ fp, "Accept: */* \ r \ n ");
@ Fputs ($ fp, "Referer: http: // $ temp [host]/\ r \ n ");
@ Fputs ($ fp, "Cookie: $ cookies \ r \ n ");
@ Fputs ($ fp, "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) \ r \ n ");
@ Fputs ($ fp, "via: 1.1 JEJE1: 80 (squid/2.5.STABLE4-NT-CVS) \ r \ n ");
@ Fputs ($ fp, "X-Forwarded-For: $ myip \ r \ n ");
If ($ _ SERVER ['request _ method'] = 'post '){
@ Fputs ($ fp, "Content-Type: application/x-www-form-urlencoded \ r \ n ");
@ Fputs ($ fp, "Content-Length:". strlen ($ pcomm). "\ r \ n ");
@ Fputs ($ fp, $ pcomm );
}
@ Fputs ($ fp, "Connection: Close \ r \ n ");
While ($ str = @ fread ($ fp, 4096 )){
If ($ str! = "\ R \ n" & preg_match_all ("# set-cookie :( [^ \ r \ n] *) # I", $ str, $ matches )){
Foreach ($ matches [1] as $ cookie_info ){
Preg_match ('# ^ \ s * ([^ =;, \ s] *) =? ([^;, \ S] *) # ', $ cookie_info, $ match) & list (, $ name, $ value) = $ match;
Preg_match ('#; \ s * expires \ s * = ([^;] *) # I', $ cookie_info, $ match) & list (, $ expires) = $ match;
$ Expires = isset ($ expires )? Strtotime ($ expires): false;
$ Expires = (! Is_numeric ($ expires) | time ()> $ expires )? False: $ expires;
Setcookie ($ name, $ value, $ expires );
}
$ Str = str_replace ($ matches [0], '', $ str );
}
$ Content. = $ str;
}
@ Fclose ($ fp );
If (strpos ($ Content, 'Content-Type: text/html ')){
$ Content = substr ($ Content, strpos ($ Content, 'Content-Type: text/html') + 33 );
} Else {
$ Content = substr ($ Content, strpos ($ Content, chr (0x0d). chr (0x0a). chr (0x0d). chr (0x0a) + 4 );
}
$ Content = str_replace ('href = "', 'href ="'. $ myaddress .'? Url = ', $ Content );
$ Content = str_replace ('href = \ '', 'href = \''. $ myaddress .'? Url = ', $ Content );
$ Content = str_replace ('src = "', 'src ="'. $ myaddress .'? Url = ', $ Content );
$ Content = str_replace ('src = \ '', 'src = \''. $ myaddress .'? Url = ', $ Content );
$ Content = str_replace ('src = image', 'src = "'. $ myaddress .'? Url = image', $ Content );
$ Content = str_replace ('src = customavatars/', 'src ='. $ myaddress .'? Url = customavatars/', $ Content );
$ Content = str_replace ('action = "', 'action ="'. $ myaddress .'? Url = ', $ Content );
$ Content = str_replace ('URL ("', 'URL ("'. $ myaddress .'? Url = ', $ Content );
$ Content = str_replace ('background = "', 'background ="'. $ myaddress .'? Url = ', $ Content );
$ Content = str_replace ('URL (\ '', 'URL (\''. $ myaddress .'? Url = ', $ Content );
$ Content = str_replace ($ myaddress .'? Url = javascript: ', 'javascript:', $ Content );
$ Content = str_replace ('; url =', '; url ='. $ myaddress .'? Url = ', $ Content );
Return $ Content;
}
}
Return false;
}
$ MyIP = rand (0,255). '.'. rand (0,255). '.'. rand (0,255). '. rand (0,255 );
Echo getUrl ('http: // www.ip138.com/ip2city.asp', $ myIP );