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: Includes in custom pageheader()  (Read 3961 times)

0 Members and 1 Guest are viewing this topic.

Michi

  • Coppermine newbie
  • Offline Offline
  • Posts: 3
Includes in custom pageheader()
« on: March 13, 2005, 08:42:38 pm »

Hey.

This is what my pageheader-function looks like now:

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

   // this is the place where the custom header file gets included

      ob_start();
      include('/home/docs/php/templates/layout.php');
      beginBody();
      $beginBody = ob_get_contents();
      ob_end_clean();

      ob_start();
      beginPage();
      $beginPage = ob_get_contents();
      ob_end_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(),
        '{BEGIN_PAGE}' => $beginPage,
        '{BEGIN_BODY}' => $beginBody,
        );

    echo template_eval($template_header, $template_vars);
}
The layout.php -file I'm including checks what style template file the page is supposed to use. The template file consists of functions, eg beginBody(), that consist of the template HTML-stuff I'm trying to wrap the Coppermine galleries with.

Problem is that when I try to print out certain stuff, for example the username, the $username variable that is declared in the beginning of the template file, isn't available in the beginBody-function.


Code: [Select]
$userid = $_REQUEST['bbuserid']; //THIS IS SET IN A COOKIE

It works fine in vBulletin, so I've figured it has something to do with CPG... I have CPG 1.2.0 installed. Does Coppermine somehow "separate" the functions from the original file and therefore loses the variables along the way...?
Logged

kegobeer

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 4637
  • Beer - it does a body good!
    • The Kazebeer Family Website
Re: Includes in custom pageheader()
« Reply #1 on: March 13, 2005, 11:06:55 pm »

Any variables you want available inside of a function need to be declared in a GLOBAL statement.  Coppermine doesn't use $username, your username is set in the constant USER_NAME, which doesn't need to be declared in a global statement.  You can see this variable used in the theme.php file.
Logged
Do not send me a private message unless I ask for one.  Make your post public so everyone can benefit.

There are no stupid questions
But there are a LOT of inquisitive idiots

Michi

  • Coppermine newbie
  • Offline Offline
  • Posts: 3
Re: Includes in custom pageheader()
« Reply #2 on: March 14, 2005, 03:13:22 pm »

in the function endPage() I'm trying to call variable $userid, which is defined in the very beginning of the template file.

Code: [Select]
$userid = $_COOKIE['bbuserid'];
After that, I have
Code: [Select]
GLOBAL $userid
But in the endPage() a "echo $userid;" -code prints out nothing.

As I use the same templates with vBulletin and news publishing, I really wouldn't want to start inserting CPG variables to the templates...
Logged
Pages: [1]   Go Up
 

Page created in 0.019 seconds with 19 queries.