Cast vote if certain string is in comment? Cast vote if certain string is in comment?
 

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]

Main Menu

Cast vote if certain string is in comment?

Started by bitcloud, November 21, 2006, 01:38:40 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

bitcloud

Hey there,

I'm trying to figure out how to either:
a. have a vote cast when a certain string is entered into comments (will be entered via a smiley, such as :great:, :good:, :bad: etc)

or
b. have each vote register as a comment also, saying ":great:" ":good:" etc so that each users opinions are public and each vote is a public comment...

does anyone have any clues as to where I should start digging around? (or can suggest any alternative methods to achieve said voting/commenting integration?
kind regards
lachlan

Nibbler


bitcloud

Thanks a heap nibbler.. that got me started!

I've managed to get this working so that a comment is added when a user votes by (in ratepic.php)
finding:
// Update the votes table
$sql = "INSERT INTO {$CONFIG['TABLE_VOTES']} " . "VALUES ('$pic', '$user_md5_id', '$curr_time')";
$result = cpg_db_query($sql);


and after that line adding:
// BEGIN BITCLOUDS VOTE COMMENTER MACHINERY
echo $rate;
if ($rate == 5) {
$msg_votecomment = ":this is good:";}
else {
$msg_votecomment = ":this is bad:";
};

$insertvotemsg = cpg_db_query("INSERT INTO {$CONFIG['TABLE_COMMENTS']} (pid, msg_author, msg_body, msg_date, author_md5_id, author_id, msg_raw_ip, msg_hdr_ip) VALUES ('$pic', '" . addslashes(USER_NAME) . "', '$msg_votecomment', NOW(), '$user_md5_id', '$user_id', '$raw_ip', '$hdr_ip')");
// END BITCLOUDS VOTE COMMENTER MACHINERY


that works great, so i guess thats a "mod" completed there... (unless you can see any backend errors i've overlooked - it seems to work fine on the surface)

But I'm stuck on this next part...
I wanted to have clicking on the ratings buttons also parse any text already entered into the comment line as well as the rating text if there is a comment written and a vote button is clicked... (ie you type in a comment and click 'rate' and it sends your comment along with the above "$msg_votecomment" through to the comment cpg_db_query)

I'm fumbling here, but i was playing around with:

echo $rate;
if ($rate == 5) {
$msg_votecomment = ":this is good:";}
else {
$msg_votecomment = ":this is bad:";
};

$insertvotemsg = cpg_db_query("INSERT INTO {$CONFIG['TABLE_COMMENTS']} (pid, msg_author, msg_body, msg_date, author_md5_id, author_id, msg_raw_ip, msg_hdr_ip) VALUES ('$pic', '" . addslashes(USER_NAME) . "', '$msg_votecomment $msg_body', NOW(), '$user_md5_id', '$user_id', '$raw_ip', '$hdr_ip')");

(the difference being that I've got "$msg_votecomment $msg_body" instead of simply "$msg_votecomment"

this looks clumsy and wrong to me, and I can't imagine how it would parse the comment box data without clicking the ok button - it's a long shot, but I imagine it's something *along* those lines...

have you got any further thoughts on this nibbler?