Support Forums | Demo Gallery [1.x] [2.x] | Downloads | News | Site Map ]
Nuked Gallery
  Create a FREE account or Login   As a guest, you don't have access to our FULL navigation system.
 Forum FAQForum FAQ   StatisticsStatistics   SearchSearch   UsergroupsUsergroups   FavoritesFavorites  

Fatal error: Cannot redeclare editfield
Goto page 1, 2  Next
 
Post new topic   Reply to topic    NukedGallery.net Forum Index » PHP-Nuke Integration » Gallery 1 Integration View previous topicPrinter friendly versionView next topic
Author Message
boubele

Beginner
Beginner


Joined: Nov 29, 2003
Posts: 12

PostPosted: Sat Nov 29, 2003 9:05 am    Post subject: Fatal error: Cannot redeclare editfield Reply with quote

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
Back to top
Offline View user's profile Send private message
AdBot
   Post subject: Fatal error: Cannot redeclare editfield  

Back to top
boubele

Beginner
Beginner


Joined: Nov 29, 2003
Posts: 12

PostPosted: Sun Nov 30, 2003 8:58 am    Post subject: Reply with quote

- bump

Sorry, still cannot fix this anybody has any idea ? Or success with this configuration ?
Back to top
Offline View user's profile Send private message
boubele

Beginner
Beginner


Joined: Nov 29, 2003
Posts: 12

PostPosted: Sun Nov 30, 2003 9:46 am    Post subject: Reply with quote

The site is now online at http://edasque.mine.nu/index.php if anyone wants to look at the problem (click on anything gallery)
Back to top
Offline View user's profile Send private message
dari

Site Admin
Site Admin


Joined: Mar 03, 2003
Posts: 6287
Location: Washington Township, NJ, USA

PostPosted: Sun Nov 30, 2003 7:28 pm    Post subject: Reply with quote

please read the directions when you post a new topic here and include the config lines from your block file(s).
Back to top
Offline View user's profile Send private message Visit poster's website
boubele

Beginner
Beginner


Joined: Nov 29, 2003
Posts: 12

PostPosted: Sun Nov 30, 2003 8:46 pm    Post subject: Reply with quote

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.
Back to top
Offline View user's profile Send private message
dari

Site Admin
Site Admin


Joined: Mar 03, 2003
Posts: 6287
Location: Washington Township, NJ, USA

PostPosted: Mon Dec 01, 2003 8:11 am    Post subject: Reply with quote

make sure all references in the block file(s) are for "require_once...", instead of just "require"...
Back to top
Offline View user's profile Send private message Visit poster's website
boubele

Beginner
Beginner


Joined: Nov 29, 2003
Posts: 12

PostPosted: Mon Dec 01, 2003 10:35 am    Post subject: Reply with quote

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.
Back to top
Offline View user's profile Send private message
dari

Site Admin
Site Admin


Joined: Mar 03, 2003
Posts: 6287
Location: Washington Township, NJ, USA

PostPosted: Mon Dec 01, 2003 1:41 pm    Post subject: Reply with quote

deactivate the random block, leaving the other block as is. let me know what happens.
Back to top
Offline View user's profile Send private message Visit poster's website
boubele

Beginner
Beginner


Joined: Nov 29, 2003
Posts: 12

PostPosted: Mon Dec 01, 2003 4:14 pm    Post subject: Re: Fatal error: Cannot redeclare editfield Reply with quote

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.
Back to top
Offline View user's profile Send private message
dari

Site Admin
Site Admin


Joined: Mar 03, 2003
Posts: 6287
Location: Washington Township, NJ, USA

PostPosted: Mon Dec 01, 2003 9:38 pm    Post subject: Reply with quote

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...
Back to top
Offline View user's profile Send private message Visit poster's website
boubele

Beginner
Beginner


Joined: Nov 29, 2003
Posts: 12

PostPosted: Tue Dec 02, 2003 12:40 am    Post subject: Reply with quote

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;
            }
        }
    }
}
?>
Back to top
Offline View user's profile Send private message
dari

Site Admin
Site Admin


Joined: Mar 03, 2003
Posts: 6287
Location: Washington Township, NJ, USA

PostPosted: Tue Dec 02, 2003 12:06 pm    Post subject: Reply with quote

try deleting this line from the block-Random file:
PHP: › <?php require_once($GALLERY_BASEDIR "init.php"); ?>
Back to top
Offline View user's profile Send private message Visit poster's website
boubele

Beginner
Beginner


Joined: Nov 29, 2003
Posts: 12

PostPosted: Tue Dec 02, 2003 12:53 pm    Post subject: Reply with quote

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.
Back to top
Offline View user's profile Send private message
dari

Site Admin
Site Admin


Joined: Mar 03, 2003
Posts: 6287
Location: Washington Township, NJ, USA

PostPosted: Tue Dec 02, 2003 12:58 pm    Post subject: Reply with quote

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.
Back to top
Offline View user's profile Send private message Visit poster's website
boubele

Beginner
Beginner


Joined: Nov 29, 2003
Posts: 12

PostPosted: Tue Dec 02, 2003 1:15 pm    Post subject: Reply with quote

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.
Back to top
Offline View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    NukedGallery.net Forum Index » PHP-Nuke Integration » Gallery 1 Integration View previous topicPrinter friendly versionView next topic
Goto page 1, 2  Next

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT - 5 Hours

Powered by phpBB © phpBB Group



Sponsors: Dedicated ServersDomain NamesWeb HostingDomain Name RegistrationDedicated Web HostingWeb Design New YorkCompare VoIPseo packagesSEO CompanyNew York Yellow PagesFind LocationsVOIP Phone ServiceNeckermannOnline internetSEORestaurant Locator • Get great HP coupons from CouponSnapshot • Search for great dell coupons at CouponSnapshot.com.au • Graduation DressesAndroid TabletSEO IndiaBuy Phen375fuel filterWorld Meds Direct

8th year online! 2003-2011
Legal • Use of this site consitutes agreement to the Acceptable Use Policy
Hosted by Implosion WorksSourceForge.net Logo • Theme by TonicMedia