function authenticateuser() { $users_model = new Users_model(); $users_service = new Users_service(); $users_model->setEmail($this->input->post('username', TRUE)); $users_model->setPassword($this->input->post('password', TRUE)); $users = $users_service->authenticateUser($users_model); //newly added sithira $this->load->library('session'); //Load Models - for this function $this->load->model('users_model1'); $this->load->model('auth_model'); //Load Form Helper $this->load->helper('form'); //end //echo $users; die(); if (count($users) == 1) { $userdata = array('user_name' => $users->name, 'user_id' => $users->id, 'user_email' => $users->email, 'logged_in' => TRUE); $name = $users->name; $id = $users->id; $users = $users_service->update_users($users->id, 1); // session_start(); $this->session->set_userdata($userdata); $this->chat_login($name, $id); echo 1; } else { echo 0; } }
function authenticateuser_registation($email, $password) { $users_model = new Users_model(); $users_service = new Users_service(); $users_model->setEmail($this->input->post($email, TRUE)); $users_model->setPassword($this->input->post($password, TRUE)); $users = $users_service->authenticateUser($users_model); //echo $users; die(); if (count($users) == 1) { $userdata = array('user_name' => $users->name, 'user_id' => $users->id, 'user_email' => $users->email, 'logged_in' => TRUE); // session_start(); $this->session->set_userdata($userdata); $this->load->helper('url'); $this->load->model('Mod_images'); $this->load->model('Mod_items'); $user_name = $this->session->userdata('user_name'); $data['user_name'] = $user_name; $data['images'] = $this->Mod_images->content(); $data['items'] = $this->Mod_items->content(); $data['topic'] = $this->Mod_items->gettopic(); $this->load->view('header', $data); $this->load->view('home', $data); $this->load->view('footer'); echo 1; } else { echo 0; } }
public function listOfConsultants() { $this->load->model('users_model'); $p = new Users_model(); $data['users'] = $p->viewAllTeachers(); $this->load->view('includes/header'); $this->load->view('includes/banner'); $this->load->view('admin/admin-menu'); $this->load->view('admin/view-consultants-list', $data); }
public function setSession() { $this->load->model('Users_model'); $p = new Users_model(); $p->user_id = $this->input->post('user_id'); $data = array(); $data = $p->getUserInformation(); $sess_array = array('user_id' => $data['user_id'], 'role_id' => $data['role_id'], 'is_logged_in' => 1); $this->session->set_userdata($sess_array); redirect('', 'refresh'); }
public function index() { $this->load->model('users_model'); $p = new Users_model(); $data['users'] = $p->viewAllTeachers(); $this->load->view('includes/header'); $this->load->view('includes/banner'); $this->load->view('teacher/teacher-menu'); $this->load->view('teacher/teacher-landing-page'); //$this->load->view('admin/admin-landing-page', $data); }
function authenticateuser() { $users_model = new Users_model(); $users_service = new Users_service(); $users_model->setEmail($this->input->post('username', TRUE)); $users_model->setPassword($this->input->post('password', TRUE)); $users = $users_service->authenticateUser($users_model); //newly added sithira $this->load->library('session'); //Load Models - for this function $this->load->model('users_model1'); $this->load->model('auth_model'); //Load Form Helper $this->load->helper('form'); $loggedInUser = $this->users_model1->getLoggedInUser(); $this->outputData['loggedInUser'] = $loggedInUser; $conditions = array('user_email' => $this->input->post('username'), 'user_password' => $this->input->post('password'), 'ci_users.status' => '1'); $query = $this->users_model1->getUsers($conditions); if ($query->num_rows() > 0) { $row = $query->row(); // update the last activity in the users table $updateData = array(); //date("Y-m-d H:i:s") $updateData['online'] = "1"; // update process for users table $this->users_model1->updateUser(array('user_id' => $row->user_id), $updateData); //Set Session For User $this->auth_model->setUserSession($row); $this->session->userdata('user_id', $row->user_id); $this->session->userdata('user_name', $row->user_name); //Notification message // $this->session->set_flashdata('flash_message', $this->users_model->flash_message('success','Logged In Successfull')); // redirect('Con_dashBord'); } else { //Notification message // $this->session->set_flashdata('flash_message', $this->users_model->flash_message('error','Login failed! Incorrect username or password '.$this->input->post('username')."")); // redirect('users'); } //If username exists //}//If End - Check For Validation //end //echo $users; die(); if (count($users) == 1) { $userdata = array('user_name' => $users->name, 'user_id' => $users->id, 'user_email' => $users->email, 'logged_in' => TRUE); // session_start(); $this->session->set_userdata($userdata); echo 1; } else { echo 0; } }
public function get_event_messages($event_id) { $this->db->select('em.id, em.created, em.message, u.id as author_id, u.username as author_username, u.birthday as author_birthday, u.gender as author_gender'); $this->db->join($this->users_model->table . ' u', 'em.users_id = u.id'); $this->db->where('em.events_id', $event_id); $messages = $this->db->get($this->table . ' em')->result_array(); if (!$messages) { return []; } foreach ($messages as &$row) { $row['author_avatar'] = $this->users_model->get_photo($row['author_id'], $this->users_model->avatar); } return $messages; }
/** * Changes user password * * @param $user_id = $this->session->id * @param $current_password * @param $new_password * @param $new_password_confirmation * * @return boolean */ public function changePassword($user_id = FALSE, $current_password, $new_password, $new_password_confirmation) { if ( ! $user_id) $user_id = $this->session->id; // check new password if($new_password !== $new_password_confirmation) show_error(_('Les mots de passe ne correspondent pas')); if( ! empty($errors = $this->checkPasswordStrenght($new_password))) show_error($errors); // check current password $check = parent::checkUserPassword($user_id, $current_password, 'id'); if( ! $check) show_error(_('Le mot de passe n\'est pas valide')); $hash = password_hash($new_password, PASSWORD_DEFAULT); $data = array( 'password' => $hash ); $this->db->where('id', $user_id); $this->db->update('users', $data); return TRUE; }
function authenticateuser() { $users_model = new Users_model(); $users_service = new Users_service(); $users_model->setEmail($this->input->post('username', TRUE)); $users_model->setPassword($this->input->post('password', TRUE)); $users = $users_service->authenticateUser($users_model); //echo $users; die(); if (count($users) == 1) { $userdata = array('user_name' => $users->name, 'user_id' => $users->id, 'user_email' => $users->email, 'logged_in' => TRUE); // session_start(); $this->session->set_userdata($userdata); echo 1; } else { echo 0; } }
protected function auth($api_only = false) { $headers = $this->input->request_headers(); $api_key = array_key_exists('API_KEY', $headers) ? $headers['API_KEY'] : ''; if ($api_key != API_KEY) { $this->response('Forbidden', 403); } if (!$api_only) { $token = array_key_exists('TOKEN', $headers) ? $headers['TOKEN'] : ''; $user = $this->users_model->check_token($token); if (!$user) { $this->response('Authorization Error', 401); } $this->user_id = $user['id']; $this->user = $user; } }
public function get_event_joined($event_id, $count = false) { $this->db->select('etu.created as join_date, u.id, u.username, u.birthday, u.gender'); $this->db->join($this->users_model->table . ' u', 'etu.users_id = u.id'); $this->db->where('etu.events_id', $event_id); if ($count) { return $this->db->count_all_results($this->table . ' etu'); } $users = $this->db->get($this->table . ' etu')->result_array(); if (!$users) { return []; } foreach ($users as &$row) { $row['avatar'] = $this->users_model->get_photo($row['id'], $this->users_model->avatar); } return $users; }
public function status_get($status) { $this->auth(); try { $this->model->update($this->user_id, ['active' => $status]); $this->response(true, 200); } catch (Exception $e) { $this->response($e->getMessage(), $e->getCode()); } }
public function index() { $this->load->model('Users_model'); $p = new Users_model(); $p->user_id = $this->session->userdata('user_id'); $data = array(); $data = $p->getUserInformation(); $fname = $data['fname']; if ($fname == NULL) { $this->load->view('includes/header'); $this->load->view('includes/banner'); $this->load->view('student/student-menu'); $this->load->view('student/create-student-profile'); } else { $this->load->view('includes/header'); $this->load->view('includes/banner'); $this->load->view('student/student-menu'); $this->load->view('includes/sem_header'); $this->load->view('student/student-classes'); } }
public function add_user($db, $data) { if (sizeof(Users_model::get_user_by_email($db, $data->email)) > 0) { return "Error adding data - Entry may already exist"; } if ($data->password != null) { $hash = Password::make($data->password, PASSWORD_BCRYPT, array("cost" => 10)); $data->password = $hash; } else { $hash = null; } $data->api_token = md5(uniqid($data->password, true)); $new_user = $db->insert("Users", $data, array()); return $new_user; }
public function get_my_joined($user_id) { $this->db->select("e.*, e.users_id as creator_id, u.username as creator_username, u.birthday as creator_birthday, u.gender as creator_gender,\n (SELECT COUNT(etu.id) FROM {$this->etu_model->table} etu WHERE etu.events_id = e.id) as joined_count"); $this->db->join($this->users_model->table . ' u', 'e.users_id = u.id'); $this->db->join($this->etu_model->table . ' etu', 'etu.events_id = e.id', 'left'); $this->db->where('etu.users_id', $user_id); $this->db->where('e.users_id !=', $user_id); $events = $this->db->get($this->table . ' e')->result_array(); foreach ($events as &$event) { $event['creator_avatar'] = $this->users_model->get_photo($event['users_id'], $this->users_model->avatar); unset($event['users_id']); $event['place_info'] = json_decode($event['place_info']); } return $events; }
function __construct() { //encryption require_once "encryption.php"; if (isset($_GET['logout']) && $_GET['logout']) { $_SESSION['logged'] = FALSE; session_destroy(); } $data['invalidEmailPass'] = "******"; //Authentication logic if (isset($_POST['login'])) { //store form email and pass $email = $_POST['email']; $enc_password = encrypt_password($_POST['password']); $usersObj = new Users_model(); if ($usersObj->login($email, $enc_password)) { $_SESSION['logged'] = TRUE; $_SESSION['email'] = $email; // $_SESSION['name'] = 'Alin'; header('Location: http://188.166.119.187/workspace/ilear/MVC/part4/index.php?page=admin'); } else { $data['invalidEmailPass'] = "******"; } } // $data['condition'] = (isset($_SESSION['logged']) && $_SESSION['logged'] === TRUE); // $data['logged'] = "You are logged in!"; // // $data['unlogged'] = ""; $data['logged'] = isset($_SESSION['logged']) && $_SESSION['logged'] === TRUE ? "You are logged in!" : ""; // $data['logged'] = "You are logged in!"; $data['title'] = "LoginPage"; // $data['mailSent'] = "Note that only phone number is optional!"; $this->render('views/top.php', $data); $this->render('views/menu.php', $data); $this->render('views/login.php', $data); $this->render('views/bottom.php', $data); }
function authenticateToken() { global $db; $app = \Slim\Slim::getInstance(); $headers = apache_request_headers(); $token; foreach ($headers as $header => $value) { if ($header == 'Authorization') { $token = str_replace('"', "", $value); } } $tokenFromDB = Users_model::get_user_by_token($db, $token); if (!$tokenFromDB) { echoResponse(403, $token); exit; } }
/** * Forgot password of user * url: http://localhost/forgot_password * Method: POST * @param string $email * @return json */ function forgot_password_post() { $this->verify_required_params(array('email')); $messages_lang = $this->common->set_language_for_server_api('users_api', array('variables_not_valid', 'reset_password_success', 'reset_password_failure')); $email = $this->post('email'); if (Users_model::is_user_exists($email)) { $this->users_model->forgot_password($email); list($result, $token) = $this->users_model->forgot_password($email); if ($result) { $this->users_model->send_mail($email, $token); $response['status'] = $messages_lang['success']; $response['message'] = $messages_lang['reset_password_success']; } else { $response['status'] = $messages_lang['failure']; $response['message'] = $messages_lang['reset_password_failure']; } } else { $response['status'] = $messages_lang['failure']; $response['message'] = $messages_lang['variables_not_valid']; } $this->response($response, 200); }
public function add_user() { $this->common->authenticate(); $user_id = $this->input->post('user_id'); $table_id = $this->input->post('table_id'); $day = $this->input->post('day'); $message = $this->common->get_message('add_user', array('add_success', 'add_failure', 'have_table')); if (is_numeric($user_id) && is_numeric($table_id)) { $result = $this->tables_model->arrange_to_add_user_in_table($user_id, $table_id, $day); switch ($result) { case JOIN_TABLE_SUCCESSFULLY: $this->load->model('users_model'); $user = Users_model::get_user_by('id', $user_id); $data = array('status' => 'success', 'message' => $message['add_success'], 'user' => $user); break; case JOIN_TABLE_FAILED: $data = array('status' => 'failure', 'message' => $message['add_failure']); break; case HAVE_SEAT_IN_TABLE: $data = array('status' => 'failure', 'message' => $message['have_table']); break; } } else { $data = array('status' => 'failure', 'message' => $message['add_failure']); } echo json_encode($data); }
function email_check($email, $user_id) { $this->load->model('users_model'); $User = new Users_model(); $User->where("email = '{$email}'")->get(); if ($User->exists() && $User->id != $user_id) { $this->form_validation->set_message('email_check', "This email address is already in use."); return FALSE; } else { return TRUE; } }
function get_session_user() { $CI =& get_instance(); // Get user_id from session $user_id = $CI->secure->get_user_session()->id; $User_model = new Users_model(); return $User_model->get_by_id($user_id); }
public function store_announcement() { $this->load->model('users_model'); $data['user_id'] = (int) $this->session->userdata('logged_in')['user_id']; $data['title'] = $this->input->post('subject'); $data['content'] = $this->input->post('content'); $data['meal_date'] = $this->input->post('lunch_date'); $announcement_for = $this->input->post('announcement_for'); $users = array(); switch ($announcement_for) { case ANNOUNCEMENT_USER: $data['user'] = $this->input->post('user'); $users[] = Users_model::get_user_by('id', $data['user']); break; case ANNOUNCEMENT_TABLE: $data['table'] = $this->input->post('table'); $this->load->model('tables_model'); $users = Tables_model::get_users_in_table($data['table']); break; case ANNOUNCEMENT_SHIFT: $data['shift'] = $this->input->post('shift'); $this->load->model('shifts_model'); $users = Shifts_model::get_users_by_shift($data['shift']); break; default: $data['user'] = '******'; $users = Users_model::get_all_users(); break; } list($result, $announcement_id) = Announcements_model::insert_announcement($data); if ($result) { $registation_ids = array(); if ($users != NULL) { foreach ($users as $user) { if ($user->gcm_regid != NULL) { $registation_ids[] = $user->gcm_regid; } } } $user = array(); $user['avatar_content_file'] = $this->session->userdata('logged_in')['avatar_content_file']; $user['email'] = $this->session->userdata('logged_in')['email']; $user['id'] = (int) $this->session->userdata('logged_in')['user_id']; if ($registation_ids != NULL) { $send_notification['data'] = array('type' => 'announcement', 'announcement' => array('id' => (int) $announcement_id, 'title' => $data['title'], 'content' => $data['content'], 'meal_date' => $data['meal_date'], 'read_flag' => FALSE, 'number_of_replies' => 0, 'number_of_have_read_replies' => 0, 'created_at' => date('Y-m-d H:i:s'), 'email' => $user['email'], 'avatar_content_file' => $user['avatar_content_file'], 'user_id' => $user['id'])); $this->common->send_notification($registation_ids, $send_notification); } return TRUE; } else { return FALSE; } }
/** * User have read replies of comment * * @param int $user_id * @param int $comment_id * @param array $reply_ids * @return bool */ function have_read_replies_comment($user_id, $comment_id, $reply_ids) { $read_replies_for_comment = array(); $reply_ids_for_comments = array(); $read_replies_for_comment['comment'] = $comment_id; $read_replies_for_comment['replies'] = $reply_ids; $this->load->model('users_model'); $user = Users_model::get_user_by('id', $user_id); $reply_ids_for_comments = (array) json_decode($user->read_replies_comments); $reply_ids_for_comments[] = $read_replies_for_comment; $this->db->where('id', $user_id); return $this->db->update('users', array('read_replies_comments' => json_encode($reply_ids_for_comments))); }
public function not_exist_email($email) { if (!Users_model::is_user_exists($email)) { $this->lang->load('web_portal/forgot_password', $this->session->userdata('site_lang')); $this->form_validation->set_message('not_exist_email', $this->lang->line('not_exist_email')); return FALSE; } return TRUE; }
public function profile($username, $videos_offset = 0) { // TODO handle user not found $user_id = $this->session->userdata('user_id'); if ($user_id) { if (intval($user_id) & USER_ROLE_ADMIN) { $allow_unactivated = TRUE; } else { $allow_unactivated = FALSE; } } else { $allow_unactivated = FALSE; } $this->load->config('localization'); $this->load->helper('date'); $this->lang->load('date'); // ** // ** LOADING MODEL // ** // Logged in user time zone $time_zone = $this->session->userdata('time_zone'); // User data $userdata = $this->users_model->get_userdata($username); $userdata['roles'] = Users_model::roles_to_string($userdata['roles']); $country_list = $this->config->item('country_list'); $userdata['country_name'] = $country_list[$userdata['country']]; $userdata['last_login'] = human_gmt_to_human_local($userdata['last_login'], $time_zone); $userdata['time_zone'] = $this->lang->line($userdata['time_zone']); // User's videos $this->load->model('videos_model'); $vs_data['videos'] = $this->videos_model->get_videos_summary(NULL, $username, intval($videos_offset), $this->config->item('videos_per_page'), 'hottest', $allow_unactivated); // Pagination $this->load->library('pagination'); $pg_config['base_url'] = site_url("user/profile/{$username}/"); $pg_config['uri_segment'] = 4; $pg_config['total_rows'] = $this->videos_model->get_videos_count(NULL, $username, $allow_unactivated); $pg_config['per_page'] = $this->config->item('videos_per_page'); $this->pagination->initialize($pg_config); $vs_data['pagination'] = $this->pagination->create_links(); $vs_data['title'] = NULL; $vs_data['category_name'] = ''; // TODO videos_summary with AJAX $params = array('title' => $this->lang->line('user_appelation') . ' ' . $username . ' – ' . $this->config->item('site_name'), 'css' => array('catalog.css'), 'js' => array('jquery.ui.thumbs.js')); $this->load->library('html_head_params', $params); // Current user profile tab $tab = !$videos_offset ? 0 : 1; // ** // ** LOADING VIEWS // ** $this->load->view('html_begin', $this->html_head_params); $this->load->view('header', array()); $vs = $this->load->view('catalog/videos_summary_view', $vs_data, TRUE); $main_params['content'] = $this->load->view('user/profile_view', array('userdata' => $userdata, 'videos_summary' => $vs, 'tab' => $tab), TRUE); $main_params['side'] = $this->load->view('side_default', NULL, TRUE); $this->load->view('main', $main_params); $this->load->view('footer'); $this->load->view('html_end'); }
/** * Push notification for mobile when Admin change access point * * @return bool */ function push_notification_change_access_point() { // Get all access point have selected $access_point = $this->get_all_access_point(SELECTED); if ($access_point != NULL) { $this->load->model('users_model'); $users = Users_model::get_all_users(); $registation_ids = array(); if ($users != NULL) { foreach ($users as $user) { if ($user->gcm_regid != NULL) { $registation_ids[] = $user->gcm_regid; } } } if ($registation_ids != NULL) { $send_notification['data'] = array('type' => 'config_access_point', 'access_point' => $access_point); $this->common->send_notification($registation_ids, $send_notification); return TRUE; } else { return FALSE; } } else { return FALSE; } }
public function viewAllTeachers() { $this->load->model('users_model'); $p = new Users_model(); $data['users'] = $p->viewAllTeachers(); $this->load->view('includes/header'); $this->load->view('includes/banner'); $this->load->view('staff/staff-menu'); $this->load->view('staff/view-users', $data); }
function delete() { $this->load->model('users_model'); if ($this->input->post('selected')) { $selected = $this->input->post('selected'); } else { $selected = (array) $this->uri->segment(4); } $User = new Users_model(); // Non-super admins cannot delete super admins nor can they delete themselves if ($this->Group_session->type == SUPER_ADMIN) { $User->where('id !=', $this->secure->get_user_session()->id)->where_in('id', $selected)->get(); } else { $User->where('id !=', $this->secure->get_user_session()->id)->where_related_groups('type !=', SUPER_ADMIN)->where_in('id', $selected)->get(); } $idExist = array(); $idNotExist = array(); $quote_request_model = $this->load->model('quote/quote_request_model'); $binder_request_model = $this->load->model('quote/binder_request_model'); $invitation_log_model = $this->load->model('trivia/invitation_log_model'); $user_log_points_model = $this->load->model('trivia/points/user_log_points_model'); foreach ($User as $My_user) { $quoteExist = $quote_request_model->QuoteExist($My_user->id); $binderExist = $binder_request_model->BinderExist($My_user->id); $invitationExist = $invitation_log_model->InvitationLogExist($My_user->id); $pointExist = $user_log_points_model->PointExist($My_user->id); // echo "$quoteExist || $binderExist || $invitationExist || $pointExist";exit; if ($quoteExist || $binderExist || $invitationExist || $pointExist) { $idExist[] = $My_user; } else { $idNotExist[] = $My_user; } } if (!empty($idNotExist)) { // Delete user uploads // $this->load->helper('file'); // // foreach ($User as $My_user) // { // $upload_path = CMS_ROOT . USER_DATA . $My_user->id . '/'; // delete_files($upload_path, TRUE); // @rmdir($upload_path); // } $this->users_model->deleteUser($idNotExist); // $User->delete_all(); $this->session->set_flashdata('message', '<p class="success">The selected items were successfully deleted.</p>'); } if (!empty($idExist)) { $this->session->set_flashdata('message', '<p class="error">Cannot delete selected user due to presence of data in database.</p>'); } redirect(ADMIN_PATH . '/users'); }
public function recover_password($username, $email) { $userdata = $this->get_userdata($username, 'email, username, id'); if (strcmp($userdata['email'], $email) !== 0) { return FALSE; } $recovered_password = Users_model::gen_password(); $this->set_userdata(intval($userdata['id']), array('password' => $recovered_password)); $subject = '[' . $this->config->item('site_name') . '] Password Recovery'; $msg = sprintf($this->lang->line('user_password_recovery_email_content'), $username, $this->config->item('site_name'), site_url(), $recovered_password); $headers = "From: " . $this->config->item('noreply_email'); mail($email, $subject, $msg, $headers); return TRUE; }
/** * User leave table * * @param int $user_id * @param int $table_id * @param int $day( NORMAL DAY OR VEGAN DAY) * @return int */ function user_leave_table($user_id, $table_id, $day = NULL) { $result = LEAVE_TABLE_FAILED; if ($this->is_user_belongs_to_table($user_id, $table_id, $day)) { $this->load->model('users_model'); $is_vegan_table = $this->is_vegan_table($table_id); $is_user_want_vegan_meal = Users_model::is_user_want_vegan_meal($user_id); $res = $is_vegan_table ? $this->check_status_of_user_in_table($user_id, VEGAN_DAY) : $this->check_status_of_user_in_table($user_id, NORMAL_DAY); if ($is_user_want_vegan_meal && $is_vegan_table) { $result = $this->delete_user_in_table($user_id, $table_id, VEGAN_DAY) ? LEAVE_TABLE_SUCCESSFULLY : LEAVE_TABLE_FAILED; } else { if ($is_user_want_vegan_meal && !$is_vegan_table) { $result = $this->delete_user_in_table($user_id, $table_id, NORMAL_DAY) ? LEAVE_TABLE_SUCCESSFULLY : LEAVE_TABLE_FAILED; } else { if (!$is_user_want_vegan_meal && !$is_vegan_table) { $result = $this->delete_user_in_table($user_id, $table_id, NULL) ? LEAVE_TABLE_SUCCESSFULLY : LEAVE_TABLE_FAILED; } else { $result = LEAVE_TABLE_FAILED; } } } } else { $result = NO_SEAT_IN_TABLE; } return $result; }