Esempio n. 1
0
        echo HTML::start('form', array('method' => 'post', 'action' => $_SERVER['PHP_SELF'] . '?confirm=yes'));
        echo HTML::para(Form::button("continue", _("Continue")) . Form::generateToken());
        echo HTML::end('form');
        echo HTML::para(HTML::link(_("Cancel"), './index.php'));
        include_once "../layout/footer.php";
        exit;
    }
}
$setQ->close();
unset($setQ);
unset($set);
/**
 * Creating each table listed in the $tables array
 */
$tables = getTables();
foreach ($tables as $tableName) {
    $result = parseSqlFile("./sql/" . $tableName . ".sql", $tableName, true);
    if ($result) {
        $text = sprintf(_("Table %s dropped."), $tableName) . PHP_EOL;
        $text .= sprintf(_("Table %s created."), $tableName) . PHP_EOL;
        $text .= str_repeat(".", 50);
        echo HTML::para(nl2br($text));
    } else {
        echo Msg::error(_("Last instruction failed"));
        include_once "../layout/footer.php";
        exit;
    }
}
echo Msg::info(_("OpenClinic tables have been created successfully!"));
echo HTML::section(1, HTML::link(_("Start using OpenClinic"), '../home/index.php'));
require_once "../layout/footer.php";
}
/**
 * Retrieving get var
 */
$idPatient = intval($_GET["id_patient"]);
/**
 * Search database for patient
 */
$patQ = new Query_Page_Patient();
if (!$patQ->select($idPatient)) {
    $patQ->close();
    include_once "../layout/xhtml_start.php";
    echo $style;
    echo HTML::end('head');
    echo HTML::start('body');
    echo Msg::error(_("That patient does not exist."));
    echo HTML::para(HTML::link(_("Close Window"), '#', null, array('onclick' => 'window.close(); return false;')));
    echo HTML::end('body');
    echo HTML::end('html');
    exit;
}
$pat = $patQ->fetch();
if (!$pat) {
    $patQ->close();
    Error::fetch($patQ);
}
$patQ->freeResult();
$patQ->close();
unset($patQ);
$patName = $pat->getFirstName() . " " . $pat->getSurname1() . " " . $pat->getSurname2();
/**
Esempio n. 3
0
    $body = array();
    $body[] = Form::textArea("sql_query", $sqlQuery, array('rows' => 15, 'cols' => 75, 'readonly' => true));
    $foot = array(Form::button("install_file", _("Install file")) . Form::generateToken());
    echo Form::fieldset(_("Install file"), $body, $foot);
    echo HTML::end('form');
    echo HTML::para(HTML::link(_("Cancel"), './index.php'));
    include_once "../layout/footer.php";
    exit;
}
// end if
require_once "../model/Query.php";
$installQ = new Query();
$installQ->captureError(true);
if ($installQ->isError()) {
    echo HTML::para(_("The connection to the database failed with the following error:"));
    echo Msg::error($installQ->getDbError());
    echo HTML::rule();
    echo HTML::para(_("Please make sure the following has been done before running this install script."));
    $array = array(sprintf(_("Create OpenClinic database (%s of the install instructions)"), HTML::link(sprintf(_("step %d"), 4), '../install.html#step4')), sprintf(_("Create OpenClinic database user (%s of the install instructions)"), HTML::link(sprintf(_("step %d"), 5), '../install.html#step5')), sprintf(_("Update %s with your new database username and password (%s of the install instructions)"), HTML::tag('strong', 'openclinic/config/database_constants.php'), HTML::link(sprintf(_("step %d"), 8), '../install.html#step8')));
    echo HTML::itemList($array, null, true);
    echo HTML::para(sprintf(_("See %s for more details."), HTML::link(_("Install Instructions"), '../install.html')));
    include_once "../layout/footer.php";
    exit;
}
// end if
$installQ->close();
echo Msg::info(_("Database connection is good."));
echo HTML::start('form', array('method' => 'post', 'action' => $_SERVER['PHP_SELF'], 'enctype' => 'multipart/form-data'));
$body = array();
$body[] = Form::file("sql_file", null, array('size' => 50));
$foot = array(Form::button("view_file", _("View file")));
Esempio n. 4
0
}
$tbody[] = $row;
$row = Form::label("birth_place", _("Natural de") . ":");
$row .= Form::text("birth_place", isset($formVar["birth_place"]) ? $formVar["birth_place"] : null, array('size' => 40, 'error' => isset($formError["birth_place"]) ? $formError["birth_place"] : null));
$tbody[] = $row;
$row = Form::label("dyear", _("Data de entrada na Pestalozzi") . ":");
$aux = explode("-", !empty($formVar["decease_date"]) ? $formVar["decease_date"] : '0000-00-00');
$row .= Form::text("dday", intval($aux[2]) != 0 ? intval($aux[2]) : null, array('size' => 2));
$row .= " - ";
$row .= Form::text("dmonth", intval($aux[1]) != 0 ? intval($aux[1]) : null, array('size' => 2));
$row .= " - ";
$row .= Form::text("dyear", intval($aux[0]) != 0 ? intval($aux[0]) : null, array('size' => 4));
$row .= " " . _("(dd-mm-aaaa)");
unset($aux);
if ($formError["decease_date"] != "") {
    $row .= Msg::error($formError["decease_date"]);
}
$tbody[] = $row;
$row = Form::label("nts", _("RG") . ":");
$row .= Form::text("nts", isset($formVar["nts"]) ? $formVar["nts"] : null, array('size' => 30, 'error' => isset($formError["nts"]) ? $formError["nts"] : null));
$tbody[] = $row;
$row = Form::label("nss", _("CPF") . ":");
$row .= Form::text("nss", isset($formVar["nss"]) ? $formVar["nss"] : null, array('size' => 30, 'error' => isset($formError["nss"]) ? $formError["nss"] : null));
$tbody[] = $row;
$row = Form::label("family_situation", _("Informações complementares") . ":");
$row .= Form::textArea("family_situation", $formVar["family_situation"], array('rows' => 3, 'cols' => 30));
$tbody[] = $row;
$row = Form::label("labour_situation", _("Trabalho dos familiares") . ":");
$row .= Form::textArea("labour_situation", $formVar["labour_situation"], array('rows' => 3, 'cols' => 30));
$tbody[] = $row;
$row = Form::label("education", _("Procedência do encaminhamento") . ":");
Esempio n. 5
0
 * Breadcrumb
 */
$links = array(_("Home") => "../home/index.php", $title => "");
echo HTML::breadcrumb($links, "icon icon_user");
unset($links);
/**
 * Error message if not session exists
 */
if (!is_dir(ini_get('session.save_path')) && ini_get('session.save_handler') == 'files') {
    echo Msg::error(_("No session support. Authentication process will fail. Check your PHP configuration."));
}
/**
 * Cookies disabled?
 */
if (!isset($_COOKIE[session_name()])) {
    echo Msg::error(_("You must have cookies enabled to access your account."));
}
/**
 * Warning message if loginAttempts == (OPEN_MAX_LOGIN_ATTEMPTS - 1)
 */
if (OPEN_MAX_LOGIN_ATTEMPTS && isset($_SESSION['auth']['login_attempts']) && $_SESSION['auth']['login_attempts'] == OPEN_MAX_LOGIN_ATTEMPTS - 1) {
    echo Msg::warning(_("Last attempt to type correct password before suspend this user account."));
}
/**
 * Login form
 */
echo HTML::start('form', array('id' => 'loginForm', 'method' => 'post', 'action' => '../auth/login.php'));
$tbody = array();
$row = Form::hidden("md5_session");
$tbody[] = $row;
$row = Form::label("login_session", _("Login") . ":");
Esempio n. 6
0
echo HTML::start('body', array('id' => 'top'));
echo HTML::start('div', array('id' => 'wrap'));
echo HTML::start('div', array('id' => 'header'));
echo appLogo();
$array = array(HTML::link(_("Close Window"), '#', null, array('onclick' => 'window.close(); return false;')));
echo HTML::itemList($array, array('id' => 'shortcuts'));
echo menuBar($tab);
echo HTML::end('div');
// #header
echo HTML::start('div', array('id' => 'main'));
echo HTML::start('div', array('id' => 'content'));
echo HTML::section(1, sprintf(_("This is a preview of the %s theme."), $_POST["theme_name"]));
echo HTML::para(HTML::link(_("Sample Link"), '#top'));
echo HTML::rule();
echo HTML::section(2, _("Subtitle Sample:"));
$thead = array(_("Table Heading") => array('colspan' => 2));
$tbody = array();
$tbody[] = array(sprintf(_("Sample data row %d"), 1));
$tbody[] = array(sprintf(_("Sample data row %d"), 2));
$row = Form::label("sample_text", _("Required Field") . ":", array('class' => 'required'));
$row .= OPEN_SEPARATOR;
$row .= Form::text("sample_text", _("Sample Input Text"), array('size' => 50, 'readonly' => true));
$tbody[] = explode(OPEN_SEPARATOR, $row);
$options = array('tfoot' => array('align' => 'center'), 'r0' => array('colspan' => 2), 'r1' => array('colspan' => 2));
$tfoot = array(Form::button("sample_button", _("Sample Button"), array('type' => 'button')));
echo HTML::table($thead, $tbody, $tfoot, $options);
echo Msg::error(_("Sample Error"));
echo Msg::warning(_("Sample Warning"));
echo Msg::info(_("Sample Info"));
echo Msg::hint(_("Sample Hint"));
require_once "../layout/footer.php";
Esempio n. 7
0
/**
 * Show page
 */
$title = _("Optimize Database");
require_once "../layout/header.php";
/**
 * Breadcrumb
 */
$links = array(_("Admin") => "../admin/index.php", _("Dumps") => "../admin/dump_view_form.php", $title => "");
echo HTML::breadcrumb($links, "icon icon_dump");
unset($links);
echo HTML::section(2, sprintf(_("Optimizing Database: %s"), OPEN_DATABASE));
$numTables = $auxConn->numRows();
if (!$numTables) {
    $auxConn->close();
    echo Msg::error(_("Database is empty."));
    include_once "../layout/footer.php";
    exit;
}
$thead = array(_("Table Name"), _("Size"), _("Status"), _("Space Saved"));
$options = array(1 => array('align' => 'right'), 3 => array('align' => 'right'));
$totalData = 0;
$totalIndex = 0;
$totalAll = 0;
$totalGain = 0;
$rows = null;
while ($row = $auxConn->fetchRow()) {
    $rows[] = $row;
}
$auxConn->freeResult();
$tbody = array();
Esempio n. 8
0
/**
 * bool _validateSettings(void)
 *
 * Validates settings of install wizard
 *
 * @return boolean true if all settings are ok, false otherwise
 * @access private
 *
 */
function _validateSettings()
{
    $error = "";
    if (empty($_POST['dbHost'])) {
        $error .= _("Database Host is empty.") . PHP_EOL;
    }
    if (empty($_POST['dbUser'])) {
        $error .= _("Database User is empty.") . PHP_EOL;
    }
    if (empty($_POST['dbName'])) {
        $error .= _("Database Name is empty.") . PHP_EOL;
    }
    if ($_POST['timeout'] <= 0) {
        $error .= _("Session Timeout must be great than zero.") . PHP_EOL;
    }
    if ($_POST['itemsPage'] <= 0) {
        $error .= _("Items per page must be great than zero.") . PHP_EOL;
    }
    if (strlen($_POST['passwd']) < 4) {
        $error .= _("Admin password must be at least 4 characters.") . PHP_EOL;
    }
    if (!empty($error)) {
        echo HTML::section(3, _("There were some errors"), array('class' => 'error'));
        echo Msg::error($error);
    }
    return empty($error);
}
Esempio n. 9
0
require_once "../lib/Msg.php";
// include HTML.php
/**
 * Retrieving get var
 */
$_file = $_GET['file'];
/**
 * XHTML Start (XML prolog, DOCTYPE, title page and meta data)
 */
$title = sprintf(_("Source file: %s"), $_file);
require_once "../layout/xhtml_start.php";
echo HTML::start('link', array('rel' => 'stylesheet', 'type' => 'text/css', 'href' => '../css/style.css'), true);
echo HTML::end('head');
$array['id'] = 'viewSource';
if (count($_GET) == 0 || empty($_file)) {
    $array['onload'] = 'window.close();';
}
echo HTML::start('body', $array);
if (isset($_SESSION['auth']['is_admin'])) {
    if (is_file($_file)) {
        highlight_file($_file);
    } else {
        echo Msg::error(_("No file found."));
        echo HTML::para(HTML::link(_("Close Window"), '#', null, array('onclick' => 'window.close(); return false;')));
    }
} else {
    echo Msg::warning(sprintf(_("You are not authorized to use %s tab."), _("Admin")));
    // maybe change
}
echo HTML::end('body');
echo HTML::end('html');
Esempio n. 10
0
echo HTML::section(1, $title);
echo HTML::para(sprintf(_("Finded version: %s"), $version));
foreach ($upgrades as $value) {
    $file = $value;
    // upgrade<initial_version>-<final_version>.sql
    $value = substr($value, strlen('upgrade'));
    // <initial_version>-<final_version>.sql
    $array = explode("-", $value);
    // 0 => <initial_version>, 1 => <final_version>.sql
    $initialVersion = $array[0];
    // <number>.<number>
    if (version_compare($version, $initialVersion, '<=')) {
        echo HTML::para(sprintf(_("Aplying %s file..."), HTML::tag('strong', $file)));
        if (!parseSqlFile('./upgrades/' . $file)) {
            //Error::debug($file); // debug
            echo Msg::error(sprintf(_("Error processing file: %s"), $file));
            include_once "../layout/footer.php";
            exit;
        }
    }
}
$setQ->captureError(false);
$setQ->select();
$set = $setQ->fetch();
echo HTML::para(sprintf(_("Upgraded to version: %s"), $set->getVersion()));
$setQ->close();
unset($setQ);
unset($set);
echo Msg::info(_("Database upgrade finished correctly!"));
echo HTML::para(HTML::link(_("Go to OpenClinic"), '../home/index.php'));
require_once "../layout/footer.php";
Esempio n. 11
0
/**
 * 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;
}