public function auth() { //Get the username and password from the field $username = $this->input->post('username'); $password = $this->input->post('password'); //Create a new user object $user = new User_model(); //If username exists load userdata if ($user->loadPropertiesFromPrimaryKey($username) || $user->loadPropertiesFromEmailAddress($username)) { //If password is correct if ($user->authenticate($password)) { if (null !== $user->getLastLogin() && 0 < $user->getLastLogin() && $user->getLastLogin() + 10368000 < time()) { $advisor = $user->getAdvisor(); $this->load->view('login', array("error2" => TRUE, 'advisorname' => $advisor->getName(), 'advisoremail' => $advisor->getEmailAddress())); } else { //Set the logged in timestamp $user->setLastLogin(time()); $user->update(); //Activate the session $_SESSION['UserID'] = $user->getUserID(); //Redirect to the mainpage controller redirect('Mainpage'); } } else { //Incorrect username or password, reload login and display an error $this->load->view('login', array("error" => TRUE)); } } else { //Incorrect username or password, reload login and display an error $this->load->view('login', array("error" => TRUE)); } }
public function index() { if (!isset($_SESSION['UserID'])) { redirect('Login/logout'); } //Create new user and load its data $user = new User_model(); if (!$user->loadPropertiesFromPrimaryKey($_SESSION['UserID'])) { redirect('Login/logout'); } //If user did not load, logout the session if (!$user->isStudent()) { redirect('Mainpage'); } //If not a student, redirect to mainpage $advisor = $user->getAdvisor(); $advisorName = $advisor->getName(); $data = array('user' => $user, 'advisor' => $advisor); $this->load->view('advisorInfo', $data); }
public function Student_Cancel() { $User_model = new User_model(); $User_model->loadPropertiesFromPrimaryKey($_SESSION['UserID']); $quarter = Academic_quarter_model::getLatestAcademicQuarter(); $quarter = $quarter->getAcademicQuarterID(); $Advising_schedule = new Advising_schedule_model(); $Advising_appointment = new Advising_appointment_model(); $advisor = $User_model->getAdvisor(); $advisor = $advisor->getUserID(); $Advising_schedule->loadPropertiesFromAdvisorIDAndAcademicQuarterID($advisor, $quarter); $app_array = $Advising_schedule->getAllAdvisingAppointments(); foreach ($app_array as $key) { if ($key->getScheduledStudentUserID() == $_SESSION['UserID'] && $key->isScheduled()) { $Advising_appointment->loadPropertiesFromPrimaryKey($key->getAdvisingAppointmentID()); $Advising_appointment->setAdvisingAppointmentState(3); $Advising_appointment->update(); break; } } //SEND Optional Email redirect('appointment_controller'); }
public function send($userID = NULL, $email = NULL) { $session_user = new User_model(); if (!$session_user->loadPropertiesFromPrimaryKey($_SESSION['UserID'])) { redirect('Login/logout'); } if (!$session_user->isAdvisor()) { redirect('Login/logout'); } $this->load->library('email'); $user = new User_model(); $user->loadPropertiesFromPrimaryKey($userID); if ($user->getAdvisor()->getUserID() != $session_user->getUserID()) { redirect('Login/logout'); } //Loads user's email if optional email wasn't set if ($email == NULL) { $email = $user->getEmailAddress(); } //Array of characters to generate password $charset = array('!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '~', '=', '+', '_', '-', '?', '/', '>', '<', '.', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'w', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'W', 'Z'); //Generate random password $passlen = mt_rand(8, 12); $pass = NULL; for ($i = 0; $i < $passlen; $i++) { $pass = $pass . $charset[mt_rand(0, count($charset) - 1)]; } //Set user password //Email user their login information $this->email->from('*****@*****.**', 'Admin Name'); $this->email->to('*****@*****.**'); $this->email->subject('Subject'); $this->email->message('Password: '******'Username: '******'headers', 'subject', 'body')); $user->setPassword($pass); //Email user their login information $this->load->library('email'); $config['protocol'] = 'smtp'; $config['smpt_crypt'] = 'ssl'; $config['smtp_host'] = 'ssl://smtp.gmail.com'; $config['smtp_port'] = '465'; $config['smtp_user'] = '******'; $config['smtp_pass'] = '******'; $config['mailtype'] = 'html'; $config['charset'] = 'utf-8'; $config['newline'] = "\r\n"; $config['validate'] = FALSE; $config['bcc_batch_mode'] = FALSE; $config['bcc_batch_size'] = 200; $this->email->initialize($config); $this->email->from('*****@*****.**', 'Senior'); $list = array('*****@*****.**'); $this->email->to($list); $this->email->reply_to('*****@*****.**', 'Senior'); $this->email->subject('Subject'); $this->email->message('Email works great!'); if ($user->update() && $this->email->send()) { $_SESSION['activation.message'] = "Success!"; } else { $_SESSION['activation.error'] = "Sending email failed!<br />" . $this->email->print_debugger(); } redirect('Activation/index'); }
<body> <?php include_once 'application/views/Templates/navbar.php'; ?> <div class="container"> <p><b>Please select a curriculum.</b></p><br/> <form action="<?php echo site_url('User/submitStudentInfoForm/' . $uID); ?> " method="POST"> <?php $student = new User_model(); $student->loadPropertiesFromPrimaryKey($uID); $studentAdvisor = $student->getAdvisor(); $studentCurriculms = $student->getCurriculums(); $Curriculums = $this->Curriculum_model->getAllCurriculums(); foreach ($Curriculums as $Curriculum) { $id = $Curriculum->getCurriculumID(); $slotName = $Curriculum->getName(); echo '<input type="checkbox" value="true" name="Curriculum' . $id . '"'; if (in_array($Curriculum, $studentCurriculms)) { echo 'checked'; } echo '/> ' . $slotName . '</br>'; } ?> <p><b>Please select an advisor. </b></p><br/> <select name="advisorID" > <?php