Jump to content

Allow_url_includes issue


YourNameHere

Recommended Posts

I have a class that's called 'page'

within 'page' there is a method called 'load'

 

It loads a 'template'. which is just an html or php page within the views directory.

 

load takes two parameters, $page_name, $views_directory.

 

function load($page_name, $views_directory)
        {
            include_once($views_directory.$page_name);
        }

 

This is from my production server:

 

ss20100421165159.png

 

so when I use $page->load('main.php', 'http://localhost/hatrixx/views/');

 

it fails with this error.

 

http:// wrapper is disabled in the server configuration by allow_url_include=0 in...

 

I have access to the php.ini on my dev server but I wont on the production server so I don't want to just change that variable.

Will it work on my production server and/or is there a way around this?

 

 

Link to comment
Share on other sites

Why would you want to include a local file using a URL? That takes 50-100 times longer than including it using a file system path because with a URL your web server must make a http request back to your web server to request the page, the same as if you browsed to the URL.

Link to comment
Share on other sites

Why would you want to include a local file using a URL?

because the url will be in a config file using a $base_url.'views/'

 

this class is a helper class to make coding faster. and the views/ dir may be different with each application.

 

But I just used a bunch of if/ifelse statement to find the /views/ directory and it works.

 

function load($template, $base_url)
        {
            if (is_dir('/views/'))
            {
                $inc_views = '/views/';
            }
            elseif 
            (is_dir('../views/'))
            {
                $inc_views = '../views/';
            }
            elseif
            (is_dir('../../views/'))
            {
                $inc_views = '../../views/';
            }
            elseif
            (is_dir('../../../views/'))
            {
                $inc_views = '../../../views/';
            }
            elseif
            (is_dir('../../../../views/'))
            {
                $inc_views = '../../../../views/';
            }
            include_once($inc_views.$template);
        }

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.