Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Modifying osC - variables, defines and scope ?


peterr

Recommended Posts

Posted

Hi,

 

We have three domains sitting on the one website, and need to change various 'content' of the site, depending upon the domain name that is visited. We are using osCommerce, and the PHP include code that is working okay is:

 

/domain_check.php

 

<?

ini_set('display_errors', 0);  //set this to zero when in production

// If user comes to site with preceeding string "www." , remove it, not required
$httphostname = $_SERVER['HTTP_HOST'];
$hostname = str_replace("www.", "", $httphostname);

$titles = array(
  'domain1.com.au' => 'Company Name #1',
  'domain2.com.au' => 'Company Name #2',
  'domain3.com.au' => 'Company Name #3'
  );

if (isset($titles[$hostname])) $title = $titles[$hostname];
  else $title = 'Unknown site';

$title_uppercase = strtoUpper($title);

?>

 

Testing has shown it is modifying page titles and email addresses okay. Now I need to use the include in the actual product, and change a lot more.

 

* Page Title

* Email from Address and To address, not only in html o/p, but also when sending emails

* "Conditions of Use" details

* Logos

* Text on main page and other pages

* Some meta tag info (e.g. if 'domain1' add more keywords)

* Any other "My Store" data that would need the company name or domain name changed.

* Some product information has hard coded info, that needs changing

* Other ??

 

As you can see, there is quite a lot to change, and considering the test PHP code works, I would like to know:

 

1. What is the difference between:

 

$title = 'Company Name #1';

 

and ...

 

define('$title', 'Company Name #1');

 

2. Where should I put the include ? There is a PHP that is called 'application_top.php', and I _think_ it is used in every other PHP file, so if I place the include there, how will it affect scope of the variable ?

 

3. Should I force the variables to be global ?

 

4. Should they be re-evaluated each time, just to check that the user hasn't 'swapped domains' ?

 

5. If none of the 3 domains are true (from the include domain_check.php, then I would prefer to add some error code, and actually prevent the user from accessing the site. Something like:

 

- a nice friendly page displayed telling them the 'domain' they have attaepted to access is "not available"

- an email msg to me, or a row inserted in the MySQL db, to inform me of such access

 

This is to prevent people from trying to access the domains from other methods, like:

 

http://Ip.add.re.ss/~username/index.php

 

.. or

 

http://servername/~username/index.php

 

In summary, the 'test' include works, but I need some help please, in regards to the above requirements, especially ablout variable useage, defines and the scope of variables. (I have read a fair bit on php.net, but it hasn't helped me much to get my head around this stuff).

 

Thanks, :)

 

Peter

Archived

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

×
×
  • Create New...