duanbei1709 2012-01-22 20:51
浏览 76
已采纳

转移到新的主机/服务器 - fopen()和fwrite()[重复]的权限问题

Possible Duplicate:
mysql_fetch_array() expects parameter 1 to be resource, boolean given in select

When users register an account, their profile is supposed to be automatically created using fopen(), like so:

$fh = fopen($profile_path.$username_file.'.php', "w");
fwrite($fh, $tpl_and_values);
fclose($fh); 

The first parameter for fopen(), when the variable values are given, should be something like this: profile/Auser.php. $tpl_and_values just gives the path to the template file.

Here are the errors I'm getting:

Warning: fopen(profile/givenusername.php) [function.fopen]: failed to open stream: Permission denied in /f5/tagzor/public/registeraccount.php on line 109

Warning: fwrite() expects parameter 1 to be resource, boolean given in /f5/tagzor/public/registeraccount.php on line 110

Warning: fclose() expects parameter 1 to be resource, boolean given in /f5/tagzor/public/registeraccount.php on line 111

(Registeraccount.php is the page where the code above resides.)

I'm thinking it has to be some kind of CHMOD permissions problem. Registeraccount.php is set to 655, so I don't really know what could be wrong. Giving it 777 might be a bad idea, but I could be wrong.

  • 写回答

2条回答 默认 最新

  • doushadu0901 2012-01-22 22:20
    关注

    Your question implies quite a few security issues.

    E.g. I hope you're sanitizing your data - what if a user registers as "../index".

    However..


    The permissions of Registeraccount.php are not relevant to the error you see.

    Assuming that $fh = fopen($profile_path.$username_file.'.php', "w"); is line 109 of your script:

    You need to ensure that $profile_path is writable. As a start make /f5/tagzor/public/profile world writable (777)

    You should find the error goes away. If you don't change the owner of that folder most likely the permissions need to remain 777, if possible though:

    • Change the owner of the profile folder to the user running php (check the owner of the files in that folder)
    • Set permissions to 755

    That will at least restrict such that only the webserver user is able to create files in that folder.

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

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog