dpzyd8865 2010-04-24 10:30
浏览 10
已采纳

跨域文件编辑

I need to know, where from is my script used (it's for sale, and i don't want any thiefs). I want to write on my server in file, IP of user, domain where from script has been runned, date, etc. I've tried fopen, fwrite, but is_file_writable returned that it isn't. File CHmods are 777, it parent catalog has too 777 chmods.

Now i'm trying something like that:

<?php
$file = 'http://www.misiur.com/security/seal.txt';

$data = date("Y-m-d H:i:s");
$ip = $_SERVER['REMOTE_ADDR'];
$svr = $_SERVER['SERVER_NAME'];
$str = "[$data] Loaded by $ip at $svr
";

$current = file_get_contents($file);
$current .= $str;
file_put_contents($file, $current);
?>

However - nothing happens. What i've got to do?

  • 写回答

1条回答 默认 最新

  • donglaoping9702 2010-04-24 10:32
    关注

    The HTTP URL wrapper doesn't allow writing.

    The best way to do this would be having a script on the remote server's end (in your example, misiur.com:

    http://www.misiur.com/security/write_seal.php
    

    Send the contents of the new text file to that script using POST. The script would then file_put_contents() the received information locally.

    Here's a code snippet that allows you to send POST contents to remote scripts easily. You will need POST because GET is usually limited in size to 1-2 kilobytes.

    Of course, you would need to secure that script somehow to prevent malicious use, e.g. through a .htaccess based password protection or a passkey.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 MCNP里如何定义多个源?
  • ¥20 双层网络上信息-疾病传播
  • ¥50 paddlepaddle pinn
  • ¥20 idea运行测试代码报错问题
  • ¥15 网络监控:网络故障告警通知
  • ¥15 django项目运行报编码错误
  • ¥15 请问这个是什么意思?
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏