Topic Title: Fatal error: Cannot redeclare editfield

Forum Index » Gallery 1 Integration » Fatal error: Cannot redeclare editfield
Topic URL: http://www.nukedgallery.net/postt460.html

AuthorMessage
Post Title: Fatal error: Cannot redeclare editfield
boubele
Joined: Nov 29, 2003
Posts: 12

Posted: Sat Nov 29, 2003 9:05 am
Hi all,

When I follow links from the integration blocks (Random Photo, new Albums) such as :

http://localhost/modules.php?set_albumN ... _photo.php

I get the following error :

Fatal error: Cannot redeclare editfield() (previously declared in d:\dev\nu\apache\apache\htdocs\modules\gallery\util.php:33) in D:\Dev\Nu\Apache\Apache\htdocs\modules\gallery\util.php on line 33

I can get to Gallery using http://localhost/modules/gallery/index.php without any issue and dig into photos and albums.

Any idea ?

Erik.

----
Give us your Gallery/webserver information to get a faster answer.
Get this information from the PHP diagnostic (in the configuration wizard).
Gallery version: 1.4.1
Apache version: Apache/1.3.29 (Win32)
PHP Version 4.3.4
Graphics Toolkit: netbpm
Operating system: Windows XP

AuthorMessage
Post Title:
boubele
Joined: Nov 29, 2003
Posts: 12

Posted: Sun Nov 30, 2003 8:58 am
- bump

Sorry, still cannot fix this anybody has any idea ? Or success with this configuration ?

AuthorMessage
Post Title:
boubele
Joined: Nov 29, 2003
Posts: 12

Posted: Sun Nov 30, 2003 9:46 am
The site is now online at http://edasque.mine.nu/index.php if anyone wants to look at the problem (click on anything gallery)

AuthorMessage
Post Title:
dari
Joined: Mar 03, 2003
Posts: 6287
Location: Washington Township, NJ, USA
Posted: Sun Nov 30, 2003 7:28 pm
please read the directions when you post a new topic here and include the config lines from your block file(s).

AuthorMessage
Post Title:
boubele
Joined: Nov 29, 2003
Posts: 12

Posted: Sun Nov 30, 2003 8:46 pm
Well, the same error occurs when clicking on an image or album in the Random, AlbumList and newAlbums block but here is the config line for my random block :

$GALLERY_BASEDIR = "D:/Dev/Nu/Apache/Apache/htdocs/modules/gallery/";
define(ALBUM_BASEADDR, "http://edasque.mine.nu/albums/");
define(SERVER_ADDR, "http://edasque.mine.nu/");

I did do a search on this forum and the gallery forum about this issue but it didn't come up with anything.

Erik.

AuthorMessage
Post Title:
dari
Joined: Mar 03, 2003
Posts: 6287
Location: Washington Township, NJ, USA
Posted: Mon Dec 01, 2003 8:11 am
make sure all references in the block file(s) are for "require_once...", instead of just "require"...

AuthorMessage
Post Title:
boubele
Joined: Nov 29, 2003
Posts: 12

Posted: Mon Dec 01, 2003 10:35 am
They are. I checked the three NG related blocks (random, album list and new albums) as well as the random_support.php and they all use require_once.

One more thing, http://edasque.mine.nu/modules.php?name=gallery produces the same result. What do you think ?

Erik.

AuthorMessage
Post Title:
dari
Joined: Mar 03, 2003
Posts: 6287
Location: Washington Township, NJ, USA
Posted: Mon Dec 01, 2003 1:41 pm
deactivate the random block, leaving the other block as is. let me know what happens.

AuthorMessage
Post Title: Re: Fatal error: Cannot redeclare editfield
boubele
Joined: Nov 29, 2003
Posts: 12

Posted: Mon Dec 01, 2003 4:14 pm
Interesting tip. After deactivating all three NG related blocks, it now works. After activating the New Album block it still works. However, activating either the Random block or the Album lists block brings the error back. What do you think ?

Erik.

AuthorMessage
Post Title:
dari
Joined: Mar 03, 2003
Posts: 6287
Location: Washington Township, NJ, USA
Posted: Mon Dec 01, 2003 9:38 pm
hmm this is an interesting error. paste the code from your random block file (the block file and the support file) here. i think i know the problem...

AuthorMessage
Post Title:
boubele
Joined: Nov 29, 2003
Posts: 12

Posted: Tue Dec 02, 2003 12:40 am
Here you go (but remember it also happens when using the block-NG-AlbumsList block )

block-NG-Random.php :
PHP: › <?php
global $gallery;
/*
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or (at
 * your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 * Developed by Dariush Molavi at NukedGallery.net
 * Version 1.0
 * 8 August 2003
 */

 
if (eregi("block-NG-AlbumList.php",$_SERVER['PHP_SELF'])) {
    
Header("Location: index.html");
    die();
}
$GALLERY_BASEDIR "D:/Dev/Nu/Apache/Apache/htdocs/modules/gallery/";
define(ALBUM_BASEADDR"http://edasque.mine.nu/albums/");
define(SERVER_ADDR"http://edasque.mine.nu/");


require_once(
$GALLERY_BASEDIR "init.php");
require_once(
$GALLERY_BASEDIR "random_support.php");

define(CACHE_FILE$gallery->app->albumDir "/block-random.cache");
define(CACHE_EXPIRED86400);

/* VALID VALUES FOR $selector:
 * "DAILY"
 * "HOURLY"
 * "RANDOM"
 */

  
$selector "RANDOM";

  if(
$selector=="DAILY"){
      
$content daily_photo();
  }
  else if (
$selector=="HOURLY"){
      
$content hourly_photo();
  }
  else if (
$selector=="RANDOM"){
      list(
$album$index) = get_random_photo_id();
        
$content random_photo($album$index,0);
  }
?>

and random_support.php :
PHP: › <?php

/* 
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or (at
 * your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */
/*
 * Original random block code from gallery.menalto.com
 * This updated version (c) 2003 Dariush Molavi
 * dari.molavi@nukedgallery.net
 * Version 1.0
 * 8 August 2003
 */

$GALLERY_BASEDIR "D:/Dev/Nu/Apache/Apache/htdocs/modules/gallery/";
require_once(
$GALLERY_BASEDIR "init.php");

function 
daily_photo(){
    global 
$gallery;
    if((
fs_file_exists($gallery->app->albumDir."/daily.jpg"))){
        
$stat=stat($gallery->app->albumDir."/daily.jpg");
        
$modtime $stat['mtime'];
        if(
date("d"$modtime) != date("d"time())) {
            list(
$album,$index) = get_random_photo_id();
            list(
$url$albumURL) = random_photo($album,$index,24);
            
$content "<center><a href=\"".$url."\"><img src=\"".ALBUM_BASEADDR."daily.jpg\" border=\"0\"></a></center>";
            
$content .= "<br><center>From: <a href=\"".$albumURL."\">".$album->fields["title"]."</a></center>";
        }
        else{
            
$fp fs_fopen($gallery->app->albumDir."/daily.txt""r");
            
$line explode("      ",fgets($fp4096));
            
fclose($fp);
            
$content "<center><a href=\"".$line[0]."\"><img src=\"".ALBUM_BASEADDR."daily.jpg\" border=\"0\"></a></center>";
            
$content .= "<br><center>From: <a href=\"".$line[1]."\">".$line[2]."</a></center>";
        }
      }
      else {
            list(
$album,$index) = get_random_photo_id();
               list (
$url$albumURL) = random_photo($album,$index,24);
            
$content "<center><a href=\"".$url."\"><img src=\"".ALBUM_BASEADDR."daily.jpg\" border=\"0\"></a></center>";
            
$content .= "<br><center>From: <a href=\"".$albumURL."\">".$album->fields["title"]."</a></center>";
      }
      return 
$content;
}
  
  function 
hourly_photo(){
    global 
$gallery;
    if((
fs_file_exists($gallery->app->albumDir."/hourly.jpg"))){
        
$stat=stat($gallery->app->albumDir."/hourly.jpg");
        
$modtime $stat['mtime'];
        if(
date("G"$modtime) != date("G"time())) {
            list(
$album,$index) = get_random_photo_id();
            list(
$url$albumURL) = random_photo($album,$index,1);
            
$content "<center><a href=\"".$url."\"><img src=\"".ALBUM_BASEADDR."hourly.jpg\" border=\"0\"></a></center>";
            
$content .= "<br><center>From: <a href=\"".$albumURL."\">".$album->fields["title"]."</a></center>";
        }
        else{
            
$fp fs_fopen($gallery->app->albumDir."/hourly.txt""r");
            
$line explode("      ",fgets($fp4096));
            
fclose($fp);
            
$content "<center><a href=\"".$line[0]."\"><img src=\"".ALBUM_BASEADDR."hourly.jpg\" border=\"0\"></a></center>";
            
$content .= "<br><center>From: <a href=\"".$line[1]."\">".$line[2]."</a></center>";
        }
      }
      else {
            list(
$album,$index) = get_random_photo_id();
               list (
$url$albumURL) = random_photo($album,$index,1);
            
$content "<center><a href=\"".$url."\"><img src=\"".ALBUM_BASEADDR."hourly.jpg\" border=\"0\"></a></center>";
            
$content .= "<br><center>From: <a href=\"".$albumURL."\">".$album->fields["title"]."</a></center>";
      }
      return 
$content;
  }
  
  function 
random_photo($album$index,$filetype){
    global 
$gallery;
        if (isset(
$index)) {
            
$id $album->getPhotoId($index);
            
$url SERVER_ADDR;
            
$url .= "modules.php?set_albumName=".$album->fields["name"];
            
$url .= "&id=" .$id;
            
$url .= "&op=modload&name=gallery&file=index&include=view_photo.php";

            
$albumURL SERVER_ADDR;
            
$albumURL .= "modules.php?set_albumName=".$album->fields["name"];
            
$albumURL .= "&op=modload&name=gallery&file=index&include=view_album.php";
            
$content "<center><a href=\"$url\">".$album->getThumbnailTag($index)."</a></center>";
            
$caption $album->getCaption($index);
            if (
$caption) {
                
$content.="<br><center>".$caption."</center>";
            }
            
$content .= "<br><center>From: <a href=\"".$albumURL."\">".$album->fields["title"]."</a></center>";

        } else {
            
$content "No photo chosen.";
        }
        if(
$filetype == 24) {
               
fs_copy($gallery->app->albumDir."/".$album->fields["name"]."/".$id.".thumb.jpg",$gallery->app->albumDir."/daily.jpg");
               
$fp fs_fopen($gallery->app->albumDir."/daily.txt","w");
               
fwrite($fp,$url."      ".$albumURL."      ".$album->fields["title"]);
               
fclose($fp);
               return array(
$url$albumURL);
          }
        else if(
$filetype == 1) {
               
fs_copy($gallery->app->albumDir."/".$album->fields["name"]."/".$id.".thumb.jpg",$gallery->app->albumDir."/hourly.jpg");
               
$fp fs_fopen($gallery->app->albumDir."/hourly.txt","w");
               
fwrite($fp,$url."      ".$albumURL."      ".$album->fields["title"]);
               
fclose($fp);
               return array(
$url$albumURL);
          }

        return 
$content;
  }

function 
get_random_photo_id(){
        
/* Initializing the seed */
        
srand ((double) microtime() * 1000000);

        
// Check the cache file to see if it's up to date
        
$rebuild 0;
        if (
fs_file_exists(CACHE_FILE)) {
            
$stat fs_stat(CACHE_FILE);
            
$mtime $stat[9];
            if (
time() - $mtime CACHE_EXPIRED) {
            
$rebuild 1;
            }
        }

        if (!
$rebuild) {
            
scanalbums();
            
savecache();
        } else {
            
readcache();
        }

        
$album choosealbum();

        if (
$album) {
            
$index choosephoto($album);
        }
        return array(
$album,$index);
}

   
/*
 * --------------------------------------------------
 * Support functions
 * --------------------------------------------------
 */

function savecache() {
    global 
$cache;
    if (
$fd fs_fopen(CACHE_FILE"w")) {
    foreach (
$cache as $key => $val) {
        
fwrite($fd"$key/$val\n");
    }
    
fclose($fd);
    }
}

function 
readcache() {
    global 
$cache;
    if (
$fd fs_fopen(CACHE_FILE"r")) {
    while (
$line fgets($fd4096)) {
        list(
$key$val) = explode("/"$line);
        
$cache[$key] = $val;
    }
    
fclose($fd);
    }
}

function 
choosephoto($album) {
    global 
$cache;

    
$count $cache[$album->fields["name"]];
    if (
$count == 0) {
    
// Shouldn't happen
    
return null;
    } else if (
$count == 1) {
    
$choose 1;
    } else {
        
$count floatval($count);
        
$choose rand(1$count);
        
$wrap 0;
        if (
$album->isHidden($choose)) {
            
$choose++;
            if (
$choose $album->numPhotos(1)) {
            
$choose 1;
            
$wrap++;

                if (
$wrap 2) {
                    return 
null;
                }
            }
        }
    }

    return 
$choose;
}

function 
choosealbum() {
    global 
$cache;

    
/*
     * The odds that an album will be selected is proportional
     * to the number of (visible) items in the album.
     */

    
$total 0;
    foreach (
$cache as $name => $count) {
        if (!
$choose) {
            
$choose $name;
        }

        
$total += $count;
        if (
$total != && ($total == || rand(1$total) <= $count)) {
            
$choose $name;
        }
    }

    if (
$choose) {
    
$album = new Album();
    
$album->load($choose);
    return 
$album;
    } else {
    return 
null;
    }
}

function 
scanalbums() {
    global 
$cache;
    global 
$gallery;

    
$cache = array();
    
$everybody $gallery->userDB->getEverybody();
    
$albumDB = new AlbumDB();
    foreach (
$albumDB->albumList as $tmpAlbum) {
        if (
$everybody->canReadAlbum($tmpAlbum)) {
            
$seeHidden $everybody->canWriteToAlbum($tmpAlbum);
            
$numPhotos $tmpAlbum->numPhotos($seeHidden);
            
$name $tmpAlbum->fields["name"];
            if (
$numPhotos 0) {
            
$cache[$name] = $numPhotos;
            }
        }
    }
}
?>

AuthorMessage
Post Title:
dari
Joined: Mar 03, 2003
Posts: 6287
Location: Washington Township, NJ, USA
Posted: Tue Dec 02, 2003 12:06 pm
try deleting this line from the block-Random file:
PHP: › <?php require_once($GALLERY_BASEDIR "init.php"); ?>

AuthorMessage
Post Title:
boubele
Joined: Nov 29, 2003
Posts: 12

Posted: Tue Dec 02, 2003 12:53 pm
that didn't do it. Same result. I wonder what's so different in the albumList and random blocks from the NewAlbum block that prevents it from working.

Erik.

AuthorMessage
Post Title:
dari
Joined: Mar 03, 2003
Posts: 6287
Location: Washington Township, NJ, USA
Posted: Tue Dec 02, 2003 12:58 pm
try adding $GALLERY_BASEDIR to the global statements at the top of the random block and the support file.

this really has me puzzled, i've never seen this particular error, and i'm not encountering it on my site...

I've made one small change to the download available. grab the new one and try it.

AuthorMessage
Post Title:
boubele
Joined: Nov 29, 2003
Posts: 12

Posted: Tue Dec 02, 2003 1:15 pm
No, that's not it either. I really wonder what's different about block_NG_newAlbums . Are any of my software version suspicious, PHP, Apache, ...

Erik.

AuthorMessage
Post Title:
dari
Joined: Mar 03, 2003
Posts: 6287
Location: Washington Township, NJ, USA
Posted: Tue Dec 02, 2003 1:16 pm
try grabbing the new download for it....

also, deactivate the random block and move one of the other blocks to the left. i know why the error is occuring, but it shouldn't be. it might be a php.ini setting that's set funny and causing problems.

AuthorMessage
Post Title:
boubele
Joined: Nov 29, 2003
Posts: 12

Posted: Tue Dec 02, 2003 1:19 pm
Also, I wonder if my installation of Gallery as a module is correct. It shows up on the list. It's in webroot/modules/gallery . Albums are in webroot/albums . It's activated. I don't know what else to do.

Erik.

AuthorMessage
Post Title:
dari
Joined: Mar 03, 2003
Posts: 6287
Location: Washington Township, NJ, USA
Posted: Tue Dec 02, 2003 1:20 pm
your installation is fine...

AuthorMessage
Post Title:
boubele
Joined: Nov 29, 2003
Posts: 12

Posted: Tue Dec 02, 2003 2:07 pm
I am confused. Grab the new download for what ? Gallery ? (I have 1.4.1). Blocks, I thought I had the latest of all three, which one do you mean ?

However, you are right, putting any NG block to the left causes the error. Having all of them on the right solves the problem. You're onto something !

Erik.

AuthorMessage
Post Title:
dari
Joined: Mar 03, 2003
Posts: 6287
Location: Washington Township, NJ, USA
Posted: Tue Dec 02, 2003 2:09 pm
new download == new download for the random block.

this is truly odd...can you create a php file called phpinfo.php and place this in it:
PHP: › <?php
phpinfo
();
?>


email me the address of the page...

AuthorMessage
Post Title:
dari
Joined: Mar 03, 2003
Posts: 6287
Location: Washington Township, NJ, USA
Posted: Thu Dec 04, 2003 9:09 am
ah..i just had this same problem.
make sure you don't have two gallery installations (i had my standard install, then was beta testing a branch of gallery when this message popped up). check your modules directory and make sure only one Gallery install exists.

AuthorMessage
Post Title: Re: Fatal error: Cannot redeclare editfield
bbongyi
Joined: Dec 27, 2003
Posts: 11

Posted: Tue Dec 30, 2003 3:23 pm
same problem here....did you all solve this problem..

here is the message i got...

Fatal error: Cannot redeclare editfield() (previously declared in c:\appserv\www\phpnuke\modules\gallery\util.php:33) in C:\AppServ\www\PHPNuke\modules\gallery\util.php on line 33

I don't know why....
I have a gallery 1.4.1 and a server Apache 1.3.34
here is the URL, http://bbongyi.gotdns.com:9000/

AuthorMessage
Post Title: Re: Fatal error: Cannot redeclare editfield
gwyers
Joined: Feb 06, 2004
Posts: 1

Posted: Fri Feb 06, 2004 1:57 pm
Glad to know it's just me getting the "Cannot redeclare editfield()" error. I too have two gallery installations on the same postnuke site, which is a must, and I would very much like to continue using the random block. Has there been a resolution to this issue?

Thanks

AuthorMessage
Post Title: Re: Fatal error: Cannot redeclare editfield
strobeyprobey
Joined: Jul 14, 2003
Posts: 4

Posted: Fri Feb 20, 2004 5:50 pm
I have the random block working just fine for one gallery. But I too have more then one gallery (four of them at the moment) on my Nuke site.

AuthorMessage
Post Title: Re: Fatal error: Cannot redeclare editfield
Krystoff
Joined: Mar 22, 2004
Posts: 1

Posted: Tue Mar 23, 2004 1:53 am
I'm having the same problem, however, the whole thing appears to work fine when I go to the direct link to the gallery instead of clicking on the gallery module link

http://www.mors-optare.org/modules/gallery instead of
http://www.mors-optare.org/modules.php?name=gallery

when I go to the module link, and click on pernissions (when logged in as god), I get the error, when I go to the module through the direct link, I don't get the error. I found it quite odd.

AuthorMessage
Post Title: Re: Fatal error: Cannot redeclare editfield
toreador
Joined: Jul 09, 2004
Posts: 1

Posted: Sat Jul 10, 2004 7:49 pm
I get not only the error:
Fatal error: Cannot redeclare editfield() (previously declared in D:\Inetpub\wwwroot\nukeforum\modules\gallery\util.php:33) in D:\inetpub\wwwroot\nukeforum\modules\gallery\util.php on line 33

but if I click on the direct link to the album it tries to load my portal page in the random photo box. I can't find any issues in the setup, but I am not sure how well it works with PHPNuke 7.3 and Gallery 1.4.3.

The funny thing is, as the others, it only happens when I have Random photo AND Featured photo enabled. If just random photo or featured photo is enabled by itself it works. As soon as I enable both I can't even get to the album without an error.

I do have featured photo on the left and Random on the right. If I put them both on the right side it all works fine!!! Crying or Very sad

AuthorMessage
Post Title: Re: Fatal error: Cannot redeclare editfield
trueguy
Joined: Jul 31, 2003
Posts: 1

Posted: Sat Aug 28, 2004 4:08 am
I had this same problem when adding Newest photo block after adding Random photo block. The problem went away as dari suggested.

I am running php 7.4 with gallery 1.4.4

AuthorMessage
Post Title: Re: Fatal error: Cannot redeclare editfield
Beridox
Joined: Nov 02, 2004
Posts: 3

Posted: Wed Nov 03, 2004 11:41 am
same problem here (php 7.4 with gallery 1.4.4)

Fatal error: Cannot redeclare editfield() (previously declared in h:\appserv\www\site\modules\gallery\util.php:27) in H:\appserv\www\site\modules\gallery\util.php on line 27

All times are GMT - 5 Hours
Powered by PHPNuke and phpBB2 © 2006 phpBB Group