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

ppmnt
ppmnt's picture

Joined: 2003-01-12
Posts: 238
Posted: Thu, 2003-12-11 17:13
dc2447 wrote:
iateyourmicrophone wrote:
it looks working to me?

It's still not right - some of the albums don't have last updated time in the listing.

Something is wrong somewhere

http://cpfc.org/gallery/last-updates.php

Hey! It looks like it's still not quite right. Can you post the URL to your cache file, or just let us know where your "albums" directory is? It looks like it's not http://cpfc.org/albums/. I'd like to take a look at the cache file.

Also, could you make a copy of last-updates.php and call it last-updates.phps, just so we can verify the code?

Thanks,
~Eva

 
dc2447

Joined: 2002-09-22
Posts: 130
Posted: Thu, 2003-12-11 17:19
ppmnt wrote:
dc2447 wrote:
iateyourmicrophone wrote:
it looks working to me?

It's still not right - some of the albums don't have last updated time in the listing.

Something is wrong somewhere

http://cpfc.org/gallery/last-updates.php

Hey! It looks like it's still not quite right. Can you post the URL to your cache file, or just let us know where your "albums" directory is? It looks like it's not http://cpfc.org/albums/. I'd like to take a look at the cache file.

Also, could you make a copy of last-updates.php and call it last-updates.phps, just so we can verify the code?

Thanks,
~Eva

Hi Eva :)

source:
http://cpfc.org/gallery/last-updates.phps

Cache
http://cpfc.org/gallery/albums/last-updated.cache

Thanks again

 
ppmnt
ppmnt's picture

Joined: 2003-01-12
Posts: 238
Posted: Thu, 2003-12-11 18:09
dc2447 wrote:
ppmnt wrote:
Hey! It looks like it's still not quite right. Can you post the URL to your cache file, or just let us know where your "albums" directory is? It looks like it's not http://cpfc.org/albums/. I'd like to take a look at the cache file.

Also, could you make a copy of last-updates.php and call it last-updates.phps, just so we can verify the code?

Thanks,
~Eva

Hi Eva :)

source:
http://cpfc.org/gallery/last-updates.phps

Cache
http://cpfc.org/gallery/albums/last-updated.cache

Thanks again

Hey there,

Looking at your cache file, you see these two lines:

cpfc=vs=villa|Aston Villa 3-0 CPFC
|12/05/03

It looks like the title of your "Aston Villa 3-0 CPFC" album has a new line character in it. :o

To verify this, I modified the title of an album on my site by just hitting enter at the end of the title. Notice the first two lines of the cache file (different date format as I'm still limping along on v1.3.3):

your_photos|Your Photos
|Dec 11, 2003

Displaying the script in the browser ended up looking like this:

2293 photos in 129 albums:

Your Photos
  updated:
Dec 11, 2003
  updated:
My Birthday, 5-03
  updated: Dec 09, 2003

So, can you go to the Aston Villa Album, select "edit title", and verify that the description does not have a new line character in it?

To verify, make sure you get a new cache file. In last-updates.php change CACHE_EXPIRED to 1 temporarily:

//define(CACHE_EXPIRED, 43200);
define(CACHE_EXPIRED, 1);

Then refresh the page. It should update your cache file. Then change CACHE_EXPIRED back to the old value to improve performance.

Let me know how it goes!
~Eva :D

 
dc2447

Joined: 2002-09-22
Posts: 130
Posted: Thu, 2003-12-11 19:07

Hi Eva - I changed the title of the Villa album and uodated the cache but still have the problem :(

I checked and made sure there were no newline character either.

source:
http://cpfc.org/gallery/last-updates.phps

Cache
http://cpfc.org/gallery/albums/last-updated.cache

 
maddys_daddy

Joined: 2003-12-07
Posts: 17
Posted: Sat, 2003-12-13 19:00

I'm getting the same error as the guy at the top of page 10 of this thread:

Quote:
Fatal error: Call to undefined function: numallalbums() in /hsphere/local/home/XXXXXXXXX/thewisemanfamily.com/gallery/last-updates.php on line 188

Yes, I did copy the 3 functions and pasted them into AlbumDB.php. I pasted them after the last original function.
Here's the page that I'm testing this on: http://www.thewisemanfamily.com/index4.html
I'm trying to put it in the small IFRAME on the left.
My last-updates.php file is in my gallery/ directory.
FWIW, I'm running Gallery 1.4.1.
Please help!
--Adam

 
ppmnt
ppmnt's picture

Joined: 2003-01-12
Posts: 238
Posted: Sun, 2003-12-14 03:03
maddys_daddy wrote:
I'm getting the same error as the guy at the top of page 10 of this thread:

Quote:
Fatal error: Call to undefined function: numallalbums() in /hsphere/local/home/XXXXXXXXX/thewisemanfamily.com/gallery/last-updates.php on line 188

Yes, I did copy the 3 functions and pasted them into AlbumDB.php. I pasted them after the last original function.
Here's the page that I'm testing this on: http://www.thewisemanfamily.com/index4.html
I'm trying to put it in the small IFRAME on the left.
My last-updates.php file is in my gallery/ directory.
FWIW, I'm running Gallery 1.4.1.
Please help!
--Adam

Adam,

If you copied the functions then this is really strange. Just so we can see the code and make sure all is in order, could you make copies of your AlbumDB.php and last-updates.php and make the extension .phps?

That should help troubleshooting.

 
ppmnt
ppmnt's picture

Joined: 2003-01-12
Posts: 238
Posted: Sun, 2003-12-14 03:09
dc2447 wrote:
Hi Eva - I changed the title of the Villa album and uodated the cache but still have the problem :(

I checked and made sure there were no newline character either.

source:
http://cpfc.org/gallery/last-updates.phps

Cache
http://cpfc.org/gallery/albums/last-updated.cache

Hey,

That's really strange. After seeing the cache file I don't think it has anything to do with the script. It works fine for all other albums and since I was able to reproduce it I was convinced that was the case. Are you absolutely sure there isn't a strange character somewhere in that album title? A new line or a carriage return?

I'll ponder this some more, but I can't think of another reason for this to happen right now. :-?

 
maddys_daddy

Joined: 2003-12-07
Posts: 17
Posted: Sun, 2003-12-14 04:58

Nevermind. I figured out what I did wrong. I pasted the modified functions outside of the function section, after the last closing bracket. Duh! Guess I should have read ppmnt's instructions a little more closely. Works like a champ now.
Now for the tweaking. I need to figure out how to changed the display font. Any suggestions?
Thanks!
And thanks ppmnt for the work.

 
desp

Joined: 2003-12-14
Posts: 6
Posted: Mon, 2003-12-15 01:06

I have problems with the last-updates.php

At first i got the error message:
Fatal error: Allowed memory size of 41943040 bytes exhausted (tried to allocate 65537 bytes) in /homepages/14/d50951116/htdocs/_gallery/util.php on line 271

Fatal error: Allowed memory size of 41943040 bytes exhausted (tried to allocate 64 bytes) in Unknown on line 0

and now it says error 500: internal servererror (perhaps from the provider?)

what is it with the cachefile? i don't found one.

the link is http://www.tarmgallery.de/last-updates.php
the source code is viewable at http://www.tarmgallery.de/last-updates.phps

Maybe someone can help me. Thanx.

 
ppmnt
ppmnt's picture

Joined: 2003-01-12
Posts: 238
Posted: Mon, 2003-12-15 18:45
maddys_daddy wrote:
Nevermind. I figured out what I did wrong. I pasted the modified functions outside of the function section, after the last closing bracket. Duh! Guess I should have read ppmnt's instructions a little more closely. Works like a champ now.
Now for the tweaking. I need to figure out how to changed the display font. Any suggestions?
Thanks!
And thanks ppmnt for the work.

LOL, OK, that's good. I'm glad you figured it out. :D

Re: display changes. Two ways: If you us an include on your web site then it would pick up the formatting from the page it is embedded in.

If you use an iframe (looks like that's what you're doing), you can just uncomment (remove the //) this line in last-updates.php:

//readfile("header.html");

Then create a file called header.html in your gallery directory and put any formatting in that. You could even just put a reference to your stylesheet in that file.

~Eva

 
ppmnt
ppmnt's picture

Joined: 2003-01-12
Posts: 238
Posted: Mon, 2003-12-15 21:42

desp,

The cache file should be in your albums directory (by default /albums), and is called last-updated.cache.

Could you explain your directory structure? I'd like to clarify. Is it the default, which would be:

/gallery - gallery install directory
/albums - albums directory, images and cache files

If this is the case, then last-updates.php should be in your /gallery directory, not in your document root as it seems to be now. Try moving it to your /gallery directory. :wink:

~Eva

 
desp

Joined: 2003-12-14
Posts: 6
Posted: Tue, 2003-12-16 00:54

The directory structure is

/_gallery - gallery install directory
and from then everything is normal like /albums for albums, images and so on.

The domain www.tarmgallery.de links directly to the _gallery.

Gallery Version is 1.3.3 and there is no cache file in the albums directory. Maybe this is the reason. Do i have to change the rights (chmod) or fix other things?

 
dc2447

Joined: 2002-09-22
Posts: 130
Posted: Wed, 2003-12-17 18:51
ppmnt wrote:
dc2447 wrote:
Hi Eva - I changed the title of the Villa album and uodated the cache but still have the problem :(

I checked and made sure there were no newline character either.

source:
http://cpfc.org/gallery/last-updates.phps

Cache
http://cpfc.org/gallery/albums/last-updated.cache

Hey,

That's really strange. After seeing the cache file I don't think it has anything to do with the script. It works fine for all other albums and since I was able to reproduce it I was convinced that was the case. Are you absolutely sure there isn't a strange character somewhere in that album title? A new line or a carriage return?

I'll ponder this some more, but I can't think of another reason for this to happen right now. :-?

The problem was that the script barfes if there is no description for the album . . .

But I am still having problems

http://cpfc.org/gallery/last-updates.php

 
desp

Joined: 2003-12-14
Posts: 6
Posted: Wed, 2003-12-24 01:40

@Eva

No clue or still too less informations?

 
ppmnt
ppmnt's picture

Joined: 2003-01-12
Posts: 238
Posted: Wed, 2003-12-24 02:12
desp wrote:
@Eva

No clue or still too less informations?

Hi,

Sorry I haven't replied. I saw your message, but haven't had time to investigate. Last week was crazy at work, no time for play, and I'm out of town this week.

No chmod should be needed, because the web server can already write to the albums directory, so it should be able to write the cache. Is there no .cache file anywhere?

is _gallery your document_root? So when I go to tarmgallery.de, it calls albums.php? or do you have an index.php or .html that redirects?

Sorry I'm kind of thin spread right now...

~Eva

 
desp

Joined: 2003-12-14
Posts: 6
Posted: Wed, 2003-12-24 19:39

@Eva

Ok, just wanted to know that you are still alive. :wink:

I don't see any .cache file in the directories. :-(

There is an index.php in the root that redirects to _gallery.

Merry X-Mas to all.

 
clydejones
clydejones's picture

Joined: 2003-11-16
Posts: 6
Posted: Thu, 2003-12-25 03:11

I have both Random-block.php and top10albums.php installed.

Individually they work fine but I can't get them to work when they are both on the same page.

I keep getting an error that says "can't initialize "savecache" because it was already initialized by whichever I have listed first on the page.

I thought I'd solved this by renaming the "savecache, readcache and scanalbums" in whatever was listed second on the page but all I get then is "viewed" and no other information shows up in the top10albums call.

is there an easy to solve this?

Any information appreciated

Clyde Jones

 
Neone

Joined: 2003-12-28
Posts: 54
Posted: Sun, 2003-12-28 18:31

First, thanx for a great "hack". I got it to work and everything.
But I don't need 10 last updated albums. Only 3 or 5.
And I don't want the hack to scan for my subalbums since I name my root albums like this:

2003-12-20 - Karma 2 (Skazi)

and the subalbums like this:

UvPucko Crew *or* Smuts *or* Pornstar

Take a look at my gallery at http://www.UvPucko.com instead, then you'll get me ;)
Enter the album called Karma2 or Husmusarna.

Since I don't know a frickin shit about PHP, maybe someone could tell me what to do? :)

http://www.uvpucko.com/gallery/last-updates.php
That's not that hot you know :P

 
ppmnt
ppmnt's picture

Joined: 2003-01-12
Posts: 238
Posted: Mon, 2004-02-23 17:05
clydejones wrote:
I have both Random-block.php and top10albums.php installed.

Individually they work fine but I can't get them to work when they are both on the same page.

I keep getting an error that says "can't initialize "savecache" because it was already initialized by whichever I have listed first on the page.

I thought I'd solved this by renaming the "savecache, readcache and scanalbums" in whatever was listed second on the page but all I get then is "viewed" and no other information shows up in the top10albums call.

is there an easy to solve this?

Any information appreciated

Clyde Jones

Clyde,

You've probably given up by now. I didn't get any emails anymore from gallery when new posts were added to this. In addition, I kind of disappeared into a black hole for a while with work just going soooo crazy.

Anyway, Clyde, you are on the right track with renaming all functions. Also, look for anything that says "define". Those need to be renamed as well. So for example in top10albums.php you have

// set the cache file name
define(CACHE_FILE, $gallery->app->albumDir . "/top10.cache");

// here we rebuild the cache file every 12 hours (43200 seconds)
define(CACHE_EXPIRED, 43200);

Change these to:

// set the cache file name
define(TOP10_CACHE_FILE, $gallery->app->albumDir . "/top10.cache");

// here we rebuild the cache file every 12 hours (43200 seconds)
define(TOP10_CACHE_EXPIRED, 43200);

Also change all other occurances of CACHE_FILE to TOP10_CACHE_FILE, and all other occurances of CACHE_EXPIRED to TOP10_CACHE_EXPIRED

Give that a try :D

 
ppmnt
ppmnt's picture

Joined: 2003-01-12
Posts: 238
Posted: Mon, 2004-02-23 17:14
Neone wrote:
First, thanx for a great "hack". I got it to work and everything.
But I don't need 10 last updated albums. Only 3 or 5.
And I don't want the hack to scan for my subalbums since I name my root albums like this:

2003-12-20 - Karma 2 (Skazi)

and the subalbums like this:

UvPucko Crew *or* Smuts *or* Pornstar

Take a look at my gallery at http://www.UvPucko.com instead, then you'll get me ;)
Enter the album called Karma2 or Husmusarna.

Since I don't know a frickin shit about PHP, maybe someone could tell me what to do? :)

http://www.uvpucko.com/gallery/last-updates.php
That's not that hot you know :P

Neone -

First of all, if you don't want the script to be recursvie, you need to use the original version by pixelchimp. The whole point of this thread is to expand that script and make it recursive. The old one used to be on transitgallery, but it looks like he is not using gallery anymore and has taken down the files downloads section. Just look for the original last-updates.php, that one wasn't recursive.

Regarding changing the number of albums displayed, find this at the end of the script:

// 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>&amp;&amp;updated: " . $cacheDate[$i] .  "</font size></td></tr>\n");
    }

and change the 9 to the number you want -1. For example, if you want to show 5 albums, change this to a 4.

Hope this helps.

 
ppmnt
ppmnt's picture

Joined: 2003-01-12
Posts: 238
Posted: Tue, 2004-03-02 06:18

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 have updated the first post of this thread.

 
ppmnt
ppmnt's picture

Joined: 2003-01-12
Posts: 238
Posted: Sat, 2004-06-12 22:33

All,

Just a quick update to let you know that I've revamped my web site. In the process I tried to make the >> gallery help << section a little easier to use. You'll still find these scripts (latest versions) and instructions there.

Hope you like it.

 
dc2447

Joined: 2002-09-22
Posts: 130
Posted: Sun, 2004-06-13 21:00

ppmnt - excelllent work.

Two quick questions on the last updates:

1: Can last updates be made to spit the dates out in European format rather than american?

2: Can the updates exlude views?

Thanks gain for a great job

 
ppmnt
ppmnt's picture

Joined: 2003-01-12
Posts: 238
Posted: Mon, 2004-06-14 05:32

dc2447,

Thanks a lot.

1) Strangely enough, theoretically it should be returning the date format in the default format for your locale. When did you download the script? If you have the latest version you'll notice a comment on March 9 saying that I fixed this.

If you do have the latest version, it could be that the web server hosting your site is not set to the same locale as your country. In that case you can hard-code the date format as follows:

Inside the function saveCacheLXU, which in the latest version starts in line 134, you'll find these lines, starting in line 155:

        $currentKey = key($dateArray);
        $keyDate = strftime("%x","$dateArray[$currentKey]");
        fwrite($fd, "$nameArray[$currentKey]|$albumName[$currentKey]|$keyDate\n");

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

         $current = next($dateArray);
         $currentKey = key($dateArray);
         $keyDate = strftime("%x","$dateArray[$currentKey]");
         fwrite($fd, "$nameArray[$currentKey]|$albumName[$currentKey]|$keyDate\n");

Simply replace both occurances of:

$keyDate = strftime("%x","$dateArray[$currentKey]");

with:

$keyDate = strftime("%d.%m.%Y","$dateArray[$currentKey]");

This will display today's date as 13.6.2004 instead of 6/13/04. If you'd like 04 instead of 2004, simply use a lower case y.

Your cache file will still have the old format in it, so you'll have to force it to refresh the cache file. Simply ste $cache_expire to 0, then refresh the page, then set $cache_expire to a high value again.

2) Unfortunately it is hard to determine what has changed in an albu. Once gallery uses a mysql database to store its data (Gallery2) this will be easier, but at this point the script simply uses a function of gallery which will include changes like the view count. Sorry I can't help you more with that one.

Anyway, I hope the date works for you.

~Eva

 
dc2447

Joined: 2002-09-22
Posts: 130
Posted: Mon, 2004-06-14 09:31

eva - the locale on my server is wrong for PHP but your fix works lovely.

Thanks again

 
dc2447

Joined: 2002-09-22
Posts: 130
Posted: Mon, 2004-06-14 21:51

eva - just fyi - I had to remove this script as the loading on my webserver was too high even with the cache set to doublew the suggested value :(

 
ppmnt
ppmnt's picture

Joined: 2003-01-12
Posts: 238
Posted: Mon, 2004-06-14 23:26

dc2447,

???

That's impossible, there should only be a load on your server fi the cache has to be rebuilt. If there is a chache file that has not yet expired the script is so minor, it's almost like loading a static page! Basically, if the cache file is not expired, all it does is read ten lines and display them. Compared to running something as complicated as gallery, this would be as much effort to a web server as it is for you to blink. The only time there would be more to do (still minor though, just takes a second) is when a new cache file is created. I'm running multiple scripts doing similar things on the same page...

Are you sure it's topXalbums that's causing the problem? What is your $cache_expire set to?

 
dc2447

Joined: 2002-09-22
Posts: 130
Posted: Fri, 2004-06-25 21:18
ppmnt wrote:
dc2447,

Are you sure it's topXalbums that's causing the problem? What is your $cache_expire set to?

It's definately this script - it doubles the loading on my server - even with a really long cache expire it causes problems - a real shame as I need the iscript to work

$cache_expire = 93200;

 
TqUiSh

Joined: 2004-08-31
Posts: 4
Posted: Tue, 2004-09-07 15:22

Hi!

The dates in the lastXupdates list is completely wacked. An examle is 24-01-2033. They are all many years into the future and the days are also wrong. And actually, the albums listed are not the last updated ones.

Any idea why this is happening?

TqUiSh

 
ppmnt
ppmnt's picture

Joined: 2003-01-12
Posts: 238
Posted: Tue, 2004-09-07 17:25

TqUiSh,

Please make sure you alays include a link you your gallery so folks can look at it to troubleshoot. I found your old post with the link...

Do you have shell access to the server? You should make sure the date is correct on the server. If the year is so far off it shouldn't have to do with your locale...

 
fryfrog

Joined: 2002-10-30
Posts: 3236
Posted: Tue, 2004-10-05 02:58

removed.

 
ppmnt
ppmnt's picture

Joined: 2003-01-12
Posts: 238
Posted: Tue, 2004-10-05 17:30

Could a moderator please move fryfrog's post into the Album list thread
( http://gallery.menalto.com/index.php?name=PNphpBB2&file=viewtopic&t=21354)

I will reply there.

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Tue, 2004-10-05 18:22

ppmnt,
I can't move posts to other threads but I can split them to a new topic.

I can however delete posts so if fryfrog, has the OK then I will delete this and ppmnt's and fryfrog's posts as to keep this thread on track and now multi pages unrelated info.

ppmnt,
If you want to start a new thread with this topic and I can lock this one and point to the new topic if you wish as well. You are the maintainer of this mod so it is up to you.

Dave

 
ppmnt
ppmnt's picture

Joined: 2003-01-12
Posts: 238
Posted: Tue, 2004-10-05 23:38
floridave wrote:
ppmnt,
I can however delete posts so if fryfrog, has the OK then I will delete this and ppmnt's and fryfrog's posts as to keep this thread on track and now multi pages unrelated info.

Sounds good to me. I already copied fryfrog's post as a quote to the correct thread and answered there.

floridave wrote:
ppmnt,
If you want to start a new thread with this topic and I can lock this one and point to the new topic if you wish as well. You are the maintainer of this mod so it is up to you.

Sure, sounds good. In fact, I created two new threads:
Solution: Top X Albums (incl. sub-albums) -- continued
Solution: Last X Album Updat (incl. sub-albums) -- continued

(Darn, I mistyped "Updates" in the thread title! Any chance you can fix that?)

You can now go a head and lock this thread. Thanks! :-)

 
ppmnt
ppmnt's picture

Joined: 2003-01-12
Posts: 238
Posted: Tue, 2004-10-05 23:40

All,

In an attempt to make this topic a little more organized, and since a lot of the info in this thread has been updated, I've created two new threads:

Solution: Top X Albums (incl. sub-albums) -- continued

Solution: Last X Album Updates (incl. sub-albums) -- continued

This thread will now be locked, so please use the two new threads for any more questions, comments, etc.

Thanks!
~Eva / ppmnt / discobug