Latest Images / Most Viewed Hack

dagman44

Joined: 2004-03-04
Posts: 10
Posted: Mon, 2004-03-08 15:27

I saw a post earlier, but did not see an answer, (or just plain missed it).
I have the stats.php etc installed and it works fine, but I was wondering if I can have it chk only 1 album.
When I upload new pics it is always to a specific album. After a few weeks there I then transfer them out, (to be replaced by new uploads), to a seperate Collection album.
The program picks up not only the newest in the upload album (which is correct) but it also picks up the files which have been recently moved into their permanent albums. (the perm albums see these as new pics on the day they are transferred in.)
Thanks for a lot of work you have abviously put into this app.

Dagman44

 
myriagon

Joined: 2004-01-22
Posts: 130
Posted: Mon, 2004-03-08 20:37

Hi dagman,

I've just hacked some code together that should do what you want. Download the latest version (1.52) from http://www.tearoom.me.uk/stats.tar.gz and use a php input parameter to define the album to filter on. For example to only display views for the "new" album you would use a html link of:

http://awebsite.com/gallery/stats.php?type=views&album=new

If there's no album specified then all gallery images are shown.

Cheers, J

 
myriagon

Joined: 2004-01-22
Posts: 130
Posted: Mon, 2004-03-08 21:01

Hi dagman... thinking again about what you are doing - I wonder if your album of new photos contains sub-albums and you want to include those ones too? If that's the case then get back to me and I will do a minor change (hopefully!) to make it work in that way.

Cheers, J

BTW what's your website address?

 
dagman44

Joined: 2004-03-04
Posts: 10
Posted: Mon, 2004-03-08 23:00

Hey there.
The hack for the newest album works like a charm. It is doing exactly what I was hopeing for.
I do not have sub albums in that newest album so this is all thats reguired. (at this time :-))

 
dagman44

Joined: 2004-03-04
Posts: 10
Posted: Mon, 2004-03-08 23:03

Oops....addy is http://grisier.com/hideaway

This Gallery happens to be password controlled however so will email you a guest entance to see it working. BTW, I also have a Random Pic nlock and have not noticed any problems with adding yours.

Dagman44

 
myriagon

Joined: 2004-01-22
Posts: 130
Posted: Mon, 2004-03-08 23:42

Thanks for sharing your site - looks really cool although the wife's not so convinced! ;)

Cheers, J

 
dagman44

Joined: 2004-03-04
Posts: 10
Posted: Mon, 2004-03-08 23:50

:-)
Well I have the other kind also. This just happens to be the one I am working on at the moment.

But a real big thanks for your expertise...

Dagman44

 
tp
tp's picture

Joined: 2003-03-26
Posts: 104
Posted: Tue, 2004-03-09 04:44

thanks for the hack! i started playing with it tonight and like it....

one thing that i couldnt figure out with my limited abilities is how to make the captions not run all the way across the page.. most of my site will resize to fit the page whatever the resolution etc.. but this most views page runs across the page (only when there are long texted captions on the page..)

i tried editing all kinds of different table widths but there must be something else to it.. or one i missed somewheres... any ideas?

page 1 with a couple long captions:
http://www.tmphillips.com/gallery/stats.php?type=views

page 3 with no long captions:
http://www.tmphillips.com/gallery/stats.php?type=views&page=3

thanks again!

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Tue, 2004-03-09 05:15

tp,
I asked the same question... well sort of:

Quote:
myriagon,
Wonderful script!! Thanks! Now you have given me some work because I put the descriptions where the name of the image is supposed to go! This makes the name of the image too long for the title bar.

and the myriagon said:

Quote:
...To get round the problem of descriptions and titles being transposed, if it was me I would be hacking stats.php. You could use the title in the description field and make it the link to view_photo.php. Then leave the title blank. ....

See this thread:
http://gallery.menalto.com/index.php?name=PNphpBB2&file=viewtopic&p=59477#59477

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Tue, 2004-03-09 05:39

tp,
You might want to upgrade to the latest version it might fix your issue:
The hack can be downloaded from here http://www.tearoom.me.uk/stats.tar.gz

Dave

 
tp
tp's picture

Joined: 2003-03-26
Posts: 104
Posted: Tue, 2004-03-09 16:30

thanks floridave.. i will check it out..

 
myriagon

Joined: 2004-01-22
Posts: 130
Posted: Tue, 2004-03-09 21:08

tp, if the latest version doesn't help as I suspect it won't, have a look at your albums.php code. From surfing your site albums.php seems to work ok. The code that generates the html in stats.php was based on albums.php. So what have I done different to make stats.php not work correctly with your page layout - or has albums.php been changed from a standard install to make that work ok?

Cheers, Jeremy

 
tp
tp's picture

Joined: 2003-03-26
Posts: 104
Posted: Wed, 2004-03-10 01:33

ya myriagon, i see what you are talking about.. comparing to Albums.php i found your line 442..

I changed "nowrap" to "wrap" and all is well..

Thanks!

 
samokk

Joined: 2003-06-25
Posts: 33
Posted: Wed, 2004-03-10 18:28

Hi !

I tried stats.php with the latest gallery CVS.
It looks like it doesn't work..

Fatal error: Call to undefined function: isalbumname() in /mnt/websites/websites/pingoo.ath.cx/gallery/stats.php on line 175

Before that, I had a 1.4.2 gallery, and it was working, except for viewing by votes. It couldn't find some function (getitemsvote() or something like that)

Any idea ?

Sam

PS: I really like this script, you guys did a really good job !!

 
myriagon

Joined: 2004-01-22
Posts: 130
Posted: Wed, 2004-03-10 19:40

tp, glad to hear you found it. I do remember something about changing wrap to nowrap because I wanted the image title (caption) to appear on one line. I'll try changing it back to see if it has any other side effects.

samokk, sounds like someone has removed the isAlbumName function from classes/Album.php That's surprising given the function is called from lots of Gallery files. I'll have a look to see what they have replaced it with.

The viewing by votes code should be switched off as it's dependent on changes I made to several Gallery files. You are welcome to the code but unfortunately it won't work after a Gallery upgrade.

Cheers, J

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Wed, 2004-03-10 19:40

samokk,
The function isalbumname has changed to isalbum. It is in /classes/album.php. Changing it in stats.php might work, but it might change again as the version you are using is beta and changes every night.

Dave

 
myriagon

Joined: 2004-01-22
Posts: 130
Posted: Wed, 2004-03-10 19:49

Thanks Dave - more details here http://cvs.sourceforge.net/viewcvs.py/gallery/gallery/classes/Album.php

I will leave it "as is" for now until the developers release a beta or rc. It would be good though if the same api could be kept for backward compatibility.

Guess I will have to sign up to the developers list to find out what's happening.

Cheers, J

 
tmothy

Joined: 2004-03-06
Posts: 53
Posted: Thu, 2004-03-11 03:06

Questions, How would I get the "Latest pics" to emulate an album on the front page while showing the latest pic as a highlight for the album thumbnail?

Is this possible? or would it take alot of coding.

 
myriagon

Joined: 2004-01-22
Posts: 130
Posted: Thu, 2004-03-11 08:16

The reason why the isAlbumName change is being made can be found here http://sourceforge.net/tracker/index.php?func=detail&aid=903936&group_id=7130&atid=107130

It's going to make it painful to support different versions of Gallery if the underlying api is changing... :( Hopefully this will be resolved by the time we get a release.

 
shoobeedoodoo

Joined: 2004-01-11
Posts: 78
Posted: Fri, 2004-03-12 07:53

Hi again =)

After much testing and with a completely new gallery installation, I am starting to believe that my hosting company is the problem, as stats.php stops working after 710 images exactly. Does this mean a php memory limitation with my host? How do I know if a new hosting company will work for me, like, should I ask them how much php memory they have or what?

Thanks again for all the help!

-Stephen

 
fryfrog

Joined: 2002-10-30
Posts: 3236
Posted: Fri, 2004-03-12 21:20

I really like your "style" with the shadow behind the albums and the total lack of border lines. Would you mind terribly if I based mine on it? I would very much like to make mine look similar. Posting what some of your changes are would make me happy, do you use a theme or did you edit the files?

 
myriagon

Joined: 2004-01-22
Posts: 130
Posted: Fri, 2004-03-12 23:22

tmothy,

I'm not exactly clear about what you're asking for however it does sound very different from what I'm doing now. That suggests it would take a lot of work. Sorry that I can't be more helpful.

Cheers, J

 
myriagon

Joined: 2004-01-22
Posts: 130
Posted: Sat, 2004-03-13 21:23

Hi fryfrog, if you're talking about my website then you are welcome to use the style. I use a "tearoom" skin which I will post on my website hopefully tomorrow when I add a "Software" page.

Cheers, J

 
myriagon

Joined: 2004-01-22
Posts: 130
Posted: Sun, 2004-03-14 11:09

Hi Stephen,

A while ago you pointed me to some code that showed the top 20. That code worked on your site. I have now modified stats.php to use the same method to load albums. The latest version (1.60) is at http://www.tearoom.me.uk/stats.tar.gz Give that a go. I will be very interested to hear how you get on. There's no reason why it shouldn't work now I hope...

Cheers,

Jeremy

 
fryfrog

Joined: 2002-10-30
Posts: 3236
Posted: Mon, 2004-03-15 04:36

Actually, I opened my big mouth and started typing before I hit the books. It turns out that... a) there is a "shadows" option (I was using poleroid), b) there is a "solid line" around thumbs option and c) getting rid of the bars around the tables (or what ever they are) was as easy as finding the right 1px setting in the skin (theme?).

It looks similar to yours, but your "shadow" is quite a bit nicer looking and more pronounced.

I have to say I really love the following picture :)

[img]http://www.tearoom.me.uk/albums/landscapes/P5060231.thumb.jpg[/img]

 
shoobeedoodoo

Joined: 2004-01-11
Posts: 78
Posted: Mon, 2004-03-15 05:14

Hey Jeremy,

Thank you so much for continuing to help me on this and rewriting your code and doing all this extra work just to help me out.

Sadly, the new stats.php does not work in my main gallery, it's just blank =(. However, I tried it on my test gallery, and in my test gallery, it says I have about 700 images, but on the stats.php page, it only says there are like 500 images, I don't know if this helps or not, but thank you so much again for helping me out through all this, I just wish it would work!

Thanks again for any help!

-Stephen

 
myriagon

Joined: 2004-01-22
Posts: 130
Posted: Mon, 2004-03-15 23:57

Hi Stephen,

Thought this could be useful for other people so I will post it here...

Try adding the following to stats.php - anywhere near the top will do.

echo "max_execution_time = ".ini_get("max_execution_time")."<br />";
echo "memory_limit = ".ini_get("memory_limit")."<br />";
echo "post_max_size = ".ini_get("post_max_size")."<br />";
echo "upload_max_filesize = ".ini_get("upload_max_filesize")."<br />";

I'm particular interested to hear what the memory_limit is. Mine is 8M.

Cheers,

Jeremy

 
Terje-
Terje-'s picture

Joined: 2004-01-20
Posts: 90
Posted: Tue, 2004-03-16 01:04

Hey,

While the API is undergoing change, will there be problems using this with new cvs builds?

Fatal error: Call to undefined function: isalbumname() in C:\Inetpub\www.mrx.no\stats.php on line 153

Anyway I can solve this?

Thanks,
Terje

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Tue, 2004-03-16 01:41

myriagon,
Here is my response for the test that you requested.

Quote:
max_execution_time = 30
memory_limit =
post_max_size = 20971520
upload_max_filesize = 20971520

I doubt that I have no memory limit! :D

operating system: FreeBSD 4.8-RELEASE
php version: PHP 4.3.2

Dave

 
fryfrog

Joined: 2002-10-30
Posts: 3236
Posted: Tue, 2004-03-16 04:29

Time to go digging in the php.ini file, cause I think the reason I can't upload big zip files is below :)

max_execution_time = 30
memory_limit = 
post_max_size = 20971520
upload_max_filesize = 20971520
 
fryfrog

Joined: 2002-10-30
Posts: 3236
Posted: Tue, 2004-03-16 04:47

Okay, after digging in php.ini I discovered some stuff. And also from <?php phpinfo(); ?> as well.

From php.ini (these were all modified, then apache2 was restarted)

max_execution_time = 120
memory_limit = 16M
post_max_size = 16M
upload_max_filesize = 100M

From phpinfo();

max_execution_time 120 120 
--disable-memory-limit (a ./configure option)
post_max_size 16M 16M
upload_max_filesize 100M 100M

From stats.php after adding the code to a "debug" section

max_execution_time = 120
memory_limit = 
post_max_size = 20971520
upload_max_filesize = 20971520

So the execution time is increased to 120, the memory limit isn't there (due to the --disable-memory-limit I assume) but the other two values are not the same. Any idea why?

 
bigTrainG
bigTrainG's picture

Joined: 2002-12-26
Posts: 33
Posted: Tue, 2004-03-16 07:24

First) I just added stats.php to my gallery directory and typed in the /url/stats.php

Quote:
837 images in the gallery Pages : 1 2 3 4 5 6 7 8 9 10 Next

Fatal error: Call to undefined function: getcaptionname() in /public_html/gallery/stats.php on line 429

What did I or my site do wrong?

Second) I am running Gal ver 1.34, will this code work with my version?

Thanks,
-w

 
myriagon

Joined: 2004-01-22
Posts: 130
Posted: Tue, 2004-03-16 08:13

fryfrog,

My system level php knowledge is very limited but there's some coupling between the different system values that may explain what you're seeing - more info at http://www.phpworld.com/manual2003/configuration.directives.html

Cheers, J

 
myriagon

Joined: 2004-01-22
Posts: 130
Posted: Tue, 2004-03-16 08:38

bigTrainG

My guess is that the problem is caused by running with v1.34. I've never tried that before. A quick solution that should work is to comment out the line of code. This will not break stats.php. Just insert "//"

      $statsCaption = $statsAlbum->getCaption($photoIndex);
 //  $statsCaption .= $statsAlbum->getCaptionName($photoIndex);

It's possible there are other incompatibilities too but that's worth a try.

Cheers, J

 
fryfrog

Joined: 2002-10-30
Posts: 3236
Posted: Tue, 2004-03-16 15:03

I will let this link explain how to fix the upload limit and actually get those values to change :)

 
bigTrainG
bigTrainG's picture

Joined: 2002-12-26
Posts: 33
Posted: Tue, 2004-03-16 16:37

I tried commenting out that function call, but another error pops up on line 444.

I guess they have renamed some of the function calls in the core gallery code??

thanks

 
rizzay

Joined: 2003-07-25
Posts: 36
Posted: Tue, 2004-03-16 17:52

Hi all,

I have implemented this wonderful script on my site but I was wondering if there is a way to change the capture date format. Currently it's showing the capture date as 22/10/2003 when the picture was really taken 10/22/2003. Is there any way to change that?

Here is a link to my site: http://photos.rizzay.com/ and click on "Newest Photos" on the right.

Thanks!

 
Terje-
Terje-'s picture

Joined: 2004-01-20
Posts: 90
Posted: Tue, 2004-03-16 19:05

Hey again,

My gallery is www.mrx.no
http://www.mrx.no/stats.php?type=date <- seems to be limited to only one album? Any idea why?

Terje

 
myriagon

Joined: 2004-01-22
Posts: 130
Posted: Tue, 2004-03-16 21:46

Terge, try using the previous version of stats.php. That one is less coupled to the Gallery api than the latest version. You can download it from www.tearoom.me.uk/stats.1.52.tar.gz If that doesn't work then I recommend that you use a stable version of Gallery unless you have a very good reason to be at the bleeding edge. BTW what did you do to workaround the undefined function isalbumname()

rizzay, I've made a minor mod to do what you want. Download the latest version (1.61) from www.tearoom.me.uk/stats.tar.gz It now defaults to US date format. I stopped it showing the century to be consistent with the upload date. If anyone wants the UK date format there's a variable at the top - $captureDateFormat that needs changing to do this.

bigTrainG, if you can, I suggest upgrading Gallery although I must say that I don't like that idea myself given all the changes that I've made to the standard 1.4.1 code! If you don't want to upgrade and you know php, have a look at albums.php - stats.php uses a lot of code from albums.php for the display. What you need to do is transplant the relevant section of albums.php into stats.php.

fryfrog, thanks for posting that link. Hopefully it will help Shoobee... if indeed his problem is a resource one. BTW that photo you love was one of the few taken by my wife. She was very pleased to hear that you like it :)

 
Terje-
Terje-'s picture

Joined: 2004-01-20
Posts: 90
Posted: Tue, 2004-03-16 22:18

Thanks myriagon, works like a charm! :-)

isalbumname(), just changed the line to isalbum() and it worked.

I truely love this last updated. :-)

Terje

 
Terje-
Terje-'s picture

Joined: 2004-01-20
Posts: 90
Posted: Tue, 2004-03-16 22:32

myriagon, is it difficult to include last comments hack in the stats.php?

Best Regards,
Terje

 
shoobeedoodoo

Joined: 2004-01-11
Posts: 78
Posted: Tue, 2004-03-16 22:46

Hey Jeremy,
Adding the resource code to the top of stats.php, I get fhe following:

max_execution_time = 50000
memory_limit = 40M
post_max_size = 8M
upload_max_filesize = 20M

Warning: Cannot send session cookie - headers already sent by (output started at /homepages/35/d93413898/htdocs/gallery/stats.php:46) in /homepages/35/d93413898/htdocs/gallery/session.php on line 60

Warning: Cannot send session cache limiter - headers already sent (output started at /homepages/35/d93413898/htdocs/gallery/stats.php:46) in /homepages/35/d93413898/htdocs/gallery/session.php on line 60

Do you think that's enough memory, or is my memory amount the main culprit behind my problems?

I've tried editing .htaccess but whenever I do, I get an error 500:internal server error. Furthermore, I do not have access to the php.ini file as my web hosting company does not allow access to it.

Thanks agian for all the help!

-Stephen

 
myriagon

Joined: 2004-01-22
Posts: 130
Posted: Tue, 2004-03-16 23:33

Hi Stephen,

It could be the memory. I've just tested my server again and it is unlimited now - not 8M as I said before. Maybe I confused the memory with another setting or something has changed on my ISP's server. Anyway try adding this code near the top of stats.php...

if (ini_set("memory_limit", "100M"))
    echo "Set memory limit<br>";
else
    echo "couldn't set memory limit<br>";

echo "memory_limit set to = ".ini_get("memory_limit")."<br>";

I'm not sure if you will be able to set the memory but it's worth a try. You could also try using "-1" instead of "100M", or even "-1M" (not sure of the correct syntax).

Regards,

Jeremy

 
shoobeedoodoo

Joined: 2004-01-11
Posts: 78
Posted: Wed, 2004-03-17 04:06

Hey Jeremy,
I get this when I add the new memory code to the top of stats.php:

Set memory limit
memory_limit set to = 100M

Warning: Cannot send session cookie - headers already sent by (output started at /homepages/35/d93413898/htdocs/gallery/stats.php:46) in /homepages/35/d93413898/htdocs/gallery/session.php on line 60

Warning: Cannot send session cache limiter - headers already sent (output started at /homepages/35/d93413898/htdocs/gallery/stats.php:46) in /homepages/35/d93413898/htdocs/gallery/session.php on line 60

After doing this, I tried increasing the number of albums by one, from 6 to 7, in your stats.php, but it still doesn't work, should I try setting the memory limit higher? It's encouraging that it actually says that the memory limit was set, so perhaps you're on the right track?

Thanks again!

-Stephen

 
myriagon

Joined: 2004-01-22
Posts: 130
Posted: Wed, 2004-03-17 23:46

Hi Stephen,

I don't think memory is the issue. 100M should be more than enough. I'll have a look at the other parameters to see if there's anything else that could be causing your issue. Unfortunately I'm no expert on php settings. It might be worth posting on a php forum. Someone there might have an idea.

Regards,

Jeremy

 
myriagon

Joined: 2004-01-22
Posts: 130
Posted: Wed, 2004-03-17 23:49

Terge - is this the hack you were thinking of?

Cheers,

Jeremy

 
shoobeedoodoo

Joined: 2004-01-11
Posts: 78
Posted: Fri, 2004-03-19 05:49

Hey Jeremy,
I found the following resource limits from my provider (1and1.com - the free 3-year hosting promotion they had):

--------------------------------------------------------------------------------------------
Important: Please optimize your scripts relative to memory usage and CPU time. Our system automatically stops scripts that use too many system resources.

Programming Limits:

Professional Package CPU : 6 seconds @ 100%
Memory : 10240KB (10MB)
Numerical Processes : 12
---------------------------------------------------------------------------------------------

Is this perhaps the reason behind stats.php not working for me?

Thanks!

-Stephen

 
bificypdog

Joined: 2004-03-15
Posts: 26
Posted: Fri, 2004-03-19 18:58

Nice Stuff.
I like this gallery and thanx to the developers.

I am using stats.php in my Gallery-Module.

Postnuke 7.26
Gallery 1.4.2

I modified gallery\index.php and included the stats.php.

Quote:
$safe_to_include =
array(

"add_comment.php",
"add_photo.php",
"add_photos.php",
"album_permissions.php",
"albums.php",
"block-random.php",
"captionator.php",
"copy_photo.php",
"create_user.php",
"delete_album.php",
"delete_photo.php",
"delete_user.php",
"do_command.php",
"edit_appearance.php",
"edit_caption.php",
"edit_field.php",
"edit_thumb.php",
"extra_fields.php",
"gallery_remote.php",
"gallery_remote2.php",
"highlight_photo.php",
"login.php",
"manage_users.php",
"modify_user.php",
"move_album.php",
"move_photo.php",
"multi_create_user.php",
"photo_owner.php",
"poll_properties.php",
"poll_results.php",
"progress_uploading.php",
"publish_xp.php",
"publish_xp_docs.php",
"register.php",
"rename_album.php",
"reset_votes.php",
"resize_photo.php",
"rotate_photo.php",
"save_photos.php",
"search.php",
"stats.php",
"slideshow.php",
"slideshow_low.php",
"sort_album.php",
"upgrade_album.php",
"upgrade_users.php",
"user_preferences.php",
"view_album.php",
"view_comments.php",
"view_photo.php",
"view_photo_properties.php"

);

I want to user the stats.php within my postnuke-module.

This URL is working:

http://mysite.com/modules.php?type=&page=1&op=modload&name=gallery&file=index&include=stats.php

But I want to user the following commands:

Quote:
stats.php?type=views [sorts by most viewed image first]
stats.php?type=date [sorts by the latest added image first]
stats.php?type=cdate [sorts by image capture date]

So I enter the following URL:

http://mysite.com/modules.php?type=&page=1&op=modload&name=gallery&file=index&include=stats.php?type=views

But it doesn't work.
I get the following error:

Quote:
Fatal error: Call to undefined function: _() in C:\xampp\htdocs\postnuke\modules\gallery\index.php on line 127

I think that the ?type... vars are not working like I want.

Any idea?

 
myriagon

Joined: 2004-01-22
Posts: 130
Posted: Fri, 2004-03-19 23:02

Hi Terge,

Thanks for the suggestion to display recent comments - hope you like the result

It's cool to be able to see all your Gallery comments in one place and should encourage people to post new comments. I wasn't sure about having a link to the Add Comment window. I left it out for now. Maybe it should be configurable if the Add Comment link appears or not.

The latest code (1.70) can be found at www.tearoom.me.uk/stats.tar.gz

If you want to get this working with the bleeding edge Gallery version then try changing:

$albumDB = new AlbumDB(FALSE);
if ($debug >= 2)
{
        echo "Retrieved album database.<br>";
}

//$list = $albumDB->albumList;
// Retrieve all albums and store in list array.
// This can be done using new AlbumDB() but this doesn't work
// on all hosts.
$numTopAlbums = $albumDB->numAlbums($gallery->user);
for ($i = 1; $i<=$numTopAlbums; $i++)
{
        $topAlbum = $albumDB->getAlbum($gallery->user, $i);
        $list[] = $topAlbum;
        recurseAlbums( $topAlbum );
}

to...

$albumDB = new AlbumDB();
if ($debug >= 2)
{
        echo "Retrieved album database.<br>";
}

$list = $albumDB->albumList;

Cheers,

Jeremy

 
myriagon

Joined: 2004-01-22
Posts: 130
Posted: Fri, 2004-03-19 23:18

Hi Stephen,

Well done for finding that info. My guess is that you are hitting the 10MB memory limit. I'm thinking about optimising stats.php particularly for performance and possibly for memory too - assuming I can do that without making the code unmaintainable.

Cheers,

Jeremy