Welcome Guest, Not a member yet? Register   Sign In
  Validation Class Migration
Posted by: El Forum - 11-02-2008, 11:45 PM - Replies (3)

[eluser]Azghanvi[/eluser]
Hi,

There is a big difference in code and implementation of new validation class.
This is really a headache for existing project of (1.6.3) to replace old validation class with new one.

Was it really required?

Well, in any case ... is there any easy way to migrate old validation class to new one?

Thanks!


  Upload excel file
Posted by: El Forum - 11-02-2008, 11:11 PM - Replies (3)

[eluser]henrihnr[/eluser]
Dear CI users..

I need to upload an excel file, which is in 2003 or 2007 format..
with 2003 format it works fine but 2007 format always return error message 'The filetype you are attempting to upload is not allowed.'

here's the code

Code:
$config['upload_path'] = 'uploads/';
$config['allowed_types'] = 'xls|xlsx';
        
$this->load->library('upload', $config);
    
if ( ! $this->upload->do_upload())
{
   echo $this->upload->display_errors();
}

anyone help me, please..


  internal server error
Posted by: El Forum - 11-02-2008, 10:55 PM - Replies (4)

[eluser]Fenix[/eluser]
I'm doing a simple "delete post" functionality that has a confirmation form and I am getting an internal server error. I use MediaTemple hosting. All my other similar scripts are working fine. If anybody can help me figure this out, that would be great. Thanks.

Quote:Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, [email protected] and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.
Apache/2.0.54 Server at mywebsite.com Port 80

here are my controller functions
Code:
function delete_post($id = '')
{
    $this->load->model('posts');

    if($id != '')
    {
        // Confirmation Page
        $data['dpost']['id'] = $id;
        $data['dpost']['title'] = $this->posts->get_post_atr('title',$id);
        $data['page_title'] = $this->config->item('title').': Confirm Delete Post';
        $data['left_col'] = $this->load->view('admin/anav_view',$data,true);
        $data['center_col'] = $this->load->view('admin/dpost_view',$data,true);
        $this->load->view('template_view',$data);
    }
    else
    {
        echo 'no id specified';
    }
}

function delete_post_process()
{
    $this->load->model('posts');
    if ($this->input->post('submitted'))
    {
        // Delete Post
        $dpost_id = $this->input->post('delete_id');
        $this->posts->delete_post($dpost_id);
        redirect('admin/dashboard/post_deleted','refresh');
    }
    else
    {
        echo 'missing post data';
    }
}

function post_deleted()
{
    $data['page_title'] = $this->config->item('title').': Post Deleted';
    $data['left_col'] = $this->load->view('admin/anav_view',$data,true);
    $data['center_col'] = $this->load->view('admin/dcpost_view',$data,true);
    $this->load->view('template_view',$data);
}

here are my model functions which i think aren't a problem
Code:
function get_post_atr($atr, $post_id)
{
    $this->db->select($atr);
    $this->db->where('post_id', $post_id);
    $this->db->limit(1);
    return $this->db->get('posts')->result();
}

function delete_post($post_id)
{
    $this->db->where('post_id', $post_id);
    $this->db->update('posts', array('status' => 'deleted'));
}


  Active Record two tables. How to?
Posted by: El Forum - 11-02-2008, 08:37 PM - Replies (4)

[eluser]Lazos[/eluser]
How do you write this query in Active Record?

Code:
$query = $this->CI->db->query('SELECT u.*, s.* FROM my_users AS u,
my_sessions AS s WHERE u.user_id = s.session_user_id AND s.session_id = "'.$session_id.'"');


  Why I get this error (Undefined index:)?
Posted by: El Forum - 11-02-2008, 05:03 PM - Replies (3)

[eluser]Lazos[/eluser]
The Controller

Code:
class Login extends Controller {
    
    function index()
    {
        $user_ip = $_SERVER['REMOTE_ADDR'];
        $userdata = $this->my_session->sess_read($user_ip, LOGIN);      
        
        $templatevars = array (
            'L_LOGIN_TITLE' => $this->lang->line('login_title'),
            'L_ENCODING'    =>    $this->lang->line('encoding'),
            'L_INFO' =>        $this->lang->line('information'),
            'L_LOGIN_INFO' =>        $this->lang->line('login_info'),
            'L_LOGIN_INFO_PARAMS' =>        $this->lang->line('login_info_params'),
            'L_USERNAME' =>        $this->lang->line('login_username'),
            'L_PASSWORD' =>        $this->lang->line('login_password'),
            'L_SUBMIT' =>        $this->lang->line('submit'),
            'L_CANCEL' =>            $this->lang->line('cancel')
        
        
        
        );
        if ($userdata['session_logged_in'] == 0) {
        $this->parser->parse('admin/login.tpl', $templatevars);
        }
    }
}

My_Session Class
Code:
function sess_read($user_ip, $page)
    {
        // Fetch the cookie    
        $session = $this->CI->input->cookie($this->sess_cookie_name);
        
        // No cookie?  Goodbye cruel world!...
        if ($session === FALSE)
        {
            log_message('debug', 'A session cookie was not found.');
            $this->sess_create(ANONYMOUS, $user_ip, $page);
        } else {
            
            // Decrypt the cookie data
            if ($this->sess_encrypt_cookie == TRUE)
            {
                $session = $this->CI->encrypt->decode($session);
            }
            else
            {    
                // encryption was not used, so we need to check the md5 hash
                $hash     = substr($session, strlen($session)-32); // get last 32 chars
                $session = substr($session, 0, strlen($session)-32);
    
                // Does the md5 hash match?  This is to prevent manipulation of session data in userspace
                if ($hash !==  md5($session.$this->encryption_key))
                {
                    log_message('error', 'The session cookie data did not match what was expected. This could be a possible hacking attempt.');
                    $this->sess_destroy();
                    $this->sess_create(ANONYMOUS, $user_ip, $page);
                }
            }
            
            // Unserialize the session array
            $session = $this->_unserialize($session);
            $user_id = $session['session_user_id'];
            
            // Is the session data we unserialized an array with the correct format?
            if ( ! is_array($session) OR ! isset($session['session_id']) OR ! isset($session['ip_address']) OR ! isset($session['session_user_id']) OR ! isset($session['user_agent']) OR ! isset($session['last_activity']))
            {
                $this->sess_destroy();
                $this->sess_create($user_id, $user_ip, $page);
            }
            
            // Is the session current?
            if (($session['last_activity'] + $this->sess_expiration) < $this->now)
            {
                $this->sess_destroy();
                $this->sess_create($user_id, $user_ip, $page);
            }
    
            // Does the IP Match?
            if ($this->sess_match_ip == TRUE AND $session['ip_address'] != $this->CI->input->ip_address())
            {
                $this->sess_destroy();
                $this->sess_create($user_id, $user_ip, $page);
            }
            
            // Does the User Agent Match?
            if ($this->sess_match_useragent == TRUE AND trim($session['user_agent']) != trim(substr($this->CI->input->user_agent(), 0, 50)))
            {
                $this->sess_destroy();
                $this->sess_create($user_id, $user_ip, $page);
            }
            
            // Is there a corresponding session in the DB?
            if ($this->sess_use_database === TRUE)
            {
                $this->CI->db->where('session_id', $session['session_id']);
                        
                if ($this->sess_match_ip == TRUE)
                {
                    $this->CI->db->where('ip_address', $session['ip_address']);
                }
    
                if ($this->sess_match_useragent == TRUE)
                {
                    $this->CI->db->where('user_agent', $session['user_agent']);
                }
                
                $query = $this->CI->db->get($this->sess_table_name);
    
                // No result?  Kill it!
                if ($query->num_rows() == 0)
                {
                    $this->sess_destroy();
                    $this->sess_create($user_id, $user_ip, $page);
                }                
            }
        
            // Session is valid!
            $this->CI->db->where('session_id', $session['session_id']);
            $this->CI->db->where_in('session_user_id', $session['session_user_id']);
            $query = $this->CI->db->get($this->sess_table_name, $this->users_table_name);
            if ($query->num_rows() == 1)
                {
                    $this->userdata = $query->result();
                    $this->sessiondata = $session;
                    unset($session);
                    $this->sess_update();
                    return $this->userdata;
                    
                }
            }        
    }

Why I am getting this error in the controller?
A PHP Error was encountered

Severity: Notice

Message: Undefined index: session_logged_in

Filename: admin/login.php

Line Number: 31


  Documentation: SMALL Typos
Posted by: El Forum - 11-02-2008, 03:53 PM - Replies (6)

[eluser]electBlake[/eluser]
First off just want to say the documentation is stellar. I'm using CodeIgniter because of it!

Anyway, I read through everything but the class references and I found a few small things I think might be bugs. SMALL.




Bug On Page: http://ellislab.com/codeigniter/user-gui...uting.html
Is it bug?: - the example shows (:num) not (:any) when in the explanation it says "any"

Code:
$route['product/(:num)'] = "catalog/product_lookup_by_id/$1";
Quote:A URL with "product" as the first segment, and anything in the second will be remapped to the "catalog" class and the "product_lookup_by_id" method passing in the match as a variable to the function.




Bug On Page: http://ellislab.com/codeigniter/user-gui...#remapping
Is it bug?: the example has: $this->$method(); and in the next line $this->default_... Shouldn't it just be $this->method() (maybe it was meant to be $$method() ?)
Quote:The overridden function call (typically the second segment of the URI) will be passed as a parameter the _remap() function:
Code:
function _remap($method)
{
    if ($method == 'some_method')
    {
        $this->$method();
    }
    else
    {
        $this->default_method();
    }
}


  Manage Database Exceptions...
Posted by: El Forum - 11-02-2008, 03:41 PM - Replies (2)

[eluser]XeRGi0[/eluser]
Hi there!!!

I got a lil' doubt... I'm using postgres, and I want to make most of the validations process in my dbms.

Let's say I grant privileges on a table to a certain users, if a tried to "SELECT" that table won't work and an error will be triggered... "Permission denied for relation......"

Ok, i want to show that error in my application without the "Database error" page that CI shows...

I a certain user can't access to certain table, show that error in a DIV only, and let the whole app keep going...

It can be done? Thanx...


  confirming successful update
Posted by: El Forum - 11-02-2008, 02:45 PM - Replies (2)

[eluser]Fenix[/eluser]
is there an easy way to check if a query has run successfully?
i'd like the update fucntions in my model to return true/false if they did/didn't succeed.
is this even necessary?
any ideas?

thanks


  how to handle Multiple form on one page without showing validation errors of both forms.
Posted by: El Forum - 11-02-2008, 01:04 PM - Replies (3)

[eluser]pankaj[/eluser]
I want to put two forms on my front page which are one for "registration of user" and one for "login" like facebook has on its front page but when I submit the page either for registration or login it will show validation errors for both forms can anybody please explain me how to handle both forms at a time without showing errors from both forms. and it should show error for particular form only and not for both forms.
is there any thread on this topic as I can't find one.

please help
thank you.


  Database nightmare: MySQL table crashes all the time
Posted by: El Forum - 11-02-2008, 10:52 AM - Replies (6)

[eluser]dmitrybelyakov[/eluser]
Hello,

I'm experiencing a problem with MySQL that causes several tables to CRASH all the time. I cannot localaze it to any particular piece of code that is causing this since the CodeIgniter user session table crashes all the time also.

So i guess it's not coding problem. I would appreciate any help or sugestions how can we debug and fix this.


Thanks!


Welcome, Guest
You have to register before you can post on our site.

Username
  

Password
  





Latest Threads
SQL server connection not...
by kenjis
59 minutes ago
CI 4.5.1 CSRF - The actio...
by kenjis
1 hour ago
CodeIgniter v4.5.0 Releas...
by kenjis
1 hour ago
Cache best practice?
by BhambriRohunu
2 hours ago
Bug with sessions CI 4.5....
by InsiteFX
3 hours ago
Codeigniter Shield Bannin...
by kenjis
7 hours ago
Best way to create micros...
by kenjis
10 hours ago
How to use Codeigniter wi...
by kenjis
10 hours ago
Getting supportedLocales ...
by kcs
Yesterday, 09:30 AM
Component help
by FlashMaster
Yesterday, 01:41 AM

Forum Statistics
» Members: 85,294
» Latest member: immigration_nz
» Forum threads: 77,577
» Forum posts: 375,985

Full Statistics

Search Forums

(Advanced Search)


Theme © iAndrew 2016 - Forum software by © MyBB