Including Header & Footer brings up "Cannot redeclare cpggetmicrotime()" Including Header & Footer brings up "Cannot redeclare cpggetmicrotime()"
 

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

Including Header & Footer brings up "Cannot redeclare cpggetmicrotime()"

Started by Steffi, July 22, 2007, 04:14:41 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Steffi

Hello,

I´ve been searching through this whole forum trying to resolve my problem, but didn´t find any helping thread.

I want to include my header and footer into coppermine, doing it with the relative path, it brings up the following error:
Fatal error: Cannot redeclare cpggetmicrotime() (previously declared in /mnt/web3/52/00/51465200/htdocs/fotos/include/init.inc.php:35) in /mnt/web3/52/00/51465200/htdocs/fotos/include/init.inc.php on line 33


Here are my settings:
My Homepage: http://www.tt-bezirk-ulm.de
My Gallery: http://www.tt-bezirk-ulm.de/fotos
My Header: http://www.tt-bezirk-ulm.de/_top.php    (I declare all "include" files with "_" at the beginning)
My Footer: http://www.tt-bezirk-ulm.de/_bottom.php
There is no <head> or <body> in my include files, I use them through all my other pages.

I include these 2 pages with the following path:
../_top.php
../_bottom.php

I guess, I took the right relative path, if not, please correct me.

Thanks in advance,
Steff

Steffi

Short Update:
Took away the custom header and footer for now, so I can go on doing my starting settings.
The Problem is NOT solved, when I put them back into config file...

blackRock

Documentation:
http://coppermine-gallery.net/demo/cpg14x/docs/index.htm#admin_theme_include_path_start

The easy way:
1. your custom header and footer files must be in yours theme folder (e.g. themes/classic)
2. go admin.php -> Themes Settings and:
  - in Path to custom header include put themes/classic/_top.php
  - in Path to custom footer include put themes/classic/_bottom.php

Of course you have to take care the includes you make in your files because their relative change is changed.

The documentation says
Quote... You can only add a relative path (seen from the root path of your coppermine install) ...

That's my help. If I didn't help, a developer will give you instructions, so, we all learn!

Tranz

Did you by any chance edit the init.inc.php file?

Here is the code that the error message refers to:
function cpgGetMicroTime()
{
    list($usec, $sec) = explode(" ", microtime());
    return ((float)$usec + (float)$sec);
}


I can't see why there could be a "redeclared" error if that's the code.

Steffi

No, of course I didn´t...

When you click on my Gallery-Link you can see that I´ve not changed anything so far, not even the theme. Everything works fine, except when I try to include my header and footer.

And also of course I do not have "function cpgGetMicroTime()" inc my _top.php or _bottom.php.

Any suggestions?

Nibbler


Steffi

No.

This is my _top.php file:


<div id=container>
<div id="header">
<table cellpadding="0" width="98%">
     <tr>
          <td><h1><a href="/index.php" name=top>Tischtennis Bezirk Ulm</a></h1></td>
          <td>&nbsp;<td>
          <td style="text-align:right;">
          <h2>
          <a href="/aktuelles/aktive/" onClick="return clickreturnvalue()" onMouseover="dropdownmenu(this, event, 'linkmenuaktive')">Aktive</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          <a href="/aktuelles/jugend/" onClick="return clickreturnvalue()" onMouseover="dropdownmenu(this, event, 'linkmenujugend')">Jugend</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          <a href="/aktuelles/senioren/" onClick="return clickreturnvalue()" onMouseover="dropdownmenu(this, event, 'linkmenusenioren')">Senioren</a>
          </h2></td>
          <td style="text-align:right;">&nbsp;</td>
     </tr>
</table>
</div>

<div id="columns-float">
<!-- startprint -->
<div id="centercontent">

Steffi

Hello (just to push it up),

are there no other suggestions?
It still doesn´t work...

Steff

Nibbler


Joachim Müller

If the section you posted is all there is in your custom header, why do you use it as external custom header file in the first place. It would be much more efficient if you added that small HTML section to themes/yourtheme/template.html instead. That's why Nibbler asked if this is all there is in your custom_header. It sounds hard to believe that straightforward HTML could trigger a PHP error.

Steffi

Well, that´s why I have an include file. It is included within ALL my pages, so I have to change it only once, when there are changes.
The same with the footer...

Actually there is some php, I have included in the header the _db.inc with the login data to my sql database, which looks like that:
include $_SERVER['DOCUMENT_ROOT'] . '/_include/db/inc.php';

And this include looks like that:

function showDBerror()
{
die("Error" . mysql_errno() . ": " . mysql_error() );
}

  $db_server = "myHost";
  $db_name = "myDBname";
  $db_user = "myDBuser";
  $db_passwort = "myDBpwd";
         
if (! ( $db = @MYSQL_CONNECT($db_server,$db_user,$db_passwort)))
die("Could not connect to DB"); 

if (! ( mysql_select_db($db_name,$db)))
showDBerror();


But I think this also has nothing to do with the error showing up...
(I need this, because there are some statistics show up in my footer, you can see it, when you click on the link I gave you)

Joachim Müller

Post the full content of your header and footer includes and the files those includes call. I'm pretty sure that the queries that compose the stats contain code that actually re-declare that function for another time. You may want to circumvent this by wrapping the function into this piece of code:if (!function_exists('cpggetmicrotime')) {
  // function definition here
}

Steffi

I think this would not help...

I´ve been searching fulltext over all my pages within this website, and there is no other "microtime" to find...

Sami

Do as suggested and give us all included files if you need support

  • _top.php
  • _bottom.php
  • and any other files that you included within those two files
It's looks like a twice including of init.inc.php to me
‍I don't answer to PM with support question
Please post your issue to related board

Joachim Müller

Quote from: Steffi on July 26, 2007, 04:44:03 PMI think this would not help...
Are you the coppermine expert and we the people who asked you for support or vice versa? It's not a bad thing if you're not a skilled PHP coder nor coppermine expert. However it's a bad thing to ignore supporter's advice.
It's not a bright idea to upset supporters with your replies that show you haven't even tried to do what we suggest.

You haven't followed our first advice to post your includes, nor did you follow my second piece of advice: edit include/init.inc.php, findfunction cpgGetMicroTime()
{
    list($usec, $sec) = explode(" ", microtime());
    return ((float)$usec + (float)$sec);
}
and replace withif (!function_exists('cpggetmicrotime')) {
  function cpgGetMicroTime()
  {
      list($usec, $sec) = explode(" ", microtime());
      return ((float)$usec + (float)$sec);
  }
}
I'm afraid though that this will not have the desired effect, but lead to another error message that is a result of including init.inc.php twice.

Steffi

I AM SORRY, I DID NOT WANT TO UPSET ANYBODY...

I was sitting at work having only little time, that´s why I gave you this short (stupid ?) answer.
Of course I will give you all my include codes...

By the way, I am a skilled ASP and .NET programmer (for work) and doing some hobby websites with php privatly. I would say I understand a little about programming, also when php is not my first, favourite or best language.
I did some "debugging" like I always do, when I get errors, but this time it didn´t help, so I did my posting here.

Now I put the "if exists..." around the cpgGetMicroTime function, now the next error comes up, it says that the next function has been previously declared (I left the error now, didn´t remove header and footer from settings).
http://www.tt-bezirk-ulm.de/fotos/
If I put the "if exists..." around this function it goes on like that, it brings the same error for the next function (in function.inc.php). So far I think you´re right, it looks like something is included twice.

So here are my includes:

header:
<?require_once $_SERVER['DOCUMENT_ROOT'] . '/_include/_klappmenulinks.php';?>
<div id=container>
<?require_once $_SERVER['DOCUMENT_ROOT'] . '/_include/db/inc.php';?>
<div id="header">
<table cellpadding="0" width="98%">
     <tr>
          <td><h1><a href="/index.php" name=top>Tischtennis Bezirk Ulm</a></h1></td>
          <td><?require_once $_SERVER['DOCUMENT_ROOT'] . '/_verwaltung/top.php';?></td>
          <td style="text-align:right;">
          <h2>
          <a href="/aktuelles/aktive/" onClick="return clickreturnvalue()" onMouseover="dropdownmenu(this, event, 'linkmenuaktive')">Aktive</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          <a href="/aktuelles/jugend/" onClick="return clickreturnvalue()" onMouseover="dropdownmenu(this, event, 'linkmenujugend')">Jugend</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          <a href="/aktuelles/senioren/" onClick="return clickreturnvalue()" onMouseover="dropdownmenu(this, event, 'linkmenusenioren')">Senioren</a>
          </h2></td>
          <td style="text-align:right;">&nbsp;</td>
     </tr>
</table>
</div>

<div id="columns-float">
<!-- startprint -->
<div id="centercontent">


Attention, it´s getting a lot...
Its the "_klappmenu.php", it´s only DHTML Code for the Menues, no PHP
<div id="linkmenuaktive" class="anylinkcss">
<a href="/aktuelles/aktive/rangliste.php">Rangliste</a>
<a href="/aktuelles/aktive/turniere.php">Turniere</a>
<a href="/aktuelles/aktive/pokal.php">Pokal</a>
<a href="/aktuelles/aktive/termine.php">Termine</a>
</div>
<div id="linkmenujugend" class="anylinkcss">
<a href="/aktuelles/jugend/rangliste.php">Rangliste</a>
<a href="/aktuelles/jugend/turniere.php">Turniere</a>
<a href="/aktuelles/jugend/pokal.php">Pokal</a>
<a href="/aktuelles/jugend/termine.php">Termine</a>
</div>
<div id="linkmenusenioren" class="anylinkcss">
<a href="/ergebnisdienst/senioren.php">Runde</a>
<a href="/aktuelles/senioren/Mannschaftsmeisterschaften.php">Mannschafts-<br>meisterschaften</a>
<a href="/aktuelles/senioren/Bezirksmeisterschaften.php">Einzel-<br>meisterschaften</a>
<a href="/aktuelles/senioren/termine.php">Termine</a>
<a href="/aktuelles/senioren/news.php">Neuigkeiten</a>
</div>
<div id="linkmenuabout" class="anylinkcss">
     <a href="/about/adressen.php">Anschriften</a>
     <a href="/about/steckbriefe.php">Steckbriefe</a>
     <a href="/about/vereine.php">Vereine</a>
     <a href="/about/vereinsorte.php">Landkarte</a>
     <a href="/about/impressum.php">Impressum/Kontakt</a>
</div>
<div id="linkmenuergebnisdienst" class="anylinkcss">
     <a href="/ergebnisdienst/index.php?wer=herren">Herren</a>
     <a href="/ergebnisdienst/index.php?wer=damen">Damen</a>
     <a href="/ergebnisdienst/index.php?wer=jungen">Jungen</a>
     <a href="/ergebnisdienst/index.php?wer=mädchen">Mädchen</a>
     <a href="/ergebnisdienst/senioren.php">Senioren</a>
</div>
<div id="linkmenutermine" class="anylinkcss">
     <a href="/termine/index.php">Termine Bezirk Ulm</a>
     <a href="/termine/turnierkalenderTTVWH.php">TTVWH Turnierkalender</a>
</div>
<div id="linkmenuservice" class="anylinkcss">
     <a href="/service/bundesliga.php">Bundesliga</a>
     <a href="/service/download.php">Download</a>
     <a href="/service/bezirksordnung.php">Bezirksordnung</a>
     <a href="/service/linklist.php">Links</a>
     <a href="/service/archiv.php">Archiv</a>
</div>
<div id="linkmenuinteraktiv" class="anylinkcss">
     <a href="http://www.tt-news.de/forum/forumdisplay.php?f=164" target="_blank">Bezirksforum</a>
     <a href="/interaktiv/rss/">RSS News/Termine</a>
     <a href="/interaktiv/game.php">Spiele Tischtennis<br>ONLINE</a>
</div>


Now the _db.inc (I´ve posted before)
function showDBerror()
{
die("Error" . mysql_errno() . ": " . mysql_error() );
}

  $db_server = "myHost";
  $db_name = "myDBname";
  $db_user = "myDBuser";
  $db_passwort = "myDBpwd";
         
if (! ( $db = @MYSQL_CONNECT($db_server,$db_user,$db_passwort)))
die("Could not connect to DB"); 

if (! ( mysql_select_db($db_name,$db)))
showDBerror();


Then the "_verwaltung/top.php" (It´s the change for the header view, when you login for my cms, only shows that you are logged in)
echo "<center><font size=1>";

//check if the user is logged in
if($_SESSION['Uname'] == '' || $_SESSION['lp'] == '')
{
// auskommentiert, Login soll nur auf der Verwaltungsseite sein!
// echo "<a href=/_verwaltung/>Login</a>";
}
else
{
echo $_SESSION['Uname'] . ", Du bist eingeloggt.&nbsp;|&nbsp;<a href=/_verwaltung/logout.php><font size=1>Logout</font></a>";
}
if($_SESSION['Uname'] != '' AND $_SESSION['Uname'] != $ADMINUNAME)
{
echo "&nbsp;|&nbsp;<a href=/_verwaltung/verwaltung.php><font size=1>Verwaltung</font></a>";
echo "&nbsp;|&nbsp;<a href=/_verwaltung/profile.php><font size=1>mein Profil</font></a>";
echo "&nbsp;|&nbsp;";
}
if($_SESSION['Uname'] == $ADMINUNAME && ! $_SESSION['Uname'] == "")
{
echo "&nbsp;|&nbsp;<a href=/_verwaltung/register.php><font size=1>Neues Mitglied anlegen</font></a>";
echo "&nbsp;|&nbsp;<a href=/_verwaltung/members.php><font size=1>Alle Mitglieder sehen</font></a>";
echo "&nbsp;|&nbsp;";
}
echo "</font></center>";


So far for the header, now the footer

_bottom.php
</div> <? // Ende centercontent ?>
<!-- stopprint -->

<div id="leftcontent"><?require_once $_SERVER['DOCUMENT_ROOT'] . '/_left.php';?></div>

</div> <? // Ende columns-float ?>

<div id="rightcontent"><?require_once $_SERVER['DOCUMENT_ROOT'] . '/_right.php';?></div>

<div id="column_padding_after">&nbsp;</div>

<div id="footer">
<div style="padding: 7px;">
<a href="/search.php"><font size="1">Suchen</font></a>&nbsp; |&nbsp;
<a href="/about/impressum.php"><font size="1">Impressum</font></a>
|
<a href="http://www.ranking-hits.de/user/www.tt-bezirk-ulm.de" title="Google Pagerank" target="_blank"><img src="http://www.ranking-hits.de/?ref=www.tt-bezirk-ulm.de&amp;style=11" border="0" alt="Google Pagerank" /></a>&nbsp;
|  &nbsp;<?
$chCounter_visible = 1;
$chCounter_template = <<<TEMPLATE
<font size=1>Besucher gesamt: {V_TOTAL_VISITORS}</font>  | <font size=1>Besucher online:</font> <a rel="nofollow" href="{V_COUNTER_URL}/stats/online_users.php" onclick="window.open('{V_COUNTER_URL}/stats/online_users.php','online_users','width=700,height=350,screenX=0,screenY=0,resizable=yes,scrollbars=yes'); return false;" target="online_users"><font size=1>{V_VISITORS_CURRENTLY_ONLINE}</font></a>
TEMPLATE;
include $_SERVER['DOCUMENT_ROOT'] . '/interaktiv/counter/counter.php' ;?></div>
</div>

<? // Ende container ?>


Now it may get complicated for you, I have a _right.php and a _left.php for the style on all pages:

_left.php (no php code)
<a href="/">
<img border="0" src="/images/logos/LogoUlm2006.jpg" width="130" height="174"></a>&nbsp;

<p>&nbsp;</p>
<p><a href="#" onClick="return clickreturnvalue()" onMouseover="dropdownmenu(this, event, 'linkmenuabout')">Über uns</a></p>
<p><a href="#" onClick="return clickreturnvalue()" onMouseover="dropdownmenu(this, event, 'linkmenuergebnisdienst')">Ergebnisdienst</a></p>
<p><a href="/news/index.php">News</a></p>
<p><a href="#" onClick="return clickreturnvalue()" onMouseover="dropdownmenu(this, event, 'linkmenutermine')">Termine</a></p>
<p><a href="#" onClick="return clickreturnvalue()" onMouseover="dropdownmenu(this, event, 'linkmenuservice')">Service</a></p>
<p><a href="#" onClick="return clickreturnvalue()" onMouseover="dropdownmenu(this, event, 'linkmenuinteraktiv')">Interaktiv</a></p>


_right.php (little php code, which doesn´t effect anything else)
<a target="_blank" href="http://www.ttvwh.de">
<img border="0" src="/images/logos/LOGO_TTVWH_NEW_small.jpg" width="130" height="90"></a>

<p>
<a target="_blank" href="http://ergebnis.ttvwh.de/">
<img border="0" src="/images/logos/click-tt-klein.gif" width="120" height="40"></a></p>
<p><script type="text/javascript"><!--
// GOOGLE ADSENSE CODE</script>

<? $seite =  "http://".$_SERVER['SERVER_NAME'].$_SERVER['PHP_SELF'] ; ?>
<p align="center">
<a href="#" onclick="openWindow('/print.php?seite=<?echo $seite;?>', 'PRINT', '675', '750', 'center', 'middle', false, 'scroll');">
<img border="0" src="/images/printer.gif" width="18" height="15" alt="Seite drucken"></a>
<a href="#" onclick="openWindow('/print.php?seite=<?echo $seite;?>', 'PRINT', '675', '750', 'center', 'middle', false, 'scroll');">Seite drucken</a></p>
<p align="center">
<a href="/search.php">
<img border="0" src="/images/lupe1.gif" width="15" height="15"></a>
<a href="/search.php">Suchen</a></p>
<p align="center">
&nbsp;</p>

</div>


At the end of the _bottom.php I included the counter (chCounter 3.1.3)
I don´t want to upset you again, but I think you really don´t need the code for this application. I´ve been searching fulltext all over my pages and there definitly is no other "microtime" in it, specially not in the chCounter Application.
Please tell me, if you also want to see this code...

And I´ve also been searching through my pages, if there´s some "double include" that could cause some loop, but I´ve also not found anything.

Please don´t be mad with me any more, of course I want your help. And maybe I´ve also showed you, that I understand a little about programming, but this error is really making me crazy.
Do you have an idea, where the "double include" (or whatever else it is) could be?

Thanks in advance for all the work you got with me...
Steff

PS: Here are all my websites
http://www.okelmann.com my private Site (ASP)
http://www.esc-ulm.de my Sportsclub
http://www.tt-bezirk-ulm.de the association for my sports

Nibbler

I don't see any problem with that code. If you can't find the double include then add this to the start of include/init.inc.php to stop it running twice

if (defined('COPPERMINE_VERSION')) return;

Steffi

OK, I did that...
It "kind of" works, but now it seems that the Coppermine theme doesn´t get along with my style...
Well, it looks, like I can´t use it together. Or what do you think about the output
http://www.tt-bezirk-ulm.de/fotos
And compare that output with the main page http://www.tt-bezirk-ulm.de/

Well, maybe it´s a good idea to use an Iframe???

Steffi

Steffi

Oh forgot - isn´t that weird with the "maybe loop" or "double include"...
No chance to find it...

Sami

You have included _klappmenulinks.php and inc.php at the top of header file but you give us
- _klappmenu.php
- _db.inc

and I don't see any session_start() at your code so top.php wouldn't works at all !
may be you are looking at wrong files and the actual code is under _klappmenulinks.php and inc.php
check them again please
‍I don't answer to PM with support question
Please post your issue to related board