$relQ = new Query_Relative(); $relQ->captureError(true); $recordQ = new Query_Page_Record(); $n = count($_POST["check"]); for ($i = 0; $i < $n; $i++) { if ($idPatient == $_POST["check"][$i]) { continue; // a patient can't be relative of himself } $relQ->insert($idPatient, $_POST["check"][$i]); if ($relQ->isError()) { if ($relQ->getDbErrno() == 1062) { $relQ->clearErrors(); } else { $relQ->close(); Error::query($relQ); } } else { /** * Record log process */ $recordQ->log("Query_Relative", "INSERT", array($idPatient, $_POST["check"][$i])); } } $recordQ->close(); unset($recordQ); $relQ->close(); unset($relQ); /** * Reset abort setting */
$sessLoginAttempts = 1; $_SESSION['auth']['last_login'] = ''; } else { if (!$userQ->isActivated($loginSession)) { $userQ->close(); $_SESSION = array(); // deregister all current session variables FlashMsg::add(_("Your user account has been suspended. Contact with administrator to resolve this problem.")); header("Location: ../home/index.php"); exit; } $formSession = Form::getSession(); $lastLogin = isset($_SESSION['auth']['last_login']) ? $_SESSION['auth']['last_login'] : ''; if (!$userQ->verifySignOn($loginSession, $pwdSession)) { $userQ->close(); Error::query($userQ); } $user = $userQ->fetch(); if (!$user) { /** * Invalid password. Add one to login attempts. */ $errorFound = true; $formError["pwd_session"] = _("Invalid sign on."); if (!isset($_SESSION['auth']['login_attempts']) || $_SESSION['auth']['login_attempts'] == "") { $sessLoginAttempts = 1; } else { if ($loginSession == $lastLogin) { $sessLoginAttempts = $_SESSION['auth']['login_attempts'] + 1; } else { $sessLoginAttempts = 1;
if (count($relArray) == 0) { echo Msg::info(_("No relatives defined for this patient.")); include_once "../layout/footer.php"; exit; } echo HTML::rule(); echo HTML::section(2, _("Relatives List:")); $thead = array(_("#"), _("Function") => array('colspan' => $_SESSION['auth']['is_administrative'] ? 2 : 1), _("Surname 1"), _("Surname 2"), _("First Name")); $options = array(0 => array('align' => 'right')); $patQ = new Query_Page_Patient(); $patQ->captureError(true); $tbody = array(); for ($i = 0; $i < count($relArray); $i++) { $patQ->select($relArray[$i]); if ($patQ->isError()) { Error::query($patQ, false); continue; } $pat = $patQ->fetch(); if (!$pat) { $patQ->close(); Error::fetch($patQ); } $relName = $pat->getFirstName() . " " . $pat->getSurname1() . " " . $pat->getSurname2(); $row = $i + 1 . '.'; $row .= OPEN_SEPARATOR; $row .= HTML::link(HTML::image('../img/action_view.png', _("view")), '../medical/patient_view.php', array('id_patient' => $pat->getIdPatient())); $row .= OPEN_SEPARATOR; if ($_SESSION['auth']['is_administrative']) { $row .= HTML::link(HTML::image('../img/action_delete.png', _("delete")), '../medical/relative_del_confirm.php', array('id_patient' => $idPatient, 'id_relative' => $pat->getIdPatient())); $row .= OPEN_SEPARATOR;
/** * bool exec(string $sql, array $params = null) * * Executes a query * * @param string $sql SQL of query to execute * @param array $params (optional) SQL parameters to prepare sentence * @return boolean returns false, if error occurs * @access public * @since 0.6 */ public function exec($sql, $params = null) { $this->_SQL = $sql; $result = $this->_conn->exec($sql, $params); if ($result === false) { $this->_isError = true; $this->_error = $this->_conn->getError(); $this->_dbErrno = $this->_conn->getDbErrno(); $this->_dbError = $this->_conn->getDbError(); if (!$this->_captureError) { $this->close(); Error::query($this); } } return $result; }
$connQ->close(); unset($connQ); if (count($connArray) == 0) { echo Msg::info(_("No connections defined for this medical problem.")); include_once "../layout/footer.php"; exit; } echo HTML::section(2, _("Connection Problems List:")); $thead = array(_("#"), _("Function") => array('colspan' => $_SESSION['auth']['is_administrative'] ? 2 : 1), _("Opening Date"), _("Wording")); $problemQ = new Query_Page_Problem(); $problemQ->captureError(true); $tbody = array(); for ($i = 0; $i < count($connArray); $i++) { $problemQ->select($connArray[$i]); if ($problemQ->isError()) { Error::query($problemQ, false); continue; } $problem = $problemQ->fetch(); if (!$problem) { $problemQ->close(); Error::fetch($problemQ); } $row = $i + 1 . '.'; $row .= OPEN_SEPARATOR; $row .= HTML::link(HTML::image('../img/action_view.png', _("view")), '../medical/problem_view.php', array('id_problem' => $problem->getIdProblem(), 'id_patient' => $idPatient)); $row .= OPEN_SEPARATOR; if ($_SESSION['auth']['is_administrative']) { $row .= HTML::link(HTML::image('../img/action_delete.png', _("delete")), '../medical/connection_del_confirm.php', array('id_problem' => $idProblem, 'id_patient' => $idPatient, 'id_connection' => $problem->getIdProblem())); $row .= OPEN_SEPARATOR; }
$connQ = new Query_Connection(); $recordQ = new Query_Page_Record(); $n = count($_POST["check"]); for ($i = 0; $i < $n; $i++) { if ($idProblem == $_POST["check"][$i]) { continue; // a problem can't be connection of itself } $connQ->captureError(true); $connQ->insert($idProblem, $_POST["check"][$i]); if ($connQ->isError()) { if ($connQ->getDbErrno() == 1062) { $connQ->clearErrors(); } else { $connQ->close(); Error::query($connQ); } } else { /** * Record log process */ $recordQ->log("Query_Connection", "INSERT", array($idProblem, $_POST["check"][$i])); } } $recordQ->close(); unset($recordQ); $connQ->close(); unset($connQ); /** * Reset abort setting */
/** * bool parseSql(string $text) * * Parses a SQL text * * @param string $text sentences to parse * @return bool false if an error occurs * @access public * @since 0.8 */ function parseSql($text) { $controlledErrors = array(1060, 1091); $installQ = new Query(); $installQ->captureError(true); /** * reading through SQL text executing SQL only when ";" is encountered and if is out of brackets */ $count = strlen($text); $sqlSentence = ""; $outBracket = true; for ($i = 0; $i < $count; $i++) { $char = $text[$i]; if ($char == "(") { $outBracket = false; } if ($char == ")") { $outBracket = true; } if ($char == ";" && $outBracket) { $result = $installQ->exec($sqlSentence); if ($installQ->isError() && !in_array($installQ->getDbErrno(), $controlledErrors)) { echo HTML::para(sprintf(_("Process sql [%s]"), $sqlSentence)); $installQ->close(); Error::query($installQ, false); echo Msg::error(sprintf(_("Error: %s"), $installQ->getDbError())); return false; } $sqlSentence = ""; } else { $sqlSentence .= $char; } } $installQ->close(); return true; }