ZBLOGPHP read the code templates and plug-in files outside the network

ZBLOGPHP in the production version of templates and plug-ins, sometimes in order to achieve some special features, read files need to call outside the network, the official does not recommend the direct use CURL code to write, there may be some users are hosting space CURL does not support expansion, so after pointing officials, and by looking at ZBLOGPHP program source code in the method, a method using blue leaves below, may camouflage the special requirements of origin, UA and other external networks to call reads the file; the following code applies only to ZBLOGPHP version program, there is a need to replicate it.

  1. {php}
  2. global $zbp;
  3. url $  = 'To access the web site' ; 
  4. REFER $  = 'camouflage origin URL' ; 
  5. $ajax = Network::Create();
  6. IF (! $ Ajax ) { the throw new new Exception ( 'host is not open to access external networks function' );  
  7. $ajax->open('GET', $url);
  8. $ajax->enableGzip();
  9. $ajax->setTimeOuts(120, 120, 0, 0);
  10. $ajax->setRequestHeader('Referer', $refer);
  11. $ajax->setRequestHeader('User-Agent', 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.154 Safari/537.36 LBBROWSER');
  12. $ajax->send();
  13. echo $ajax->responseText;
  14. {/php}

Guess you like

Origin www.cnblogs.com/xuwen777/p/11735998.html