Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
- class User extends CI_Controller {
- /**
- * Index Page for this controller.
- *
- * Maps to the following URL
- * http://example.com/index.php/user
- * - or -
- * http://example.com/index.php/user/index
- * - or -
- * Since this controller is set as the default controller in
- * config/routes.php, it's displayed at http://example.com/
- *
- * So any other public methods not prefixed with an underscore will
- * map to /index.php/welcome/<method_name>
- * @see http://codeigniter.com/user_guide/general/urls.html
- */
- function User()
- {
- parent :: __construct();
- $this->view_data['base_url'] = base_url();
- $this->load->model('User_model');
- }
- function index()
- {
- $this->register();
- }
- function register()
- {
- $this->form_validation->set_rules('username', 'Username', 'trim|required|alpha_numeric|min_length[6]|xss_clean|strtolower|callback_usernameNotExists');
- $this->form_validation->set_rules('password', 'Password', 'trim|required|alpha_numeric|min_length[6]|xss_clean');
- $this->form_validation->set_rules('passwordConfirm', 'Confirm Password', 'trim|required|alpha_numeric|min_length[6]|xss_clean|matches[password]');
- $this->form_validation->set_rules('email', 'Email', 'trim|required|min_length[6]|xss_clean|valid_email|callback_emailNotExists');
- $this->form_validation->set_rules('firstName', 'First Name', 'trim|required|alpha_numeric|xss_clean');
- $this->form_validation->set_rules('lastName', 'Last Name', 'trim|required|alpha_numeric|xss_clean');
- if ($this->form_validation->run() == FALSE)
- {
- $this->load->view('view_register', $this->view_data);
- }
- else
- {
- $username = $this->input->post('username');
- $password = $this->input->post('password');
- $email = $this->input->post('email');
- $firstName = $this->input->post('firstName');
- $lastName = $this->input->post('lastName');
- $registrationKey = substr(md5(mt_rand()), 0, 5);
- $this->User_model->registerUser($username, $password, $email, $firstName, $lastName, $registrationKey);
- $this->load->library('email');
- $this->email->from('kowmanagement@kansasoutlawwrestling.com', 'KOW Management');
- $this->email->to($email);
- $this->email->subject('KOW Manager Account Registration');
- $this->email->message('Hello '.$firstName.' '.$lastName.' Welcome to our website!<br /><br />You, or someone using your email address, has completed registration at '.myDomainName().'. You can complete registration by clicking the following link:<br /><br />' . anchor('http://www.'.myDomainName().'/manager/verify.php?userID='.$userID.'&verifyHash='.$verifyHash.'", http://www.'.myDomainName().'/manager/verify.php?userID='.$userID.'&verifyHash='.$verifyHash.''));
- $this->email->send();
- }
- }
- function registerConfirm()
- {
- $registrationKey = $this->uri->segment(3);
- if ($registrationKey == '')
- {
- echo 'No registration key found in URL';
- exist();
- }
- $registrationConfirmed = $this->Register_model->confirmRegistration($registrationKey);
- if ($registrationConfirmed)
- {
- echo 'You have successfully registered!';
- }
- else
- {
- echo 'You have failed to register!';
- }
- }
- function usernameNotExists($username)
- {
- $this->form_validation->set_message('usernameNotExists', ' That %s already exists inside the database!');
- if($this->User_model->checkExistsUsername($username))
- {
- return false;
- }
- else
- {
- return true;
- }
- }
- function emailNotExists($email)
- {
- $this->form_validation->set_message('emailNotExists', ' That %s already exists inside the database!');
- if($this->User_model->checkExistsEmail($email))
- {
- return false;
- }
- else
- {
- return true;
- }
- }
- function myDomainName()
- {
- $my_domain = $_SERVER['HTTP_HOST'];
- $my_domain = str_replace('www.', '', $my_domain);
- return $my_domain;
- }
- }
- /* End of file welcome.php */
- /* Location: ./application/controllers/welcome.php */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement