View file SHEFON-PROXY/proxy.php

File size: 1.8Kb
<?php function ddirname($url){$url=preg_replace('~^http://~si','',$url); $url=substr($url,0,strpos($url.'?','?')); if(strpos($url,'/')===false) return 'http://'.$url.'/'; return 'http://'.substr($url,0,strrpos('/'.$url,'/'));} function wsc($a){if(is_array($a)){foreach($a as $k=>$v) $a[$k]=wsc($v);}else{$a=str_replace('$','$$',HtmlSpecialChars($a,3));} return $a;} header("Content-Type: text/vnd.wap.wml; charset=utf-8"); header("Cache-Control: no-cache"); if(!isset($url))pr(); function pr($txt=''){die('<?xml version="1.0" encoding="utf-8"?><!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.3//EN" "http://www.wapforum.org/DTD/wml13.dtd"><wml><card title="&#x413;a&#x43b;&#x438;&#x43c;&#x44b;&#x439; proxy">'.$txt.'<p><input title="URL:" name="url" value="http://" format="*m"/><br/><a href="'.basename($_SERVER['PHP_SELF']).'?url=$(url:escape)">proxy</a></p></card></wml>'); } $f=@fopen($url,'rb'); if($f===false)pr('<onevent type="onenterforward"><refresh><setvar name="url" value="'.wsc($url).'"/></refresh></onevent><p align="center"><small><u>&#x424;a&#x439;&#x43b; &#x43d;e &#x43d;a&#x439;&#x434;e&#x43d;</u></small></p>'); $file=''; while(!feof($f))$file.=@fread($f,1024); fclose($f); if(strpos($file,'<wml>')===false && strpos(strtolower($file),'<html>')===false)die($file); $fnhttp=WSC(basename($_SERVER['PHP_SELF'])).'?url='; $fnnohttp=$fnhttp.ddirname($url).'/'; $fnhost=$fnhttp.preg_replace('~(^http://.*?)/.*~si','$1',$url).'/'; $fnempty=$fnhttp.preg_replace('~(.*?)\?.*~s','$1',$url); die(strtr($file,array('href="http://'=>'href="'.$fnhttp.'http://','href=""'=>'href="'.$fnempty.'"','href="?'=>'href="'.$fnempty.'?','href="/'=>'href="'.$fnhost,'href="'=>'href="'.$fnnohttp,'href="#'=>'href="#','src="http://'=>'src="http://','src="/'=>'src="'.substr($fnhost,strlen($fnhttp)),'src="'=>'src="'.substr($fnnohttp,strlen($fnhttp))))); ?>