Advanced search  

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]

Pages: [1]   Go Down

Author Topic: Inputing other PHP in themes.php  (Read 8464 times)

0 Members and 1 Guest are viewing this topic.

Disc13

  • Coppermine newbie
  • Offline Offline
  • Posts: 7
Inputing other PHP in themes.php
« on: March 11, 2004, 10:00:17 am »

Hi, I'm trying to input two PHP includes into the theme.html thing. I've followed the FAQ thing, my code looking like this (only have one php inclues on here)

Code: [Select]
function pageheader($section, $meta = '')
{
   global $CONFIG, $THEME_DIR;
   global $template_header, $lang_charset, $lang_text_dir;

   if(empty($custom_header)){
      include('http://www.myurl.com/randomimage.php');
      static $custom_header = ob_get_contents();
      ob_clean();
   }

   header('P3P: CP="CAO DSP COR CURa ADMa DEVa OUR IND PHY ONL UNI COM NAV INT DEM PRE"');
   user_save_profile();

   $template_vars = array(
      '{LANG_DIR}' => $lang_text_dir,
      '{TITLE}' => $CONFIG['gallery_name'].' - '.$section,
      '{CHARSET}' => $CONFIG['charset'] == 'language file' ? $lang_charset : $CONFIG['charset'],
      '{META}' => $meta,
      '{GAL_NAME}' => $CONFIG['gallery_name'],
      '{GAL_DESCRIPTION}' => $CONFIG['gallery_description'],
      '{MAIN_MENU}' => theme_main_menu(),
      '{ADMIN_MENU}' => theme_admin_mode_menu(),
      '{CUSTOM_HEADER}' => $custom_header,
   );

   echo template_eval($template_header, $template_vars);


but I get this error when I try to load the index.php:

Parse error: parse error, unexpected '(', expecting ',' or ';' in /usr/local/psa/home/vhosts/funkymoron.net/httpdocs/gallery/themes/default/theme.php on line 779

Fatal error: Call to undefined function: theme_display_album_list_cat() in /usr/local/psa/home/vhosts/funkymoron.net/httpdocs/gallery/index.php on line 493

Thanks much in advance for any help!
Logged

Casper

  • VIP
  • Coppermine addict
  • ***
  • Country: 00
  • Offline Offline
  • Gender: Male
  • Posts: 5231
Inputing other PHP in themes.php
« Reply #1 on: March 11, 2004, 11:19:00 am »

Please post the code around line 779 of your theme.php, with that line noted.
Logged
It has been a long time now since I did my little bit here, and have done no coding or any other such stuff since. I'm back to being a noob here

JJ

  • Coppermine newbie
  • Offline Offline
  • Posts: 3
Re: Inputing other PHP in themes.php
« Reply #2 on: March 11, 2004, 12:15:56 pm »

Quote from: "Disc13"


Parse error: parse error, unexpected '(', expecting ',' or ';' in /usr/local/psa/home/vhosts/funkymoron.net/httpdocs/gallery/themes/default/theme.php on line 779



I had the same... I have only poor knowledge of php (so I have no clue what other possible unwanted causes my modification might have) but I found 2 fixes for this...

Change this line
      static $custom_header = ob_get_contents();

To either
     $custom_header = ob_get_contents();
or this
      static $custom_header = ob_get_contents;

Everything seems to be working fine?!?!?  (Someone with knowledge might want to explain what I just did?)

Only trouble I have with inputing other php:s currently is that they have dublicate variable definitions, so I don't have it fully working (yet, if ever).

-J-
Logged

Maarten_Holland

  • Coppermine newbie
  • Offline Offline
  • Posts: 1
Inputing other PHP in themes.php
« Reply #3 on: March 14, 2004, 09:03:12 pm »

First of all: My compliments to the creators and supporters of CPG. I've downloaded it earlier this week and am *VERY* impressed!

I've suffered the same error as described in this post and solved it by removing the word 'static' from line 779 in index.php (thanks JJ).

Unfortunately I've got little to no knowledge of PHP and Coppermine, so I'm wondering what's causing this error and if I can expect problems by using this method.

Thank you for any explanation,

Maarten
Logged

hyperion

  • VIP
  • Coppermine addict
  • ***
  • Offline Offline
  • Posts: 1317
  • - retired -
Inputing other PHP in themes.php
« Reply #4 on: March 15, 2004, 04:58:55 am »

Code: [Select]
$custom_header = ob_get_contents();

would be best. You will take a slight performance hit as PHP will require a little more processing time when a page is processed.  

Only server experimentation will tell you how much of an effect this change has on Coppermine's performance in your environment.
Logged
"Then, Fletch," that bright creature said to him, and the voice was very kind, "let's begin with level flight . . . ."

-Richard Bach, Jonathan Livingston Seagull

(http://www.mozilla.org/products/firefox/buttons/getfirefox_small.png)

Disc13

  • Coppermine newbie
  • Offline Offline
  • Posts: 7
Inputing other PHP in themes.php
« Reply #5 on: March 15, 2004, 08:38:58 pm »

thanks a bunch! your fix worked.

did you ever figure out how to add more that one php includes though? (or does anyone know?) again, thanks in advance for any help!
Logged

JJ

  • Coppermine newbie
  • Offline Offline
  • Posts: 3
Inputing other PHP in themes.php
« Reply #6 on: March 15, 2004, 10:38:33 pm »

Quote from: "Disc13"
did you ever figure out how to add more that one php includes though? (or does anyone know?) again, thanks in advance for any help!


Who me? I never actually tried to do that... but I would guess you would just need to "introduce" another header (function pageheader2(...)  etc) or do the extra include in that php you already included as your header.

So how's your include workin?
Mine ain't... I'm trying (or maybe I should already say I was trying, since I managed to get the same looks & feel with another solution) to include the pageheader from my phpBB/EZPortal to this coppermine to make them integrate perfectly. So as I said, i got the looks & feel already, but now as it ain't the actual pageheader, future updates will be pain in the ass. If you want to take a look how my work looks like, feel free http://www.naturalsoundkillers.com (Some minor fixing & cosmetic improvement still going on... and one other interesting coppermine feature integration testing also)

-J-
Logged

hyperion

  • VIP
  • Coppermine addict
  • ***
  • Offline Offline
  • Posts: 1317
  • - retired -
Inputing other PHP in themes.php
« Reply #7 on: March 16, 2004, 01:12:50 am »

To explain how this works:

Essentially, the script calls the custom php file.  The file executes and dumps it's output into the buffer.  The output is extracted from the buffer and stored in $custom_header. Then the output is removed from the buffer so that CPG can send it's output.  The template engine then adds the HTML stored in $custom_header where appropriate in the template.

The method for adding two custom files depends on what the output of each will look like.
Logged
"Then, Fletch," that bright creature said to him, and the voice was very kind, "let's begin with level flight . . . ."

-Richard Bach, Jonathan Livingston Seagull

(http://www.mozilla.org/products/firefox/buttons/getfirefox_small.png)

nukeworker

  • Coppermine regular visitor
  • **
  • Offline Offline
  • Gender: Male
  • Posts: 83
  • Visit NukeWorker.com
    • Nuclear Jobs
Re: Inputing other PHP in themes.php
« Reply #8 on: June 30, 2004, 01:26:59 am »

I got multiple php ssi functions to work with the following code:

Code: [Select]
function pageheader($section, $meta = '')
{
    global $CONFIG, $THEME_DIR;
    global $template_header, $lang_charset, $lang_text_dir;

   if(empty($smf_logonline)){
      include('http://www.nukeworker.com/forum/SSI.php?ssi_function=logOnline');
      $smf_logonline = ob_get_contents();
      ob_clean();
   }

   if(empty($smf_boardstats)){
      include('http://www.nukeworker.com/forum/SSI.php?ssi_function=boardStats');
      $smf_boardstats = ob_get_contents();
      ob_clean();
   }
   if(empty($cpg_statistics)){
      include('http://www.nukeworker.com/pictures/statistics_ssi.php');
      $cpg_statistics = ob_get_contents();
      ob_clean();
   }
   if(empty($smf_latestmember)){
      include('http://www.nukeworker.com/forum/SSI.php?ssi_function=latestMember');
      $smf_latestmember = ob_get_contents();
      ob_clean();
   }

    header('P3P: CP="CAO DSP COR CURa ADMa DEVa OUR IND PHY ONL UNI COM NAV INT DEM PRE"');
    user_save_profile();

    $template_vars = array('{LANG_DIR}' => $lang_text_dir,
        '{TITLE}' => $CONFIG['gallery_name'] . ' - ' . $section,
        '{CHARSET}' => $CONFIG['charset'] == 'language file' ? $lang_charset : $CONFIG['charset'],
        '{META}' => $meta,
        '{GAL_NAME}' => $CONFIG['gallery_name'],
        '{GAL_DESCRIPTION}' => $CONFIG['gallery_description'],
        '{MAIN_MENU}' => theme_main_menu(),
        '{ADMIN_MENU}' => theme_admin_mode_menu(),
'{smf_logonline}' => $smf_logonline,
'{smf_boardstats}' => $smf_boardstats,
'{cpg_statistics}' => $cpg_statistics,
'{smf_latestmember}' => $smf_latestmember,
        );

    echo template_eval($template_header, $template_vars);
}

Rednarb

  • Coppermine newbie
  • Offline Offline
  • Gender: Male
  • Posts: 4
    • Rednarb Photography
Re: Inputing other PHP in themes.php
« Reply #9 on: October 12, 2004, 08:46:50 pm »

Code: [Select]
$custom_header = ob_get_contents();
would be best. You will take a slight performance hit as PHP will require a little more processing time when a page is processed.  

Only server experimentation will tell you how much of an effect this change has on Coppermine's performance in your environment.

After making this adjustment, I get the following errors:

Code: [Select]
Warning: pageheader(): open_basedir restriction in effect. File(/include/header.html) is not within the allowed path(s): (/home/rednarb/:/usr/lib/php:/usr/local/lib/php:/tmp) in /home/rednarb/public_html/jammers/cpg/themes/Jammers/theme.php on line 809

Warning: pageheader(/include/header.html): failed to open stream: Operation not permitted in /home/rednarb/public_html/jammers/cpg/themes/Jammers/theme.php on line 809

HTML:
Code: [Select]
               <table width="100%" border="0" cellspacing="0" cellpadding="0">
                       <tr><td align="center">{CUSTOM_HEADER}</td></tr>
                       <tr><td align="center">{MAIN_MENU}</td></tr>
                </table>

theme.php pageheader function:

Code: [Select]
function pageheader($section, $meta = '')
{
    global $CONFIG, $THEME_DIR;
    global $template_header, $lang_charset, $lang_text_dir;

    if(empty($custom_header)){
       include('/include/header.html');
       $custom_header = ob_get_contents();
       ob_clean();
    }

    header('P3P: CP="CAO DSP COR CURa ADMa DEVa OUR IND PHY ONL UNI COM NAV INT DEM PRE"');
    user_save_profile();

    $template_vars = array(
   '{LANG_DIR}' => $lang_text_dir,
        '{TITLE}' => $CONFIG['gallery_name'] . ' - ' . $section,
        '{CHARSET}' => $CONFIG['charset'] == 'language file' ? $lang_charset : $CONFIG['charset'],
        '{META}' => $meta,
        '{GAL_NAME}' => $CONFIG['gallery_name'],
        '{GAL_DESCRIPTION}' => $CONFIG['gallery_description'],
        '{MAIN_MENU}' => theme_main_menu(),
        '{ADMIN_MENU}' => theme_admin_mode_menu(),
     '{CUSTOM_HEADER}' => $custom_header,
     );

    echo template_eval($template_header, $template_vars);
}


http://jammers.rednarb.com/cpg

I've searched the forum for this error and found many references to open_basedir but none seem to apply. Any pointers would be sincerely appreciated!

aTdHvAaNnKcSe!

Eric
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: Inputing other PHP in themes.php
« Reply #10 on: October 13, 2004, 12:15:46 am »

your ouput starts too early, this is a very common php error. Make sure there's no output before the header has been sent (no linebreaks or spaces either).

Joachim
Logged

Rednarb

  • Coppermine newbie
  • Offline Offline
  • Gender: Male
  • Posts: 4
    • Rednarb Photography
Re: Inputing other PHP in themes.php
« Reply #11 on: October 13, 2004, 07:31:17 pm »

your ouput starts too early, this is a very common php error. Make sure there's no output before the header has been sent (no linebreaks or spaces either).

Joachim

You've lost me. When you say "header" do you mean my included header? I've seen other issues with configs and php's having additional line breaks and I don't think this is related. Here is my template.html in its entirety:
Code: [Select]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html dir="{LANG_DIR}">
<head>
<title>{TITLE}</title>
<meta http-equiv="Content-Type" content="text/html; charset={CHARSET}" />
<meta http-equiv="Pragma" content="no-cache" />
{META}
<link rel="stylesheet" href="themes/Jammers/style.css" />
<script type="text/javascript" src="scripts.js"></script>
<!--
$Id: template.html,v 1.1 2004/06/11 09:20:08 tarique Exp $
-->
</head>
<body>
<table width="100%" height="100%" border="0" cellpadding="20" cellspacing="20" bgcolor="#808080">
 <tr><td valign="top" bordercolor="#666666" bgcolor="#FFFFFF" style="border: 1px solid;">
 <table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr><td align="center">{CUSTOM_HEADER}</td></tr>
  <tr><td align="center">{MAIN_MENU}</td></tr>
 </table>
 <table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr><td align="center" valign="top">{LANGUAGE_SELECT_FLAGS}</td></tr>
  <tr><td align="center" valign="top">{LANGUAGE_SELECT_LIST} {THEME_SELECT_LIST}</td></tr>
 </table>
 <img src="images/spacer.gif" width="1" height="15" /><br />
 <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr><td align="center" valign="top">{ADMIN_MENU} {GALLERY}</td></tr>
 </table>
</td></tr>
</table>
</body>
</html>

Here is my header.html:
Code: [Select]
<table class="header" border="0">
<tr height="140px"><td></td></tr>
<tr><td>
<div id="navcontainer">
<ul id="navlist">
<li><a href="/" title="News">News</a></li>
<li><a href="/info.php" title="Team Information">Team Info</a></li>
<li><a href="/cs/calendar.pl" title="Team Calendar">Calendar</a></li>
<li><a href="/cpg/" title="Team Photo Gallery">Gallery</a></li>
</ul>
</div>
</tr>
</table>

All I want to do is include my header in to the CPG header, without having to copy the HTML in to the template.html. With my other php pages I just do an Include statement but as we all know it doesn't work with CPG so I'm trying this hack.  But when I make the mods stated on this thread, mods that seem to work for everyone else, they give me those errors.

Code: [Select]
Warning: pageheader(): open_basedir restriction in effect. File(/include/header.html) is not within the allowed path(s): (/home/rednarb/:/usr/lib/php:/usr/local/lib/php:/tmp) in /home/rednarb/public_html/jammers/cpg/themes/Jammers/theme.php on line 809

Warning: pageheader(/include/header.html): failed to open stream: Operation not permitted in /home/rednarb/public_html/jammers/cpg/themes/Jammers/theme.php on line 809

Warning: pageheader(): Failed opening '/include/header.html' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/rednarb/public_html/jammers/cpg/themes/Jammers/theme.php on line 809

Line 809 is the include statement in the following portion of theme.php:
Code: [Select]
function pageheader($section, $meta = '')
{
    global $CONFIG, $THEME_DIR;
    global $template_header, $lang_charset, $lang_text_dir;

    if(empty($custom_header)){
       include('/include/header.html');
       $custom_header = ob_get_contents();
       ob_clean();
    }

    header('P3P: CP="CAO DSP COR CURa ADMa DEVa OUR IND PHY ONL UNI COM NAV INT DEM PRE"');
    user_save_profile();

    $template_vars = array(
    '{LANG_DIR}' => $lang_text_dir,
        '{TITLE}' => $CONFIG['gallery_name'] . ' - ' . $section,
        '{CHARSET}' => $CONFIG['charset'] == 'language file' ? $lang_charset : $CONFIG['charset'],
        '{META}' => $meta,
        '{GAL_NAME}' => $CONFIG['gallery_name'],
        '{GAL_DESCRIPTION}' => $CONFIG['gallery_description'],
        '{MAIN_MENU}' => theme_main_menu(),
        '{ADMIN_MENU}' => theme_admin_mode_menu(),
      '{CUSTOM_HEADER}' => $custom_header,
     );

    echo template_eval($template_header, $template_vars);
}


Thank you,

Eric
Logged

Nibbler

  • Guest
Re: Inputing other PHP in themes.php
« Reply #12 on: October 13, 2004, 07:47:13 pm »

Code: [Select]
include('/include/header.html'); should probably be
Code: [Select]
include('include/header.html');
Logged
Pages: [1]   Go Up
 

Page created in 0.026 seconds with 19 queries.