首页 \ 问答 \ PHP页面保护(PHP page protection)

PHP页面保护(PHP page protection)

我在我的网站上销售数字产品,并且我想设置某种页面保护。 我的客户通过PayPal付款。 我有一个“提交”页面上的链接到PayPal结帐,并已设置我的结帐重定向到“信息”页面。 信息页面是我想要保护的内容。

这里是我到目前为止的代码,但由于某种原因,它不工作,我不断收到“else”语句...

<div id="info">
<ul>
<li>
<?php 
if ( $_SERVER['HTTP_REFERER'] == "https://www.paypal.com/" ){

echo 'information...';

}else{
echo 'You need to pay first...';
}
?>
</li>
</ul>
</div>

有人看到我做错了什么? 或者有更好的选择?

谢谢!


I am selling digital products on my site, and I want to set up some kind of page protection. My customers are paying through PayPal. I have a link on the "submit" page to PayPal checkout, and have set up my checkout to redirect to the "information" page. The information page is what I want to protect.

Here's the code I have so far, but for some reason it's not working, I keep getting the "else" statement...

<div id="info">
<ul>
<li>
<?php 
if ( $_SERVER['HTTP_REFERER'] == "https://www.paypal.com/" ){

echo 'information...';

}else{
echo 'You need to pay first...';
}
?>
</li>
</ul>
</div>

Anybody see what I'm doing wrong? Or have a better option?

Thanks!


原文:https://stackoverflow.com/questions/7266025
更新时间:2023-06-08 13:06

最满意答案

忘了md5一秒钟。 相反,想象你的散列函数真的很愚蠢,它只是将源数据中每个字节的值相加。

现在假设您的源数据只是两个字节: 0x010x020x02顺序。 对于这些输入,散列值为3

问题是,你可以从许多其他字节序列得到3的相同答案:

0x01 0x01 0x01
0x00 0x03
0x03
0x02 0x01

......你明白了,希望你也看到,当你所拥有的只是散列值时,不可能确切地知道哪些可能性是原始输入, 3

使用md5,算法更加复杂,并且更好地避免了碰撞,但原理是相同的。 出于这个原因,它被称为“单向哈希”。


Forget md5 for a second. Instead imagine that your hashing function was really dumb and it just added up the value of each byte in the source data.

Now let's say that your source data is just two bytes: 0x01 and 0x02, in that order. For these inputs the hashed value is 3.

Problem is, you can get the same answer of 3 from lots of other byte sequences:

0x01 0x01 0x01
0x00 0x03
0x03
0x02 0x01

...you get the idea, and hopefully you also see that it's impossible to know with any certainty which of those possibilities could have been the original input when all you have is the hashed value, 3.

With md5, the algorithm is far more complex and way better at avoiding collisions, but the principle is the same. It's called a "one-way hash" for this very reason.

相关问答

更多
  • MD5的全称是Message-Digest Algorithm 5,在90年代初由MIT的计算机科学实验室和RSA Data Security Inc 发明,由 MD2/MD3/MD4 发展而来的。MD5的实际应用是对一段Message(字节串)产生fingerprint(指纹),可以防止被“篡改”。举个例子,天天安全网提供下载的MD5校验值软件WinMD5.zip,其MD5值是1e07ab3591d25583eff5129293dc98d2,但你下载该软件后计算MD5发现其值却是81395f50b94bb ...
  • 什么是MD5效验码[2022-06-03]

    MD5的全称是Message-Digest Algorithm 5,在90年代初由MIT的计算机科学实验室和RSA Data Security Inc 发明,由 MD2/MD3/MD4 发展而来的。MD5的实际应用是对一段Message(字节串)产生fingerprint(指纹),可以防止被“篡改”。举个例子,天天安全网提供下载的MD5校验值软件WinMD5.zip,其MD5值是1e07ab3591d25583eff5129293dc98d2,但你下载该软件后计算MD5发现其值却是81395f50b94bb ...
  • MD5验证是什么[2022-06-05]

    MD5是message-digest algorithm 5(信息-摘要算法)的缩写,被广泛用于加密和解密技术上,它可以说是文件的“数字指纹”。任何一个文件,无论是可执行程序、图像文件、临时文件或者其他任何类型的文件,也不管它体积多大,都有且只有一个独一无二的MD5信息值,并且如果这个文件被修改过,它的MD5值也将随之改变。因此,我们可以通过对比同一文件的MD5值,来校验这个文件是否被“篡改”过。 MD5到底有什么用 当我们下载了文件后,如果想知道下载的这个文件和网站的原始文件是否一模一样,就可以给自己下载 ...
  • 什么是MD5???---MD5的全称是Message-Digest Algorithm 5 MD5的典型应用是对一段信息(Message)产生信息摘要(Message-Digest),以防止被篡改。比如,在UNIX下有很多软件在下载的时候都有一个文件名相同,文件扩展名为.md5的文件,在这个文件中通常只有一行文本,大致结构如: MD5 (tanajiya.tar.gz) = 0ca175b9c0f726a831d895e269332461 这就是tanajiya.tar.gz文件的数字签名。MD5将整个文件 ...
  • 不,这对于使您的密码更安全没有多大帮助。 它增加了一点“默默无闻的安全性”,但是当我们对密码进行哈希处理时,我们会为攻击者知道哈希值和算法的情况做好准备。 MD5的一般问题和推导问题是,它们的计算速度太快。 使用通用硬件,您可以计算8Giga MD5 / s ,这使得暴力破解变得非常简单。 今天的密码破解工具不仅提供普通的MD5哈希,你还可以计算出衍生物,例如md5(strtoupper(md5($pass))) 。 为了安全存储密码,您需要一个缓慢的哈希函数,如BCrypt,PBKDF2或SCrypt,并 ...
  • 加密散列实际上是一个位序列,但它可以解释为数字。 因此,理论上你可以使用好的旧base_convert()表示在一个大的基础上。 遗憾的是,此函数仅适用于36,它仅限于实际数字(即适合PHP_INT_MAX短整数) - 否则会发生数据丢失。 这是第三方图书馆拯救的地方。 唯一的问题是它们往往难以找到,因为它们通常解决非常具体的用例(比特币,ID混淆等)。 我找到了例如aza / math ,这可能是矫枉过正但应该完成工作。 我没有机会测试它,但它应该是这样的: $original = '719bedacf2 ...
  • 忘了md5一秒钟。 相反,想象你的散列函数真的很愚蠢,它只是将源数据中每个字节的值相加。 现在假设您的源数据只是两个字节: 0x01和0x02 , 0x02顺序。 对于这些输入,散列值为3 。 问题是,你可以从许多其他字节序列得到3的相同答案: 0x01 0x01 0x01 0x00 0x03 0x03 0x02 0x01 ......你明白了,希望你也看到,当你所拥有的只是散列值时,不可能确切地知道哪些可能性是原始输入, 3 。 使用md5,算法更加复杂,并且更好地避免了碰撞,但原理是相同的。 出于这个 ...
  • 这确实是合理的担忧。 您可能会发现以下有趣的文章: 彩虹桌 盐 但MD5被安全专家认为是“破”的。 这取决于你的要求是什么:MD5可能是合适的,但像SHA-2系列这样更安全的哈希可能是更明智的选择,或者甚至是像PBKDF2这样的密钥加强技术(正如CodeInChaos所建议的 )。 请注意,您单独使用散列算法的选择不能孤立地被视为安全或不安全。 以经过验证的,经过验证的方式使用哈希算法很重要。 These are indeed legitimate concerns. You might find the ...
  • 你试图以错误的方式解决这个问题。 最好的解决方案是使用HTTPS。 这意味着您不必担心模糊输入的密码。 在我的解决方案中,我通过HTTPS接受纯文本密码,然后更进一步检查他们的密码不是我在本地存储的12,000个左右的“简单”密码之一。 You are trying to go about this the wrong way. The best solution is to use HTTPS. This means you don't have to worry about obfuscating th ...
  • 默认情况下, MD5()函数生成的哈希长度为32个字符。 passwd列的数据类型当前为VARCHAR (25) ,这意味着它最多只能存储25个字符,比实际值少7个字符。 要解决此问题,您需要更改passwd列的数据类型以便能够存储正确的长度,例如VARCHAR (32) 。 By default, the hash generated by the MD5() function is 32 characters long. The datatype of the passwd column is curr ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)