简体   繁体   English

传入谷歌和雅虎链接的PHP代码帮助

[英]php code help for incoming google and yahoo links

Actually i am working on a web site and on that site i want to add two more features like, 实际上,我正在一个网站上工作,并且我想在该网站上添加另外两个功能,例如,

  • Incoming google links: 传入的Google链接:
  • Incoming yahoo links: 传入的Yahoo链接:

when user write his web site url in text box then the result show below the total incoming google and yahoo links. 当用户在文本框中输入其网站网址时,结果将显示在总的传入google和yahoo链接下方。

If anyone has the knowledge of this, then please help, waiting,,thanks 如果有人知道这一点,请帮助,等待,谢谢

You can use the $_SERVER['HTTP_REFERER'] : 您可以使用$_SERVER['HTTP_REFERER']

http://php.net/manual/en/reserved.variables.server.php http://php.net/manual/en/reserved.variables.server.php

You would have to use a database (like MySQL) to store the HTTP_REFERERs, like Kristopher Ives mentioned. 您将必须使用数据库(例如MySQL)来存储HTTP_REFERER,例如Kristopher Ives所述。 But first you would have to analyze the referers to see whether it came from a yahoo or google domain. 但是首先,您必须分析引荐来源网址,以查看它是否来自yahoo或google域。

$regex = '/(?:yahoo|google)\.[a-z]{2,3}$/';
$info = parse_url($_SERVER['HTTP_REFERER']);
if ($info !== false && preg_match($regex,$info['host']))
   // Add $_SERVER['HTTP_REFERER'] to database or increment a counter
   // on the matched domain

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM