public function loginAction() { if (!isset($_POST['ID'])) { throw new Exception('ID is not set'); } if (!isset($_POST['Password'])) { throw new Exception('Password is not set'); } if (!isset($_POST['Type'])) { throw new Exception('Type is not set'); } $info; $id; if ($_POST['Type'] == 'student') { require_once $_SERVER['DOCUMENT_ROOT'] . '/school/model/studentIdentityItem.php'; $info = new studentIdentityItem(); $id = 'Stu_ID'; } else { if ($_POST['Type'] == 'teacher') { require_once $_SERVER['DOCUMENT_ROOT'] . '/school/model/teacherIdentityItem.php'; $info = new teacherIdentityItem(); $id = 'Tea_ID'; } else { if ($_POST['Type'] == 'staff') { require_once $_SERVER['DOCUMENT_ROOT'] . '/school/model/staffIdentityItem.php'; $info = new staffIdentityItem(); $id = 'Sta_ID'; } else { throw new Exception('Type is invalid'); } } } $req = array(); $req[0] = array('key' => $id, $id => $_POST['ID']); $arg = array('Password'); $res = $info->search($req, $arg); if (count($res) == 0) { throw new Exception('Account does not exist'); } else { if ($res[0]['Password'] != $_POST['Password']) { throw new Exception('Password is wrong'); } } return true; }
public function changePasswordAction() { require $_SERVER['DOCUMENT_ROOT'] . '/school' . '/model/staffIdentityItem.php'; $identify = new staffIdentityItem(); $this->util_->requireArg('OP', $_POST); $this->util_->requireArg('NP', $_POST); $req = array(); $req[0] = array('key' => 'Sta_ID', 'Sta_ID' => $_POST['Account']); $identify->Sta_ID = $_POST['Account']; $arg = array('Password'); $res = $identify->search($req, $arg); if ($res[0]['Password'] != $_POST['OP']) { throw new Exception('Password wrong'); } $arg1 = array('Password' => $_PSOT['NP']); $identify->update($arg1); }