Advanced search  

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Pages: [1]   Go Down

Author Topic: How many gallery members?  (Read 4621 times)

0 Members and 1 Guest are viewing this topic.

hama

  • Contributor
  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 229
How many gallery members?
« on: March 08, 2005, 08:25:35 pm »


Hi

I would like to make visible (on my startpage, not on the startpage of the gallery) how many users are registered in my gallery.

I did it with "How many pictures" and with "How many hits" but with "Registered users" I can't find the solution.

Solution for "Pictures":

Code: [Select]
<?php
// gallery_pics
$gallery_pics implode(''$_gallery->fetch_first('SELECT COUNT(*) FROM cpg132_pictures AS p, cpg132_albums AS a WHERE p.aid = a.aid '));
?>


Solution for "Hits":

Code: [Select]
<?php
// gallery hits
$gallery_hits implode(''$_gallery->fetch_first('SELECT SUM(`hits`) FROM cpg132_pictures AS p, cpg132_albums AS a WHERE p.aid = a.aid '));
?>


Solution for "Registered users":

Code: [Select]
<?php
// gallery members
$gallery_members I don't find the solution.;
?>


Thanks for a bit help.  :)

hama

Logged
Get up, stand up, stand up for your rights! - Get up, stand up, don't give up the fight!

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: How many gallery members?
« Reply #1 on: March 09, 2005, 10:07:35 am »

The code
Code: [Select]
$_gallery->fetch_first is neither PHP standards nor does it come with coppermine: you're either refering to some mod you applied, or you have created your own function. In both cases, we don't no what you did, so you will have to give more details (and maybe post a reference to the mod you're using). For an unbridged coppermine install, the query to show the number of registered users would look like this:
Code: [Select]
SELECT COUNT(*) FROM cpg132_users WHERE  user_active = 'YES'afaik.

Joachim
Logged

nol33t

  • Contributor
  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 244
  • Exploring Coppermine in every directions
    • tieum's pics
Re: How many gallery members?
« Reply #2 on: March 09, 2005, 11:10:06 am »

Code: [Select]
SELECT COUNT(*) FROM cpg132_users WHERE  user_active = 'YES'

[tips of the day]
a good habit is to put the primary key only in the count ( so "count(user_id)" ) --> real difference in time execution when you deal with big tables
[/tips of the day]
;)

hama

  • Contributor
  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 229
Re: How many gallery members?
« Reply #3 on: March 09, 2005, 04:55:31 pm »


@GauGau

It's an unbridged coppermine install and not a hack or a mod. For sure it's not PHP standard, it's try and error, learning by doing, and I'm happy that it works ...  :)

This one is in the head.php of my website (not gallery):

Code: [Select]
// new Gallery DB
$_gallery = new db($_cfg['DB_SERVER'], $_cfg['DB_GALLERY_USER'], $_cfg['DB_GALLERY_PASS'], $_cfg['DB_GALLERY_NAME']);
   
// gallery_pics
$gallery_pics = implode('', $_gallery->fetch_first('SELECT COUNT(*) FROM cpg132_pictures AS p, cpg132_albums AS a WHERE p.aid = a.aid '));
   
// gallery hits
$gallery_hits = implode('', $_gallery->fetch_first('SELECT SUM(`hits`) FROM cpg132_pictures AS p, cpg132_albums AS a WHERE p.aid = a.aid '));

And with this one in the left_login.tpl I get the result on the startpage of my website (for example www.orst.ch after login with test test).

Code: [Select]
   <li><a href="http://www.orst.ch/copper/index.php">Gallery-Fotos</a> ($gallery_pics)</li>
    <li><a href="http://www.orst.ch/copper/index.php">Gallery-Views</a> ($gallery_hits)</li>

Now I'll try to build in how many users are registered in the gallery (thanks for your idea, I'll try it out).

The difference between your idea and the idea of "nol33t" I don't understand.

My website is builded around a forum (it's a very good one) but there is no gallery bridge for this forum, so I think my solution is not so bad for the moment (except the problem that everybody has to make two registrations/logins, one for the website (including the forum) and another one for the gallery).

If it would be very easy to build in automaticly all the forum users into the gallery, so that every website user after his login is also logged in into the gallery, I'm open for this solution.  ;)

hama
Logged
Get up, stand up, stand up for your rights! - Get up, stand up, don't give up the fight!

nol33t

  • Contributor
  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 244
  • Exploring Coppermine in every directions
    • tieum's pics
Re: How many gallery members?
« Reply #4 on: March 09, 2005, 05:51:26 pm »

The difference between your idea and the idea of "nol33t" I don't understand.

you weren't talkin' to me but since you seem to want to understand: this is the same idea. but the day you'll have 200 000 users, count(user_id) will be faster than count(*)

you probably won't ever have that many users but as i said: it's just a good habit not to count(*)

-matt-

hama

  • Contributor
  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 229
Re: How many gallery members?
« Reply #5 on: March 09, 2005, 05:59:26 pm »


@ -matt- !

200 000 users ... wow ... not today and not tomorrow ...  :o

If I understand you correctly I better change the code from

SELECT COUNT(*)  to  SELECT COUNT(user_id).

Thanks and have a good time

hama

Logged
Get up, stand up, stand up for your rights! - Get up, stand up, don't give up the fight!
Pages: [1]   Go Up
 

Page created in 0.024 seconds with 20 queries.