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/customer_tags.php
<?php
/**
 * api/admin/customer_tags.php
 */

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('customer_tags');
if (!is_admin()) json_response(false, 'Sadece admin bu işlemi yapabilir.');
csrf_required();
header('Content-Type: application/json');

$action = post_str('action');
$id     = post_int('id');

switch ($action) {

    case 'create':
        $name          = post_str('name');
        $discount_rate = post_int('discount_rate');
        $auto_note     = post_str('auto_note');

        if (!$name) json_response(false, 'Etiket adı zorunludur.');
        if (db_value('SELECT id FROM customer_tags WHERE name=?', [$name])) {
            json_response(false, 'Bu isimde etiket zaten var.');
        }

        db_insert('INSERT INTO customer_tags (name, discount_rate, auto_note) VALUES (?,?,?)', [$name, $discount_rate, $auto_note]);
        json_response(true, 'Etiket oluşturuldu.');

    case 'update':
        if (!$id) json_response(false, 'Geçersiz ID.');
        $name          = post_str('name');
        $discount_rate = post_int('discount_rate');
        $auto_note     = post_str('auto_note');

        if (!$name) json_response(false, 'Etiket adı zorunludur.');
        $exists = db_value('SELECT id FROM customer_tags WHERE name=? AND id!=?', [$name, $id]);
        if ($exists) json_response(false, 'Bu isimde başka etiket var.');

        db_run('UPDATE customer_tags SET name=?, discount_rate=?, auto_note=? WHERE id=?', [$name, $discount_rate, $auto_note, $id]);
        json_response(true, 'Etiket güncellendi.');

    case 'delete':
        if (!$id) json_response(false, 'Geçersiz ID.');
        $tag = db_row('SELECT is_default FROM customer_tags WHERE id=?', [$id]);
        if (!$tag) json_response(false, 'Etiket bulunamadı.');
        if ($tag['is_default']) json_response(false, 'Varsayılan etiket silinemez.');
        $count = (int)db_value('SELECT COUNT(*) FROM customers WHERE tag_id=?', [$id]);
        if ($count > 0) json_response(false, 'Bu etikete bağlı müşteri var. Önce müşterilerin etiketini değiştirin.');
        db_run('DELETE FROM customer_tags WHERE id=?', [$id]);
        json_response(true, 'Etiket silindi.');

    case 'set_default':
        if (!$id) json_response(false, 'Geçersiz ID.');
        db_run('UPDATE customer_tags SET is_default=0');
        db_run('UPDATE customer_tags SET is_default=1 WHERE id=?', [$id]);
        json_response(true, 'Varsayılan güncellendi.');

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