refactor: move o SQL restante das vistas de multi-ginásio (fecha 6.3)
Os últimos 3 pontos de SQL direto em vistas, que tinham entrado depois da auditoria original (trabalho de multi-ginásio): gyms/create.php e gyms/edit.php partilhavam a mesma query da lista de galerias — agora db_galleries_options() em functions_galerias.php (e simplificada: o _gyms_has_col() defensivo já não é preciso, galleries.deleted_at existe desde a migração de 25/09). reviews/index.php gravava google_place_id à mão — agora db_gym_set_place_id(), separado do db_gyms_update() geral para não auditar/validar o resto do registo por uma só coluna. Zero vistas com SQL direto agora (grep confirma). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
fa87aabb87
commit
43e0fc7be6
5 files changed
+17
-6
No files matched your search
@@ -5,8 +5,7 @@ $user = require_admin();
|
||||
|
||||
$errors = [];
|
||||
$data = gym_defaults();
|
||||
$galleries = $pdo->query("SELECT id, name FROM galleries" . (_gyms_has_col($pdo, 'galleries', 'deleted_at') ? " WHERE deleted_at IS NULL" : "") . " ORDER BY id")
|
||||
->fetchAll(PDO::FETCH_KEY_PAIR);
|
||||
$galleries = db_galleries_options($pdo);
|
||||
$sources = db_gyms_list($pdo);
|
||||
$copy_from = (int) ($_POST['copy_from'] ?? 0);
|
||||
$copy_what = (array) ($_POST['copy'] ?? array_keys(gyms_copy_options()));
|
||||
|
||||
@@ -9,8 +9,7 @@ if (!$item || $item['deleted_at'] !== null) { header('Location: index.php'); exi
|
||||
|
||||
$errors = [];
|
||||
$data = $item;
|
||||
$galleries = $pdo->query("SELECT id, name FROM galleries" . (_gyms_has_col($pdo, 'galleries', 'deleted_at') ? " WHERE deleted_at IS NULL" : "") . " ORDER BY id")
|
||||
->fetchAll(PDO::FETCH_KEY_PAIR);
|
||||
$galleries = db_galleries_options($pdo);
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
csrf_check();
|
||||
|
||||
@@ -21,8 +21,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
} elseif ($key !== '') {
|
||||
db_update_setting($pdo, 'google_places_api_key', secret_encrypt($key), $uid);
|
||||
}
|
||||
$pdo->prepare("UPDATE gyms SET google_place_id = ?, updated_at = NOW() WHERE id = ?")
|
||||
->execute([mb_substr(trim((string) ($_POST['google_place_id'] ?? '')), 0, 120), (int) $rgym['id']]);
|
||||
db_gym_set_place_id($pdo, (int) $rgym['id'], mb_substr(trim((string) ($_POST['google_place_id'] ?? '')), 0, 120));
|
||||
db_update_setting($pdo, 'google_reviews_min_rating', (string) max(1, min(5, (int) ($_POST['min_rating'] ?? 4))), $uid);
|
||||
db_update_setting($pdo, 'google_reviews_max', (string) max(1, min(5, (int) ($_POST['max'] ?? 3))), $uid);
|
||||
db_update_setting($pdo, 'google_reviews_cache_hours', (string) max(1, (int) ($_POST['cache_hours'] ?? 24)), $uid);
|
||||
|
||||
Reference in new issue
Block a user