Welcome Guest, Not a member yet? Register   Sign In
Strange issue with validation libraries
#11

[eluser]daweb[/eluser]
Thank you for reply Xwero, I know that is my bad English...

At the time my script works fine!, but if I erase
$this->load->model('settings_model', 'set'); row it doesn't works.

Validation array errors for example is empty. If I put the model row it works!

And there's no explanation for this, I don't need that model in Login Controller.
#12

[eluser]xwero[/eluser]
I that case i don't know what the problem is either. Sorry i couldn't help you.
#13

[eluser]daweb[/eluser]
That's ok.

Thank you.
#14

[eluser]tonanbarbarian[/eluser]
can you provide the code of the model that is letting things work? that might give a clue

one other note is that you are using language lines but at no point do you load a language file in the controller

i would suggest turning on the logging and seeing what things happen in the log as well.
#15

[eluser]daweb[/eluser]
Ok tonanbarbarian, here I am.

Language file is autoloaded from autoload.php and it runs fine in all my app.

This is the setting model (set), there are just queries to my db tables.

Code:
<?php
class settings_model extends Model {

    function __construct()
    {
        parent::Model();
    }
    
    function list_items($table = NULL, $extraQuery = NULL, $order = 'name')
    {
        $this->db->orderby($order, 'desc');
        if($table == 'categories' && $extraQuery) $this->db->where('id', $extraQuery);
        if($table == 'details' && $extraQuery) $this->db->where('option_cod', $extraQuery);
        if($table == 'details_options' && $extraQuery) $this->db->where('detail_cod', $extraQuery);

        if($table == 'typologies') $this->db->where('typologies.category_cod', $extraQuery);
                
        return $this->db->get($table);
    }
    
    function list_entries()
    {
        $this->db->select('*, categories.name as categoryName, typologies.name as typologyName, entries.id as entryId, entries.status as entryStatus');
        $this->db->where(array('entries.status >=' => 0));
        $this->db->join('categories', 'categories.id = entries.category_cod');
        $this->db->join('typologies', 'typologies.id = entries.typology_cod');
        $this->db->orderby('created_date');
        return $this->db->get('entries');
    }    

        
    function list_one_item($table, $id)
    {
        $this->db->where('id', $id);
        $query = $this->db->get($table);
        if($query->num_rows() <= 0)
        {
            return FALSE;
        }
        return $query->row();
    }
    
        
    function insert_new_item($table = NULL, $title, $title_url, $field = NULL, $value = NULL, $serialized = NULL)
    {
        $title = $this->db->escape_str($title);
        
        $title = ucfirst($title);
        $title_url = strtolower($title_url);
        $title = ascii_to_entities($title);
        $data_stack = array('name' => $title, 'url' => $title_url, 'created' => time(), 'lastedit' => time(), 'status' => 1);
        
        if(!is_null($value)) $data_stack[$field] = $value;
        if(!is_null($serialized)) $data_stack['type_value'] = $serialized;
    
        if(!empty($title))
        {
            $this->db->insert($table, $data_stack);
        }
    }
    
    
    function delete_items($item, $table)
    {
        $this->db->where('id', $item);
        $this->db->delete($table);
        // ottimizza la tabella
        $this->dbutil->optimize_table($table);
    }

    function edit_items($post, $item, $table)
    {
        $title = ascii_to_entities($post['title'][$item]);
        
        $data_stack = array(
                      'name' => $this->db->escape_str($title),
                      'url' => $this->db->escape_str($post['url_title'][$item]),
                      'lastedit' => time(),
                      'status' => $post['status'][$item]
                         );
        $this->db->where('id', $item);
        $this->db->update($table, $data_stack);
    }

    function unique_record($value)
    {
        $this->db->where('url', $value);
        if($this->table == 'typologies')
        {
            $this->db->where('category_cod', $this->idCategory);
        }
        if($this->table == 'details_options')
        {
            $this->db->where('detail_cod', $this->detailCod);
        }
        if($this->table == 'details')
        {
            $this->db->where('option_cod', $this->idCategory);
        }
        
        return $this->db->get($this->table);
    }
    
    function lastInsertItem($id)
    {
        $this->db->where('id', $id);
        return $this->db->get($this->table)->row();
    }
    
    function update_options_structure($options, $category, $typology, $emptyArray = NULL)
    {
        $data_stack = array();
        $data_stack['category_cod'] = $category;
        if(is_null($emptyArray))
        {
            foreach($options as $key => $value)
            {
                $data_stack['typology_cod'] = $key;
            
                $this->db->delete('options_structure', array('category_cod' => $category, 'typology_cod' => $key));
                foreach($value as $valore)
                {
                    echo $this->db->last_query();
                    $data_stack['option_cod'] = $valore;
                    $this->db->insert('options_structure', $data_stack);
                }
            }
        }
        else
        {
            $this->db->delete('options_structure', array('category_cod' => $category, 'typology_cod' => $typology));
        }
    }
    
    function updateMemoField($value, $id)
    {
        $data_stack = array('type_value' => $value);
        $this->db->where('id', $id);
        $this->db->update('details', $data_stack, 1);
    }
}
?&gt;
#16

[eluser]tonanbarbarian[/eluser]
ok there is nothing in the model that looks like it would be causing any issues.

Grasping at straws a bit here but there are a couple of things I would try.

1. Move all of the code out of the constructor and into the index of your controller
there has been noted some issues in the past with loading things in the constructor
should not be the case but it think it has to do with issues with some specific versions of php
so try
Code:
&lt;?php
class Login extends Controller {

    function __construct()
    {
        parent::Controller();
    }

    function index()
    {
        $this->load->helper('form');
        $this->load->helper('security');
        // utente non autorizzato
        $this->authUser = FALSE;          
        $this->load->library('validation');

        $data_stack['pageTitle']   = $this->lang->line('titleLogin');
        $this->load->view('admin/custom_validation/logins_validation.php', '', FALSE);
        if($this->validation->run() == TRUE)
        {
            redirect('front', 'location');
            exit();
        }

        $this->load->view('admin/login/index', $data_stack);
    }
    
    function check_login()
    {
      $username = $this->input->post('username');
      $password = dohash($this->input->post('password'));
      if ($this->erkanaauth->try_login(array('username'=>$username, 'password'=>$password)))
      {
        $this->erkanaauth->updateLastVisit();
        return TRUE;
      }
      else
      {
        $this->validation->set_message('check_login', 'Errore, utente e/o password errati');
        return FALSE;
      }
    }
} // END Front
?&gt;
I also removed the library

Also you might want to try using the constructor in the php4 way. I know the user guide says you can use __construct in php5 however I have always used the php4 method and never had any issues, and have seen instances where people have switched to that and it fixed the problem

so you could also try
Code:
&lt;?php
class Login extends Controller {

    function Login()
    {
        parent::Controller();
        $this->load->helper('form');
        $this->load->helper('security');
        // utente non autorizzato
        $this->authUser = FALSE;          
        $this->load->library('validation');
    }

    function index()
    {

        $data_stack['pageTitle']   = $this->lang->line('titleLogin');
        $this->load->view('admin/custom_validation/logins_validation.php', '', FALSE);
        if($this->validation->run() == TRUE)
        {
            redirect('front', 'location');
            exit();
        }

        $this->load->view('admin/login/index', $data_stack);
    }
    
    function check_login()
    {
      $username = $this->input->post('username');
      $password = dohash($this->input->post('password'));
      if ($this->erkanaauth->try_login(array('username'=>$username, 'password'=>$password)))
      {
        $this->erkanaauth->updateLastVisit();
        return TRUE;
      }
      else
      {
        $this->validation->set_message('check_login', 'Errore, utente e/o password errati');
        return FALSE;
      }
    }
} // END Front
?&gt;
again i left the load model out to see if it will work now




Theme © iAndrew 2016 - Forum software by © MyBB