Welcome Guest, Not a member yet? Register   Sign In
Parse error: syntax error, unexpected T_PUBLIC in /home/main.php on line 209
#1

[eluser]Unknown[/eluser]
could anyone help me im trying to get this controller to work and i keep getting this error.

_______

Parse error: syntax error, unexpected T_PUBLIC in /home/main.php on line 209
_
thanks in advance

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Main extends CI_Controller
{

var $data;

function __construct()
{
parent::__construct();
$this->load->library (array('form_validation', 'session'));
$this->load->helper(array('url', 'form'));
$this->load->model('account_model');

$this->_salt = '123456789987654321';
}
//This is the index function for logging into the dashboard
function index ()
{
if ($this->account_model->logged_in() ===TRUE)
{
$this->dashboard(TRUE);
}
else
{
$this->load->view('account/details');
}
}
//This is the dashboard area.
function dashboard($condition = FALSE)
{
if ($condition ===TRUE OR $this->account_model->logged_in() ===TRUE)
{
$this->load->view('account/dashboard');
}
else
{
$this->load->view('account/details');
}
}
//This is the code for validating the login.
function login()
{
$this->form_validation->
set_rules('username', 'Username',
'xss_clean|required|callback_username_check');
$this->form_validation->
set_rules ('password', 'Password',
'xss_clean|required|min_length[4]|max_length[12]|
sha1|callback_password_check');

$this->_username = $this->input->post('username');
$this->_password =
sha1($this->_salt . $this->input->post('password'));
{
if ($this->form_validation->run() ==FALSE)
{
$this->load->view('account/login');
}
else {
$this->account_model->login();

$data ['message'] =
"You are logged in"
. anchor('account/dashboard', 'Dashboard');
$this->load->view('account/success', $data);
}
}
//This is for new users to register account.
function register()
{
$this->form_validation->
set_rules('username', 'Username', 'xss_clean|required');

$this->form_validation->
set_rules('email', 'Email Address',
'xss_clean|required|valid_email|callback_email_exists');

$this->form_validation->set_rules('password', 'Password', 'xss_clean|required|min_length[4]|max_length[12]|matches[password_conf]
|sha1');

$this->form_validation->
set_rules('password_conf', 'Password Confirmation',
'xss_clean|required|matches[password]|sha1');

if ($this->form_validation->run() == FALSE)
{
$this->load->view('account/register');
}
else {
$data['username'] = $this->input->post('username');
$data['email'] = $this->input->post('email');
$data['password'] =
sha1($this->_salt . $this->input->post('password'));

if ($this->account_model->create($data) ===TRUE)
{
$data['message'] =
"The user account has been successfully created "
. anchor ('account/login', 'here') . ".";
$this->load->view('account/success', $data) ;
}
else {
$data['$error'] =
"There was a problem when creating your account.";
$this->load->view('account/error', $data);
}
}
}
//This is to successfully logout.
function logout()
{
$this->session->sess_destroy();
$this->load->view('account/logout');
}

function password_check()
{

$this->db->where('username', $this->_username);
$query = $this->db->get('users');
$result = $query->row_array();
if ($result['password'] == $this->_password);
{
return TRUE;
}

if ($query->num_rows() == 0)
{
$this->form_validation->
set_message('password_check', ' There was an error!');
return FALSE;
}

}
//This is to see if a user is already registered.
function user_exists($user)
{
$query = $this->db->get_where('users', array('username' => $user));

if ($query->num_rows() > 0 )
{
$this->form_validation->
set_message ('user_exists',
'The %s already registered.');
return FALSE;
}

$query->free_result();

return TRUE;
}

function email_exists($email)
{
$query = $this->db->get_where('users', array('email' => $email));

if ($query->num_rows() > 0)
{
$this->form_validation->
set_message ('email_exists',
'the %s is already registered.');
return FALSE;
}

$query->free_result();

return TRUE;
}
}
}
// intercept return from shopping cart
if (isset($_SERVER['HTTP_REFERER']) && strpos($_SERVER['HTTP_REFERER'], 'http://www.mcssl.com/SecureCart') === 0 && strpos($this->session->userdata('cartReturn'), base_url()) === 0)
{
$redirect = $this->session->userdata('cartReturn');
$this->session->set_userdata('cartReturn', false);
redirect($redirect);
}

// generate nav tree
$this->data['site_nav'] = $this->_getSubCats(0);
$this->data['meta'] = array(
'title'=>'',
'keywords'=>'',
'description'=>''
);

include_once(BASEPATH.'../serly.php');


function _getSubCats($parent)
{
$subCats = false;
$query = 'SELECT DISTINCT new_categories.* FROM new_categories
WHERE parentCat = '.(int)$parent.' AND displayMenu = 1 ORDER BY displayOrder ASC, name ASC';
$results = $this->db->query($query);
if ($results->num_rows() > 0)
{
foreach ($results->result_array() as $cat)
{
$cat['subcats'] = $this->_getSubCats($cat['catId']);
$subCats[] = $cat;
}
}

return $subCats;
}

public function index()
{
//$this->output->cache(15);
// load home page books
$book = new Book();
if (isset($this->data['home_boxes']) && is_array($this->data['home_boxes']))
{
$this->data['badsku'] =




Theme © iAndrew 2016 - Forum software by © MyBB