HTTP Proxy supporting breakpoint through PHP

xiaoxiao2021-03-06  21

HTTP Proxy supporting breakpoint through PHP

The HTTP protocol is only supported by the HTTP protocol. It does not support the HEADER redirection processing. Interested you can take a look ^ _ ^ * // * * // *************************************** ********* / set_time_limit (180); Define ('pp_error_code', 1); define ('pp_error_me ", 2); define (' pp_error_all ', 3); define (' pp_return_string", 1 ); define ( 'PP_RETURN_ARRAY', 2); define ( 'PP_RETURN_ALL', 3); class CPhpProxy {var $ _strUrl; var $ _arrArgv; var $ _strRef; var $ _arrUrl; var $ _resSocket; var $ _intError; var $ _strError Var $ _ARRDEFAULTARRAYURL; VAR $ _ARRDEFAULTPORT; FUNCTION CPHPPROXY ($ StrURL = NULL, $ Arrargv = array ()) {$ this-> init (); is_null ($ Strurl)? ': $ This-> seturl ($ StrURL Is_null ($ Arrargv ['Refer'])? '': $ This-> setref ($ Arrargv ['Refer']); $ this-> proxy ($ Strurl, $ Arr Argv);} Function SETERROR ($ INTERROR, $ MIXARGV = NULL) {$ this -> _ interror = $ interror; if ($ INTERROR == 1001) {$ this -> _ strerror = "call $ mixARGV method When the parameter passes an error, Enumeration value does not exist;} elseif ($ INTERROR == 1) {$ this -> _ strrror = "URL error, URL format is incorrect ./n".$$$$$} elseif ($ INTERROR == 2) {$ This -> _ strerror = "URL error, currently has not yet supported this protocol ./n"} elseif ($ INTERROR == 3) {$ this -> _ strerror = "Unable to open". $ this -> _ arrurl [' Host '].': '. $ this -> _ arrurl ['

Port ']. "/ n". $ Mixargv [0].': '. $ mixargv [1];} Return False;} Function GetError ($ enumreturntype = pp_error_code) {if ($ enumretURNTYPE == PP_ERROR_ALL) {Return Array (str_pad ($ this -> _ intError, 5, '0', STR_PAD_LEFT), $ this -> _ strError);} elseif ($ enumReturnType == PP_ERROR_MESSAGE) {Return $ this -> _ strError;} elseif ($ enumReturnType == PP_ERROR_CODE ) {RETURN $ THIS -> _ interror;} else {return false;}} function init ()}} function init () {$ this -> _ strurl = null; $ this -> _ arrargv = array (); $ this -> _ strref = null; $ this - >_ arrurl = array (); $ this -> _ relacket = null; $ this -> _ interror = 0; $ this -> _ strerror = 'there is no error'; // arrurl default $ this -> _ arrdefaultArrayURL = array ( 'protocol' => 'http', 'file' => 'Index.htm'); // Default port $ this -> _ arrdefaultport = array ('http' => '80'); return true;} Function seturl $ StrURL) { $ Strurl = Trim ($ StrURL); // Regular $ reg = "/ ^ (([/ w] ):)? ([^: | / / | @] *:)? ([^: | // | @] * @)? ([/ w | / - | /.] (// [^ /? | #] *)? (/? [^ #] *)? #. *)? $ / IS "; if (! preg_match ($ R, $ Strurl, $ arrurl) {Return $ this-> setError (1, $ StrURL);} else {// dismantling matching number list List $ TMP, $ TMP, $ Arr ['Protocol'], $ Arr ['User'], $ Arr ['Pass'], $ Arr [' Host '], $ Arr [' Port '], $ Arr [' Path '], $ arr [' query '], $ arr [' Anchor ']) =

$ arrurl; // Default protocol if (! $ arr [protocol ']) {$ arrrl [1] = $ this-> _ARRDEFAULTARRAYURL [' protocol '].': // ';} // set FileName $ ARR [ 'file'] = BaseName ($ Arr ['Path']); // Default Foreach ($ this -> _ arrdefaultArrayURL AS $ Key => $ VAL) {IF ($ ARR [$ Key] == ') { $ arr [$ key] = $ val;}} // default port if (is_null ($ this -> _ arrdefaultport [$ arr ['protocol'])) {Return $ this-> setError (2, $ arr [" Protocol ']);} elseif ($ arr [' port ']) {$ arr [' port '] = $ this -> _ arrdefaultport [$ arr [' protocol '];} // set URI $ Arr [' URI '] = ($ ARR [' Path ']? $ arr [' Path ']:' / '). ($ ARR [' Query ']?'? $ arr ['query']: ') $ ARR ['Anchor']? '#'. $ arr ['Anchor']: '); // Set URL UNSET ($ arrurl [0]); unset ($ arrurl [2]); $ this -> _ Strurl = Implode ('', $ arrurl); // set arrurl $ This -> _ arrUrl = $ arr; Return true;}} function getUrl ($ enumReturnType = PP_RETURN_ARRAY) {if ($ enumReturnType == PP_RETURN_STRING) {Return $ this -> _ strUrl;} elseif ($ enumReturnType == PP_RETURN_ARRAY) {Return $ this -> _ arrurl;} if ($ enumreturntype == pp_return_all) {Return Array ($ this -> _ strurl, $ this -> _ arrurl);} else {returnome

SetError (1001);}} Function setrefer ($ this -> _ strref = trim ($ strower); return true;} function getrefer () {RETURN $ THIS -> _ strref;} function getProxyurl ()} Function getProxyurl ()} _Server; list ($ strprocotol) = exPlode ('/', strtolower (TRIM ($ _ server ['server_protocol')))))))))))))); $ STR = STRPROCOTOL. ': //' $_server ['http_host']. $ _Server ['php_self']. '? U ='. Urlencode ($ this-> geturl). ($ This-> getrefer ()? ('& R ='. Urlencode ($ this-> getrefer ()) : ''); Return $ Str;} Function OpenSocket ()} Function OpenSocket () {$ Arr = $ this-> getURL (); $ this -> _RRSOCKET = @fsockopen ($ Arr ['Host'], $ Arr ['Port' ], $ INTERROR, $ STRERROR, 30); if (! $ this -> _RESSOCKET) {$ this -> _RESSSOCKET = NULL; RETURN $ this-> setError (3, Array ($ INTERROR, $ strrror);} Else {Return True;}} function getRequest () {RETURN $ this -> {'get'.Ucfirst ($ THIS -> _ arrurl ['protocol']). 'Request'} ();} Function Sendrequest () {Return Fwrite ($ this -> _RESSOCKET, $ this-> getRequest ());} function flushresponse ()} function flushresponse () {RETURN $ THIS -> {'flush'.ucfirst ($ this -> _ arrurl [' protocol ']).' response '} ();} function gethttpRequest () {$ arr = $ this-> getURL (); $ arRRequest = getAllHeaders ); $ ArRRequest ['Host'] = $ Arr ['Host']; $ strrequest = "get". $ Arr ['uri']. "Http / 1.1 / r / n";

Foreach ($ ARREQUEST AS $ Key => $ VAL) {$ strrequest. = "$ key: $ val / r / n";} $ strrequest. = "/ r / n"; return $ strrequest;} function flushhttpResponse () {$ Bolheader = true; while (! Feof ($ this -> _ limited)) {$ str = fgets ($ this -> _RESSOCKET, 4096); if ($ bolheader) {@Header ($ Str);} else {echo ($ STR);} IF ($ bolheader && $ str == "/ r / n") {$ bolheader = false; @Header ("content-type: Application / Gzip"); @Header ('Content-Disposition: Attachment; FileName = "'. $ this -> _ arrurl [' file '].'");}} return true;} function close () {fclose ($ this -> _ relassocket); $ this -> _ relassocket = null Return True;} Function Proxy ($ strurl = null, $ arrargv = array ()) {if (! Is_null ($ this-> geturl (pp_return_string)) && $ this-> OpenSocket () && $ this-> sendrequest ) && $ this-> Flushresp Onse ()) {echo (123); $ this-> close ();} else {return false;}}} f ($ strGetArrayName = '_get';} elseif (sizeof ($ http_get_vars) )) {$ StrGetArrayName = 'http_get_vars';} else {Die (' "HTML>" h> "Meta http-equiv = "content-type" content = "text / html"> phpproxy </ title> <</p> <p>Style Type = "Text / CSS"> <! - body, td {font-family: verdana; font-size: 12px;} th, input {font-family: verdana;} -> </ stop> </ HEAD> <body> <form name = "form1" method = "get" action = "'. $ _ server [' php_self '].'"> <table width = "500" border = "1" align = "center" Cellpadding = "5" Cellspacing = "1"> <tr> <tr> "2"> phpproxy </ th> </ tr> <tr> <td width = "39" nowrap> URL: </ td> < Td width = "432"> <input name = "u" type = "text" id = "u" size = "60"> </ td> </ tr> <tr> <TD NOWRAP> Referer: </ td > <TD> <input name = "r" type = "text" id = "r" size = "60"> <td> </ tr> <tr> <td colspan = "2" align = "center" > <input name = "ACT" value = "make" type = "hidden"> <input type = "submit" value = "get proxy url"> <input type = "reset" value = "reset"> </ td > </ Tr> </ table> </ form> </ body> </ html> ');} $ StrURL = TRIM ($ StrGetArrayName} [' u ']); if ($ StrURL ==' " ) {Die ('Please enter the URL address.');} // Get Referer $ strreftmp = Trim ($ {$ strGetArrayName} ['r']); // Initialization Proxy class $ objProxy = new cphpproxy (); // Set URL and REFER $ OBJPROY-> SetURL ($ StrURL);</p> <p>$ objProxy-> setRefer ($ strref); // Error output if ($ objProxy-> getError ()) {DIE ($ objProxy-> getError (pp_error_message));} // echo url for Downloadif ($ sTARRAYNAME} ['ACT'] == 'Make') {Die ("<center> <h4> <a href=" getproxyurl (). "> Click here to download file </a> </ h2> </ center> ");} // Take the file $ objProxy-> proxy (); // Error handling IF ($ objProxy-> getError ()) {die ($ objProxy-> getError (PP_ERROR_MESSAGE)) }?> <? php / *************************************** * * * // * php http proxy * // * Version: 0.0.2 * // * Last Modify: 2005.1.12 * // * Author: Q3boy <q3boy@sina.com> * // * * // *** ************************************ / SET_TIME_LIMIT (180); Define ('pp_error_code', 1) Define ('PP_ERROR_MESSAGE', 2); Define ('PP_RROR_ALL', 3); Define ('PP_RETURN_STRING', 1); Define ('PP_RETURN_ARRAY', 2); Define ('PP_RETURN_ALL', 3); Class Cphpproxy {VAR $ _STRURL; var $ _ARRARGV; var $ _STRREF; var $ _arrurl; var $ _resSocket; var $ _intError; var $ _strError; var $ _arrDefaultArrayUrl; var $ _arrDefaultPort; function CPhpProxy ($ strUrl = null, $ arrArgv = array ()) {$ this-> init (); is_null ($ strUrl) ''? : $ this-> seturl; is_null ($ Arrargv ['Refer'])? '': $ this-> setRef ($ Arrargv ['Refer']); $ this-> proxy ($ strurl, $ Strurl, $ Strull Arrargv);} Function SETERROR ($ INTERROR, $ Mixargv = null) {$ this -> _ interror = $ interror; if ($ interror == 1001) {$ this -> _ strrror =</p> <p>"When calling the $ mixargv method, the parameter passes an error, the enumeration value does not exist";} elseif ($ INTERROR == 1) {$ this -> _ strerror = "URL error, the URL format is incorrect ./n" @mixargvs;} Elseif ($ INTERROR == 2) {$ this -> _ strerror = "URL error, currently not supported this protocol ./N" Elseif ($ INTERROR == 3) {$ this -> _ strerror = "Unable Open ". $ This -> _ arrurl ['host']. ':'. $ This -> _ arrurl ['port']." / N ". $ Mixargv [0]. ':'. $ Mixargv [1]; } Return false;} function getError ($ enumReturnType = PP_ERROR_CODE) {if ($ enumReturnType == PP_ERROR_ALL) {Return array (str_pad ($ this -> _ intError, 5, '0', STR_PAD_LEFT), $ this -> _ strError); } elseif ($ enumReturnType == PP_ERROR_MESSAGE) {Return $ this -> _ strError;} elseif ($ enumReturnType == PP_ERROR_CODE) {Return $ this -> _ intError;} else {Return false;}} function init () {$ this- > _Strurl = NULL; $ this -> _ arrargv = array (); $ this -> _ strref = null; $ this -> _ arrurl = array ( $ This -> _RESSOCKET = NULL; $ this -> _ interror = 0; $ this -> _ strongror = 'there is no error'; // arrurl default $ this -> _ arrdefaultArrayURL = array ('protocol' => ' http ',' file '=>' Index.htm '); // Default Port $ this -> _ arrdefaultport = array (' http '=>' 80 '); return true;} Function seturl ($ Strurl) {$ Strurl = TRIM ($ Strurl); // Regular $ reg = "/ ^ (([/ w] ):)? ([^: | / / | @</p> <p>] *:)? ([^: | / / | @] * @)? ([/ w | / - | /.] (】) (:/ D )? (// [^ /? | #] *) (/? [^ #] *)? (#. *)? $ / IS "; if (! preg_match ($ R, $ Strurl, $ arrurl) {Return $ this-> setError (1, $ Strurl) ELSE {// Disassemble Matches List ($ TMP, $ TMP, $ ARR ['Protocol'], $ Arr ['User'], $ Arr ['Pass'], $ Arr ['Host'], $ Arr ['Port'], $ Arr ['Query'], $ Arr [ANChor ']) = $ arrurl; // Default Protocol IF (! $ arr [protocol'] ) {$ Arrurl [1] = $ this-> _arrdefaultArrayURL ['protocol']. ': //';} // set filename $ arr ['file'] = basename ($ ArR ['Path']); / / Default Foreach ($ this -> _ arrdefaultarrayurl as $ key => $ val) {if ($ ARR [$ Key] == ') {$ Arr [$ Key] = $ VAL;}} // Default Port IF (IS_NULL ($ this -> _ arrdefaultport [$ arr ['protocol'])) {Return $ this-> setError (2, $ arr ['protocol');} elseif (! $ arr ['port']) {$ Arr ['Port'] = $ this -> _ arrdefaul TPORT [$ ARR ['protocol'];} // set URI $ ARR ['URI'] = ($ Arr ['Path']? $ Arr ['Path']: '/'). ($ Arr [ 'query']? '?'. $ arr ['query']: '). ($ arr [' Anchor ']?' # '. $ arr [' Anchor ']:'); // Set URL Unset ($ arrurl [2]); $ this -> _ strurl = Implode ('', $ arrurl); // set arrurl $ this -> _ arrurl = $ arr; return true;</p> <p>}} Function getUrl ($ enumReturnType = PP_RETURN_ARRAY) {if ($ enumReturnType == PP_RETURN_STRING) {Return $ this -> _ strUrl;} elseif ($ enumReturnType == PP_RETURN_ARRAY) {Return $ this -> _ arrUrl;} if ($ enumReturnType = = PP_RETURN_ALL) {Return Array ($ this -> _ Strull, $ this -> _ arrurl);} else {return $ this-> setError (1001);}} Function setrefer ($ strref) {$ this -> _ strref = trim $ strRef); Return true;} function getRefer () {Return $ this -> _ strRef;} function getProxyUrl () {global $ _SERVER; list ($ strProcotol) = explode ( '/', strtolower (trim ($ _ SERVER [ ' Server_protocol '])))))))))))))); $ STR = $ STRPROCOTOL.': // '$_server [' http_host ']. $ _ Server [' php_self '].'? U = '. Urlencode ($ this-> getURL (pp_return_string )). ($ This-> getrefer ()? ('& R ='. Urlencode ($ this-> getrefer ()): ''); returnome} function opensocket ()} $ arr = $ this-> geturl (); $ this -> _ relacket = @fsockopen ($ Arr ['Host'], $ Arr ['Port'], $ INTERROR, $ STRERROR, 30); IF (! $ THIS -> _ relacket) {$ this -> _RESSOCKET = NULL; RETURN $ this-> setError (3, Array ($ INTERROR, $ STRERROR);}} function getRequest ()}} function getRequest () {RETURN $ this-> {'get'.Ucfirst ($ this -> _ arrurl [' protocol ']).' Request '} ();} Function Sendrequest () {Return Fwrite ($ this -> _RESSOCKET, $ this-> getRequest ());</p> <p>} Function flushresponse () {RETURN $ THIS -> {'Flush'.Ucfirst ($ this -> _ arrurl [' protocol ']).' Response '} ();} function gethttpRequest () {$ arr = $ tris-> GETURL (); $ arRrequest = getAllHeaders (); $ arRRequest ['Host'] = $ arr ['host']; $ strrequest = "get". $ arr ['uri']. "http / 1.1 / r / n "" For "($ strrequest. =" $ Key: $ val / r / n ";} $ strrequest. =" / R / n "; return $ strrequest;} Function FlushhttpResponse () {$ Bolheader = true; while ($ this -> _ limited)) {$ str = fgets ($ this -> _ relativet, 4096); if ($ bolheader) {@Header ($ STR);} Else {Echo ($ STR);} IF ($ BOLHEADER && $ STR == "/ R / N") {$ bolheader = false; @Header ("Content-Type: Application / Gzip"); @Header ('Content- Disposition: attachment; filename = "'. $ This -> _ arrurl [' file '].'"); }}} Return True;} Function Close () {Fclose ($ this -> _RRRUE; RETURN TRUE;} Function Proxy ($ strurl = null, $ arrargv = arral = null, $ arrargv = array; ! is_null ($ this-> geturl (pp_return_string) && $ this-> OpenSocket () && $ this-> sendrequest () && $ this-> flushresponse ()) {echo (123); $ this-> close () Else {Return False;</p> <p>!}}} If (sizeof ($ _ GET)) {$ strGetArrayName = '_GET';} elseif (sizeof ($ HTTP_GET_VARS)) {$ strGetArrayName = 'HTTP_GET_VARS';} else {die ( '<DOCTYPE HTML PUBLIC "- / / W3c // DTD HTML 4.01 Transitional // En "" http://www.w3.org/tr/html4/loose.dtd "> <html> <head> <meta http-equiv =" content-type "Content = "Text / HTML"> <title> phpproxy </ title> <style type = "text / css"> <! - body, td {font-family: verdana; font-size: 12px;} th, input { FONT-FAMILY: VERDANA;} -> </ style> </ head> <body> <form name = "form1" method = "get" action = "'. $ _ server [' php_self '].'> < Table width = "500" border = "1" align = "center" cellpadding = "5" cellspacing = "1"> <tr> <th series = "2"> phpproxy </ th> </ tr> <TR> <td width = "39" NOWRAP> URL: </ TD> <TD width = "432"> <input name = "u" type = "text" ID = "u" size = "60"> </ td> </ tr> <tr> <TD NOWRAP> Referer: </ TD> <TD> <input name = "r" type = "text" id = "r" size = "60"> </ td> </ tr > <Tr> <td colspan = "2" ali GN = "center"> <input name = "act" value = "make" type = "hidden"> <input type = "submit" value = "get proxy url"></p></div><div class="text-center mt-3 text-grey"> 转载请注明原文地址:https://www.9cbs.com/read-43191.html</div><div class="plugin d-flex justify-content-center mt-3"></div><hr><div class="row"><div class="col-lg-12 text-muted mt-2"><i class="icon-tags mr-2"></i><span class="badge border border-secondary mr-2"><h2 class="h6 mb-0 small"><a class="text-secondary" href="tag-2.html">9cbs</a></h2></span></div></div></div></div><div class="card card-postlist border-white shadow"><div class="card-body"><div class="card-title"><div class="d-flex justify-content-between"><div><b>New Post</b>(<span class="posts">0</span>) </div><div></div></div></div><ul class="postlist list-unstyled"> </ul></div></div><div class="d-none threadlist"><input type="checkbox" name="modtid" value="43191" checked /></div></div></div></div></div><footer class="text-muted small bg-dark py-4 mt-3" id="footer"><div class="container"><div class="row"><div class="col">CopyRight © 2020 All Rights Reserved </div><div class="col text-right">Processed: <b>0.029</b>, SQL: <b>9</b></div></div></div></footer><script src="./lang/en-us/lang.js?2.2.0"></script><script src="view/js/jquery.min.js?2.2.0"></script><script src="view/js/popper.min.js?2.2.0"></script><script src="view/js/bootstrap.min.js?2.2.0"></script><script src="view/js/xiuno.js?2.2.0"></script><script src="view/js/bootstrap-plugin.js?2.2.0"></script><script src="view/js/async.min.js?2.2.0"></script><script src="view/js/form.js?2.2.0"></script><script> var debug = DEBUG = 0; var url_rewrite_on = 1; var url_path = './'; var forumarr = {"1":"Tech"}; var fid = 1; var uid = 0; var gid = 0; xn.options.water_image_url = 'view/img/water-small.png'; </script><script src="view/js/wellcms.js?2.2.0"></script><a class="scroll-to-top rounded" href="javascript:void(0);"><i class="icon-angle-up"></i></a><a class="scroll-to-bottom rounded" href="javascript:void(0);" style="display: inline;"><i class="icon-angle-down"></i></a></body></html><script> var forum_url = 'list-1.html'; var safe_token = 'mZ_2BvgBwDxH_2BR0geF3nusjSfmvNdNX3c3Rq7EbW2zdqsOshahbGb_2F_2Fe073dsiq_2BHgbwshtGjAov6WRqrR24M3FQ_3D_3D'; var body = $('body'); body.on('submit', '#form', function() { var jthis = $(this); var jsubmit = jthis.find('#submit'); jthis.reset(); jsubmit.button('loading'); var postdata = jthis.serializeObject(); $.xpost(jthis.attr('action'), postdata, function(code, message) { if(code == 0) { location.reload(); } else { $.alert(message); jsubmit.button('reset'); } }); return false; }); function resize_image() { var jmessagelist = $('div.message'); var first_width = jmessagelist.width(); jmessagelist.each(function() { var jdiv = $(this); var maxwidth = jdiv.attr('isfirst') ? first_width : jdiv.width(); var jmessage_width = Math.min(jdiv.width(), maxwidth); jdiv.find('img, embed, iframe, video').each(function() { var jimg = $(this); var img_width = this.org_width; var img_height = this.org_height; if(!img_width) { var img_width = jimg.attr('width'); var img_height = jimg.attr('height'); this.org_width = img_width; this.org_height = img_height; } if(img_width > jmessage_width) { if(this.tagName == 'IMG') { jimg.width(jmessage_width); jimg.css('height', 'auto'); jimg.css('cursor', 'pointer'); jimg.on('click', function() { }); } else { jimg.width(jmessage_width); var height = (img_height / img_width) * jimg.width(); jimg.height(height); } } }); }); } function resize_table() { $('div.message').each(function() { var jdiv = $(this); jdiv.find('table').addClass('table').wrap('<div class="table-responsive"></div>'); }); } $(function() { resize_image(); resize_table(); $(window).on('resize', resize_image); }); var jmessage = $('#message'); jmessage.on('focus', function() {if(jmessage.t) { clearTimeout(jmessage.t); jmessage.t = null; } jmessage.css('height', '6rem'); }); jmessage.on('blur', function() {jmessage.t = setTimeout(function() { jmessage.css('height', '2.5rem');}, 1000); }); $('#nav li[data-active="fid-1"]').addClass('active'); </script>