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  

Random Photo block error line 61???

 
Post new topic   Reply to topic    NukedGallery.net Forum Index » PHP-Nuke Integration » Blocks View previous topicPrinter friendly versionView next topic
Author Message
palmoscentral

Beginner
Beginner


Joined: Sep 11, 2004
Posts: 3

PostPosted: Sat Sep 11, 2004 11:05 am    Post subject: Random Photo block error line 61??? Reply with quote

Please help, I searched, and also had this working, but it stoped. I reloaded everything but I got this error:

Fatal error: main(): Failed opening required '/path/to/your/modules/gallery/init.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/palmosce/public_html/Nuke2/blocks/NG-RandomPhoto_functions.php on line 61

I know my init.php is there,
here is my RandomPhoto_functions.php contents

<?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 = "/home/palmosce/public_html/mahonfamiles-com/Nuke2/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/palmosce/public_html/mahonfamiles-com/Nuke2/modules/gallery/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->getAlbumName($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->getAlbumName($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->getAlbumName($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->getAlbumName($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->getAlbumName($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;
}
}
}
}

?>
Back to top
Offline View user's profile Send private message
AdBot
   Post subject: Random Photo block error line 61???  

Back to top
dizn0g

Beginner
Beginner


Joined: Jun 12, 2004
Posts: 7

PostPosted: Sat Sep 11, 2004 2:46 pm    Post subject: Re: Random Photo block error line 61??? Reply with quote

I got the exact same problem, just installed the Random block today. I'm running Nuke 7.5, and Gallery 1.4.3-pl2.

dizn0g
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: Sat Sep 11, 2004 6:41 pm    Post subject: Re: Random Photo block error line 61??? Reply with quote

you have to replace the '/path/to/your/modules/gallery/init.php' with the actual path, ie '/home/jimbob/public_html/modules/gallery/init.php' (that is only an example!!).
Back to top
Offline View user's profile Send private message Visit poster's website
palmoscentral

Beginner
Beginner


Joined: Sep 11, 2004
Posts: 3

PostPosted: Sat Sep 11, 2004 8:59 pm    Post subject: Re: Random Photo block error line 61??? Reply with quote

First Thanks for the reply
But where and how do I do that?
I am guessing, here
require_once($GALLERY_BASEDIR . "init.php");
but what should the new line look like?
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: Sat Sep 11, 2004 9:16 pm    Post subject: Re: Random Photo block error line 61??? Reply with quote

it should be something like:
require_once("/home/palmosce/public_html/mahonfamiles-com/Nuke2/modules/gallery/init.php");

not sure why the GALLERY_BASEDIR isn't working...probably because that variable is gone in the latest versions of Gallery. I need to recode these blocks, but I haven't had the time.
Back to top
Offline View user's profile Send private message Visit poster's website
dizn0g

Beginner
Beginner


Joined: Jun 12, 2004
Posts: 7

PostPosted: Sat Sep 11, 2004 11:47 pm    Post subject: Re: Random Photo block error line 61??? Reply with quote

Which file does that change need to be made in? I have modified the NG_RandomPhoto_Functions.php to have the correct base directory, but don't see anything in any of the three files that has a specific path to the init.php
Back to top
Offline View user's profile Send private message
dizn0g

Beginner
Beginner


Joined: Jun 12, 2004
Posts: 7

PostPosted: Sat Sep 11, 2004 11:50 pm    Post subject: Re: Random Photo block error line 61??? Reply with quote

Figured it out... Thanks.
Back to top
Offline View user's profile Send private message
palmoscentral

Beginner
Beginner


Joined: Sep 11, 2004
Posts: 3

PostPosted: Sun Sep 12, 2004 8:41 am    Post subject: Re: Random Photo block error line 61??? Reply with quote

Figured it out as in it worked?
I added the fix above, but still get this message:
Fatal error: main(): Failed opening required '/home/palmosce/public_html/mahonfamiles-com/Nuke2/modules/gallery/init.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/palmosce/public_html/Nuke2/blocks/NG-RandomPhoto_functions.php on line 61
Back to top
Offline View user's profile Send private message
ceasar

Beginner
Beginner


Joined: Nov 02, 2004
Posts: 1

PostPosted: Sat Nov 06, 2004 11:34 pm    Post subject: Re: Random Photo block error line 61??? Reply with quote

Palmoscentral, if you are still having the error in line 61 the answer is easy. It seems this dizn0g figured it out but does not share information. I was having the same problem. Look in your gallery directory and see if the g in gallery is capitalized. If it is your full path to gallery will be - $GALLERY_BASEDIR = "/home/palmosce/public_html/mahonfamiles-com/Nuke2/modules/Gallery/";
and the module name to your gallery will be - $GALLERY_MODULENAME = "Gallery"; This was my solution to this problem.
Back to top
Offline View user's profile Send private message
chet

Novice
Novice


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

PostPosted: Wed Nov 24, 2004 11:50 am    Post subject: Re: Random Photo block error line 61??? Reply with quote

i was having this problem until i moved my albums to the main directory. Dont know if that helps? But thos is how my new structure is setup
Code: › /*******************************************************************/
/* Full path to your Gallery, don't forget the trailing /          */
/*******************************************************************/
$GALLERY_BASEDIR = "/home/photoan/public_html/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/photoan/public_html/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");
Back to top
Offline View user's profile Send private message Yahoo Messenger
Display posts from previous:   
Post new topic   Reply to topic    NukedGallery.net Forum Index » PHP-Nuke Integration » Blocks View previous topicPrinter friendly versionView next topic

 
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 filter

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