HEX
Server: LiteSpeed
System:
User: ()
PHP: 7.4.33
Disabled: sendmail,mail,exec,shell_exec,dl,system,passthru,pclose,proc_open,proc_nice,proc_terminate,proc_get_status,proc_close,leak,apache_child_terminate,posix_kill,posix_mkfifo,posix_setpgid,posix_setsid,posix_setuid,escapeshellcmd,escapeshellarg shell-exec,fpassthru,crack_check,crack_closedict,crack_getlastmessage,crack_opendict,psockopen,php_uname,symlink,ini_restore,posix_getpwuid,posix_getegid,posix_getcwd,posix_geteuid,posix_getgroups,posix_uname,posix_setuid,eval,show_source,passthru,popen,allow_url_fopen,get_current_user,getmyuid,getmygid,entre2v2,index_changer_wp,index_changer_joomla,exec_mode_1,exec_mode_2,exec_mode_3,wsoFooter,wsoEx,wsoViewSize,wsoPerms,wsoPermsColor,ukuran,tulis,ambil,tukar,entre2v2,rapih,magicboom,goaction,scookie,showstat,index_changer
Upload Files
File: /home/muratemr/theotto.tr/api/admin/reservations.php
<?php
/**
 * api/admin/reservations.php
 * Rezervasyon CRUD AJAX endpoint
 */

declare(strict_types=1);

require_once __DIR__ . '/../../includes/db.php';
require_once __DIR__ . '/../../includes/auth.php';
require_once __DIR__ . '/../../includes/functions.php';
require_once __DIR__ . '/../../includes/csrf.php';

require_permission('reservations');
header('Content-Type: application/json');

$action = $_GET['action'] ?? post_str('action');

// GET istekleri
if ($_SERVER['REQUEST_METHOD'] === 'GET' && $action === 'get') {
    $id  = get_int('id');
    $row = db_row('SELECT * FROM reservations WHERE id = ?', [$id]);
    if (!$row) json_response(false, 'Rezervasyon bulunamadı.');
    json_response(true, '', ['reservation' => $row]);
}

// POST istekleri - CSRF kontrol
csrf_required();

set_exception_handler(function(Throwable $e) {
    http_response_code(500);
    header("Content-Type: application/json");
    echo json_encode(["success" => false, "message" => "Sunucu hatası: " . $e->getMessage()]);
    exit;
});

$id = post_int('id');

switch ($action) {

    case 'confirm':
        if (!$id) json_response(false, 'Geçersiz ID.');
        $table_no   = post_str('table_no');
        $admin_note = post_str('admin_note');
        db_run(
            "UPDATE reservations SET status='onaylandi', table_no=?, admin_note=? WHERE id=? AND status='bekliyor'",
            [$table_no, $admin_note, $id]
        );
        json_response(true, 'Rezervasyon onaylandı.');

    case 'reject':
        if (!$id) json_response(false, 'Geçersiz ID.');
        $reason = post_str('cancel_reason');
        db_run(
            "UPDATE reservations SET status='reddedildi', cancel_reason=? WHERE id=? AND status='bekliyor'",
            [$reason, $id]
        );
        json_response(true, 'Rezervasyon reddedildi.');

    case 'cancel':
        if (!$id) json_response(false, 'Geçersiz ID.');
        $reason = post_str('cancel_reason');
        db_run(
            "UPDATE reservations SET status='iptal', cancel_reason=? WHERE id=? AND status IN ('bekliyor','onaylandi')",
            [$reason, $id]
        );
        json_response(true, 'Rezervasyon iptal edildi.');

    case 'archive':
        if (!$id) json_response(false, 'Geçersiz ID.');
        db_run("UPDATE reservations SET status='arsiv' WHERE id=? AND status='onaylandi'", [$id]);
        json_response(true, 'Arşivlendi.');

    case 'visit':
        if (!$id) json_response(false, 'Geçersiz ID.');
        $visit_status = post_str('visit_status');
        $visit_note   = post_str('visit_note');
        $allowed      = ['', 'geldi', 'gelmedi'];
        if (!in_array($visit_status, $allowed)) json_response(false, 'Geçersiz durum.');
        db_run(
            "UPDATE reservations SET visit_status=?, visit_note=? WHERE id=? AND status IN ('onaylandi','arsiv')",
            [$visit_status ?: null, $visit_note, $id]
        );
        json_response(true, 'Ziyaret durumu güncellendi.');

    case 'update':
        if (!$id) json_response(false, 'Geçersiz ID.');
        $full_name       = post_str('full_name');
        $phone           = post_str('phone');
        $guest_count     = post_int('guest_count');
        $date            = post_str('date');
        $time            = post_str('time');
        $table_no        = post_str('table_no');
        $special_request = post_str('special_request');
        $admin_note      = post_str('admin_note');

        if (!$full_name || !$phone || !$date || !$time) {
            json_response(false, 'Zorunlu alanlar eksik.');
        }

        db_run(
            "UPDATE reservations SET full_name=?, phone=?, guest_count=?, date=?, time=?, table_no=?, special_request=?, admin_note=? WHERE id=?",
            [$full_name, $phone, $guest_count, $date, $time, $table_no, $special_request, $admin_note, $id]
        );
        json_response(true, 'Rezervasyon güncellendi.');

    case 'delete':
        if (!is_admin()) json_response(false, 'Yetkiniz yok.');
        if (!$id) json_response(false, 'Geçersiz ID.');
        db_run('DELETE FROM reservations WHERE id=?', [$id]);
        json_response(true, 'Silindi.');

    default:
        json_response(false, 'Geçersiz işlem.');
}