Welcome Guest, Not a member yet? Register   Sign In
Input class doesn't seem to be loading??
#1

[eluser]minerbog[/eluser]
Hi All,

I have the following code below that I am creating for my website. For some reason it returns an error on line 8 "Thats the $this->input->ip_address();" line.

The error return is
Code:
A PHP Error was encountered

Severity: Notice

Message: Undefined property: Admin::$input

Filename: controllers/admin.php

Line Number: 8

And the code is
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Admin extends CI_Controller {
    
    public function __construct()
    {
        //New section to check IP is valid.
        $ip = $this->input->ip_address();    
        //$allowed = 'xx.xx.xx.xx';
        //$allowed = '0.0.0.0';
        if ($ip !== $allowed)
        {
            show_error($this->lang->line('error_404_message'));
            exit;
        }
        
        //Force SSL for admin
        $CI =& get_instance();
        $CI->config->config['base_url'] = str_replace('http://', 'https://', $CI->config->config['base_url']);
        if ($_SERVER['SERVER_PORT'] != 443)
        {
            redirect($CI->uri->uri_string());
        }
    }

    public function index()
    {
    }

}

/* End of file admin.php */
/* Location: ./application/controllers/admin.php

Any ideas?? I thought the input class was loaded automatically??

Cheers,

Gavin
#2

[eluser]Italo Domingues[/eluser]
In the constructor method put parent::__construct()

You do not need
Code:
$CI =& get_instance();
        $CI->config->config['base_url'] = str_replace('http://', 'https://', $CI->config->config['base_url']);

Use
Code:
$this->config->config['base_url'] = str_replace('http://', 'https://', $this->config->config['base_url']);
#3

[eluser]toopay[/eluser]
Code:
parent::__construct();
should present at first line of constructor function.
#4

[eluser]minerbog[/eluser]
Smile

Opps, Why do you always miss the obvious!!

Thanks Guys
#5

[eluser]InsiteFX[/eluser]
In the future if you need to find out if a library has loaded just add this code to your controller:
Code:
// Boolean TRUE = on - FALSE = off
$this->output->enable_profiler(TRUE);

InsiteFX




Theme © iAndrew 2016 - Forum software by © MyBB