Support > cpg1.5 miscellaneous

PHP not functioning fully in Custom Header

(1/1)

idosha:
I use the {CUSTOM_HEADER} to insert php into my themes. For some reason $_SERVER['SERVER_NAME‘] does not work properly to find out the URL of the page in my code yet all other php coding (I've tried) works properly using this method. The code works fine outside of coppermine.

Anyone have any ideas why? Or another way to get php code to run inside the theme. Basically I need to check the url against an array and display one of 2 pieces of code depending if it matches the array or not.

ron4mac:
You will need to use the $superCage object provided by the Inspekt mechanism.
http://documentation.coppermine-gallery.net/en/dev_superglobals.htm

idosha:
Yah I'm definitely not a coding expert so didn't have any luck with that.

Anyone able to help me out? I'd be willing to pay $10 for some assistance making my script work inside coppermine "custom header" - This is the simple script I need to get working.

<?php
$ffhdomains = array(
"domainname.com",
"domainname2.com",
);
//match the domain to the array
$currdomain = preg_replace('/^www./', '', $_SERVER['SERVER_NAME']); //requests current domain without www.
if (in_array($currdomain, $ffhdomains)) {
//if matched display code a
Code A
<?php } else {  //Put default adcode below here ?>
//if no match display code b
Code B
<?php } //end of default adcode - everything below loads on all sites ?>

ron4mac:

--- Code: ---<?php
$superCage = Inspekt::makeSuperCage();

$ffhdomains = array('domainname.com', 'domainname2.com');

//match the domain to the array
$currdomain = preg_replace('/^www./', '', $superCage->server->getraw('SERVER_NAME')); //requests current domain without www.

if (in_array($currdomain, $ffhdomains)): //if matched display code a
?>

Code A

<?php else:  //Put default adcode below here ?>

Code B

<?php endif; //end of default adcode - everything below loads on all sites ?>

--- End code ---

Navigation

[0] Message Index

Go to full version