PHP not functioning fully in Custom Header PHP not functioning fully in Custom Header
 

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Main Menu

PHP not functioning fully in Custom Header

Started by idosha, August 23, 2018, 04:26:11 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

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

#1
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

<?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 ?>