douluan4644 2013-05-06 12:50
浏览 13

检查列表上的推荐和打印警报

I'd like a code to check if the referrer URL of a visitor to my Website is registered on a list, so then it will give back one alert or another. I have tried this, but doesn't work, and it can just check if the visitor is coming from a specific URL, not checking a list as I want:

<?php
if (ref.match(/^https?:\/\/([^\/]+\.)?friendsite\.com(\/|$)/i)) {
  alert("You came from a friend Website");
  else { alert("You came from a non friendly Webstie");
}
?>
  • 写回答

1条回答 默认 最新

  • dtvfshi5248 2013-05-14 21:45
    关注
       if(!empty($_SERVER['HTTP_REFEREF'] ) {// if there is referer
           $host = parse_url($_SERVER['HTTP_REFERER'], PHP_URL_HOST); // parse site (remove page, protocol, etc
           if(in_array($host, array('site.com', 'friend.ru'))) {
               echo "<script>alert(\"etc\")</script>";
           }
       }
    
    评论

报告相同问题?

悬赏问题

  • ¥15 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突