Author Topic: [MOD] Votes saved in DB  (Read 244200 times)

0 Members and 1 Guest are viewing this topic.

Offline soapycats

  • Pre-Newbie
  • Posts: 6
    • View Profile
Re: [MOD] Votes saved in DB
« Reply #135 on: September 15, 2006, 03:00:52 PM »
is there another link for the installer, I cant seem to get any action on the link given here.

also -- regarding 1.7.3 regular voting/rating data, is there any way "as is" without this mod or any other to pull the voting history - i need to see who has already voted, before install the mod.
also, can anyone explain the logic of the voting calculation 4images provides?

thanks in advance,
michelle

Offline desperate_housewif

  • Full Member
  • ***
  • Posts: 105
    • View Profile
Re: [MOD] Votes saved in DB
« Reply #136 on: September 17, 2006, 10:16:14 AM »
Habe die erforderlichen Statistikdateien soweit erstellt. Da beim Aufrufen der bekannte und hier schon beschrieben Datenbankfehler auftauchte, wollte ich V@no´s Vote installieren, was man offensichtlich dazu benötigt. Leider kann ich V@no über den in dem Forum angegebenen Link derzeit nicht erreichen. Kennt jemand einen anderen Link für den Mod?

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: [MOD] Votes saved in DB
« Reply #137 on: September 17, 2006, 06:37:18 PM »
I've attached the installers to the original post.
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline Stoleti

  • Hero Member
  • *****
  • Posts: 574
    • View Profile
Re: [MOD] Votes saved in DB
« Reply #138 on: September 17, 2006, 07:26:25 PM »
Its possible list at our profiles, the users who have rate our images ???

 :P

Offline soapycats

  • Pre-Newbie
  • Posts: 6
    • View Profile
Re: [MOD] Votes saved in DB
« Reply #139 on: September 18, 2006, 03:27:00 PM »
I've attached the installers to the original post.

thanks Vano, i didn't notice the "attached zip files" at the bottom of the instructions on page1.

question -
i've already received some votes before the add-on was installed, is there any way i can find out who voted and what they voted for from the admin panel/database download for the votes received before the addon was added!????

otherwise, in the databases download before the addon was installed, there are fields as follows:
image_votes  / image_rating / image_hits
can you explain the logic behind the rating?
it does not seem to be a simple calculation of "votes" x "score" (given on rating template)??
does it factor in the hits too??? 

i really need help on this and appreciation feedback. 
thanks

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: [MOD] Votes saved in DB
« Reply #140 on: September 18, 2006, 03:35:47 PM »
No, such information is not available without this mod, so votes before this mod are not recoverable...
as of hits included in the vote system - no, the rating calculated as average of all votes. The formula is the following:

new rating = ((old rating * number of votes) + rating) / (number of votes + 1)
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline qvforum

  • Pre-Newbie
  • Posts: 9
    • View Profile
Re: [MOD] Votes saved in DB
« Reply #141 on: September 18, 2006, 06:47:14 PM »
Hello, does the Votes saved in DB MOD function with an integration phpbb of the user intergration? What do I have to consider thereby, change which code perhaps?

Andreas

PS: Please my very bad English excuses

Offline soapycats

  • Pre-Newbie
  • Posts: 6
    • View Profile
Re: [MOD] Votes saved in DB
« Reply #142 on: November 25, 2006, 04:25:22 PM »
....the rating calculated as average of all votes. The formula is the following:

new rating = ((old rating * number of votes) + rating) / (number of votes + 1)

Hi Vano,   

I am still a little confused.

If i multiple votes x rating will that give me the over total value of the votes received for that image?

How can I back calculate from the formula you give above, e.g., new rating = ((old rating * nu. images) + rating).........????

For example, currently an image with a rating of 5 beats one with a rating of 4.75 BUT in actual fact the image with 4.75 actually received more votes and thus a higher overall score and was penalised when it was averaged! whereas the images with a rating of 5 sometimes only received one voter giving one good vote? 

and why do some calculate with a decimal?
for example, one image got 9 votes, and a rating of 3.34 which would give a total of 30.06 and as there isn't any decimals in my ratings which go 1 to 5 (best) I dont know how the total could have a decimal?????

any feedback advice on the formula and calculation would be greatly appreciated !!!

thanks,
michelle

Offline {{DELIKANLIM}}

  • Pre-Newbie
  • Posts: 5
    • View Profile
    • Www.Delikanlim.Net
Re: [MOD] Votes saved in DB
« Reply #143 on: January 25, 2007, 08:11:21 PM »
Die Version A habe ich installiert und es funktioniert alles, außer die DB Votes. Da steht jetzt allerdings "An unexpected error occured. Please try again later." Vorher stand aber, dass es Probleme mit der Datenbank gibt.
Hier ist die Adresse:
http://www.delikanlim.net/galery/

Könnten Sie mir bitte helfen?
Ich danke im Vorraus.

Offline cipriansamoila

  • Pre-Newbie
  • Posts: 7
    • View Profile
Re: [MOD] Votes saved in DB
« Reply #144 on: February 23, 2007, 12:57:52 AM »
Hi,

what are the changes needed when using PHPBB user integration.

I am gettting errors in the details page http://icons.greenmap.org/gallery/details.php?image_id=400

i hope V@no will be around to help me out... i have been around for 2 years and it's now i need your help.

best,
cip

Offline mstgokcen

  • Newbie
  • *
  • Posts: 44
    • View Profile
Re: [MOD] Votes saved in DB
« Reply #145 on: May 09, 2007, 09:36:32 AM »

who voted: user1
                 user2
                 user3

isnt it better to display

who voted: user1,user2,user.....

how can we change?


still need an answer..help plz

Offline Darkness2001

  • Full Member
  • ***
  • Posts: 151
    • View Profile
    • photo-galerie-online
ERROR in DB
« Reply #146 on: July 30, 2007, 05:06:27 PM »
Hi,

ich bekomme immer nach jedem Kommentareintrag auf der detail Seite einen Fehler angezeigt. Wenn ich im Adminbereich Bilder bearbeite und dann speichere kommt der selbe Fehler

Errormeldung: DB Error: Bad SQL Query: INSERT INTO galerie_voted (user_id, image_id, vote) VALUES (, 4, )
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' 4, )' at line 4


ich habe hier schon gesucht, aber nix gefunden.

Mein table voted in der DB sieht so aus:

--
-- Tabellenstruktur für Tabelle `galerie_voted`
--

DROP TABLE IF EXISTS `galerie_voted`;
CREATE TABLE `galerie_voted` (
  `user_id` mediumint(8) NOT NULL default '0',
  `image_id` mediumint(8) unsigned NOT NULL default '0',
  `vote` int(2) unsigned NOT NULL default '0',
  `vote_date` int(10) unsigned NOT NULL default '0',
  KEY `user_id` (`user_id`),
  KEY `image_id` (`image_id`),
  KEY `vote_date` (`vote_date`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_german2_ci;

Wer kann mir helfen  :mrgreen:

GRüße darkness

Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: [MOD] Votes saved in DB
« Reply #147 on: August 18, 2007, 04:54:25 PM »
This for see who rate in details.

In details.php file,

find:

Quote
//-----------------------------------------------------
//--- Show Image --------------------------------------
//-----------------------------------------------------

add before:

Quote
//-----------------------------------------------------
//--- Show user vote foreach image  -----
//-----------------------------------------------------
$sql = "

SELECT " . get_user_table_field("v.", "user_id") . get_user_table_field(", u.", "user_name") . ", v.vote
FROM (" . VOTED_TABLE . " v, " . IMAGES_TABLE . " i)
LEFT JOIN " . USERS_TABLE . " u ON (" . get_user_table_field("u.", "user_id") . " = v.user_id)
WHERE i.image_id = " . $image_id;

$result = $site_db->query($sql);

if (isset($result) && $result) {

while ($vote_row = $site_db->fetch_array($result)) {
}

}

In includes/functions.php file,

find:

Quote
function show_image($image_row, $mode = "", $show_link = 1, $detailed_view = 0) {
  global $self_url, $site_template, $site_sess, $user_info, $config, $cat_cache, $lang, $additional_image_fields, $user_table_fields, $url_show_profile;

replace:

Quote
function show_image($image_row, $mode = "", $show_link = 1, $detailed_view = 0) {
  global $self_url, $site_template, $site_sess, $user_info, $config, $cat_cache, $lang, $additional_image_fields, $user_table_fields, $url_show_profile, $vote_row;

Find:

Quote
"image_hits" => $image_row['image_hits'],

add after:

Quote
"vote_user_id" => $vote_row[$user_table_fields['user_id']],
"lang_vote_user_name" => preg_replace("/" . $site_template->start. "get_vote_user_name" . $site_template->end . "/siU", $vote_row[$user_table_fields['user_name']], $lang['vote_user_name']),
"vote_user_value" => $vote_row['vote'],

In lang/english/main.php file,

add before ?>:

Quote
$lang['vote_user_name'] = "Voted by: {get_vote_user_name}";

In templates/your_template/details.html file,

use:

Quote
{vote_user_id} (for URL)
{lang_vote_user_name}
{vote_user_value}

and create way you want. ;)
« Last Edit: August 18, 2007, 05:37:55 PM by thunderstrike »
8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?

Offline davy_74

  • Jr. Member
  • **
  • Posts: 69
    • View Profile
Re: [MOD] Votes saved in DB
« Reply #148 on: December 13, 2007, 10:59:34 PM »
Hi folks.

I did option A of this mod, and works perfect. I added a new field to 4images_voted table. I called it user_ip just to store the IP of the user who votes. Everything I tried doesn't store the IP, that field is empty in all my records.

my function update_image_rating is as follows. I know I'm close but I don't know how to reach. Some help please

//function update_image_rating($image_id, $rating) {
//  global $site_db;


function update_image_rating($image_id, $rating) {
  global $site_db, $user_info; 
 
  $sql = "SELECT cat_id, image_votes, image_rating
          FROM ".IMAGES_TABLE."
          WHERE image_id = $image_id";
  $image_row = $site_db->query_firstrow($sql);
  if (check_permission("auth_vote", $image_row['cat_id'])) {
    $old_votes = $image_row['image_votes'];
    $old_rating = $image_row['image_rating'];
    $new_rating = (($old_rating * $old_votes) + $rating) / ($old_votes + 1);
    $new_rating = sprintf("%.2f", $new_rating);


//oooooooooooooooooooooooooooooooooooooooo

// this is for including guest's votes too

   //if ($user_info['user_id'] != GUEST)
    {
        $sql = "INSERT INTO ".VOTED_TABLE."
                (user_id, image_id, vote)
                VALUES
                (".$user_info['user_id'].", ".$image_id.", ".$rating.")";
        $site_db->query($sql);
    }
//oooooooooooooooooooooooooooooooooooooooo


    $sql = "UPDATE ".IMAGES_TABLE."
            SET image_votes = ($old_votes + 1), image_rating = '$new_rating'
            WHERE image_id = $image_id";
    $site_db->query($sql);
  }
}


Cheers

Davy
« Last Edit: December 13, 2007, 11:15:30 PM by davy_74 »

Offline darvid

  • Jr. Member
  • **
  • Posts: 96
    • View Profile
    • KNOWTEBOOK.COM - Community for webdeveloper
Re: [MOD] Votes saved in DB
« Reply #149 on: December 14, 2007, 05:07:06 PM »
This is an addition for users who used Kurts "Star Rating Mod" (http://www.4homepages.de/forum/index.php?topic=17829.0)



OPEN RATING_NEW.PHP:

FIND:

Code: [Select]
?>
INSERT BEFORE




   
Code: [Select]

// Anfang: Hinzugefügt, SebastianScheuer.de, Datum: 12. Dezember 2007
   
$sql = "INSERT INTO ".VOTED_TABLE."
(user_id, image_id, vote)
VALUES
(".$user_info['user_id'].", ".$image_id_sent.", ".$vote_sent.")";
$site_db->query($sql);

// Ende: Hinzugefügt, SebastianScheuer.de, Datum: 12. Dezember 2007
/* KNOWTEBOOK - BoostYourself community for webdeveloper
/* http://www.knowtebook.com

Integration von Wordpress Blog, PHPBB Forum und 4Images Bildergalerie:
http://www.sebastianscheuer.de/aktuell/integration-von-wordpress-blog-phpbb-forum-und-4images-bildergallerie/
DEMO: http://www.pilotenbilder.de/