Inputing other PHP in themes.php Inputing other PHP in themes.php
 

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

Inputing other PHP in themes.php

Started by Disc13, March 11, 2004, 10:00:17 AM

Previous topic - Next topic

0 Members and 3 Guests are viewing this topic.

Disc13

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)

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!

Casper

Please post the code around line 779 of your theme.php, with that line noted.
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

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-

Maarten_Holland

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

hyperion

$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.
"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

(https://coppermine-gallery.com/forum/proxy.php?request=http%3A%2F%2Fwww.mozilla.org%2Fproducts%2Ffirefox%2Fbuttons%2Fgetfirefox_small.png&hash=9f6d645801cbc882a52f0ee76cfeda02625fc537)

Disc13

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!

JJ

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-

hyperion

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

(https://coppermine-gallery.com/forum/proxy.php?request=http%3A%2F%2Fwww.mozilla.org%2Fproducts%2Ffirefox%2Fbuttons%2Fgetfirefox_small.png&hash=9f6d645801cbc882a52f0ee76cfeda02625fc537)

nukeworker

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

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

Quote from: hyperion on March 15, 2004, 04:58:55 AM
$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:

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

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

Joachim Müller

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

Rednarb

Quote from: GauGau 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

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:
<!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:
<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.


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

Nibbler

include('/include/header.html'); should probably be include('include/header.html');