Curl PHP
function search($url,$curlPost){$cookiejar = realpath ( 'cookie.txt' );
$ch = curl_init ();
curl_setopt ( $ch, CURLOPT_URL, $url);
curl_setopt ( $ch, CURLOPT_HEADER, 0 );
curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ( $ch, CURLOPT_POST, 1 );
curl_setopt ( $ch, CURLOPT_POSTFIELDS, $curlPost );
curl_setopt ( $ch, CURLOPT_COOKIEJAR, $cookiejar ); // 要回传cookie
$data=curl_exec ( $ch );
curl_close ( $ch );
return $data;
}
?>
我想用PHP实现外网机器通过我的电脑访问内网的资源,一张截图是我在内网登录内网的网站的数据交互截图,另一张是通过我的PHP文件用curl函数访问时的截图,它提示少了什么文件。请问有人知道怎么解决吗
回复讨论(解决方案)
你仅仅模拟一个页面是不可以的,你现在只是模拟的login!checkLogin.action,要在这个内容中将header.html等替换成你用curl获取的连接,然后用curl获取内容展现出来,也就是header.html要变成curl.php?page=header.html。
如果你不替换的话,是在你模拟curl的php的同目录下找header.html,我估计肯定不存在。
你好,那你能告诉我怎么实现吗
仅仅用你那个 search 函数是完成不了了
从截图上看,你那是个框架页面,你只向外网返回了框架布局页数据,并没有向外网返回每一个框架页的数据
你这个应用应写成一个代理(proxy)程序才行
我向第一个界面发送了数据,内网服务器不是会给我返回下面的4个界面吗,而我又是直接输出的,怎么还不能打印出来呢
不错,内网服务器是会给你返回下面的4个界面
但这些页面不都是内网的吗?从外网怎么能直接访问到?
要是能从外网直接访问,那你还要写函数干什么?
我的意思是我本机在内网用curl函数取得这四个界面,然后将这四个界面的数据传给外网的访问者。为什么这4个界面不能打印出来呢,而且四个界面都取到了并且都传给了他怎么还说缺少界面呢?
比如布局页中有
你说那个 top.htm 是指向哪里的?
如果是指向内网的,那么外网可以访问到吗?
iframe的机制是
1、浏览器获取携带iframe元素的页面
2、浏览器渲染页面
3、浏览器检测iframe元素
4、浏览器重新请求iframe包含的页面内容
5、渲染iframe包含的页面
对应你这里就是
1、浏览器发起请求login!checkLogin.action
2、渲染页面
3、检测到iframe元素(例如包含header.html的iframe)
4、浏览器重新请求header.html
5、渲染header.html页面
现在你的请情况是这样
1、浏览器对你的主机请求,你的主机请求内网login!checkLogin.action
2、浏览器渲染页面
3、检测到iframe元素
4、 浏览器对你请求header.html,你那里来的header.html?
那么处理方案就是
1、浏览器对你的主机请求,你的主机请求内网login!checkLogin.action,同时修改iframe中src由原来的header.html 改为 代理.php?page=headerl.html
2、浏览渲染页面
3、检测到iframe
4、对你的主机发起请求 代理.php?page=header.html, 代理.php去内网获取html内容返回
5、渲染header.html页面的实际内容

ThebestapproachforsendingemailsinPHPisusingthePHPMailerlibraryduetoitsreliability,featurerichness,andeaseofuse.PHPMailersupportsSMTP,providesdetailederrorhandling,allowssendingHTMLandplaintextemails,supportsattachments,andenhancessecurity.Foroptimalu

The reason for using Dependency Injection (DI) is that it promotes loose coupling, testability, and maintainability of the code. 1) Use constructor to inject dependencies, 2) Avoid using service locators, 3) Use dependency injection containers to manage dependencies, 4) Improve testability through injecting dependencies, 5) Avoid over-injection dependencies, 6) Consider the impact of DI on performance.

PHPperformancetuningiscrucialbecauseitenhancesspeedandefficiency,whicharevitalforwebapplications.1)CachingwithAPCureducesdatabaseloadandimprovesresponsetimes.2)Optimizingdatabasequeriesbyselectingnecessarycolumnsandusingindexingspeedsupdataretrieval.

ThebestpracticesforsendingemailssecurelyinPHPinclude:1)UsingsecureconfigurationswithSMTPandSTARTTLSencryption,2)Validatingandsanitizinginputstopreventinjectionattacks,3)EncryptingsensitivedatawithinemailsusingOpenSSL,4)Properlyhandlingemailheaderstoa

TooptimizePHPapplicationsforperformance,usecaching,databaseoptimization,opcodecaching,andserverconfiguration.1)ImplementcachingwithAPCutoreducedatafetchtimes.2)Optimizedatabasesbyindexing,balancingreadandwriteoperations.3)EnableOPcachetoavoidrecompil

DependencyinjectioninPHPisadesignpatternthatenhancesflexibility,testability,andmaintainabilitybyprovidingexternaldependenciestoclasses.Itallowsforloosecoupling,easiertestingthroughmocking,andmodulardesign,butrequirescarefulstructuringtoavoidover-inje

PHP performance optimization can be achieved through the following steps: 1) use require_once or include_once on the top of the script to reduce the number of file loads; 2) use preprocessing statements and batch processing to reduce the number of database queries; 3) configure OPcache for opcode cache; 4) enable and configure PHP-FPM optimization process management; 5) use CDN to distribute static resources; 6) use Xdebug or Blackfire for code performance analysis; 7) select efficient data structures such as arrays; 8) write modular code for optimization execution.

OpcodecachingsignificantlyimprovesPHPperformancebycachingcompiledcode,reducingserverloadandresponsetimes.1)ItstorescompiledPHPcodeinmemory,bypassingparsingandcompiling.2)UseOPcachebysettingparametersinphp.ini,likememoryconsumptionandscriptlimits.3)Ad


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Dreamweaver Mac version
Visual web development tools

Dreamweaver CS6
Visual web development tools

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.
