Posted: Sat Jul 09, 2005 12:29 pm Post subject: Re: [RELEASE] Random Photo V2
block-NG-RandomPhoto.php:
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 = 3;
/*******************************************************************/
/* 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;
NG-RandomPhoto_functions.php:
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 = "/home/public_html/NEW/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/public_html/images/");
/*******************************************************************/
/* STOP!! DO NOT EDIT ANYTHING BELOW THIS POINT */
/*******************************************************************/
define(CACHE_FILE, ALBUM_DIRECTORY."block-random.cache");
function createBlockContent($album,$index,$scale,$auto=0) {
global $gallery, $GALLERY_EMBEDDED_INSIDE, $GALLERY_EMBEDDED_INSIDE_TYPE, $GALLERY_MODULENAME;
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;
Joined: Mar 03, 2003 Posts: 6318 Location: Washington Township, NJ, USA
Posted: Mon Jul 11, 2005 8:09 am Post subject: Re: [RELEASE] Random Photo V2
perhaps you need the "NEW" in your album path?
also, if you're on a virtual server (ie, from a hosting company), sometimes they "mask" the true paths to the files. create a phpinfo file and see what the path is that it reveals as the "script path".
Posted: Sun Sep 18, 2005 2:01 am Post subject: Re: [RELEASE] Random Photo V2
Ok, I am not new to gallery or php-nuke but.....
Am trying to get the block working correctly. Have made a test block as the last block on the right side.
Everything displays until I get to that block. No error msgs, and no page footer. It just stops. There is nothing even in display source .. last line is a <br> and then the next block should start.
Any ideas where to start. I have tripple checks the paths in the function file...
Posted: Fri Nov 18, 2005 7:25 pm Post subject: Re: [RELEASE] Random Photo V2
trying to use it as a center block. screws up the right side blocks (they vanish)... and doesnt work itself either (does not show up). Only the left hand side blocks shop up, the center content and blocks show up except for this one...
php v4.3.3 using phpnuke 7.8 with chatserv patched 3.1, gallery 1.5 ... Gallery's working like a charm otherwise.
Posted: Mon Nov 28, 2005 11:44 pm Post subject: Re: [RELEASE] Random Photo V2
kachukuma wrote: › trying to use it as a center block. screws up the right side blocks (they vanish)... and doesnt work itself either (does not show up). Only the left hand side blocks shop up, the center content and blocks show up except for this one...
php v4.3.3 using phpnuke 7.8 with chatserv patched 3.1, gallery 1.5 ... Gallery's working like a charm otherwise.
PLEASE HELP!!!
I've got the same problem but with nuke 7.9 at PHP 4.3.11
Posted: Tue Jan 24, 2006 12:29 pm Post subject: Re: [RELEASE] Random Photo V2
BumontheRun wrote: ›
kachukuma wrote: › trying to use it as a center block. screws up the right side blocks (they vanish)... and doesnt work itself either (does not show up). Only the left hand side blocks shop up, the center content and blocks show up except for this one...
php v4.3.3 using phpnuke 7.8 with chatserv patched 3.1, gallery 1.5 ... Gallery's working like a charm otherwise.
PLEASE HELP!!!
I've got the same problem but with nuke 7.9 at PHP 4.3.11
got the same problem, everything after where the block should be is missing aswell as the block.
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