CVE-2022-2824: Authorization Bypass Through User-Controlled Key (CWE-639)
value: Authorization Bypass Through User-Controlled Key in GitHub repository openemr/openemr prior to 7.0.0.1.


CWE description: The system's authorization functionality does not prevent one user from gaining access to another user's data or record by modifying the key value identifying the data.
CVSS v3 base score: 5.4
Published: 2022-08-15T16:15Z
Repository: https://github.com/openemr/openemr
Language: PHP
Files changed: portal/patient/fwk/libs/verysimple/Phreeze/Criteria.php, portal/patient/fwk/libs/verysimple/Phreeze/DataPage.php, portal/patient/fwk/libs/verysimple/Phreeze/DataSet.php, portal/patient/fwk/libs/verysimple/Phreeze/Phreezable.php, portal/patient/fwk/libs/verysimple/Phreeze/Reporter.php, portal/patient/libs/Controller/PortalPatientController.php, portal/patient/templates/OnsiteActivityViewListView.tpl.php, portal/patient/templates/ProviderHome.tpl.php, portal/report/portal_patient_report.php, portal/sign/lib/save-signature.php, portal/sign/lib/show-signature.php, src/Gacl/Gacl.php
Commit date: 2022-08-05 08:31:02 -0400
Commit message: bug fix and php8.1 fixes (#5664)

* bug fix and php8.1 fixes

* styling
Diff: diff --git a/portal/patient/fwk/libs/verysimple/Phreeze/Criteria.php b/portal/patient/fwk/libs/verysimple/Phreeze/Criteria.php
index 8d8558bf17..dc05a4d786 100644
--- a/portal/patient/fwk/libs/verysimple/Phreeze/Criteria.php
+++ b/portal/patient/fwk/libs/verysimple/Phreeze/Criteria.php
@@ -221,67 +221,67 @@ class Criteria
 
                         foreach ($filters as $filter) {
                             $this->_where .= $this->_where_delim . ' ' . $filter->GetWhere($this);
                             $this->_where_delim = " and";
                         }
-                    } elseif (substr($prop, - 7) == "_Equals" && strlen($this->$prop)) {
+                    } elseif (substr($prop, - 7) == "_Equals" && strlen($this->$prop ?? '')) {
                         $dbfield = $this->GetFieldFromProp(str_replace("_Equals", "", $prop));
                         $this->_where .= $this->_where_delim . " " . $dbfield . " = " . $this->GetQuotedSql($val) . "";
                         $this->_where_delim = " and";
-                    } elseif (substr($prop, - 10) == "_NotEquals" && strlen($this->$prop)) {
+                    } elseif (substr($prop, - 10) == "_NotEquals" && strlen($this->$prop ?? '')) {
                         $dbfield = $this->GetFieldFromProp(str_replace("_NotEquals", "", $prop));
                         $this->_where .= $this->_where_delim . " " . $dbfield . " != " . $this->GetQuotedSql($val) . "";
                         $this->_where_delim = " and";
-                    } elseif (substr($prop, - 8) == "_IsEmpty" && $this->$prop) {
+                    } elseif (substr($prop, - 8) == "_IsEmpty" && $this->$prop ?? '') {
                         $dbfield = $this->GetFieldFromProp(str_replace("_IsEmpty", "", $prop));
                         $this->_where .= $this->_where_delim . " " . $dbfield . " = ''";
                         $this->_where_delim = " and";
-                    } elseif (substr($prop, - 11) == "_IsNotEmpty" && $this->$prop) {
+                    } elseif (substr($prop, - 11) == "_IsNotEmpty" && $this->$prop ?? '') {
                         $dbfield = $this->GetFieldFromProp(str_replace("_IsNotEmpty", "", $prop));
                         $this->_where .= $this->_where_delim . " " . $dbfield . " != ''";
                         $this->_where_delim = " and";
-                    } elseif (substr($prop, - 7) == "_IsLike" && strlen($this->$prop)) {
+                    } elseif (substr($prop, - 7) == "_IsLike" && strlen($this->$prop ?? '')) {
                         $dbfield = $this->GetFieldFromProp(str_replace("_IsLike", "", $prop));
                         $this->_where .= $this->_where_delim . " " . $dbfield . " like '%" . $this->Escape($val) . "%'";
                         $this->_where_delim = " and";
-                    } elseif (substr($prop, - 10) == "_IsNotLike" && strlen($this->$prop)) {
+                    } elseif (substr($prop, - 10) == "_IsNotLike" && strlen($this->$prop ?? '')) {
                         $dbfield = $this->GetFieldFromProp(str_replace("_IsNotLike", "", $prop));
                         $this->_where .= $this->_where_delim . " " . $dbfield . " not like '%" . $this->Escape($val) . "%'";
                         $this->_where_delim = " and";
-                    } elseif (substr($prop, - 11) == "_BeginsWith" && strlen($this->$prop)) {
+                    } elseif (substr($prop, - 11) == "_BeginsWith" && strlen($this->$prop ?? '')) {
                         $dbfield = $this->GetFieldFromProp(str_replace("_BeginsWith", "", $prop));
                         $this->_where .= $this->_where_delim . " " . $dbfield . " like '" . $this->Escape($val) . "%'";
                         $this->_where_delim = " and";
-                    } elseif (substr($prop, - 9) == "_EndsWith" && strlen($this->$prop)) {
+                    } elseif (substr($prop, - 9) == "_EndsWith" && strlen($this->$prop ?? '')) {
                         $dbfield = $this->GetFieldFromProp(str_replace("_EndsWith", "", $prop));
                         $this->_where .= $this->_where_delim . " " . $dbfield . " like '%" . $this->Escape($val) . "'";
                         $this->_where_delim = " and";
-                    } elseif (substr($prop, - 12) == "_GreaterThan" && strlen($this->$prop)) {
+                    } elseif (substr($prop, - 12) == "_GreaterThan" && strlen($this->$prop ?? '')) {
                         $dbfield = $this->GetFieldFromProp(str_replace("_GreaterThan", "", $prop));
                         $this->_where .= $this->_where_delim . " " . $dbfield . " > " . $this->GetQuotedSql($val) . "";
                         $this->_where_delim = " and";
-                    } elseif (substr($prop, - 19) == "_GreaterThanOrEqual" && strlen($this->$prop)) {
+                    } elseif (substr($prop, - 19) == "_GreaterThanOrEqual" && strlen($this->$prop ?? '')) {
                         $dbfield = $this->GetFieldFromProp(str_replace("_GreaterThanOrEqual", "", $prop));
                         $this->_where .= $this->_where_delim . " " . $dbfield . " >= " . $this->GetQuotedSql($val) . "";
                         $this->_where_delim = " and";
-                    } elseif (substr($prop, - 9) == "_LessThan" && strlen($this->$prop)) {
+                    } elseif (substr($prop, - 9) == "_LessThan" && strlen($this->$prop ?? '')) {
                         $dbfield = $this->GetFieldFromProp(str_replace("_LessThan", "", $prop));
                         $this->_where .= $this->_where_delim . " " . $dbfield . " < " . $this->GetQuotedSql($val) . "";
                         $this->_where_delim = " and";
-                    } elseif (substr($prop, - 16) == "_LessThanOrEqual" && strlen($this->$prop)) {
+                    } elseif (substr($prop, - 16) == "_LessThanOrEqual" && strlen($this->$prop ?? '')) {
                         $dbfield = $this->GetFieldFromProp(str_replace("_LessThanOrEqual", "", $prop));
                         $this->_where .= $this->_where_delim . " " . $dbfield . " <= " . $this->GetQuotedSql($val) . "";
                         $this->_where_delim = " and";
-                    } elseif (substr($prop, - 10) == "_BitwiseOr" && strlen($this->$prop)) {
+                    } elseif (substr($prop, - 10) == "_BitwiseOr" && strlen($this->$prop ?? '')) {
                         $dbfield = $this->GetFieldFromProp(str_replace("_BitwiseOr", "", $prop));
                         $this->_where .= $this->_where_delim . " (" . $dbfield . " | '" . $this->Escape($val) . ")";
                         $this->_where_delim = " and";
-                    } elseif (substr($prop, - 11) == "_BitwiseAnd" && strlen($this->$prop)) {
+                    } elseif (substr($prop, - 11) == "_BitwiseAnd" && strlen($this->$prop ?? '')) {
                         $dbfield = $this->GetFieldFromProp(str_replace("_BitwiseAnd", "", $prop));
                         $this->_where .= $this->_where_delim . " (" . $dbfield . " & " . $this->Escape($val) . ")";
                         $this->_where_delim = " and";
-                    } elseif (substr($prop, - 16) == "_LiteralFunction" && strlen($this->$prop)) {
+                    } elseif (substr($prop, - 16) == "_LiteralFunction" && strlen($this->$prop ?? '')) {
                         $dbfield = $this->GetFieldFromProp(str_replace("_LiteralFunction", "", $prop));
                         $this->_where .= $this->_where_delim . " (" . $dbfield . " " . $val . ")";
                         $this->_where_delim = " and";
                     } elseif (substr($prop, - 3) == "_In" && isset($val)) {
                         // if a string was passed in then treat it as comma-delimited
diff --git a/portal/patient/fwk/libs/verysimple/Phreeze/DataPage.php b/portal/patient/fwk/libs/verysimple/Phreeze/DataPage.php
index be09fde562..e23f8a67e5 100644
--- a/portal/patient/fwk/libs/verysimple/Phreeze/DataPage.php
+++ b/portal/patient/fwk/libs/verysimple/Phreeze/DataPage.php
@@ -44,31 +44,36 @@ class DataPage implements Iterator
 
     /**
      *
      * @return Phreezable
      */
+    #[\ReturnTypeWillChange]
     public function Next()
     {
         return next($this->Rows);
     }
+    #[\ReturnTypeWillChange]
     public function rewind()
     {
         reset($this->Rows);
     }
 
     /**
      *
      * @return Phreezable
      */
+    #[\ReturnTypeWillChange]
     public function current()
     {
         return current($this->Rows);
     }
+    #[\ReturnTypeWillChange]
     public function key()
     {
         return key($this->Rows);
     }
+    #[\ReturnTypeWillChange]
     public function valid()
     {
         return $this->current() !== false;
     }
 
diff --git a/portal/patient/fwk/libs/verysimple/Phreeze/DataSet.php b/portal/patient/fwk/libs/verysimple/Phreeze/DataSet.php
index 3e6928b968..9404fab066 100644
--- a/portal/patient/fwk/libs/verysimple/Phreeze/DataSet.php
+++ b/portal/patient/fwk/libs/verysimple/Phreeze/DataSet.php
@@ -91,10 +91,11 @@ class DataSet implements Iterator // @TODO implement Countable, ArrayAccess
      * Next returns the next object in the collection.
      *
      * @access public
      * @return Preezable
      */
+    #[\ReturnTypeWillChange]
     function Next()
     {
         if ($this->UnableToCache) {
             require_once("verysimple/Util/ExceptionFormatter.php");
             $info = ExceptionFormatter::FormatTrace(debug_backtrace());
@@ -145,30 +146,34 @@ class DataSet implements Iterator // @TODO implement Countable, ArrayAccess
      */
     public function Execute()
     {
         return $this->_phreezer->DataAdapter->Execute($this->_sql);
     }
+    #[\ReturnTypeWillChange]
     public function rewind()
     {
         $this->_rs = null;
         $this->_counter = 0;
         $this->_no_exception = true;
         $this->_total = $this->Count();
         $this->_verifyRs();
         $this->Next(); // we have to get the party started for php iteration
     }
+    #[\ReturnTypeWillChange]
     public function current()
     {
         // php iteration calls next then gets the current record. The DataSet
         // Next return the current object. so, we have to fudge a little on the
         // laster iteration to make it work properly
         return ($this->key() == $this->Count()) ? $this->_last : $this->_current;
     }
+    #[\ReturnTypeWillChange]
     public function key()
     {
         return $this->_counter;
     }
+    #[\ReturnTypeWillChange]
     public function valid()
     {
         return $this->key() <= $this->Count();
     }
 
diff --git a/portal/patient/fwk/libs/verysimple/Phreeze/Phreezable.php b/portal/patient/fwk/libs/verysimple/Phreeze/Phreezable.php
index 246a0d2d88..f9893acecb 100644
--- a/portal/patient/fwk/libs/verysimple/Phreeze/Phreezable.php
+++ b/portal/patient/fwk/libs/verysimple/Phreeze/Phreezable.php
@@ -429,11 +429,11 @@ abstract class Phreezable implements Serializable
                                 $this->AddValidationError($prop, "$prop is not a valid number");
                             }
                             break;
                         case FM_TYPE_DATE:
                         case FM_TYPE_DATETIME:
-                            if (strtotime($this->$prop) === '') {
+                            if (strtotime(($this->$prop ?? '')) === '') {
                                 $this->AddValidationError($prop, "$prop is not a valid date/time value.");
                             }
                             break;
                         case FM_TYPE_ENUM:
                             if (! in_array($this->$prop, $fm->GetEnumValues())) {
@@ -785,6 +785,12 @@ abstract class Phreezable implements Serializable
      */
     public function __set($key, $val)
     {
         throw new Exception("Unknown property: $key");
     }
+
+    function __serialize()
+    {}
+
+    function __unserialize($data)
+    {}
 }
diff --git a/portal/patient/fwk/libs/verysimple/Phreeze/Reporter.php b/portal/patient/fwk/libs/verysimple/Phreeze/Reporter.php
index 75de195172..75fe1561df 100644
--- a/portal/patient/fwk/libs/verysimple/Phreeze/Reporter.php
+++ b/portal/patient/fwk/libs/verysimple/Phreeze/Reporter.php
@@ -340,6 +340,12 @@ abstract class Reporter implements Serializable
      * @access protected
      */
     protected function OnLoad()
     {
     }
+
+    function __serialize()
+    {}
+
+    function __unserialize($data)
+    {}
 }
diff --git a/portal/patient/libs/Controller/PortalPatientController.php b/portal/patient/libs/Controller/PortalPatientController.php
index fd6e1a49f3..cfbfbf2b78 100644
--- a/portal/patient/libs/Controller/PortalPatientController.php
+++ b/portal/patient/libs/Controller/PortalPatientController.php
@@ -193,11 +193,13 @@ class PortalPatientController extends AppBasePortalController
             $patient->HipaaAllowemail = $this->SafeGetVal($json, 'hipaaAllowemail', $patient->HipaaAllowemail);
             /*$patient->Squad = $this->SafeGetVal($json, 'squad', $patient->Squad);
             $patient->Fitness = $this->SafeGetVal($json, 'fitness', $patient->Fitness);
             $patient->ReferralSource = $this->SafeGetVal($json, 'referralSource', $patient->ReferralSource);
             $patient->Pricelevel = $this->SafeGetVal($json, 'pricelevel', $patient->Pricelevel);*/
-            $patient->Regdate = date('Y-m-d', strtotime($this->SafeGetVal($json, 'regdate', $patient->Regdate)));
+            if (!empty($patient->Regdate)) {
+                $patient->Regdate = date('Y-m-d', strtotime($this->SafeGetVal($json, 'regdate', $patient->Regdate)));
+            }
             /*$patient->Contrastart = date('Y-m-d', strtotime($this->SafeGetVal($json, 'contrastart', $patient->Contrastart)));
             $patient->CompletedAd = $this->SafeGetVal($json, 'completedAd', $patient->CompletedAd);
             $patient->AdReviewed = date('Y-m-d', strtotime($this->SafeGetVal($json, 'adReviewed', $patient->AdReviewed)));
             $patient->Vfc = $this->SafeGetVal($json, 'vfc', $patient->Vfc);*/
             $patient->Mothersname = $this->SafeGetVal($json, 'mothersname', $patient->Mothersname);
diff --git a/portal/patient/templates/OnsiteActivityViewListView.tpl.php b/portal/patient/templates/OnsiteActivityViewListView.tpl.php
index e009350d52..5ae19be253 100644
--- a/portal/patient/templates/OnsiteActivityViewListView.tpl.php
+++ b/portal/patient/templates/OnsiteActivityViewListView.tpl.php
@@ -8,15 +8,22 @@
  * @author    Jerry Padgett <sjpadgett@gmail.com>
  * @copyright Copyright (c) 2016-2020 Jerry Padgett <sjpadgett@gmail.com>
  * @license   https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
  */
 
-    $this->assign('title', xlt('Portal') . ' | ' . xlt('Activity'));
-    $this->assign('nav', 'onsiteactivityviews');
+$this->assign('title', xlt('Portal') . ' | ' . xlt('Activity'));
+$this->assign('nav', 'onsiteactivityviews');
 
-    $this->display('_FormsHeader.tpl.php');
-    echo "<script>var cuser='" . $this->cuser . "';</script>";
+use OpenEMR\Common\Acl\AclMain;
+
+if (!AclMain::aclCheckCore('patientportal', 'portal')) {
+    die(xlt("Unauthorized"));
+    exit;
+}
+
+$this->display('_FormsHeader.tpl.php');
+echo "<script>var cuser='" . $this->cuser . "';</script>";
 ?>
 <script>
     $LAB.script("<?php echo $GLOBALS['web_root']; ?>/portal/patient/scripts/app/onsiteactivityviews.js?v=<?php echo $GLOBALS['v_js_includes']; ?>").wait(function(){
         $(function () {
             actpage.init();
diff --git a/portal/patient/templates/ProviderHome.tpl.php b/portal/patient/templates/ProviderHome.tpl.php
index 8cf9209c62..7883c2a2c0 100644
--- a/portal/patient/templates/ProviderHome.tpl.php
+++ b/portal/patient/templates/ProviderHome.tpl.php
@@ -11,12 +11,18 @@
  */
 
 $this->assign('title', xlt("Portal Dashboard") . " | " . xlt("Home"));
 $this->assign('nav', 'home');
 
+use OpenEMR\Common\Acl\AclMain;
 use OpenEMR\Core\Header;
 
+if (!AclMain::aclCheckCore('patientportal', 'portal')) {
+    die(xlt("Unauthorized"));
+    exit;
+}
+
 ?>
 <!DOCTYPE html>
 <!-- Language grabbed by PDF var that has the correct format !-->
 <html lang="<?php echo $GLOBALS['pdf_language']; ?>">
 <head>
diff --git a/portal/report/portal_patient_report.php b/portal/report/portal_patient_report.php
index c75df113e7..afc3001877 100644
--- a/portal/report/portal_patient_report.php
+++ b/portal/report/portal_patient_report.php
@@ -468,11 +468,11 @@ while ($prow = sqlFetchArray($pres)) {
 
     while ($result = sqlFetchArray($res)) {
         if ($result["form_name"] == "New Patient Encounter") {
             if ($isfirst == 0) {
                 foreach ($registry_form_name as $var) {
-                    if ($toprint = $html_strings[$var]) {
+                    if ($toprint = ($html_strings[$var] ?? '')) {
                         foreach ($toprint as $var) {
                             print $var;
                         }
                     }
                 }
diff --git a/portal/sign/lib/save-signature.php b/portal/sign/lib/save-signature.php
index 475f143ab4..59b485030b 100644
--- a/portal/sign/lib/save-signature.php
+++ b/portal/sign/lib/save-signature.php
@@ -37,10 +37,22 @@ if ($isPortal) {
         exit();
     }
 }
 require_once("../../../interface/globals.php");
 
+if (!$isPortal) {
+    $userManipulatedFlag = false;
+    if ($user != $_SESSION['authUserID']) {
+        $userManipulatedFlag = true;
+    }
+
+    if ($userManipulatedFlag) {
+        echo js_escape("error");
+        exit();
+    }
+}
+
 if ($type === 'witness-signature') {
     echo(js_escape('Done'));
     exit();
 }
 if ($_SERVER['REQUEST_METHOD'] === 'POST') {
diff --git a/portal/sign/lib/show-signature.php b/portal/sign/lib/show-signature.php
index f2846680a0..16b0114ad7 100644
--- a/portal/sign/lib/show-signature.php
+++ b/portal/sign/lib/show-signature.php
@@ -36,10 +36,22 @@ if ($isPortal) {
         exit();
     }
 }
 require_once("../../../interface/globals.php");
 
+if (!$isPortal) {
+    $userManipulatedFlag = false;
+    if ($user != $_SESSION['authUserID']) {
+        $userManipulatedFlag = true;
+    }
+
+    if ($userManipulatedFlag) {
+        echo js_escape("error");
+        exit();
+    }
+}
+
 $created = time();
 $lastmod = date('Y-m-d H:i:s');
 $status = 'filed';
 $info_query = array();
 $isAdmin = ($type === 'admin-signature');
@@ -55,11 +67,11 @@ if ($req_pid === 0 || empty($user)) {
         echo(js_escape('error not an admin'));
         exit();
     }
 }
 
-if ($data['mode'] === 'fetch_info') {
+if (($data['mode'] ?? null) === 'fetch_info') {
     $stmt = "Select CONCAT(IFNULL(fname,''), ' ',IFNULL(lname,'')) as userName From users Where id = ?";
     $user_result = sqlQuery($stmt, array($user)) ?: [];
     $stmt = "Select CONCAT(IFNULL(fname,''), ' ',IFNULL(lname,'')) as ptName From patient_data Where pid = ?";
     $pt_result = sqlQuery($stmt, array($req_pid)) ?: [];
     $signature = [];
@@ -85,24 +97,24 @@ if ($isAdmin) {
     $row = sqlQuery("SELECT pid,status,sig_image,type,user FROM onsite_signatures WHERE user=? && type=?", array($user, $type));
 } else {
     $row = sqlQuery("SELECT pid,status,sig_image,type,user FROM onsite_signatures WHERE pid=? And user=?", array($req_pid, $user));
 }
 
-if (!$row['pid'] && !$row['user']) {
+if (!($row['pid'] ?? null) && !($row['user'] ?? null)) {
     $status = 'waiting';
     $qstr = "INSERT INTO onsite_signatures (pid,lastmod,status,type,user,signator,created) VALUES (?,?,?,?,?,?,?)";
     sqlStatement($qstr, array($req_pid, $lastmod, $status, $type, $user, $signer, $created));
 }
 
-if ($row['status'] == 'filed') {
-    if ($data['mode'] === 'fetch_info') {
+if (($row['status'] ?? null) == 'filed') {
+    if (($data['mode'] ?? null) === 'fetch_info') {
         $info_query['signature'] = $row['sig_image'];
         echo js_escape($info_query);
         exit();
     }
     echo js_escape($row['sig_image']);
-} elseif ($row['status'] == 'waiting' || $status == 'waiting') {
+} elseif (($row['status'] ?? null) == 'waiting' || $status == 'waiting') {
     $info_query['message'] = 'waiting';
     echo js_escape($info_query);
 }
 
 exit();
diff --git a/src/Gacl/Gacl.php b/src/Gacl/Gacl.php
index e5466cc356..fc9545146f 100644
--- a/src/Gacl/Gacl.php
+++ b/src/Gacl/Gacl.php
@@ -564,10 +564,13 @@ class Gacl {
 				        $retarr = array('acl_id' => &$row[0], 'return_value' => &$row[2], 'allow' => $allow);
                                 }
 			} else {
                                 if ($return_all) {
 			                // Permission denied.
+                            if(!is_array($retarr)) {
+                                $retarr = [];
+                            }
 			                $retarr[] = array('acl_id' => NULL, 'return_value' => NULL, 'allow' => FALSE);
                                 }
                                 else {
                                         // Permission denied.
                                         $retarr = array('acl_id' => NULL, 'return_value' => NULL, 'allow' => FALSE);

Vulnerable code:                     } elseif (substr($prop, - 7) == "_Equals" && strlen($this->$prop)) {
                    } elseif (substr($prop, - 10) == "_NotEquals" && strlen($this->$prop)) {
                    } elseif (substr($prop, - 8) == "_IsEmpty" && $this->$prop) {
                    } elseif (substr($prop, - 11) == "_IsNotEmpty" && $this->$prop) {
                    } elseif (substr($prop, - 7) == "_IsLike" && strlen($this->$prop)) {
                    } elseif (substr($prop, - 10) == "_IsNotLike" && strlen($this->$prop)) {
                    } elseif (substr($prop, - 11) == "_BeginsWith" && strlen($this->$prop)) {
                    } elseif (substr($prop, - 9) == "_EndsWith" && strlen($this->$prop)) {
                    } elseif (substr($prop, - 12) == "_GreaterThan" && strlen($this->$prop)) {
                    } elseif (substr($prop, - 19) == "_GreaterThanOrEqual" && strlen($this->$prop)) {
                    } elseif (substr($prop, - 9) == "_LessThan" && strlen($this->$prop)) {
                    } elseif (substr($prop, - 16) == "_LessThanOrEqual" && strlen($this->$prop)) {
                    } elseif (substr($prop, - 10) == "_BitwiseOr" && strlen($this->$prop)) {
                    } elseif (substr($prop, - 11) == "_BitwiseAnd" && strlen($this->$prop)) {
                    } elseif (substr($prop, - 16) == "_LiteralFunction" && strlen($this->$prop)) {
                            if (strtotime($this->$prop) === '') {
            $patient->Regdate = date('Y-m-d', strtotime($this->SafeGetVal($json, 'regdate', $patient->Regdate)));
    $this->assign('title', xlt('Portal') . ' | ' . xlt('Activity'));
    $this->assign('nav', 'onsiteactivityviews');
    $this->display('_FormsHeader.tpl.php');
    echo "<script>var cuser='" . $this->cuser . "';</script>";
                    if ($toprint = $html_strings[$var]) {
if ($data['mode'] === 'fetch_info') {
if (!$row['pid'] && !$row['user']) {
if ($row['status'] == 'filed') {
    if ($data['mode'] === 'fetch_info') {
} elseif ($row['status'] == 'waiting' || $status == 'waiting') {
Fixed code:                     } elseif (substr($prop, - 7) == "_Equals" && strlen($this->$prop ?? '')) {
                    } elseif (substr($prop, - 10) == "_NotEquals" && strlen($this->$prop ?? '')) {
                    } elseif (substr($prop, - 8) == "_IsEmpty" && $this->$prop ?? '') {
                    } elseif (substr($prop, - 11) == "_IsNotEmpty" && $this->$prop ?? '') {
                    } elseif (substr($prop, - 7) == "_IsLike" && strlen($this->$prop ?? '')) {
                    } elseif (substr($prop, - 10) == "_IsNotLike" && strlen($this->$prop ?? '')) {
                    } elseif (substr($prop, - 11) == "_BeginsWith" && strlen($this->$prop ?? '')) {
                    } elseif (substr($prop, - 9) == "_EndsWith" && strlen($this->$prop ?? '')) {
                    } elseif (substr($prop, - 12) == "_GreaterThan" && strlen($this->$prop ?? '')) {
                    } elseif (substr($prop, - 19) == "_GreaterThanOrEqual" && strlen($this->$prop ?? '')) {
                    } elseif (substr($prop, - 9) == "_LessThan" && strlen($this->$prop ?? '')) {
                    } elseif (substr($prop, - 16) == "_LessThanOrEqual" && strlen($this->$prop ?? '')) {
                    } elseif (substr($prop, - 10) == "_BitwiseOr" && strlen($this->$prop ?? '')) {
                    } elseif (substr($prop, - 11) == "_BitwiseAnd" && strlen($this->$prop ?? '')) {
                    } elseif (substr($prop, - 16) == "_LiteralFunction" && strlen($this->$prop ?? '')) {
    #[\ReturnTypeWillChange]
    #[\ReturnTypeWillChange]
    #[\ReturnTypeWillChange]
    #[\ReturnTypeWillChange]
    #[\ReturnTypeWillChange]
    #[\ReturnTypeWillChange]
    #[\ReturnTypeWillChange]
    #[\ReturnTypeWillChange]
    #[\ReturnTypeWillChange]
    #[\ReturnTypeWillChange]
                            if (strtotime(($this->$prop ?? '')) === '') {

    function __serialize()
    {}

    function __unserialize($data)
    {}

    function __serialize()
    {}

    function __unserialize($data)
    {}
            if (!empty($patient->Regdate)) {
                $patient->Regdate = date('Y-m-d', strtotime($this->SafeGetVal($json, 'regdate', $patient->Regdate)));
            }
$this->assign('title', xlt('Portal') . ' | ' . xlt('Activity'));
$this->assign('nav', 'onsiteactivityviews');
use OpenEMR\Common\Acl\AclMain;

if (!AclMain::aclCheckCore('patientportal', 'portal')) {
    die(xlt("Unauthorized"));
    exit;
}

$this->display('_FormsHeader.tpl.php');
echo "<script>var cuser='" . $this->cuser . "';</script>";
use OpenEMR\Common\Acl\AclMain;
if (!AclMain::aclCheckCore('patientportal', 'portal')) {
    die(xlt("Unauthorized"));
    exit;
}

                    if ($toprint = ($html_strings[$var] ?? '')) {
if (!$isPortal) {
    $userManipulatedFlag = false;
    if ($user != $_SESSION['authUserID']) {
        $userManipulatedFlag = true;
    }

    if ($userManipulatedFlag) {
        echo js_escape("error");
        exit();
    }
}

if (!$isPortal) {
    $userManipulatedFlag = false;
    if ($user != $_SESSION['authUserID']) {
        $userManipulatedFlag = true;
    }

    if ($userManipulatedFlag) {
        echo js_escape("error");
        exit();
    }
}

if (($data['mode'] ?? null) === 'fetch_info') {
if (!($row['pid'] ?? null) && !($row['user'] ?? null)) {
if (($row['status'] ?? null) == 'filed') {
    if (($data['mode'] ?? null) === 'fetch_info') {
} elseif (($row['status'] ?? null) == 'waiting' || $status == 'waiting') {
                            if(!is_array($retarr)) {
                                $retarr = [];
                            }