Home > Backend Development > PHP Tutorial > How to add advertising images with links in Baidu Tieba_PHP Tutorial

How to add advertising images with links in Baidu Tieba_PHP Tutorial

WBOY
Release: 2016-07-21 14:55:59
Original
936 people have browsed it

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:
以下为引用的内容:
mysql.jpg http://www.bkjia.com/bkjia.com/images/liehuo2009/logo.gif http://www.bkjia.com/
lyf.jpg http://www.bkjia.com/uploads/allimg/090904/1231133495-0-lp.jpg http://www.bkjia.com/
mysql.jpg http://www .bkjia.com/bkjia.com/images/liehuo2009/logo.gif http://www.bkjia.com/ lyf.jpg http://www.bkjia.com/uploads/allimg/090904/1231133495- 0-lp.jpg http://www.bkjia.com/


Call like this:

http://yourhost/image.php?name=lyf.jpg

This picture can realize the functions in Tieba. Very simple, but very creative. However, this method is not possible under Firefox!

http://www.bkjia.com/PHPjc/364323.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/364323.htmlTechArticleLieHuo.Net Tutorial I saw a post on Baidu Tieba today, click on the picture inside to enter Your own set link. It seems unlikely, because Baidu only allows you to fill in...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template