'站长论坛', 'seo_title' => '站长论坛 - 网站运营推广、SEO优化、建站技术与站长交流社区', 'seo_keywords' => '站长论坛交流社区,个人站长建站经验分享,网站SEO优化长尾词策略,网站运营推广实战教程,服务器运维与网站安全交流,网站流量变现与广告合作,域名主机建站问题答疑,站长工具资源分享平台', 'seo_description' => '站长论坛面向个人站长、网站运营者和建站开发者,提供网站SEO优化、网站运营推广、域名主机选择、服务器运维安全、流量变现、广告合作、站长工具资源与建站问题答疑交流。' ); if (!function_exists('chuan_theme_clean_seo_title')) { function chuan_theme_clean_seo_title($title, $conf_sitename, $theme_sitename, $seo_title) { $title = trim(strip_tags((string)$title)); $remove = array_filter(array($conf_sitename, 'Xiuno BBS', 'Site Brief', $theme_sitename, $seo_title)); foreach ($remove as $name) { $name = trim((string)$name); if ($name === '') continue; $patterns = array( ' - '.$name, '-'.$name, '_'.$name, '_'.$name, $name.' - ', $name.'-', $name.'_', $name ); foreach ($patterns as $pattern) { $title = str_replace($pattern, '', $title); } } $title = trim(preg_replace('/[\s\-_]+$/u', '', $title)); return trim($title); } } $seo_title = trim($chuan_theme_seo['seo_title']); $seo_keywords = trim($chuan_theme_seo['seo_keywords']); $seo_description = trim($chuan_theme_seo['seo_description']); if ($seo_title !== '') { if ($route == 'index' || empty($header['title'])) { $header['title'] = $seo_title; } else { $page_title = chuan_theme_clean_seo_title($header['title'], array_value($conf, 'sitename', ''), $chuan_theme_seo['sitename'], $seo_title); $header['title'] = $page_title === '' ? $seo_title : $page_title.' - '.$seo_title; } } if ($seo_keywords !== '') { $header['keywords'] = $seo_keywords; } if ($seo_description !== '') { $page_description = trim(strip_tags(array_value($header, 'description', ''))); if ($route == 'index' || $page_description === '' || $page_description == array_value($conf, 'sitebrief', '') || $page_description == 'Site Brief') { $header['description'] = $seo_description; } elseif (strpos($page_description, $seo_description) === false) { $header['description'] = $page_description.','.$seo_description; } } if(!function_exists('chuan_plugin_is_on')) { function chuan_plugin_is_on($dir) { static $chuan_plugins_status = array(); if(isset($chuan_plugins_status[$dir])) return $chuan_plugins_status[$dir]; if(function_exists('plugin_paths_enabled')) { $plugins = plugin_paths_enabled(); $path = APP_PATH.'plugin/'.$dir; $res = !empty($plugins[$path]) && !empty($plugins[$path]['enable']); } else { $plugins = G('plugins', array()); $res = !empty($plugins[$dir]) && !empty($plugins[$dir]['enable']); } $chuan_plugins_status[$dir] = $res; return $res; } } // Global cache setup if (!isset($GLOBALS['chuan_theme_cache'])) { $GLOBALS['chuan_theme_cache'] = array( 'plugins' => array(), 'merchants' => array(), 'equipped_badges' => array(), 'badges' => array(), 'v_settings' => null, 'user_profiles' => array(), ); } // Table creation check run exactly once if (!kv_get('chuan_theme_installed')) { db_exec("CREATE TABLE IF NOT EXISTS bbs_chuan_thread_favorite ( id int(11) unsigned NOT NULL AUTO_INCREMENT, uid int(11) unsigned NOT NULL DEFAULT 0, tid int(11) unsigned NOT NULL DEFAULT 0, create_date int(11) unsigned NOT NULL DEFAULT 0, PRIMARY KEY (id), UNIQUE KEY uid_tid (uid, tid) ) ENGINE=MyISAM DEFAULT CHARSET=utf8"); db_exec("CREATE TABLE IF NOT EXISTS bbs_chuan_thread_charge ( id int(11) unsigned NOT NULL AUTO_INCREMENT, uid int(11) unsigned NOT NULL DEFAULT 0, touid int(11) unsigned NOT NULL DEFAULT 0, tid int(11) unsigned NOT NULL DEFAULT 0, amount int(11) NOT NULL DEFAULT 0, create_date int(11) unsigned NOT NULL DEFAULT 0, PRIMARY KEY (id), KEY tid (tid) ) ENGINE=MyISAM DEFAULT CHARSET=utf8"); db_exec("CREATE TABLE IF NOT EXISTS bbs_chuan_thread_like ( id int(11) unsigned NOT NULL AUTO_INCREMENT, uid int(11) unsigned NOT NULL DEFAULT 0, tid int(11) unsigned NOT NULL DEFAULT 0, create_date int(11) unsigned NOT NULL DEFAULT 0, PRIMARY KEY (id), UNIQUE KEY uid_tid (uid, tid) ) ENGINE=MyISAM DEFAULT CHARSET=utf8"); kv_set('chuan_theme_installed', 1); } if (!function_exists('chuan_theme_username_html')) { function chuan_theme_username_html($uid, $username) { global $chuan_theme_cache; if (!isset($chuan_theme_cache)) $chuan_theme_cache = array(); $html = function_exists('chuan_vip_username_html') ? chuan_vip_username_html($uid, $username) : xn_html_safe($username); $user_row = user_read_cache($uid); if (!isset($chuan_theme_cache['plugins'])) $chuan_theme_cache['plugins'] = array(); if (!isset($chuan_theme_cache['plugins']['Chuan_prison'])) { $chuan_theme_cache['plugins']['Chuan_prison'] = chuan_plugin_is_on('Chuan_prison'); } if (!isset($chuan_theme_cache['plugins']['Chuan_merchant_stately'])) { $chuan_theme_cache['plugins']['Chuan_merchant_stately'] = chuan_plugin_is_on('Chuan_merchant_stately'); } if (!isset($chuan_theme_cache['plugins']['Chuan_v_apply'])) { $chuan_theme_cache['plugins']['Chuan_v_apply'] = chuan_plugin_is_on('Chuan_v_apply'); } if (!isset($chuan_theme_cache['plugins']['Chuan_badge'])) { $chuan_theme_cache['plugins']['Chuan_badge'] = chuan_plugin_is_on('Chuan_badge'); } $prison_on = $chuan_theme_cache['plugins']['Chuan_prison']; $merchant_on = $chuan_theme_cache['plugins']['Chuan_merchant_stately']; $v_apply_on = $chuan_theme_cache['plugins']['Chuan_v_apply']; $badge_on = $chuan_theme_cache['plugins']['Chuan_badge']; if ($prison_on && $user_row && intval($user_row['gid']) === 7) { $html .= ' 禁闭中'; } // Add merchant badge if successfully approved $timeers = time(); if($merchant_on) { if (!isset($chuan_theme_cache['merchants'])) $chuan_theme_cache['merchants'] = array(); if(!isset($chuan_theme_cache['merchants'][$uid])) { $chuan_theme_cache['merchants'][$uid] = db_find_one('merchant', array('uid' => $uid, 'status' => 2)); } $merchant = $chuan_theme_cache['merchants'][$uid]; if (!empty($merchant) && $merchant['endtime'] > $timeers) { $html .= ' 商家'; } } // Verified member badge (username nearby) logic $v_level = ($user_row && !empty($user_row['v'])) ? intval($user_row['v']) : 0; if ($v_apply_on && $v_level > 0) { if (!isset($chuan_theme_cache['v_settings'])) { $chuan_theme_cache['v_settings'] = setting_get('till_verified_member_setting'); } $settings = $chuan_theme_cache['v_settings']; if (!empty($settings)) { global $route, $thread; $show_badge = false; if ($route == 'index' || $route == 'forum') { $show_badge = !empty($settings['v_show_thread_list_inc_username_before']); } elseif ($route == 'user') { $show_badge = !empty($settings['v_show_user_profile_username_after']); } elseif ($route == 'my') { $show_badge = !empty($settings['v_show_my_common_username_after']); } elseif ($route == 'thread') { if (!empty($thread) && $uid == $thread['uid']) { $show_badge = !empty($settings['v_show_thread_username_before']) || !empty($settings['v_show_thread_user_username_after']); } else { $show_badge = !empty($settings['v_show_post_list_inc_username_after']); } } else { $show_badge = !empty($settings['v_show_header_nav_username_after']); } if ($show_badge) { if (!function_exists('v_show_badge')) { include_once _include(APP_PATH . 'plugin/Chuan_v_apply/model/v.func.php'); } if (function_exists('v_show_badge')) { $badge_html = v_show_badge($v_level, $user_row['v_title'], $settings); if (!empty($badge_html)) { $html .= ' ' . $badge_html; } } } } } if($badge_on) { if(!function_exists('chuan_badge_equipped_html') && is_file(APP_PATH.'plugin/Chuan_badge/model/chuan_badge.func.php')) { include_once _include(APP_PATH.'plugin/Chuan_badge/model/chuan_badge.func.php'); } if(function_exists('chuan_badge_equipped_html')) { $html .= chuan_badge_equipped_html($uid); } } return $html; } } if (!function_exists('chuan_theme_avatar_html')) { function chuan_theme_avatar_html($uid, $avatar_url, $img_class = 'w-10 h-10 rounded-xl object-cover') { global $chuan_theme_cache; if (!isset($chuan_theme_cache)) $chuan_theme_cache = array(); $user_row = user_read_cache($uid); if (!isset($chuan_theme_cache['plugins'])) $chuan_theme_cache['plugins'] = array(); if (!isset($chuan_theme_cache['plugins']['Chuan_prison'])) { $chuan_theme_cache['plugins']['Chuan_prison'] = chuan_plugin_is_on('Chuan_prison'); } if (!isset($chuan_theme_cache['plugins']['Chuan_v_apply'])) { $chuan_theme_cache['plugins']['Chuan_v_apply'] = chuan_plugin_is_on('Chuan_v_apply'); } $prison_on = $chuan_theme_cache['plugins']['Chuan_prison']; $v_apply_on = $chuan_theme_cache['plugins']['Chuan_v_apply']; $is_banned = $prison_on && $user_row && intval($user_row['gid']) === 7; $img_style = $is_banned ? 'filter: grayscale(100%) opacity(0.7);' : ''; $html = '
'; $html .= ''; $v_level = ($user_row && !empty($user_row['v'])) ? intval($user_row['v']) : 0; if ($v_apply_on && $v_level > 0) { if (!isset($chuan_theme_cache['v_settings'])) { $chuan_theme_cache['v_settings'] = setting_get('till_verified_member_setting'); } $settings = $chuan_theme_cache['v_settings']; if (!empty($settings)) { global $route, $thread; $show_badge = false; if ($route == 'index' || $route == 'forum') { $show_badge = !empty($settings['v_show_thread_list_inc_avatar_after']); } elseif ($route == 'user') { $show_badge = !empty($settings['v_show_user_profile_avatar_after']); } elseif ($route == 'my') { $show_badge = !empty($settings['v_show_my_common_avatar_after']); } elseif ($route == 'thread') { if (!empty($thread) && $uid == $thread['uid']) { $show_badge = !empty($settings['v_show_thread_user_avatar_after']); } else { $show_badge = !empty($settings['v_show_post_list_inc_avatar_after']); } } else { $show_badge = false; } if ($show_badge) { if (!function_exists('v_show_badge')) { include_once _include(APP_PATH . 'plugin/Chuan_v_apply/model/v.func.php'); } if (function_exists('v_show_badge')) { $badge_html = v_show_badge($v_level, $user_row['v_title'], $settings); if (!empty($badge_html)) { $html .= '
'; $html .= $badge_html; $html .= '
'; } } } } } $html .= '
'; return $html; } } ?>