普通网友 2009-03-03 06:15
浏览 29
已采纳

将配置变量存储在站点根目录下的PHP站点上的XML文件中是否存在风险太大?

I've noticed that Magento stores MySQL connection details in an XML file which isn't secured above the docroot. This seems.... well dangerous.

XML seems like a handy way to store config data, except for one thing, typing in http://www.domain.com.au/library/config.xml will show the world your private details!

I went ahead and used an XMl file and added this to my .htaccess file.

<Files ~ "\.xml$"> // regex files that end with xml extension
Order allow,deny 
Deny from all // don't show them
</Files>

Now I was happy with this, now I'm not too sure. What if the .htaccess file is accidentally deleted/corrupted (does that happen besides human error) and what if one day I want to place the app on a non apache server... does every server have the equivalent to block XML files, and if they do, can they be altered on a folder level like the .htaccess can (and not just a httpd.conf file).

My question is... does the convenience of XML (easy to update, designers who need to tinker won't feel so intimidated) outweigh the potential problems (exposing private data)?

  • 写回答

3条回答 默认 最新

  • dongpo2002 2009-03-03 06:51
    关注

    I'd personally only store config file information in a format thats not in a directly accessible format or location. So I'd either use the XML format above the docroot or use the PHP $config['varname'] = 'value' format. The later method would just render a blank white page if called directly (so long as it's all PHP and contains no HTML and doesn't echo out).

    Gallery, vBulletin, and Joomla all use the second method I mentioned. I know I've mentioned those projects before in other PHP related questions, but it seems to be a method that's widely used and accepted between projects.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?
  • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?
  • ¥15 乘性高斯噪声在深度学习网络中的应用
  • ¥15 运筹学排序问题中的在线排序
  • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛