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



Search Forums

(Advanced Search)

Forum Statistics
» Members: 9,430
» Latest member: riham13
» Forum threads: 66,609
» Forum posts: 417,739

Full Statistics

Latest Threads
Using existing session da...
Forum: General Help
12 minutes ago
» Replies: 2   » Views: 46
Rewrite on Windows Server
Forum: General Help
2 hours ago
» Replies: 0   » Views: 17
CI 2.1.4 - PHP 5.6.30 - p...
Forum: CodeIgniter 2.x
3 hours ago
» Replies: 2   » Views: 36
All links give a 500 Erro...
Forum: General Help
8 hours ago
» Replies: 4   » Views: 174
H1,H2 headings are to big
Forum: Lounge
Yesterday, 05:58 PM
» Replies: 8   » Views: 146
Error 500
Forum: Installation & Setup
Yesterday, 04:44 PM
» Replies: 3   » Views: 89
Better update routine?
Forum: General Help
Yesterday, 04:20 PM
» Replies: 19   » Views: 470
Problem with large record...
Forum: Regional User Groups
Yesterday, 03:55 PM
» Replies: 5   » Views: 98
Sessions Performance Issu...
Forum: CodeIgniter 3.x
Yesterday, 12:17 PM
» Replies: 6   » Views: 455
How to call controller fr...
Forum: Best Practices
Yesterday, 11:51 AM
» Replies: 10   » Views: 546

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

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.


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

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.



class Note extends Controller()
    function Note()
    function index()

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)

line 663 in validation.php

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)

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.

$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: ");

this gives the following output:
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
return str_replace(array("'", '"', '<', '>'), array("'", "&quot;", '&lt;', '&gt;'), stripslashes($str));

There shouldn't be a stripslashes there right?

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)

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:


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


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:

class MY_Router extends CI_Router{
    function MY_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


            $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

                    return $this->custom_404();








                // 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
        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)

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():

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

Checking locale (varies according to your region, of course):
$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:
setlocale(LC_ALL, 'no_no');

Replacement pattern:
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)

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

$data['query'] = $this->db->get('user');

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

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

is available to add attributes to parse template tag link ExpressionEngine
For example

{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)

Here is my code in processing file upload :

class Ungxu extends Controller
  function Ungxu()
function index()
       $this->load->view('ungxu', array('error' => ' ' ));// pass error argument
       // attach file upload (if have)
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);
                $upload_data = $this->upload->data();
                $filename = $upload_data['file_name'];

and view:
    &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>
    <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;                            
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.