Advanced search  

News:

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

Pages: [1]   Go Down

Author Topic: PHP not functioning fully in Custom Header  (Read 945 times)

0 Members and 1 Guest are viewing this topic.

idosha

  • Coppermine newbie
  • Offline Offline
  • Posts: 9
PHP not functioning fully in Custom Header
« on: August 23, 2018, 04:26:11 pm »

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.
Logged

ron4mac

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: us
  • Offline Offline
  • Posts: 1000
Re: PHP not functioning fully in Custom Header
« Reply #1 on: August 23, 2018, 05:30:18 pm »

You will need to use the $superCage object provided by the Inspekt mechanism.
http://documentation.coppermine-gallery.net/en/dev_superglobals.htm
« Last Edit: August 23, 2018, 05:39:04 pm by ron4mac »
Logged

idosha

  • Coppermine newbie
  • Offline Offline
  • Posts: 9
Re: PHP not functioning fully in Custom Header
« Reply #2 on: August 29, 2018, 01:15:31 am »

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

Logged

ron4mac

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: us
  • Offline Offline
  • Posts: 1000
Re: PHP not functioning fully in Custom Header
« Reply #3 on: August 29, 2018, 05:32:01 pm »

Code: [Select]
<?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 ?>
Logged
Pages: [1]   Go Up
 

Page created in 0.016 seconds with 20 queries.