<?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();

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

    $recsendsipuser = $_POST['recsendsipuser'];

    if (is_file('textchat/' . $recsendsipuser . '/rsa_1024_pub.pem')) {

        $chatKey = file('textchat/' . $recsendsipuser . '/rsa_1024_pub.pem');

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

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

    $result = ['chatkey' => $chatKey, 'resmessage' => $message];

    echo json_encode($result);

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

?>
