drqj8605 2019-01-22 21:00
浏览 79

安全问题将php写入文件

I'm creating code that allows me to create a libary of templates from the backend of my CMS website. I create them in a textarea and then write them to a database.

I then get a text string from a database and then save it to a file people.php.

            $text='<?php echo\'<div class="tileContainer three_across_homePage">
              <div class="tileBox three_across_box_0_homePage">
                <div class="tileModule three_across_module_0_homePage">
                <a href="\'.$holder[0].\'"><img src="\'.$holder[1].\'" alt="\'.$holder[2].\'" />
                  <div class="centeredHomePage">
                    \'.$holder[2].\'
                    <p>&nbsp;</p>
                    </a> </div>
                </div>
              </div>\';';

            $file = 'people.php';
            $current = file_get_contents($file);
            $current = $text;
            file_put_contents($file, $current);

I then include this file in subsequent code which creates and uses the $holder array to fill in the place holders $holder[0], $holder[1] etc

The text string is written to the database from the admin area of a CMS.

The other obvious way to do this would be eval but that would be a big security risk.

So I'm wondering if the security risk is still too big and I should just write php files that are stored on the server directly. However the trouble with this approach is how to update multiple site that are using the templates.

thanks

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 使用C#,asp.net读取Excel文件并保存到Oracle数据库
    • ¥15 C# datagridview 单元格显示进度及值
    • ¥15 thinkphp6配合social login单点登录问题
    • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
    • ¥15 如何在scanpy上做差异基因和通路富集?
    • ¥20 关于#硬件工程#的问题,请各位专家解答!
    • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
    • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
    • ¥30 截图中的mathematics程序转换成matlab
    • ¥15 动力学代码报错,维度不匹配