Home | Support Forums | Your Account | Gallery [2] | 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  

Help with Random Photo block
Goto page 1, 2, 3  Next
 
Post new topic   Reply to topic    NukedGallery.net Forum Index » PHP-Nuke Issues » Blocks View previous topicPrinter friendly versionView next topic
Author Message
PaoloIV

User
User


Joined: Oct 07, 2004
Posts: 36

PostPosted: Mon Nov 22, 2004 9:47 am    Post subject: Help with Random Photo block Reply with quote

Get this information from the PHP diagnostic (in the configuration wizard).
Gallery URL (optional but very useful):www.dwarf.it/gallery
Gallery version:1.4.4 pl4
Graphics Toolkit: GD 2.0
Operating system: Linux
Web browser/version (if applicable): Explorer

Error: Requested index [0] out of bounds [3]
Fatal error: Call to a member function on a non-object in /web/htdocs/www.dwarf.it/home/modules/gallery/classes/Album.php on line 1258

sometimes the new random image block 2.0 gives me this error, not everytime just sometimes when I load up the page I found this thing written, I'm using the NG-Random Photo block V2.0, but it gave me the same problem with the older version.

Can you help?

I don't want much I just want a block that shows scrolling images from my gallery.

thanks a lot
Back to top
Offline View user's profile Send private message
AdBot
   Post subject: Help with Random Photo block  

Back to top
slackbladder

Moderator
Moderator


Joined: Mar 29, 2003
Posts: 1038
Location: Cambs,UK

PostPosted: Mon Nov 22, 2004 11:41 am    Post subject: Re: Help with Random Photo block Reply with quote

Try deleting the file block.random-cache in your ALBUMS folder, then refresh the page
_________________
"The only difference between me and a madman is that I'm not mad."
Back to top
Offline View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger
PaoloIV

User
User


Joined: Oct 07, 2004
Posts: 36

PostPosted: Mon Nov 22, 2004 3:48 pm    Post subject: Re: Help with Random Photo block Reply with quote

uhm I didn't find that file....

I trtied to delete that line from album php but doing so doesn't let me see big pics anymore...
thanks for the help
Back to top
Offline View user's profile Send private message
slackbladder

Moderator
Moderator


Joined: Mar 29, 2003
Posts: 1038
Location: Cambs,UK

PostPosted: Mon Nov 22, 2004 4:01 pm    Post subject: Re: Help with Random Photo block Reply with quote

Plz POST your config lines from the BLOCK files.

EXAMPLE:

Code: ›
/*******************************************************************/
/* Full path to your Gallery, don't forget the trailing /          */
/*******************************************************************/
$GALLERY_BASEDIR = "/home/httpd/phpnuke.nukedgallery.net/htdocs/modules/gallery/";

/*******************************************************************/
/* The module name of your Gallery, default is "gallery"           */
/*******************************************************************/
$GALLERY_MODULENAME = "gallery";

/*******************************************************************/
/* Time, in seconds, to refresh random photo cache. Default is     */
/* 86400 (check it daily)                                          */
/*******************************************************************/
define(CACHE_EXPIRED, 10);

/*******************************************************************/
/* Full path to your albums directory, don't forget the trailing / */
/*******************************************************************/
define(ALBUM_DIRECTORY,"/home/httpd/phpnuke.nukedgallery.net/htdocs/albums/");

_________________
"The only difference between me and a madman is that I'm not mad."
Back to top
Offline View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger
PaoloIV

User
User


Joined: Oct 07, 2004
Posts: 36

PostPosted: Mon Nov 22, 2004 5:11 pm    Post subject: Re: Help with Random Photo block Reply with quote

Code: › <?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.
 *
 * Developed by Dariush Molavi at NukedGallery.net
 * Version 2.0
 * 11 December 2003
 */

 if (eregi("block-NG-RandomPhoto.php",$_SERVER['PHP_SELF'])) {
    Header("Location: index.php");
    die();
}

global $gallery, $Version_Num;

require_once("NG-RandomPhoto_functions.php");

/*******************************************************************/
/* Valid values for $selector: "DAILY", "HOURLY", "RANDOM", "AUTO" */
/* DAILY, HOURLY show a new photo each day/hour                    */
/* RANDOM shows a new photo with each reload of the page           */
/* AUTO refreshes just the block with a new random photo           */
/*******************************************************************/
$selector = "RANDOM";

/*******************************************************************/
/* Number of seconds between autorefresh of block, valid only for  */
/* $selector = AUTO                                                */
/*******************************************************************/
$auto_rate = 5;

/*******************************************************************/
/* Number of photos to display, valid only for $selector = RANDOM  */
/*******************************************************************/
$number_of_pix = 5;

/*******************************************************************/
/* Show photos horozontally(1) or vertically(0). Valid only for    */
/* $selector = RANDOM                                              */
/*******************************************************************/
$horozontal = 0;

/*******************************************************************/
/* Size of thumbnail. Leave at 0 to use Gallery default            */
/*******************************************************************/
$scaleTo = 0;

/*******************************************************************/
/* Scrolling photos, valid only for $selector = RANDOM             */
/*******************************************************************/
$scroll = 1;


/*******************************************************************/
/*          STOP!! DO NOT EDIT ANYTHING BELOW THIS POINT           */
/*******************************************************************/
if($selector=="DAILY"){
        $content = get_photo(24,$scaleTo);
}
else if ($selector=="HOURLY"){
        $content = get_photo(1,$scaleTo);
}
else if ($selector =="AUTO") {
        $content = "<center><iframe name=\"randomblock\" scrolling=\"no\" allowtransparency=\"true\" width=\"140\" src=\"block-NG-AutoPhoto.php?rate=".$auto_rate."\" frameborder=\"0\" marginheight=\"0\" marginwidth=\"0\" hspace=\"0\" vspace=\"0\"></iframe></center>";
}
else if ($selector=="RANDOM"){
        if($horozontal == 0) {
                if($scroll) {
                        $content .= "<marquee loop=\"infinite\" direction=\"up\" behavior=\"scroll\" align=\"center\" scrollamount= \"2\" scrolldelay=\"60\" height=\"220\" onmouseover='this.stop()' onmouseout='this.start()'>";
                }
                for($i=0;$i<$number_of_pix;$i++) {
                        $content .= get_photo(0,$scaleTo);
                        if($number_of_pix >1) {
                                $content .= "<br>";
                        }
                }
                if($scroll) {
                        $content .= "<p><p><p></marquee>";
                }
        }
        else {
                $content = "<table border=\"0\"><tr>";
                for($i=0;$i<$number_of_pix;$i++) {
                        $content .= "<td>".get_photo(0,$scaleTo)."</td>";
                }
                $content .= "</tr></table>";
        }
}
?>


it's the base blok, the one where you don't have to config nothing
Back to top
Offline View user's profile Send private message
slackbladder

Moderator
Moderator


Joined: Mar 29, 2003
Posts: 1038
Location: Cambs,UK

PostPosted: Mon Nov 22, 2004 5:20 pm    Post subject: Re: Help with Random Photo block Reply with quote

You need to POST the CONFIG lines from your NG-RandomPhoto_functions.php
_________________
"The only difference between me and a madman is that I'm not mad."
Back to top
Offline View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger
PaoloIV

User
User


Joined: Oct 07, 2004
Posts: 36

PostPosted: Fri Nov 26, 2004 1:34 pm    Post subject: Re: Help with Random Photo block Reply with quote

ok that's the problem, I didn't configure right the random photo functions, now I have another problem as fast as I configure it like this:

Code: › <?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.
 *
 * Developed by Dariush Molavi at NukedGallery.net
 * Version 2.0
 * 13 December 2003
 */

 if (eregi("block-NG-RandomPhoto_functions.php",$_SERVER['PHP_SELF'])) {
    Header("Location: index.php");
    die();
}

global $gallery, $GALLERY_EMBEDDED_INSIDE, $GALLERY_EMBEDDED_INSIDE_TYPE, $GALLERY_MODULENAME, $Version_Num;

/*******************************************************************/
/* Full path to your Gallery, don't forget the trailing /          */
/*******************************************************************/
$GALLERY_BASEDIR = "/web/htdocs/www.dwarf.it/home/modules/gallery/";

/*******************************************************************/
/* The module name of your Gallery, default is "gallery"           */
/*******************************************************************/
$GALLERY_MODULENAME = "gallery";

/*******************************************************************/
/* Time, in seconds, to refresh random photo cache. Default is     */
/* 86400 (check it daily)                                          */
/*******************************************************************/
define(CACHE_EXPIRED, 10);

/*******************************************************************/
/* Full path to your albums directory, don't forget the trailing / */
/*******************************************************************/
define(ALBUM_DIRECTORY,"/web/htdocs/www.dwarf.it/home/albums/");



/*******************************************************************/
/*          STOP!! DO NOT EDIT ANYTHING BELOW THIS POINT           */
/*******************************************************************/
define(CACHE_FILE, ALBUM_DIRECTORY."block-random.cache");

$GALLERY_EMBEDDED_INSIDE = "nuke";
$GALLERY_EMBEDDED_INSIDE_TYPE = "phpnuke";

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

function createBlockContent($album,$index,$scale,$auto=0) {
        global $gallery, $GALLERY_EMBEDDED_INSIDE, $GALLERY_EMBEDDED_INSIDE_TYPE, $GALLERY_MODULENAME;

        $id = $album->getPhotoId($index);
        $caption = $album->getCaption($index);
        $photo = $album->getPhoto($index);
        $dir = $album->getAlbumDirURL("full");
        $image = $photo->image;
        $PHOTO_URL = makeAlbumUrl($album->fields['name'], $id);
        $ALBUM_URL = makeAlbumUrl($album->fields['name']);
        if($scale == 0) {
                        if($auto == 0) {
                                $IMG = "<center><a href=\"$PHOTO_URL\">".$album->getThumbnailTag($index)."</a><br>";
                        }
                        else {
                                $IMG = "<center><a href=\"$PHOTO_URL\" target=\"_top\">".$album->getThumbnailTag($index)."</a><br>";
                        }
        } else {
                        if($auto == 0) {
                                $IMG = "<center><a href=\"$PHOTO_URL\">".$album->getThumbnailTag($index,$scale)."</a><br>";
                        }
                        else {
                                $IMG = "<center><a href=\"$PHOTO_URL\" target=\"_top\">".$album->getThumbnailTag($index,$scale)."</a><br>";
                        }
        }
        $FROM = "From: <a href=\"$ALBUM_URL\">" . $album->fields['title'] . '</a>';
        $blockContent .=  "\t$IMG\n";
        $blockContent .= "\t$caption<br />\n";
        $blockContent .= "\t$FROM\n</center>";
        return $blockContent;
}

function get_photo($interval, $scale,$auto=0) {
        global $gallery, $GALLERY_EMBEDDED_INSIDE, $GALLERY_EMBEDDED_INSIDE_TYPE, $GALLERY_MODULENAME;

        switch ($interval) {
                case 0:
                        list($album,$index) = get_random_photo_id();
                        while($album->isAlbumName($index)) {
                                list($album,$index) = get_random_photo_id();
                        }
                        $blockContent = createBlockContent($album,$index,$scale,$auto);
                        return $blockContent;
                        break;
                case 1:
                        if (file_exists($gallery->app->albumDir."/hourly.txt")) {
                                $stat=stat($gallery->app->albumDir."/hourly.txt");
                                $modtime = $stat['mtime'];
                                if(date("G", $modtime) != date("G", time())) {                               
                                        list($album,$index) = get_random_photo_id();
                                        while($album->isAlbumName($index)) {
                                                list($album,$index) = get_random_photo_id();
                                        }
                                        $blockContent = createBlockContent($album,$index,$scale);
                                        $fp = fopen($gallery->app->albumDir."/hourly.txt","w");
                                        fwrite($fp,$album->fields['name']."/".$index);
                                        fclose($fp);
                                        return $blockContent;
                                }
                                else {
                                        $fp = fopen($gallery->app->albumDir."/hourly.txt","r");
                                        $line = explode("/",fgets($fp));
                                        $albumName = $line[0];
                                        $album = new Album();
                                        $album->load($albumName);
                                        $index = $line[1];
                                        $blockContent = createBlockContent($album,$index,$scale);
                                        return $blockContent;
                                }
                        }
                        else {
                                list($album,$index) = get_random_photo_id();
                                while($album->isAlbumName($index)) {
                                        list($album,$index) = get_random_photo_id();
                                }
                                $blockContent = createBlockContent($album,$index,$scale);
                                $fp = fopen($gallery->app->albumDir."/hourly.txt","w");
                                fwrite($fp,$album->fields['name']."/".$index);
                                fclose($fp);
                                return $blockContent;
                        }
                        break;
                case 24:
                        if (file_exists($gallery->app->albumDir."/daily.txt")) {
                                $stat=stat($gallery->app->albumDir."/daily.txt");
                                $modtime = $stat['mtime'];
                                if(date("d", $modtime) != date("d", time())) {                               
                                        list($album,$index) = get_random_photo_id();
                                        while($album->isAlbumName($index)) {
                                                list($album,$index) = get_random_photo_id();
                                        }
                                        $blockContent = createBlockContent($album,$index,$scale);
                                        $fp = fopen($gallery->app->albumDir."/daily.txt","w");
                                        fwrite($fp,$album->fields['name']."/".$index);
                                        fclose($fp);
                                        return $blockContent;
                                }
                                else {
                                        $fp = fopen($gallery->app->albumDir."/daily.txt","r");
                                        $line = explode("/",fgets($fp));
                                        $albumName = $line[0];
                                        $album = new Album();
                                        $album->load($albumName);
                                        $index = $line[1];
                                        $blockContent = createBlockContent($album,$index,$scale);
                                        return $blockContent;
                                }
                        }
                        else {
                                list($album,$index) = get_random_photo_id();
                                while($album->isAlbumName($index)) {
                                        list($album,$index) = get_random_photo_id();
                                }
                                $blockContent = createBlockContent($album,$index,$scale);
                                $fp = fopen($gallery->app->albumDir."/daily.txt","w");
                                fwrite($fp,$album->fields['name']."/".$index);
                                fclose($fp);
                                return $blockContent;
                        }
                        break;
        }
}

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;
                        }
                }
                else {
                        $rebuild = 1;
                }

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

                $album = choosealbum();

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

function savecache() {
    global $cache;
    $fd = 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($fd, 4096)) {
                        list($key, $val) = explode("/", $line);
                        $cache[$key] = $val;
                }
                fclose($fd);
    }
}

function choosephoto($album) {
    global $cache, $gallery;

    $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 != 0 && ($total == 1 || 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;
                        }
                }
    }
}

?>


now I get this error

Fatal error: Call to undefined function: isalbumname() in /web/htdocs/www.dwarf.it/home/blocks/NG-RandomPhoto_functions.php on line 101


so if I delete the line 101 wich is this:

while($album->isAlbumName($index))

I don't get that error anymore,
how can I fix this problem?
and what's the downside with deleting that line?

thank you for all the help.
Back to top
Offline View user's profile Send private message
slackbladder

Moderator
Moderator


Joined: Mar 29, 2003
Posts: 1038
Location: Cambs,UK

PostPosted: Fri Nov 26, 2004 2:11 pm    Post subject: Re: Help with Random Photo block Reply with quote

Replace ALL refernces to isAlbumName() to getAlbumName() - do not DELETE it Smile
_________________
"The only difference between me and a madman is that I'm not mad."
Back to top
Offline View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger
PaoloIV

User
User


Joined: Oct 07, 2004
Posts: 36

PostPosted: Fri Nov 26, 2004 2:23 pm    Post subject: Re: Help with Random Photo block Reply with quote

looks like it works fine now ^^

thanks for the fast help as always ^^
Back to top
Offline View user's profile Send private message
PaoloIV

User
User


Joined: Oct 07, 2004
Posts: 36

PostPosted: Sat Nov 27, 2004 3:20 pm    Post subject: Re: Help with Random Photo block Reply with quote

Error: Requested index [0] out of bounds [3]
Fatal error: Call to a member function on a non-object in /web/htdocs/www.dwarf.it/home/modules/gallery/classes/Album.php on line 1610

now it gives me this problem.....
sometimes...not everytime....
Back to top
Offline View user's profile Send private message
slackbladder

Moderator
Moderator


Joined: Mar 29, 2003
Posts: 1038
Location: Cambs,UK

PostPosted: Sat Nov 27, 2004 7:02 pm    Post subject: Re: Help with Random Photo block Reply with quote

Try deleting the 'block-random.cache' file from your ALBUMS folder and re-fresh the page.
_________________
"The only difference between me and a madman is that I'm not mad."
Back to top
Offline View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger
PaoloIV

User
User


Joined: Oct 07, 2004
Posts: 36

PostPosted: Sun Nov 28, 2004 4:12 am    Post subject: Re: Help with Random Photo block Reply with quote

tried that, let's wait and see ^^

thanks for the help
Back to top
Offline View user's profile Send private message
PaoloIV

User
User


Joined: Oct 07, 2004
Posts: 36

PostPosted: Mon Nov 29, 2004 2:08 pm    Post subject: Re: Help with Random Photo block Reply with quote

nuthing....again the same error, some clue?
thanks for the help
Back to top
Offline View user's profile Send private message
chet

Novice
Novice


Joined: Nov 23, 2004
Posts: 20
Location: Zimmerman/MN

PostPosted: Mon Nov 29, 2004 6:36 pm    Post subject: Re: Help with Random Photo block Reply with quote

wht server are you on ? the code you have may not work on your server as i found it didnt on mine i needed to change the line items

Code: › $GALLERY_BASEDIR = "/home/www.photoandcanvas.com/public_html/modules/gallery/";


to

Code: › $GALLERY_BASEDIR = "/home/photoan/public_html/modules/gallery/";


as for some reason my server will not allow that www. path set up i had to use the name of the site server

Chet
Back to top
Offline View user's profile Send private message Yahoo Messenger
PaoloIV

User
User


Joined: Oct 07, 2004
Posts: 36

PostPosted: Tue Nov 30, 2004 4:52 am    Post subject: Re: Help with Random Photo block Reply with quote

my server is aruba.it and anyway the problem is that it gives me that problem only "sometimes" not everytime and sometime the whole site starts flashing in and out (like now) it keeps reloading (only the mainpage where the block is with on one side this thing appearing :table width="100%" border="0" cellpadding=" and I have to take away the block and then after a while I can reactivate it with no problems
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 Issues » Blocks View previous topicPrinter friendly versionView next topic
Goto page 1, 2, 3  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: Web HostingDedicated ServersDomain NamesDomain Name RegistrationDedicated Web HostingSearch Engine OptimisationSEOWeb Design New YorkSEO Web DesignWeb hosting AustraliaSEO

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