initialize(); $host = $_SERVER['HTTP_HOST'] ?? ''; $scheme = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on') ? 'https' : 'http'; $baseUrl = $scheme . '://' . $host; $themeBase = '/themes/default'; function formatImageUrl($path, $baseUrl) { if (empty($path)) return ''; if (preg_match('/^https?:\/\//', $path)) return $path; return $baseUrl . (strpos($path, '/') === 0 ? '' : '/') . $path; } function stripHtmlText($html) { if (empty($html)) return ''; $text = preg_replace('/<[^>]+>/', ' ', $html); $text = preg_replace('/\s+/', ' ', $text); return trim($text); } $page = isset($_GET['page']) ? (int)$_GET['page'] : 1; if ($page < 1) $page = 1; $pageSize = 10; try { $tenantDomain = Db::name('mete_tenant_domain') ->where('full_domain', $host) ->where('status', 1) ->whereNull('delete_time') ->find(); $tid = $tenantDomain ? (int)$tenantDomain['tid'] : 0; if ($tid === 0) { die("未找到相关内容"); } $setting = Db::name('mete_system_site_setting')->where('tid', $tid)->whereNull('delete_time')->find(); $tenant = Db::name('mete_tenant')->where('id', $tid)->whereNull('delete_time')->find(); $siteInfo = array_merge($tenant ?: [], $setting ?: []); $baseQuery = Db::name('mete_articles') ->where('tid', $tid) ->whereNull('delete_time'); // 如果存在 status 字段,通常用 2 表示已发布;不存在也不影响(交给数据库报错会影响页面) // 为避免因不同库结构导致报错,这里不强依赖 status 过滤。 $total = (int)$baseQuery->count(); $totalPages = (int)max(1, ceil($total / $pageSize)); if ($page > $totalPages) $page = $totalPages; $offset = ($page - 1) * $pageSize; $articles = $baseQuery ->order('publish_date', 'desc') ->limit($offset, $pageSize) ->select() ->toArray(); } catch (\Exception $e) { die("系统错误: " . $e->getMessage()); } ?> <?php echo htmlspecialchars(($siteInfo['sitename'] ?? '') ?: '新闻中心'); ?>

新闻中心

最新动态与行业资讯,持续更新。

暂无文章
120) $desc = mb_substr($desc, 0, 120) . '…'; $thumb = $a['thumb'] ?? ($a['image'] ?? ''); $thumbUrl = $thumb ? formatImageUrl($thumb, $baseUrl) : ''; $id = (int)($a['id'] ?? 0); ?>