0
votes

I have several websites that function like one big CMS, with all sites based on includes hosted by one central website. I posted code from one of the satellite sites below to illustrate how I include files.

The problem is that I just activated PDO online, and it's causing all kinds of problems. There's apparently a conflict between PDO and my .htaccess files that I'm working on. At the same time, my includes aren't being included.

So I'd like to ask if there's an alternate method of including files between websites online, at least until I can fix the PDO/Apache problem(s). Thanks.

$path = $_SERVER['REQUEST_URI'];
$path2 = str_replace('/', '', $path);

$Section  = current(explode('/', ltrim($path, '/'), 2));  // Main line 
$Sections = array('Introduction', 'Topics', 'World', 'Ecosymbols', 'Glossary', 'Reference',  'Links', 'About', 'Search');

if ( ! in_array($Section, $Sections)) 
{ 
 // die('Invalid section: ' . $Section); 
} 

switch (PHP_OS)
{
 case 'Linux':
 $BaseINC = '/home/geobear2/public_html';
 $BaseURL = 'http://www.geobop.org';
 break;

 case 'Darwin':
 // Just some code for my local includes...
 break;

 default:
 break;
}

include ($BaseINC."/2B/dbc.php");

Note: Here are the error messages I'm getting from the home page of one affected site. ACE.php is the name of the file that contains the code I posted above.

Warning: include(/home/geobear2/public_html/2B/dbc.php) [function.include]: failed to open stream: Permission denied in /home/symbolos/public_html/1A/ACE.php on line 67

Warning: include() [function.include]: Failed opening '/home/geobear2/public_html/2B/dbc.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/symbolos/public_html/1A/ACE.php on line 67

Warning: include(/home/geobear2/public_html/2B/inc/A1.php) [function.include]: failed to open stream: Permission denied in /home/symbolos/public_html/index.php on line 31

Warning: include() [function.include]: Failed opening '/home/geobear2/public_html/2B/inc/A1.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/symbolos/public_html/index.php on line 31

1
PDO wouldn't affect this sort of stuff. PDO also has nothing to do with .htaccess and I can't imagine how you think they're interacting. You mention "all kinds of problems" without providing any useful details, and the code you've provided really doesn't tell us much at all... - ceejayoz
I originally had an Internal Server Error (after my webhost enabled PDO). A support tech looked into it, and he said there was some sort of conflict between PDO and my .htaccess files, specifically the line php_flag magic_quotes_gpc Off. When I commented that line out one of my .htaccess files, my site was partially restored... - David Blomstrom
Hmmm...My home page was restored as I was typing the comment above. However, no other pages display, as the link to my database connection file is still lost. I'll post the error messages in my original post, so they aren't so jumbled. - David Blomstrom
hey you asked that question already.. why not edit the other one? stackoverflow.com/questions/23024576/… - Félix Adriyel Gagnon-Grenier
magic_quotes_gpc has nothing to do with PDO. Time to get a new host - if their support techs are that ignorant you're in for a world of hurt. The reason that setting is breaking your site is probably because the setting got removed in PHP 5.4 - if you're on a PHP 5.4 host, it has no clue what to do with that setting. See the red box in php.net/manual/en/security.magicquotes.php. - ceejayoz

1 Answers

2
votes

I believe you're asking the wrong question... the way you "include" files in your application is a bit wrong and, i might say, "oldschool".

You should not include from other websites... if they are hosted on the same server you can use (if you have enough access, some servers will forbid you to do this), absolute paths for includes.

Also, your method will slow you down, and i doubt it worked in the first place...

See how include works here: http://ro1.php.net/manual/en/function.include.php +++ cross reference require, require_once, include_once.

Elegant solution: If you read the documentations properly and play around with it, granted your server has a newer version of php (5.3 atleast from what i remember, i may be wrong), you can start using namespaces.

Docs: http://www.php.net/manual/en/language.namespaces.php

This is a wonderful way to have a common set of classes to use within your apps. OOP knowledge is a must, for that i can't guide you much, there are hundreds of wonderful tutorials online.