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页面的实际内容

PHP and Python each have their own advantages, and the choice should be based on project requirements. 1.PHP is suitable for web development, with simple syntax and high execution efficiency. 2. Python is suitable for data science and machine learning, with concise syntax and rich libraries.

PHP is not dying, but constantly adapting and evolving. 1) PHP has undergone multiple version iterations since 1994 to adapt to new technology trends. 2) It is currently widely used in e-commerce, content management systems and other fields. 3) PHP8 introduces JIT compiler and other functions to improve performance and modernization. 4) Use OPcache and follow PSR-12 standards to optimize performance and code quality.

The future of PHP will be achieved by adapting to new technology trends and introducing innovative features: 1) Adapting to cloud computing, containerization and microservice architectures, supporting Docker and Kubernetes; 2) introducing JIT compilers and enumeration types to improve performance and data processing efficiency; 3) Continuously optimize performance and promote best practices.

In PHP, trait is suitable for situations where method reuse is required but not suitable for inheritance. 1) Trait allows multiplexing methods in classes to avoid multiple inheritance complexity. 2) When using trait, you need to pay attention to method conflicts, which can be resolved through the alternative and as keywords. 3) Overuse of trait should be avoided and its single responsibility should be maintained to optimize performance and improve code maintainability.

Dependency Injection Container (DIC) is a tool that manages and provides object dependencies for use in PHP projects. The main benefits of DIC include: 1. Decoupling, making components independent, and the code is easy to maintain and test; 2. Flexibility, easy to replace or modify dependencies; 3. Testability, convenient for injecting mock objects for unit testing.

SplFixedArray is a fixed-size array in PHP, suitable for scenarios where high performance and low memory usage are required. 1) It needs to specify the size when creating to avoid the overhead caused by dynamic adjustment. 2) Based on C language array, directly operates memory and fast access speed. 3) Suitable for large-scale data processing and memory-sensitive environments, but it needs to be used with caution because its size is fixed.

PHP handles file uploads through the $\_FILES variable. The methods to ensure security include: 1. Check upload errors, 2. Verify file type and size, 3. Prevent file overwriting, 4. Move files to a permanent storage location.

In JavaScript, you can use NullCoalescingOperator(??) and NullCoalescingAssignmentOperator(??=). 1.??Returns the first non-null or non-undefined operand. 2.??= Assign the variable to the value of the right operand, but only if the variable is null or undefined. These operators simplify code logic, improve readability and performance.


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

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

SublimeText3 English version
Recommended: Win version, supports code prompts!

Zend Studio 13.0.1
Powerful PHP integrated development environment

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

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