I am working on this PHP site. I downloaded it from their FTP and worked on it on MAMP locally. All worked fine because I was able to set the root directory inside MAMP.
Now I need to put this site online on my server for client approval. My server is a shared hosting server where you upload the sites to a directory like “/home/public_html/username/_beta/company”.
All of the includes and PHP file references break because it goes back to the home directory.
Here are the first few lines in index.php that error first:
<?php
require_once($_SERVER['DOCUMENT_ROOT'] . '/lib/includes/init.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
I get this error:
Warning: require_once(/home/gailco/public_html/lib/includes/init.php) [function.require-once]: failed to open stream: No such file or directory in /home/gailco/public_html/_beta/insidesign/index.php on line 2
Fatal error: require_once() [function.require]: Failed opening required ‘/home/gailco/public_html/lib/includes/init.php’ (include_path=‘.:/usr/lib/php:/usr/local/lib/php’) in /home/gailco/public_html/_beta/insidesign/index.php on line 2
Is there a way I can temporarily tell the site I moved to “/public_html/_beta/company/index.php” to treat this as the root directory so all includes such as “<?php
require_once($_SERVER[‘DOCUMENT_ROOT’] . ‘/lib/includes/init.php’);
?>” will work?
Please help! I googled around and I can’t understand. I am a beginner with PHP so I need it explained where to put the code etc.
Thanks!
This is the init.php file. Is there something I can do in here?
<?php
// Report all PHP errors (bitwise 63 may be used in PHP 3)
//error_reporting(E_ALL);
//initialization file for xxxxxxxxxxx.COM
define('DOCROOT', $_SERVER['DOCUMENT_ROOT']);
define('REMOTEADDR', $_SERVER['REMOTE_ADDR']);
define('URLTYPE', ($_SERVER['SERVER_PORT'] == 443 ? 'https://' : 'http://'));
define('SERVERNAME', $_SERVER['SERVER_NAME']);
// Make PHP automatically load class files from the main classes directory
function __autoload($className) {
require_once($_SERVER['DOCUMENT_ROOT'] . '/lib/classes/' . $className . '.class.php');
}
require_once($_SERVER['DOCUMENT_ROOT'] . '/lib/includes/globals.inc.php');
if (IS_LIVE) ini_set("include_path", ".:../:./lib/includes/PEAR:../lib/includes/PEAR:../../lib/includes/PEAR");
session_start();
if (empty($_SESSION['Session'])) {
$_SESSION['Session'] = new Session();
}
$tmpArr = explode("/",$_SERVER['SCRIPT_NAME']);
define('SCRIPT_NAME',$tmpArr[sizeof($tmpArr)-1]);
foreach ($tmpArr as $x) { if (!empty($x)) break; }
define('SITE_SECTION', $x);
define('SITE_SUBSECTION',$tmpArr[2]);
define('SKIN_PATH', "/lib/skins/".CURRENT_SKIN);
define('DATEFORMAT','Y-m-d');
$site = new Site();
if (SITE_SECTION == 'admin' && SCRIPT_NAME != 'login.php') $site->requireAdminLogin();
?>
P.S. I also see lines in the code for includes like “<? $site->showHeader(); ?>”. Does this look familiar? Is this site built in some kind of CMS or framework I need to know of?