douting0585 2015-09-06 19:08
浏览 19

从.GZ存档执行PHP文件?

With PHP, Is it possible to extract to memory another PHP file from a .GZ, execute it and delete it from memory?

Suppose to have into the public html directory: index.php and site.gz

Inside it, there are:

page.php
article.php
news.php

When I give index.php?p=page1

it extract page.php from the .gz file and put it into the memory (not on the Disk) , execute it, so that the user can have the generated content displayed, and then "destroyed" once have finished to be executed?

  • 写回答

1条回答 默认 最新

  • douluhaikao93943 2015-09-06 19:16
    关注

    If it's really a single gzip -c compressed file, then you can use stream wrappers to unpack and load a PHP script right away:

     include "compress.zlib://example.php.gz";
    

    Otherwise Phars are a more convenient alternative for distribution than e.g. plain zip/tar archives.

    Take note that you shouldn't use unvetted user input $_GET["p"] for including local files. (If that's what you're trying to do.)

    评论

报告相同问题?

悬赏问题

  • ¥15 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单
  • ¥15 神经网络怎么把隐含层变量融合到损失函数中?
  • ¥30 自适应 LMS 算法实现 FIR 最佳维纳滤波器matlab方案
  • ¥15 lingo18勾选global solver求解使用的算法
  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
  • ¥20 测距传感器数据手册i2c
  • ¥15 RPA正常跑,cmd输入cookies跑不出来
  • ¥15 求帮我调试一下freefem代码
  • ¥15 matlab代码解决,怎么运行
  • ¥15 R语言Rstudio突然无法启动