/** * A function which returns true if the logged in user * is a student in the system. * * @since 4.3 * @param int $id * Student's ID. * @return bool */ function isStudent($id) { if ('' == _trim($id)) { $message = _t('Invalid student ID: Empty ID given.'); _incorrectly_called(__FUNCTION__, $message, '6.2.0'); return; } if (!is_numeric($id)) { $message = _t('Invalid student ID: student id must be numeric.'); _incorrectly_called(__FUNCTION__, $message, '6.2.0'); return; } $stu = get_person_by('personID', $id); if ($stu->stuID != '') { return true; } return false; }
/** * Checks a person's login information. * * @since 6.2.0 * @param string $login Person's username or email address. * @param string $password Person's password. * @param string $rememberme Whether to remember the person. */ function etsis_authenticate_person($login, $password, $rememberme) { $app = \Liten\Liten::getInstance(); if (empty($login) || empty($password)) { if (empty($login)) { $app->flash('error_message', _t('<strong>ERROR</strong>: The username/email field is empty.')); } if (empty($password)) { $app->flash('error_message', _t('<strong>ERROR</strong>: The password field is empty.')); } redirect(get_base_url() . 'login' . '/'); return; } if (filter_var($login, FILTER_VALIDATE_EMAIL)) { $person = get_person_by('email', $login); if (false == $person->email) { $app->flash('error_message', _t('<strong>ERROR</strong>: Invalid email address.')); redirect(get_base_url() . 'login' . '/'); return; } } else { $person = get_person_by('uname', $login); if (false == $person->uname) { $app->flash('error_message', _t('<strong>ERROR</strong>: Invalid username.')); redirect(get_base_url() . 'login' . '/'); return; } } if (!etsis_check_password($password, $person->password, _h($person->personID))) { $app->flash('error_message', _t('<strong>ERROR</strong>: The password you entered is incorrect.')); redirect(get_base_url() . 'login' . '/'); return; } /** * Filters log in details. * * @since 6.2.0 * @param string $login Person's username or email address. * @param string $password Person's password. * @param string $rememberme Whether to remember the person. */ $person = $app->hook->apply_filter('etsis_authenticate_person', $login, $password, $rememberme); return $person; }
/** * Checks whether the given email exists. * * @since 6.2.4 * @param string $email * Email to check. * @return int|false The person's ID on success, and false on failure. */ function email_exists($email) { if ($person = get_person_by('email', $email)) { return $person->personID; } return false; }
$uname = get_person_by('uname', $_POST['uname']); if ($uname->uname == $_POST['uname']) { echo '1'; } }); /** * Before route check. */ $app->before('GET|POST', '/resetPassword/(\\d+)/', function () { if (!hasPermission('reset_person_password')) { redirect(get_base_url() . 'dashboard' . '/'); } }); $app->get('/resetPassword/(\\d+)/', function ($id) use($app, $flashNow, $email) { $passSuffix = 'eT*'; $person = get_person_by('personID', $id); $dob = str_replace('-', '', $person->dob); $ssn = str_replace('-', '', $person->ssn); if ($ssn > 0) { $pass = $ssn . $passSuffix; } elseif ($person->dob > '0000-00-00') { $pass = $dob . $passSuffix; } else { $pass = '******' . $passSuffix; } Node::dispense('reset_password'); $node = Node::table('reset_password'); $node->uname = (string) _h($person->uname); $node->email = (string) _h($person->email); $node->name = (string) get_name(_h($person->personID)); $node->personid = (int) _h($person->personID);
$term = $app->db->term()->select('termCode,termStartDate,termEndDate')->where('termCode = ?', $_POST['termCode'])->_and_()->where('active = "1"'); $q = $term->find(function ($data) { $array = []; foreach ($data as $d) { $array[] = $d; } return $array; }); foreach ($q as $k => $v) { $json = array('input#startDate' => $v['termStartDate'], 'input#endDate' => $v['termEndDate']); } echo json_encode($json); }); $app->post('/stuLookup/', function () use($app) { $stu = $app->db->student()->where('stuID = ?', (int) $_POST['stuID'])->findOne(); $nae = get_person_by('personID', $stu->stuID); $json = ['input#stuName' => $nae->lname . ', ' . $nae->fname]; echo json_encode($json); }); $app->get('/regTermLookup/', function () use($app) { $term = $app->db->query("SELECT termCode,termName FROM term WHERE termCode <> 'NULL' AND active ='1'"); $q = $term->find(function ($data) { $array = []; foreach ($data as $d) { $array[] = $d; } return $array; }); $items = []; foreach ($q as $r) { $option = ['id' => $r['termCode'], 'value' => $r['termName']];
}); $app->get('/applications/', function () use($app, $json_url) { $css = ['css/admin/module.admin.page.alt.form_elements.min.css', 'css/admin/module.admin.page.alt.tables.min.css']; $js = ['components/modules/admin/forms/elements/bootstrap-select/assets/lib/js/bootstrap-select.js?v=v2.1.0', 'components/modules/admin/forms/elements/bootstrap-select/assets/custom/js/bootstrap-select.init.js?v=v2.1.0', 'components/modules/admin/forms/elements/select2/assets/lib/js/select2.js?v=v2.1.0', 'components/modules/admin/forms/elements/select2/assets/custom/js/select2.init.js?v=v2.1.0', 'components/modules/admin/forms/elements/bootstrap-datepicker/assets/lib/js/bootstrap-datepicker.js?v=v2.1.0', 'components/modules/admin/forms/elements/bootstrap-datepicker/assets/custom/js/bootstrap-datepicker.init.js?v=v2.1.0', 'components/modules/admin/forms/elements/bootstrap-timepicker/assets/lib/js/bootstrap-timepicker.js?v=v2.1.0', 'components/modules/admin/forms/elements/bootstrap-timepicker/assets/custom/js/bootstrap-timepicker.init.js?v=v2.1.0']; $appl = $app->db->application()->where('personID = ?', (int) get_persondata('personID')); $q = $appl->find(function ($data) { $array = []; foreach ($data as $d) { $array[] = $d; } return $array; }); $app->view->display('application/appls', ['title' => 'My Applications', 'cssArray' => $css, 'jsArray' => $js, 'appls' => $q]); }); $app->post('/applicantLookup/', function () use($app, $json_url) { $appl = get_person_by('personID', $_POST['personID']); $json = ['input#person' => $appl->lname . ', ' . $appl->fname]; echo json_encode($json); }); $app->get('/deleteInstAttend/(\\d+)/', function ($id) use($app, $flashNow) { $inst = $app->db->institution_attended()->where('instAttID = ?', $id); if ($inst->delete()) { $app->flash('success_message', $flashNow->notice(200)); } else { $app->flash('error_message', $flashNow->notice(409)); } redirect($app->req->server['HTTP_REFERER']); }); }); $app->setError(function () use($app) { $app->view->display('error/404', ['title' => '404 Error']);
$app->before('GET|POST', '/add/(\\d+)/', function () { if (!hasPermission('create_stu_record')) { redirect(get_base_url() . 'dashboard' . '/'); } /** * If user is logged in and the lockscreen cookie is set, * redirect user to the lock screen until he/she enters * his/her password to gain access. */ if (isset($_COOKIE['SCREENLOCK'])) { redirect(get_base_url() . 'lock' . '/'); } }); $app->match('GET|POST', '/add/(\\d+)/', function ($id) use($app, $css, $js, $json_url, $flashNow, $email) { if ($app->req->isPost()) { $nae = get_person_by('personID', $id); if ($nae->ssn > 0) { $pass = str_replace('-', '', $nae->ssn); } elseif ($nae->dob != '0000-00-00') { $pass = str_replace('-', '', $nae->dob); } else { $pass = '******'; } $degree = $app->db->acad_program()->where('acadProgCode = ?', _trim($_POST['acadProgCode']))->findOne(); $appl = $app->db->application()->where('personID = ?', $id)->findOne(); $student = $app->db->student(); $student->stuID = $id; $student->status = $_POST['status']; $student->addDate = $app->db->NOW(); $student->approvedBy = get_persondata('personID'); $sacp = $app->db->stu_program();