forum.coppermine-gallery.net

Support => cpg1.4.x Support => Older/other versions => cpg1.4 themes/skins/templates => Topic started by: Steffi on July 22, 2007, 04:14:41 pm

Title: Including Header & Footer brings up "Cannot redeclare cpggetmicrotime()"
Post by: Steffi on July 22, 2007, 04:14:41 pm
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:
Code: [Select]
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
Title: Re: Including Header & Footer brings up "Cannot redeclare cpggetmicrotime()"
Post by: Steffi on July 22, 2007, 04:20:20 pm
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...
Title: Re: Including Header & Footer brings up "Cannot redeclare cpggetmicrotime()"
Post by: blackRock on July 22, 2007, 05:24:16 pm
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!
Title: Re: Including Header & Footer brings up "Cannot redeclare cpggetmicrotime()"
Post by: Tranz on July 22, 2007, 05:39:34 pm
Did you by any chance edit the init.inc.php file?

Here is the code that the error message refers to:
Code: [Select]
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.
Title: Re: Including Header & Footer brings up "Cannot redeclare cpggetmicrotime()"
Post by: Steffi on July 22, 2007, 05:45:56 pm
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?
Title: Re: Including Header & Footer brings up "Cannot redeclare cpggetmicrotime()"
Post by: Nibbler on July 22, 2007, 08:59:30 pm
Do you include init.inc.php in your custom files?
Title: Re: Including Header & Footer brings up "Cannot redeclare cpggetmicrotime()"
Post by: Steffi on July 22, 2007, 09:04:26 pm
No.

This is my _top.php file:

Code: [Select]
<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">
Title: Re: Including Header & Footer brings up "Cannot redeclare cpggetmicrotime()"
Post by: Steffi on July 25, 2007, 09:07:40 pm
Hello (just to push it up),

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

Steff
Title: Re: Including Header & Footer brings up "Cannot redeclare cpggetmicrotime()"
Post by: Nibbler on July 26, 2007, 06:16:43 am
So there is no actual php code in your _top.php ?
Title: Re: Including Header & Footer brings up "Cannot redeclare cpggetmicrotime()"
Post by: Joachim Müller on July 26, 2007, 08:29:40 am
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.
Title: Re: Including Header & Footer brings up "Cannot redeclare cpggetmicrotime()"
Post by: Steffi on July 26, 2007, 10:08:27 am
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:
Code: [Select]
include $_SERVER['DOCUMENT_ROOT'] . '/_include/db/inc.php';
And this include looks like that:
Code: [Select]
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)
Title: Re: Including Header & Footer brings up "Cannot redeclare cpggetmicrotime()"
Post by: Joachim Müller on July 26, 2007, 10:27:15 am
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:
Code: [Select]
if (!function_exists('cpggetmicrotime')) {
  // function definition here
}
Title: Re: Including Header & Footer brings up "Cannot redeclare cpggetmicrotime()"
Post by: Steffi on July 26, 2007, 04:44:03 pm
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...
Title: Re: Including Header & Footer brings up "Cannot redeclare cpggetmicrotime()"
Post by: Sami on July 26, 2007, 05:01:57 pm
Do as suggested and give us all included files if you need support
It's looks like a twice including of init.inc.php to me
Title: Re: Including Header & Footer brings up "Cannot redeclare cpggetmicrotime()"
Post by: Joachim Müller on July 26, 2007, 07:04:22 pm
I 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, find
Code: [Select]
function cpgGetMicroTime()
{
    list($usec, $sec) = explode(" ", microtime());
    return ((float)$usec + (float)$sec);
}
and replace with
Code: [Select]
if (!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.
Title: Re: Including Header & Footer brings up "Cannot redeclare cpggetmicrotime()"
Post by: Steffi on July 27, 2007, 12:39:35 am
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/ (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:
Code: [Select]
<?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
Code: [Select]
<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)
Code: [Select]
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)
Code: [Select]
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
Code: [Select]
</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)
Code: [Select]
<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)
Code: [Select]
<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 (http://www.okelmann.com) my private Site (ASP)
http://www.esc-ulm.de (http://www.esc-ulm.de) my Sportsclub
http://www.tt-bezirk-ulm.de (http://www.tt-bezirk-ulm.de) the association for my sports
Title: Re: Including Header & Footer brings up "Cannot redeclare cpggetmicrotime()"
Post by: Nibbler on July 27, 2007, 12:47:50 am
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

Code: [Select]
if (defined('COPPERMINE_VERSION')) return;
Title: Re: Including Header & Footer brings up "Cannot redeclare cpggetmicrotime()"
Post by: Steffi on July 27, 2007, 01:01:20 am
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 (http://www.tt-bezirk-ulm.de/fotos)
And compare that output with the main page http://www.tt-bezirk-ulm.de/ (http://www.tt-bezirk-ulm.de/)

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

Steffi
Title: Re: Including Header & Footer brings up "Cannot redeclare cpggetmicrotime()"
Post by: Steffi on July 27, 2007, 01:02:46 am
Oh forgot - isnīt that weird with the "maybe loop" or "double include"...
No chance to find it...
Title: Re: Including Header & Footer brings up "Cannot redeclare cpggetmicrotime()"
Post by: Sami on July 27, 2007, 05:15:16 am
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
Title: Re: Including Header & Footer brings up "Cannot redeclare cpggetmicrotime()"
Post by: Steffi on July 27, 2007, 09:04:53 am
Sorry, I did not copy, but type the _db.inc which is of course wrong.

Itīs the following includes (which I gave you)

About the session_start():
When you logg into my cms over (hidden) admin pages, then there is another include with the session_start().
But that one doesnīt matter, when you are not authorized. If you look at _verwaltung/top.php you can see that it does not and also should not work, if thereīs no login Session.

All the Code I gave you, is the state when you are not logged in, which is right for Coppermine. I donīt want to "merge" these two systems.