File manager - Edit - /home/webapp69.cm.in.th/u69319090041/Shop41/public/ajax/update_footer.php
Back
<?php require_once __DIR__ . '/../../config/config.php'; require_once __DIR__ . '/../../includes/auth.php'; header('Content-Type: application/json'); if ($_SERVER['REQUEST_METHOD'] !== 'PUT') { http_response_code(405); echo json_encode(['success' => false, 'error' => 'Method not allowed']); exit; } if (!isAdmin()) { http_response_code(403); echo json_encode(['success' => false, 'error' => 'Forbidden']); exit; } $inputJSON = file_get_contents('php://input'); $data = json_decode($inputJSON, true); if (!$data) { echo json_encode(['success' => false, 'error' => 'Invalid JSON']); exit; } try { $db = getDBConnection(); // Check if table exists, if not maybe the admin hasn't run the migration yet $tableCheck = $db->query("SHOW TABLES LIKE 'system_settings'")->fetch(); if (!$tableCheck) { echo json_encode(['success' => false, 'error' => 'Table system_settings does not exist. Please run migration.']); exit; } $stmt = $db->prepare("INSERT INTO system_settings (setting_key, setting_value) VALUES ('footer_config', ?) ON DUPLICATE KEY UPDATE setting_value = ?"); $jsonEncoded = json_encode($data, JSON_UNESCAPED_UNICODE); $stmt->execute([$jsonEncoded, $jsonEncoded]); echo json_encode(['success' => true]); } catch (Exception $e) { echo json_encode(['success' => false, 'error' => $e->getMessage()]); }
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | Generation time: 0.23 |
proxy
|
phpinfo
|
Settings