CodeIgniter Forums

Full Version: Hide functions for public
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]Mittchel[/eluser]
Dear,

I recently started out with CodeIgniter, and I really like it. It's an powerful framework which makes coding much easier and quicker.

I now have a system up and running, and trying to check some security things.. and what I want is to hide functions for the public, I can dothis with _functionname(){}

But I still want my method to be accessible from the URL, because I have ancors that link to that url. What I get if I go to this url: http://localhost/ci/properties/ I get the error:
Quote:A PHP Error was encountered
Severity: Warning
Message: Missing argument 1 for Reservation::properties()
Filename: controllers/reservation.php
Line Number: 51
Plus it shows my SQL statement, which is unsafe.

That's because my method properties($id); needs an argument, so if I use this url: /properties/4/ I will get the data.. but I don't want to get that message when someone tries to acces without the ID how can I accomplish this?

Regards,


Code:
function properties($id)
    {
        if(!$this->session->userdata('is_loggedin') && !$this->session->userdata('level') > 2 )
        {
            redirect("members/index");
        }
        
        $this->load->model('Membersmodel');
        $this->Membersmodel->show_properties($id);
    }

El Forum

[eluser]Eric Barnes[/eluser]
Why not just change it to something like:
Code:
function properties($id = '')
{
  if ( ! is_numeric($id))
  {
    show_404();
  }