<?php
/**
 *  Copyright (C) 2021  Double Bastion LLC
 *
 *  This file is part of Roundpin, which is licensed under the
 *  GNU Affero General Public License Version 3.0. The license terms
 *  are detailed in the "LICENSE.txt" file located in the root directory.
 */

session_start();
 // header('Set-Cookie: PHPSESSID= ' . session_id() . '; SameSite=strict; Secure=true; HttpOnly=true;');

if (isset($_POST['s_ajax_call']) && ($_POST['s_ajax_call'] == $_SESSION['validate_s_access']) && isset($_POST['crnttconfext']) && $_POST['crnttconfext'] != '') {

    $textConfExt = $_POST['crnttconfext'];

    if (file_exists('../textchat/' . $textConfExt . '/rsa_1024_priv.pem')) {

        $chatPrivKey = file('../textchat/' . $textConfExt . '/rsa_1024_priv.pem');

        if (!empty($chatPrivKey)) { $message = 'success'; } else { $message = 'error'; }

    } else { $chatPrivKey = ''; $message = 'error'; }

    $result = ['chatprivkey' => $chatPrivKey, 'resmessage' => $message];

    echo json_encode($result);

} else {
    header("Location: ../login.php");
}

?>