Example #1
0
    {
        global $files;
        if (preg_match('/^\\./', $value)) {
            unset($files[$key]);
        }
        if (preg_match('/_model/', $value)) {
            $files[$key] = ROOT . 'application/tests/models/' . $value;
        }
        if (preg_match('/_controller/', $value)) {
            $files[$key] = ROOT . 'application/tests/controllers/' . $value;
        }
        if (preg_match('/_view/', $value)) {
            $files[$key] = ROOT . 'application/tests/views/' . $value;
        }
        if (preg_match('/_library/', $value)) {
            $files[$key] = ROOT . 'application/tests/libraries/' . $value;
        }
        if (preg_match('/_helper/', $value)) {
            $files[$key] = ROOT . 'application/tests/helpers/' . $value;
        }
    }
    array_walk($files, 'prepare_array');
    //Add each file to the test suite
    foreach ($files as $file) {
        add_test($file, &$test);
    }
} else {
    add_test(ROOT . 'application/tests/' . $file, &$test);
}
//Run tests!
$test->run(new HtmlReporter());
Example #2
0
function autoImportPatientEntry($importPatient, $patientName)
{
    $query_string = "SELECT * FROM patient " . "WHERE name LIKE '{$patientName}'";
    $record = query_associative_one($query_string);
    if ($record) {
        $saved_db = DbUtil::switchToGlobal();
        $userId = $_SESSION['user_id'];
        $query = "SELECT * FROM lab_config_access where user_id = {$userId}";
        $record = query_associative_one($query);
        $labConfigId = $record['lab_config_id'];
        $currentLabPatient = Patient::getObject($record);
        $globalPatientId = $importPatient->patientId;
        $importLabConfigId = substr($globalPatientId, 0, 3);
        if ($importLabConfigId == $labConfigId) {
            return;
        }
        $subValue = $importLabConfigId . "00000000000";
        $importPatientIdStr = bcsub($globalPatientId, $subValue);
        $importPatientId = intval($importPatientIdStr);
        $saved_db = DbUtil::switchToLabConfig($importLabConfigId);
        $querySelect = "SELECT * FROM specimen " . "WHERE patient_id={$importPatientId}";
        $resultset = query_associative_all($querySelect, $rowCount);
        if ($resultset) {
            foreach ($resultset as $record) {
                $specimenRecords[] = Specimen::getObject($record);
            }
            foreach ($specimenRecords as $specimenRecord) {
                $querySelect = "SELECT * FROM test " . "WHERE specimen_id={$specimenRecord->specimenId}";
                $resultset = query_associative_all($querySelect, $rowCount);
                foreach ($resultset as $record) {
                    $testRecords[] = Test::getObject($record);
                }
            }
        }
        DbUtil::switchRestore($saved_db);
        /* Build a mapping of Specimens from the Global Table & make appropriate substitutions */
        $saved_db = DbUtil::switchToGlobal();
        $querySelect = "SELECT * FROM specimen_mapping";
        $resultset = query_associative_all($querySelect, $rowCount);
        if ($resultset) {
            $specimenIds = array();
            foreach ($resultset as $record) {
                $labIdSpecimenIds = explode(";", $record['lab_id_specimen_id']);
                foreach ($labIdSpecimenIds as $labIdSpecimenId) {
                    $labIdSpecimenIdsSeparated = explode(":", $labIdSpecimenId);
                    $labId = $labIdSpecimenIdsSeparated[0];
                    $specimenId = $labIdSpecimenIdsSeparated[1];
                    $specimenIds[$labId] = $specimenId;
                }
                foreach ($specimenRecords as $specimenRecord) {
                    if ($specimenIds[$labConfigId] == $specimenRecord->specimenTypeId) {
                        $specimenRecord->specimenTypeId = $specimenIds[$importLabConfigId];
                    }
                }
            }
        }
        /* Build a mapping of Tests from the Global Table & make appropriate substitutions */
        $querySelect = "SELECT * FROM test_mapping";
        $resultset = query_associative_all($querySelect, $rowCount);
        if ($resultset) {
            $testIds = array();
            foreach ($resultset as $record) {
                $labIdTestIds = explode(";", $record['lab_id_test_id']);
                foreach ($labIdTestIds as $labIdTestId) {
                    $labIdTestIdsSeparated = explode(":", $labIdTestId);
                    $labId = $labIdTestIdsSeparated[0];
                    $testId = $labIdTestIdsSeparated[1];
                    $testIds[$labId] = $testId;
                }
                foreach ($testRecords as $testRecord) {
                    if ($testIds[$labConfigId] == $testRecord->testTypeId) {
                        $testRecord->testTypeId = $testIds[$importLabConfigId];
                    }
                }
            }
        }
        DbUtil::switchRestore($saved_db);
        $i = 0;
        if ($specimenRecords) {
            foreach ($specimenRecords as $specimenRecord) {
                $saved_db = DbUtil::switchToLabConfig($importLabConfigId);
                $querySelect = "SELECT * FROM test " . "WHERE specimen_id={$specimenRecord->specimenId}";
                $resultset = query_associative_all($querySelect, $rowcount);
                DbUtil::switchRestore($saved_db);
                $specimenRecord->specimenId = get_max_specimen_id() + 1;
                $specimenRecord->patientId = $currentLabPatient->patientId;
                $specimenRecord->userId = $_SESSION['user_id'];
                $specimenRecord->doctor = '';
                add_specimen($specimenRecord);
                for ($j = 0; $j < count($resultset); $j++) {
                    $testRecord = $testRecords[$i];
                    $testRecord->specimenId = $specimenRecord->specimenId;
                    $testRecord->userId = $_SESSION['user_id'];
                    $i++;
                    add_test($testRecord);
                }
            }
        }
        DbUtil::switchRestore($saved_db);
    }
}
    header('Location: gradebook_tests.php');
    exit;
} else {
    if (isset($_POST['addATutorTest'])) {
        if (preg_match('/^at_(.*)$/', $_POST["id"], $matches) > 0) {
            if ($matches[1] == 0) {
                $sql = "SELECT * FROM " . TABLE_PREFIX . "tests t" . " WHERE course_id=" . $_SESSION["course_id"] . " AND num_takes = 1" . " AND NOT EXISTS (SELECT 1" . " FROM " . TABLE_PREFIX . "gradebook_tests g" . " WHERE g.id = t.test_id" . " AND g.type='ATutor Test')";
                $result = mysql_query($sql, $db) or die(mysql_error());
                while ($row = mysql_fetch_assoc($result)) {
                    add_test($row["test_id"], $row["title"]);
                }
            } else {
                $sql = "SELECT * FROM " . TABLE_PREFIX . "tests t" . " WHERE test_id=" . $matches[1];
                $result = mysql_query($sql, $db) or die(mysql_error());
                $row = mysql_fetch_assoc($result);
                add_test($matches[1], $row["title"]);
            }
        } else {
            if (preg_match('/^aa_(.*)$/', $_POST["id"], $matches) > 0) {
                if ($matches[1] == 0) {
                    $sql = "SELECT * FROM " . TABLE_PREFIX . "assignments a" . " WHERE course_id=" . $_SESSION["course_id"] . " AND NOT EXISTS (SELECT 1" . " FROM " . TABLE_PREFIX . "gradebook_tests g" . " WHERE g.id = a.assignment_id" . " AND g.type='ATutor Assignment')";
                    $result = mysql_query($sql, $db) or die(mysql_error());
                    while ($row = mysql_fetch_assoc($result)) {
                        add_assignment($row["assignment_id"]);
                    }
                } else {
                    add_assignment($matches[1]);
                }
            }
        }
        $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
Example #4
0
$specimen->reportTo = $report_to;
if ($doctor != "") {
    $specimen->doctor = $title . $doctor;
} else {
    $specimen->doctor = $doctor;
}
# Add entry to 'specimen' table
add_specimen($specimen);
# Add entries to 'specimen_custom_data'
$custom_field_list = get_custom_fields_specimen();
foreach ($custom_field_list as $custom_field) {
    $custom_value = get_custom_value($custom_field);
    $custom_data = new SpecimenCustomData();
    $custom_data->fieldId = $custom_field->id;
    $custom_data->fieldValue = $custom_value;
    $custom_data->specimenId = $specimen_id;
    add_custom_data_specimen($custom_data);
}
# Add entries to 'test' table
foreach ($tests_list as $test_type_id) {
    $test = new Test();
    $test->specimenId = $specimen_id;
    $test->testTypeId = $test_type_id;
    $test->comments = "";
    $test->userId = $_SESSION['user_id'];
    $test->result = "";
    add_test($test);
}
commit_transaction();
echo "Test";
SessionUtil::restore($saved_session);
Example #5
0
            foreach ($proc_times as $proc_time) {
                if ($proc_time < 0 || $proc_time > 25) {
                    $error_msg .= "Cannot have less than 0 or more than \n                        25 proctors in a single hour.<BR>";
                    $missing_proctors = false;
                    break;
                }
                if ($proc_time != 0) {
                    $missing_proctors = false;
                    break;
                }
            }
            if ($missing_proctors) {
                $error_msg .= "At least one hour needs a \n                proctor count other than zero.<BR>";
            }
            if ($error_msg != "") {
                echo $error_msg;
            } else {
                $date = explode("/", $date);
                $datetime = $date[2] . '-' . $date[0] . '-' . $date[1];
                add_test($test_name, $datetime, $test_cde, $room_id, $proc_times);
                header("Location: ../test_status");
            }
        } else {
            header("Location: ../test_status");
        }
        break;
    default:
        display_error('Unknown teacher action: ' . $action);
        break;
}
include "view.php";
function security_checks()
{
    global $tests;
    $tests = array();
    $dscr = 'Is UL_SITE_KEY long enough?';
    $explain = 'The cryptographic strength of UL_SITE_KEY is important to some security features implemented by uLogin. The string should be random and contain more than 40 characters. Try using a random string from the end of this page.';
    if (strlen(UL_SITE_KEY) > 40) {
        $result = 'OK';
    } else {
        $result = 'Warning';
    }
    add_test($dscr, $explain, $result);
    $dscr = 'Are pages using uLogin redirected to SSL?';
    $explain = 'It is highly recommended to turn on the UL_HTTPS option. uLogin encrypts passwords serverside, so to ensure a secure password transmit from the client, an SSL-secured connection is necessary.';
    if (UL_HTTPS) {
        $result = 'OK';
    } else {
        $result = 'Warning';
    }
    add_test($dscr, $explain, $result);
    $dscr = 'Is automatic username filtering on?';
    $explain = 'If uLogin is not set to only allow specific characters in usernames, the host application is responsible for properly filtering user input to avoid some attacks.';
    if (strlen(trim(UL_USERNAME_CHECK)) > 0) {
        $result = 'OK';
    } else {
        $result = 'Warning';
    }
    add_test($dscr, $explain, $result);
    if (UL_AUTH_BACKEND == 'pdo') {
        $dscr = 'Is there a separate DB user for authentication?';
        $explain = 'There should be a separate database account for UL_PDO_AUTH_USER with minimal privileges.';
        if (UL_PDO_AUTH_USER != UL_PDO_UPDATE_USER && UL_PDO_AUTH_USER != UL_PDO_DELETE_USER && UL_PDO_AUTH_USER != UL_PDO_SESSIONS_USER && UL_PDO_AUTH_USER != UL_PDO_LOG_USER) {
            $result = 'OK';
        } else {
            $result = 'Warning';
        }
        add_test($dscr, $explain, $result);
    }
    $dscr = 'Is the debug mode of uLogin disabled?';
    $explain = 'On a production website UL_DEBUG should be disabled or it might leak information that is useful for an attacker.';
    if (UL_DEBUG === false) {
        $result = 'OK';
    } else {
        $result = 'Warning';
    }
    add_test($dscr, $explain, $result);
    $dscr = 'Is PHP display_errors disabled?';
    $explain = 'On a production website the PHP display_errors directive should be set to Off or it might leak information that is useful for an attacker.';
    if (ini_get('display_errors') == '0' || strtolower(ini_get('display_errors')) == 'off') {
        $result = 'OK';
    } else {
        $result = 'Warning';
    }
    add_test($dscr, $explain, $result);
    $dscr = 'Is PHP register_globals disabled?';
    $explain = 'If PHP register_globals is turned on, it might allow an attacker to inject and overwrite variables on the server.';
    if (!ini_get('register_globals')) {
        $result = 'OK';
    } else {
        $result = 'Warning';
    }
    add_test($dscr, $explain, $result);
    $dscr = 'Is PHP session.use_only_cookies enabled?';
    $explain = 'PHP should not be allowed to propagate session identifiers in URLs, because it is easier to manipulate than a cookie.';
    if (ini_get('session.use_only_cookies')) {
        $result = 'OK';
    } else {
        $result = 'Warning';
    }
    add_test($dscr, $explain, $result);
    $dscr = 'Is PHP session.use_trans_sid disabled?';
    $explain = 'PHP should not be allowed to rewrite form requests and URIs to contain your session ID. This is a security threat, amongst other disadvantages.';
    if (!ini_get('session.use_trans_sid')) {
        $result = 'OK';
    } else {
        $result = 'Warning';
    }
    add_test($dscr, $explain, $result);
    $dscr = 'Is PHP session.cookie_httponly enabled?';
    $explain = 'Enabling this will protect all your cookies from being read by user-side scripts. Even if this option is disabled uLogin will still set the \'httponly\' flag on its own cookies.';
    if (ini_get('session.cookie_httponly')) {
        $result = 'OK';
    } else {
        $result = 'Warning';
    }
    add_test($dscr, $explain, $result);
    $dscr = 'Is PHP session.hash_function enforced?';
    $explain = 'To make session identifiers harder to guess set session.hash_function to a valid value other than \'0\'.';
    if (ini_get('session.hash_function') != '0') {
        $result = 'OK';
    } else {
        $result = 'Warning';
    }
    add_test($dscr, $explain, $result);
    $dscr = 'Is PHP expose_php disabled?';
    $explain = 'Your HTTP server should not explicitly advertise that it is running PHP.';
    if (!ini_get('expose_php')) {
        $result = 'OK';
    } else {
        $result = 'Warning';
    }
    add_test($dscr, $explain, $result);
}
Example #7
0
                    }
                } elseif (false !== strpos($file, '_view')) {
                    if (file_exists(TESTS_DIR . 'views/' . $file)) {
                        add_test('views', $file, $test);
                    }
                } elseif (false !== strpos($file, '_library')) {
                    if (file_exists(TESTS_DIR . 'libraries/' . $file)) {
                        add_test('libraries', $file, $test);
                    }
                } elseif (false !== strpos($file, '_bug')) {
                    if (file_exists(TESTS_DIR . 'bugs/' . $file)) {
                        add_test('bugs', $file, $test);
                    }
                } elseif (false !== strpos($file, '_helper')) {
                    if (file_exists(TESTS_DIR . 'helpers/' . $file)) {
                        add_test('helpers', $file, $test);
                    }
                }
            }
        }
    }
} elseif (isset($_POST['test'])) {
    $file = $_POST['test'];
    //autorun will load failed test if no tests are present to run
    require_once SIMPLETEST . 'autorun.php';
    require_once SIMPLETEST . 'web_tester.php';
    require_once SIMPLETEST . 'mock_objects.php';
    require_once SIMPLETEST . 'extensions/my_reporter.php';
    $test = new TestSuite();
    $test->_label = 'CodeIgniter Test Suite';
    if (file_exists(TESTS_DIR . $file)) {
Example #8
0
$record = query_associative_one($querySelect);
$newPatientId = $record['patient_id'];
*/
/* Create New Specimen & Test Records */
$i = 0;
foreach ($specimenRecords as $specimenRecord) {
    $saved_db = DbUtil::switchToLabConfig($importLabConfigId);
    $querySelect = "SELECT * FROM test " . "WHERE specimen_id={$specimenRecord->specimenId}";
    $resultset = query_associative_all($querySelect, $rowcount);
    DbUtil::switchRestore($saved_db);
    //$specimenRecord->specimenId = get_max_specimen_id() + 1;
    $specimenRecord->patientId = $importPatientId;
    $specimenRecord->userId = $_SESSION['user_id'];
    $specimenRecord->doctor = '';
    add_specimen($specimenRecord);
    for ($j = 0; $j < count($resultset); $j++) {
        $testRecord = $testRecords[$i];
        $testRecord->specimenId = $specimenRecord->specimenId;
        $testRecord->userId = $_SESSION['user_id'];
        $i++;
        add_test($testRecord, $testRecord['test_id']);
    }
}
DbUtil::switchRestore($saved_db);
?>
<script type="text/javascript">
window.location="../new_specimen.php?pid=<?php 
echo $importPatientId;
?>
";
</script>
Example #9
0
$querySelect = "SELECT patient_id FROM patient " . "WHERE name like '{$patientName}' ";
$record = query_associative_one($querySelect);
$newPatientId = $record['patient_id'];
/* Create New Specimen & Test Records */
$i = 0;
foreach ($specimenRecords as $specimenRecord) {
    $saved_db = DbUtil::switchToLabConfig($importLabConfigId);
    $querySelect = "SELECT * FROM test " . "WHERE specimen_id={$specimenRecord->specimenId}";
    $resultset = query_associative_all($querySelect, $rowcount);
    DbUtil::switchRestore($saved_db);
    $specimenRecord->specimenId = get_max_specimen_id() + 1;
    $specimenRecord->patientId = $newPatientId;
    $specimenRecord->userId = $_SESSION['user_id'];
    $specimenRecord->doctor = '';
    add_specimen($specimenRecord);
    for ($j = 0; $j < count($resultset); $j++) {
        $testRecord = $testRecords[$i];
        $testRecord->specimenId = $specimenRecord->specimenId;
        $testRecord->userId = $_SESSION['user_id'];
        $i++;
        add_test($testRecord);
    }
}
DbUtil::switchRestore($saved_db);
?>
<script type="text/javascript">
window.location="../new_specimen.php?pid=<?php 
echo $newPatientId;
?>
";
</script>
Example #10
0
 {
     $partner = new Partner();
     $partner->email = $email;
     list($partner->last_name, $partner->first_name, $partner->middle_name) = explode(" ", $name);
     $partner->password = array_shift(explode('@', $email));
     loginkit_update_password_hash($partner);
     $partner->put();
     return $partner;
 }
 srand(3546565);
 // random test data should be the same every time
 $all_tests[] = $test = add_test("IQ-тест");
 add_question($test, "Как называется приспособление для подъема воды из колодца?", array("Журавль", "Аист", "Цапля", "Страус"));
 add_question($test, "Чью мать обещал показать американцам Хрущев?", array("Кузькину", "Чертову", "Свою", "Микояна"));
 add_question($test, "Какое прозвище носила Манька в фильме «Место встречи изменить нельзя»?", array("Акция", "Ваучер", "Облигация", "Лотерейный билет"));
 $all_tests[] = $test = add_test("Тест на интеллект");
 add_question($test, "Кем работал в зоопарке Крокодил Гена?", array("Сторожем", "Директором", "Дрессировщиком", "Крокодилом"));
 add_question($test, "Какой запах, как утверждают, сопровождает появление нечистой силы?", array("Нашатырного спирта", "Озона", "Серы", "Хлора"));
 add_question($test, "Что (или кто) «нечаянно нагрянет, когда ее совсем не ждешь»?", array("Жена", "Зима", "Налоговая инспекция", "Любовь"));
 $all_partners[] = add_partner('*****@*****.**', "Таранцов Андрей Витальевич");
 $all_partners[] = add_partner('*****@*****.**', "Калугин Михаил Борисович");
 $percent_partner_sessions = 70;
 $percent_sessions = array(10, 50, 5, 35);
 // unfinished, finished-nosms, finished-sms-nocode, finished
 $time_range = 90;
 // days
 $session_count = 1000;
 $payment_count = floor($time_range / 7) * count($all_partners);
 for ($i = 1; $i < count($percent_sessions); $i++) {
     $percent_sessions[$i] += $percent_sessions[$i - 1];
 }