<?php
$pathInfo = $_SERVER['REQUEST_URI'];
$pathInfo = preg_replace('/^\/news\//', '', $pathInfo);
$pathInfo = str_replace('.html', '', $pathInfo);

if (preg_match('/(\d+)$/', $pathInfo, $matches)) {
    $id = intval($matches[1]);
} else {
    echo '文章不存在'; die;
}
if ($id <= 0) { echo '文章不存在'; die; }

$mysqli = @new mysqli('pc-bp1l53cgat7izo2zn.rwlb.rds.aliyuncs.com:3306', 'kol98347', 'Wzy785859', 'kol34iu4');
if (!$mysqli || $mysqli->connect_error) { echo '系统错误'; die; }

$stmt = $mysqli->prepare("SELECT title, content, create_time, cover_url FROM tlk_news WHERE status=1 AND id=?");
$stmt->bind_param("i", $id);
$stmt->execute();
$stmt->bind_result($r_title, $r_content, $r_ct, $r_cover);
if (!$stmt->fetch()) { echo '文章不存在'; die; }

$__host = '//www.jinsiwei.com';
$__fix = function($s) use ($__host){ $s=preg_replace('#https?://daren\.huacaicn\.com#i',$__host,(string)$s); if(strpos($s,'../')!==false) $s=$__host.'/'.ltrim(str_replace(['../../','../'],'',$s),'/'); return $s; };
$__ct = preg_replace('#https?://daren\.huacaicn\.com#i',$__host,(string)$r_content);
$__ct = str_replace(['../../uploads','../uploads'],$__host.'/uploads',$__ct);
$data = [
    'title' => $r_title,
    'create_time' => date("Y-m-d", (int)$r_ct),
    'cover' => $__fix($r_cover),
    'content' => $__ct
];
$stmt->close();
$mysqli->close();
?>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title><?php echo htmlspecialchars($data['title']); ?> - 庆趣新闻</title>
  <link rel="stylesheet" href="/style.css">
  <link rel="preconnect" href="https://fonts.googleapis.com">
  <link href="https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@300;400;500;600;700;900&display=swap" rel="stylesheet">
</head>
<body>
  <nav class="navbar" id="navbar">
    <div class="container nav-container">
      <a href="/index.html" class="logo"><img src="/images/newlogo.png" alt="大庆金思维" class="logo-img"><span class="logo-name">大庆金思维</span><span class="logo-cert">国家级高新技术企业认证</span></a>
      <button class="nav-toggle" id="navToggle" aria-label="菜单"><span></span><span></span><span></span></button>
      <ul class="nav-links" id="navLinks">
        <li><a href="/index.html">首页</a></li>
        <li><a href="/intro.html">企业介绍</a></li>
        <li><a href="/qingqu.html">庆趣成人</a></li>
        <li><a href="/dede.html">嘚嘚象</a></li>
        <li><a href="/quhaom.html">趣好卖</a></li>
        <li><a href="/stores.html">客户案例</a></li>
        <li><a href="/agent.html">代理合作</a></li>
        <li><a href="/news.html" class="active-link">新闻中心</a></li>
        <li><a href="/contact.html">联系我们</a></li>
      </ul>
    </div>
  </nav>
  <section class="page-hero page-hero-news" style="padding:90px 0 20px">
    <div class="container">
      <div class="breadcrumb"><a href="/index.html">首页</a><svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M9 18l6-6-6-6"/></svg><a href="/news.html">新闻中心</a><svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M9 18l6-6-6-6"/></svg><span>详情</span></div>
    </div>
  </section>
  <section class="section" style="padding-top:40px">
    <div class="container" style="max-width:800px">
      <h1 style="font-size:1.6rem;font-weight:700;margin-bottom:10px;line-height:1.4"><?php echo htmlspecialchars($data['title']); ?></h1>
      <p style="font-size:.82rem;color:#86868b;margin-bottom:24px"><?php echo $data['create_time']; ?></p>
      <?php if (!empty($data['cover'])): ?><img src="<?php echo htmlspecialchars($data['cover']); ?>" alt="<?php echo htmlspecialchars($data['title']); ?>" style="width:100%;border-radius:10px;margin-bottom:24px;display:block" onerror="this.style.display='none'"><?php endif; ?>
      <div class="article-body" style="font-size:.95rem;color:#333;line-height:2"><?php echo $data['content']; ?></div>
      <div style="text-align:center;margin-top:40px"><a href="/news.html" class="btn btn-ghost"><svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M19 12H5M12 19l-7-7 7-7"/></svg> 返回新闻列表</a></div>
    </div>
  </section>
  <footer class="footer"><div class="container"><div class="footer-bottom"><p>Copyright &copy; 2017-2026 EQINGQU.COM. 大庆金思维 版权所有</p><p>Powered by eqingqu.com &nbsp; <a href="https://beian.miit.gov.cn/" target="_blank" style="color:inherit">黑ICP备11005751号-24</a></p></div></div></footer>
  <script src="/script.js"></script>
</body>
</html>
