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: "counter-code"  (Read 8159 times)

0 Members and 1 Guest are viewing this topic.

hama

  • Contributor
  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 229
"counter-code"
« on: November 16, 2004, 09:57:39 pm »

With this code in the head.php:

Code: [Select]
// gallery_pics
$gallery_pics = implode('', $_gallery->fetch_first('SELECT COUNT(*) FROM `cpg130_pictures`'));
   
// gallery hits
$gallery_hits = implode('', $_gallery->fetch_first('SELECT SUM(`hits`) FROM `cpg130_pictures`'));

and this code in the left_login.tpl:

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

of my website http://www.orst.ch (login with test test) I can see on the startpage how many pictures are in the gallery and how many views that the gallery has.

The problem is that with this code "the counter" on the startpage counts the private albums/categories too. So the numbers on the startpage and the numbers in the gallery are not the same.

All private albums are in cat=9.

Has anybody a good idea? You will get a dvd for "the" solution.

hama
« Last Edit: November 17, 2004, 05:37:31 pm by GauGau »
Logged
Get up, stand up, stand up for your rights! - Get up, stand up, don't give up the fight!

kiig

  • Contributor
  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 141
    • Igel's Journaler
Re: "counter-code"
« Reply #1 on: November 16, 2004, 11:15:12 pm »

not sure about "cat=9"... but looking at the different tables made me think that the field AID indicates the category, - or album...

so if select count(*) from cpg130_pictures gives you the total count, -
then try select count(*) from cpg130_pictures where aid != 9

and likewise with the number of hits :
select sum(hits) from cpg130_pictures where aid != 9

I'm guessing here, - but I don't think the database structure is more complex than that... but still, - a guess.

If it's wrong... :-) I'll look again :-)

Not very flexible, - and very hardcoded, - but if I'm right, - this will solve your problem.

Kim Igel.
Logged
Kim Igel
http://igel.it (Personal playground) or http://foto.igel.it (Paypal shop-site)

hama

  • Contributor
  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 229
Re: "counter-code"
« Reply #2 on: November 16, 2004, 11:26:06 pm »


Nothing changes by adding your idea.  :\'(

I still hope for a good solution.

Thanks

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

kiig

  • Contributor
  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 141
    • Igel's Journaler
Re: "counter-code"
« Reply #3 on: November 16, 2004, 11:43:39 pm »

okok.. looked a bit more... seems like there is a table of categories, - and a table of albums... albums belong to a categori, - and all pictures belong to an album....

So selecting from pictures, - omitting the albums that are marked as part of the category that belongs to users...

I've tried this:
SELECT count(  *  )
FROM  `cpg11d_pictures`
WHERE aid NOT
IN (  'SELECT aid
FROM cpg11d_albums
WHERE category =14' )

My tables have other names, - and you probably need to change the category= part, - if cat=9 means the database value '9', - then put that in there....

This time I'm not saying I think it works.... :-)
(try fiddling with it in a mysql Myadmin if you have one.....)

I'm not used to Mysql, - and I might have missed out on a couple of quotes or something, - but the above works in my MySql admin.... try it...

Kim
Logged
Kim Igel
http://igel.it (Personal playground) or http://foto.igel.it (Paypal shop-site)

Nibbler

  • Guest
Re: "counter-code"
« Reply #4 on: November 17, 2004, 12:22:12 pm »

OK, that query will only work on mysql 4.1+ due to use of the subquery so likely will not work on most ppls webservers. To exclude cat 9 you change the query to:

Code: [Select]
SELECT COUNT(*) FROM cpg130_pictures AS p, cpg130_albums AS a WHERE p.aid = a.aid AND a.category <> 9
Similar thing for the second query.
Logged

hama

  • Contributor
  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 229
Re: "counter-code"
« Reply #5 on: November 17, 2004, 01:50:15 pm »

@Nibbler: Yes, that's the solution. --> solved.

Send me a "personal message" with your address and the name of the dvd. I'll do the amazon-order in the next few days.

@Kim: Thanks for your help. If you send me your address too, I'll send you a CD.

Thanks to all for the professional help!

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

kiig

  • Contributor
  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 141
    • Igel's Journaler
Re: "counter-code"
« Reply #6 on: November 17, 2004, 02:30:51 pm »

thanx for the insight Nibbler.... :-)

@Hama, - don't worry about the CD... :-) I came close, - but no cigar... :-) and as I said, - I'm not used to MySql.
Logged
Kim Igel
http://igel.it (Personal playground) or http://foto.igel.it (Paypal shop-site)
Pages: [1]   Go Up
 

Page created in 0.02 seconds with 20 queries.