csrf ongoing work (#1803)
[openemr.git] / library / ajax / offsite_portal_ajax.php
blob18a17ca04ed80bbdec616d9f165d338b7cbb4b7e
1 <?php
2 /**
3 * Ajax script to connect to offsite patient portal.
5 * Currently supports collecting the vpn connection package and
6 * can be expanded to support other features in the future.
8 * Copyright (C) 2013 Z&H Consultancy Services Private Limited <sam@zhservices.com>
10 * LICENSE: This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://opensource.org/licenses/gpl-license.php>;.
21 * @package OpenEMR
22 * @author Eldho Chacko <eldho@zhservices.com>
23 * @author Vinish K <vinish@zhservices.com>
24 * @link http://www.open-emr.org
28 require_once(dirname(__FILE__)."/../../interface/globals.php");
29 require_once("$srcdir/acl.inc");
30 require_once(dirname(__FILE__)."/../../myportal/soap_service/portal_connectivity.php");
32 //verify csrf
33 if (!verifyCsrfToken($_POST["csrf_token_form"])) {
34 die(xlt('Authentication Error'));
37 if ($_POST['action'] == 'check_file' && acl_check('admin', 'super')) {
38 $client = portal_connection();
39 $error_message = '';
40 try {
41 $response = $client->getPortalConnectionFiles($credentials);
42 } catch (SoapFault $e) {
43 error_log('SoapFault Error');
44 $error_message = xlt('Patient Portal connectivity issue');
45 } catch (Exception $e) {
46 error_log('Exception Error');
47 $error_message = xlt('Patient Portal connectivity issue');
50 if ($response['status'] == 1) {
51 if ($response['value'] != '') {
52 echo "OK";
53 } else {
54 echo $error_message;
56 } else {
57 echo xlt('Offsite Portal web Service Failed').": ".text($response['value']);