4images Forum & Community
4images Modifications / Modifikationen => Mods & Plugins (Releases & Support) => Topic started by: V@no on June 08, 2003, 06:19:12 PM
-
This mod will save each members vote in the database. That means, that members now can only vote ONCE for the same image, even if they clear cookies.
I made two versions of this mod:
A - will uses new table in the database "4images_voted", that will stores new entry for each vote for each image and user. That would allow with some extra code display how many members voted for an image, who and what was the vote (http://www.4homepages.de/forum/index.php?topic=6123.msg37763#msg37763). And backwards: how many images the user voted, witch images and what was the vote. The disadvantage of this version is that database will grew as fast as many votes members do. :(
B - will uses existing users table "4images_users" with new field and store image ids and vote rating as simple text. Disadvantage of this version - statistics other then which images a member voted for would not be avalable (almost not possible).
------------------------------
Version A
Just 3 files to edit:
/includes/page_header.php
/includes/functions.php
/includes/constants.php
------ Installation ------
Step 1
Open /includes/page_header.php
Find: $rating = intval($HTTP_POST_VARS['rating']);
Add after: if ($user_info['user_level'] != GUEST) {
$sql = "SELECT user_id, image_id, vote
FROM ".VOTED_TABLE."
WHERE image_id = ".$id." AND user_id = ".$user_info['user_id'];
$rated = $site_db->query_firstrow($sql);
$rating = ($rated['vote']) ? $rated['vote'] : $rating;
}else{
$rated = FALSE;
}
Step 1.2
Find:if (!in_array($id, $split_list) && !in_array($id, $cookie_rated)) {
Replace with:if (!in_array($id, $split_list) && !in_array($id, $cookie_rated) && !$rated) {
Step 2
Open /includes/functions.php
Find:function update_image_rating($image_id, $rating) {
global $site_db;
Replace with:function update_image_rating($image_id, $rating) {
global $site_db, $user_info;
Step 2.2
Find next:$sql = "UPDATE ".IMAGES_TABLE."
SET image_votes = ($old_votes + 1), image_rating = '$new_rating'
Add before: 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);
}
Step 3
Open /includes/constants.php
Add just before closing ?>define('VOTED_TABLE', $table_prefix.'voted');
Step 4
Download this (http://gallery.vano.org/file31dl) installer.
Unpack it and upload to your 4images root.
Start it http://yoursite/4images/voted_b_install.php
Version B
Just 3 files to edit:
/includes/page_header.php
/includes/functions.php
/includes/db_field_definitions.php
------ Installation ------
Step 1
Open /includes/page_header.php
Find: $rating = intval($HTTP_POST_VARS['rating']);
Add after: if ($user_info['user_level'] != GUEST) {
$voted_array = array();
if (!empty($user_info['user_voted'])) {
$voted_array = explode(" ", $user_info['user_voted']);
}
$list_rated = array();
foreach ($voted_array as $key) {
$split = explode(",", $key);
$list_rated[] = $split[0];
if ($id == $split[0]) {
$rating = $split[1];
}
}
$rated = in_array($id, $list_rated);
}else{
$rated = FALSE;
}
Step 1.2
Find:if (!in_array($id, $split_list) && !in_array($id, $cookie_rated)) {
Replace with:if (!in_array($id, $split_list) && !in_array($id, $cookie_rated) && !$rated) {
Step 2
Open /includes/functions.php
Find:function update_image_rating($image_id, $rating) {
global $site_db;
Replace with:function update_image_rating($image_id, $rating) {
global $site_db, $user_info;
Step 2.2
Find next: $sql = "UPDATE ".IMAGES_TABLE."
SET image_votes = ($old_votes + 1), image_rating = '$new_rating'
Add before: if ($user_info['user_id'] != GUEST) {
$user_info['user_voted'] = $user_info['user_voted']." ".$image_id.",".$rating;
$sql = "UPDATE ".USERS_TABLE."
SET user_voted = '".trim($user_info['user_voted'])."'
WHERE user_id = ".$user_info['user_id'];
$site_db->query($sql);
}
Step 3
Open /includes/db_field_definitions.php
Add just before closing ?>$additional_user_fields['user_voted'] = array("User votes", "text", 0);
Step 4
Download this (http://gallery.vano.org/file32dl) installer.
Unpack it and upload to your 4images root.
Start it http://yoursite/4images/voted_b_install.php
Version history
-
Thank you
But how can I see what did they vots? :(
-
Can we see any demo?
I would like to know if the votes can be see next to comments?
-
Thank you V@no, it work perfectly ;)
-
Yes, can I see a demo of this
(V@no, was this the mod I requested?)
-
I dont know, guys, what kind of demo do u need? :?
all I can show u is url to my site, registr/login and vote for something, close your browser, clear cookies, come back, and u'll see that u cant vote agian for same image.
what else I can show u? ;)
[EDITED]
ok, here is a little example of what u can do with version A:
http://www.come.no-ip.com/details.php?image_id=9741
look at the side, under category info.
With just one change it can also display what was their votes. (I dont want to show it, because I belive voting should be private)
-
What I'm wondering is can this somehow be included in the Admin control panel so that we can look up a particular user, and see which images he/she voted on, and what rating they gave them?
-
What I'm wondering is can this somehow be included in the Admin control panel so that we can look up a particular user, and see which images he/she voted on, and what rating they gave them?
yes, u can, with either of version.
-
I'm currently in the middle of installing this, and ran into a problem.
On step 2.2, I have to instances of:
$sql = "UPDATE ".IMAGES_TABLE."
One inside this:
function update_comment_count($image_id = 0, $user_id = 0) {
The other is inside this:
function update_image_rating($image_id, $rating) {
Which one should I replace, or both?
-
And another problem. Upon downloading voted_a_install.zip, I get the following error from WinZip:
Cannot open file: it does not appear to be a valid archice.
If you downloaded this file, try downloading the file again.
Anybody else have a problem with installer A?
Thanks
-
On step 2.2, I have to instances of:
$sql = "UPDATE ".IMAGES_TABLE."
Which one should I replace, or both?
no, in function update_image_rating
by default u shouldnt have more then one "UPDATE"
ok, I have updated my post.
about the download thing, try to clear your internet cache and download again. I was upgrading my Apache to Apache2 and PHP 4.3.3, so u might caught that time...(also, registered users can receive by email any files ;))
-
I have cleared my cache, still no go on the download.
-
I have cleared my cache, still no go on the download.
I dont know what to say...nobody has reported this...
maybe try to reboot?
-
Can you PM me the source or somethin?
I'd appreciate it.
-
Kewl, I got it all to work! :)
Now who wants to code v1.1?
[Request] What I would want is a place in the control panel to check out all of these stats, like give a list of users, which image they voted on, and what they gave that image.
Thanks!
-
What should we do if we want to show votes next to comments?
-
I think there is bug in version A. I uploaded file voted_a_install.php and run it. But that one creates wrong table. It should create 4images_voted table not VOTED_CREATE or something like that.
And i have difficulte to unzip voted_a_install.zip file. One error is inside.
-
I think there is bug in version A. I uploaded file voted_a_install.php and run it. But that one creates wrong table. It should create 4images_voted table not VOTED_CREATE or something like that.
And i have difficulte to unzip voted_a_install.zip file. One error is inside.
did u forgot do step 3?
-
Nope i didnt forget it. But i was getting error that 4images_voted table doesnt exist. So i just changed that table to 4images_voted and now votes are saved in DB. But i just dont know how can i set that they will show in each comment
-
I also got the same error about the table name not being correct.
I think it did not pick up the variable "VOTED_TABLE", so it just named the table that.
-
The zip file of the version A is corrupted, you lets not extract.
Greeting Ingo.
-
The zip file of the version A is corrupted, you lets not extract.
Greeting Ingo.
I dont know guys, what wrong with...who knows what, but I've tryed myself on 3 different browsers (NS6, Mozilla, IE6) on 3 different computers (including the server), none of my friends who downloaded this file, had any problems...I even made fresh .zip archive on different coputer...even switch back to Apache 1.3.6 now...
I'm pretty much sure its something wrong with your system.
P.S. I dont use WinZip or something, but I'm sure, that XP zip folders feature is standart as WinZip, so that cant cause the problem.
-
I tried with both winzip and winrar, and both said the file is corrupt.
I just tried here at work, first time downloading on this computer, and same error, so the file is definitely corrupt.
-
ok, its turned out that the problem was PHP v4.3.3. I downgraded it to v4.2.3.
Try now and let me know if it still corrupted.
-
It works fine!
CU Ingo.
-
Great work, V@no! Thank you!
With just one change it can also display what was their votes. (I dont want to show it, because I belive voting should be private)
I'd like to display each vote next to the comments, in the author's box for example. Would this be possible? What would I have to change?
Thanks in advance,
Biggi
-
Wow, this became a semi-popular mod :)
I just wanted to share what I decided to do for a gui:
http://new.girls-on-bikes.com/vote_stats.php
-
I just wanted to share what I decided to do for a gui:
imho not a good idea... votes is a kind of privat information and i'm pretty sure my users will not be very happy when i disclose this info
-
This will not be something publicly available to users.
It will be moved into my password protected admin folder very soon, but I just wanted to share what I did as far as a gui is concerned.
And at a higher level, the reason I requested this mod is because I want to find out if any users are rating all the pictures with the lowest rating just to mess up the rating system. I've had plenty of this with my old site, and this mod provides me with a way to easily check this.
-
strange... my members and i want that the votes could be see next to comment. Is it possible?
-
strange... my members and i want that the votes could be see next to comment. Is it possible?
nothing strange... it depends from the kind of gallery you're running... mine, for example, is for irc network, with photos of people chatting there, people knowing each other... i'm sure these people do not want to show their personal likes and dislikes on public
btw, admin plugin to "spy" all votes is ready, let's ask v@no to publish it :wink:
-
Hi,
I´ve wrote 2 extensions to v@no´s mod. If you are interested, look here:
http://www.4homepages.de/forum/viewtopic.php?t=6404
http://www.4homepages.de/forum/viewtopic.php?t=6405
bye
-
v@no will you publish it? :roll:
-
v@no will you publish it? :roll:
no, because it doesnt work...properly...:(
-
Well you sure knows php better then me, but its strange, couse in database you can actualy see user_id image_id vote for specific photo. Tell us why is not working propertly, maybe we could solve it together?
-
ups 2 posts together :(
-
Does anyone have the installer?
The file doesnt work.
-
Does anyone have the installer?
The file doesnt work.
The link fixed now.
-
Thanks, installing right now.
How do i view the votes.
-
Does anyone have the installer?
The file doesnt work.
The link fixed now.
All I get out of the link is a DLL file. Is that correct?
-
All I get out of the link is a DLL file. Is that correct?
u are getting what?
I hope u are not trying right click on the link and save as...
-
I wasn't right clicking, I just wasn't getting anywhere. Must have been your server, or some server between yours and my IP... anyway, I got it downloaded.
There's a problem though. After testing, I found that deleting cookies makes it so that the user can vote again. Isn't this supposed to prevent that from happening? I'm using 4images 1.7.
-
if u tested it as a guest, then yes, that's supposed to be. Votes saved in the database only for members.
-
Only registered members are able to vote. No guests.
-
Wait... I think I made a mistake. Don't ponder over this just yet...
-
Here is a little addon for version A of this mod which I promised for a long time and never published it...
It will show who voted and if u logged in as admin also show what was the vote of each voted member on image details page (details.php)
Step 1
Open details.php
Find://-----------------------------------------------------
//--- Print Out ---------------------------------------
//-----------------------------------------------------
Insert above://-----------------------------------------------------
//--- Voted stats -------------------------------------
//-----------------------------------------------------
$sql = "SELECT v.user_id, v.vote, u.user_name
FROM ".VOTED_TABLE." v
LEFT JOIN ".USERS_TABLE." u ON (u.user_id = v.user_id)
WHERE u.user_id = v.user_id AND image_id = ".$image_id;
$result = $site_db->query($sql);
$voted_list = "";
while ($row = $site_db->fetch_array($result))
{
$vote = ($user_info['user_level'] == ADMIN) ? " (".$row['vote'].")" : "";
$voted_list .= "<a href=\"".$site_sess->url(ROOT_PATH."member.php?action=showprofile&user_id=".$row['user_id'])."\">".$row['user_name']."</a>".$vote."<br />"; //member name WITH a link to their profile page
// $voted_list .= $row['user_name'].$vote."<br />"; //member name WITHOUT a link to their profile page
}
$site_template->register_vars(array(
"voted_list" => $voted_list,
"lang_voted_list" => $lang['voted_list']
));
//----- End Voted stats ----------------
Step 2
In lang/<your language>/main.php at the very end, above closing ?> insert:$lang['voted_list'] = "Who voted";
Step 3
In templates/<your template>/details.html use the following tags:
{lang_voted_list} - this will show text "Who voted"
{voted_list} - this will show the list of members who has voted
P.S. if you installed a mod that changed details.php and that alteres $image_id variable, this mod might not work properly!
-
wonderful... thanks for this addon - I guess it was not only me waiting for this (no matter if 2 lazy or 2 stoopid to find out, how to do that)
I'll try to implement that tonight :D
-
Hi,
how can i insert more than one voting?
Perhaps u have a gallery and would like to let vote for graphic, quality, and so on ...
Best regards
Michaela
-
that would be a completly different mod ;)
perhaps u should start a new mod request topic
-
What should I change to hide rating option ater vote (in version A) and show only how user rating this picture :?:
something like "U voted already - > 5"
PS. thx great mod
-
you meen this?
http://www.4homepages.de/forum/index.php?topic=5853.0
-
yes but how can i "mix it" with this mod ver. A
-
Hi V@no
Few months back i install version B of this Mod. It was working good.
Now when i try to apply the mod "More than more statistics" I realised that i need Version A of your DB mode. I have undo the changes caused by v B in all three files but i dont know how to remove Database changes.
So what i am asking is. DO i need to remove anything caused by version B installer?
So far i cant see any error but i m not sure that i am not seeing it or is there no any error :roll:
-
Dont worry about that ;) everything is ok :)
-
What about old ratings, which were voted, before this mod installed?
Will be all old votes displayed togeter with new votes from DB or not?
Thank you!
-
What about old ratings, which were voted, before this mod installed?
Unless you are an excellent magician or one powerful sorcerer, you can't get informations about it :mrgreen:
Will be all old votes displayed togeter with new votes from DB or not?
same answer : you must reveal them initially :lol:
-
What about old ratings, which were voted, before this mod installed?
Will be all old votes displayed togeter with new votes from DB or not?
Thank you!
This mod does not affect the image votes/ratings and it is more like a "logging" tool. But, as cheribibi said, you wont be able to tell who voted where and how much was the vote, before this mod installed ;)
-
Thanks! This was my bad english translation. I've spoke about the ratings, not about votes logging, of course.
-
Here is my changes for "Voted stats". I want to display users list with a comma delimeter, instead of a new line.
E.g.:
User1 (7), User2 (12), User3 (24)
instead of
User1 (7)
User2 (12)
User3 (24)
//-----------------------------------------------------
//--- Voted stats -------------------------------------
//-----------------------------------------------------
$sql = "SELECT v.user_id, v.vote, u.user_name
FROM ".VOTED_TABLE." v
LEFT JOIN ".USERS_TABLE." u ON (u.user_id = v.user_id)
WHERE u.user_id = v.user_id AND image_id = ".$image_id;
$result = $site_db->query($sql);
$voted_list = "";
$vcnt = 0;
$sdelimeter = "";
while ($row = $site_db->fetch_array($result))
{
if ($vcnt > 0)
$sdelimeter = ", ";
$vcnt++;
$vote = ($user_info['user_level'] == ADMIN) ? " (".$row['vote'].")" : "";
$voted_list .= $sdelimeter."<a href=\"".$site_sess->url(ROOT_PATH."member.php?action=showprofile&user_id=".$row['user_id'])."\">".$row['user_name']."</a>".$vote;
//member name WITH a link to their profile page
//$voted_list .= $row['user_name'].$vote."<br />"; //member name WITHOUT a link to their profile page
}
$site_template->register_vars(array(
"voted_list" => $voted_list,
"lang_voted_list" => $lang['voted_list']
));
//----- End Voted stats ----------------
-
V@no, can I fetch a number of votes for a user? I want to decrease ulpoad limit for users who didn't votes, or who have less than 2 vote in DB. Thanks!
-
You can use this query:
$sql = "SELECT COUNT(vote) AS num
FROM ".VOTED_TABLE."
WHERE user_id = ".$user_id;
$result = $site_db->query_firstrow($sql);
echo $result['num'];
(Asuming variable $user_id conteins the user id ;))
-
Hi,
I installed Version A of this fantastic MOD.
Now it would be great, if the dropdownlist with the scale 1-5 is only shown, when the user still has not voted. As soon as her has voted, instead of the dropdown list a text like "already voted" should be displayed.
How ca I do that?
Thanks!
-
it seems you need this mod (http://www.4homepages.de/forum/index.php?topic=5853) : [Mod] Rating Button Disabled After Vote
:wink:
-
upps... haven't seen this MOD :oops:
Thanks cheribibi for the hint! :)
-
I'm using the Version A , and i would like know how make only possible see "who Voted" for Admin's ? For Another Users make show "You've No Permission" :mrgreen:
:wink:
-
Hi cheribibi
The MOD you proposed works with Cookies. The votes are stored in the DB, but are not anymore interpreted for a second "vote-try". When I delete the Cookies, I can vote again and I get a second entry in the database.
Now I'm asking, if it is possible to check the database and disabled the dropdownlist with the scale (1-5) when the picture was already voted by a user.
Thanks!!!
-
I'm asking, if it is possible to check the database and disabled the dropdownlist with the scale (1-5) when the picture was already voted by a user.
you're right :arrow: here is the modification:
in this mod (http://www.4homepages.de/forum/index.php?topic=5853) STEP 2 (modifying functions.php), in the new function :
function rate_form($id, $rate_suffix = "", $rating = ""){
find :
global $site_template, $session_info, $lang, $site_sess, $HTTP_COOKIE_VARS, $rate_suffix;
and replace by:
global $site_template, $session_info, $lang, $site_sess, $HTTP_COOKIE_VARS, $rate_suffix;
global $user_info, $site_db; //-----[ [ MOD ] : check user rating in DB
and find :
$no_rateform = (in_array($id, $split_list) || in_array($id, $cookie_rated)) ? "disabled" : 0;
and replace by:
//-----[ [ MOD ] : check user rating in DB
$image_rated_by_user = "";
$sql30 = "SELECT vote
FROM ".VOTED_TABLE."
WHERE image_id =".$id." AND user_id =".$user_info['user_id'];
$row = $site_db->query_firstrow($sql30);
$image_rated_by_user = (isset($row['vote']))? 1 : 0 ;
$rating = (isset($row['vote']))? $row['vote'] : 0 ;
// $no_rateform = (in_array($id, $split_list) || in_array($id, $cookie_rated)) ? "disabled" : 0; // original code
$no_rateform = (in_array($id, $split_list) || in_array($id, $cookie_rated) || $image_rated_by_user) ? "disabled" : 0;
//-----[/[ MOD ] : check user rating in DB ]
here is the work :wink:
-
sure but you can very easy manipulate the vote.
- login with first username
- vote for picture
- logout
- delete cookies
- login with second username
- vote again for the same picture
Ive tried something like this (snippet)
if ($action == "rateimage" && $id) {
$rating = intval($HTTP_POST_VARS['rating']);
if ($user_info['user_level'] != GUEST) {
$sql = "SELECT user_id, image_id, vote
FROM ".VOTED_TABLE."
WHERE image_id = ".$id." AND user_id = ".$user_info['user_id'];
$rated = $site_db->query_firstrow($sql);
$rating = ($rated['vote']) ? $rated['vote'] : $rating;
$hisIp=$_SERVER['REMOTE_ADDR'];
$opsa="SELECT imID, ipAdd FROM ip_vote WHERE imID = ".$id." AND ipAdd = '".$hisIp."'";
if ($site_db->query_firstrow($opsa)) { $rated = TRUE ;}
}else{
$rated = FALSE;
}
$cookie_name = (defined("COOKIE_NAME")) ? COOKIE_NAME : "4images_";
$cookie_rated = isset($HTTP_COOKIE_VARS[$cookie_name.'rated']) ? unserialize(stripslashes($HTTP_COOKIE_VARS[$cookie_name.'rated'])) : array();
if ($rating && $rating <= MAX_RATING && $id) {
if (!isset($session_info['rated_imgs'])) {
$session_info['rated_imgs'] = $site_sess->get_session_var("rated_imgs");
}
and added a new field for the IP, but i have to make some more bugfixes...
It is possible to make the voting check also the IP, so V@no suggestions?
-
and added a new field for the IP, but i have to make some more bugfixes...
It is possible to make the voting check also the IP
by keeping your reasoning, even if you records the ip addresses, someone who knows how to use proxies to hide its real IP will still be able to vote again and again :wink:
-
and added a new field for the IP, but i have to make some more bugfixes...
It is possible to make the voting check also the IP
by keeping your reasoning, even if you records the ip addresses, someone who knows how to use proxies to hide its real IP will still be able to vote again and again :wink:
sure, but at least it is some more protection ;)
-
Ok, since cheribibi did most of the job, its quiet easy to add IP check.
Note, the following will only work with version A of this mod!
Step 1
Execute this MySQL query (you can use phpmyadmin or something simular)
[qcode]ALTER TABLE 4images_voted ADD vote_ip VARCHAR( 15 ) NOT NULL[/qcode](make sure the table prefix is the same as its in your config.php. 4images_ is the default prefix.)
Step 2
Follow the cheribibi's tutorial above
then replace $sql30 = "SELECT vote
FROM ".VOTED_TABLE."
WHERE image_id =".$id." AND user_id =".$user_info['user_id'];
with: $sql30 = "SELECT vote
FROM ".VOTED_TABLE."
WHERE image_id =".$id." AND (user_id =".$user_info['user_id']." OR vote_ip = '".$site_sess->user_ip."')";
Step 3.
in includes/functions.php find:$sql = "INSERT INTO ".VOTED_TABLE."
(user_id, image_id, vote)
VALUES
(".$user_info['user_id'].", ".$image_id.", ".$rating.")";
Replace with:global $site_sess;
$sql = "INSERT INTO ".VOTED_TABLE."
(user_id, image_id, vote, vote_ip)
VALUES
(".$user_info['user_id'].", ".$image_id.", ".$rating.", '".$site_sess->user_ip."')";
I didnt tested this, but theoreticaly it should work ;)
-
V@no, so this IP-check will not allow users from the same IP vote two times for the same picture? Just to get it right, if yes i will test it and post my results.
But, is there any way to do this without the "rate form disable after vote", because if i installthat mod, it will totally change my design (hot or not)?
-
v@no i have a further question related to your MOD. How can i delete all votes from a specific user ?
-
On myphpadmin i think you can do that :roll: , search and after after set again to 0 ...
-
On myphpadmin i think you can do that :roll: , search and after after set again to 0 ...
really? but in whitch table? Iam not good at phpAdmin :)
-
Go to your DB (4images_XX) , there 4images_voted , and after choose "browse" , there you have a list of votes ;)
I've put as prefix 4images, maybe you've another one...but i hope you've understand (sorry for my english)
-
MySQL query:[qcode]DELETE FROM 4images_voted WHERE user_id = XXX[/qcode]where XXX is user id.
And yes, the code above will restrict voting for the same image from same IP, it will not work for guests though.
-
cheribibi, V@no... thanks!! :D
One more questions.
Is it correct, that the dropdownlist is not activ because of the DB entry, but the voting (e.g. 5) is shown becaus of a cookie?.
When I delete the cookies, the dropdown is not activ (perfect), but the voting isn't shown anymore.
Is it possible to show the voting stored in the DB?
Thanks!!
-
I just updated cheribibi's post (hope they dont mind ;))
replace $image_rated = (isset($row['vote']))? $row['vote'] : 0 ;
with: $rating = (isset($row['vote']))? $row['vote'] : 0 ;
-
Hi V@no,
now the MOD is perfect for me!
Again, thanks to you an cheribibi! :D
-
I'm using the Version A , and i would like know how make only possible see "who Voted" for Admin's ? For Another Users make show "You've No Permission" :mrgreen:
:wink:
Anyone can answer me ? :roll:
-
http://www.4homepages.de/forum/index.php?topic=6123.45
-
http://www.4homepages.de/forum/index.php?topic=6123.45
But how make appear a message for non-admin's " You've no permission ... " :?
-
for Admin use:
$vote = ($user_info['user_level'] == ADMIN) ? " (".$row['vote'].")" : "";
for User use:
$vote = ($user_info['user_level'] == USER) ? " (".$row['vote'].")" : "";
and for Admin and User:
???
Sorry i dont no :?
-
http://www.4homepages.de/forum/index.php?topic=6123.45
But how make appear a message for non-admin's " You've no permission ... " :?
try to replace this code :
while ($row = $site_db->fetch_array($result))
{
$vote = ($user_info['user_level'] == ADMIN) ? " (".$row['vote'].")" : "";
$voted_list .= "<a href=\"".$site_sess->url(ROOT_PATH."member.php?action=showprofile&user_id=".$row['user_id'])."\">".$row['user_name']."</a>".$vote."<br />"; //member name WITH a link to their profile page
// $voted_list .= $row['user_name'].$vote."<br />"; //member name WITHOUT a link to their profile page
}
by this one :
if ($user_info['user_level'] == ADMIN) {
while ($row = $site_db->fetch_array($result))
{
$vote = $row['vote'];
$voted_list .= "<a href=\"".$site_sess->url(ROOT_PATH."member.php?action=showprofile&user_id=".$row['user_id'])."\">".$row['user_name']."</a>".$vote."<br />"; //member name WITH a link to their profile page
// $voted_list .= $row['user_name'].$vote."<br />"; //member name WITHOUT a link to their profile page
}
} else {
$voted_list .= "You have no permission!" // or anything you want
}
-
@cheribibi:
if ($user_info['user_level'] == ADMIN) {
while ($row = $site_db->fetch_array($result))
{
$vote = $row['vote'];
$voted_list .= "<a href=\"".$site_sess->url(ROOT_PATH."member.php?action=showprofile&".URL_USER_ID."=".$row[$user_table_fields['user_id']])."\">".$row[$user_table_fields['user_name']]."</a>".$vote."<br />"; //member name WITH a link to their profile page
// $voted_list .= $row[$user_table_fields['user_name']]. $vote."<br />"; //member name WITHOUT a link to their profile page
}
And :
$voted_list .= "You have no permission!" // or anything you want
to :
$voted_list .= $lang['no_permission']; // or anything you want
This text has already been added as part of the core in 4images's lang/english/main.php definition file. ;)
-
@cheribibi:
if ($user_info['user_level'] == ADMIN) {
while ($row = $site_db->fetch_array($result))
{
$vote = $row['vote'];
$voted_list .= "<a href=\"".$site_sess->url(ROOT_PATH."member.php?action=showprofile&URL_USER_ID."=".$row[$user_table_fields['user_id']])."\">".$row[$user_table_fields['user_name']]."</a>".$vote."<br />"; //member name WITH a link to their profile page
// $voted_list .= $row[$user_table_fields['user_name']]. $vote."<br />"; //member name WITHOUT a link to their profile page
}
@TheOracle
well, the code I post was a copy/paste of another code this the topic. please can you also correct all the other codes in this thread ? thanks ! :mrgreen:
-
@Daniel:
Perhaps you're looking for this :
for User use:
$vote = ($user_info['user_level'] >= USER) ? " (".$row['vote'].")" : "";
;)
-
:Dworks perfect thank you very much!
-
I have made a plugin so you can view whitch member had voted in witch file.
My programming and my englisch are not good i know.
You can change a lot on this file. (it's a start for me :lol:)
This is the code
<?php // PLUGIN_TITLE: voted
$nozip = 1;
define('IN_CP', 1);
$root_path = "./../../";
define('ROOT_PATH', $root_path);
require(ROOT_PATH.'admin/admin_global.php');
show_admin_header();
function display_results() {
global $site_db;
$sql = 'SELECT * FROM `4images_voted` LIMIT 0, 30 ';
$result = $site_db->query($sql);
while($row = $site_db->fetch_array($result)){
$user_id = $row["user_id"];
$postcard_date = date("D d M, Y g:i a", $row["postcard_date"]);
$image_id = $row["image_id"];
$image_name = $row["image_name"];
$image_thumb_file = $row["image_thumb_file"];
$cat_id = $row["cat_id"];
$postcard_headline = $row["postcard_headline"];
$postcard_message = $row["postcard_message"];
$postcard_sender_name = $row["postcard_sender_name"];
$postcard_sender_email = $row["postcard_sender_email"];
$postcard_recipient_name = $row["vote"];
$postcard_recipient_email = $row["postcard_recipient_email"];
$cat_id = $row['cat_id'];
$pict_id = get_media_code($row['image_media_file'], $image_id, $cat_id, $row['image_name']);
$image_media_file = get_media_code($row['image_media_file'], $image_id, $cat_id, $row['image_name']);
$template = TEMPLATE_PATH;
echo "
<font color=\"#000000\" size=\"1\"></td>
</tr>
</tbody>
</table></td>
</tr>
</tbody>
</table>
<table border=\"1\">
<tr>
<td height=\"15\" width=\"119\" align=\"center\" bgcolor=\"#E5E5E5\">
<p align=\"center\"><b>Gebruiker</b></td>
<td height=\"15\" width=\"148\" align=\"center\" bgcolor=\"#E5E5E5\"><b>
Cijfer</b></td>
<td height=\"15\" width=\"286\" align=\"center\" bgcolor=\"#E5E5E5\"><b>
Wallpaper</b></td>
</tr>
<tr>
<td height=\"21\" width=\"119\" align=\"center\" bgcolor=\"#F5F5F5\">
<font color=\"#000000\" size=\"2\" face=\"Tahoma\" >$user_id</td>
<td height=\"21\" width=\"148\" align=\"center\" bgcolor=\"#F5F5F5\">
<font face=\"Tahoma\"> <font color=\"#000000\" size=\"2\" >
$postcard_recipient_name</font><font size=\"2\"> </font> <font color=\"#000000\" size=\"1\" >
<a href=\"mailto:$postcard_recipient_email\">
<font color=\"#000000\" size=\"2\">$postcard_recipient_email</a></font></td>
<td height=\"21\" width=\"286\" align=\"center\" bgcolor=\"#F5F5F5\">
<font color=\"#555555\" size=\"2\" face=\"Tahoma\" >
(<a href=\"../../details.php?image_id=$image_id\" target=\"_blank\">ID: $image_id</a>)
</font></td>
</tr>
</table>\n";
END; }
}
display_results();
show_admin_footer();
?>
Yes i change a other plugin to get this.
I enybody has a better code 8)
-
@ theoracle
yes, thank you, very nice. :D
>=
daniel
-
http://www.4homepages.de/forum/index.php?topic=6123.45
But how make appear a message for non-admin's " You've no permission ... " :?
try to replace this code :
while ($row = $site_db->fetch_array($result))
{
$vote = ($user_info['user_level'] == ADMIN) ? " (".$row['vote'].")" : "";
$voted_list .= "<a href=\"".$site_sess->url(ROOT_PATH."member.php?action=showprofile&user_id=".$row['user_id'])."\">".$row['user_name']."</a>".$vote."<br />"; //member name WITH a link to their profile page
// $voted_list .= $row['user_name'].$vote."<br />"; //member name WITHOUT a link to their profile page
}
by this one :
if ($user_info['user_level'] == ADMIN) {
while ($row = $site_db->fetch_array($result))
{
$vote = $row['vote'];
$voted_list .= "<a href=\"".$site_sess->url(ROOT_PATH."member.php?action=showprofile&user_id=".$row['user_id'])."\">".$row['user_name']."</a>".$vote."<br />"; //member name WITH a link to their profile page
// $voted_list .= $row['user_name'].$vote."<br />"; //member name WITHOUT a link to their profile page
}
} else {
$voted_list .= "You have no permission!" // or anything you want
}
Thanks its working very well :mrgreen:
-
@stoleti:
please read this post in the mean time :
http://www.4homepages.de/forum/index.php?topic=6123.msg60862#msg60862
@daniel:
Glad it worked out for you. ;)
-
@stoleti:
please read this post in the mean time :
http://www.4homepages.de/forum/index.php?topic=6123.msg60862#msg60862
@daniel:
Glad it worked out for you. ;)
I've made that modifications 8)
-
i have a problem with this mod... all vote_date entries are "0" :?:
i need the vote date for a toplist - i will select all images they have rating x with x votes and order by last vote date.... but without vote_date ist impossible :|
-
This mod does not store the date...sorry.
-
hm, iam confused...
why i have in 4images_voted table a vote_date?
-
most probably after installing one of these mods:
http://www.4homepages.de/forum/index.php?topic=6484.0
http://www.4homepages.de/forum/index.php?topic=6404.0
-
ok, thx :/
-
V@no, the IP-check is not working.
I can vote still twice with 2 diffrefrent usernames after deleting cookies :roll:
edit: when i make the steps, i can even vote twice for an image :roll:
-
The code by cheribi plus mine addition from this (http://www.4homepages.de/forum/index.php?topic=6123.msg60531#msg60531) page doesnt work? did you check all the step and make sure everything is correctly modifyed?
I've tested it on a fresh 4images, it worked just fine, in fact, I'm using the exact code on my site...
-
yes!
i tried first to install the mod [rating buttoin disabled...] , then your update for the votes to database, after that cheribis code and after that you modifications. Dont work. After that, i restored my backups and tried just to add the code from charibi and your addition - dont work either.
The problem is, that i have many users online, and now i have errors in the database, users are getting mad etc :(
Maybe i have made some error, even if i checked it many times, can i post my functions.php and my page_header in order to you to make the changes? I just dont wanna risk more doubble-votings from my users.
thanks for the support, i really appreciate it.
Georgi
-
next great addon for this mod could be something like "show only 10 (xx) last voters" :idea:
-
you mean listed in the details page?
-
yeah later list could be a really long :wink:
-
hallo,
ich hab das mod (version a) insalliert und bekomme beim abstimmen folgenden fehler:
DB Error: Bad SQL Query: SELECT user_id, image_id, vote FROM 4images_voted WHERE image_id = 2329 AND user_id = 1
Unknown column 'user_id' in 'field list'
kann mir da mal jemand helfen?
danke
-
huh? and what fields are in your 4images_voted table? Hope you didnt change anything that were not supposed to...
-
Thanx for answering.
I didn't change anything that is not supposed to be changed, I made everything as advised. look---> http://fryz.fr.funpic.de/4images/statistics.php
In the moment i vote for a photo in my gallery, the following hint appears:
DB Error: Bad SQL Query: SELECT user_id, image_id, vote FROM 4images_voted WHERE image_id = 2354 AND user_id = 2
Unknown column 'user_id' in 'field list'
DB Error: Bad SQL Query: INSERT INTO 4images_voted (user_id, image_id, vote) VALUES (2, 2354, 5)
Unknown column 'user_id' in 'field list'
-
So, what are the fields in your 4images_voted table?
-
VOTED_TABLE INT 11 ----- UNSIGNED not null 0 -----
you mean this?
-
No, I mean this something like this:[qcode]CREATE TABLE `4images_voted` (
`id` mediumint(8) NOT NULL auto_increment,
`user_id` mediumint(8) unsigned NOT NULL default '0',
`image_id` mediumint(8) unsigned NOT NULL default '0',
`vote` int(2) unsigned NOT NULL default '0',
`date` int(11) NOT NULL default '0',
PRIMARY KEY (`id`),
KEY `user_id` (`user_id`),
KEY `image_id` (`image_id`)
) ENGINE=MyISAM;[/qcode](this is how it looks like when you export it in phpmyadmin)
or from mysql shell itself:[qcode]mysql> SHOW columns FROM 4images_voted;
+----------+-----------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+----------+-----------------------+------+-----+---------+----------------+
| id | mediumint(8) | | PRI | NULL | auto_increment |
| user_id | mediumint(8) unsigned | | MUL | 0 | |
| image_id | mediumint(8) unsigned | | MUL | 0 | |
| vote | int(2) unsigned | | | 0 | |
| date | int(11) | | | 0 | |
+----------+-----------------------+------+-----+---------+----------------+
5 rows in set (0.00 sec)[/qcode]
I think you should delete the table and run the installer again.
-
I have the same code like :
DB Error: Bad SQL Query: INSERT INTO 4images_voted (user_id, image_id, vote) VALUES (, 12, 3)
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 ' 12, 3)' at line 4
and my table on myphpadmin is like:
----------------------------------------------------
#
# Tablo yapısı : `4images_voted`
#
DROP TABLE IF EXISTS `4images_voted`;
CREATE TABLE `4images_voted` (
`user_id` mediumint(8) unsigned NOT NULL default '0',
`image_id` mediumint(8) unsigned NOT NULL default '0',
`vote` int(2) unsigned NOT NULL default '0',
KEY `user_id` (`user_id`),
KEY `image_id` (`image_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
whats wrong?
NOTE: I had already installed "more and more statistics MOD" before this mod.
-
In the first page you say:
Open /includes/functions.php
Step 2.2
Find next: $sql = "UPDATE ".IMAGES_TABLE."
SET image_votes = ($image_votes + 1), image_rating = '$new_rating'
Add before:
if ($user_info[$user_table_fields['user_id']] != GUEST) {
$sql = "INSERT INTO ".VOTED_TABLE."
(user_id, image_id, vote)
VALUES
(".$user_info[$user_table_fields['user_id']].", ".$image_id.", ".$rating.")";
$site_db->query($sql);
}
but in my function.php I coudnt find the code you told but I have this code instead
$sql = "UPDATE ".IMAGES_TABLE."
SET image_votes = ($old_votes + 1), image_rating = '$new_rating'
WHERE image_id = $image_id";
$site_db->query($sql);
why my code is different
should I follow the version B?
-
After i vote..apear this:
DB Error: Bad SQL Query: INSERT INTO 4images_voted (user_id, image_id, vote) VALUES (, 19, 1)
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 ' 19, 1)' at line 4
Why?
-
Sorry, redo steps 1 and 2.2
-
but in my function.php I coudnt find the code you told but I have this code instead
$sql = "UPDATE ".IMAGES_TABLE."
SET image_votes = ($old_votes + 1), image_rating = '$new_rating'
WHERE image_id = $image_id";
$site_db->query($sql);
why my code is different
should I follow the version B?
I have the same problem
-
yes, insert the new code above
$sql = "UPDATE ".IMAGES_TABLE."
SET image_votes = ($old_votes + 1), image_rating = '$new_rating'
P.S. I've updated the original post, thanks.
-
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);
$sql = "UPDATE ".IMAGES_TABLE."
SET image_votes = ($old_votes + 1), image_rating = '$new_rating'
/*line 555 >>>*/ if ($user_info[$user_table_fields['user_id']] != GUEST) {
$sql = "INSERT INTO ".VOTED_TABLE."
(user_id, image_id, vote)
VALUES
(".$user_info[$user_table_fields['user_id']].", ".$image_id.", ".$rating.")";
$site_db->query($sql);
}
WHERE image_id = $image_id";
$site_db->query($sql);
}
}
The code it's ok?
because i have a problem >>>> Parse error: syntax error, unexpected '[', expecting ']' in /home/etop100/public_html/concurs/includes/functions.php on line 555
-
ABOVE (before), not BELOW (after) ;)
-
ups ... thx
but i steel have this error:
DB Error: Bad SQL Query: INSERT INTO 4images_voted (user_id, image_id, vote) VALUES (, 19, 1)
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 ' 19, 1)' at line 4
Version 1.7.1
-
I have the same code like :
DB Error: Bad SQL Query: INSERT INTO 4images_voted (user_id, image_id, vote) VALUES (, 12, 3)
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 ' 12, 3)' at line 4
and my table on myphpadmin is like:
----------------------------------------------------
#
# Tablo yapısı : `4images_voted`
#
DROP TABLE IF EXISTS `4images_voted`;
CREATE TABLE `4images_voted` (
`user_id` mediumint(8) unsigned NOT NULL default '0',
`image_id` mediumint(8) unsigned NOT NULL default '0',
`vote` int(2) unsigned NOT NULL default '0',
KEY `user_id` (`user_id`),
KEY `image_id` (`image_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
whats wrong?
NOTE: I had already installed "more and more statistics MOD" before this mod.
The same problem!
-
I already answered you...you dont have to repeat yourself 3 times...
Sorry, redo steps 1 and 2.2
-
Now it works perfect thnx V@no but it displays
who voted: user1
user2
user3
isnt it better to display user1,user2,user.....how can we change?
more import is (as asked before many times) I want the get vote in the comment table...
I mean
user1 ..... his comment ....and his vote ...not listing in details table
it is really important for me?
-
Thanks for the mod, works great =D now I'm just trying to find out how to disable guest voting =\
-
[qcode]CREATE TABLE `4images_voted` (
`id` mediumint(8) NOT NULL auto_increment,
`user_id` mediumint(8) unsigned NOT NULL default '0',
`image_id` mediumint(8) unsigned NOT NULL default '0',
`vote` int(2) unsigned NOT NULL default '0',
`date` int(11) NOT NULL default '0',
PRIMARY KEY (`id`),
KEY `user_id` (`user_id`),
KEY `image_id` (`image_id`)
) ENGINE=MyISAM;[/qcode]
So I get the right table in the sql, but not with the voted_a_install.php from your zip from the first posting.
The table which is craeted by the install-php is named "VOTED_TABLE" then I got BD Errors, table not exist
-
Step 3
Open /includes/constants.php
Add just before closing ?>define('VOTED_TABLE', $table_prefix.'voted');
-
I did it as it was written by v@no but it didn't help...
-
You must do step 3 before you run the installer. if your new table named as "VOTED_TABLE", then you did not do properly the step 3.
-
That could be the mistake... :(
-
What should I change in the code so everybody, admin, guest and users can see what was the vote of each voted member on image details page?
Best regards from Spain and thank you very much :D
Here is a little addon for version A of this mod which I promised for a long time and never published it...
It will show who voted and if u logged in as admin also show what was the vote of each voted member on image details page (details.php)
Step 1
Open details.php
Find://-----------------------------------------------------
//--- Print Out ---------------------------------------
//-----------------------------------------------------
Insert above://-----------------------------------------------------
//--- Voted stats -------------------------------------
//-----------------------------------------------------
$sql = "SELECT v.user_id, v.vote, u.user_name
FROM ".VOTED_TABLE." v
LEFT JOIN ".USERS_TABLE." u ON (u.user_id = v.user_id)
WHERE u.user_id = v.user_id AND image_id = ".$image_id;
$result = $site_db->query($sql);
$voted_list = "";
while ($row = $site_db->fetch_array($result))
{
$vote = ($user_info['user_level'] == ADMIN) ? " (".$row['vote'].")" : "";
$voted_list .= "<a href=\"".$site_sess->url(ROOT_PATH."member.php?action=showprofile&user_id=".$row['user_id'])."\">".$row['user_name']."</a>".$vote."<br />"; //member name WITH a link to their profile page
// $voted_list .= $row['user_name'].$vote."<br />"; //member name WITHOUT a link to their profile page
}
$site_template->register_vars(array(
"voted_list" => $voted_list,
"lang_voted_list" => $lang['voted_list']
));
//----- End Voted stats ----------------
Step 2
In lang/<your language>/main.php at the very end, above closing ?> insert:$lang['voted_list'] = "Who voted";
Step 3
In templates/<your template>/details.html use the following tags:
{lang_voted_list} - this will show text "Who voted"
{voted_list} - this will show the list of members who has voted
P.S. if you installed a mod that changed details.php and that alteres $image_id variable, this mod might not work properly!
-
$vote = ($user_info['user_level'] == ADMIN) ? " (".$row['vote'].")" : "";
To this: $vote = " (".$row['vote'].")";
-
Thank you very much V@no
-
I think I have another problem... :roll:
I tried to delete some votes from the database. I did it from phpmyadmin but I still can see them if i check the top images from my gallery...
Even I deleted them, they are showed in the top yet...
Do you understand what I mean?
Sorry for my horrible english :oops:
-
Correct, thats because this mod does not change the way 4images stores the total votes/rating, its being saved into 4images_images table for each image individualy. So, what you see at top page, is the information stored in 4images_images table.
-
Thank you again V@no :D
Is there any solution?. It is no so easy to change it by hand because people is voting often their own pics to appear in the top and I have to delete it... :roll:
Correct, thats because this mod does not change the way 4images stores the total votes/rating, its being saved into 4images_images table for each image individualy. So, what you see at top page, is the information stored in 4images_images table.
-
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
-
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?
-
I've attached the installers to the original post.
-
Its possible list at our profiles, the users who have rate our images ???
:P
-
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
-
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)
-
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
-
....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
-
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.
-
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
-
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
-
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
-
This for see who rate in details.
In details.php file,
find:
//-----------------------------------------------------
//--- Show Image --------------------------------------
//-----------------------------------------------------
add before:
//-----------------------------------------------------
//--- 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:
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:
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:
"image_hits" => $image_row['image_hits'],
add after:
"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 ?>:
$lang['vote_user_name'] = "Voted by: {get_vote_user_name}";
In templates/your_template/details.html file,
use:
{vote_user_id} (for URL)
{lang_vote_user_name}
{vote_user_value}
and create way you want. ;)
-
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
-
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:
?>
INSERT BEFORE
// 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
-
i thing, it is not working :wink:
KurtW
-
oh yeah it is. you have to use the code in the thread vom V@no of course. and after that: use my piece and put it in rating_new.php.
notice: i have only members allowed to vote, so it is possible to save username, id, voting and a lot more ;)
-
sorry, but i thing no...
you use a old mode code.
in rating_new.php:
search:
if (($vote_sent >= 1 && $vote_sent <= $units)) {
$update = "UPDATE " . IMAGES_TABLE . " SET image_votes='".$count_new."', image_rating='".$sum_new."', image_used_ips='".$ip."', image_used_ids='".$old_used_ids."".$leer."".$new_used_id."' WHERE image_id='" . $image_id_sent . "'";
$result = $site_db->query($update);
after this code you can add the new code from c-bass
Kurt
-
Hey guys
I already installed the [MOD] Votes saved in DB. I use Option A. I use a table called "voted" to store the image_id, the user_id, vote, and user_IP. The problem is when I delete an image or an entire category, it's ok. 4images delete the records in the images table, but doesn't delete the record in the voted table. How can we repair this?
I looked for the code to delete the image
$sql = "DELETE FROM ".IMAGES_TABLE."
WHERE image_id = $image_id";
$del_img = $site_db->query($sql);
and the code to delete the comments
$sql = "DELETE FROM ".COMMENTS_TABLE."
WHERE image_id = $image_id";
$del_com = $site_db->query($sql);
We should add something like this somewhere (I don't know how) -- PLease Help
$sql = "DELETE FROM ".VOTED_TABLE."
WHERE image_id = $image_id";
$del_img = $site_db->query($sql);
In ACP we should do something too.
Need some help from the author and the good programmers here to solve this.
Cheers
David
-
the same goes for deleting users. the user votes also have to be deleted.
-
Yes, c-bass you are right. But the problem I have is where to put the code. I know MySQL but I'm a newbie in PHP coding.
I need some help
Cheers
David
-
David... i think in admin/users.php
and delete the user...not the images :wink:
$sql = "DELETE FROM ".VOTED_TABLE."
WHERE user_id = $user_id";
$site_db->query($sql);
-
:?:
Wie müßte bloß die sql-Abrafe lauten wenn man nur die neuen Votes aus dem VOTED_TABLE errechnen und in den images_table damit updaten wollen würde...
How can i use only new new votes (just from voted_table) to inset this in the image_table
:?:
a happy new year :wink:
-
Du kannst für jede einzelne Kategorie angeben wer voten darf... ACP -> Kategorien bearbeiten
-
From Configuration statistics.php "Note: Save Votes in DB type A must be installed and altered by votetime"
http://www.4homepages.de/forum/index.php?topic=6123.0
How to do that?
In der statistics.php ist der Tabellenname VOTED_TABLE vorgegeben.
Meine Tabelle heißt aber 4images_voted und da wird auch alles reingeschrieben. Zumindest wird eine Statistik erstellt
Die VOTED_TABLE ist leer.
Die Tabelle wird in der statistics.html angzeigt, wenn ich die Funktion aktiviere (1 statt 0).
Chris
-
Ich habe jetzt einfach mal testweise bei den Bildern ein Datum (1200055080) eingetragen.
In der Statistik werden die Votes dann gezählt.
Neue Bewertungen werden aber nicht dazugezählt. ;-(
Ich glaube, dass die Anpasssung fehlt: "Note: Save Votes in DB type A must be installed and altered by votetime".
http://www.4homepages.de/forum/index.php?topic=6123.0
Kann mir jemand dabei helfen?
Chris.
-
Hallo!
Ich habe den MOD Votes saved in DB - Option A installiert und versuchte die IP-Adresse zu speichern beim Berwerten.
Dazu machte ich folgendes:
DB-Code:
ALTER TABLE 4images_voted ADD vote_ip VARCHAR( 15 ) NOT NULL
includes/functions.php
Suche:
$sql = "INSERT INTO ".VOTED_TABLE."
(user_id, image_id, vote)
VALUES
(".$user_info['user_id'].", ".$image_id.", ".$rating.")";
Ersetze mit:
global $site_sess;
$sql = "INSERT INTO ".VOTED_TABLE."
(user_id, image_id, vote, vote_ip)
VALUES
(".$user_info['user_id'].", ".$image_id.", ".$rating.", ".$site_sess->user_ip.")";
Jedoch dies alles funktionierte nicht.
Es stand nur "NULL" in "vote_ip". "global $site_sess;" vergass ich nicht...
Ich versuchte auch mit "$session_info['session_ip']" anstatt mit "$site_sess->user_ip".
Könntet ihr mir bitte weiterhelfen.
Vielen Dank
Gruss Jones
4images: 1.7.6
Php Version: 4.4.7
-
Hallo,
der MOD interessiert mich sehr, allerdings ist der Link zur Installationsdatei von Seite 1 nicht mehr aktuell. Hat hier jemand noch diese Datei oder den entsprechenden sql Befehl... ???
__________
I am very interested of this Mod, but the link to the installer at side 1 isn´t active. Has here anyone the file or the sql order...???
Besten Dank
ThanX
cliff
-
all needed files are attached to the original post:
http://www.4homepages.de/forum/index.php?topic=6123.msg26633#post_attach
-
ohhh... call me an idiot! I didn´t see that file... Now it´s running wonderful!
ThanX a lot...
best regards
cliff
-
This mod is fantastic Thx for it.
It's working very good.
It's posiible to have data and hour of voting on photo?
http://ogk.cal.pl/details.php?image_id=684
After my nick.
-
is it possible to delete my vote and re-vote? Or change the vote? But aain everyone must give vote for once not more then once
-
Hello.
How can I prevent from users that are voting from own photo?
-
Thx for this Mod,
it works great on my Site. :D
Ralf
-
guys, anyone knows how to join this MOD and this MOD http://www.4homepages.de/forum/index.php?topic=4023.0?
I run a website where people comment, but are not very keen in setting a rating....
so I would really appreciate any help in joining of this MOD with this MOD http://www.4homepages.de/forum/index.php?topic=4023.0
but i need that MOD to let visitors post comment ONLY with voting and vote without comment
EDIT
Nevermind...
-
OK guys... I solved it...
Here is what you do if you want to have a comment ONLY if your user rated an image... and the user can VOTE with no comments for the image...
1. Install this MOD :lol:
2. in comments_form.html
add in the place where you would like this form to appear...
<!--new rate system -->
{if rate_form}
<tr>
<td>
{rate}
</td>
<td valign="bottom">
<select name="rating" class="select" {rate_button}>
{rate_options}
</select>
<input type="hidden" name="action" value="rateimage" />
<input type="hidden" name="id" value="{image_id}" />
</td>
</tr>
{endif rate_form}
<!-- end of new rate system -->
3. in details.php
find:
if ($user_name == "") {
and ADD BEFORE
//no comment without rating
//user rated before?
$image_rated_by_user = "";
$sql = "SELECT vote
FROM ".VOTED_TABLE."
WHERE image_id =".$id." AND user_id =".$user_info['user_id'];
$row = $site_db->query_firstrow($sql);
$image_rated_by_user = (isset($row['vote']))? 1 : 0 ;
//user is the owner of image?
$is_image_owner2 = "";
$sql2 = "SELECT i.image_id, i.cat_id, i.user_id, i.image_name, i.image_description, i.image_keywords, i.image_date, i.image_active, i.image_media_file, i.image_thumb_file, i.image_download_url, i.image_allow_comments, i.image_comments, i.image_downloads, i.image_votes, i.image_rating, i.image_hits".$additional_sql.", c.cat_name".get_user_table_field(", u.", "user_name").get_user_table_field(", u.", "user_email")."
FROM (".IMAGES_TABLE." i, ".CATEGORIES_TABLE." c)
LEFT JOIN ".USERS_TABLE." u ON (".get_user_table_field("u.", "user_id")." = i.user_id)
WHERE i.image_id = ".$id." AND i.image_active = 1 AND c.cat_id = i.cat_id";
$image_row2 = $site_db->query_firstrow($sql2);
$is_image_owner2 = ($user_info['user_id'] == $image_row2['user_id']) ? 1 : 0;
if (!$is_image_owner2 && $image_rated_by_user == 0 && $rating == "--") {
$msg .= (($msg != "") ? "<br />" : "").$lang['rating_required'];
$error = 1;
}
//end no comment without rating
3.1
find
update_comment_count($id, $user_info['user_id']);
and ADD AFTER
//save rating from comment form
if (!$is_image_owner2 && $image_rated_by_user == 0) {
update_image_rating($id, $rating);
}
//end save rating from comment form
4. in your language main.php
find
//-----------------------------------------------------
//--- Image Details -----------------------------------
//-----------------------------------------------------
and add after
$lang['rating_required'] = "You did not include the rating for this image";
this should work for you...
I can not remove one bug....
I have not removed the original rate form from below the image, so that user can vote as before and that rate form works perfectly... and shows the rating you have gived to the image....
but if you add a rating from the comments form, it gets entered into the database and the comment appears.. but the rate form does not change... thus letting the user vote again from the separate rate form...
anyways any ideas please.. I ran out of steam today trying to resolve this one...
-
Not quiet sure what exactly is the problem...it's not clear...also your tutorial is a mix of several other mods you've installed and would not work for everyone else, unfortunately.
-
well... trouble is, that when the comment is posted, the rating value is transfered with POST... database updates..
but the data for the rate form (not the one listed by me, but the one modded with the modification listed in this topic to show the user vote after he voted) does not get pulled from the database correctly...
EDIT
fixed by replacing in page_header.php
line
if ($action == "rateimage" && $id) {
with line
if ($action == "rateimage" && $id || $action == "postcomment" && $id) {
-
Hey guys
I already installed the [MOD] Votes saved in DB. I use Option A. I use a table called "voted" to store the image_id, the user_id, vote, and user_IP. The problem is when I delete an image or an entire category, it's ok. 4images delete the records in the images table, but doesn't delete the record in the voted table. How can we repair this?
I agree with it. For now I've deleted more than 25000 rows from 4images_voted table via phpMyAdmin:
DELETE
FROM `4images_voted`
WHERE NOT EXISTS
( SELECT *
FROM `4images_images`
WHERE 4images_images.image_id = 4images_voted.image_id
);
DELETE
FROM `4images_voted`
WHERE NOT EXISTS
( SELECT *
FROM `4images_users`
WHERE 4images_users.user_id = 4images_voted.user_id
);
But we need a correction on core delete (image/user) function.
-
This mod is super. But is it possible that users can't see who voted on photo? Now they can only see who voted but they can't see the point's.
I want that only admin know who voted on picture.
-
I want that only admin know who voted on picture.
Open details.php, find
//--- Voted stats -------------------------------------
and before
$site_template->register_vars(array(
insert something like (change YOURNAME to your login)
if ($user_info['user_name'] !="YOURNAME") {
$voted_list = "Image was rated";
}
-
This mod is super. But is it possible that users can't see who voted on photo? Now they can only see who voted but they can't see the point's.
I want that only admin know who voted on picture.
What mod/code are you referring to?
@Joss:
better use if ($user_info['user_level'] == ADMIN)
{
// your code here
}
;)
-
@Joss:
better use if ($user_info['user_level'] == ADMIN)
{
// your code here
}
;)
[/quote]
When a putt Your code it's not working :/ I still see nick as quest or normal user.
if ($user_info['user_name'] !="YOURNAME") {
$voted_list = "Image was rated";
}
Code above is working but how add more admins?
-
Is this possible?:
Create new category (photo of the month). I put for example 10 photos and user vote for it. But - on gallery a have voting scale 1-10.
Is this possible to do for this category:
- only one point - user can give only 1 (in other categories all the time 1-10)
- hide for user info about voting - only admins can see it. (now user can see in bellow thumbnail)
-
Ich benutze [MOD] Votes saved in DB in der Version B.
Erstmal ein Dank an V@no. Es funktioniert ausgezeichnet. Es gibt keine Probleme.
Nun möchte ich verhindern, dass User ihre eigenen Bilder bewerten können.
Dafür habe ich ein Mod von 2006 gefunden, dass die functions.php ändert.
User darf sein eigenes Bild nicht bewerten:
http://www.4homepages.de/forum/index.php?topic=489.msg2197#msg2197 (http://www.4homepages.de/forum/index.php?topic=489.msg2197#msg2197)
Ich weiß nun nicht, ob sich diese beiden Mods vertragen.
Oder gibt es eine andere Möglichkeit, das [MOD] Votes saved in DB Version B, so anzupassen, dass eigene Bilder nicht bewertet werden können?
Nachtrag: ich habe es einfach ausprobiert und es klappt dann nicht mehr. Zwar können die eigenen Bilder nicht mehr bewertet werden, aber die Datenbank funktioniert nicht mehr.
Mit dem Ergebnis, dass jetzt wieder mehrfache Bewertungen aller anderen Bilder möglich sind.
Daher noch einmal die Frage, ob es eine anderes Mod gibt, dass man einsetzen könnte und das sich mit "Votes saved in DB in der Version B" verträgt?
Wäre schön, wenn sich mal jemand äußern könnte.
Gruß
Artemios
-
Vano, hi.
Explain me pls, only votes of registred users save in DB? what about guests?
After cookie delete, every guest can vote again!
Теперь по-русски. Проблема такова, что действительно, после удаления кукисов возможность голосования остается у гостей (-1), и их голос не сохраняется в БД.
Что можно сделать с этим?
-
It's possible?
I want that average of votes will be shown only for admins and the autor of the foto.
-
Hallo,
habe ein kleines Problem in (/member.php?action=showprofile&user_id=552), hätte es gerne so wie bei (Kommentare: (19) alle anzeigen)
Bilder bewertet (15) alle anzeigen (hier fehlt mir die Seite) bekomme ich nicht hin
Registriert seit: 22.07.2009
Aktualisiert: 04.04.2012 09:22
Kommentare: (19) alle anzeigen (geht)
Kommentare schreiben Passives Mitglied, Beginner, Aktives Mitglied, Super, Mega
Email:
Homepage:
ICQ:
toni's Favoriten: (34) alle anzeigen (geht)
Gruss Lailash
-
Vano, hi.
Explain me pls, only votes of registred users save in DB? what about guests?
After cookie delete, every guest can vote again!
The only solution is to don't allow vote for guests.
Hallo,
habe ein kleines Problem in (/member.php?action=showprofile&user_id=552), hätte es gerne so wie bei (Kommentare: (19) alle anzeigen)
Bilder bewertet (15) alle anzeigen (hier fehlt mir die Seite) bekomme ich nicht hin
Registriert seit: 22.07.2009
Aktualisiert: 04.04.2012 09:22
Kommentare: (19) alle anzeigen (geht)
Kommentare schreiben Passives Mitglied, Beginner, Aktives Mitglied, Super, Mega
Email:
Homepage:
ICQ:
toni's Favoriten: (34) alle anzeigen (geht)
Gruss Lailash
Yes, possible, but that would be a completely knew mod ;)
Try request it at mod request section.
-
Instructions from version A - first post in this topic.
"Step 4
Download this installer.
Unpack it and upload to your 4images root.
Start it http://yoursite/4images/voted_b_install.php"
So if I use method A I should download voted_b_install yes ?
-
...So if I use method A I should download voted_b_install yes ?
no, voted_a_install.php, This is a read error in the instruction.
-
thx but it's a pity that when i install this mod : http://www.4homepages.de/forum/index.php?topic=6157.0 (http://www.4homepages.de/forum/index.php?topic=6157.0) (vote and comment sending together) the rating is not saving to database - there must be some error i think...unfortunatelly :(
-
Used version B, worked right away :mrgreen:
Big thanks !
J.
-
Maybe a rather stupid question, but will this work on the latest version (1.7.11)?