<?php
/**
 * 芋头CMS
 * ============================================================================
 * 版权所有 2016-2028 沅陵县乌托邦网络服务有限公司，并保留所有权利。
 * 网站地址: http://www.yutoucms.cn
 * ----------------------------------------------------------------------------
 * 如果商业用途务必到官方购买正版授权, 以免引起不必要的法律纠纷。
 * ============================================================================
 * Author: 芋头 <mxgsf@qq.com>
 * Date: 2026-5-30
 */
if (!defined('ROOT_PATH')) { exit('Access Denied'); }

$footerGroups = [];
foreach ($topChannels as $ch) {
    $subs = $db->fetchAll("SELECT * FROM {$db->table('channel')} WHERE parent_id = ? AND is_show = 1 ORDER BY list_order ASC, id ASC LIMIT 6", [$ch['id']]);
    $footerGroups[] = ['channel' => $ch, 'subs' => $subs];
}
?>
<div class="h50"></div>
<div class="bg_footer">
  <div class="jz footer">
    <div class="fl">
      <h1><?php echo htmlspecialchars($siteName); ?></h1>
      <h5><?php echo htmlspecialchars(mb_substr(trim(strip_tags($siteCompany ?: $siteDescription)), 0, 80)); ?></h5>
      <form method="get" action="<?php echo getUrl('search'); ?>">
        <input type="hidden" name="m" value="search">
        <input type="text" name="keyword" placeholder="请输入关键字">
        <input type="submit" value="搜索">
      </form>
    </div>
    <div class="fr">
      <?php foreach (array_slice($footerGroups, 0, 3) as $group): ?>
      <div class="left">
        <ul>
          <h6><?php echo htmlspecialchars($group['channel']['channel_name']); ?></h6>
          <?php if ($group['subs']): ?>
            <?php foreach ($group['subs'] as $sub): ?>
            <li><a href="<?php echo getUrl('channel', $sub['id'], $sub['channel_dir'] ?? ''); ?>"><?php echo htmlspecialchars($sub['channel_name']); ?></a></li>
            <?php endforeach; ?>
          <?php else: ?>
            <li><a href="<?php echo getUrl('channel', $group['channel']['id'], $group['channel']['channel_dir'] ?? ''); ?>">查看更多</a></li>
          <?php endif; ?>
        </ul>
      </div>
      <?php endforeach; ?>
      <div class="right">
        <ul>
          <h6>联系我们</h6>
          <?php if ($sitePhone || $siteMobile): ?><li>电话：<?php echo htmlspecialchars($sitePhone ?: $siteMobile); ?></li><?php endif; ?>
          <?php if (!empty($siteConfig['site_email'])): ?><li>邮箱：<?php echo htmlspecialchars($siteConfig['site_email']); ?></li><?php endif; ?>
          <?php if ($siteAddress): ?><li>地址：<?php echo htmlspecialchars($siteAddress); ?></li><?php endif; ?>
        </ul>
        <div class="ewm">
          <?php if (!empty($customQr) && preg_match('/\.(jpg|jpeg|png|gif|webp|svg)(\?.*)?$/i', $customQr)): ?>
            <img src="<?php echo htmlspecialchars($customQr); ?>" alt="二维码">
          <?php else: ?>
            <?php echo htmlspecialchars($customQr); ?>
          <?php endif; ?>
        </div>
      </div>
    </div>
  </div>
  <div class="db_footer">
    <div class="jz">
      <p>
        Copyright © <?php echo date('Y'); ?> <?php echo htmlspecialchars($siteName); ?> 版权所有
        <?php if (!empty($siteConfig['site_icp'])): ?>
        &nbsp;&nbsp;<?php echo htmlspecialchars($siteConfig['site_icp']); ?>
        <?php endif; ?>
        &nbsp;&nbsp;Powered by <a href="http://www.yutoucms.cn/" target="_blank">芋头CMS</a>
      </p>
    </div>
  </div>
</div>
<script src="<?php echo $site['template_dir']; ?>skin/js/jquery.min.js"></script>
<script src="<?php echo $site['template_dir']; ?>skin/js/amazeui.min.js"></script>
<script src="<?php echo $site['template_dir']; ?>skin/js/layer.js"></script>
</body>
</html>
