hotlink protection

后端 未结 2 558
星月不相逢
星月不相逢 2021-01-07 01:49

i made this simple code to prevent hotlinking my files from my php download file :

if ((strpos($_SERVER[\'HTTP_REFERER\'],\'www.domain.com\')!==0)) {
    $re         


        
2条回答
  •  执笔经年
    2021-01-07 02:33

    You actually want to use !== FALSE instead. The string could be at position 0. Also include zerkms' suggestion:

    if (!empty($_SERVER['HTTP_REFERER']) && 
        (strpos($_SERVER['HTTP_REFERER'],'www.domain.com') !== FALSE)) {
    

    Documentation: http://php.net/manual/en/function.strpos.php

提交回复
热议问题