Merge pull request #940 for adding access controls for encounter categories
[openemr.git] / myportal / index.php
bloba2af791d355d1a8b0b1724b1de00655d77d0a610
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 // +------------------------------------------------------------------------------+
30 if (!extension_loaded('soap')) {
31 die("PLEASE ENABLE SOAP EXTENSION");
33 require_once("../interface/globals.php");
34 $emr_path = $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
35 $emrpatharr = explode("/myportal",$emr_path);
36 $emr_path = (!empty($_SERVER['HTTPS'])) ? "https://".$emrpatharr[0] : "http://".$emrpatharr[0];
37 $row = sqlQuery("SELECT fname,lname FROM users WHERE id=?",array($_SESSION['authId']));
38 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')");
39 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'");
41 function md5_pass($length = 8)
43 $randkey = substr(md5(rand().rand()), 0, $length);
44 $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));
45 if(sqlNumRows($res)){
46 md5_pass();
48 else{
49 $grpID = sqlInsert("INSERT INTO audit_master SET type=5");
50 sqlStatement("INSERT INTO audit_details SET field_value=? , audit_master_id=?",array($randkey,$grpID));
51 return $randkey;
54 for($i=1;$i<=5;$i++){//some times php is continuing without getting the return value from the function md5_pass()
55 if(!$randkey){
56 if($i>1)
57 sleep(1);
58 $randkey = md5_pass();
60 else{
61 break;
64 $pass = sha1($GLOBALS['portal_offsite_password'].gmdate('Y-m-d H').$randkey);
66 <html>
67 <head>
68 <script type="text/javascript">
69 function getshansubmit(){
70 document.forms[0].submit();
73 </script>
74 </head>
75 <title><?php echo xlt('Redirection');?></title>
76 <body onload="getshansubmit()">
77 <form name="portal" method="post" action="<?php echo htmlspecialchars($GLOBALS['portal_offsite_address']."?version=".$v_offsite_portal,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="<?php echo htmlspecialchars($randkey,ENT_QUOTES);?>">
84 <input type="hidden" name="pwd" value="<?php echo htmlspecialchars($pass,ENT_QUOTES);?>">
85 </form>
86 </body>
87 </html>