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: Resetting View and Rating Counts ?  (Read 6505 times)

0 Members and 1 Guest are viewing this topic.

webbo

  • Coppermine newbie
  • Offline Offline
  • Posts: 7
Resetting View and Rating Counts ?
« on: March 15, 2006, 10:10:21 pm »

Hi,

As i am running a monthly competition using the coppermine gallery within my site, i am wondering if there is any way i can reset all the views and ratings of applicable files, with out having to go through each one individually.

We are using the views and ratings as a way of selecting shots for judging, so to be able to reset these values very rapidly at the beginning of each month would be very handy.

I have checked the FAQ's and can't find any relative info.

Can any one help and suggest any ideas ?
cheers
W ;D ;D
Logged

xplicit

  • Contributor
  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 214
Re: Resetting View and Rating Counts ?
« Reply #1 on: March 15, 2006, 10:21:07 pm »

Sounds easy.

Just running a little query in a special php files sounds like the easiest way.

I dont know how your site is build up. I assume you dont want to reset all the views for all files on your gallery but that you placed the files which are running in the competition in a sepate album. In that case the page has its unique $aid and is eay to filter on.

If you post a link to your site I can take a look on how it looks and if help is needed I can code it and place the file here.
Logged
Don't ask me: Can you do this .... or Give me that...or I need Quick help in PM's. I'm not Santaclaus so post your questions on the board so it will be in the benefit for everyone.

xplicit

  • Contributor
  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 214
Re: Resetting View and Rating Counts ?
« Reply #2 on: March 16, 2006, 01:37:45 am »

Ok I just made a quick and dirty piece of code which will do the job, layout could be a lot better but functionality is ok

It will:

* Preset the number of hits of a specific album ID to a desired value
* Protected so that only people with admin rights can perform these actions

It will not:

* Check if the album is valid, could be easily done by checking the result of the query but I was lazy ;)
* Reset ratings since your post is not very clear to me what you mean.

To clear the actual votes you can write the code further yourself, bij selecting all pid's in the specific album in a query and reset these values in the vote_stats table and votes table in another query

Just run the script using: http://www.yoursite.com/competition.php or fit it properly in your design in the usual ways

It's valid for 1.3x , 1.4x (language is hard coded but its up to you if you want to do it the proper way in the language files)

Code: [Select]
<?php
/*************************
  Coppermine Photo Gallery
  ************************
  Copyright (c) 2003-2005 Coppermine Dev Team
  v1.1 originaly written by Gregory DEMAR

  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 2 of the License, or
  (at your option) any later version.
  ********************************************
  Coppermine version: 1.4.4

  $Revision: 1.00 $
  $Author: AJ (Xplicit) $
  $Date: 2006/03/16 00:30:00 $
**********************************************/

define('IN_COPPERMINE'true);

require(
'include/init.inc.php');

if (!
GALLERY_ADMIN_MODEcpg_die(ERROR$lang_errors['access_denied']);

if (isset(
$_POST['resetalbum'])) {
$desired_album = (int)$_POST['resetalbum'];
$value = (int)$_POST['value'];

    $sql "UPDATE {$CONFIG['TABLE_PICTURES']} SET hits = $value WHERE aid=$desired_album"
$result cpg_db_query($sql);

pageheader("RESET BEING PERFORMED");

echo <<< EOT

<form method="post" action="competition.php" name="again">
EOT;


starttable('80%'"");
echo <<< EOT
  <tr>
        <td align="center" class="tableh2">
          <font size="3" color="red"><b>HITS FOR PICTURES IN ALBUM NR 
$desired_album SUCCESFULLY SET TO $value<b></font>
        </td>
      </tr>    

<tr>
  <td class="tableb" align="center" >
<input type="submit" value="PERFORM ANOTHER (P)RESET ACTION" class="button" />
       <input type="hidden" name="again" value="none" />
       </td>
     </tr>        
EOT;

endtable();
echo 
'</form>';


EOT;
endtable();

} else {

if (!
USER_ID && $CONFIG['allow_unlogged_access'] == 0) {
    $redirect $redirect "login.php";
    header("Location: $redirect");
    exit();
}

pageheader("Reset competition results of a specific album number");

echo <<< EOT

<form method="post" action="competition.php" name="resetcompetition">
EOT;


starttable('80%'"");

echo <<< EOT
<tr>
  <td  class="tableb" align="left" >
<div align="left"><font size="3"><b>ALBUM ID<b></font>
    <input type="text" style="width: 100" name="resetalbum" maxlength="5" value="" class="textinput" /><BR/>
    </div>
       </td>
</tr>
<tr>
<td  class="tableb" align="right" >
<div align="left"><font size="3"><b>PRESET VALUE<b></font>
    <input type="text" style="width: 100" name="value" maxlength="5" value="" class="textinput" /><BR/>
   </div>
       </td>
     </tr>        
<tr>
<td width="50%" colspan="2" align="center" >
<input type="submit" value="(P)RESET ALL HITS FOR THIS ALBUM" class="button" />
</td>
<tr>
EOT;

endtable();
echo 
'</form>';
}
pagefooter();
ob_end_flush();
?>


« Last Edit: March 16, 2006, 02:24:27 am by xplicit »
Logged
Don't ask me: Can you do this .... or Give me that...or I need Quick help in PM's. I'm not Santaclaus so post your questions on the board so it will be in the benefit for everyone.

webbo

  • Coppermine newbie
  • Offline Offline
  • Posts: 7
Re: Resetting View and Rating Counts ?
« Reply #3 on: March 16, 2006, 11:12:59 pm »

Many thanks.

Heres a link to my site: www.enlyten.org/user_galleries/index.php

Apologies for being unclear in my initial post - heres a better description.

The gallery at the link above is used by registered users to upload photos.
Each photo that is uploaded is entered into the photo of the month competiton
To be able to reset the views and ratings for each image in the gallery will help us to decide which entry wins each month - this is decided on the average of ratings and views each month.

I can't write my own code - wouldn't have a clue how to start  ???

the galleries were set up for me by a friend who worked out how to run them.

Any help you can offer is appriciated ;D
Logged

Nibbler

  • Guest
Re: Resetting View and Rating Counts ?
« Reply #4 on: March 16, 2006, 11:16:37 pm »

You can reset hits and votes in album properties.
Logged

webbo

  • Coppermine newbie
  • Offline Offline
  • Posts: 7
Re: Resetting View and Rating Counts ?
« Reply #5 on: March 19, 2006, 01:23:48 pm »

yeah that's how i'm resetting them at the moment - but as far as i can work out, you can only reset the values for single entries at one time - so you ahve to reset all the values individually. - thats a lot of resetting. :P

I would like to be able to reset all values for all entries in one easy method - so that at the beginning of the month all entries in the gallery - and therefore all entries in the competition - start at 0.

Make it easier to judge and the leaders are clearly visible to all gallery users under the 'most viewed' selection.

Do you know if there is a way to reset all the values easily ?

I tried running Xplicits code snippet - but it errors on me. Am i running it correctly - just typing in the URL.??

many thanks for your advice.

Webbo  ;D
Logged

xplicit

  • Contributor
  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 214
Re: Resetting View and Rating Counts ?
« Reply #6 on: March 20, 2006, 01:41:14 am »

The file I made is without errors. just run is from your root. The only error you can get is a error if you try to run the script from a none admin account (cause this file is protected otherwise everyone could reset things)

Perhaps you didn't cut and paste it in a real low level text editor.

What kind of errors do you get?

If making a cut and paste file is too difficult perhaps it's just not your thing.
Logged
Don't ask me: Can you do this .... or Give me that...or I need Quick help in PM's. I'm not Santaclaus so post your questions on the board so it will be in the benefit for everyone.

webbo

  • Coppermine newbie
  • Offline Offline
  • Posts: 7
Re: Resetting View and Rating Counts ?
« Reply #7 on: March 26, 2006, 06:58:08 pm »

I still can't get the code supplied to work.

Unfortunately - your gonna have to explain this one in laymans terms - I haven't had the time to nerd out on this one - hence why i'm asking if anyone can help.

If i try and run the above code like so : www.enlyten.org/user-galleries/competition.php,  this is the error i get :

Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in /vhost/vhost2/e/n/l/enlyten.org/www/user_galleries/competition.php on line 48

How do you integrate the code with the gallery ??? Does the code work properly ?
 
i'm not sure what you mean by : " just run is from your root. The only error you can get is a error if you try to run the script from a none admin account (cause this file is protected otherwise everyone could reset things)" 

How do you run the file competition.php from within the gallery ????

once again - if you can help it's appriciated.

cheers

W
Logged

xplicit

  • Contributor
  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 214
Re: Resetting View and Rating Counts ?
« Reply #8 on: March 26, 2006, 07:07:01 pm »

Quote
Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in /vhost/vhost2/e/n/l/enlyten.org/www/user_galleries/competition.php on line 48

doesn't make sense if you cut and paste the code exactly since line 48 is just plain html or did you remove parts?

Else attach your file to see where your version goes wrong
Logged
Don't ask me: Can you do this .... or Give me that...or I need Quick help in PM's. I'm not Santaclaus so post your questions on the board so it will be in the benefit for everyone.

webbo

  • Coppermine newbie
  • Offline Offline
  • Posts: 7
Re: Resetting View and Rating Counts ?
« Reply #9 on: March 27, 2006, 11:02:33 am »

I've just  cut and paste the code again into a new php file, uploaded the new file and still get the same error.

???

help.
Logged

xplicit

  • Contributor
  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 214
Re: Resetting View and Rating Counts ?
« Reply #10 on: March 27, 2006, 07:23:11 pm »

I repeat:

Else attach your file to see where your version goes wrong

Otherwise I can't help you
Logged
Don't ask me: Can you do this .... or Give me that...or I need Quick help in PM's. I'm not Santaclaus so post your questions on the board so it will be in the benefit for everyone.

webbo

  • Coppermine newbie
  • Offline Offline
  • Posts: 7
Re: Resetting View and Rating Counts ?
« Reply #11 on: March 28, 2006, 02:28:04 am »

Here it is. Attached file.
The file is a.php file - so you may need to change the extension to be able to read it.

 All i have done ins copy and pasted the info you provided above into a new .php doc and uploaded to the correct gallery folder on my server.
When i run the file as you instructed it errors with the above.

The code that i have used also is here too incase the file upload doesn't  work.

Code: [Select]
<?php
/*************************
  Coppermine Photo Gallery
  ************************
  Copyright (c) 2003-2005 Coppermine Dev Team
  v1.1 originaly written by Gregory DEMAR

  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 2 of the License, or
  (at your option) any later version.
  ********************************************
  Coppermine version: 1.4.4

  $Revision: 1.00 $
  $Author: AJ (Xplicit) $
  $Date: 2006/03/16 00:30:00 $
**********************************************/

define('IN_COPPERMINE'true);

require(
'include/init.inc.php');

if (!
GALLERY_ADMIN_MODEcpg_die(ERROR$lang_errors['access_denied']);

if (isset(
$_POST['resetalbum'])) {
$desired_album = (int)$_POST['resetalbum'];
$value = (int)$_POST['value'];

    
$sql "UPDATE {$CONFIG['TABLE_PICTURES']} SET hits = $value WHERE aid=$desired_album"
$result cpg_db_query($sql);

pageheader("RESET BEING PERFORMED");

echo <<< EOT

<form method="post" action="competition.php" name="again">
EOT;


starttable('80%'"");
echo <<< EOT
  <tr>
        <td align="center" class="tableh2">
          <font size="3" color="red"><b>HITS FOR PICTURES IN ALBUM NR 
$desired_album SUCCESFULLY SET TO $value<b></font>
        </td>
      </tr>    
  
<tr>
  <td class="tableb" align="center" >
<input type="submit" value="PERFORM ANOTHER (P)RESET ACTION" class="button" />
       <input type="hidden" name="again" value="none" />
       </td>
     </tr>        
EOT;

endtable();
echo 
'</form>';


EOT;
endtable();

} else {

if (!
USER_ID && $CONFIG['allow_unlogged_access'] == 0) {
    
$redirect $redirect "login.php";
    
header("Location: $redirect");
    exit();
}

pageheader("Reset competition results of a specific album number");

echo <<< EOT

<form method="post" action="competition.php" name="resetcompetition">
EOT;


starttable('80%'"");

echo <<< EOT
<tr>
  <td  class="tableb" align="left" >
<div align="left"><font size="3"><b>ALBUM ID<b></font>
    <input type="text" style="width: 100" name="resetalbum" maxlength="5" value="" class="textinput" /><BR/>
    </div>
       </td>
</tr>
<tr>
<td  class="tableb" align="right" >
<div align="left"><font size="3"><b>PRESET VALUE<b></font>
    <input type="text" style="width: 100" name="value" maxlength="5" value="" class="textinput" /><BR/>
   </div>
       </td>
     </tr>        
<tr>
<td width="50%" colspan="2" align="center" >
<input type="submit" value="(P)RESET ALL HITS FOR THIS ALBUM" class="button" />
</td>
<tr>
EOT;

endtable();
echo 
'</form>';
}
pagefooter();
ob_end_flush();
?>
Logged

xplicit

  • Contributor
  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 214
Re: Resetting View and Rating Counts ?
« Reply #12 on: March 28, 2006, 02:43:31 am »

Ok a few blank spaces are the problem

I'll send you a working version without them (rename jpg to php)
Logged
Don't ask me: Can you do this .... or Give me that...or I need Quick help in PM's. I'm not Santaclaus so post your questions on the board so it will be in the benefit for everyone.

Stramm

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Gender: Male
  • Posts: 6006
    • Bettis Wollwelt
Re: Resetting View and Rating Counts ?
« Reply #13 on: March 28, 2006, 07:09:27 pm »

to reset the view counter is an admin tools function

MstrMitch

  • Guest
Re: Resetting View and Rating Counts ?
« Reply #14 on: October 26, 2006, 08:54:05 pm »

I am getting an error

Fatal error: Call to undefined function: cpg_db_query() in /home/hsphere/local/home/fetish/azfetishball.com/pics/competition.php on line 31

using the same script..any help?

Mitch
Phoenix, AZ
Logged

Nibbler

  • Guest
Re: Resetting View and Rating Counts ?
« Reply #15 on: October 26, 2006, 09:00:26 pm »

There is no support for Coppermine 1.3. Update your gallery.
Logged
Pages: [1]   Go Up
 

Page created in 0.041 seconds with 20 queries.