초기 커밋: 5130 레거시 시스템
- URL 하드코딩 → .env APP_URL 기반 동적 URL로 변경 - DB 연결 하드코딩 → .env 기반으로 변경 - MySQL strict mode DATE 오류 수정
This commit is contained in:
47
ocr/delete.php
Normal file
47
ocr/delete.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
require_once($_SERVER['DOCUMENT_ROOT'] . "/session.php");
|
||||
require_once(__DIR__ . '/../lib/mydb.php');
|
||||
|
||||
// 권한 체크 (레벨 5 이하만 접근)
|
||||
if ($level > 5) {
|
||||
header('Content-Type: application/json; charset=utf-8');
|
||||
echo json_encode(['ok' => false, 'error' => '접근 권한이 없습니다.'], JSON_UNESCAPED_UNICODE);
|
||||
exit;
|
||||
}
|
||||
|
||||
header('Content-Type: application/json; charset=utf-8');
|
||||
|
||||
try {
|
||||
$input = json_decode(file_get_contents('php://input'), true);
|
||||
$id = isset($input['id']) ? intval($input['id']) : 0;
|
||||
|
||||
if ($id <= 0) {
|
||||
echo json_encode(['ok' => false, 'error' => '잘못된 ID입니다.'], JSON_UNESCAPED_UNICODE);
|
||||
exit;
|
||||
}
|
||||
|
||||
$pdo = db_connect();
|
||||
|
||||
// 데이터 존재 확인
|
||||
$check_sql = "SELECT id FROM biz_cert WHERE id = :id";
|
||||
$check_stmt = $pdo->prepare($check_sql);
|
||||
$check_stmt->bindValue(':id', $id, PDO::PARAM_INT);
|
||||
$check_stmt->execute();
|
||||
|
||||
if (!$check_stmt->fetch()) {
|
||||
echo json_encode(['ok' => false, 'error' => '해당 데이터를 찾을 수 없습니다.'], JSON_UNESCAPED_UNICODE);
|
||||
exit;
|
||||
}
|
||||
|
||||
// 삭제 실행
|
||||
$delete_sql = "DELETE FROM biz_cert WHERE id = :id";
|
||||
$delete_stmt = $pdo->prepare($delete_sql);
|
||||
$delete_stmt->bindValue(':id', $id, PDO::PARAM_INT);
|
||||
$delete_stmt->execute();
|
||||
|
||||
echo json_encode(['ok' => true], JSON_UNESCAPED_UNICODE);
|
||||
|
||||
} catch (Exception $e) {
|
||||
echo json_encode(['ok' => false, 'error' => '삭제 중 오류가 발생했습니다: ' . $e->getMessage()], JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user