Home >Backend Development >PHP Tutorial >How to add advertising images with links in Baidu Tieba_PHP Tutorial
Bangkejia (www.Bkjia.com) tutorial Today I saw a post on Baidu Tieba. Clicking on the picture inside will lead to your own set link. It seems unlikely, because Baidu only allows you to fill in a picture link, and does not allow pictures to add links themselves. In fact, just use PHP to determine whether it is referenced by the picture or whether it is being viewed. The code is as follows:
以下为引用的内容: $fileLine = file(dirname(__FILE__) . "/file.ini"); $nameMap = array(); foreach ($fileLine as $item) { $item = explode(" ", $item); if (count($item) == 3) { $nameMap[$item[0]] = array($item[1], $item[2]); } } $name = $_GET['name']; if (!isset($nameMap[$name])) { exit(0); } header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past if (isset($_SERVER['HTTP_REFERER']) && stripos($_SERVER['HTTP_REFERER'], "baidu") !== false) { header("Content-Type: image/png"); echo get($nameMap[$name][0]); } else { header("location:" . $nameMap[$name][1]); exit(0); } |
File.ini is configured like this:
The following is the quoted content:
|
Call like this:
This picture can realize the functions in Tieba. Very simple, but very creative. However, this method is not possible under Firefox!