簡體   English   中英

PHP文件編輯問題

[英]PHP File Editing problems

我最近一直在使用IIS和PHP,但無法編輯文件。 我已將wwwroot文件編輯為IIS_IUSRS的權限,但這似乎無濟於事。 我仍然收到以下警告:

Thanks for your request, *My IP Here* The robot moved forward. Warning: fopen(Ips.txt): failed to open stream: Permission denied in C:\inetpub\wwwroot\CMD.php on line 20 Unable to open file, Ips.txtPermission denied in C:\inetpub\wwwroot\CMD.php on line 20 Unable to open file, Ips.txt

如果我理解正確,這意味着wwwroot無法打開php編輯。 這是我的代碼:

<?php
$cmd=$_GET["cmd"];
$ip=$_SERVER['REMOTE_ADDR'];
if($cmd=="Forward") {
//insert forward code here.
    echo "Thanks for your request, ".$ip." The robot moved forward.";

} else if($cmd=="Backward") {
//insert backwards code here.
    echo "Thanks for your request, ".$ip." The robot moved backwards.";
} else if($cmd=="Left") {
//insert left code here.
    echo "Thanks for your request, ".$ip." The robot moved left.";
} else if($cmd=="Right") {
//insert right code here.
    echo "Thanks for your request, ".$ip." The robot moved right.";
} else {
    echo "Got invalid command: ".$cmd." From IP: ".$ip;
}
$ipfile = fopen("C:/inetpub/wwwroot/Ips.txt",'w') or exit("Unable to open file, Ips.txt");
if(!strpos(file_get_contents("C:/inetpub/wwwroot/Ips.txt"),$ip)) {
    fwrite($ipfile,$ip);
}
echo "\nYour IP has been logged for security purposes.";
fclose($ipfile);
$log=fopen("C:/inetpub/wwwroot/Logs.txt",'w') or exit("Unable to open file, Logs.txt");
fwrite($log,"Got command, ".$cmd." from a computer at the adress, ".$ip);
fclose($log);
?>

我已經環顧了很長時間,並且發現了類似的情況,但是未找到解決方案,或者關於不適當的IIS文件權限。

我知道了,結果IPs.txt不知何故失去了用戶編輯的權限,我添加了權限,並解決了問題,感謝所有幫助!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM