Secure SOAP APIs to support third party patient portals. Contributed
[openemr.git] / myportal / index.php
blobd3e8d4a73b4244d12c07fa3829eefe4e890f9234
1 <?php
2 // +-----------------------------------------------------------------------------+
3 // Copyright (C) 2011 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 // Jacob T Paul <jacob@zhservices.com>
25 // Paul Simon <paul@zhservices.com>
27 // +------------------------------------------------------------------------------+
29 //SANITIZE ALL ESCAPES
30 $sanitize_all_escapes=true;
33 //STOP FAKE REGISTER GLOBALS
34 $fake_register_globals=false;
36 if (!extension_loaded('soap')) {
37 die("PLEASE ENABLE SOAP EXTENSION");
39 require_once("../interface/globals.php");
40 $emr_path = $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
41 $emrpatharr = explode("/myportal",$emr_path);
42 $emr_path = (!empty($_SERVER['HTTPS'])) ? "https://".$emrpatharr[0] : "http://".$emrpatharr[0];
43 $row = sqlQuery("SELECT fname,lname FROM users WHERE id=?",array($_SESSION['authId']));
44 sqlStatement("DELETE FROM audit_details WHERE audit_master_id IN(SELECT id FROM audit_master WHERE type=5 AND created_time<'".date("Y-m-d H:m",(strtotime(date("Y-m-d H:m")-7200))).":00')");
45 sqlStatement("DELETE FROM audit_master WHERE type=5 AND created_time<'".date("Y-m-d H:m",(strtotime(date("Y-m-d H:m")-7200))).":00'");
47 function md5_pass($length = 8)
49 $randkey = substr(md5(rand().rand()), 0, $length);
50 $res = sqlStatement("SELECT * FROM audit_master AS am LEFT OUTER JOIN audit_details AS ad ON ad.audit_master_id=am.id WHERE type=5 AND field_value=?",array($randkey));
51 if(sqlNumRows($res)){
52 md5_pass();
54 else{
55 $grpID = sqlInsert("INSERT INTO audit_master SET type=5");
56 sqlStatement("INSERT INTO audit_details SET field_value=? , audit_master_id=?",array($randkey,$grpID));
57 return $randkey;
61 <html>
62 <head>
63 <?php include_once($GLOBALS['fileroot']."/library/sha1.js");?>
64 <script type="text/javascript">
65 function getshansubmit(){
66 randkey = "<?php echo md5_pass();?>";
67 pass = SHA1(document.portal.pass.value+"<?php echo gmdate('Y-m-d H');?>"+randkey);
68 document.portal.pwd.value=pass;
69 document.portal.randkey.value=randkey;
70 document.forms[0].submit();
73 </script>
74 </head>
75 <title><?php echo htmlspecialchars(xl("Redirection"),ENT_QUOTES);?></title>
76 <body onload="getshansubmit()">
77 <form name="portal" method="post" action="<?php echo htmlspecialchars($GLOBALS['portal_offsite_address'],ENT_QUOTES);?>">
78 <input type="hidden" name="user" value="<?php echo htmlspecialchars($GLOBALS['portal_offsite_username'],ENT_QUOTES);?>">
79 <input type="hidden" name="emr_path" value="<?php echo htmlspecialchars($emr_path,ENT_QUOTES);?>">
80 <input type="hidden" name="emr_site" value="<?php echo htmlspecialchars($_SESSION['site_id'],ENT_QUOTES);?>">
81 <input type="hidden" name="uname" value="<?php echo htmlspecialchars($row['fname']." ".$row['lname'],ENT_QUOTES);?>">
82 <input type="hidden" name="pass" value="<?php echo htmlspecialchars($GLOBALS['portal_offsite_password'],ENT_QUOTES);?>">
83 <input type="hidden" name="randkey" value="">
84 <input type="hidden" name="pwd" value="">
85 </form>
86 </body>
87 </html>