2019-02-26 18:48
采纳率: 0%
浏览 101


I hope you can help me on this matter. I tested a very simple script to add a comment to a zip file before downloading it, and it worked fine, so now I decided to try implementing it into a file hosting script, but I'm being unable to find a way to edit the generated file.

At line 59 of this file: (which is the file which generates the download link for my file) you can see my edit, which I will also post below:

$ipaddress = '';
if (getenv('HTTP_CLIENT_IP'))
    $ipaddress = getenv('HTTP_CLIENT_IP');
else if(getenv('HTTP_X_FORWARDED_FOR'))
    $ipaddress = getenv('HTTP_X_FORWARDED_FOR');
else if(getenv('HTTP_X_FORWARDED'))
    $ipaddress = getenv('HTTP_X_FORWARDED');
else if(getenv('HTTP_FORWARDED_FOR'))
    $ipaddress = getenv('HTTP_FORWARDED_FOR');
else if(getenv('HTTP_FORWARDED'))
    $ipaddress = getenv('HTTP_FORWARDED');
else if(getenv('REMOTE_ADDR'))
    $ipaddress = getenv('REMOTE_ADDR');
    $ipaddress = 'UNKNOWN';

# Create a new Archive
$zip = new ZipArchive;
# Create the file to archive to
$res = $zip->open($file, ZipArchive::CREATE);
# If create works
if ($res === TRUE) {
    # Create the comment here

Basically it works to append the IP of who downloads it into the zip file, as comment.

As standalone script it works fine, but I'm having a hard time implementing it into the file hosting script, as when the file gets downloaded, it's unmodified.

I suppose the problem is with the variable $file which might not be correct, because as stand-alone script it's enough to specify in there the name of the archive in order to append the comment and then download it, while with the file hosting script, if I assign the variable holding the file name (which is $file->originalFilename), still nothing happens.

Hope you can assist me into properly implementing my script, thank you.

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

相关推荐 更多相似问题