- initial
This commit is contained in:
@@ -0,0 +1,123 @@
|
||||
<?php
|
||||
$adminTitle = 'Site Settings';
|
||||
include __DIR__.'/admin_header.php';
|
||||
|
||||
if (isPost()) {
|
||||
csrfCheck();
|
||||
$act = p('_act');
|
||||
|
||||
if ($act === 'settings') {
|
||||
setSetting('site_name', ps('site_name'));
|
||||
setSetting('site_tagline', ps('site_tagline'));
|
||||
setSetting('contact_email', ps('contact_email'));
|
||||
setSetting('registration_enabled',p('registration_enabled','0'));
|
||||
setSetting('events_require_approval',p('events_require_approval','0'));
|
||||
flash('Settings saved!','success');
|
||||
go('/admin/settings.php');
|
||||
}
|
||||
|
||||
// Change admin password
|
||||
if ($act === 'change_password') {
|
||||
$pw = ps('new_password');
|
||||
$pw2 = ps('confirm_password');
|
||||
if (strlen($pw) < 6) { flash('Password must be at least 6 characters.','error'); go('/admin/settings.php'); }
|
||||
if ($pw !== $pw2) { flash('Passwords do not match.','error'); go('/admin/settings.php'); }
|
||||
qrun("UPDATE users SET password=? WHERE id=?",[password_hash($pw,PASSWORD_BCRYPT),uid()]);
|
||||
flash('Password updated successfully!','success');
|
||||
go('/admin/settings.php');
|
||||
}
|
||||
}
|
||||
|
||||
$regEnabled = setting('registration_enabled','1');
|
||||
$evtApproval = setting('events_require_approval','1');
|
||||
$siteName = setting('site_name','Discover Keyser WV');
|
||||
$siteTagline = setting('site_tagline','The Friendliest City in the U.S.A.');
|
||||
$contactEmail = setting('contact_email','info@discoverkeyser.com');
|
||||
$me = qone("SELECT * FROM users WHERE id=?",[uid()]);
|
||||
?>
|
||||
<?php adminTitle('Site Settings') ?>
|
||||
|
||||
<div class="g2" style="gap:1.5rem">
|
||||
<!-- General settings -->
|
||||
<div>
|
||||
<div class="ibox" style="border-color:var(--gold-d)">
|
||||
<div class="ibox-title">🌐 GENERAL SETTINGS</div>
|
||||
<form method="POST"><?=csrfField()?><input type="hidden" name="_act" value="settings">
|
||||
<div class="fg"><label class="flabel">SITE NAME</label><input type="text" name="site_name" class="finput" value="<?=e($siteName)?>"></div>
|
||||
<div class="fg"><label class="flabel">SITE TAGLINE</label><input type="text" name="site_tagline" class="finput" value="<?=e($siteTagline)?>"></div>
|
||||
<div class="fg"><label class="flabel">CONTACT EMAIL</label><input type="email" name="contact_email" class="finput" value="<?=e($contactEmail)?>"></div>
|
||||
<hr class="divider" style="margin:1rem 0">
|
||||
|
||||
<div class="fg">
|
||||
<label class="flabel">USER REGISTRATION</label>
|
||||
<div style="display:flex;gap:1rem;margin-top:.4rem">
|
||||
<label style="display:flex;align-items:center;gap:.4rem;cursor:pointer;font-size:.9rem">
|
||||
<input type="radio" name="registration_enabled" value="1"<?=$regEnabled==='1'?' checked':''?>>
|
||||
<span style="color:var(--green-l)">✅ Enabled — users can register</span>
|
||||
</label>
|
||||
</div>
|
||||
<div style="display:flex;gap:1rem;margin-top:.4rem">
|
||||
<label style="display:flex;align-items:center;gap:.4rem;cursor:pointer;font-size:.9rem">
|
||||
<input type="radio" name="registration_enabled" value="0"<?=$regEnabled==='0'?' checked':''?>>
|
||||
<span style="color:var(--red-l)">🔒 Disabled — registration closed</span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="fhint">When disabled, the Sign Up link is hidden and registration page shows a message.</div>
|
||||
</div>
|
||||
|
||||
<div class="fg">
|
||||
<label class="flabel">EVENT SUBMISSIONS</label>
|
||||
<div style="margin-top:.4rem">
|
||||
<label style="display:flex;align-items:center;gap:.4rem;cursor:pointer;font-size:.9rem;margin-bottom:.35rem">
|
||||
<input type="radio" name="events_require_approval" value="1"<?=$evtApproval==='1'?' checked':''?>>
|
||||
<span>Require admin approval before events go public</span>
|
||||
</label>
|
||||
<label style="display:flex;align-items:center;gap:.4rem;cursor:pointer;font-size:.9rem">
|
||||
<input type="radio" name="events_require_approval" value="0"<?=$evtApproval==='0'?' checked':''?>>
|
||||
<span>Auto-approve all submitted events</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button type="submit" class="btn btn-primary">Save Settings</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Admin password change -->
|
||||
<div>
|
||||
<div class="ibox" style="border-color:var(--gold-d)">
|
||||
<div class="ibox-title">🔑 CHANGE YOUR ADMIN PASSWORD</div>
|
||||
<div class="irow"><span class="irow-i">👤</span><span class="irow-v"><?=e($me['username'])?> <span class="badge badge-gold">ADMIN</span></span></div>
|
||||
<div class="irow" style="margin-bottom:1rem"><span class="irow-i">📅</span><span class="irow-v">Last login: <?=$me['last_login']?ago($me['last_login']):'—'?></span></div>
|
||||
<form method="POST"><?=csrfField()?><input type="hidden" name="_act" value="change_password">
|
||||
<div class="fg"><label class="flabel">NEW PASSWORD *</label><input type="password" name="new_password" class="finput" required autocomplete="new-password"><div class="fhint">Minimum 6 characters.</div></div>
|
||||
<div class="fg"><label class="flabel">CONFIRM NEW PASSWORD *</label><input type="password" name="confirm_password" class="finput" required autocomplete="new-password"></div>
|
||||
<button type="submit" class="btn btn-primary">Update Password</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<!-- DB info -->
|
||||
<div class="ibox">
|
||||
<div class="ibox-title">📊 DATABASE INFO</div>
|
||||
<?php
|
||||
$counts = [
|
||||
'Businesses' => qval("SELECT COUNT(*) FROM businesses"),
|
||||
'Users' => qval("SELECT COUNT(*) FROM users"),
|
||||
'Reviews' => qval("SELECT COUNT(*) FROM reviews"),
|
||||
'Events' => qval("SELECT COUNT(*) FROM events"),
|
||||
'Attractions'=> qval("SELECT COUNT(*) FROM attractions"),
|
||||
'Alerts' => qval("SELECT COUNT(*) FROM alerts"),
|
||||
'Reports' => qval("SELECT COUNT(*) FROM reports"),
|
||||
'Menu Sections'=> qval("SELECT COUNT(*) FROM menu_sections"),
|
||||
'Menu Items' => qval("SELECT COUNT(*) FROM menu_items"),
|
||||
];
|
||||
foreach ($counts as $lbl => $n):
|
||||
?><div class="irow"><span class="irow-i">📌</span><span class="irow-v" style="display:flex;justify-content:space-between;width:100%"><span><?=e($lbl)?></span><strong style="color:var(--gold)"><?=$n?></strong></span></div><?php endforeach; ?>
|
||||
<?php if(file_exists(DB_FILE)): ?>
|
||||
<div class="irow"><span class="irow-i">💾</span><span class="irow-v" style="display:flex;justify-content:space-between;width:100%"><span>DB File Size</span><strong style="color:var(--gold)"><?=number_format(filesize(DB_FILE)/1024,1)?> KB</strong></span></div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php include __DIR__.'/admin_footer.php'; ?>
|
||||
Reference in New Issue
Block a user