<?php

$cert = trim($_POST['cert']);
$redirect = false;
$dr = $_SERVER['DOCUMENT_ROOT'];

if (file_exists($dr . "/sites/default/files/feeds/pdf/" . $cert . ".pdf")) {
    $success = true;
} else {
    $cert = str_replace("M", "лю", $cert);
    if (file_exists($dr . "/sites/default/files/feeds/pdf/" . $cert . ".pdf")) {
        $success = true;
    } else {
        $success = false;
    }
}

$return = [
    'success' => $success,
    'cert' => $cert,
    'redirect' => $redirect
];
echo json_encode($return);
//echo 'Script ok';

?>