0 ? time() + $expDays * 86400 : 0; $note = $_POST['note'] ?? ''; list($ok, $msg) = GoldShop::createCode($code, $gold, $maxUses, $perUser, $expires, $note, $admid); if ($ok) { $logMsg = mysqli_real_escape_string($GLOBALS['link'], 'Promo code created: ' . GoldShop::normCode($code) . ' (' . (int)$gold . ' gold)'); mysqli_query($GLOBALS['link'], "INSERT INTO " . TB_PREFIX . "admin_log VALUES (0, " . $admid . ", '" . $logMsg . "', " . time() . ")"); } } elseif ($do === 'toggle') { $id = (int)($_POST['id'] ?? 0); $active = (int)($_POST['active'] ?? 0); if ($id > 0) { GoldShop::setActive($id, $active); $msg = $active ? 'Code enabled.' : 'Code disabled.'; } } elseif ($do === 'delete') { $id = (int)($_POST['id'] ?? 0); if ($id > 0) { GoldShop::deleteCode($id); mysqli_query($GLOBALS['link'], "INSERT INTO " . TB_PREFIX . "admin_log VALUES (0, " . $admid . ", 'Promo code deleted (id " . $id . ")', " . time() . ")"); $msg = 'Code deleted.'; } } header("Location: ../../../Admin/admin.php?p=goldShop&msg=" . urlencode($msg)); exit; ?>