Offsite portal support for secure vpn connectivity.
[openemr.git] / myportal / soap_service / portal_connectivity.php
blob9c98dac9213010184d02c49708666f2b12654784
1 <?php
2 // +-----------------------------------------------------------------------------+
3 // Copyright (C) 2013 Z&H Consultancy Services Private Limited <sam@zhservices.com>
4 //
5 //
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 2
9 // of the License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
18 // A copy of the GNU General Public License is included along with this program:
19 // openemr/interface/login/GnuGPL.html
20 // For more information write to the Free Software
21 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 //
23 // Author: Eldho Chacko <eldho@zhservices.com>
24 // Vinish K <vinish@zhservices.com>
26 // +------------------------------------------------------------------------------+
27 //SANITIZE ALL ESCAPES
28 $sanitize_all_escapes=true;
31 //STOP FAKE REGISTER GLOBALS
32 $fake_register_globals=false;
34 function portal_connection(){
35 global $credentials;
36 $password = $GLOBALS['portal_offsite_password'];
37 $randkey = '';
38 $timminus = date("Y-m-d H:m",(strtotime(date("Y-m-d H:m"))-7200)).":00";
39 sqlStatement("DELETE FROM audit_details WHERE audit_master_id IN(SELECT id FROM audit_master WHERE type=5 AND created_time<=?)",array($timminus));
40 sqlStatement("DELETE FROM audit_master WHERE type=5 AND created_time<=?",array($timminus));
41 do{
42 $randkey = substr(md5(rand().rand()), 0, 8);
43 $res = sqlStatement("SELECT * FROM audit_details WHERE field_value = ?",array($randkey));
44 $cnt = sqlNumRows($res);
46 while($cnt>0);
47 $password = sha1($password.gmdate("Y-m-d H").$randkey);
48 $grpID = sqlInsert("INSERT INTO audit_master SET type=5");
49 sqlStatement("INSERT INTO audit_details SET field_value=? , audit_master_id=?",array($randkey,$grpID));
50 $credentials = array($GLOBALS['portal_offsite_username'],$password,$randkey);
51 //CALLING WEBSERVICE ON THE PATIENT-PORTAL
52 $client = new SoapClient(null, array(
53 'location' => $GLOBALS['portal_offsite_address_patient_link']."/webservice/webserver.php",
54 'uri' => "urn://portal/req"
57 return $client;