-
Notifications
You must be signed in to change notification settings - Fork 1
/
wp-ipip-options.php
35 lines (25 loc) · 1.01 KB
/
wp-ipip-options.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php
$tpl_path = WP_PLUGIN_DIR.'/wp-ipip/wp-ipip-options.html';
if (!is_readable($tpl_path)) {
echo 'Cannot read file wp-ipip-options.html at '.getcwd();
return;
}
$tpl = file_get_contents($tpl_path);
$ipip_data_filepath = '/wp-ipip/ipipdotnet/';
$ipip_data_filename = 'ipipfree.ipdb';
$ipip_data_fullpath = WP_PLUGIN_DIR.$ipip_data_filepath.$ipip_data_filename;
if (is_readable($ipip_data_fullpath)) {
$ipip_data_status = '<span style="color: green;">检测到 IPIP.net 数据库文件</span>';
} else {
$ipip_data_status = '<span style="color: red;">未检测到 IPIP.net 数据库文件</span> 于 <code>'.$ipip_data_fullpath.'</code>';
}
$search = ['{{$ipip_data_status}}'];
$replace = [$ipip_data_status];
$echo = str_replace($search, $replace, $tpl);
$search = ['{{$ipip_data_filepath}}'];
$replace = [$ipip_data_filepath];
$echo = str_replace($search, $replace, $echo);
$search = ['{{$ipip_data_filename}}'];
$replace = [$ipip_data_filename];
$echo = str_replace($search, $replace, $echo);
echo $echo;