<?php
require("includes/check_auth_user.php");
require("includes/dbconnect.php");
include('includes/function.php');

$zdb = $_SESSION["zdbyear_" . $dbname];
$zyear = right($zdb, 4);

mysqli_select_db($conn,$zdb);

if (isset($_REQUEST["snapPass"])) {
    $success = "";
    $snapVouch = $_REQUEST["snapVouch"];
    $snapPass = $_REQUEST["snapPass"];

    $getImage = mysqli_query($conn,"SELECT * FROM `passimage` WHERE `passno`='$snapPass' AND `vouchno`='$snapVouch'")or die(mysqli_error($conn));
    $rows = array();
    while ($image = mysqli_fetch_array($getImage)) {
        $rows [] = [
            'success'   => true,
            'src'       => $image[imgpath] ."?a=". mt_rand(),
            'type'      => $image[type]
        ];
    }
    header("Content-type: application\json");
    echo json_encode($rows);
}
?>