526 lines
33 KiB
PHP
526 lines
33 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
require __DIR__ . '/bootstrap.php';
|
|
|
|
$config = load_config();
|
|
$fontStack = font_stack_css($config['theme']['admin_font_stack'] ?? 'sans');
|
|
|
|
if (isset($_GET['delete_asset']) && in_array($_GET['delete_asset'], ['favicon', 'apple_touch_icon', 'og_image', 'sidebar_logo'], true)) {
|
|
$token = $_GET['csrf_token'] ?? '';
|
|
$sessionToken = $_SESSION['csrf_token'] ?? '';
|
|
if ($token === '' || !is_string($sessionToken) || !hash_equals($sessionToken, $token)) {
|
|
http_response_code(403);
|
|
exit('Invalid CSRF token.');
|
|
}
|
|
|
|
$asset = $_GET['delete_asset'];
|
|
if (isset($config['assets'][$asset])) {
|
|
$assetPath = $config['assets'][$asset];
|
|
if ($assetPath !== '') {
|
|
$filePath = PUREBLOG_BASE_PATH . $assetPath;
|
|
if (file_exists($filePath)) {
|
|
if (validate_image_path(PUREBLOG_CONTENT_IMAGES_PATH, $filePath)) {
|
|
@unlink($filePath);
|
|
}
|
|
}
|
|
}
|
|
unset($config['assets'][$asset]);
|
|
if (save_config($config)) {
|
|
$_SESSION['admin_action_flash'] = ['ok' => true, 'message' => t('admin.settings.site.notice_updated')];
|
|
} else {
|
|
$_SESSION['admin_action_flash'] = ['ok' => false, 'message' => t('admin.settings.site.error_save')];
|
|
}
|
|
}
|
|
header('Location: ' . base_path() . '/admin/settings-site.php');
|
|
exit;
|
|
}
|
|
|
|
$errors = [];
|
|
$notice = '';
|
|
$hiddenBlogValue = '__hidden__';
|
|
$pages = get_all_pages(true);
|
|
$pageOptions = array_values(array_filter($pages, fn($page) => ($page['slug'] ?? '') !== ''));
|
|
$pageSlugLookup = array_fill_keys(array_map(fn($page) => $page['slug'], $pageOptions), true);
|
|
|
|
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['download_backup'])) {
|
|
verify_csrf();
|
|
$backupResult = create_site_backup_zip();
|
|
if ($backupResult['ok'] ?? false) {
|
|
$zipPath = (string) $backupResult['path'];
|
|
$zipName = (string) $backupResult['filename'];
|
|
try {
|
|
while (ob_get_level() > 0) {
|
|
ob_end_clean();
|
|
}
|
|
header('Content-Type: application/zip');
|
|
header('Content-Disposition: attachment; filename="' . $zipName . '"');
|
|
header('Content-Length: ' . (string) filesize($zipPath));
|
|
header('Cache-Control: no-store, no-cache, must-revalidate');
|
|
readfile($zipPath);
|
|
} finally {
|
|
@unlink($zipPath);
|
|
}
|
|
exit;
|
|
}
|
|
$errors[] = (string) ($backupResult['error'] ?? t('admin.settings.site.error_backup_zip'));
|
|
}
|
|
|
|
if ($_SERVER['REQUEST_METHOD'] === 'POST' && !isset($_POST['admin_action_id']) && !isset($_POST['download_backup'])) {
|
|
verify_csrf();
|
|
$siteTitle = trim($_POST['site_title'] ?? '');
|
|
$siteTagline = trim($_POST['site_tagline'] ?? '');
|
|
$siteDescription = trim($_POST['site_description'] ?? '');
|
|
$siteEmail = trim($_POST['site_email'] ?? '');
|
|
$customNav = trim($_POST['custom_nav'] ?? '');
|
|
$customNavOnly = !empty($_POST['custom_nav_only']);
|
|
$customRoutes = trim($_POST['custom_routes'] ?? '');
|
|
$headInjectPage = trim($_POST['head_inject_page'] ?? '');
|
|
$headInjectPost = trim($_POST['head_inject_post'] ?? '');
|
|
$footerInjectPage = trim($_POST['footer_inject_page'] ?? '');
|
|
$footerInjectPost = trim($_POST['footer_inject_post'] ?? '');
|
|
$postsPerPage = (int) ($_POST['posts_per_page'] ?? 20);
|
|
$searchExcerptLength = max(0, (int) ($_POST['search_excerpt_length'] ?? 2500));
|
|
$searchIncludePages = !empty($_POST['search_include_pages']);
|
|
$language = trim($_POST['language'] ?? '');
|
|
$timezone = trim($_POST['timezone'] ?? '');
|
|
$dateFormat = trim($_POST['date_format'] ?? '');
|
|
$baseUrl = trim($_POST['base_url'] ?? '');
|
|
$homepageSlug = trim($_POST['homepage_slug'] ?? '');
|
|
$blogPageSlug = trim($_POST['blog_page_slug'] ?? '');
|
|
$searchPageSlug = trim($_POST['search_page_slug'] ?? '');
|
|
$ogImagePreferred = trim($_POST['og_image_preferred'] ?? 'banner');
|
|
$showReadingTime = !empty($_POST['show_reading_time']);
|
|
$cacheEnabled = !empty($_POST['cache_enabled']);
|
|
$rssttl = max(0, (int) ($_POST['rss_ttl'] ?? 3600));
|
|
$adminHomepage = in_array($_POST['admin_homepage'] ?? '', ['dashboard', 'content'], true) ? $_POST['admin_homepage'] : 'dashboard';
|
|
$adminHideDashboard = $adminHomepage === 'content' && !empty($_POST['admin_hide_dashboard']);
|
|
$enableBlogPosts = ($blogPageSlug === $hiddenBlogValue) ? !empty($_POST['enable_blog_posts']) : true;
|
|
$purecommentsEnabled = !empty($_POST['purecomments_enabled']);
|
|
$purecommentsUrl = trim($_POST['purecomments_url'] ?? '');
|
|
$purecommentsAutoload = !empty($_POST['purecomments_autoload']);
|
|
|
|
if ($siteTitle === '') {
|
|
$errors[] = t('admin.settings.site.error_title');
|
|
}
|
|
|
|
if ($postsPerPage < 1 || $postsPerPage > 100) {
|
|
$errors[] = t('admin.settings.site.error_posts_per_page');
|
|
}
|
|
if ($timezone === '' || !in_array($timezone, DateTimeZone::listIdentifiers(), true)) {
|
|
$errors[] = t('admin.settings.site.error_timezone');
|
|
}
|
|
if ($dateFormat === '') {
|
|
$errors[] = t('admin.settings.site.error_date_format');
|
|
}
|
|
|
|
if ($homepageSlug !== '' && !isset($pageSlugLookup[$homepageSlug])) {
|
|
$errors[] = t('admin.settings.site.error_homepage');
|
|
}
|
|
|
|
if ($blogPageSlug !== '' && $blogPageSlug !== $hiddenBlogValue && !isset($pageSlugLookup[$blogPageSlug])) {
|
|
$errors[] = t('admin.settings.site.error_blog_page');
|
|
}
|
|
if ($searchPageSlug !== '' && !isset($pageSlugLookup[$searchPageSlug])) {
|
|
$errors[] = t('admin.settings.site.error_search_page');
|
|
}
|
|
if (!in_array($ogImagePreferred, ['banner', 'square'], true)) {
|
|
$errors[] = t('admin.settings.site.error_og_format');
|
|
}
|
|
|
|
if ($purecommentsEnabled) {
|
|
if ($purecommentsUrl === '') {
|
|
$errors[] = t('admin.settings.site.error_purecomments_url');
|
|
} elseif (!filter_var($purecommentsUrl, FILTER_VALIDATE_URL)) {
|
|
$errors[] = t('admin.settings.site.error_purecomments_url_invalid');
|
|
}
|
|
}
|
|
|
|
if (!$errors) {
|
|
$config['site_title'] = $siteTitle;
|
|
$config['site_tagline'] = $siteTagline;
|
|
$config['site_description'] = $siteDescription;
|
|
$config['site_email'] = $siteEmail;
|
|
$config['custom_nav'] = $customNav;
|
|
$config['custom_nav_only'] = $customNavOnly;
|
|
$config['custom_routes'] = $customRoutes;
|
|
$config['head_inject_page'] = $headInjectPage;
|
|
$config['head_inject_post'] = $headInjectPost;
|
|
$config['footer_inject_page'] = $footerInjectPage;
|
|
$config['footer_inject_post'] = $footerInjectPost;
|
|
$config['posts_per_page'] = $postsPerPage;
|
|
$config['search_excerpt_length'] = $searchExcerptLength;
|
|
$config['search_include_pages'] = $searchIncludePages;
|
|
$config['language'] = $language !== '' ? $language : 'en';
|
|
$config['timezone'] = $timezone;
|
|
$config['date_format'] = $dateFormat;
|
|
$config['show_reading_time'] = $showReadingTime;
|
|
$config['base_url'] = $baseUrl;
|
|
$config['homepage_slug'] = $homepageSlug;
|
|
$config['blog_page_slug'] = $blogPageSlug;
|
|
$config['search_page_slug'] = $searchPageSlug;
|
|
$config['cache']['enabled'] = $cacheEnabled;
|
|
$config['cache']['rss_ttl'] = $rssttl;
|
|
$config['admin_homepage'] = $adminHomepage;
|
|
$config['admin_hide_dashboard'] = $adminHideDashboard;
|
|
$config['enable_blog_posts'] = $enableBlogPosts;
|
|
$config['community']['purecomments_enabled'] = $purecommentsEnabled;
|
|
$config['community']['purecomments_url'] = rtrim($purecommentsUrl, '/');
|
|
$config['community']['purecomments_autoload'] = $purecommentsAutoload;
|
|
|
|
if (!isset($config['assets'])) {
|
|
$config['assets'] = ['favicon' => '', 'apple_touch_icon' => '', 'og_image' => '', 'og_image_preferred' => 'banner', 'sidebar_logo' => ''];
|
|
}
|
|
$config['assets']['og_image_preferred'] = $ogImagePreferred;
|
|
|
|
$assetDir = PUREBLOG_CONTENT_IMAGES_PATH;
|
|
if (!is_dir($assetDir)) {
|
|
mkdir($assetDir, 0755, true);
|
|
}
|
|
|
|
$allowedImageTypes = ['image/jpeg', 'image/png', 'image/gif', 'image/webp', 'image/avif'];
|
|
$finfo = new finfo(FILEINFO_MIME_TYPE);
|
|
|
|
if (!empty($_FILES['favicon']['name']) && $_FILES['favicon']['error'] === UPLOAD_ERR_OK) {
|
|
$mimeType = $finfo->file($_FILES['favicon']['tmp_name']) ?: '';
|
|
if (in_array($mimeType, $allowedImageTypes, true)) {
|
|
$name = basename($_FILES['favicon']['name']);
|
|
$name = strtolower($name);
|
|
$name = preg_replace('/[^a-z0-9._-]/', '-', $name) ?? $name;
|
|
$name = preg_replace('/-+/', '-', $name) ?? $name;
|
|
$name = trim($name, '-');
|
|
if ($name !== '') {
|
|
$dest = $assetDir . '/' . $name;
|
|
if (move_uploaded_file($_FILES['favicon']['tmp_name'], $dest)) {
|
|
$config['assets']['favicon'] = '/content/images/' . $name;
|
|
}
|
|
}
|
|
} else {
|
|
$errors[] = t('admin.editor.error_upload_type');
|
|
}
|
|
}
|
|
|
|
if (!empty($_FILES['apple_touch_icon']['name']) && $_FILES['apple_touch_icon']['error'] === UPLOAD_ERR_OK) {
|
|
$mimeType = $finfo->file($_FILES['apple_touch_icon']['tmp_name']) ?: '';
|
|
if ($mimeType === 'image/png') {
|
|
$name = basename($_FILES['apple_touch_icon']['name']);
|
|
$name = strtolower($name);
|
|
$name = preg_replace('/[^a-z0-9._-]/', '-', $name) ?? $name;
|
|
$name = preg_replace('/-+/', '-', $name) ?? $name;
|
|
$name = trim($name, '-');
|
|
if ($name !== '') {
|
|
$dest = $assetDir . '/' . $name;
|
|
if (move_uploaded_file($_FILES['apple_touch_icon']['tmp_name'], $dest)) {
|
|
$config['assets']['apple_touch_icon'] = '/content/images/' . $name;
|
|
}
|
|
}
|
|
} else {
|
|
$errors[] = t('admin.settings.site.error_apple_touch_icon_type');
|
|
}
|
|
}
|
|
|
|
if (!empty($_FILES['og_image']['name']) && $_FILES['og_image']['error'] === UPLOAD_ERR_OK) {
|
|
$mimeType = $finfo->file($_FILES['og_image']['tmp_name']) ?: '';
|
|
if (in_array($mimeType, $allowedImageTypes, true)) {
|
|
$name = basename($_FILES['og_image']['name']);
|
|
$name = strtolower($name);
|
|
$name = preg_replace('/[^a-z0-9._-]/', '-', $name) ?? $name;
|
|
$name = preg_replace('/-+/', '-', $name) ?? $name;
|
|
$name = trim($name, '-');
|
|
if ($name !== '') {
|
|
$dest = $assetDir . '/' . $name;
|
|
if (move_uploaded_file($_FILES['og_image']['tmp_name'], $dest)) {
|
|
$config['assets']['og_image'] = '/content/images/' . $name;
|
|
}
|
|
}
|
|
} else {
|
|
$errors[] = t('admin.editor.error_upload_type');
|
|
}
|
|
}
|
|
|
|
if (!empty($_FILES['sidebar_logo']['name']) && $_FILES['sidebar_logo']['error'] === UPLOAD_ERR_OK) {
|
|
$mimeType = $finfo->file($_FILES['sidebar_logo']['tmp_name']) ?: '';
|
|
if (in_array($mimeType, $allowedImageTypes, true)) {
|
|
$name = basename($_FILES['sidebar_logo']['name']);
|
|
$name = strtolower($name);
|
|
$name = preg_replace('/[^a-z0-9._-]/', '-', $name) ?? $name;
|
|
$name = preg_replace('/-+/', '-', $name) ?? $name;
|
|
$name = trim($name, '-');
|
|
if ($name !== '') {
|
|
$dest = $assetDir . '/' . $name;
|
|
if (move_uploaded_file($_FILES['sidebar_logo']['tmp_name'], $dest)) {
|
|
$config['assets']['sidebar_logo'] = '/content/images/' . $name;
|
|
}
|
|
}
|
|
} else {
|
|
$errors[] = t('admin.editor.error_upload_type');
|
|
}
|
|
}
|
|
|
|
if (save_config($config)) {
|
|
build_search_index();
|
|
$notice = t('admin.settings.site.notice_updated');
|
|
} else {
|
|
$errors[] = t('admin.settings.site.error_save');
|
|
}
|
|
}
|
|
}
|
|
|
|
$adminTitle = t('admin.settings.site.page_title');
|
|
require __DIR__ . '/../includes/admin-head.php';
|
|
?>
|
|
<main class="mid">
|
|
<h1><?= e(t('admin.settings.site.heading')) ?></h1>
|
|
<?php require __DIR__ . '/../includes/admin-notices.php'; ?>
|
|
|
|
<nav class="admin-actions">
|
|
<button class="save" type="submit" form="settings-form" aria-label="<?= e(t('admin.settings.nav.save')) ?>">
|
|
<svg class="icon" aria-hidden="true"><use href="#icon-save"></use></svg>
|
|
<?= e(t('admin.settings.nav.save')) ?>
|
|
</button>
|
|
<form method="post" class="inline-form">
|
|
<?= csrf_field() ?>
|
|
<button type="submit" name="download_backup" value="1" aria-label="<?= e(t('admin.settings.site.download_backup')) ?>">
|
|
<svg class="icon" aria-hidden="true"><use href="#icon-download"></use></svg>
|
|
<?= e(t('admin.settings.site.download_backup')) ?>
|
|
</button>
|
|
</form>
|
|
</nav>
|
|
|
|
<form method="post" enctype="multipart/form-data" id="settings-form">
|
|
<?= csrf_field() ?>
|
|
<section class="section-divider">
|
|
<span class="title"><?= e(t('admin.settings.site.section_title')) ?></span>
|
|
<label for="site_title"><?= e(t('admin.settings.site.site_title')) ?></label>
|
|
<input type="text" id="site_title" name="site_title" value="<?= e($config['site_title']) ?>" required>
|
|
|
|
<label for="site_tagline"><?= e(t('admin.settings.site.tagline')) ?></label>
|
|
<input type="text" id="site_tagline" name="site_tagline" value="<?= e($config['site_tagline']) ?>">
|
|
|
|
<label for="site_description"><?= e(t('admin.settings.site.description')) ?></label>
|
|
<textarea id="site_description" name="site_description" rows="4"><?= e($config['site_description'] ?? '') ?></textarea>
|
|
|
|
<label for="site_email"><?= e(t('admin.settings.site.email')) ?></label>
|
|
<input type="email" id="site_email" name="site_email" value="<?= e($config['site_email'] ?? '') ?>" placeholder="you@example.com">
|
|
|
|
<label for="posts_per_page"><?= e(t('admin.settings.site.posts_per_page')) ?></label>
|
|
<input type="number" id="posts_per_page" name="posts_per_page" min="1" max="100" value="<?= e((string) ($config['posts_per_page'] ?? 20)) ?>">
|
|
|
|
<label for="search_excerpt_length"><?= e(t('admin.settings.site.search_excerpt_length')) ?></label>
|
|
<input type="number" id="search_excerpt_length" name="search_excerpt_length" min="0" value="<?= e((string) ($config['search_excerpt_length'] ?? 2500)) ?>">
|
|
<p class="tip"><?= e(t('admin.settings.site.search_excerpt_length_tip')) ?></p>
|
|
|
|
<label class="inline-checkbox" for="search_include_pages">
|
|
<input type="checkbox" id="search_include_pages" name="search_include_pages"<?= ($config['search_include_pages'] ?? true) ? ' checked' : '' ?>>
|
|
<?= e(t('admin.settings.site.search_include_pages')) ?>
|
|
</label>
|
|
|
|
<?php
|
|
$availableLanguages = lang_available();
|
|
$currentLanguage = (string) ($config['language'] ?? 'en');
|
|
if (!isset($availableLanguages[$currentLanguage]) && $currentLanguage !== '') {
|
|
$availableLanguages[$currentLanguage] = $currentLanguage;
|
|
}
|
|
?>
|
|
<label for="language"><?= e(t('admin.settings.site.language')) ?></label>
|
|
<select id="language" name="language">
|
|
<?php foreach ($availableLanguages as $langCode => $langName): ?>
|
|
<option value="<?= e($langCode) ?>"<?= $langCode === $currentLanguage ? ' selected' : '' ?>><?= e($langName) ?> (<?= e($langCode) ?>)</option>
|
|
<?php endforeach; ?>
|
|
</select>
|
|
|
|
<label for="timezone"><?= e(t('admin.settings.site.timezone')) ?> <span class="tip">(<a href="https://www.php.net/manual/en/timezones.php" target="_blank" rel="noopener noreferrer"><?= e(t('admin.settings.site.tip_timezone_link')) ?></a>)</span></label>
|
|
<input type="text" id="timezone" name="timezone" value="<?= e((string) ($config['timezone'] ?? date_default_timezone_get())) ?>" placeholder="UTC" required>
|
|
|
|
<label for="date_format"><?= e(t('admin.settings.site.date_format')) ?> <span class="tip">(<a href="https://www.php.net/manual/en/datetime.format.php" target="_blank" rel="noopener noreferrer"><?= e(t('admin.settings.site.tip_date_format_link')) ?></a>)</span></label>
|
|
<input type="text" id="date_format" name="date_format" value="<?= e((string) ($config['date_format'] ?? 'F j, Y')) ?>" placeholder="F j, Y" required>
|
|
|
|
<label class="inline-checkbox" for="show_reading_time">
|
|
<input type="checkbox" id="show_reading_time" name="show_reading_time"<?= !empty($config['show_reading_time']) ? ' checked' : '' ?>>
|
|
<?= e(t('admin.settings.site.show_reading_time')) ?>
|
|
</label>
|
|
|
|
<label for="homepage_slug"><?= e(t('admin.settings.site.homepage')) ?></label>
|
|
<select id="homepage_slug" name="homepage_slug">
|
|
<option value=""><?= e(t('admin.settings.site.homepage_default')) ?></option>
|
|
<?php foreach ($pageOptions as $pageOption): ?>
|
|
<option value="<?= e($pageOption['slug']) ?>"<?= ($config['homepage_slug'] ?? '') === $pageOption['slug'] ? ' selected' : '' ?>>
|
|
<?= e($pageOption['title']) ?> (<?= e($pageOption['slug']) ?>)
|
|
</option>
|
|
<?php endforeach; ?>
|
|
</select>
|
|
<label for="blog_page_slug"><?= e(t('admin.settings.site.blog_page')) ?></label>
|
|
<select id="blog_page_slug" name="blog_page_slug">
|
|
<option value=""><?= e(t('admin.settings.site.blog_use_homepage')) ?></option>
|
|
<option value="<?= e($hiddenBlogValue) ?>"<?= ($config['blog_page_slug'] ?? '') === $hiddenBlogValue ? ' selected' : '' ?>><?= e(t('admin.settings.site.blog_hidden')) ?></option>
|
|
<?php foreach ($pageOptions as $pageOption): ?>
|
|
<option value="<?= e($pageOption['slug']) ?>"<?= ($config['blog_page_slug'] ?? '') === $pageOption['slug'] ? ' selected' : '' ?>>
|
|
<?= e($pageOption['title']) ?> (<?= e($pageOption['slug']) ?>)
|
|
</option>
|
|
<?php endforeach; ?>
|
|
</select>
|
|
<div id="enable_blog_posts_container" style="<?= ($config['blog_page_slug'] ?? '') === $hiddenBlogValue ? '' : 'display: none;' ?> margin-top: -0.75rem; margin-bottom: 1.5rem;">
|
|
<label class="inline-checkbox" for="enable_blog_posts">
|
|
<input type="checkbox" id="enable_blog_posts" name="enable_blog_posts"<?= ($config['enable_blog_posts'] ?? true) ? ' checked' : '' ?>>
|
|
<?= e(t('admin.settings.site.enable_blog_posts')) ?>
|
|
</label>
|
|
</div>
|
|
|
|
<label for="search_page_slug"><?= e(t('admin.settings.site.search_page')) ?></label>
|
|
<select id="search_page_slug" name="search_page_slug">
|
|
<option value=""><?= e(t('admin.settings.site.search_page_none')) ?></option>
|
|
<?php foreach ($pageOptions as $pageOption): ?>
|
|
<option value="<?= e($pageOption['slug']) ?>"<?= ($config['search_page_slug'] ?? 'search') === $pageOption['slug'] ? ' selected' : '' ?>>
|
|
<?= e($pageOption['title']) ?> (<?= e($pageOption['slug']) ?>)
|
|
</option>
|
|
<?php endforeach; ?>
|
|
</select>
|
|
|
|
<label for="base_url"><?= e(t('admin.settings.site.base_url')) ?></label>
|
|
<input type="text" id="base_url" name="base_url" value="<?= e($config['base_url']) ?>">
|
|
|
|
<label for="favicon"><?= e(t('admin.settings.site.favicon')) ?> <span class="tip">(<?= e(t('admin.settings.site.tip_favicon')) ?>)</span></label>
|
|
<input type="file" id="favicon" name="favicon" accept="image/*">
|
|
<?php if (!empty($config['assets']['favicon'])): ?>
|
|
<p class="current-image"><?= e(t('admin.settings.site.current')) ?>: <a href="<?= e($config['assets']['favicon']) ?>" target="_blank" rel="noopener noreferrer"><?= e($config['assets']['favicon']) ?></a> <a href="?delete_asset=favicon&csrf_token=<?= urlencode(csrf_token()) ?>" class="link-button delete" onclick="return confirm('<?= e(t('admin.images.delete_confirm')) ?>');"><svg class="icon" aria-hidden="true"><use href="#icon-circle-x"></use></svg> <?= e(t('admin.editor.delete')) ?></a></p>
|
|
<?php endif; ?>
|
|
|
|
<label for="apple_touch_icon"><?= e(t('admin.settings.site.apple_touch_icon')) ?> <span class="tip">(<?= e(t('admin.settings.site.tip_apple_touch_icon')) ?>)</span></label>
|
|
<input type="file" id="apple_touch_icon" name="apple_touch_icon" accept="image/png,.png">
|
|
<?php if (!empty($config['assets']['apple_touch_icon'])): ?>
|
|
<p class="current-image"><?= e(t('admin.settings.site.current')) ?>: <a href="<?= e($config['assets']['apple_touch_icon']) ?>" target="_blank" rel="noopener noreferrer"><?= e($config['assets']['apple_touch_icon']) ?></a> <a href="?delete_asset=apple_touch_icon&csrf_token=<?= urlencode(csrf_token()) ?>" class="link-button delete" onclick="return confirm('<?= e(t('admin.images.delete_confirm')) ?>');"><svg class="icon" aria-hidden="true"><use href="#icon-circle-x"></use></svg> <?= e(t('admin.editor.delete')) ?></a></p>
|
|
<?php endif; ?>
|
|
|
|
<label for="og_image"><?= e(t('admin.settings.site.og_image')) ?> <span class="tip">(<?= e(t('admin.settings.site.tip_og_image')) ?>)</span></label>
|
|
<input type="file" id="og_image" name="og_image" accept="image/*">
|
|
<p class="tip"><?= e(t('admin.settings.site.tip_og_image_dynamic')) ?> <a href="https://docs.pureblog.org/open-graph-images/" target="_blank" rel="noopener noreferrer"><?= e(t('admin.settings.site.tip_og_image_doc_link')) ?></a>.</p>
|
|
<?php if (!empty($config['assets']['og_image'])): ?>
|
|
<p class="current-image"><?= e(t('admin.settings.site.current')) ?>: <a href="<?= e($config['assets']['og_image']) ?>" target="_blank" rel="noopener noreferrer"><?= e($config['assets']['og_image']) ?></a> <a href="?delete_asset=og_image&csrf_token=<?= urlencode(csrf_token()) ?>" class="link-button delete" onclick="return confirm('<?= e(t('admin.images.delete_confirm')) ?>');"><svg class="icon" aria-hidden="true"><use href="#icon-circle-x"></use></svg> <?= e(t('admin.editor.delete')) ?></a></p>
|
|
<?php endif; ?>
|
|
|
|
<label for="og_image_preferred"><?= e(t('admin.settings.site.og_image_format')) ?></label>
|
|
<select id="og_image_preferred" name="og_image_preferred">
|
|
<option value="banner"<?= ($config['assets']['og_image_preferred'] ?? 'banner') === 'banner' ? ' selected' : '' ?>><?= e(t('admin.settings.site.og_banner')) ?></option>
|
|
<option value="square"<?= ($config['assets']['og_image_preferred'] ?? 'banner') === 'square' ? ' selected' : '' ?>><?= e(t('admin.settings.site.og_square')) ?></option>
|
|
</select>
|
|
|
|
<label for="sidebar_logo"><?= e(t('admin.settings.site.sidebar_logo')) ?> <span class="tip">(<?= e(t('admin.settings.site.tip_sidebar_logo')) ?>)</span></label>
|
|
<input type="file" id="sidebar_logo" name="sidebar_logo" accept="image/*">
|
|
<?php if (!empty($config['assets']['sidebar_logo'])): ?>
|
|
<p class="current-image"><?= e(t('admin.settings.site.current')) ?>: <a href="<?= e($config['assets']['sidebar_logo']) ?>" target="_blank" rel="noopener noreferrer"><?= e($config['assets']['sidebar_logo']) ?></a> <a href="?delete_asset=sidebar_logo&csrf_token=<?= urlencode(csrf_token()) ?>" class="link-button delete" onclick="return confirm('<?= e(t('admin.images.delete_confirm')) ?>');"><svg class="icon" aria-hidden="true"><use href="#icon-circle-x"></use></svg> <?= e(t('admin.editor.delete')) ?></a></p>
|
|
<?php endif; ?>
|
|
|
|
<label for="custom_nav"><?= e(t('admin.settings.site.custom_nav')) ?> <span class="tip">(<?= e(t('admin.settings.site.tip_one_per_line')) ?>)</span></label>
|
|
<textarea id="custom_nav" name="custom_nav" rows="4" placeholder="GitHub | https://github.com/you Projects | /projects"><?= e($config['custom_nav'] ?? '') ?></textarea>
|
|
|
|
<label class="inline-checkbox" for="custom_nav_only" style="margin-top: -0.5rem; margin-bottom: 1.25rem;">
|
|
<input type="checkbox" id="custom_nav_only" name="custom_nav_only"<?= !empty($config['custom_nav_only']) ? ' checked' : '' ?>>
|
|
<?= e(t('admin.settings.site.custom_nav_only')) ?>
|
|
</label>
|
|
|
|
<label for="custom_routes"><?= e(t('admin.settings.site.custom_routes')) ?> <span class="tip">(<?= e(t('admin.settings.site.tip_one_per_line')) ?>)</span></label>
|
|
<textarea id="custom_routes" name="custom_routes" rows="4" placeholder="/archive | /content/includes/archive.php /reading | reading.php"><?= e($config['custom_routes'] ?? '') ?></textarea>
|
|
</section>
|
|
|
|
<section class="section-divider">
|
|
<span class="title"><?= e(t('admin.settings.site.community_section')) ?></span>
|
|
<label class="inline-checkbox" for="purecomments_enabled">
|
|
<input type="checkbox" id="purecomments_enabled" name="purecomments_enabled"<?= !empty($config['community']['purecomments_enabled']) ? ' checked' : '' ?>>
|
|
<?= e(t('admin.settings.site.purecomments_enable')) ?>
|
|
</label>
|
|
|
|
<div id="purecomments_url_container" style="<?= !empty($config['community']['purecomments_enabled']) ? '' : 'display: none;' ?> margin-top: -0.75rem; margin-bottom: 1.5rem;">
|
|
<label for="purecomments_url"><?= e(t('admin.settings.site.purecomments_url')) ?></label>
|
|
<input type="url" id="purecomments_url" name="purecomments_url" value="<?= e($config['community']['purecomments_url'] ?? '') ?>" placeholder="https://comments.example.com"<?= !empty($config['community']['purecomments_enabled']) ? ' required' : ' disabled' ?>>
|
|
|
|
<label class="inline-checkbox" for="purecomments_autoload" style="margin-top: -0.5rem;" title="<?= e(t('admin.settings.site.purecomments_autoload_tooltip')) ?>">
|
|
<input type="checkbox" id="purecomments_autoload" name="purecomments_autoload"<?= !empty($config['community']['purecomments_autoload']) ? ' checked' : '' ?><?= !empty($config['community']['purecomments_enabled']) ? '' : ' disabled' ?>>
|
|
<?= e(t('admin.settings.site.purecomments_autoload')) ?>
|
|
<abbr title="<?= e(t('admin.settings.site.purecomments_autoload_tooltip')) ?>">(?)</abbr>
|
|
</label>
|
|
</div>
|
|
</section>
|
|
|
|
<section class="section-divider">
|
|
<span class="title"><?= e(t('admin.settings.site.header_injects')) ?></span>
|
|
<label for="head_inject_page"><?= e(t('admin.settings.site.head_inject_page_label')) ?> <span class="tip">(<?= e(t('admin.settings.site.tip_optional')) ?>)</span></label>
|
|
<textarea id="head_inject_page" name="head_inject_page" rows="6" placeholder="<meta name="x-custom" content="value">"><?= e($config['head_inject_page'] ?? '') ?></textarea>
|
|
|
|
<label for="head_inject_post"><?= e(t('admin.settings.site.head_inject_post_label')) ?> <span class="tip">(<?= e(t('admin.settings.site.tip_optional')) ?>)</span></label>
|
|
<textarea id="head_inject_post" name="head_inject_post" rows="6" placeholder="<link rel="stylesheet" href="/content/css/comments.css">"><?= e($config['head_inject_post'] ?? '') ?></textarea>
|
|
</section>
|
|
|
|
<section class="section-divider">
|
|
<span class="title"><?= e(t('admin.settings.site.footer_injects')) ?></span>
|
|
<label for="footer_inject_page"><?= e(t('admin.settings.site.footer_inject_page_label')) ?> <span class="tip">(<?= e(t('admin.settings.site.tip_optional')) ?>)</span></label>
|
|
<textarea id="footer_inject_page" name="footer_inject_page" rows="6" placeholder="<script src="/assets/js/page-only.js" defer></script>"><?= e($config['footer_inject_page'] ?? '') ?></textarea>
|
|
|
|
<label for="footer_inject_post"><?= e(t('admin.settings.site.footer_inject_post_label')) ?> <span class="tip">(<?= e(t('admin.settings.site.tip_optional')) ?>)</span></label>
|
|
<textarea id="footer_inject_post" name="footer_inject_post" rows="6" placeholder="<script src="/assets/js/post-only.js" defer></script>"><?= e($config['footer_inject_post'] ?? '') ?></textarea>
|
|
</section>
|
|
|
|
<section class="section-divider">
|
|
<span class="title"><?= e(t('admin.settings.site.admin_ui_section')) ?></span>
|
|
<label for="admin_homepage"><?= e(t('admin.settings.site.admin_homepage')) ?></label>
|
|
<select id="admin_homepage" name="admin_homepage">
|
|
<option value="dashboard"<?= ($config['admin_homepage'] ?? 'dashboard') === 'dashboard' ? ' selected' : '' ?>><?= e(t('admin.settings.site.admin_homepage_dashboard')) ?></option>
|
|
<option value="content"<?= ($config['admin_homepage'] ?? 'dashboard') === 'content' ? ' selected' : '' ?>><?= e(t('admin.settings.site.admin_homepage_content')) ?></option>
|
|
</select>
|
|
<label class="inline-checkbox" for="admin_hide_dashboard">
|
|
<input type="checkbox" id="admin_hide_dashboard" name="admin_hide_dashboard"<?= !empty($config['admin_hide_dashboard']) ? ' checked' : '' ?><?= ($config['admin_homepage'] ?? 'dashboard') !== 'content' ? ' disabled' : '' ?>>
|
|
<?= e(t('admin.settings.site.admin_hide_dashboard')) ?>
|
|
</label>
|
|
</section>
|
|
|
|
<section class="section-divider">
|
|
<span class="title"><?= e(t('admin.settings.site.cache_section')) ?></span>
|
|
<label class="inline-checkbox" for="cache_enabled">
|
|
<input type="checkbox" id="cache_enabled" name="cache_enabled" <?= !empty($config['cache']['enabled']) ? 'checked' : '' ?>>
|
|
<?= e(t('admin.settings.site.cache_enable')) ?>
|
|
</label>
|
|
|
|
<label for="rss_ttl"><?= e(t('admin.settings.site.rss_ttl')) ?> <span class="tip">(<?= e(t('admin.settings.site.tip_rss_ttl')) ?>)</span></label>
|
|
<input type="number" id="rss_ttl" name="rss_ttl" min="0" value="<?= e((string) ($config['cache']['rss_ttl'] ?? 3600)) ?>">
|
|
</section>
|
|
</form>
|
|
</main>
|
|
<script>
|
|
const adminHomepageSelect = document.getElementById('admin_homepage');
|
|
const hideDashboardCheckbox = document.getElementById('admin_hide_dashboard');
|
|
adminHomepageSelect.addEventListener('change', function () {
|
|
hideDashboardCheckbox.disabled = this.value !== 'content';
|
|
if (hideDashboardCheckbox.disabled) hideDashboardCheckbox.checked = false;
|
|
});
|
|
|
|
const blogPageSlugSelect = document.getElementById('blog_page_slug');
|
|
const enableBlogPostsContainer = document.getElementById('enable_blog_posts_container');
|
|
const enableBlogPostsCheckbox = document.getElementById('enable_blog_posts');
|
|
blogPageSlugSelect.addEventListener('change', function () {
|
|
if (this.value === '__hidden__') {
|
|
enableBlogPostsContainer.style.display = '';
|
|
} else {
|
|
enableBlogPostsContainer.style.display = 'none';
|
|
enableBlogPostsCheckbox.checked = true;
|
|
}
|
|
});
|
|
|
|
const pureCommentsEnabledCheckbox = document.getElementById('purecomments_enabled');
|
|
const pureCommentsUrlContainer = document.getElementById('purecomments_url_container');
|
|
const pureCommentsUrlInput = document.getElementById('purecomments_url');
|
|
const pureCommentsAutoloadCheckbox = document.getElementById('purecomments_autoload');
|
|
pureCommentsEnabledCheckbox.addEventListener('change', function () {
|
|
if (this.checked) {
|
|
pureCommentsUrlContainer.style.display = '';
|
|
pureCommentsUrlInput.disabled = false;
|
|
pureCommentsUrlInput.required = true;
|
|
if (pureCommentsAutoloadCheckbox) pureCommentsAutoloadCheckbox.disabled = false;
|
|
} else {
|
|
pureCommentsUrlContainer.style.display = 'none';
|
|
pureCommentsUrlInput.disabled = true;
|
|
pureCommentsUrlInput.required = false;
|
|
if (pureCommentsAutoloadCheckbox) pureCommentsAutoloadCheckbox.disabled = true;
|
|
}
|
|
});
|
|
</script>
|
|
<?php require __DIR__ . '/../includes/admin-footer.php'; ?>
|