Welcome to Geeklog, Anonymous Tuesday, April 23 2024 @ 02:48 pm EDT

Geeklog Forums

Page header error


Ron

Anonymous
I'm trying to install ThinkBling's Google Adsens revenue sharing mod, which I had no problems installing on a regular phpbb. When I try to install it with phpBBBridge, I get this error:

Text Formatted Code
Fatal error: Call to undefined function: com_siteheader() in /home2/revenue/public_html/forum/includes/page_header.php on line 418
 


The snippet I'm trying to install in page_header is this:

Text Formatted Code
$PageName = substr($_SERVER[PATH_INFO], strlen($_SERVER[PATH_INFO]) - 13);

  //Set the default ad info.
  $shared_ad_client_id = $board_config['ad_client_id'];
  $shared_ad_channel = $board_config['ad_channel'];  

  //If the page is "viewtopic.php" AND if the ad is enabled, or if the 50% random
  // counter is true, proceed with checking if the user has enough posts.
  if ($PageName == "viewtopic.php" &&
      $board_config['ad_enabled'] == "1" &&
      rand(0, 1) == 1)
  {
    global $FirstPoster;
    if (!isset($FirstPoster))
    {
      $FirstPoster = 0;
    }
       
    $sql = "SELECT * ".
           "FROM phpbb_users ".
           "WHERE user_id = $FirstPoster";

    if ( !($result = $db->sql_query($sql)) )
    {
      echo($sql);
          }
    $user_row = $db->sql_fetchrow($result);
       
    if ($user_row['user_posts'] > $board_config['ad_min_posts'])
    {
      $user_id = intval($HTTP_POST_VARS['id']);
     
      //Get the previous settings if they exist.
      $sql = "SELECT * ".
             "FROM phpbb_ad_user ".
             "WHERE user_id = $user_id";
                                                         
      if (!($shared_result = $db->sql_query($sql)))
            {
        echo($sql);
            }
      $shared_ad_row = $db->sql_fetchrow($shared_result);
      $shared_ad_client_id = $shared_ad_row['ad_client_id'];
      $shared_ad_channel   = $shared_ad_row['ad_channel'];
                }
  }
       
        if (strlen(trim($shared_ad_client_id)) < 15)
        {
                $shared_ad_client_id = $board_config['ad_client_id'];
        }

$adsense =
"<script type="text/javascript"><!--n".
"google_ad_client = "" . $shared_ad_client_id . "";n".
"google_ad_width = 468;n".
"google_ad_height = 60;n".
"google_ad_format = "468x60_as";n".
"google_ad_channel ="" . $shared_ad_channel . "";n".
"google_ad_type = "text_image";n".
"//--></script>n".
"<script type="text/javascript"n".
"  src="http://pagead2.googlesyndication.com/pagead/show_ads.js">n".
"</script>";
 


Now, according to the error message, the error is somwhere in here:

Text Formatted Code
// Added by Turias
global $_PHPBBB_CONF;
$geeklog_site_header = '';
if ($_PHPBBB_CONF['show_left_blocks'])
{
        $geeklog_site_header = COM_siteHeader();
}
else
{
        $geeklog_site_header = COM_siteHeader('none');
}
 


Is there a workaround I can use to solve this?
 Quote

Status: offline

Turias

Forum User
Full Member
Registered: 10/20/03
Posts: 807
I'm confused. Are you trying to add tempalte variables to page_header to place in your overall_header?

The idea behind that message is that every time page_header.php is run, it needs to have already loaded Geeklog's lib-common.php file. Here, it has not, which is why it doesn't know about COM_siteHeader.

The next version of phpBBBridge will make the lib-common including more natural. For now, you may need to include it manually in your new php code.

See the phpBB index.php file to see how I am including the lib-common file when necessary.
 Quote

How could I do this?

Anonymous
I've included it in the forum itself. but for the member to add their google adsend ID, they do it in the members profile page. WHen the button is clicked, the page error comes up from the page_header. If you go to profile here, with User: demo password: demo, you can see what's going on. I don't know if I could put it elsewhere and still have it work. It's just that few lines in the page_header that's causing it.

Below is what needs to be added to page_header to make this script work:
Text Formatted Code
#
#-----[ FIND ]------------------------------------------
#
while( list($nav_item, $nav_array) = @each($nav_links) )
{
        if ( !empty($nav_array['url']) )
        {
                $nav_links_html .= sprintf($nav_link_proto, $nav_item, append_sid($nav_array['url']), $nav_array['title']);
        }
        else
        {
                // We have a nested array, used for items like <link rel='chapter'> that can occur more than once.
                while( list(,$nested_array) = each($nav_array) )
                {
                        $nav_links_html .= sprintf($nav_link_proto, $nav_item, $nested_array['url'], $nested_array['title']);
                }
        }
}

#
#-----[ AFTER, ADD ]------------------------------------------
#
  $PageName = substr($_SERVER[PATH_INFO], strlen($_SERVER[PATH_INFO]) - 13);

  //Set the default ad info.
  $shared_ad_client_id = $board_config['ad_client_id'];
  $shared_ad_channel = $board_config['ad_channel'];  

  //If the page is "viewtopic.php" AND if the ad is enabled, or if the 50% random
  // counter is true, proceed with checking if the user has enough posts.
  if ($PageName == "viewtopic.php" &&
      $board_config['ad_enabled'] == "1" &&
      rand(0, 1) == 1)
  {
    global $FirstPoster;
    if (!isset($FirstPoster))
    {
      $FirstPoster = 0;
    }
       
    $sql = "SELECT * ".
           "FROM phpbb_users ".
           "WHERE user_id = $FirstPoster";

    if ( !($result = $db->sql_query($sql)) )
    {
      echo($sql);
          }
    $user_row = $db->sql_fetchrow($result);
       
    if ($user_row['user_posts'] > $board_config['ad_min_posts'])
    {
      $user_id = intval($HTTP_POST_VARS['id']);
     
      //Get the previous settings if they exist.
      $sql = "SELECT * ".
             "FROM phpbb_ad_user ".
             "WHERE user_id = $user_id";
                                                         
      if (!($shared_result = $db->sql_query($sql)))
            {
        echo($sql);
            }
      $shared_ad_row = $db->sql_fetchrow($shared_result);
      $shared_ad_client_id = $shared_ad_row['ad_client_id'];
      $shared_ad_channel   = $shared_ad_row['ad_channel'];
                }
  }
       
        if (strlen(trim($shared_ad_client_id)) < 15)
        {
                $shared_ad_client_id = $board_config['ad_client_id'];
        }

$adsense =
"<script type="text/javascript"><!--n".
"google_ad_client = "" . $shared_ad_client_id . "";n".
"google_ad_width = 468;n".
"google_ad_height = 60;n".
"google_ad_format = "468x60_as";n".
"google_ad_channel ="" . $shared_ad_channel . "";n".
"google_ad_type = "text_image";n".
"//--></script>n".
"<script type="text/javascript"n".
"  src="http://pagead2.googlesyndication.com/pagead/show_ads.js">n".
"</script>";

#
#-----[ FIND ]------------------------------------------
#
// The following assigns all _common_ variables that may be used at any point
// in a template.
//
$template->assign_vars(array(

#
#-----[ AFTER, ADD ]------------------------------------------
#
  'ADSENSE' =>  $adsense,

#
#-----[ FIND ]------------------------------------------
#
        'U_INDEX' => append_sid('index.'.$phpEx),

#
#-----[ REPLACE WITH ]------------------------------------------
#
        'U_INDEX' => append_sid('../index.'.$phpEx),

#

 
 Quote

Status: offline

Turias

Forum User
Full Member
Registered: 10/20/03
Posts: 807
You're loading a new page, ad_profile.php. From that page, you need to include the lib-common.php file. See index.php, viewtopic.php, viewforum.php, etc to see how I do that.
 Quote

Cool

Anonymous
Great, it worked, THANKS!
 Quote

All times are EDT. The time is now 02:48 pm.

  • Normal Topic
  • Sticky Topic
  • Locked Topic
  • New Post
  • Sticky Topic W/ New Post
  • Locked Topic W/ New Post
  •  View Anonymous Posts
  •  Able to post
  •  Filtered HTML Allowed
  •  Censored Content