As mentioned above, I have been studying the scheme of displaying IP addresses in the comment area recently, but finally abandoned the scheme of online API interfaces. Because no cache will be set, and each time I directly query the information returned, it will naturally be much slower. There may be several comments, but if there are dozens or even hundreds of comments in the article, I can imagine how far it will drag, So today we use zblog Application Center plug-in unit "Physical IP address (pure version)" to achieve this function.
I talked with the Tang Dynasty before and also gave some suggestions. It's a great honor to be accepted. More importantly, the plug-in is free, and no extra cost is allowed. As shown in the figure above, the display mode is divided into three types, which directly shows the IP location and the location+IP address, as well as the location and IP alternate display. You can also set the display mode, which can be province+region (Shenyang, Liaoning) or province (Liaoning), according to your own preferences.
The plug-in is very simple and there is nothing superfluous. According to the instructions of the Tang Dynasty, because it is a local query, it is very fast, and there is no drag of the online interface. After testing, it is really fast, the same time as the plug-in was not opened. Of course, my comments are few. If you open the plug-in and the query speed is slow, you can contact me. After installing the plug-in, don't forget to download it“ qqwry.dat ”Pure IP data. This is necessary. After downloading, follow the course The directory upload of can be completed, which is very simple. The method of directly calling the Tang Dynasty is also given:
{if $zbp->CheckPlugin('ytecn_ipshow')} <span class="interaction area">From {ytecn_ip ($comment. IP)}</span> {/if}
Copy the above code and place it in the location where the IP address needs to be displayed, such as the comment area of the blog. Path:“ /Zb_users/theme/Topic ID/template/comment.php ”After saving, remember to display it on the foreground of "Clear Cache Compilation" on the background home page. After the code makes a judgment, the call will be displayed only after the plug-in is enabled, and no error will be reported if the plug-in is not enabled.
The effect after the plug-in is enabled is probably that of Jamie (taking the theme of hope as an example):
The theme will update the IP location function in succession. The back switch can be turned on or off according to the actual situation. After all, different places have different requirements for websites. It is estimated that personal blog websites will have to force requirements later. Well, the tutorial is completed. I will update the theme template. If you have any questions, please leave a message!
the latest version:
Because the Tang Dynasty bosses are busy, they haven't been updated. I'm looking for Baidu After a variety of methods, I finally came back. Currently, I use the 3. x version (ipv4+ipv6) developed by "Zhao Binyan" to automatically identify IPV4 or IPV6. At present, after testing, I have made plug-ins. The settings are similar according to the version of the Tang Dynasty tycoons, and can't be said to be a dime. Yes, after all, I use the Tang Dynasty plug-in framework directly, but the code is different, as shown in the figure below:
Code calling method:
{if ((int)$zbp->Config('iparealee')->Getipon) && ($zbp->CheckPlugin('iparealee'))} {get_ipaddress($comment.IP)} {/if}
The display after this update is more perfect, for example, the problem that the real IP address cannot be obtained by using CDN is added, The code display is clearer, as shown in the figure:
After obtaining the IP address, different contents can be displayed according to the actual situation. The plug-in background updates three ways: province: Guangdong, province: Shenzhen, Guangdong, province: * * District, Shenzhen, Guangdong (because the IP data comes from free, the district display is not particularly friendly, depending on fate). It is recommended to display the province directly during actual use, which is more accurate, It is not known whether the IP data will be updated later. The plug-in is currently tested, and there is no problem to release it later. Ok, the update article is completed. By the way, the download address of IP data is attached.
PS: The development theme of this website has basically integrated relevant code, which can be achieved only by downloading and enabling the theme. If there is any problem, contact the blogger.
Data download:
Follow the public account to view the verification code (download function test)
Please follow our WeChat official account and reply Verification code , get the verification code.
Search on WeChat "Li Yang Blog" perhaps “liblogcn” Or WeChat scanning the QR code on the right can follow our WeChat official account.