douliaotong4944 2019-03-04 22:47
浏览 141

PHP:是否可以保存网站,模拟手动保存?

I understand how to use fopen, file_get_contents, etc - but I'm curious to know if there is a way to generate a "manual save" on a webpage? As if I were to physically right-click > "Save As" > to Desktop?

I'm asking this because I'm trying to learn more about securing data. I didn't think it was possible to hide source code, but I recently found out that can be done by putting the code in JavaScript. So the "hidden code" won't appear in View Source, but it will still appear in Firefox Web Developer Tools and such.

So let's say I'm using JavaScript to secure my source code (as best as can be, that is). If someone were to Ctrl+U (View Source) my webpage (or fopen/file_get_contents), they would see:

<div class="StartofSecretSourceCode"></div>

Instead of:

<div class="StartofSecretSourceCode">
    <div class="Something">Some stuff and things</div>
</div>

In order for the user to see the full source code in this section, they would have to inspect the code in Firefox/Firebug/etc or manually save the webpage.

So I'm wondering if it's possible for someone to automate "manually saving" the webpage using PHP (or something else). And if so, I'm curious to know how you would do that in PHP. I hope that my question makes sense >.<

  • 写回答

1条回答 默认 最新

  • dongzhuo1733 2019-03-04 22:51
    关注

    You can use guzzle library or curl to send request and save response (in the same way as browser - literally you can simulate browser) - so you can sent GET request and download page (and its assets like js files) and save it to disc from php side - it is no problem.

    However if you want to protect your code dont send it to user but EXECUTE it on server side and return to user only RESULTS (in html file). This is standard and good way of code protection

    评论

报告相同问题?

悬赏问题

  • ¥15 matlab中使用gurobi时报错
  • ¥15 WPF 大屏看板表格背景图片设置
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂