Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用PayDotCom或Paypal的PHP安全下载程序_Php - Fatal编程技术网

使用PayDotCom或Paypal的PHP安全下载程序

使用PayDotCom或Paypal的PHP安全下载程序,php,Php,下面的脚本是一个快速而肮脏的尝试,旨在提供一种保护我在PayDotCom和Paypal上出售的文件的方法 如果有人有这些服务的经验,我有几个问题 1) 在执行下载之前,我是否可以在这些支付网站中设置令牌,然后在下面的脚本中进行检查 2) 在下面的脚本中,检索到的文件是正确的,但是,它要保存到的文件名与PHP处理页面(secure download.PHP)相同。如何更改已保存文件的文件名?e、 它将是一个zip文件 3) 下面的代码中有一些注释,我需要一些关于 <?php $fi

下面的脚本是一个快速而肮脏的尝试,旨在提供一种保护我在PayDotCom和Paypal上出售的文件的方法

如果有人有这些服务的经验,我有几个问题

1) 在执行下载之前,我是否可以在这些支付网站中设置令牌,然后在下面的脚本中进行检查

2) 在下面的脚本中,检索到的文件是正确的,但是,它要保存到的文件名与PHP处理页面(secure download.PHP)相同。如何更改已保存文件的文件名?e、 它将是一个zip文件

3) 下面的代码中有一些注释,我需要一些关于

<?php

    $file = basename(urldecode($_GET['file']));
    $fileDir = dirname(dirname( dirname( __FILE__ ) ) )."/secure/";

// The secure directory is outside of www root

    if (file_exists($fileDir . $file))
    {
        // Note: Need advice here to do some more checks 
        // on the filetype, size, etc.
        $contents = file_get_contents($fileDir . $file);

        // Note: Need to implement some kind 
        // of check on filetype
        header('Content-type: application/zip');

        echo $contents;
                    //currently the filename is same as the processing file, need to change it to [somefile].zip

    }

?>

您可以通过以下操作轻松更改文件名:

标题(“内容配置:atachment;文件名=myfilename.zip”)


至于令牌保护,您需要参考PayPal文档,因为您需要此脚本来拥有传入的令牌变量-然后将其传输给他们以确认它是有效的令牌。

为什么我不确定我是否理解您的想法,但我认为您下载该文件时有问题?如果是这样,这是您的固定代码:

<?php

    $file = basename(urldecode($_GET['file']));
    $fileDir = dirname(dirname( dirname( __FILE__ ) ) )."/secure/";

// The secure directory is outside of www root

    if (file_exists($fileDir . $file))
    {
        $contents = file_get_contents();
        header("Content-Type: x-type/subtype");
        header("Content-Disposition: attachment; filename=\""$fileDir.$file"\"");
    }

?>


谢谢,这有助于解决文件名问题,但我在内容配置上遇到了一个错误…解析错误:语法错误,第12行的pathtomyfile中出现意外的T_变量我能够解决第12行的问题。我将接受你的答案,并为IPN/Paypal和PayDotCom问题专门创建另一个答案。谢谢你的帮助!