95 lines
3.6 KiB
PHP
95 lines
3.6 KiB
PHP
<?php
|
|
#注册插件
|
|
RegisterPlugin("zxd_ctrlcenter","ActivePlugin_zxd_ctrlcenter");
|
|
|
|
require ZBP_PATH . 'zb_users/plugin/zxd_ctrlcenter/plugin/404/include.php'; // 404
|
|
require ZBP_PATH . 'zb_users/plugin/zxd_ctrlcenter/plugin/grey/include.php'; // 网站变黑
|
|
require ZBP_PATH . 'zb_users/plugin/zxd_ctrlcenter/plugin/code/include.php'; // 代码显示优化
|
|
require ZBP_PATH . 'zb_users/plugin/zxd_ctrlcenter/plugin/wxreward/include.php'; // 微信打赏
|
|
require ZBP_PATH . 'zb_users/plugin/zxd_ctrlcenter/plugin/spider/include.php'; // 蜘蛛来访
|
|
|
|
function ActivePlugin_zxd_ctrlcenter() {
|
|
// 添加 顶部快捷方式
|
|
Add_Filter_Plugin('Filter_Plugin_Admin_TopMenu','zxd_ctrlcenter_AddMenu');
|
|
|
|
global $zbp;
|
|
if($zbp->Config('zxd_ctrlcenter')-> plugin_404_Enable)
|
|
Add_Filter_Plugin('Filter_Plugin_Zbp_ShowError', 'zxd_ctrlcenter_404'); // 404
|
|
if($zbp->Config('zxd_ctrlcenter')-> plugin_grey_Enable)
|
|
Add_Filter_Plugin('Filter_Plugin_Zbp_MakeTemplatetags','zxd_ctrlcenter_grey'); // 网站变黑
|
|
if($zbp->Config('zxd_ctrlcenter')-> plugin_code_Enable)
|
|
Add_Filter_Plugin('Filter_Plugin_ViewPost_Template', 'zxd_ctrlcenter_code'); // 代码显示优化
|
|
if($zbp->Config('zxd_ctrlcenter')-> plugin_wxreward_Enable) {
|
|
Add_Filter_Plugin('Filter_Plugin_Zbp_MakeTemplatetags','zxd_ctrlcenter_wxreward_js'); // 微信打赏
|
|
Add_Filter_Plugin('Filter_Plugin_ViewPost_Template','zxd_ctrlcenter_wxreward_html');
|
|
}
|
|
if($zbp->Config('zxd_ctrlcenter')-> plugin_spider_Enable){
|
|
Add_Filter_Plugin('Filter_Plugin_Index_End','zxd_ctrlcenter_Index_End'); // 蜘蛛来访 抓取统计
|
|
}
|
|
|
|
// 判断表格是否存在在,如果不存在就创建表
|
|
zxd_ctrlcenter_spider_CreateTable();
|
|
}
|
|
|
|
function InstallPlugin_zxd_ctrlcenter() {
|
|
// 蜘蛛来访
|
|
global $zbp;
|
|
//配置初始化,判断是否是安装插件后第一次启动
|
|
if (!$zbp->Config('zxd_ctrlcenter') -> HasKey('zxd_ctrlcenter_version')) {
|
|
$zbp->Config('zxd_ctrlcenter') -> zxd_ctrlcenter_version = '1.1.1';
|
|
|
|
$zbp->Config('zxd_ctrlcenter') -> plugin_spider_viewconut ='20';
|
|
$zbp->Config('zxd_ctrlcenter') -> plugin_spider_spiders = 'Baiduspider,Baidu|Googlebot,Google|Sosospider,SoSo|YoudaoBot,YouDao|bingbot,Bing|Sogou web spider,SoGou|Yahoo! Slurp,Yahoo|Alexa,Alexa|360Spider,So';
|
|
|
|
$zbp->SaveConfig('zxd_ctrlcenter');
|
|
}
|
|
|
|
// 判断表格是否存在在,如果不存在就创建表
|
|
zxd_ctrlcenter_spider_CreateTable();
|
|
|
|
}
|
|
function UninstallPlugin_zxd_ctrlcenter() {
|
|
// 微信打赏
|
|
// global $zbp;
|
|
// $zbp->DelConfig('zxd_ctrlcenter');
|
|
|
|
// 蜘蛛来访
|
|
// global $zbp;
|
|
// $zbp->DelConfig('SpiderStatistics');
|
|
// zxd_ctrlcenter_spider_DelTable();
|
|
}
|
|
|
|
|
|
// 顶部快捷方式
|
|
function zxd_ctrlcenter_AddMenu(&$m){
|
|
global $zbp;
|
|
$m[]=MakeTopMenu('root', '控制中心', $zbp->host . 'zb_users/plugin/zxd_ctrlcenter/main.php','','topmenu_zxd_ctrlcenter_spider');
|
|
}
|
|
|
|
// 蜘蛛来访
|
|
function zxd_ctrlcenter_Index_End() {
|
|
global $zbp;
|
|
$array = array();
|
|
$agent = null;
|
|
$status = null;
|
|
$url = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
|
|
$ip = GetGuestIP();
|
|
$datetime = time();
|
|
|
|
$spiders = explode('|', $zbp->Config('zxd_ctrlcenter') -> plugin_spider_spiders);
|
|
|
|
foreach ($spiders as $key => $spider) {
|
|
$spidername = explode(',', $spider);
|
|
if(strpos(GetGuestAgent(), $spidername[0]) !== false) {
|
|
$agent = $spidername[1];
|
|
break;
|
|
}
|
|
}
|
|
|
|
if($url && $agent) {
|
|
$array = array('Spider_Name' => $agent, 'Spider_IP' => $ip, 'Spider_DateTime' => $datetime, 'Spider_Url' => $url, 'Spider_Status' => 200);
|
|
|
|
$sql = $zbp->db->sql->Insert($zbp->table['zxd_ctrlcenter_spider'], $array);
|
|
$zbp->db->Insert($sql);
|
|
}
|
|
} |