子文件夹中的自定义 php.ini 文件导致 $_SESSIONS 变量出现问题 [英] custom php.ini file in subfolder causing issues with $_SESSIONS variables

查看:40
本文介绍了子文件夹中的自定义 php.ini 文件导致 $_SESSIONS 变量出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含两个文件的子文件夹.第一个是email.php,有一个用户可以给我发送电子邮件的表单.它还有一个类似验证码的脚本来防止垃圾邮件,并使用 $_SESSION[foo] 变量.第二个是upload.php,它允许注册用户上传文件.两个文件都运行良好.现在我需要为upload.php 增加upload_max_filesize 从基础2MB 开始.我的主机不提供对主 php.ini 的访问,但建议我在此子文件夹中创建自定义 php.ini 文件.所以我创建了:

I have a sub-folder with two files. The first is email.php, with a form that user can send me an email. It also has a captcha-like script to prevent spam, and uses $_SESSION[foo] variables. The second is upload.php, which allows registered users to upload files. Both files worked fine. Now I need to increase the upload_max_filesize from the base 2MB for upload.php. My host does not provide access to main php.ini, but recommend that I create a custom php.ini file in this subfolder. So I created:

php.ini

upload_max_filesize = 10M ;
post_max_size = 10M ;

我现在收到错误 Warning: include() [function.include]: Filename cannot be emptyWarning: include() [function.include]: Failed opening '' for当我在 email.php 上提交表单/验证码时包含 (include_path='.:/usr/lib/php:/usr/local/lib/php').

I now get the errors Warning: include() [function.include]: Filename cannot be empty and Warning: include() [function.include]: Failed opening '' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') when I submit the form/captcha on email.php.

$_SESSION[foo]=$_GET[bar]; 
else  $_SESSION[foo]="foobar.php";
include($_SESSION['foo']); 

我发现即使有 else$_SESSION[foo] 也是空的.经过一些研究,我发现当我运行 phpinfo() 时,session.save_pathno value(原始是/tmp).所以现在

I found that $_SESSION[foo] is empty even with the else. After some research I found that when I ran phpinfo() that session.save_path was no value (the original was /tmp). So now

php.ini

upload_max_filesize = 10M ;
post_max_size = 10M ;
session.save_path = /home/foobar/tmp ;

但我仍然收到错误消息.如果我从此文件夹中删除 php.ini 文件,则 email.php 上的表单脚本可以正常工作,但我又回到 upload_max_filesize = 2MB for upload.php.任何帮助将不胜感激.

But I am still getting the error. If I remove the php.ini file from this folder, then the form script on email.php works just fine, but I am back to upload_max_filesize = 2MB for upload.php. Any help would be appreciated.

推荐答案

这是 CGI PHP 设置的一个问题,其中服务器 php.ini 指令不会级联到自定义配置中.

This is an issue with CGI PHP setups where the server php.ini directives do not cascade into custom configurations.

我在这里广泛地写了这个 - http://blog.philipbrown.id.au/2009/08/php-suexec-and-custom-php-ini-files/

I've written about this extensively here - http://blog.philipbrown.id.au/2009/08/php-suexec-and-custom-php-ini-files/

$_SESSION[foo]=$_GET[bar];否则 $_SESSION[foo]="foobar.php";包括($_SESSION['foo']);

$_SESSION[foo]=$_GET[bar]; else $_SESSION[foo]="foobar.php"; include($_SESSION['foo']);

我对这个片段有点困惑.它不仅无效(没有 if 语句,没有引用数组索引)而且非常不安全.

I'm a bit confused by this snippet. Not only is it invalid (no if statement, array indexes not quoted) but highly insecure.

这篇关于子文件夹中的自定义 php.ini 文件导致 $_SESSIONS 变量出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆