Welcome to Geeklog, Anonymous Thursday, March 28 2024 @ 08:40 am EDT

Geeklog Forums

GalleryBlock Conflict with Who's Online Code?


Status: offline

bcbrock

Forum User
Chatty
Registered: 02/04/03
Posts: 64
indescribable
I've never been able to get GalleryBlock to work, but when I got a new computer to host my web site recently, I decided to do some more extensive troubleshooting...

I've installed a fresh copy of Geeklog, then set up a new installation of Gallery, then finally, implemented a new copy of GalleryBlock. Like I've seen every other time I've attempted to use this block, I get the following error message in error.log:
Text Formatted Code

Tue Oct  5 20:12:47 2004 - 1064: You have an error in your SQL syntax.  Check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE remote_ip = '' AND uid = 1' at line 1. SQL in question: DELETE FROM  WHERE remote_ip = '' AND uid = 1
 


I have confirmed that it's tripping over this line of code from lib-common.php, in the section that handles the 'Who's Online Block', by commenting out the line : "DB_query( "DELETE FROM {$_TABLES['sessions']} WHERE remote_ip = '$REMOTE_ADDR' AND uid = 1" );". When this line has been commented out, I get a differrent error in error.log:
Text Formatted Code

Tue Oct  5 20:15:30 2004 - 1064: You have an error in your SQL syntax.  Check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE uid = 1 AND start_time < 1097025030' at line 1. SQL in question: DELETE FROM  WHERE uid = 1 AND start_time < 1097025030
 


I'm at a loss for what the problem here is, as it seems there are several people using this block successfully. When I first had this problem, I attributed it to the possibility of a conflict with some other plugin, but I'm now currently dealing with a completely fresh install of geeklog with no other plugins installed.

I'm hoping that somebody has solved this matter in the past, or is willing to help me figure out what is happening? My site has over a gig of photos on it, and this block would sure be nice to have working!

Thanks.
~Brian
 Quote

Status: offline

Dirk

Site Admin
Admin
Registered: 01/12/02
Posts: 13073
Location:Stuttgart, Germany
FWIW, those SQL requests are missing the name of the table (gl_sessions).

But I have no idea how that could have happened and what it should have to do with the Gallery block ...

bye, Dirk
 Quote

Status: offline

jeffhare

Forum User
Junior
Registered: 12/04/03
Posts: 24
Hello,
I'm using the following gallery random block successfully on my sites. Is this similar to the block you're using?

Text Formatted Code

/**
* Ver 1.2
* packetmad October 14, 2003 www.lanside.net
*
* Blaine Lang March 21/02   www.langfamily.ca
* Ver 1.1
* This Geeklog PHP function uses the Gallery Random Block code contibuted by Bharat Mediratta - Gallery Developer
*
* The Gallery random photo block will display a random photo from your Gallery in a geeklog block.
* The photo is displayed along with its caption and clicking the photo will take you directly to that photo in the appropriate album.
* This version of the random photo code only displays public photos - for which gallery has granted everyboddy access.
* Once a day it scans all your albums to see which ones are viewable by the general public.
* Then it saves that data and uses it for the rest of the day.
* If you change permissions on an album, add or delete albums the changes won't be reflected right away in the random photo block.
* You must have Gallery v1.2 or better to use this block.
*
* This block will also display the photo caption. This is nice when you add comments as a photo caption
* But if you have not, the block may display the default photo caption which gallery defaulted to which is your digicam IMAGE ID
* I have added a check and exclude these captions. Modify this as required - about halfway down in this function.
*
*/
function phpblock_galleryRandomPhoto() {
    global $_CONF, $GALLERY_BASEDIR, $GALLERY_NO_SESSIONS, $gallery;
    $GALLERY_NO_SESSIONS=true;
    $GALLERY_BASEDIR = "/home/cat320/public_html/gallery/";
    define(CACHE_FILE, "/home/cat320/public_html/gallery_temp/randomblock/block-random.cache");
    define(CACHE_EXPIRED, 86400);
    require_once($GALLERY_BASEDIR ."init.php");
    include_once($_CONF['path_html'] . "/block-random.php");

    if ($profile) {
        $timer = time();
    }
   
    /* Initializing the seed */
    srand ((double) microtime() * 1000000);
       
    // Check the cache file to see if it's up to date
    $rebuild = 1;
    if (fs_file_exists(CACHE_FILE)) {
        $stat = fs_stat(CACHE_FILE);
        $mtime = $stat[9];
        if (time() - $mtime < CACHE_EXPIRED) {
        $rebuild = 0;
        }
    }
   
    if ($rebuild) {
        scanAlbums();
        saveCache();
    } else {
        readCache();
    }
   
    $album = chooseAlbum();
   
    if ($album) {
        $index = choosePhoto($album);
    }
   
    if (isset($index)) {
        $id = $album->getPhotoId($index);
        $retval = ""
            ."<a href=" .makeAlbumUrl($album->fields["name"], $id) .">"
            .$album->getThumbnailTag($index)
            ."</a>";
       
        $caption = $album->getCaption($index);
       
        // Add any exclusions that you want for captions. I don't always add an caption and Gallery use the default image name
        // which I don't want to display. My Cannon digicam uses IMG_XXXX and my Kodak uses DCP_XXXX
        if (($caption) AND(!strstr($caption,"IMG_")) AND (!strstr($caption,"DCP_"))) {
            $retval .= "<br><center>$caption</center>";
        } else {
            $retval .= "<br>";
        }  
       
        $retval .= "<br><center>From: "
            ."<a href=" .makeAlbumUrl($album->fields["name"]) .">"
            .$album->fields["title"]
            ."</a></center>";
    } else {
        $retval = "No photo chosen.";
    }
   
    if ($profile) {
        $elapsed = time() - $timer;
        $retval .= "<br>Elapsed: $elapsed secs";
    }
   
    return $retval;
}

 
 Quote

Status: offline

bcbrock

Forum User
Chatty
Registered: 02/04/03
Posts: 64
No, it's not the random photo block, but rather this one from squatty's site:

http://www.squatty.com/filemgmt/singlefile.php?lid=302

Thanks.
~Brian
 Quote

Status: offline

bcbrock

Forum User
Chatty
Registered: 02/04/03
Posts: 64
excited
YIPPEE!!!

I have FINALLY discovered what was causing this problem, and now, I shall bestow my newfound knowledge upon you! (Ok, so you may not care, but the next time I 'forget' and am having this same issue, I'll be glad I documented it)

Short story... case matters in the paths

Long story... I've never had any issues in using all lowercase in my paths. In fact, I probably wouldn't have found the problem had my friend and I not noticed the fact that in gallery's config.php file that some paths DID contain uppercase letters. Can anybody confirm or deny if Gallery does some kind of check of the path entered, and changes the case to match the system being installed on? At any rate, in Gallery's conifig.php, we noticed that while the '$gallery->app->albumDir' path and the '$gallery->app->movieThumbnail ' path did contain uppercase characters, the '$gallery->app->geeklog_dir' did NOT! Changing the appropriate characters to uppercase solved the problem.

If the Gallery Config process uses some method to capitalize the characters it needs to so that the paths match the local system, I wonder if the developers would consider running the '$gallery->app->geeklog_dir value through that same process? I'll drop them a note and see what they say.

Whew... I'm going out for a drink!
~Brian
 Quote

Status: offline

jeffhare

Forum User
Junior
Registered: 12/04/03
Posts: 24
Regarding character case in pathnames, it depends entirely on the hosting platform. If any part of your website is being hosted on Unix/Linux, then it simply must be character case correct. /Home/file and /hoMe/file are entirely different directories on unix. On a windows hosted site, it usually doesn't matter, but could depending on the web server being used.

Bottom line. Case matters in file and directory pathnames.

Good find. Cheers!
 Quote

Status: offline

dgaussin

Forum User
Junior
Registered: 06/01/03
Posts: 16
dizzy
bcbrock, if you have the problem yet, you can try this... Cool

Locate in gallery/init.php the following code :

Text Formatted Code
if (isset($gallery->app->embedded_inside_type) && $gallery->app->embedded_inside_type=='GeekLog') {
        $GALLERY_EMBEDDED_INSIDE='GeekLog';
        $GALLERY_EMBEDDED_INSIDE_TYPE = 'GeekLog';

        // Verify that the geeklog_dir isn't overwritten with a remote exploit
        if (!realpath($gallery->app->geeklog_dir)) {
                print _("Security violation") ."n";
                exit;
        } else {
                if (! defined ("GEEKLOG_DIR")) {
                        define ("GEEKLOG_DIR",$gallery->app->geeklog_dir);
                }
        }
        require_once(GEEKLOG_DIR . '/lib-common.php');
}

 



and modify into...
Text Formatted Code
if (isset($gallery->app->embedded_inside_type) && $gallery->app->embedded_inside_type=='GeekLog') {
        $GALLERY_EMBEDDED_INSIDE='GeekLog';
        $GALLERY_EMBEDDED_INSIDE_TYPE = 'GeekLog';

        // Verify that the geeklog_dir isn't overwritten with a remote exploit
        if (!realpath($gallery->app->geeklog_dir)) {
                print _("Security violation") ."n";
                exit;
        } else {
                if (! defined ("GEEKLOG_DIR")) {
                        define ("GEEKLOG_DIR",$gallery->app->geeklog_dir);
                }
        }
        if (!$GALLERY_BASEDIR) {
                require_once(GEEKLOG_DIR . '/lib-common.php');
        }
}

 
 Quote

All times are EDT. The time is now 08:40 am.

  • Normal Topic
  • Sticky Topic
  • Locked Topic
  • New Post
  • Sticky Topic W/ New Post
  • Locked Topic W/ New Post
  •  View Anonymous Posts
  •  Able to post
  •  Filtered HTML Allowed
  •  Censored Content