Mine
public text v1 · immutable<?php
if (!defined('BASEPATH'))
exit('No direct script access allowed');
class Admin extends Public_Controller {
public function __construct() {
parent::__construct();
}
public function index() {
$this->load->view('_blocks/header');
$this->load->view('_blocks/nav');
$this->load->view('dashboard');
$this->load->view('_blocks/footer');
}
/**
* Login
*/
public function create_account() {
$this->data['page_settings'] = array(
'title' => 'Create new account',
'content_heading' => 'Create a new hosting account'
);
// Form settings
$this->shp_ui->form_config(
array(
'form' => array(
'form_attributes' => array(
'class' => 'standard-form',
'id' => 'create-account-form'
),
'rows' => array(
array(
'header' => 'Account details',
'left_column' => array(
'username' => array(
'type' => 'text',
'attributes' => array(
'name' => 'username',
'id' => 'username',
'class' => 'textbox',
'value' => $this->input->post('username'),
),
'help' => 'Username is required.'
),
'activate' => array(
'name' => 'activate',
'type' => 'select',
'attributes' => 'id="activate" class="selectbox"',
'options' => array(
'0' => 'no',
'1' => 'yes',
),
'selected' => $this->input->post('activate'),
'help' => 'Activate user immediately. (requires that you set a password)'
),
),
'right_column' => array(
'email' => array(
'type' => 'text',
'attributes' => array(
'name' => 'email',
'id' => 'email',
'class' => 'textbox',
'value' => $this->input->post('email'),
),
'help' => 'Contact email.'
),
'hosting_template' => array(
'name' => 'hosting_template',
'type' => 'select',
'attributes' => 'id="hosting_template" class="selectbox"',
'options' => array(
'0' => 'Default',
'custom' => 'Customize',
'1' => 'Small',
'2' => 'Medium',
'3' => 'Large',
),
'selected' => $this->input->post('activate'),
'help' => 'Activate user immediately. (requires that you set a password)'
),
),
),
array(
'header' => 'Personal details',
'left_column' => array(
'first_name' => array(
'type' => 'text',
'attributes' => array(
'name' => 'first_name',
'id' => 'first_name',
'class' => 'textbox',
'value' => $this->input->post('first_name'),
),
'help' => 'Optional.'
),
'last_name' => array(
'type' => 'text',
'attributes' => array(
'name' => 'last_name',
'id' => 'last_name',
'class' => 'textbox',
'value' => $this->input->post('last_name'),
),
'help' => 'Optional.'
),
),
'right_column' => array(
'password' => array(
'type' => 'password',
'attributes' => array(
'name' => 'password',
'id' => 'password',
'class' => 'textbox',
),
'help' => 'Optional.'
),
'passconf' => array(
'type' => 'text',
'attributes' => array(
'name' => 'confirm_password',
'id' => 'passconf',
'class' => 'textbox',
'value' => $this->input->post('confirm_password'),
),
'help' => 'Confirm password.'
),
),
),
),
'submit' => array(
'name' => '',
'value' => 'Create account',
'class' => 'emphasis',
),
),
'form_rules' => array(
'username' => array(
'field' => 'username',
'human_name' => 'username',
'rules' => 'required|trim|alpha_dash',
),
'email' => array(
'field' => 'email',
'human_name' => 'email',
'rules' => 'valid_email',
),
'activate' => array(
'field' => 'activate',
'human_name' => 'activate',
'rules' => 'trim',
),
'hosting_template' => array(
'field' => 'hosting_template',
'human_name' => 'hosting template',
'rules' => 'trim',
),
'first_name' => array(
'field' => 'first_name',
'human_name' => 'first name',
'rules' => 'trim|alpha',
),
'last_name' => array(
'field' => 'last_name',
'human_name' => 'last name',
'rules' => 'trim|alpha',
),
'password' => array(
'field' => 'password',
'human_name' => 'password',
'rules' => 'trim',
),
'confirm_password' => array(
'field' => 'confirm_password',
'human_name' => 'Confirm password',
'rules' => 'trim|matches[password]',
),
),
)
);
// Parse form rules
$this->shp_ui->parse_form_rules();
// Validate form input
if ($this->form_validation->run() === TRUE) { // Run form validation
if ($this->shp_auth->auth_user(// Perform authentication
$this->input->post('username'), $this->input->post('password')) !== FALSE) {
// Authentication success
redirect(base_url()); // Redirect to web root
} else {
// Authentication failed, get error messages
$this->shp_ui->filter_ui_messages($this->shp_auth->get_error_msg());
}
}
// Parse form
$this->shp_ui->parse_form_view('two_column_form', true, $this->data);
}
}
/* End of file admin.php */
/* Location: ./application/controllers/admin.php */