Skip to content

Commit

Permalink
Minor adjust
Browse files Browse the repository at this point in the history
  • Loading branch information
catscarlet committed May 21, 2018
1 parent 8124e94 commit 9b726aa
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
8 changes: 5 additions & 3 deletions wp-ipip-options.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
</head>
<body>
<h1 id="wp-ipip">WP-IPIP</h1>
<hr>
<h2>简介</h2>
<p>
<strong>WP-IPIP</strong>是一款根据 IP 显示评论来源地址的插件。
Expand All @@ -15,10 +16,11 @@ <h2>设置</h2>
<h3 id="ipip-">IPIP数据库文件</h3>
<p>文件状态:{{$ipip_data_status}}</p>
<p>说明:默认 IPIP 的数据库文件存放于插件目录下的<code>/17mon/php/</code>目录下,文件名为<code>17monipdb.dat</code></p>
<p>您可以到<a href="https://www.ipip.net/">IPIP官网</a>下载更新的数据库文件,并上传到插件目录下的<code>/17mon/php/</code>目录下。目前仅支持免费版数据库</p>
<p>您可以到 <a href="https://www.ipip.net/" target="_blank">IPIP.net 官网</a> 下载更新的数据库文件,并上传到插件目录下的<code>/17mon/php/</code>目录下。</p>
<hr>
<h2>项目地址</h2>
<p>GitHub:<a href="https://github.com/catscarlet/wp-ipip">https://github.com/catscarlet/wp-ipip</a>
</p>
<p>GitHub:<a href="https://github.com/catscarlet/wp-ipip" target="_blank">https://github.com/catscarlet/wp-ipip</a></p>
<p>本项目暂未包含于 WordPress Plugin 仓库中,如有必要请到 <a href="https://github.com/catscarlet/wp-ipip/releases/latest" target="_blank">这里</a> 下载最新的版本。</p>
<p>目前仅 0.1.X 版本支持旧的 IPIP.net DAT 数据库,请尽可能升级到 0.2 以上的版本并使用 IPIP.net DATX 数据库。</p>
</body>
</html>
11 changes: 6 additions & 5 deletions wp-ipip-options.php
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
<?php

$tplpath = WP_PLUGIN_DIR.'/wp-ipip/wp-ipip-options.html';
$tpl_path = WP_PLUGIN_DIR.'/wp-ipip/wp-ipip-options.html';

if (!is_readable($tplpath)) {
if (!is_readable($tpl_path)) {
echo 'Cannot read file wp-ipip-options.html at '.getcwd();

return;
}
$tpl = file_get_contents($tplpath);

$tpl = file_get_contents($tpl_path);

$ipip_data_filepath = WP_PLUGIN_DIR.'/wp-ipip/17mon/php/17monipdb.dat';

if (is_readable($ipip_data_filepath)) {
$ipip_data_status = '<span style="color: green;">检测到IPIP数据库文件</span>';
$ipip_data_status = '<span style="color: green;">检测到 IPIP.net 数据库文件</span>';
} else {
$ipip_data_status = '<span style="color: red;">未检测到IPIP数据库文件</span> 于 <code>'.$ipip_data_filepath.'</code>';
$ipip_data_status = '<span style="color: red;">未检测到 IPIP.net 数据库文件</span> 于 <code>'.$ipip_data_filepath.'</code>';
}

$search = ['{{$ipip_data_status}}'];
Expand Down
8 changes: 4 additions & 4 deletions wp-ipip.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function wpipip_add_option_page()

function load_wp_ipip_resources($hook_suffix)
{
if ($hook_suffix == 'edit-comments.php') {
if ('edit-comments.php' == $hook_suffix) {
wp_register_script('wp-ipip.js', plugin_dir_url(__FILE__).'js/wp-ipip.js', array('jquery'));
wp_enqueue_script('wp-ipip.js');
include_once WP_PLUGIN_DIR.'/wp-ipip/17mon/php/IP.class.php';
Expand All @@ -44,20 +44,20 @@ function wp_ipip($comment_text, $comment = null)
$results = IP::find($comment->comment_author_IP);
} catch (Exception $e) {
$location = 'WP-IPIP Caught exception: '.$e->getMessage();
$wpipip_e = '<div class="wp-ipip-comment" display="none" id="wp_ipip_perfix_'.$comment->comment_ID.'" style="color:red">'.$location.'</div>';
$wpipip_e = '<div class="wp-ipip-comment" display="none" id="wp-ipip-perfix-'.$comment->comment_ID.'" style="color:red">'.$location.'</div>';

echo $wpipip_e;

return $comment_text;
}

if ($results == 'N/A') {
if ('N/A' == $results) {
return $comment_text;
}

$location = array();
foreach ($results as $str) {
if ($str != null) {
if (null != $str) {
$location[] = $str;
}
}
Expand Down

0 comments on commit 9b726aa

Please sign in to comment.