Forums / General Questions / Fatal error: main() Failed opening required '' in tpl_index_default.php

Fatal error: main() Failed opening required '' in tpl_index_default.php

Locked

Views: 14,198

Results 1 to 20 of 44
This thread is locked. New replies are disabled.
3 Oct 2006, 3:09 PM
#1
sprintstar avatar

sprintstar

New Zenner

Join Date:
Oct 2006
Location:
UK
Posts:
25
Plugin Contributions:
0

Fatal error: main() Failed opening required '' in tpl_index_default.php

I have just suddenly started getting this error message (amongst others) on my site (https://www.t3tuning.co.uk).:

**Fatal error: main() [function.require]: Failed opening required '' (include_path='.:/usr/lib/php') in /home/t3tuning/public_html/shop/includes/templates/template_default/templates/tpl_index_default.php on line 42
**
Its running v1.2.5 of zencart, and is a mature site having been up for a while. I haven't changed any files recently, so it must be a change on the server of some sort.

The line in question is:

<td class="plainBox"><?php require($define_main_page); ?><br /></td>

..and it looks like "$define_main_page" is not defined on that page. It must be defined somewhere, but what could have changed on the server that could have broken this mechanism?

I have searched the forums, and people have had some similar problems (like http://www.zen-cart.com/forum/showthread.php?t=47585), but no definate solutions. I am getting no help from my hosting co, and am getting desparate!

Thanks, Chris

3 Oct 2006, 5:37 PM
#2
sprintstar avatar

sprintstar

New Zenner

Join Date:
Oct 2006
Location:
UK
Posts:
25
Plugin Contributions:
0

Re: Fatal error: main() Failed opening required '' in tpl_index_default.php

Anyone know the answer??

3 Oct 2006, 9:41 PM
#3
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Fatal error: main() Failed opening required '' in tpl_index_default.php

Your permissions on your /includes/languages/english/html_includes files are too low, causing them to not be readable, and thus the error.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

4 Oct 2006, 6:36 AM
#4
sprintstar avatar

sprintstar

New Zenner

Join Date:
Oct 2006
Location:
UK
Posts:
25
Plugin Contributions:
0

Re: Fatal error: main() Failed opening required '' in tpl_index_default.php

I don't have an html_includes directory in /includes/languages/. Should there be one in my version of zencart? I have lowered all permissions on everything in the /includes/languages/ folder, with no change..

4 Oct 2006, 7:00 AM
#5
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Fatal error: main() Failed opening required '' in tpl_index_default.php

sprintstar:

I don't have an html_includes directory in /includes/languages/. Should there be one in my version of zencart? I have lowered all permissions on everything in the /includes/languages/ folder, with no change..

Well, your code is making reference to "define pages". Those are stored in the /includes/languages/english/html_includes folder.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

4 Oct 2006, 7:49 AM
#6
sprintstar avatar

sprintstar

New Zenner

Join Date:
Oct 2006
Location:
UK
Posts:
25
Plugin Contributions:
0

Re: Fatal error: main() Failed opening required '' in tpl_index_default.php

Ah well I have an html_includes folder in /includes/languages/english/, but I have set the permissions on everything in the languages folder to 766, with no change. Where does $define_main_page get assigned a value, and what could have suddenly changed on my server to stop this working?

4 Oct 2006, 8:49 AM
#7
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Fatal error: main() Failed opening required '' in tpl_index_default.php

Did you try 777 ?

Your template file says:```php

<?php require($define_main_page); ?>
and $define_main_page is a variable that is set in the /includes/modules/pages/index/header_php.php around line 49:```php
  $define_main_page = zen_get_file_directory(DIR_WS_LANGUAGES . $_SESSION['language'] . '/html_includes/', FILENAME_DEFINE_MAIN_PAGE, 'false');

That is looking for the includes/languages/english/html_includes/mred/define_main_page.php and if it can't find that it will look for includes/languages/english/html_includes/define_main_page.php
If it can't find either of those then you'll get the error you reported.

Either that, or your template file uses something other than "$define_main_page" and the header_php.php uses something else; thus the value of the variable is blank, and when the "require()" command attempts to access it, it is forced to try loading a file whose name is blank. Thus the error.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

4 Oct 2006, 9:09 AM
#8
sprintstar avatar

sprintstar

New Zenner

Join Date:
Oct 2006
Location:
UK
Posts:
25
Plugin Contributions:
0

Re: Fatal error: main() Failed opening required '' in tpl_index_default.php

Yes, its now all 777..

I have my main page defined here:

/public_html/shop/includes/languages/english/html_includes/uktemplate/define_main_page.php

And /includes/modules/pages/index/header_php.php looks as it should, so maybe zen_get_file_directory is not working as it should?

4 Oct 2006, 9:14 AM
#9
sprintstar avatar

sprintstar

New Zenner

Join Date:
Oct 2006
Location:
UK
Posts:
25
Plugin Contributions:
0

Re: Fatal error: main() Failed opening required '' in tpl_index_default.php

Might it be anything to do with my host's php setup?

http://www.t3tuning.co.uk/phpinfo.php

4 Oct 2006, 1:43 PM
#10
pixxi avatar

pixxi

Totally Zenned

Join Date:
Jan 2004
Location:
UK
Posts:
1,065
Plugin Contributions:
1

Re: Fatal error: main() Failed opening required '' in tpl_index_default.php

Your server is running PHP as a CGI module, so the maximum you can set your folders to is 755. Try setting the files in your custom html_includes folder to 600 (user read/write).

If the errors have started recently on a mature site, it looks like your host has installed PHPSuExec on it's servers. PHPSuExec increases server security by forcing PHP scripts to run as the user, rather than as 'nobody'.

You will find you have to change permissions on all folders currently set over 755 down to 755, and reduce permissions on all files so they are no longer writable by World. You will also have to remove any php_flag or php_value statements from your htaccess and put them in a php.ini file. You may need the php.ini file copied to other folders too.

Your host should really have given you advance warning about this change so you had time to make the changes and test them before the changeover.

4 Oct 2006, 2:03 PM
#11
sprintstar avatar

sprintstar

New Zenner

Join Date:
Oct 2006
Location:
UK
Posts:
25
Plugin Contributions:
0

Re: Fatal error: main() Failed opening required '' in tpl_index_default.php

Thanks for your reply.. I have set everything within \includes\languages to 600 and much of everything else to 644, but there is no change.

I don't have any php_flag or php_value statements in .htaccess files at all, but there are some commented out ones in \admin.htaccess (below):

# Fix certain PHP values

#<IfModule mod_php4.c>
#  php_value session.use_trans_sid 0
#  php_value register_globals 1
#</IfModule>

# to turn off register_globals
# php_value register_globals 0

After my host co migrated the site, it worked for a while, then just stopped working.

What else could I try? I appreciate the suggestions, keep em comming!

4 Oct 2006, 2:07 PM
#12
sprintstar avatar

sprintstar

New Zenner

Join Date:
Oct 2006
Location:
UK
Posts:
25
Plugin Contributions:
0

Re: Fatal error: main() Failed opening required '' in tpl_index_default.php

The admin area of my site appears to work fine, if thats of any help?

4 Oct 2006, 2:23 PM
#13
pixxi avatar

pixxi

Totally Zenned

Join Date:
Jan 2004
Location:
UK
Posts:
1,065
Plugin Contributions:
1

Re: Fatal error: main() Failed opening required '' in tpl_index_default.php

It's not just your html_includes folder that needs changing ...

All folders that were set at 777 (world-writable) before now need to be set to 755.

This includes all the folders that you set to 777 when you first installed zen - see the readme/install instructions in the zen cart /docs folder for a list of the folders (eg. your image folder and it's sub-folders) - and it includes your custom html_includes folder. In other words, there's more folders than just the html_includes that you'll need to change permissions on to get your site working again.

4 Oct 2006, 2:50 PM
#14
sprintstar avatar

sprintstar

New Zenner

Join Date:
Oct 2006
Location:
UK
Posts:
25
Plugin Contributions:
0

Re: Fatal error: main() Failed opening required '' in tpl_index_default.php

The whole shop is now at 755, but no change.. :(

4 Oct 2006, 3:29 PM
#15
pixxi avatar

pixxi

Totally Zenned

Join Date:
Jan 2004
Location:
UK
Posts:
1,065
Plugin Contributions:
1

Re: Fatal error: main() Failed opening required '' in tpl_index_default.php

You're getting a fail on function.require:

Fatal error: main() [function.require]: Failed opening ...

If you look here:

http://uk.php.net/function.require

and then scroll down to the comments, you'll see a tip:

If you are experiencing a bug related to using relative paths with include or require, it may be related to a grandparent directory that is executable but not readable. It will cause FILE to return a relative path instead of the full path which it is supposed to show...

So you may want to check the permissions again on the folders leading to shop/includes/templates/template_default/templates/tpl_index_default.php.

4 Oct 2006, 3:54 PM
#16
sprintstar avatar

sprintstar

New Zenner

Join Date:
Oct 2006
Location:
UK
Posts:
25
Plugin Contributions:
0

Re: Fatal error: main() Failed opening required '' in tpl_index_default.php

Hmm, interesting. All folders in that path are readable, up to public_html, which is the last one I can access with FTP. Is it possible that one lower down is not readable such as /home or /home/t3tuning?

4 Oct 2006, 4:22 PM
#17
pixxi avatar

pixxi

Totally Zenned

Join Date:
Jan 2004
Location:
UK
Posts:
1,065
Plugin Contributions:
1

Re: Fatal error: main() Failed opening required '' in tpl_index_default.php

home and public_html should be fine (unless you've changed them, of course) - so check your folder permissions down to the file tpl_index_default.php.

Does that file exist? What are the permissions on it?

Another aspect of PHPSuExec is that any files that were previously owned by 'nobody' will now not be accessible by your user name (because all files must now be 'owned' by your user name for your account to access them). So check to see if you have any files/folders (below public_html) owned by 'nobody' - if you do, you will need to get your host to chown them back to your user name.

4 Oct 2006, 6:12 PM
#18
sprintstar avatar

sprintstar

New Zenner

Join Date:
Oct 2006
Location:
UK
Posts:
25
Plugin Contributions:
0

Re: Fatal error: main() Failed opening required '' in tpl_index_default.php

Yes, the file exists and it and all its parent folders (/public_html/shop/includes/templates/template_default/templates) and set to 755.

How do I check 'ownership'?

4 Oct 2006, 6:20 PM
#19
pixxi avatar

pixxi

Totally Zenned

Join Date:
Jan 2004
Location:
UK
Posts:
1,065
Plugin Contributions:
1

Re: Fatal error: main() Failed opening required '' in tpl_index_default.php

You should be able to see the owner and group listed alongside each file/folder in your FTP program together with size, last date modified, etc.

If yours doesn't show you that (and you may have to select an option to enable that view) try FileZilla (free) - I think that one does, IIRC.

4 Oct 2006, 6:25 PM
#20
sprintstar avatar

sprintstar

New Zenner

Join Date:
Oct 2006
Location:
UK
Posts:
25
Plugin Contributions:
0

Re: Fatal error: main() Failed opening required '' in tpl_index_default.php

Ah yeah, eveything has an owner of "32296" and a group of "32295"...