<?php
/**
 * config.php  —  keep this OUTSIDE your public web root if you can,
 * or at minimum deny access to it in .htaccess.
 */

// ---------- Database ----------
define('DB_HOST', '103.119.196.249');
define('DB_NAME', 'datacentralkajar_datacedb');
define('DB_USER', 'datacentralkajar_datacedb');
define('DB_PASS', 'x(z8@kSzJCnNkOVu');

// ---------- Provider send-message API ----------
// Get these from your panel's "API / Developer" section.
define('WA_API_URL',   'https://wa-crm.concordtechnosoft.com/api/meta/v19.0/1129682130226320/messages');  // provider's send endpoint
define('WA_API_KEY',   'nT4K7D5ZWoDVyvkwCgREFTSAJSdzUqIejLkPcSgWr6x9AVNmHUYQJFGwRbVU5ERVJTQ09SRQJDWbFREFTSA2HxsVrT6vylw2oLfGTfREFTSAJ9VU5ERVJTQ09SRQi2yIREFTSAuenexUZWlXJ3LI64JmHq8URpqVJdgC5AuaSQjz1JjmLVU5ERVJTQ09SRQTeBV3F4kb0VU5ERVJTQ09SRQH7NWzNa4m1al1NlhGdGjIk6nbzXUsV9REFTSAlNt6xMBREFTSAg7u1OY6GjWJiZwxZfGpC7JNV6zPk0FORtAh81if6AmwThxw');
define('WA_INSTANCE',  '');                                  // some panels call this instance_id / channel_id

// How the send endpoint expects the request: 'json' | 'form' | 'query' | 'cloud'
define('WA_API_MODE',  'cloud');

// ---------- Optional shared secret ----------
// Append ?s=THIS_VALUE to the webhook URL you paste into the panel.
// Leave empty to disable the check. Does NOT affect the GET challenge.
define('WA_WEBHOOK_SECRET', '');

// ---------- Auto-reply toggle ----------
define('WA_AUTOREPLY_ENABLED', true);


/**
 * Shared PDO connection.
 */
function db(): PDO
{
    static $pdo = null;
    if ($pdo === null) {
        $dsn = 'mysql:host=' . DB_HOST . ';dbname=' . DB_NAME . ';charset=utf8mb4';
        $pdo = new PDO($dsn, DB_USER, DB_PASS, [
            PDO::ATTR_ERRMODE            => PDO::ERRMODE_EXCEPTION,
            PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
            PDO::ATTR_EMULATE_PREPARES   => false,
        ]);
    }
    return $pdo;
}
