Solution: top 10 albums and last updates including sub-album

ppmnt
ppmnt's picture

Joined: 2003-01-12
Posts: 238
Posted: Mon, 2003-02-03 00:31

June 11 2004 -
Edit: fixed the URL where you can find my gallery help pages, as I moved from PHP-Nuke to Geeklog this weekend...

=========================================

March 1 2004-
I've still been getting quite a few requests for help with these scripts. I realize that this is not the easiest thing to do if you are not familiar with PHP. So I've decided to put together some >> help pages << on these two features (last X updates and top X albums).

I have also updated the code and improved the scripts some, as well as made it easier to customize. For example, it is now easy to set the number of albums to be displayed. You can also display the top X albums with a rank (like on >> my web site <<).

Unless you already have it working and you are happy with it, please download the new versions.

I will leave the info below so that this thread still makes sense. But please check the more detailed instructions on my >> help pages <<.

=========================================

Feb 23, 2004 - I updated this post to make it a little easier to read. Since the boards update the code sections was just too messy looking

I know some of you said you were working on this, so I didn't want to keep bugging you. But since I just reorganized my gallery into only 3 top level albums (for now), it was urgent for me to try to fix the top 10 / last updated scripts so that they include sub-albums.

Check out >> my web site <<to see the new top 10 script in action.

I haven't updated the last-updated one yet, but here's what you need to do to make top10albums.php get a list of all albums, not only the top-level albums:

1.) Download the script you want >> here <<.

Credit still goes to pixelchimp, all I did was change some function calls to call new modified functions (see next step) and take out the double isRoot() check.

March 1, 2004 - By now I've made more changes than that...

2.) Add 3 custom functions to AlbumDB.php. They are modified copies of functions that already exist and that are used by top10.

You can add these anywhere within AlbumDB.php in the functions section (except in the middle of another function, of course). One way is to add all custom functions at the very bottom, just before the last

}

?>

Add these 3 functions:


// --------- BEGIN CUSTOMIZATIONS --------- //

        /* 
          20040218: Added numAllAlbums, getAllAlbum, and getAllVisibleAlbums to also scan sub-albums (not just root albums)
          to be used by top 10, most recently updated, etc mods 
         */
         
        function numAllAlbums($user) {
                return sizeof($this->getAllVisibleAlbums($user));
        }

        function getAllAlbum($user, $index) {
                global $gallery;
                $list = $this->getAllVisibleAlbums($user);
                if (!$list[$index-1]->transient->photosloaded) {
                        $list[$index-1]->loadPhotos($gallery->app->albumDir . "/" . $list[$index-1]->fields["name"]);
                }
                return $list[$index-1];
        }

        function getAllVisibleAlbums($user) {
                global $gallery;
                $list = array();
                foreach ($this->albumList as $album) {
                        if ($user->canReadAlbum($album)) {
                                array_push($list, $album);
                        }
                }
                return $list;
        }

// --------- END CUSTOMIZATIONS --------- //

That's it! Have fun!

~Eva

 
ppmnt
ppmnt's picture

Joined: 2003-01-12
Posts: 238
Posted: Mon, 2003-02-03 00:46

Post not needed anymore...

 
Picolio
Picolio's picture

Joined: 2003-02-02
Posts: 18
Posted: Mon, 2003-02-03 02:20

This is great! Thank you for taking the time!

With that said..I'm having one problem ...

When I add it to my page I get an error "Object Expected" on line 29.

The page works fine without the include. ==> http://www.Picolio.com/

The include works fine without the page ==> http://www.Picolio.com/test.php

But when I put the include into the page I get the error on page ==> http://www.Picolio.com/indexTest.php
(you can see the little error message at the bottom of IE5.5 especially if you mouse over the links in the 'last updated' area.

When viewing the code itself line 29 falls in the IFRAMEs for the random images...

<IFRAME id="blockrandom"
onLoad="iFrameHeight();"
src="http://www.picolio.com/Gallery/block-random.php?&amp;target=_top"
width="180"
height="130" align=center valign=middle scrolling=no frameborder=0>
[This feature requires IFRAME.]
</IFRAME>

Any ideas?

Thanks again!

Deb

 
ppmnt
ppmnt's picture

Joined: 2003-01-12
Posts: 238
Posted: Mon, 2003-02-03 02:31

Deb,

If you look at the source of my page you'll see that I'm actually using an iFrame for the latest updates, not an include:
<!-- BBCode Start --><TABLE BORDER=0 ALIGN=CENTER WIDTH=85%><TR><TD><font class="pn-sub">Code:</font><HR></TD></TR><TR><TD><FONT class="pn-sub"><PRE>
<iframe width="300" height="250" frameborder="0" src="http://www.discobug.com/gallery/last-updates.php">
Your browser does not support IFrames.<br>
Yhis section would show you the latest updated albums in the
<a href="/gallery"> photo gallery</a>.<br></iframe>
</TD></TR></TABLE><!-- BBCode End -->

I didn't try an include. I'm on my way out, but I can try it later. Otherwise, would an iFrame be an option for you?

~Eva

 
Picolio
Picolio's picture

Joined: 2003-02-02
Posts: 18
Posted: Mon, 2003-02-03 02:40

Hmmm, I'm not versed enough with IFRAMEs to understand it but I removed the following line from both of the IFRAMEs on top of the page for the random images

onLoad="iFrameHeight();"

Now it all works :razz: http://www.Picolio.com/ <<== shows it

Thanks very much for taking the time to provide this enhanced feature!

Deb

 
ppmnt
ppmnt's picture

Joined: 2003-01-12
Posts: 238
Posted: Mon, 2003-02-03 04:18
Quote:
Hmmm, I'm not versed enough with IFRAMEs to understand it but I removed the following line from both of the IFRAMEs on top of the page for the random images

onLoad="iFrameHeight();"

Now it all works :razz: http://www.Picolio.com/ <<== shows it

Thanks very much for taking the time to provide this enhanced feature!

Deb

All the did is take away the functionality to resize the iFrame automatically depending on the height of the thumbnail. If you took that out you can also remove this:
<!-- BBCode Start --><TABLE BORDER=0 ALIGN=CENTER WIDTH=85%><TR><TD><font class="pn-sub">Code:</font><HR></TD></TR><TR><TD><FONT class="pn-sub"><PRE>
<script language="JavaScript">
// Credit goes to user kenny9336 on "http://www.experts-exchange.com"
function iFrameHeight() {
if(document.getElementById &amp;&amp; !(document.all)) {
var h = document.getElementById('blockrandom').contentDocument.body.scrollHeight;
document.getElementById('blockrandom').style.height = h;
}
else if(document.all) {
h = document.frames('blockrandom').document.body.scrollHeight;
document.all.blockrandom.style.height = h;
}
}
</script>
</TD></TR></TABLE><!-- BBCode End -->
That should be somewhere between your <head> ... </head> tags, that was the function that one line in the iFrame was calling.

I think on your page that's not imortant anyway, because the Pic Olio image on top is higher than your random thumbnails. If you look at <!-- BBCode Start --><A HREF="http://www.discobug.com/" TARGET="_blank">>> my page <<</A><!-- BBCode End --> again, as it loads you can see that the left side moves up once the thumbnail appears. Otherwise there'd be too much space underneath the image when it loads a landscape photo.

By the way, if you never had the code above in your <head> area, then that would explain the error you were getting, as it was calling a javascript function that wasn't defined. :razz:

Anyway, it looks great!

 
ppmnt
ppmnt's picture

Joined: 2003-01-12
Posts: 238
Posted: Mon, 2003-02-03 04:21

I was just looking at your pictures (Nikki and MacDonalds is a crack up!), and noticed you actually seem to have that error on every page. The random image iFrames in the header still have this line in them:

onLoad="iFrameHeight();"

But when I did a view source I couldn't find the function defined in your <head> tags.

 
Picolio
Picolio's picture

Joined: 2003-02-02
Posts: 18
Posted: Mon, 2003-02-03 04:53

Yeah I'm a slowpoke (spend too much time with Nikki at McDonalds hehe) but it's all fixed now :grin:

I didn't use an include so needed to make the same edit within all of the header files in Gallery.. I got preoccupied with your other mods though LOL

 
ppmnt
ppmnt's picture

Joined: 2003-01-12
Posts: 238
Posted: Mon, 2003-02-03 04:56

LOL - no problem, just thought I'd mention it, as I was worried how the last-updated block could have caused that error. :grin:

 
Nebular

Joined: 2003-02-02
Posts: 8
Posted: Mon, 2003-02-03 04:59

Ok, I must be dumb or something but I can't figure this one out.

For some reason this is what I get when I call last-updates.php:

<!-- BBCode Start --><TABLE BORDER=0 ALIGN=CENTER WIDTH=85%><TR><TD><font class="pn-sub">Code:</font><HR></TD></TR><TR><TD><FONT class="pn-sub"><PRE> 215 photos in 8 albums:

Vacations<a href="#" onClick="javascript:nw=window.open('http:
last updated:
Caving Clarsville<a href="#" onClick="javascript:nw=window.open('http:
last updated:
Outdoor<a href="#" onClick="javascript:nw=window.open('http:
last updated:
Outdoor<a href="#" onClick="javascript:nw=window.open('http:
last updated:
My dad's hydroplane<a href="#" onClick="javascript:nw=window.open('http:
last updated:
</TD></TR></TABLE><!-- BBCode End -->

You can check it out at <!-- BBCode Start --><A HREF="http://www.ngray.com/gallery2/last-updates.php" TARGET="_blank">http://www.ngray.com/gallery2/last-updates.php</A><!-- BBCode End -->

Any guesses as to what’s going on?

- Nebular

 
ppmnt
ppmnt's picture

Joined: 2003-01-12
Posts: 238
Posted: Mon, 2003-02-03 05:12

Nebular -

I get that same problem when I'm logged into the gallery as admin. I followed your link and it looks fine for me, so I think this is the same problem. Try logging off and look at it again.

This is some problem with the original code, I never tried to figure it out once I realized it looked fine to everyone else. I don't have any users with login IDs on my gallery, so I'm not sure if it also affects non-admin users.

Also, as a tip, it also breaks if you have a "/" anywhere in your album title, because the cache file is /-delimited.

 
Nebular

Joined: 2003-02-02
Posts: 8
Posted: Mon, 2003-02-03 05:15

Ohhh... that's better! Thanks!

btw, wonderful addin!

 
TheGoOse
TheGoOse's picture

Joined: 2002-12-31
Posts: 50
Posted: Tue, 2003-02-04 22:26

First of all, thanks for your coding, ppmnt, it's a good improvement for a lot of galleries, including mine :smile:

I see some people want it to work with an "include" instead of an "iframe", though. I've had to do this in my gallery. It's as simple as commenting the following lines:

<!-- BBCode Start --><TABLE BORDER=0 ALIGN=CENTER WIDTH=85%><TR><TD><font class="pn-sub">Code:</font><HR></TD></TR><TR><TD><FONT class="pn-sub"><PRE>require($GALLERY_BASEDIR . "init.php");
readfile("header.html");</TD></TR></TABLE><!-- BBCode End -->

Also, it can be useful editing the last lines of the PHP page, so it integrates better in the gallery web page. Something like this:

<!-- BBCode Start --><TABLE BORDER=0 ALIGN=CENTER WIDTH=85%><TR><TD><font class="pn-sub">Code:</font><HR></TD></TR><TR><TD><FONT class="pn-sub"><PRE>[...]
$numAllAlbums = $albumDB->numAllAlbums($gallery->user);
$numPhotos = $albumDB->numPhotos($gallery->user);

?>

<span class="title">Last updates</span><br>

<?

// for loop reads the data from the arrays and renders it on screen

for ($i = 0; $i <= 4; $i++) {
$albumURL = makeGalleryUrl($cacheName[$i]);
if (strcmp($cacheRealName[$i],"")) {
echo ("&amp;nbsp&amp;nbsp<a href=" . $albumURL . ">" . $cacheRealName[$i] . "</a> (" . $cacheDate[$i] . ")<br>");
}
}

}

echo ("<br>");

?>
</table></TD></TR></TABLE><!-- BBCode End -->

You can see it working (in Spanish :roll: ) in <!-- BBCode Start --><A HREF="http://ganso.org" TARGET="_blank">my web page</A><!-- BBCode End -->.

 
thebign

Joined: 2003-01-14
Posts: 11
Posted: Tue, 2003-02-04 22:39

Hi

I use this functions with iframe, but can't see the album when I click on the link in recent updates and top 10 albums.

My folder setings for Gallery is:

Standard configuration

gallery/
gallery/last-updates.php
gallery/top10albums.php
gallery/albums

Here is the link to the test file: http://mitgalleri.com/recent.html
or
Here is the link to the test file: http://mitgalleri.com/gallery/last-updates.php
or
Here is the link to the test file: http://mitgalleri.com/gallery/top10albums.php

What to do?

 
BorgKing
BorgKing's picture

Joined: 2002-09-12
Posts: 314
Posted: Tue, 2003-02-04 22:58

You're getting this error because your Gallery doesn't have mod_rewrite enabled. This script assumes you have mod_rewrite enabled (not that good). You could solve it by rewriting the part of the script where URLs are created to use the non-mod_rewrite URLS, e.g. inserting "view_album.php?set_albumName=" in the code.

 
thebign

Joined: 2003-01-14
Posts: 11
Posted: Tue, 2003-02-04 23:31

Hi Again

PHP is very new for me, could you please explain and show me how to make the changes?

Thx

 
ppmnt
ppmnt's picture

Joined: 2003-01-12
Posts: 238
Posted: Wed, 2003-02-05 07:03
Quote:
First of all, thanks for your coding, ppmnt, it's a good improvement for a lot of galleries, including mine :smile:

I see some people want it to work with an "include" instead of an "iframe", though. I've had to do this in my gallery. It's as simple as commenting the following lines:

[ ... ]

Thanks, TheGoose, I'll try that out. Might look a little better loading over a slow connection.

 
ppmnt
ppmnt's picture

Joined: 2003-01-12
Posts: 238
Posted: Wed, 2003-02-05 07:12
Quote:
Thanks, TheGoose, I'll try that out. Might look a little better loading over a slow connection.

TheGoose -

Two things: I went to your page and clicked on the Andalucia album, and found the following:

Warning: Failed opening 'last_updates.php' for inclusion (include_path='.:/usr/local/lib/php') in /usr/people/goose/public_html/gallery/view_album.php on line 591

Also, when you comment out those two lines, you miss a lot of function definitions, so I get the following:

Fatal error: Call to undefined function: fs_file_exists() in /path/to/gallery/top10albums-noi.php on line 63

I saw the same thing when I went to the URL of <!-- BBCode Start --><A HREF="http://ganso.org/last-updates.php" TARGET="_blank">your last-updates script</A><!-- BBCode End -->

I remember I was trying to mess with this last night. including the required class files directly in the album instead of init.php, or using different functions. I was tired and finally gave up.

Has anybody else got this working with a php include instead of an iframe?

 
TheGoOse
TheGoOse's picture

Joined: 2002-12-31
Posts: 50
Posted: Wed, 2003-02-05 10:46
Quote:
>>Thanks, TheGoose, I'll try that out. Might look a little better loading over a slow connection.<<

TheGoose -

Two things: I went to your page and clicked on the Andalucia album, and found the following:

Warning: Failed opening 'last_updates.php' for inclusion (include_path='.:/usr/local/lib/php') in /usr/people/goose/public_html/gallery/view_album.php on line 591

Oops !! I tried to keep it just in the main gallery page, and I though view_album.php was the right file. I'll try to correct it later at home.

Quote:
Also, when you comment out those two lines, you miss a lot of function definitions, so I get the following:

Fatal error: Call to undefined function: fs_file_exists() in /path/to/gallery/top10albums-noi.php on line 63

I don't use the top10 albums feature, as I have less than 10 albums :wink:
Again, I'll try to look at this afterwards. Anyway, as the PHP code is included inside the original code, which already inclused init.php, it should work, at last when included only in the main page (as I tried to do :roll: )

 
TheGoOse
TheGoOse's picture

Joined: 2002-12-31
Posts: 50
Posted: Wed, 2003-02-05 14:33

I have corrected the "Failed opening 'last_updates.php' for inclusion" error. I had left an wrong include-line in view_album.php, since a couple of test I did some time ago. I didn't have anything to do with the latest modifications.

 
.pixelchimp

Joined: 2002-08-19
Posts: 13
Posted: Fri, 2003-02-07 11:16

thanks ppmnt for fixing this issue for me, i was trying to find time to get around to making these changes to the scripts, as i don't use sub-albums on my site it wasn't a priority for me unfortunatly.

good work though, pat on back well deserved!

- pixelchimp
[<!-- BBCode Start --><A HREF="http://www.chaoslibrary.com" TARGET="_blank">www.chaoslibrary.com</A><!-- BBCode End -->]

 
ppmnt
ppmnt's picture

Joined: 2003-01-12
Posts: 238
Posted: Sat, 2003-02-08 03:45
Quote:
thanks ppmnt for fixing this issue for me, i was trying to find time to get around to making these changes to the scripts, as i don't use sub-albums on my site it wasn't a priority for me unfortunatly.

good work though, pat on back well deserved!

- pixelchimp
[<!-- BBCode Start --><A HREF="http://www.chaoslibrary.com" TARGET="_blank">www.chaoslibrary.com</A><!-- BBCode End -->]

Thanks pixelchimp. I didn't want to step on anybody's feet by doing this, I knew you said you were going to get to it at some point... I just couldn't wait! :grin:

Thanks for the original scripts!

 
vpy

Joined: 2002-09-27
Posts: 18
Posted: Mon, 2003-02-10 04:41
Quote:
And here's the updated <!-- BBCode Start --><A HREF="http://www.discobug.com/last-updates.phps" TARGET="_blank">>> last-updates.php <<</A><!-- BBCode End -->.

Hi -- This is really great! I am pretty new to this but I was having a little bit of trouble making the links work within my phpnuke-powered site. Anyway, after a little tweaking, I finally got it to work and I also added a photograph (although that had to be manually selected.). If anyone is interested, I will make the revised code available. If you want to see it, look at http://www.kalorama.net. Anyway, thanks ppmnt and pixelchimp for a very useful script.

 
dtdgoomba

Joined: 2002-11-04
Posts: 185
Posted: Wed, 2003-02-12 04:10

I can't access discobug for the last-updates.php code. Can anyone else? or point me to someone else that has it for download? Thanks!

 
ppmnt
ppmnt's picture

Joined: 2003-01-12
Posts: 238
Posted: Wed, 2003-02-12 05:42
Quote:
I can't access discobug for the last-updates.php code. Can anyone else? or point me to someone else that has it for download? Thanks!

discobug is back up now, try again: <!-- BBCode Start --><A HREF="http://www.discobug.com/last-updates.phps" TARGET="_blank">>>last-updates.php <<</A><!-- BBCode End --> and <!-- BBCode Start --><A HREF="http://www.discobug.com/top10albums.phps" TARGET="_blank"> >> top10albums.php <<</A><!-- BBCode End -->

Well, I've been with this host for 2 years, this is the first time Apache has gone down. That's a pretty good record, I guess. :smile:

~Eva

 
dtdgoomba

Joined: 2002-11-04
Posts: 185
Posted: Wed, 2003-02-12 13:10

Thanks! I'll be playing today, and yes, that is a good long time to have things working well.... :wink:

 
dtdgoomba

Joined: 2002-11-04
Posts: 185
Posted: Wed, 2003-02-12 14:08

Works perfectly in tests. I don't know if anyone else does this, but I use / in my dates on the album names like:

NYC - 5/5/99 and save/read cache functions use / as the separator for each item so the data getting pulled from the cache cut off..

I deleted my cache, changed the lines in the code to use | (since I never use pipe ever) for the save cache function to be (make sure you get all of them):

fwrite($fd, "$nameArray[$currentKey]|$albumName[$currentKey]|$clickArray[$currentKey]n");

and in your read cache function, look for the explode and change it to whatever character you're using, like:

explode("|", $line);

....and no, don't tell me to write my title dates differently, it's easier to do this, then rename all my albums :wink:

 
ppmnt
ppmnt's picture

Joined: 2003-01-12
Posts: 238
Posted: Wed, 2003-02-12 21:28

dtdgoomba -

Yeah, I noticed that too, but then I forgot that I meant to change that before I put them up. Both the top 10 &amp; last updates cache are slash-delimited. And dates are pretty common for album names, I would think...

Thanks for sharing!

 
drazin

Joined: 2002-11-23
Posts: 144
Posted: Tue, 2003-03-04 20:58

hello all!

i'm having a problem with the top 10 and last updates addin.... when i try to use the php i get this error

Warning: readfile(header.html) [function.readfile]: failed to create stream: No such file or directory in /home/drazin/public_html/gallery/last-updates.php on line 87
1917 photos in 47 albums:

and

Warning: readfile(header.html) [function.readfile]: failed to create stream: No such file or directory in /home/drazin/public_html/gallery/top10albums.php on line 72

any ideas?

edit: i took out the line of code that refers to header.html and now it sorta works but it donsent have any info like how many clicks....or when it was updated.....plz help

 
cyberlok
cyberlok's picture

Joined: 2003-01-14
Posts: 6
Posted: Tue, 2003-04-08 06:30

I was wondering if any of you could help me. I have successfully implemented the last updated code now for sometime. But just now for some reason it seems to be freaking out.
Could anyone look at
http://www.cyberlok.org/cyberlok/
tell me what you think let me know in any way I can help with the info.
I just cant seem to figure out what could be causing this bug.

 
JPS

Joined: 2003-03-21
Posts: 8
Posted: Thu, 2003-04-10 15:02

nice hacks, cheers

 
simplythi

Joined: 2003-04-11
Posts: 3
Posted: Fri, 2003-04-11 08:54

ppmnt, who did you feature your sub albums on the main page like that? please help.

 
JPS

Joined: 2003-03-21
Posts: 8
Posted: Sat, 2003-04-12 16:43
Quote:
You're getting this error because your Gallery doesn't have mod_rewrite enabled. This script assumes you have mod_rewrite enabled (not that good). You could solve it by rewriting the part of the script where URLs are created to use the non-mod_rewrite URLS, e.g. inserting "view_album.php?set_albumName=" in the code.

where about exactly does that code go?

 
quiksil903

Joined: 2003-01-06
Posts: 12
Posted: Sun, 2003-04-13 15:42

I'm going to try to bump this because I don't have the foggiest where the mod_rewrite section of code is and whether I should be enabling or disabling it.

More specifically, I am getting the same header errors that drazin was getting:

Quote:
Warning: readfile("header.html") - No such file or directory in /home/httpd/vhosts/trystery.com/httpdocs/gallery/lastupdates.php on line 87)

)

...which you can see <!-- BBCode Start --><A HREF="http://www.trystery.com/gallery/lastupdates.php" TARGET="_blank">here</A><!-- BBCode End -->and <!-- BBCode Start --><A HREF="http://www.trystery.com/gallery/top10albums.php" TARGET="_blank">here</A><!-- BBCode End -->.

Can anyone help? Where is this header file supposed to be? I load other people's lastupdates.php and it does not come with a header errror...

 
adams

Joined: 2003-03-27
Posts: 18
Posted: Wed, 2003-04-23 19:36

I also had the admin seing an odd album name with a javascript edit when I used the last updated mod.

I added the following when getting the album name...

$albumName[$i] = strip_tags(editField($gallery->album, "title", $edit));
$albumName[$i] = str_replace("[edit title]", "", $albumName[$i]);

Which just cleans it up in case the admin happens to be the person who renews the cache.

 
volksport
volksport's picture

Joined: 2002-10-06
Posts: 239
Posted: Thu, 2003-04-24 05:57

ppmnt: which method did you use to count the total albums on your site on the main page?

 
ppmnt
ppmnt's picture

Joined: 2003-01-12
Posts: 238
Posted: Fri, 2003-04-25 21:22
Quote:
ppmnt: which method did you use to count the total albums on your site on the main page?

This thread should help you:

<!-- BBCode Start --><A HREF="http://gallery.menalto.com/modules.php?op=modload&amp;name=phpBB_14&amp;file=index&amp;action=viewtopic&amp;topic=2317&amp;start=0" TARGET="_blank">http://gallery.menalto.com/modules.php?op=modload&amp;name=phpBB_14&amp;file=index&amp;action=viewtopic&amp;topic=2317&amp;start=0</A><!-- BBCode End -->

 
ppmnt
ppmnt's picture

Joined: 2003-01-12
Posts: 238
Posted: Fri, 2003-04-25 21:38
Quote:
ppmnt, who did you feature your sub albums on the main page like that? please help.

simplythi -

Check out <!-- BBCode Start --><A HREF="http://gallery.menalto.com/modules.php?op=modload&amp;name=phpBB_14&amp;file=index&amp;action=viewtopic&amp;topic=1127&amp;9601" TARGET="_blank">>> this thread <<</A><!-- BBCode End --> for info on how to change how many levels of sub-albums are displayed in the sub-albums list. I have mine se to "1", it got to crowded.

Then I made some changes to util.php. I wanted to be able to display the number of clicks in other places, but not in the list of sub-albums on the main gallery page. For me this is around line 1273 int he printChildren function that you modified if you followed the instructions in the linke above. Basically I just commented out the part that gets the number of clicks:

<!-- BBCode Start --><TABLE BORDER=0 ALIGN=CENTER WIDTH=85%><TR><TD><font class="pn-sub">Code:</font><HR></TD></TR><TR><TD><FONT class="pn-sub"><PRE>/* ------ don't display # of hits in sub-album tree!
if (!strcmp($nestedAlbum->fields['display_clicks'], 'yes')) {
$val3 = "(" . pluralize($nestedAlbum->getClicks(), "hit", "0") . ")";
} else {
$val3 = "";
}
------ */ </TD></TR></TABLE><!-- BBCode End -->

I think that should get you started. I also commented out 'echo "<span class=fineprint>";' to make the links a little bigger.

Is this what you were looking for?

 
adams

Joined: 2003-03-27
Posts: 18
Posted: Mon, 2003-04-28 04:59

I have been using this script for the past week and just took it out, I was looking at my httpd processes (1.3.27) and noticed that they were all chewing up a ton of memory.

I did an 'apachectl graceful' and they go back to normal - but as soon as I refresh my top10.php they jump up to about 60mb/process and stay there.

I can refresh my main page without the top10.php include() and the processes stay at the normal 15mb/process.

So - I suspect there is something wrong with the code - especially since it causes the mem jump even when its reading from the cache file (ie not scanning the albums).

http://jadz.com/last10.phps is the code I'm using (with the added functions at the beginning of this thread).

 
ppmnt
ppmnt's picture

Joined: 2003-01-12
Posts: 238
Posted: Mon, 2003-05-05 20:49

adams -

That's strange, I had no such problems (also running 1.3.27). I tried to go check but unfortunatley my web host just implemented jailshell so I can't monitor processes other than my own anymore.

The code itself would be a bit memory intesive, kind of like doing a complicated awk or sort or something that needs through text files. But like you said, that should not be the case if the cache file isn't expired.

Sorry, I can't help you trouble-shoot as I can't monitor Apache anymore. But I know that I didn't have any problems before...

~ppmnt

 
ppmnt
ppmnt's picture

Joined: 2003-01-12
Posts: 238
Posted: Mon, 2003-05-05 21:00
quiksil903 wrote:
I'm going to try to bump this because I don't have the foggiest where the mod_rewrite section of code is and whether I should be enabling or disabling it.

More specifically, I am getting the same header errors that drazin was getting:

Quote:
Warning: readfile("header.html") - No such file or directory in /home/httpd/vhosts/trystery.com/httpdocs/gallery/lastupdates.php on line 87)

)

...which you can see <!-- BBCode Start --><A HREF="http://www.trystery.com/gallery/lastupdates.php" TARGET="_blank">here</A><!-- BBCode End -->and <!-- BBCode Start --><A HREF="http://www.trystery.com/gallery/top10albums.php" TARGET="_blank">here</A><!-- BBCode End -->.

Can anyone help? Where is this header file supposed to be? I load other people's lastupdates.php and it does not come with a header errror...

Sorry it took so long for you to get a response, I didn't see your question right away.

Just comment out the line where it calls header.html:

// write common header elements - text colour etc
readfile("header.html");

It's line 90 for me. Put "//" in front of the second line.

You seem to have another problem as well:

Warning: fopen("/home/virtual/site147/fst/var/www/html/gallery/albums/last-updated.cache", "w") - Permission denied in /home/virtual/site147/fst/var/www/html/gallery/platform/fs_unix.php on line 53

Make sure the cache files are writable by the ID that runs your web server (usually www or nobody).

 
ppmnt
ppmnt's picture

Joined: 2003-01-12
Posts: 238
Posted: Sun, 2003-05-11 22:21
adams wrote:
I also had the admin seing an odd album name with a javascript edit when I used the last updated mod.

I added the following when getting the album name...

$albumName[$i] = strip_tags(editField($gallery->album, "title", $edit));
$albumName[$i] = str_replace("[edit title]", "", $albumName[$i]);

Which just cleans it up in case the admin happens to be the person who renews the cache.

Thanks for the tip!

 
anothersaab

Joined: 2003-05-14
Posts: 3
Posted: Wed, 2003-05-14 04:26

hey everybody, i have 2 quick questions that i haven't been able to find a definitive answer for:

1. http://www.anothersaab.com/gallery/top10albums.php

- what is causing just "Visits" to appear. what am I missing?

2. http://www.anothersaab.com/gallery/last-updates.php

- why are my dates showing up incorrectly. the order is correct, but 3 of the 5show up right and 2 show just a number and 2 have long titles and they are getting chopped.

thoughts?

 
ppmnt
ppmnt's picture

Joined: 2003-01-12
Posts: 238
Posted: Sat, 2003-05-17 18:25

anothersaab -

Looks like you got last-updates to work by now. What was the problem?

Regarding top10albums, can you show your top10albums.php? Just make a copy of it and call it .phps, so we can view the code in the browser.

PS: Great dogs!!! :D

 
anothersaab

Joined: 2003-05-14
Posts: 3
Posted: Sun, 2003-05-18 00:27
ppmnt wrote:
anothersaab -

Looks like you got last-updates to work by now. What was the problem?

Regarding top10albums, can you show your top10albums.php? Just make a copy of it and call it .phps, so we can view the code in the browser.

PS: Great dogs!!! :D

yes, i did get the last-updates corrected. the problem with that was simple. 2 of the albums contained dates with slashes (01/01/2001) and the slashes caused the album name to be truncated and the last update date to read just a number.

here is my top10albums.php: http://www.anothersaab.com/gallery/top10albums.phps

thanks for the dog compliment. as a matter of fact, i just got home from walking them to the coffee shop and i saw your post. thanks for the compliment *and* helping me out.

Tim

 
ppmnt
ppmnt's picture

Joined: 2003-01-12
Posts: 238
Posted: Sun, 2003-05-18 07:27

anothersaab,

OK, thanks for showing your top10albums code, I was hoping it would be fairly obvious. The problem is that you added all those additional functions to the top10albums.php instead of to AlbumDB.php .

Go back to the very first post on this thread and read through it. Then add only the numAllAlbums, getAllAlbum, and getAllVisibleAlbums to AlbumDB.php. I am only showing the other functions as a reference point.

I updated the top10albums.phps file on my site. it now uses pipes ("|") as a delimiter, and even if you are logged in as admin when you refresh the cache you won't get funny characters in your links (thanks to dtdgoomba and adams).

Let me know if it works out for you!

~Eva

 
ppmnt
ppmnt's picture

Joined: 2003-01-12
Posts: 238
Posted: Sun, 2003-05-18 07:50
cyberlok wrote:
I was wondering if any of you could help me. I have successfully implemented the last updated code now for sometime. But just now for some reason it seems to be freaking out.
Could anyone look at
http://www.cyberlok.org/cyberlok/
tell me what you think let me know in any way I can help with the info.
I just cant seem to figure out what could be causing this bug.

cyberlok -

Interesting layout you have at that link. Looks familiar somehow (especially when I do a view source!)

Anyway. To trouble-shoot your problem, go to last-updates.php on your site in a browser (> here <). Then do a "view source" on it. You'll see that it's a bit messed up:

<link rel="stylesheet" type="text/css" href="http://www.cyberlok.org/cyberlok/gallery/css/standalone_style.css.default">

927</b> photos in <b>68</b> albums:
<tr><td><a href=view_album.php?set_albumName=album60 target='_blank'>Minnesota Friends</a><br>  last updated: May 13, 2003
</td></tr><tr><td><a href=view_album.php?set_albumName=album61 target='_blank'>The Kids</a><br>  last updated: May 13, 2003
</td></tr><tr><td><a href=view_album.php?set_albumName=album38 target='_blank'>Photographs</a><br>  last updated: May 11, 2003
</td></tr><tr><td><a href=view_album.php?set_albumName=Family target='_blank'>Family</a><br>  last updated: May 11, 2003
</td></tr><tr><td><a href=view_album.php?set_albumName=album58 target='_blank'>Pictures of Sally</a><br>  last updated: May 11, 2003
</td></tr></table> 

Your stylesheet reference is not inside a <head> tag. It starts table rows but there is no <table> tag. However, at the end there is a close table tag.

When I do the same thing at my site, a view source shows this:

<head>
<link rel="stylesheet" type="text/css" href="/css/gray-purple.css">
</head>
     <b>1997</b> photos in <b>112</b> albums:
     <p>

<table>
<tr><td><a href=http://www.discobug.com/gallery/bday_seaplane_05-02 target='_top'>Sea plane flight over the Bay Area, 5-02</a>
<br><font size=1>&&updated: May 17, 2003
</font size></td></tr>
<tr><td><a href=http://www.discobug.com/gallery/mama_visit_12-02 target='_top'>My mom visits, 12-02</a>
<br><font size=1>&&updated: May 17, 2003
</font size></td></tr>
<tr><td><a href=http://www.discobug.com/gallery/muir_woods_03-02 target='_top'>Muir Woods, 3-02</a>
<br><font size=1>&&updated: May 17, 2003
</font size></td></tr>
<tr><td><a href=http://www.discobug.com/gallery/mike_bday_2002 target='_top'>Mike's birthday, 2-02</a>
<br><font size=1>&&updated: May 17, 2003
</font size></td></tr>
<tr><td><a href=http://www.discobug.com/gallery/2002 target='_top'>2002</a>
<br><font size=1>&&updated: May 17, 2003
</font size></td></tr>
 -- etc --
</table>

It looks like maybe at some point you tried to change the way it is displayed and some tags got screwed up.

This is how the for loop at the end of last-updates.php looks for me:

<table>
<?
   
// for loop reads the data from the arrays and renders it on screen

    for ($i = 0; $i <= 9; $i++) {

         $albumURL = makeGalleryUrl($cacheName[$i]);
         echo ("<tr><td><a href=" . $albumURL . " target='_top'>" . $cacheRealName[$i] . "</a>\n");
         echo ("<br><font size=1>&&updated: " . $cacheDate[$i] .  "</font size></td></tr>\n");
    }

}

?>
</table>

Looks like you need to tweak yours some to make sure you open and close all the tags you need...

Tip: when something goes wrong, a view source usually helps trouble-shoot.

~Eva

 
kyliedog
kyliedog's picture

Joined: 2003-03-02
Posts: 25
Posted: Thu, 2003-07-03 23:17

This script is wonderful and works great. I do have an issue tho, the gallery I am working with is 95% user only and it has a sample gallery. It seems that if a non-user hits the page after the 10 minutes, then they generate a new cache file that shows only the sample gallery as new. Is there a way to specify that the cache is only updated by users?

Thank you

 
fryfrog

Joined: 2002-10-30
Posts: 3236
Posted: Sun, 2003-07-06 05:03

Just wanted to say I updated to your version (with some minor modifications so it fits my site) and its super, thanks for asking. I was hoping something like this would appear and it did. Glad you could do the coding, cause asside from minor cosmetic tweaks I am lost in gallery code :)

If anyone wants to see how it was applied, http://fryfrog.com/ on the left side :)

 
kyliedog
kyliedog's picture

Joined: 2003-03-02
Posts: 25
Posted: Tue, 2003-07-15 07:05

So is that a no?

 
ppmnt
ppmnt's picture

Joined: 2003-01-12
Posts: 238
Posted: Tue, 2003-07-15 17:35

Kyliedog,

I was moving and didn't see your post until now. I apologize. It should be as simple as changing this:

// 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;
    }
}

to this:

// Check the cache file to see if it's up to date
// and if the viewer is logged in as a Gallery user
$rebuild = 1;
if (fs_file_exists(CACHE_FILE)) {
    $stat = fs_stat(CACHE_FILE);
    $mtime = $stat[9];
    if ((time() - $mtime < CACHE_EXPIRED) && ( $gallery->user->isLoggedIn() == True )) {
        $rebuild = 0;
    }
}

This would make it so that the cache is only rebuild if the user viewing the page is logged in. I haven't tested this yet, but it should work fine. Is that what you wanted?

~Eva