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

Username/Email:
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 8,932
» Latest member: royrk107
» Forum threads: 66,208
» Forum posts: 415,493

Full Statistics

Latest Threads
Trying to get property of...
Forum: General Help
59 minutes ago
» Replies: 1   » Views: 42
How to create resful web ...
Forum: Learn More
6 hours ago
» Replies: 1   » Views: 115
download remote file wit...
Forum: General Help
7 hours ago
» Replies: 7   » Views: 120
codeigniter captcha Allo...
Forum: General Help
8 hours ago
» Replies: 2   » Views: 58
Error conecting postgresq...
Forum: CodeIgniter 4 Support
10 hours ago
» Replies: 2   » Views: 96
How to set and read a fla...
Forum: General Help
11 hours ago
» Replies: 1   » Views: 55
Is there a way to run a c...
Forum: General Help
Today, 06:48 AM
» Replies: 2   » Views: 100
Common function
Forum: General Help
Today, 06:43 AM
» Replies: 2   » Views: 87
Query Caching or NOT?!!!
Forum: Best Practices
Yesterday, 12:07 PM
» Replies: 4   » Views: 179
Fetch data in a selected ...
Forum: CodeIgniter 3.x
Yesterday, 09:56 AM
» Replies: 8   » Views: 232

 
  Bootstrapping Advice
Posted by: El Forum - 06-23-2007, 04:29 PM - Forum: Archived General Discussion - Replies (2)

[eluser]richard_ctv[/eluser]
Hello, I am new to these forums and to CodeIgniter.

I have an application I'm working on, and I have got bogged down, so I was looking for a framework to use. I'm very impressed with CodeIgniter (compared with the dozen or so other I have looked at so far) - the system actually makes sense to me - but I have a couple of issues I need to solve quite quickly, hence my post.

I will port the existing code to the framework (this is trivial given I already use a basic MVC layout).

The four problems I have are:

1. I run separate blog and forum software alongside my main app (in /blogs and /forums). I don't want these requests to code to CodeIgniter. Possible ?

2. I need to use the forum authentication within the rest of the site (the CodeIgniter bit).

3. The length of URLs is long. The 'Controller' component might have more than one level

e.g. /category/sub-cat/sub-cat/sub-cat/item-to-view/part-1/fragment-1

There can be a number of sub-categories (the use can create these, but they wont go totally crazy), then the item to view. The item to view may be split into parts, and those may have fragments. So the transistion between the controller and he action changes. If there is no part or fragment then that is the last level.

4. I need to share some components from the main site in the other applications - for example parts of the header and footer (but not all of the header).

I hope that makes sense. :-)

Many thanks for any comments.

Richard


  Really simple (hopefully) problem.
Posted by: El Forum - 06-23-2007, 03:24 PM - Forum: Archived General Discussion - Replies (3)

[eluser]jord[/eluser]
For whatever reason, I'm having a terrible time getting a very basic code igniter application off the ground.

The welcome page works perfectly fine, but when I attempt to a use a controller / view of my own it doesn't work even if I basically copy/past from the welcome code. Viewing the source in the browser shows that nothing is being sent from the server. 'note' is currently set as the default controller.

Code:

note.php

Code:
<?php
class Note extends Controller()
{
    function Note()
    {
        parent::Controller();    
    }
    
    function index()
    {
        $this->load->view('note_viewer');
    }
}
?>

note_viewer.php is a direct copy of welcome.php

The code is simple, I just can't figure out why it isn't working. There are no errors in the logs.


  validation class esaping bug
Posted by: El Forum - 06-23-2007, 01:36 PM - Forum: Archived Development & Programming - Replies (1)

[eluser]johnman[/eluser]
line 663 in validation.php

Code:
return str_replace(array("'", '"', '<', '>'), array("'", "&quot;", '&lt;', '&gt;'), stripslashes($str));

There shouldn't be a stripslashes there right?


  I think i found a new bug , but im not sure (involves escaping & validation->run)
Posted by: El Forum - 06-23-2007, 01:04 PM - Forum: Archived General Discussion - Replies (1)

[eluser]johnman[/eluser]
I am currenly trying to get my form validation correct and somehow CI is throwing away some of the '\' if i use it in the input fields. Below is the debugging code i used to pinpoint the problem.

Code:
$this->validation->set_error_delimiters('<div class="error">', '</div>');

        if( count($_POST)){
            echo("Voor: ");
            echo($this->validation->name . " ");

        }

        if ($this->validation->run() == FALSE){ //validation failed, reload the view
            $data['query_groups'] = $this->db->get('user_groups');
            
        if(false || count($_POST)){
            echo("NA: ");
            echo($this->validation->name);
            exit;
        }

this gives the following output:
Code:
Voor: aaa\bbb NA: aaabbb

I checked everything until the validation->run and right at that point the '\' disappears.

Im not sure if this is already known since i know there are already some bugreports involving escaping.

(PS i know there shouldn't be any backslashes in a name anyway Smile )

I think i found it:

line 663 in validation.php
Code:
return str_replace(array("'", '"', '<', '>'), array("'", "&quot;", '&lt;', '&gt;'), stripslashes($str));

There shouldn't be a stripslashes there right?

EDIT
I also posted this in the bug topic just to be sure it is known .


  Escaping queries
Posted by: El Forum - 06-23-2007, 12:31 PM - Forum: Archived Development & Programming - Replies (1)

[eluser]VivaUkraine[/eluser]
Hello!
I've a very basic quastion i think...

So i have some form with to text fields, and i this form data is inserting to database..

like this:

Code:
$this->db->insert('news',$_POST);

Does the CI automaticly escaping $_POST data? Or i need to use somethink like:

Code:
$this->db->set('title',$this->db->escape($_POST['title']));

for the each field ?


  Custom 404 controller like any other controller
Posted by: El Forum - 06-23-2007, 09:35 AM - Forum: Archived Development & Programming - Replies (18)

[eluser]Henrik Pejer[/eluser]
Hello fellow CI code crunchers!

I decided to start my venture down the CI-path with a little fix for, as I'd call it, complete custom 404 controller page.

I searched the forum for how I should make a custom 404-page. It seemed like I should extend the Exceptions-class. The only problem is that the 404-event triggers before all the base classes are loaded: I have no controller, database etc.

I think the reason for this is based on security: not letting an ill typed URL somehow get run by CI as a normal controller.

But I realized that by extending not the Exceptions class but rather the Router-class, I was able to 'fool' CI to use one of my own controller, and let the system load as normal.

All I did was copy the '_validate_segments'-function and slightly modify it to return the custom controller I wanted to use as 404-page. My custom 404-controller is called 'custom404controller' and located in my application/controllers/-folder, like any other controller.

A word of advice: before you use this, test it thoroughly! Also make sure that by using this way of handling 404-errors, you do not compromise the security of you application. Also,this is for version 1.5.3 of CI.

This is the extension that seemed to do the trick:

Code:
class MY_Router extends CI_Router{
    
    function MY_Router(){
        parent::CI_Router();
    }
    
    function _validate_segments($segments)

    {

        // Does the requested controller exist in the root folder?

        if (file_exists(APPPATH.'controllers/'.$segments[0].EXT))

        {

            return $segments;

        }



        // Is the controller in a sub-folder?

        if (is_dir(APPPATH.'controllers/'.$segments[0]))

        {        

            // Set the directory and remove it from the segment array

            $this->set_directory($segments[0]);

            $segments = array_slice($segments, 1);

            

            if (count($segments) > 0)

            {

                // Does the requested controller exist in the sub-folder?

                if ( ! file_exists(APPPATH.'controllers/'.$this->fetch_directory().$segments[0].EXT))

                {
                    # HENRIK PEJER MOD: commented out the line below, added the line below that

                    #show_404();
                    return $this->custom_404();

                }

            }

            else

            {

                $this->set_class($this->default_controller);

                $this->set_method('index');

            

                // Does the default controller exist in the sub-folder?

                if ( ! file_exists(APPPATH.'controllers/'.$this->fetch_directory().$this->default_controller.EXT))

                {

                    $this->directory = '';

                    return array();

                }

            

            }              

            return $segments;

        }

    

        // Can't find the requested controller...
        # HENRIK PEJER MOD: commented out the line below, added the line below that
        #show_404();
        return $this->custom_404();

    }
    
    function custom_404(){
        # return an array with the name of the controller we want as the 404-handler...
        return array('custom404controller');
    }
}

Any advice, tips or concerns regarding the code above would be very interesting to hear.

Take care and happy CI:ing!


  alpha, xss_clean and i18n in CI
Posted by: El Forum - 06-23-2007, 05:16 AM - Forum: Archived General Discussion - Replies (1)

[eluser]Crimp[/eluser]
I have been trying to resolve two CI issues:

Validation.php -> all TRUE alpha-based functions are ASCII only
Input.php -> xss_clean silently returns an empty $_POST value if entry string is not ASCII

Both problems are already documented in the forums. Unless hacked, these core functions are not usable for anyone outside the basic ASCII geography (not even the ISO-8859-1 folks).

I have attempted, as a start, to change the locale and alter the relevant regexp patterns in Validation.php, but it fails. It seems, to me, that PCRE does not support the extended ASCII charsets despite first checking and then setting the correct locale. I hope someone may be able to assist with this to help resolve these issues. Some example snippets:

CI Validation.php alpha():

Code:
function alpha($str)
    {
        return ( ! preg_match("/^([a-z])+$/i", $str)) ? FALSE : TRUE;
    }

Checking locale (varies according to your region, of course):
Code:
$loc_no = setlocale(LC_ALL, 'no_no', 'no_NO', 'nb_NO','nb_NO.ISO-8859-1','no_NO.ISO-88591');
echo "Preferred locale on this system is '$loc_no'";

Setting tested locale:
Code:
setlocale(LC_ALL, 'no_no');

Replacement pattern:
Code:
function alpha($str)
    {
        return ( ! preg_match("/^([a-zæøåÆØÅ])+$/i", $str)) ? FALSE : TRUE;
    }

Validation strings containing the extra chars still return FALSE. Then there's the bigger xss_clean issue. Has anyone resolved these i18n issues with CI, or just written their own callbacks instead (perhaps a better approach than always hacking the core?), or just turned off those rules and hoped for the best?


  Basic Question for a newbie
Posted by: El Forum - 06-23-2007, 04:03 AM - Forum: Archived Development & Programming - Replies (6)

[eluser]deineMudder[/eluser]
Hello everyone,
i am totally new to CI.
I watched the video tutorials, which are impressive. doing the tutorials step by step on my own server seem to get me some problems already tho.
when i started to extend my controller with a db-query

Code:
$data['query'] = $this->db->get('user');
$this->load->view('login',$data);

it results in Fatal error: Call to a member function on a non-object .

now i havent made anything special at all, just following the video tutorial of "creating a blog in 20min". The scaffolding feature works nicely, tho if i try to connect on my own to the database it seems impossible to work. i was searching the forum already for over an hour to find a proper solution to my problem, but nothing seems to help.

linux server
php4


  template parser attributes
Posted by: El Forum - 06-23-2007, 03:16 AM - Forum: Archived Development & Programming - Replies (2)

[eluser]Unknown[/eluser]
is available to add attributes to parse template tag link ExpressionEngine
For example

Code:
{link slug='your slug here'}


  I think the code is correct. But.........
Posted by: El Forum - 06-23-2007, 12:12 AM - Forum: Archived Development & Programming - Replies (1)

[eluser]java[/eluser]
Here is my code in processing file upload :
Controller:

Code:
class Ungxu extends Controller
{
  function Ungxu()
{
    parent::Controller();
    $this->load->model('tintuc_model','tintuc');
    $this->load->helper('form','url');
}
}
function index()
{
       $this->load->view('ungxu', array('error' => ' ' ));// pass error argument
       // attach file upload (if have)
            
            if(isset($_POST['filename']))
            {
                $this->doUpload();
                $this->email->attach('/uploads/folder/$file_name');
        }
}
function doUpload()
    {
        $config['upload_path'] = '/uploads/ungxu/';
        $config['allowed_types'] = 'doc|txt|rar';
        $config['max_size']    = '100';
        $config['max_width']  = '1024';
        $config['max_height']  = '768';
        
        $this->load->library('upload', $config);
            
            if ( ! $this->upload->do_upload())
            {
                $error = array('error' => $this->upload->display_errors());
                $data['content'] = $this->load->view('dangky', $error, true);
            }    
            else
            {
                $upload_data = $this->upload->data();
                $filename = $upload_data['file_name'];
            }

    }
and view:
Code:
<tr>
&lt;?=$error;?&gt;
    &lt;?=form_open_multipart('ungxu/doUpload'); ?&gt;

      <td style="width: 198px">
      &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; Tài liệu đính kèm</td>
      <td>&lt;input name="filename" type="file" id="filename" /&gt; (Tối đa 1MB)</td>
</tr>
<tr>
    <td align="center" colspan="2">
     &lt;input type="submit" name="submit" value="Gửi" id="send" style="width:70px;"
&lt;input type="reset" value="Làm lại" /&gt;                            
    </td&gt;
</tr>
   </table>                
  &lt;/form&gt;
My idea is if a visitor upload a file and webpages will automatically attach file to send mail. But when i try it, an error generated:
Quote:An Error Was Encountered
Unable to load the requested language file: language/upload_lang.php
My code have some problems? Please tell me how can resolve it? Thank you..



  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2017 MyBB Group.