prepare("SELECT id, exten_for_external, exten_for_ext_pass, conf_extension FROM external_users WHERE exten_for_external = ? AND exten_for_ext_pass = ? AND conf_extension = ?"); $query->bind_param("sss", $extForExternal, $extenPassEnc, $vconfExtension); $query->execute(); $extqueryres = $query->get_result()->fetch_array(); if (!$extqueryres) { http_response_code(400); exit(); } else { if (is_dir('../textchat/' . $extForExternal . 'vconf' . '/uploads')) { try { array_map('unlink', glob('../textchat/' . $extForExternal . 'vconf' . '/uploads/*')); if (glob('../textchat/' . $extForExternal . 'vconf' . '/uploads/*')) { throw new Exception('Directory not empty'); } else { throw new Exception(''); } } catch (Exception $e) { if ($e->getMessage() == '') { $cmessage = 'success'; } else { $cmessage = 'failure'; } } } else { $cmessage = 'success'; } } $resresult = ["note" => $cmessage]; echo json_encode($resresult); } else { header("Location: ../login.php"); } ?>