How to paste pictures and hyperlinks in Baidu

Source: Internet
Author: User
Tags copy empty header php code servervariables
Before the webmaster network to see how a paste in Baidu posted pictures and hyperlinks to the article, not too concerned about, and later in retrospect, is indeed a very good "means" is now transferred to everyone. This article gives the asp,php code.

Implementation methods and code:

1. Create a folder called Test.jpg, remember the folder

2. In the folder down a larger size of the picture such as 570*383, to ensure that the picture in the post to Baidu Post it will be abbreviated display

3. Place a index.php or index.asp file on the folder, which reads as follows:

PHP Version Code:

The following are the referenced contents:
<?php
if ($_server[' http_referer ']!= ') {
@header ("Content-type:image/jpeg");
Echo file_get_contents ("1.jpg")//The name of the picture placed under the Test.jpg folder in step 2nd, that is, the picture that is actually displayed
}
else{
@header ("location:http://www.lyrs.net");//Click on the thumbnail to jump to the URL
}
?>

ASP Version Code:

The following are the referenced contents:
<%
Pic_url= "1.jpg"

If UCase (Cstr (Request.ServerVariables ("Http_referer")) <> "" Then
Response.Redirect Pic_url
Else
Response.Redirect "Http://www.lyrs.net"
End If
%>

4. In Baidu Post bar Picture: Test.jpg

In the Baidu Post map posted on the site after the picture will be normal display, click the picture will jump to the set of pages, of course, on the copy on the Web site directly pasted to the browser or on the QQ to friends, visitors will jump to your site.

Principle Analysis:

Baidu in larger size will be thumbnail display, click the thumbnail to view the original image, but the thumbnail is not directly linked to the original, but in the JS code pop-up (pop-up code in http://static.tieba.baidu.com/tb/js/ Pb.js file), that will cause the browser will not have routing information, so you can in the PHP program or the ASP program to judge the antecedents, if the routing is empty, then jump to the designated URL, if the route will not be empty, then use the test.jpg directory of index.php or index.asp files directly to get straight picture or generate straight pictures, the reason folder name test.jpg to contain. jpg is essentially for the Baidu post when the folder disguised as a picture.

The reason is that through QQ to friends or directly in the browser to the output of the image address access will also jump, that is because there is no routing information.

Test address: http://tieba.baidu.com/f? kz=273127757 (9 Floor for PHP version, 10 Floor for ASP edition)

Extended Applications:

In fact, since the output of index.php or index.asp is straight, then we can completely achieve the effect of random display of pictures, the following ASP code to achieve two pictures of the random display:

The following are the referenced contents:

<%
Pic_url= "1.jpg2.jpg"

Thechar= "" ' Separator character
Ipy=split (Pic_url,thechar)
Ipy_s=ubound (IPY)

If InStr (Pic_url,thechar) >0 Then
Randomize
pic_url=ipy (int (ipy_s*rnd))
End If

If UCase (Cstr (Request.ServerVariables ("Http_referer")) <> "" Then
Response.Redirect Pic_url
Else
Response.Redirect "Http://www.lyrs.net"
End If
%>

We can also combine PHP application, using PHP real-time generation of dynamic pictures, such as the following code can read their blog The latest article title to generate pictures:

The following are the referenced contents:

<?php
Include (".. /config.php ");

$font = "MINGLIU.TTC";//font (put the font file in the same directory)     
$size = 8.5;//font Size (PT)
Header (" Content-type:image/gif ");   
$nimage =imagecreatetruecolor (228,80);//new picture width 228 High 80 pixel      
$black =imagecolorallocate ($nimage, 115,115,115);//Get text color, rgb    
$ Simage =imagecreatefromgif (' bg.gif '); Read the background picture (do it yourself, like me this is my PS)    
Imagecopy ($nimage, $simage, 0,0,0,0,228,80);//copy background picture To the picture we want to output  

$i = 46;
$SQLSTR = "SELECT * from art_content ORDER BY id desc limit 2";//Read the statement of the header information in the database
$result =mysql_query ($SQLSTR);
while ($row =mysql_fetch_array ($result)) {
$text 1 = "Deciduous life:". $row ["title"];
$text 1 = iconv ("gb2312", "Utf-8", $text 1);/must be converted to UTF-8, otherwise Chinese garbled
Imagettftext ($nimage, $size, 0,2, $i, $black, $font, $text 1);//output The first line of text, coordinates: 2,46
$i = $i +20;
}

Imagegif ($nimage); Output GIF Picture contents
Imagedestroy ($nimage);
Imagedestroy ($simage); Picture Buffering used before closing
?>



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.