Allegro.cc - Online Community

Allegro.cc Forums » Off-Topic Ordeals » Team Allegro

This thread is locked; no one can reply to it. rss feed Print
Team Allegro
Jakub Wasilewski
Member #3,653
June 2003
avatar

Hm, strange :). 12 people have voted, and there is only 23 votes altogether. That means some 13 of them are missing, BAF? :P. Also, I voted for someone 3 times and he's got only 2 votes in the table.

Looks like Operation Mindf*ck strikes again :P. Or a typo in PHP code ;).

---------------------------
[ ChristmasHack! | My games ] :::: One CSS to style them all, One Javascript to script them, / One HTML to bring them all and in the browser bind them / In the Land of Fantasy where Standards mean something.

Oscar Giner
Member #2,207
April 2002
avatar

There's some bug in BAF code. I voted, but only two of them were counted.

Jakub Wasilewski
Member #3,653
June 2003
avatar

[Danger: a joke]BAF got sure that every third vote not on him gets ruled out :P[/Danger].

---------------------------
[ ChristmasHack! | My games ] :::: One CSS to style them all, One Javascript to script them, / One HTML to bring them all and in the browser bind them / In the Land of Fantasy where Standards mean something.

Krzysztof Kluczek
Member #4,191
January 2004
avatar

BAF: If you want to fix database by hand and don't know where to put these extra votes you can put them on me. ;)

CGamesPlay
Member #2,559
July 2002
avatar

He's got it rigged so it saves who each user voted for, so if the points were put in the user table properly first but not counted properly second then it'll be fine. Furthermore,

.... emm... I forgot. I cycled from the window for a bit and forgot :)

--
Tomasu: Every time you read this: hugging!

Ryan Patterson - <http://cgamesplay.com/>

BAF
Member #2,981
December 2002
avatar

the 2nd reason was incase someone like cough cgames cough makes many accounts to rig the voting :P

I have been seeing this bug a lot, i am just going to go through the db and tally up who got what votes, and fix the numbers. I shall do that now

(its a good thing i made it save who voted for who, i almost didnt)

[edit]
All fixed. Kryzeik (i know i misspelled it) is leading with 8 votes, followed by a tie with Oscar, Epoch, and CGamesPlay for 2nd place. But you can always look at the voting early-results page ;D

[edit2]
We are going to have forums up on the site soon, as soon as i can make phpBB look like my site ;D

Krzysztof Kluczek
Member #4,191
January 2004
avatar

Thanks all so far! ;D I'll do my best if I'm picked. :)

Anyway, this isn't main purpose of this post. It's (mainly to BAF):

1) Voting status page is broken - Oscar Giner had 6 votes IIRC and he now has 2.

2) Some people haven't voted yet. Maybe there should be deadline specified? I'd suggest 1th July - date when compo starts. :)

3) Vote everyone! :)

ReyBrujo
Moderator
January 2001
avatar

I keep my saying: I cannot vote until we chose a game genre.

--
RB
光子「あたしただ…奪う側に回ろうと思っただけよ」
Mitsuko's last words, Battle Royale

Krzysztof Kluczek
Member #4,191
January 2004
avatar

Hmm, why?

Anyway, we can't choose game genre until we know contest rules which will be available when contest starts. :P

ReyBrujo
Moderator
January 2001
avatar

Well, I trust some people more for 3D design and programming than others, as I do trust people for doing RPGs more than others, as I do trust some more when making arcades than others.

Just my opinion.

--
RB
光子「あたしただ…奪う側に回ろうと思っただけよ」
Mitsuko's last words, Battle Royale

nonnus29
Member #2,606
August 2002
avatar

Hey BAF, tell me how to make phpbb look unugly when you figure it out (ie I want to use my logo in place of ugly 'phpbb' logo, yuck!)

Like I said somewhere else; I don't expect anyone to actually use this jsgc thing, I put it on sourceforge mainly so I can have free web hosting ;D [/disclaimer]

Edit; oops, thanks, hehe

Krzysztof Kluczek
Member #4,191
January 2004
avatar

Play with styles. And the logo is in "templates/subSilver/images/logo_phpBB.gif" (quick look at page source revealed this). ;)

BAF
Member #2,981
December 2002
avatar

Or even edit the templates/subSilver/*.tpl files and/or pagehead.php and pagefooter.php.

That is how i am going to make it look good with my site :)

and as far as voting goes, there is a bug in the php script someplace. I'm not fixing it for a cpl people to vote. Tomorrow mornign i will recounstruct the coutns (it stores who votes for who, so i acn tally it manually and change the counts)

ReyBrujo
Moderator
January 2001
avatar

Votes should be secret :P I hope you at least encrypt the passwords ;)

--
RB
光子「あたしただ…奪う側に回ろうと思っただけよ」
Mitsuko's last words, Battle Royale

Inphernic
Member #1,111
March 2001

Quote:

I'm not fixing it for a cpl people to vote

A simple voting script should NOT have these kinds of bugs in the first place. Next time you're running a vote, ask someone who knows PHP to do the script(s).

Oscar Giner
Member #2,207
April 2002
avatar

BAF, your voting system is crazy. Everytime I look the ranking is completelly different :P KK just moved from its 1st position with 9 votes to 5th with only 2 votes :P

I don't know why you're having so many problems. Don't you just have to do something like:

SELECT v.vote, COUNT(*), m.has_voted FROM votes v, members m WHERE v.vote = m.username GROUP BY v.vote

to show the results ? There aren't many places to have bugs, here ::)

Evert
Member #794
November 2000
avatar

Can we just reset the vote?
I know whom I voted for and I'll probably vote for those same people again, but as it is, I don't trust the results.

BAF
Member #2,981
December 2002
avatar

i encrypt the passwords, i know who voted for who, and i dunno what is wrong with the code. Here is the offending code from ta.php, can anyone spot any bugs?

1elseif(isset($_GET['vote_leader']))
2{
3 if(!check_login())
4 {
5 print "You must be <a href=\"./ta.php?login\">logged in</a> to vote. Either <a href=\"./ta.php?login\">log in</a> or <a href=\"./ta.php?register\">sign up</a>";
6 }
7 elseif($user['voted'] != 0)
8 {
9 print "You have already voted. If you haven't, please email BAF from the main Team Allegro page, or see the BAFSoft contact page";
10 }
11 else
12 {
13 if(!isset($_GET['vote1']) || !isset($_GET['vote2']) || !isset($_GET['vote3']))
14 {
15 $query1 = "SELECT * FROM ta_members ORDER BY username";
16 //$row1 = mysql_fetch_assoc($result1);
17 print "Please vote for our leader of Team Allegro. You only get three (3) votes, and once you vote you can NOT change your votes<br><br>";
18 print "<form method=\"GET\" action=\"./ta.php\"><input type=\"hidden\" name=\"vote_leader\"><table>";
19
20 print "<tr><td>Vote 1:</td><td><select name=\"vote1\">";
21 $result1 = mysql_query($query1);
22 while($row1 = mysql_fetch_assoc($result1))
23 {
24 print "<option value=\"".$row1['id']."\">".stripslashes($row1['username'])."</option>";
25 }
26 print "</select></td></tr>";
27
28 print "<tr><td>Vote 2:</td><td><select name=\"vote2\">";
29 $result1 = mysql_query($query1);
30 while($row1 = mysql_fetch_assoc($result1))
31 {
32 print "<option value=\"".$row1['id']."\">".stripslashes($row1['username'])."</option>";
33 }
34 print "</select></td></tr>";
35
36 print "<tr><td>Vote 3:</td><td><select name=\"vote3\">";
37 $result1 = mysql_query($query1);
38 while($row1 = mysql_fetch_assoc($result1))
39 {
40 print "<option value=\"".$row1['id']."\">".stripslashes($row1['username'])."</option>";
41 }
42 print "</select></td></tr>";
43
44 print "<tr><td></td><td><input type=\"submit\" value=\"Vote\"></td></tr></table></form>";
45 }
46 else
47 {
48 // register votes
49 $vote1 = intval($_GET['vote1']);
50 $vote2 = intval($_GET['vote2']);
51 $vote3 = intval($_GET['vote3']);
52
53 //var_dump($_GET);
54 //print "<br>";
55
56 $uvfs = ""; // user voted for string
57
58 $query1 = "SELECT * FROM ta_members WHERE id = ".$vote1.";";
59 $result1 = mysql_query($query1);
60 $row1 = mysql_fetch_assoc($result1);
61 $vote1votes = intval($row1['leadervotes']) + 1;
62 $query2 = "UPDATE ta_members SET leadervotes = ".$vote1votes." WHERE id = ".$vote1.";";
63 mysql_query($query2);
64
65 $query3 = "SELECT * FROM ta_members WHERE id = ".$vote2.";";
66 $result3 = mysql_query($query3);
67 $row3 = mysql_fetch_assoc($result3);
68 $vote2votes = intval($row2['leadervotes']) + 1;
69 $query4 = "UPDATE ta_members SET leadervotes = ".$vote2votes." WHERE id = ".$vote2.";";
70 mysql_query($query4);
71 
72 $query5 = "SELECT * FROM ta_members WHERE id = ".$vote3.";";
73 $result5 = mysql_query($query5);
74 $row5 = mysql_fetch_assoc($result5);
75 $vote3votes = intval($row5['leadervotes']) + 1;
76 $query6 = "UPDATE ta_members SET leadervotes = ".$vote3votes." WHERE id = ".$vote3.";";
77 mysql_query($query6);
78 
79 $uvfs = $row1['username'].", ".$row3['username'].", ".$row5['username'];
80 $query7 = "UPDATE ta_members SET votedfor = '".$uvfs."' WHERE id = '".$user['id']."';";
81 mysql_query($query7);
82 $query8 = "UPDATE ta_members SET voted = 1 WHERE id = ".$user['id'].";";
83 mysql_query($query8);
84
85 print "You now voted!";
86 }
87 }
88}

Matthew Leverton
Supreme Loser
January 1999
avatar

Quote:

$row3 = mysql_fetch_assoc($result3);
$vote2votes = intval($row2['leadervotes']) + 1;

Surely you mean $row3 there.

You should make it a habit to run your code on the strictest warning settings, especially during development. It will catch typos, indexes that don't exist, etc.

Also, it looks like to me that someone could vote as many times as they wanted. I know you're setting a flag, but you should be checking it before you insert values.

Also, you could easily do:

UPDATE members SET vote_count = vote_count + 1 WHERE id=$id

To do it all in one query.

RallyMonkey
Member #4,615
May 2004
avatar

Do you really need error checking with the isset? IF it is a dropdown box and they don't change it they vote for the first person. Correct?

EDIT: Or is that how you get whether they have gone to that page before? If so. Nevermind.

NOTICE: This post's grammar/spelling/puncuation is definitive. English is frequently inaccurate.
---
"Puppet Sex!!!!" - Goalie Ca

BAF
Member #2,981
December 2002
avatar

ML: I am checking it:

elseif($user['voted'] != 0)
  {
    print "You have already voted. If you haven't, please email BAF from the main Team Allegro page, or see the BAFSoft contact page";
  }
  else
  { ...

So if it gets stuck in that else if, the voting code is all in the last else, so it wont ever allow it to pass.

And thanks for pointing out that error to me :)

[edit]
Rally: That is just to make sure some browser doesn't do some funked up thing and make my query code go bonkers :P. I did the addition in the mysql code as well.

[edit2]
Rebuilt the voting db again, and fixed the bug. Kryzeik(sp?) is winning with 12 votes, with OscarG right behind with 10 votes. Then you can go to the voting page (link in my sig to the Team Allegro page) and see the rest..

Matthew: is there a way to do double ordering in the mysql query? First i want to order by the number of votes there are, Descending. If they are tied i then want to order by username, Ascending. I know i can just do ORDER BY leadervotes,username. But then it will do username descending too. And i dont think ORDER BY leadervotes,username DESC,ASC will work, will it?

Matthew Leverton
Supreme Loser
January 1999
avatar

Quote:

And i dont think ORDER BY leadervotes,username DESC,ASC will work, will it?

ORDER BY leadervotes DESC, username ASC

Inphernic
Member #1,111
March 2001

The total number of votes given is 58.

19 people have voted. 19 * 3 votes = 57 votes.

Oscar Giner
Member #2,207
April 2002
avatar

BAF, my suggestion: destroy the votefor column.
Instead of having this column, create another table to store this info, with just two fields, user and voted_for, being the primary key the pair (user, voted_for)

Much neater this way. Probably you won't want to change this at this stage, but anyway for future reference :)

And all the code for updating the number of votes can be reduced to just 1 line (in fact you don't need to store this if you use the previous table):

mysql_query("UPDATE ta_members SET leadervotes = leadervotes + 1 WHERE id IN ($vote1, $vote2, $vote3)");

In general, is less probable to have a bug or typo in 1 line of code than in 18 ;)

BAF
Member #2,981
December 2002
avatar

Inphernic: i don't know why. I will be making a php script to fix the db one last time for me.

OscarG and Matthew: thank you.



Go to: