/** * Authenticate */ function Index() { // Enable SSL? maintain_ssl($this->config->item("ssl_enabled")); // Redirect signed in users to homepage if ($this->config->item('account_email_validation_required')) { if ($this->authentication->is_signed_in()) { redirect(''); } } //redirect invalid entries to homepage if ($this->input->get('user_id', TRUE) == NULL && $this->input->get('token', TRUE) == NULL) { redirect(''); } $account = $this->Account_model->get_by_id($this->input->get('user_id', TRUE)); //check for valid token if ($this->input->get('token', TRUE) == sha1($account->id . $account->createdon . $this->config->item('password_reset_secret'))) { //activate $this->Account_model->verify($account->id); //load the confirmation page $this->load->view('account/account_authentication', isset($data) ? $data : NULL); } else { echo "FALSE"; //redirect(''); } }
function vote() { // Enable SSL? maintain_ssl($this->config->item("ssl_enabled")); $userId = (int) $this->input->get('code', TRUE); $securecode = $this->input->get('securecode', TRUE); $hash = $this->session->userdata('securecode'); $done = $this->session->userdata($hash . $userId); if ($done) { $this->data['error'] = array('code' => 2, 'type' => 'AuthLimitError', 'msg' => lang('services_auth_error')); } else { if ($hash == $securecode) { $trainer = $this->trainers_model->get_one_by_id($userId); // Create a3m account $this->data['data'] = array('votes' => sprintf("%06d", 0), 'msg' => 'Voto no registrado correctamente.', 'user' => true); if ($trainer) { $this->trainers_model->update_by_id($userId, array('votes' => $trainer['votes'] + 1)); $this->session->set_userdata($hash . $userId, '1'); // Create a3m account $this->data['data'] = array('votes' => sprintf("%06d", $trainer['votes'] + 1), 'msg' => 'Voto registrado correctamente.', 'user' => true); } } else { $this->data['error'] = array('code' => 1, 'type' => 'AuthError', 'msg' => lang('services_auth_error')); } } $this->shapeResponse(); }
function index() { // Enable SSL? maintain_ssl($this->config->item("ssl_enabled")); // Get user by username / email if (!($user = $this->account_model->get_by_username_email($this->input->post('email', true)))) { // Username / email doesn't exist $this->data['error'] = array('code' => 10, 'type' => 'NotFoundError', 'msg' => lang('sign_in_username_email_does_not_exist')); } else { // Check password if (!$this->authentication->check_password($user->password, $this->input->post('password', true))) { // Increment sign in failed attempts //$this->session->set_userdata( 'sign_in_failed_attempts', (int) $this->session->userdata( 'sign_in_failed_attempts' ) + 1 ); $this->data['error'] = array('code' => 20, 'type' => 'AuthError', 'msg' => lang('sign_in_combination_incorrect')); } else { // Clear sign in fail counter $this->session->unset_userdata('sign_in_failed_attempts'); // Run sign in routine $this->session->set_userdata('account_id', $user->id); $this->account_model->update_last_signed_in_datetime($user->id); $account_details = $this->account_details_model->get_by_account_id($this->session->userdata('account_id')); $this->data['data']['user']['fullname'] = $account_details->fullname; $this->data['data']['user']['firstname'] = $account_details->firstname; $this->data['data']['user']['lastname'] = $account_details->lastname; $this->data['data']['user']['gender'] = $account_details->gender; $this->data['data']['user']['picture'] = $account_details->picture; } } $this->shapeResponse(); }
function index() { maintain_ssl(); if ($this->authentication->is_signed_in()) { $data['account'] = $this->account_model->get_by_id($this->session->userdata('account_id')); $highest_role = 100; //$all_user_role=$this->site_model->get_all_user_role($data['account']->id); $all_user_role = $this->general->get_all_table_info_by_id_asc_desc('a3m_rel_account_role', 'account_id', $data['account']->id, 'role_id', 'asc'); foreach ($all_user_role as $user_role) { if ($user_role->role_id < $highest_role) { $highest_role = $user_role->role_id; } } if ($highest_role == 6) { // 6= customer $this->load->view('dashboard_drt_customer', isset($data) ? $data : NULL); } else { $this->load->view('dashboard', isset($data) ? $data : NULL); } //Admin Dashboard //$this->load->view('dashboard', isset($data) ? $data : NULL); //$this->load->view('dashboard_drt_customer', isset($data) ? $data : NULL); } else { //$this->load->view('dashboard', isset($data) ? $data : NULL); redirect(base_url()); } }
/** * Account sign up * * @access public * @return void */ function index() { // Enable SSL? maintain_ssl($this->config->item("ssl_enabled")); // Redirect signed in users to homepage if ($this->authentication->is_signed_in()) { redirect(''); } // Check recaptcha $recaptcha_result = $this->recaptcha->check(); // Store recaptcha pass in session so that users only needs to complete captcha once if ($recaptcha_result === TRUE) { $this->session->set_userdata('sign_up_recaptcha_pass', TRUE); } // Setup form validation $this->form_validation->set_error_delimiters('<span class="field_error">', '</span>'); $this->form_validation->set_rules(array(array('field' => 'sign_up_username', 'label' => 'lang:sign_up_username', 'rules' => 'trim|required|alpha_dash|min_length[2]|max_length[24]'), array('field' => 'sign_up_password', 'label' => 'lang:sign_up_password', 'rules' => 'trim|required|min_length[6]'), array('field' => 'sign_up_email', 'label' => 'lang:sign_up_email', 'rules' => 'trim|required|valid_email|max_length[160]'))); // Run form validation if ($this->form_validation->run() === TRUE && $this->config->item("sign_up_enabled")) { // Check if user name is taken if ($this->username_check($this->input->post('sign_up_username')) === TRUE) { $data['sign_up_username_error'] = lang('sign_up_username_taken'); } elseif ($this->email_check($this->input->post('sign_up_email')) === TRUE) { $data['sign_up_email_error'] = lang('sign_up_email_exist'); } elseif (!($this->session->userdata('sign_up_recaptcha_pass') == TRUE || $recaptcha_result === TRUE) && $this->config->item("sign_up_recaptcha_enabled") === TRUE) { $data['sign_up_recaptcha_error'] = $this->input->post('recaptcha_response_field') ? lang('sign_up_recaptcha_incorrect') : lang('sign_up_recaptcha_required'); } else { // Remove recaptcha pass $this->session->unset_userdata('sign_up_recaptcha_pass'); // Create user $user_id = $this->account_model->create($this->input->post('sign_up_username', TRUE), $this->input->post('sign_up_email', TRUE), $this->input->post('sign_up_password', TRUE)); // Add user details (auto detected country, language, timezone) $this->account_details_model->update($user_id); // Create folder for specific user if not found if (!file_exists(RES_DIR . "/user/" . $user_id)) { mkdir(RES_DIR . "/user/" . $user_id); copy(RES_DIR . "/user/index.html", RES_DIR . "/user/" . $user_id . "/index.html"); } // Generate QR Code if (!file_exists(RES_DIR . "/user/" . $user_id . "/qr-" . $user_id . ".png")) { include RES_DIR . '/adminlte/plugins/qrcode/phpqrcode/qrlib.php'; QRcode::png("#" . $user_id . "#" . $this->input->post('sign_up_username', TRUE) . "#" . $this->input->post('sign_up_email', TRUE), RES_DIR . "/user/" . $user_id . "/qr-" . $user_id . ".png", "H", 10, 2); } // Auto sign in? if ($this->config->item("sign_up_auto_sign_in")) { // Run sign in routine $this->authentication->sign_in($user_id); } redirect('account/sign_in'); } } // Load recaptcha code if ($this->config->item("sign_up_recaptcha_enabled") === TRUE) { if ($this->session->userdata('sign_up_recaptcha_pass') != TRUE) { $data['recaptcha'] = $this->recaptcha->load($recaptcha_result, $this->config->item("ssl_enabled")); } } // Load sign up view $this->load->view('sign_up', isset($data) ? $data : NULL); }
/** * Account password */ function index() { // Enable SSL? maintain_ssl($this->config->item("ssl_enabled")); // Redirect unauthenticated users to signin page if (!$this->authentication->is_signed_in()) { redirect('account/sign_in/?continue=' . urlencode(base_url() . 'account/account_password')); } // Retrieve sign in user $data['account'] = $this->account_model->get_by_id($this->session->userdata('account_id')); // No access to users without a password if (!$data['account']->password) { redirect(''); } ### Setup form validation $this->form_validation->set_error_delimiters('<span class="field_error">', '</span>'); $this->form_validation->set_rules(array(array('field' => 'password_new_password', 'label' => 'lang:password_new_password', 'rules' => 'trim|required|min_length[6]'), array('field' => 'password_retype_new_password', 'label' => 'lang:password_retype_new_password', 'rules' => 'trim|required|matches[password_new_password]'))); ### Run form validation if ($this->form_validation->run()) { // Change user's password $this->account_model->update_password($data['account']->id, $this->input->post('password_new_password', TRUE)); $this->session->set_flashdata('password_info', lang('password_password_has_been_changed')); redirect('account/account_password'); } $this->load->view('account/account_password', $data); }
/** * Account settings */ function index() { // Enable SSL? maintain_ssl($this->config->item("ssl_enabled")); // Redirect unauthenticated users to signin page if (!$this->authentication->is_signed_in()) { redirect('account/sign_in/?continue=' . urlencode(base_url() . 'account/account_settings')); } // Active Sidebar_L Menu $data['accountinfo'] = true; $data['accountsettings'] = true; // Retrieve sign in user $data['account'] = $this->account_model->get_by_id($this->session->userdata('account_id')); $data['account_details'] = $this->account_details_model->get_by_account_id($this->session->userdata('account_id')); if ($this->authorization->is_permitted('manage_mailbox')) { $this->load->helper('mailbox'); $data['mailinfo'] = mailInfo(); } // Retrieve countries, languages and timezones $data['countries'] = $this->ref_country_model->get_all(); $data['languages'] = $this->ref_language_model->get_all(); $data['zoneinfos'] = $this->ref_zoneinfo_model->get_all(); // Split date of birth into month, day and year if ($data['account_details'] && $data['account_details']->dateofbirth) { $dateofbirth = strtotime($data['account_details']->dateofbirth); $data['account_details']->dob_month = mdate('%m', $dateofbirth); $data['account_details']->dob_day = mdate('%d', $dateofbirth); $data['account_details']->dob_year = mdate('%Y', $dateofbirth); } // Setup form validation $this->form_validation->set_error_delimiters('<div class="field_error">', '</div>'); $this->form_validation->set_rules(array(array('field' => 'settings_email', 'label' => 'lang:settings_email', 'rules' => 'trim|required|valid_email|max_length[160]'), array('field' => 'settings_fullname', 'label' => 'lang:settings_fullname', 'rules' => 'trim|max_length[160]'), array('field' => 'settings_firstname', 'label' => 'lang:settings_firstname', 'rules' => 'trim|max_length[80]'), array('field' => 'settings_lastname', 'label' => 'lang:settings_lastname', 'rules' => 'trim|max_length[80]'), array('field' => 'settings_postalcode', 'label' => 'lang:settings_postalcode', 'rules' => 'trim|max_length[40]'))); // Run form validation if ($this->form_validation->run()) { // If user is changing email and new email is already taken if (strtolower($this->input->post('settings_email', TRUE)) != strtolower($data['account']->email) && $this->email_check($this->input->post('settings_email', TRUE)) === TRUE) { $data['settings_email_error'] = lang('settings_email_exist'); } elseif (!($this->input->post('settings_dob_month') && $this->input->post('settings_dob_day') && $this->input->post('settings_dob_year') || !$this->input->post('settings_dob_month') && !$this->input->post('settings_dob_day') && !$this->input->post('settings_dob_year'))) { $data['settings_dob_error'] = lang('settings_dateofbirth_incomplete'); } else { // Update account email $this->account_model->update_email($data['account']->id, $this->input->post('settings_email', TRUE) ? $this->input->post('settings_email', TRUE) : NULL); // Update account details if ($this->input->post('settings_dob_month', TRUE) && $this->input->post('settings_dob_day', TRUE) && $this->input->post('settings_dob_year', TRUE)) { $attributes['dateofbirth'] = mdate('%Y-%m-%d', strtotime($this->input->post('settings_dob_day', TRUE) . '-' . $this->input->post('settings_dob_month', TRUE) . '-' . $this->input->post('settings_dob_year', TRUE))); } $attributes['fullname'] = $this->input->post('settings_fullname', TRUE) ? $this->input->post('settings_fullname', TRUE) : NULL; $attributes['firstname'] = $this->input->post('settings_firstname', TRUE) ? $this->input->post('settings_firstname', TRUE) : NULL; $attributes['lastname'] = $this->input->post('settings_lastname', TRUE) ? $this->input->post('settings_lastname', TRUE) : NULL; $attributes['gender'] = $this->input->post('settings_gender', TRUE) ? $this->input->post('settings_gender', TRUE) : NULL; $attributes['postalcode'] = $this->input->post('settings_postalcode', TRUE) ? $this->input->post('settings_postalcode', TRUE) : NULL; $attributes['country'] = $this->input->post('settings_country', TRUE) ? $this->input->post('settings_country', TRUE) : NULL; $attributes['language'] = $this->input->post('settings_language', TRUE) ? $this->input->post('settings_language', TRUE) : NULL; $attributes['timezone'] = $this->input->post('settings_timezone', TRUE) ? $this->input->post('settings_timezone', TRUE) : NULL; $this->account_details_model->update($data['account']->id, $attributes); $data['settings_info'] = lang('settings_details_updated'); } } $this->load->view('account/account_settings', $data); }
/** * Linked accounts */ function index() { // Enable SSL? maintain_ssl($this->config->item("ssl_enabled")); // Redirect unauthenticated users to signin page if (!$this->authentication->is_signed_in()) { redirect('account/sign_in/?continue=' . urlencode(base_url() . 'account/account_linked')); } // Retrieve sign in user $data['account'] = $this->account_model->get_by_id($this->session->userdata('account_id')); $data['account_details'] = $this->account_details_model->get_by_account_id($this->session->userdata('account_id')); // Delete a linked account if ($this->input->post('facebook_id') || $this->input->post('twitter_id') || $this->input->post('openid')) { if ($this->input->post('facebook_id')) { $this->account_facebook_model->delete($this->input->post('facebook_id', TRUE)); } elseif ($this->input->post('twitter_id')) { $this->account_twitter_model->delete($this->input->post('twitter_id', TRUE)); } elseif ($this->input->post('openid')) { $this->account_openid_model->delete($this->input->post('openid', TRUE)); } $this->session->set_flashdata('linked_info', lang('linked_linked_account_deleted')); redirect('account/account_linked'); } // Check for linked accounts $data['num_of_linked_accounts'] = 0; // Get Facebook accounts if ($data['facebook_links'] = $this->account_facebook_model->get_by_account_id($this->session->userdata('account_id'))) { foreach ($data['facebook_links'] as $index => $facebook_link) { $data['num_of_linked_accounts']++; } } // Get Twitter accounts if ($data['twitter_links'] = $this->account_twitter_model->get_by_account_id($this->session->userdata('account_id'))) { $this->load->config('account/twitter'); $this->load->helper('account/twitter'); foreach ($data['twitter_links'] as $index => $twitter_link) { $data['num_of_linked_accounts']++; $epiTwitter = new EpiTwitter($this->config->item('twitter_consumer_key'), $this->config->item('twitter_consumer_secret'), $twitter_link->oauth_token, $twitter_link->oauth_token_secret); $data['twitter_links'][$index]->twitter = $epiTwitter->get_usersShow(array('user_id' => $twitter_link->twitter_id)); } } // Get OpenID accounts if ($data['openid_links'] = $this->account_openid_model->get_by_account_id($this->session->userdata('account_id'))) { foreach ($data['openid_links'] as $index => $openid_link) { if (strpos($openid_link->openid, 'google.com')) { $data['openid_links'][$index]->provider = 'google'; } elseif (strpos($openid_link->openid, 'yahoo.com')) { $data['openid_links'][$index]->provider = 'yahoo'; } elseif (strpos($openid_link->openid, 'myspace.com')) { $data['openid_links'][$index]->provider = 'myspace'; } elseif (strpos($openid_link->openid, 'aol.com')) { $data['openid_links'][$index]->provider = 'aol'; } else { $data['openid_links'][$index]->provider = 'openid'; } $data['num_of_linked_accounts']++; } } $this->load->view('account/account_linked', $data); }
function index() { // Enable SSL? maintain_ssl($this->config->item("ssl_enabled")); // Check if user is signed in on facebook if ($this->facebook_lib->user) { // Check if user has connect facebook to a3m if ($user = $this->account_facebook_model->get_by_facebook_id($this->facebook_lib->user['id'])) { // Check if user is not signed in on a3m if (!$this->authentication->is_signed_in()) { // Run sign in routine $this->authentication->sign_in($user->account_id); } $user->account_id === $this->session->userdata('account_id') ? $this->session->set_flashdata('linked_error', sprintf(lang('linked_linked_with_this_account'), lang('connect_facebook'))) : $this->session->set_flashdata('linked_error', sprintf(lang('linked_linked_with_another_account'), lang('connect_facebook'))); redirect('account/account_linked'); } else { // Check if user is signed in on a3m if (!$this->authentication->is_signed_in()) { // Store user's facebook data in session $this->session->set_userdata('connect_create', array(array('provider' => 'facebook', 'provider_id' => $this->facebook_lib->user['id']), array('fullname' => $this->facebook_lib->user['name'], 'firstname' => $this->facebook_lib->user['first_name'], 'lastname' => $this->facebook_lib->user['last_name'], 'gender' => $this->facebook_lib->user['gender'], 'picture' => 'http://graph.facebook.com/' . $this->facebook_lib->user['id'] . '/picture/?type=large'))); // Create a3m account redirect('account/connect_create'); } else { // Connect facebook to a3m $this->account_facebook_model->insert($this->session->userdata('account_id'), $this->facebook_lib->user['id']); $this->session->set_flashdata('linked_info', sprintf(lang('linked_linked_with_your_account'), lang('connect_facebook'))); redirect('account/account_linked'); } } } // Load facebook redirect view $this->load->view("account/redirect_fb"); }
function index() { maintain_ssl(); if ($this->authentication->is_signed_in()) { $data['account'] = $this->account_model->get_by_id($this->session->userdata('account_id')); } $this->load->view('home', isset($data) ? $data : NULL); }
/** * Forgot password */ function index() { // Enable SSL? maintain_ssl($this->config->item("ssl_enabled")); // Redirect signed in users to homepage if ($this->authentication->is_signed_in()) { redirect(''); } // Check recaptcha $recaptcha_result = $this->recaptcha->check(); // Store recaptcha pass in session so that users only needs to complete captcha once if ($recaptcha_result === TRUE) { $this->session->set_userdata('forget_password_recaptcha_pass', TRUE); } // Setup form validation $this->form_validation->set_error_delimiters('<span class="field_error">', '</span>'); $this->form_validation->set_rules(array(array('field' => 'forgot_password_username_email', 'label' => 'lang:forgot_password_username_email', 'rules' => 'trim|required'))); // Run form validation if ($this->form_validation->run()) { // User has neither already passed recaptcha nor just passed recaptcha if ($this->session->userdata('forget_password_recaptcha_pass') != TRUE && $recaptcha_result !== TRUE) { $data['forgot_password_recaptcha_error'] = $this->input->post('recaptcha_response_field') ? lang('forgot_password_recaptcha_incorrect') : lang('forgot_password_recaptcha_required'); } else { // Remove recaptcha pass $this->session->unset_userdata('forget_password_recaptcha_pass'); // Username does not exist if (!($account = $this->account_model->get_by_username_email($this->input->post('forgot_password_username_email')))) { $data['forgot_password_username_email_error'] = lang('forgot_password_username_email_does_not_exist'); } elseif (!$account->password) { $data['forgot_password_username_email_error'] = lang('forgot_password_does_not_manage_password'); } else { // Set reset datetime $time = $this->account_model->update_reset_sent_datetime($account->id); // Load email library $this->load->library('email'); // Generate reset password url $password_reset_url = site_url('account/reset_password?id=' . $account->id . '&token=' . sha1($account->id . $time . $this->config->item('password_reset_secret'))); // Send reset password email $this->email->from($this->config->item('password_reset_email'), lang('reset_password_email_sender')); $this->email->to($account->email); $this->email->subject(lang('reset_password_email_subject')); $this->email->message($this->load->view('reset_password_email', array('username' => $account->username, 'password_reset_url' => anchor($password_reset_url, $password_reset_url)), TRUE)); echo $this->load->view('reset_password_email', array('username' => $account->username, 'password_reset_url' => anchor($password_reset_url, $password_reset_url)), TRUE); @$this->email->send(); // Load reset password sent view $this->load->view('reset_password_sent', isset($data) ? $data : NULL); return; } } } // Load recaptcha code if ($this->session->userdata('forget_password_recaptcha_pass') != TRUE) { $data['recaptcha'] = $this->recaptcha->load($recaptcha_result, $this->config->item("ssl_enabled")); } // Load forgot password view $this->load->view('forgot_password', isset($data) ? $data : NULL); }
public function index() { maintain_ssl(); if ($this->authentication->is_signed_in()) { $data['account'] = $this->account_model->get_by_id($this->session->userdata('account_id')); redirect('social_goods/social_goods/view_product_list'); } else { redirect('account/sign_in'); } }
function index() { maintain_ssl(); if ($this->authentication->is_signed_in()) { $data['account'] = $this->account_model->get_by_id($this->session->userdata('account_id')); $this->load->view('dashboard', isset($data) ? $data : NULL); } else { //$this->load->view('dashboard', isset($data) ? $data : NULL); redirect(base_url()); } }
function index() { maintain_ssl(); if ($this->authentication->is_signed_in()) { $data['account'] = $this->account_model->get_by_id($this->session->userdata('account_id')); $data['account_details'] = $this->account_details_model->get_by_account_id($this->session->userdata('account_id')); $this->load->view('admin', isset($data) ? $data : NULL); } else { redirect('/account/sign_in', 'refresh'); } }
/** * Complete facebook's authentication process * * @access public * @return void */ function index() { // Enable SSL? maintain_ssl($this->config->item("ssl_enabled")); // Redirect user to home if 'connect_create' session data doesn't exist if (!$this->session->userdata('connect_create')) { redirect(''); } $data['connect_create'] = $this->session->userdata('connect_create'); // Setup form validation $this->form_validation->set_error_delimiters('<span class="field_error">', '</span>'); $this->form_validation->set_rules(array(array('field' => 'connect_create_username', 'label' => 'lang:connect_create_username', 'rules' => 'trim|required|alpha_numeric|min_length[2]|max_length[16]'), array('field' => 'connect_create_email', 'label' => 'lang:connect_create_email', 'rules' => 'trim|required|valid_email|max_length[160]'))); // Run form validation if ($this->form_validation->run()) { // Check if username already exist if ($this->username_check($this->input->post('connect_create_username')) === TRUE) { $data['connect_create_username_error'] = lang('connect_create_username_taken'); } elseif ($this->email_check($this->input->post('connect_create_email')) === TRUE) { $data['connect_create_email_error'] = lang('connect_create_email_exist'); } else { // Destroy 'connect_create' session data $this->session->unset_userdata('connect_create'); // Create user $user_id = $this->account_model->create($this->input->post('connect_create_username'), $this->input->post('connect_create_email')); // Add user details $this->account_details_model->update($user_id, $data['connect_create'][1]); // Load email library $this->load->library('email'); // Send user creation email $this->email->from($this->config->item('password_reset_email'), lang('new_account_email_sender')); $this->email->to($this->input->post('connect_create_email')); $this->email->subject(lang('new_account_email_subject')); $this->email->message($this->load->view('new_account_email', array('username' => $this->input->post('connect_create_username')), TRUE)); //echo $this->load->view('new_account_email', array('username' => $this->input->post('connect_create_username')), TRUE); @$this->email->send(); // Connect third party account to user switch ($data['connect_create'][0]['provider']) { case 'facebook': $this->account_facebook_model->insert($user_id, $data['connect_create'][0]['provider_id']); break; case 'twitter': $this->account_twitter_model->insert($user_id, $data['connect_create'][0]['provider_id'], $data['connect_create'][0]['token'], $data['connect_create'][0]['secret']); break; case 'openid': $this->account_openid_model->insert($data['connect_create'][0]['provider_id'], $user_id); break; } // Run sign in routine $this->authentication->sign_in($user_id); } } $this->load->view('connect_create', isset($data) ? $data : NULL); }
public function index() { maintain_ssl(); if ($this->authentication->is_signed_in()) { $data['account'] = $this->account_model->get_by_id($this->session->userdata('account_id')); if ($this->authorization->is_permitted('view_information_services')) { $this->load->helper("url"); $data['title'] = 'GramCar Generel Health checkup List'; $data['all_services_point'] = $this->ref_site_model->get_all_services_point(); $data['all_package'] = $this->ref_services_model->get_all_services_package_by_id(5); // 5= Internet Service/ Learning $this->load->library('pagination'); //pagination $config = array(); $config["base_url"] = base_url() . "learning/learning/index/"; $config["total_rows"] = $this->learning_model->get_all_learning_registration_count(); $config["per_page"] = $this->config->item("pagination_perpage"); $config["uri_segment"] = 4; $config['full_tag_open'] = '<div class="pagination"><ul>'; $config['full_tag_close'] = '</ul></div><!--pagination-->'; $config['first_link'] = '« First'; $config['first_tag_open'] = '<li class="prev page">'; $config['first_tag_close'] = '</li>'; $config['last_link'] = 'Last »'; $config['last_tag_open'] = '<li class="next page">'; $config['last_tag_close'] = '</li>'; $config['next_link'] = 'Next →'; $config['next_tag_open'] = '<li class="next page">'; $config['next_tag_close'] = '</li>'; $config['prev_link'] = '← Previous'; $config['prev_tag_open'] = '<li class="prev page">'; $config['prev_tag_close'] = '</li>'; $config['cur_tag_open'] = '<li class="active"><a href="">'; $config['cur_tag_close'] = '</a></li>'; $config['num_tag_open'] = '<li class="page">'; $config['num_tag_close'] = '</li>'; //$config['anchor_class'] = 'follow_link'; $choice = $config['total_rows'] / $config['per_page']; $config['num_links'] = round($choice); $this->pagination->initialize($config); $page = $this->uri->segment(4) ? $this->uri->segment(4) : 0; $data['all_learning'] = $this->learning_model->get_all_learning_registration_by_limit($config["per_page"], $page); $data["links"] = $this->pagination->create_links(); $data["page"] = $page; $this->load->view('learning/view_learning', isset($data) ? $data : NULL); } else { redirect(''); // if not permitted "create_registration" redirect to home page } } else { redirect('account/sign_in'); } }
function index() { maintain_ssl(); if ($this->authentication->is_signed_in()) { $data['account'] = $this->account_model->get_by_id($this->session->userdata('account_id')); $data['account_details'] = $this->account_details_model->get_by_account_id($this->session->userdata('account_id')); if ($this->authorization->is_permitted('manage_mailbox')) { $this->load->helper('mailbox'); $data['mailinfo'] = mailInfo(); } } $this->load->view('home', isset($data) ? $data : NULL); }
function index() { // Enable SSL? maintain_ssl($this->config->item("ssl_enabled")); $newUser = array(); $newUser['fullname'] = trim($this->input->post('name', TRUE)); $newUser['firstname'] = ucwords(strtolower(trim($this->input->post('name', TRUE)))); $newUser['lastname'] = trim(strpos($newUser['firstname'], ' ') !== false ? substr($newUser['firstname'], strpos($newUser['firstname'], ' ')) : ''); $newUser['firstname'] = trim(strpos($newUser['firstname'], ' ') !== false ? substr($newUser['firstname'], 0, strpos($newUser['firstname'], ' ')) : $newUser['firstname']); $newUser['gender'] = strtoupper(trim($this->input->post('gender', TRUE))) == "F" ? "F" : "M"; $newUser['email'] = strtolower(trim($this->input->post('email', TRUE))); $newUser['terms'] = (int) $this->input->post('terms', TRUE) > 0 ? 1 : 0; if ($this->username_check($newUser['email'])) { $this->data['error'] = array('code' => 10, 'type' => 'UserFoundError', 'msg' => 'El correo ya se encuentra registrado.', 'scope' => 'email'); } else { if ($this->email_check($newUser['email'])) { $this->data['error'] = array('code' => 11, 'type' => 'EmailFoundError', 'msg' => 'El correo ya se encuentra registrado.', 'scope' => 'email'); } else { if (!$newUser['terms']) { $this->data['error'] = array('code' => 30, 'type' => 'TermsError', 'msg' => 'Debes aceptar los términos de uso.', 'scope' => 'terms'); } else { // Create user $user_id = $this->account_model->create($newUser['email'], $newUser['email']); $this->account_model->update_password($user_id, $this->input->post('password', TRUE) ? $this->input->post('password', TRUE) : $newUser['email'] . $newUser['firstname']); $email = $newUser['email']; // Add user details unset($newUser['email'], $newUser['provider']); $this->account_details_model->update($user_id, $newUser); // Clear sign in fail counter $this->session->unset_userdata('sign_in_failed_attempts'); // Run sign in routine $this->session->set_userdata('account_id', $user_id); $this->account_model->update_last_signed_in_datetime($user_id); $account_details = $this->account_details_model->get_by_account_id($this->session->userdata('account_id')); $html = file_get_contents(FCPATH . 'resources/mailing/register.html'); $html = str_replace('__NAME__', htmlentities($newUser['fullname']), $html); $this->email->to($email); // change it to yours $this->email->from('*****@*****.**', 'Carus System'); $this->email->subject('¡CARUS TE DA LA BIENVENIDA!'); $this->email->message($html); $this->email->send(); // Create a3m account $this->data['data'] = array('place' => 'register.create', 'msg' => 'Usuario registrado correctamente.', 'user' => array('fullname' => $account_details->fullname, 'firstname' => $account_details->firstname, 'lastname' => $account_details->lastname, 'gender' => $account_details->gender, 'picture' => $account_details->picture)); } } } $this->shapeResponse(); }
/** * Account sign in * * @access public * @return void */ function index() { // Enable SSL? maintain_ssl($this->config->item("ssl_enabled")); // Setup form validation $this->form_validation->set_error_delimiters('<span class="field_error">', '</span>'); $this->form_validation->set_rules(array(array('field' => 'user_name', 'label' => 'lang:sign_in_username_email', 'rules' => 'trim|required'), array('field' => 'password', 'label' => 'lang:sign_in_password', 'rules' => 'trim|required'))); // Run form validation if ($this->form_validation->run() === TRUE) { // Get user by username / email if (!($user = $this->account_model->get_by_username_email(base64_decode($this->input->post('user_name', TRUE))))) { //echo base64_decode($this->input->post('user_name', TRUE)); $response["success"] = 0; $response["message"] = lang('sign_in_username_email_does_not_exist'); echo json_encode($response); } else { if (!$this->authentication->check_password($user->password, base64_decode($this->input->post('password', TRUE)))) { // Increment sign in failed attempts $this->session->set_userdata('sign_in_failed_attempts', (int) $this->session->userdata('sign_in_failed_attempts') + 1); $response["success"] = 0; $response["message"] = lang('sign_in_combination_incorrect'); echo json_encode($response); } else { $response['account_role'] = $this->acl_role_model->get_by_account_id($user->id)[0]->id; if ($response['account_role'] == 5) { $response['account'] = $this->account_model->get_by_id($user->id); $response['account_details'] = $this->account_details_model->get_by_account_id($user->id); $response["success"] = 1; $response["driver"] = 1; $response['user_id'] = $user->id; $response['api_key'] = $this->config->item("api_key"); echo json_encode($response); } else { $response['account'] = $this->account_model->get_by_id($user->id); $response['account_details'] = $this->account_details_model->get_by_account_id($user->id); $response["success"] = 1; $response["driver"] = 0; $response['user_id'] = $user->id; $response['api_key'] = $this->config->item("api_key"); echo json_encode($response); } } } } else { $response["success"] = 0; $response["message"] = "Requerd field is empty"; echo json_encode($response); } }
/** * Account sign in * * @access public * @return void */ function index() { // Enable SSL? maintain_ssl($this->config->item("ssl_enabled")); // Redirect signed in users to homepage if ($this->authentication->is_signed_in()) { redirect(''); } // Set default recaptcha pass $recaptcha_pass = $this->session->userdata('sign_in_failed_attempts') < $this->config->item('sign_in_recaptcha_offset') ? TRUE : FALSE; // Check recaptcha $recaptcha_result = $this->recaptcha->check(); // Setup form validation $this->form_validation->set_error_delimiters('<span class="field_error">', '</span>'); $this->form_validation->set_rules(array(array('field' => 'sign_in_username_email', 'label' => 'lang:sign_in_username_email', 'rules' => 'trim|required'), array('field' => 'sign_in_password', 'label' => 'lang:sign_in_password', 'rules' => 'trim|required'))); // Run form validation if ($this->form_validation->run() === TRUE) { // Get user by username / email if (!($user = $this->account_model->get_by_username_email($this->input->post('sign_in_username_email', TRUE)))) { // Username / email doesn't exist $data['sign_in_username_email_error'] = lang('sign_in_username_email_does_not_exist'); } else { // Either don't need to pass recaptcha or just passed recaptcha if (!($recaptcha_pass === TRUE || $recaptcha_result === TRUE) && $this->config->item("sign_in_recaptcha_enabled") === TRUE) { $data['sign_in_recaptcha_error'] = $this->input->post('recaptcha_response_field') ? lang('sign_in_recaptcha_incorrect') : lang('sign_in_recaptcha_required'); } else { // Check password if (!$this->authentication->check_password($user->password, $this->input->post('sign_in_password', TRUE))) { // Increment sign in failed attempts $this->session->set_userdata('sign_in_failed_attempts', (int) $this->session->userdata('sign_in_failed_attempts') + 1); $data['sign_in_error'] = lang('sign_in_combination_incorrect'); } else { // Clear sign in fail counter $this->session->unset_userdata('sign_in_failed_attempts'); // Run sign in routine $this->authentication->sign_in($user->id, $this->input->post('sign_in_remember', TRUE)); } } } } // Load recaptcha code if ($this->config->item("sign_in_recaptcha_enabled") === TRUE) { if ($this->config->item('sign_in_recaptcha_offset') <= $this->session->userdata('sign_in_failed_attempts')) { $data['recaptcha'] = $this->recaptcha->load($recaptcha_result, $this->config->item("ssl_enabled")); } } // Load sign in view $this->load->view('sign_in', isset($data) ? $data : NULL); }
/** * Account sign in * * @access public * @return void */ function index() { // Enable SSL? maintain_ssl($this->config->item("ssl_enabled")); // Redirect signed in users to homepage if ($this->authentication->is_signed_in()) { redirect(base_url()); } // Set default recaptcha pass $recaptcha_pass = $this->session->userdata('sign_in_failed_attempts') < $this->config->item('sign_in_recaptcha_offset') ? TRUE : FALSE; // Check recaptcha $recaptcha_result = $this->recaptcha->check(); // Setup form validation $this->form_validation->set_error_delimiters('<span class="field_error">', '</span>'); $this->form_validation->set_rules(array(array('field' => 'sign_in_username_email', 'label' => 'lang:sign_in_username_email', 'rules' => 'trim|required'), array('field' => 'sign_in_password', 'label' => 'lang:sign_in_password', 'rules' => 'trim|required'))); // Run form validation if ($this->form_validation->run()) { // Either don't need to pass recaptcha or just passed recaptcha if (!($recaptcha_pass === TRUE || $recaptcha_result === TRUE) && $this->config->item("sign_in_recaptcha_enabled") === TRUE) { $data['sign_in_recaptcha_error'] = $this->input->post('recaptcha_response_field') ? lang('sign_in_recaptcha_incorrect') : lang('sign_in_recaptcha_required'); } else { // Authenticate if ($sign_in_error = $this->authentication->sign_in($this->input->post('sign_in_username_email', TRUE), $this->input->post('sign_in_password', TRUE), $this->input->post('sign_in_remember', TRUE))) { //change this to redirect to page you want your users to go after logins redirect(base_url()); } else { if ($sign_in_error = 'invalid') { //show login error $data['sign_in_error'] = lang('sign_in_non_validated_email'); } elseif ($sign_in_error = 'suspended') { //show login error $data['sign_in_error'] = lang('sign_in_suspended_account'); } else { //show login error $data['sign_in_error'] = lang('sign_in_combination_incorrect'); } } } } // Load recaptcha code if ($this->config->item("sign_in_recaptcha_enabled") === TRUE) { if ($this->config->item('sign_in_recaptcha_offset') <= $this->session->userdata('sign_in_failed_attempts')) { $data['recaptcha'] = $this->recaptcha->load($recaptcha_result, $this->config->item("ssl_enabled")); } } // Load sign in view $this->load->view('sign_in', isset($data) ? $data : NULL); }
function share() { // Enable SSL? maintain_ssl($this->config->item("ssl_enabled")); $id = $this->input->get('id', TRUE); $type = $this->input->get('type', TRUE); $securecode = $this->input->get('securecode', TRUE); $hash = $this->session->userdata('securecode'); $done = $this->session->userdata($hash . $type . $id); if ($done) { $this->data['error'] = array('code' => 2, 'type' => 'AuthLimitError', 'msg' => lang('services_auth_error')); } else { if ($hash == $securecode) { $model = null; $field = null; if ($type == 'twitter') { $model = $this->tweetsmodel; $field = 'tweet_id'; } else { if ($type == 'instagram') { $model = $this->hashtagimmodel; $field = 'idMessage'; } else { if ($type == 'youtubemodel') { $model = $this->youtubemodel; $field = 'idYoutube'; } } } // Create a3m account $this->data['data'] = array('shares' => sprintf("%06d", 0), 'msg' => 'No registrado correctamente.', 'user' => true); if ($model) { $function = 'get_one_by_' . $field; $object = $model->{$function}($id); if ($object) { $function = 'update_by_' . $field; $model->{$function}($id, array('shares' => $object['shares'] + 1)); $this->session->set_userdata($hash . $type . $id, '1'); $this->data['data'] = array('shares' => sprintf("%06d", $object['shares'] + 1), 'msg' => 'Registo correcto.', 'user' => true); } } } else { $this->data['error'] = array('code' => 1, 'type' => 'AuthError', 'msg' => lang('services_auth_error')); } } $this->shapeResponse(); }
function index() { maintain_ssl($this->config->item("ssl_enabled")); // Redirect unauthenticated users to signin page if (!$this->authentication->is_signed_in()) { redirect('account/sign_in/?continue=' . urlencode(base_url() . 'dashboard')); } if ($this->authentication->is_signed_in()) { $data['account'] = $this->account_model->get_by_id($this->session->userdata('account_id')); $data['account_details'] = $this->account_details_model->get_by_account_id($this->session->userdata('account_id')); if ($this->authorization->is_permitted('manage_mailbox')) { $this->load->helper('mailbox'); $data['mailinfo'] = mailInfo(); } } $this->load->view('qrscanner', isset($data) ? $data : NULL); }
public function index() { maintain_ssl(); if ($this->authentication->is_signed_in()) { $data['account'] = $this->account_model->get_by_id($this->session->userdata('account_id')); if ($this->authorization->is_permitted('add_services_point_schedule')) { $data['title'] = 'GramCar add services point schedule'; $data['site'] = $this->ref_site_model->get_all_site(); $this->load->view('services_point_schedule/view_add_services_point_schedule', isset($data) ? $data : NULL); } else { redirect(''); // if not permitted "create_registration" redirect to home page } } else { redirect('account/sign_in'); } }
public function index() { maintain_ssl(); if ($this->authentication->is_signed_in()) { $data['account'] = $this->account_model->get_by_id($this->session->userdata('account_id')); if ($this->authorization->is_permitted('add_edit_delete_gramcar_services')) { $data['title'] = 'GramCar Basic Setting'; $data['services_list'] = $this->basic_setting_model->get_all_services(); $this->load->view('basic_setting/view_basic_setting', isset($data) ? $data : NULL); } else { redirect(''); // if not permitted "create_registration" redirect to home page } } else { redirect('account/sign_in'); } }
function index() { // Enable SSL? maintain_ssl($this->config->item("ssl_enabled")); if ($this->input->get('oauth_token')) { try { // Perform token exchange $this->twitter_lib->etw->setToken($this->input->get('oauth_token')); $twitter_token = $this->twitter_lib->etw->getAccessToken(); $this->twitter_lib->etw->setToken($twitter_token->oauth_token, $twitter_token->oauth_token_secret); // Get account credentials $twitter_info = $this->twitter_lib->etw->get_accountVerify_credentials()->response; } catch (Exception $e) { $this->authentication->is_signed_in() ? redirect('account/account_linked') : redirect('account/sign_up'); } // Check if user has connect twitter to a3m if ($user = $this->account_twitter_model->get_by_twitter_id($twitter_info['id'])) { // Check if user is not signed in on a3m if (!$this->authentication->is_signed_in()) { // Run sign in routine $this->authentication->sign_in($user->account_id); } $user->account_id === $this->session->userdata('account_id') ? $this->session->set_flashdata('linked_error', sprintf(lang('linked_linked_with_this_account'), lang('connect_twitter'))) : $this->session->set_flashdata('linked_error', sprintf(lang('linked_linked_with_another_account'), lang('connect_twitter'))); redirect('account/account_linked'); } else { // Check if user is signed in on a3m if (!$this->authentication->is_signed_in()) { // Store user's twitter data in session $this->session->set_userdata('connect_create', array(array('provider' => 'twitter', 'provider_id' => $twitter_info['id'], 'username' => $twitter_info['screen_name'], 'token' => $twitter_token->oauth_token, 'secret' => $twitter_token->oauth_token_secret), array('fullname' => $twitter_info['name'], 'picture' => $twitter_info['profile_image_url']))); // Create a3m account redirect('account/connect_create'); } else { // Connect twitter to a3m $this->account_twitter_model->insert($this->session->userdata('account_id'), $twitter_info['id'], $twitter_token->oauth_token, $twitter_token->oauth_token_secret); $this->session->set_flashdata('linked_info', sprintf(lang('linked_linked_with_your_account'), lang('connect_twitter'))); redirect('account/account_linked'); } } } // Redirect to authorize url header("Location: " . $this->twitter_lib->etw->getAuthenticateUrl()); }
function index() { maintain_ssl($this->config->item("ssl_enabled")); // Redirect unauthenticated users to signin page if (!$this->authentication->is_signed_in()) { redirect('account/sign_in/?continue=' . urlencode(base_url() . 'file')); } if ($this->authentication->is_signed_in()) { $this->data['account'] = $this->account_model->get_by_id($this->session->userdata('account_id')); $this->data['account_details'] = $this->account_details_model->get_by_account_id($this->session->userdata('account_id')); if ($this->authorization->is_permitted('manage_mailbox')) { $this->load->helper('mailbox'); $data['mailinfo'] = mailInfo(); } } //$this->data['scan'] = $this->scan($this->session->userdata('account_id'),FALSE); $this->data['dir'] = RES_DIR . '/user/' . $this->session->userdata('account_id'); //$this->elfinder_init($this->data['dir']); $this->load->view('file', isset($this->data) ? $this->data : NULL); }
function dashboard() { $this->output->enable_profiler(TRUE); // Enable SSL maintain_ssl($this->config->item("ssl_enabled")); // Get account data if signed in if ($this->authentication->is_signed_in()) { $data['account'] = $this->account_model->get_by_id($this->session->userdata('account_id')); } // Redirect unauthenticated users to signin page if (!$this->authentication->is_signed_in()) { redirect('account/sign_in/?continue=' . urlencode(base_url() . 'home/dashboard')); } // Redirect unauthorized users to account profile page if (!$this->authorization->is_permitted('tasks_dashboard')) { redirect('account/account_profile'); } $this->load->model('tasks_model'); $data['tasks'] = $this->tasks_model->get(); $this->load->view('dashboard', isset($data) ? $data : NULL); }
/** * Reset password */ function index($id = null) { // Enable SSL? maintain_ssl($this->config->item("ssl_enabled")); // Redirect signed in users to homepage if ($this->authentication->is_signed_in()) { redirect(''); } // Check recaptcha $recaptcha_result = $this->recaptcha->check(); // User has not passed recaptcha + check that it is really needed if ($recaptcha_result !== TRUE && $this->config->item("forgot_password_recaptcha_enabled") === TRUE) { if ($this->input->post('recaptcha_challenge_field')) { $data['reset_password_recaptcha_error'] = $recaptcha_result ? lang('reset_password_recaptcha_incorrect') : lang('reset_password_recaptcha_required'); } // Load recaptcha code $data['recaptcha'] = $this->recaptcha->load($recaptcha_result, $this->config->item("ssl_enabled")); // Load reset password captcha view $this->load->view('account/reset_password_captcha', isset($data) ? $data : NULL); return; } // Get account by email if ($account = $this->account_model->get_by_id($this->input->get('id'))) { // Check if reset password has expired if (now() < strtotime($account->resetsenton) + $this->config->item("password_reset_expiration")) { // Check if token is valid if ($this->input->get('token') == sha1($account->id . strtotime($account->resetsenton) . $this->config->item('password_reset_secret'))) { // Remove reset sent on datetime $this->account_model->remove_reset_sent_datetime($account->id); // Upon sign in, redirect to change password page $this->session->set_userdata('sign_in_redirect', 'account/account_password'); // Run sign in routine $this->authentication->sign_in($account->id); } } } // Load reset password unsuccessful view $this->load->view('account/reset_password_unsuccessful', isset($data) ? $data : NULL); }
function index() { // Enable SSL? maintain_ssl($this->config->item("ssl_enabled")); if ($this->input->get('code')) { $client = $this->google_lib->getClient(); $plus = new Google_Service_Plus($client); $client->authenticate($this->input->get('code')); $person = $plus->people->get('me'); $emails = $person->getEmails(); // Check if user has connect google to a3m if ($user = $this->account_google_model->get_by_google_id($person->getId())) { // Check if user is not signed in on a3m if (!$this->authentication->is_signed_in()) { // Run sign in routine $this->authentication->sign_in($user->account_id); } $user->account_id === $this->session->userdata('account_id') ? $this->session->set_flashdata('linked_error', sprintf(lang('linked_linked_with_this_account'), lang('connect_google'))) : $this->session->set_flashdata('linked_error', sprintf(lang('linked_linked_with_another_account'), lang('connect_google'))); redirect(''); } else { // Check if user is signed in on a3m if (!$this->authentication->is_signed_in()) { // Store user's google data in session $this->session->set_userdata('connect_create', array(array('provider' => 'google', 'provider_id' => $person->getId()), array('fullname' => $person->getDisplayName(), 'firstname' => $person->getName()->familyName, 'lastname' => $person->getName()->givenName, 'gender' => $person->gender, 'email' => count($emails) > 0 ? $emails[0]->getValue() : '', 'picture' => $person->getImage()->url))); // Create a3m account redirect('registro'); } else { // Connect google to a3m $this->account_google_model->insert($this->session->userdata('account_id'), $person->getId()); $this->session->set_flashdata('linked_info', sprintf(lang('linked_linked_with_your_account'), lang('connect_google'))); redirect(''); } } } // Load google redirect view //$this->load->view("account/redirect_gplus"); redirect(''); }