<?php /** @var string $seg */
$phpVer   = phpversion();
$sapi     = php_sapi_name();
$dbDriver = \Core\Db::driver();
$dbVer    = $dbDriver === 'mysql' ? \Core\Db::pdo()->query("SELECT VERSION()")->fetchColumn() : '—';
$tz       = date_default_timezone_get();
$storageWritable = is_writable(BASE_PATH . '/storage');
$uploadWritable  = is_writable(BASE_PATH . '/public/uploads');
$installed = \Core\Installer::isInstalled();
$info = [
    'PHP 版本'     => $phpVer,
    '运行模式'     => $sapi,
    '数据库驱动'   => $dbDriver === 'mysql' ? 'MySQL' : $dbDriver,
    '数据库版本'   => $dbVer,
    '系统时区'     => $tz,
    '站点已安装'   => $installed ? '是' : '否',
    '根目录'       => BASE_PATH,
    '存储目录可写' => $storageWritable ? '✓ 可写' : '✗ 不可写',
    '上传目录可写' => $uploadWritable ? '✓ 可写' : '✗ 不可写',
];
?>
<div class="page-head">
  <div><h1>系统设置</h1><div class="desc">查看运行环境与数据库维护入口。</div></div>
</div>

<div class="admin-card">
  <h3 class="card-title">运行环境</h3>
  <table class="tbl tbl-info">
    <tbody>
      <?php foreach ($info as $k => $v): ?>
        <tr><th><?php echo e($k); ?></th><td class="mono"><?php echo e($v); ?></td></tr>
      <?php endforeach; ?>
    </tbody>
  </table>
</div>

<div class="shortcut-grid">
  <a class="shortcut-card" href="<?php echo site_url('admin/db'); ?>">
    <span class="shortcut-ic"><?php echo admin_icon('database', 26); ?></span>
    <span class="shortcut-title">数据库管理</span>
    <span class="shortcut-desc">查看并编辑所有表的数据</span>
  </a>
  <a class="shortcut-card" href="<?php echo site_url('admin/upgrade'); ?>">
    <span class="shortcut-ic"><?php echo admin_icon('upload', 26); ?></span>
    <span class="shortcut-title">数据库升级</span>
    <span class="shortcut-desc">执行升级包并留痕记录</span>
  </a>
</div>
