Jump to content

global scope help


ballhogjoni

Recommended Posts

I am defining a url using the define(). I have this in my sys_config.php file. I include the sys_config.php file into my index.php file and then I am trying to require_once() the defined url into my config.php file from the sys_config.php file, but its not working. I assume this is becuase of the scope of the defined url. Can someone guide me in the right direction, maybe help out with some global explanation here. I have searched all over google and php.net.

 

code of sys_config.php:

<?php
# Filename: sys_config.php 

# the exact path is defined. 
$fixpath = dirname(__FILE__); 

define ("BASE_DIR", "http://localhost/www/secure/");
define ("OFFER_CONFIG_DIR", "http://localhost/www/secure/templates/offers/");
define ("SMARTY_DIR", "C:/xampp/htdocs/www/Smarty/libs/"); 

/*$GLOBALS['site_variables']['OFFER_CONFIG_DIR'] = "http://localhost/www/secure/templates/offers/";*/
require_once (SMARTY_DIR."Smarty.class.php"); 
?>

 

index.php file:

<?php
# filedir: secure/index.php
if (!$_SERVER['HTTP_REFERER']) {
	header('location:xxxxx.com');
} else {
	session_start();
	$referer = $_SERVER['HTTP_REFERER'];
	$urlparsed = parse_url($referer);
	extract($urlparsed);
	$newquery = strstr($query, "&c=");
	$offerCode = substr($newquery,3,4);
	//echo $offerCode;
	require_once("sys_config.php");
	$smarty = new Smarty;

	//$smarty->compile_check = true;
	//$smarty->debugging = true;
	if ($offerCode == '3583') {
		header("location:xxxxxxxxxx.com"); 
	} elseif ($offerCode == '') {
		require_once(OFFER_CONFIG_DIR."eBay/config.php");
		$smarty->assign("IMG_DIR", IMG_DIR);
		$smarty->assign ("eBayThreeFieldForm", $eBayThreeFieldForm);
		$smarty->display ("offers/eBay/page.tpl");
	} elseif ($offerCode == '4058') {
		header('location:xxxxxxxxxx.com');
	} else {
		echo 'There has been an error';
	}
}
?>

 

config.php file that I am including it in:

<?php
define ("IMG_DIR", OFFER_CONFIG_DIR."eBay/");
echo IMG_DIR;
?>

 

My output for the above file is: OFFER_CONFIG_DIReBay/ 

Link to comment
https://forums.phpfreaks.com/topic/106119-global-scope-help/
Share on other sites

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.