php include not showing up php include not showing up
 

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Main Menu

php include not showing up

Started by blazer380, December 28, 2004, 05:45:01 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

blazer380

I have a PHP script that shows how many visitors are online at the moment and I am trying to use a php include function to have it in my theme.php file. The way I figured is I will put it is in a form of a button. When I put the include function, the button shows up, but the script doesnt. If I put the same include in the anycontent.php file, then it shows up. What am I doing wrong?

This is the code for the extra button with the include to show # of users online.

<!-- BEGIN Extra Button -->
                                        <td><img name="spacer" src="images/spacer.gif" width="5" height="25" border="0" id="spacer" alt="" /></td>
                                        <td><img name="buttonleft" src="themes/hardwired/images/buttonleft.gif" width="17" height="25" border="0" id="buttonleft" alt="" /></td>
                                        <td background="themes/hardwired/images/buttoncenter.gif">
                                                <? include"/home/scum002/public_html/virtualonline/virtualonline.php";?>
                                        </td>
                                        <td><img name="buttonright" src="themes/hardwired/images/buttonright.gif" width="7" height="25" border="0" id="buttonright" alt="" /></td>
<!-- END Extra Button -->


I have tried all of the following ways, but none of them show up.


<?php include"/home/scum002/public_html/virtualonline/virtualonline.php";?>



<? include"/home/scum002/public_html/virtualonline/virtualonline.php";?>



<? include ('http://www.s-c-u-m.com/virtualonline/virtualonline.php');?>

Joachim Müller

This has been asked quite often, search the board for "custom header".

Joachim

blazer380

well i found the code that i needed after searching, BUT it shows up in the top left of my gallery and not where I want it to. What is wrong with the code below? (my gallery can be seen at http://www.s-c-u-m.com/cell )


function pageheader($section, $meta = '')
{
    global $CONFIG, $THEME_DIR;
    global $template_header, $lang_charset, $lang_text_dir;
    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_MENU1}' => theme_main_menu1(),
        '{MAIN_MENU2}' => theme_main_menu2(),
        '{ADMIN_MENU}' => theme_admin_mode_menu(),
        '{USERS_ONLINE}' => include("http://www.s-c-u-m.com/virtualonline/virtualonline.php")
        );
    echo template_eval($template_header, $template_vars);
}

Joachim Müller

#3
When looking at http://www.s-c-u-m.com/cell/themes/hardwired/template.html I get <? $update = "$_POST[update]";
if ($update=="1") {
$name = "$_POST[name]";
$comment = "$_POST[comment]";
$Host = "localhost";
$User = "****";
$Password = "****";
$DBName = "***";
$Link = mysql_connect ($Host, $User, $Password);
$Query = "INSERT INTO `comments` ( `id` , `name` , `comment` )VALUES('', '$name', '$comment');";
$Result = mysql_db_query($DBName, $Query, $Link);
mysql_close($Link);
}

$Host2 = "localhost";
$User2 = "***";
$Password2 = "****";
$DBName2 = "****";
$Link2 = mysql_connect ($Host2, $User2, $Password2);
$Query2 = "SELECT * FROM `comments` ORDER BY 'id' DESC";
$Result2 = mysql_db_query($DBName2, $Query2, $Link2);

?>
at the very top of the page - you seem to have applied another mod that enables parsing of php directly in template.html - you mustn't. All that is suppossed to go into template.html (using the method suggested) is {USERS_ONLINE}. Take a look at http://forum.coppermine-gallery.net/index.php?topic=9863.msg44419#msg44419

Joachim

blazer380

that PHP code in top of template.html is for a javascript that I need. How would I incorporate that into theme.php?
As for {USERS_ONLINE} inside template.html, it shows only a "1", instead of "Users Online: 4". Not sure if that other PHP code is intefering with it. Is there any way someone can show me the code I need to put into theme.php and into template.html to make the UsersOnline php include work as well as the code php code for the javascript?

Thanx

Joachim Müller

like I said: do not enable php parsing for template.html - the mod is just silly.
If you need JavaScript, you should code JavaScript. If you need dynamic JavaScript, use the custom header technology outlined in the thread I refered to (yes, you can have two or more cutom headers).

Joachim

P.S. PHP start tags should be <?php, not <?

blazer380

Ok, so I should remove that PHP code from template.html and instead type in {CUSTOM_HEADER}
And in template.html also put {USERS_ONLINE} where I want it to show.

and in theme.php replace the pageheader with this?:
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
   if(empty($custom_header)){
      ob_start();
      include('menu_main.htm');
      $custom_header = cleanup_custom_includes(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(),
        '{USERS_ONLINE}' => include("http://www.s-c-u-m.com/virtualonline/virtualonline.php")
        '{CUSTOM_HEADER}' => <? $update = "$_POST[update]";
if ($update=="1") {
$name = "$_POST[name]";
$comment = "$_POST[comment]";
$Host = "localhost";
$User = "scum002_scum002x";
$Password = "seth123";
$DBName = "scum002_xmb1";
$Link = mysql_connect ($Host, $User, $Password);
$Query = "INSERT INTO `comments` ( `id` , `name` , `comment` )VALUES('', '$name', '$comment');";
$Result = mysql_db_query($DBName, $Query, $Link);
mysql_close($Link);
}

$Host2 = "localhost";
$User2 = "scum002_scum002x";
$Password2 = "seth123";
$DBName2 = "scum002_xmb1";
$Link2 = mysql_connect ($Host2, $User2, $Password2);
$Query2 = "SELECT * FROM `comments` ORDER BY 'id' DESC";
$Result2 = mysql_db_query($DBName2, $Query2, $Link2);

?>
,
        );

    echo template_eval($template_header, $template_vars);
}

Joachim Müller

no, of course not. Maybe you should read the whole thread I was refering to. The user asked how to include another php-enabled file 'menu_main.htm', and the code I gave him will just do that. You will have to edit the code I posted to fit your design. You can not just insert your custom php code anywhere - it has to go where (in the thread I refered to) the code include('menu_main.htm'); is, and you will of course have to define the placeholders (the stuff in curly braces) you introduce in template.html. Maybe you should add one at a time, to make this less complicated for you.

Joachim

blazer380

#8
ok.. as you can tell i have no idea what i am doing. i have attached the zip file that includes theme.php and template.html
you know where things are supposed to go........ can you please edit them for me? I know {CUSTOM_HEADER} will go on top of template.html
and {USERS_ONLINE} will go somewhere within template.html. As far as editing pageheader, I have no clue.....

Joachim Müller

I could tell you have no idea. Don't get me wrong, but imo you shouldn't do what you're trying to do, as you simply don't have the skills to accomplish it (yet). I have edited the files, but the custom footer won't do what you expect it to do - the code is just crap. I put some notes into the code, and I'll post the relevant bits here as well, so others might learn from it (although this is not a good example for what you can do with custom header functions).
I had to delete the attachment you made, as it contains your db password. You must never ever post your db details publicly; you're encouraged  to change it asap (or ask your webhost to do this for you) for security reasons.

This is the relevant part of theme.php: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
   if(empty($custom_header)){
      ob_start();
      // your custom footer's php code starts here.
      // Of course it's crap and won't work, that's why I commented it out.
      // To put it back into place, remove the slash_asterisk and asterisk_slash lines (910 and 931).
      // the code won't actually do anything except running a query (without using the queried data for anything particular).
      // You'll have to edit the password values as well, as I removed them for security reasons.
      /*
        $update = "$_POST['update']";
        if ($update=="1") {
            $name = "$_POST['name']";
            $comment = "$_POST['comment']";
            $Host = "localhost";
            $User = "scum002_scum002x";
            $Password = "***";
            $DBName = "scum002_xmb1";
            $Link = mysql_connect ($Host, $User, $Password);
            $Query = "INSERT INTO `comments` ( `id` , `name` , `comment` )VALUES('', '$name', '$comment');";
            $Result = mysql_db_query($DBName, $Query, $Link);
            mysql_close($Link);
        }
        $Host2 = "localhost";
        $User2 = "scum002_scum002x";
        $Password2 = "***";
        $DBName2 = "scum002_xmb1";
        $Link2 = mysql_connect ($Host2, $User2, $Password2);
        $Query2 = "SELECT * FROM `comments` ORDER BY 'id' DESC";
        $Result2 = mysql_db_query($DBName2, $Query2, $Link2);
      */
      // your custom footer's php code ends here
      $custom_header = cleanup_custom_includes(ob_get_contents());
      ob_clean();
   }

   if(empty($users_online)){
      ob_start();
      // your users online script get's included here
      // the next line needs editing
      include('/your/path/to/virtualonline/virtualonline.php');
      $users_online = cleanup_custom_includes(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_MENU1}' => theme_main_menu1(),
        '{MAIN_MENU2}' => theme_main_menu2(),
        '{ADMIN_MENU}' => theme_admin_mode_menu(),
        '{USERS_ONLINE}' => $users_online,
        '{CUSTOM_HEADER}' => $custom_header,
        );
    echo template_eval($template_header, $template_vars);
}
// Function for writing a pagefooter
function pagefooter()
{
    global $HTTP_GET_VARS, $HTTP_POST_VARS, $HTTP_SERVER_VARS;
    global $USER, $ALBUM_SET, $CONFIG, $time_start, $query_stats;
    global $template_footer;
    if ($CONFIG['debug_mode']==1 || ($CONFIG['debug_mode']==2 && GALLERY_ADMIN_MODE)) {
    cpg_debug_output();
    }
    echo $template_footer;
}

// Function to clean up any double html leftovers from the custom header and footer that are not meant to get parsed
function cleanup_custom_includes($string) {
    $string = str_replace('<HTML>', '', $string);
    $string = str_replace('<HEAD>', '', $string);
    $string = str_replace('<BODY>', '', $string);
    $string = str_replace('</HTML>', '', $string);
    $string = str_replace('</HEAD>', '', $string);
    $string = str_replace('</BODY>', '', $string);
    return $string;
}


Code for template.html:<!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" />
<style type="text/css">
<!--
.style1 {font-size: 9px}

form#login {
background-color: #56606D;
color: #000000;
border: 0px solid #56606D;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
text-align: right;
}

#login .text {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
width: 300px;
margin-right: 1px;

}

#login .buttons {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
background-color: #333333;
color: #FFFFFF;
margin-right: 1px;
}

-->
</style>
{META}
<meta name="keywords" content="VX7000, VX7000 ringtones, vx7000 wallpapers, qpst, qpst 2.7, ringtones, wallpapers, free ringtones, free wallpapers, mp3 ringtones, 176x184, lg vx7000 ringtones, vx7000 hack, vx7000 mp3 ringtones, free ringtones for vx7000, qualcomm qpst, download qpst, VX8000">
<meta name="description" content="This is a website that provides Wallpapers, Ringtones, and Tutorials for your cell phones (LG VX6000, VX7000, VX8000, as well as any other phones that play mp3 ringtones and have wallpaper capabilities). Most images are 176x184 and will fit the LG VX7000/8000 phones perfectly.">
<link rel="stylesheet" href="themes/hardwired/style.css" />
<script type="text/javascript" src="scripts.js"></script>
<!--
$Id: template.html,v 1.3 2004/06/11 09:20:09 tarique Exp $
-->
</head>
<body onLoad="fadeRumor()">
{CUSTOM_HEADER}
<table width="778" height="100%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td width="778" height="61" valign="middle" align="right" background="themes/hardwired/images/hw_01.gif">
        <table width="73%" height="32" border="0" cellpadding="0" cellspacing="0">
          <tr>
            <td width="94%" height="22" valign="bottom" align="right"><span class="gal_name">{GAL_NAME}</span><br />
              <span class="style1">{GAL_DESCRIPTION}</span><br />
              {USERS_ONLINE}
            </td>
            <td width="6%"></td>
          </tr>
        </table>
    </td>
  </tr>
  <tr>
    <td height="100%" align="center" valign="top" background="themes/hardwired/images/hw_02.gif"><table width="100%" height="100%" border="0" align="center">
        <tr>
          <td valign="top" align="left">
              <table width="725" border="0" align="center" cellpadding="6" cellspacing="0">
                <tr>
                  <td height="108" valign="top"><div align="right">{MAIN_MENU1}</div><br />
                    {MAIN_MENU2} <br />
                    <div align="center">{LANGUAGE_SELECT_FLAGS}<br>{THEME_SELECT_LIST}&nbsp;{LANGUAGE_SELECT_LIST}</div><br />
                    {ADMIN_MENU} {GALLERY}</td>
                </tr>
              </table>
              <br />
          </td>
        </tr>
      </table></TD>
  </tr>
  <tr>
    <td valign="bottom"> <img src="themes/hardwired/images/hw_03.gif"></td>
  </tr>
</table>
</body>
</html>

blazer380

That worked great. I removed the database code from theme.php alltogether and inserted it into anycontent.php and it works. I also changed the password and username.

Thanx for your help. :)