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
https://forums.phpfreaks.com/topic/199326-allow_url_includes-issue/
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.

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);
        }

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.