vote

A voting system with jQuery, PHP and Smarty

一笑奈何 提交于 2019-12-08 03:38:16
问题 I have made a voting feature to my website using only PHP and Smarty. This's the HTML part of it: <p>{$vote} <a href="vote.php?q_vote=vote_up&question_id={$qid}"><i class="icon-thumbs-up"></i></a> <a href="vote.php?q_vote=vote_down&question_id={$qid}"><i class="icon-thumbs-down"></i></a></p> The PHP part of the code takes the vote and refreshes the same page. I want to do the same thing using jQuery so that it won't need to refresh the page. Here is what I wrote in the HTML : $("#q_upvote")

How can I use PHP and JavaScript to make an image clickable, and increment a counter stored as a flat file?

柔情痞子 提交于 2019-12-06 18:18:24
Im trying to find a php/js script that will let me take an image, and when clicked, increase the number in a flat file, and save that file. I know how to include the file to get the vote total. Im going insane trying to find this to plug and play into my website. Id love to have ip logging, and a cool fade in/out refresh update thing. But at this point ill settle for basics. Id like to avoid using MySQL, but if its necessary i can work with it. Your best bet is to use the AJAX support in jQuery to access, but not load to the user, some kind of URL that writes the increment to the file. If you

Spring Security: AccessDecisionVoter

爷,独闯天下 提交于 2019-12-06 16:16:33
问题 @Service public class MyVoter implements AccessDecisionVoter<Entity> { @Override public boolean supports(ConfigAttribute attribute) { boolean myBool = false; return myBool; } @Override public boolean supports(Class<?> clazz) { return clazz == Project.class; } @Override public int vote(Authentication authentication, Entity someEntity, Collection<ConfigAttribute> config) { return ACCESS_GRANTED; } } Can you explain me, how the first supports method is supposed to work? No matter how i change

Prevent double voting

旧街凉风 提交于 2019-12-04 23:39:21
问题 I'm creating a web application where users will vote for some candidates by clicking thumbs up or thumbs down, and these users won't have any account on the site. What is the best technique to use? Is it necessary to use captcha for more protection from spam? Vote counts are expected to be millions, and the subject is not very critical as long as I get 95% accuracy that would be fine. Thanks. 回答1: You can combine these two methods: Add a cookie to prevent multiple votes from the same machine

Spring Security: AccessDecisionVoter

江枫思渺然 提交于 2019-12-04 21:05:08
@Service public class MyVoter implements AccessDecisionVoter<Entity> { @Override public boolean supports(ConfigAttribute attribute) { boolean myBool = false; return myBool; } @Override public boolean supports(Class<?> clazz) { return clazz == Project.class; } @Override public int vote(Authentication authentication, Entity someEntity, Collection<ConfigAttribute> config) { return ACCESS_GRANTED; } } Can you explain me, how the first supports method is supposed to work? No matter how i change myBool, the vote-method is always invoked. It seems like only supports(Class clazz) has effect on the

Prevent double voting

房东的猫 提交于 2019-12-03 15:49:46
I'm creating a web application where users will vote for some candidates by clicking thumbs up or thumbs down, and these users won't have any account on the site. What is the best technique to use? Is it necessary to use captcha for more protection from spam? Vote counts are expected to be millions, and the subject is not very critical as long as I get 95% accuracy that would be fine. Thanks. You can combine these two methods: Add a cookie to prevent multiple votes from the same machine Log IP addresses and prevent voting more than a set number of times from the same address (for example, 5

reddit style voting with django

风格不统一 提交于 2019-12-03 05:20:22
问题 Hay i need to hand implemeneting a voting system into a model. I've had a huge helping hand from Mike DeSimone making this work in the first place, but i need to expand upon his work. Here is my current code View def show_game(request): game = Game.objects.get(pk=1) discussions = game.gamediscussion_set.filter(reply_to=None) d = { 'game':game, 'discussions':discussions } return render_to_response('show_game', d) Template <ul> {% for discussion in discussions %} {{ discussion.html }} {% endfor

Storing “votes” in a database

天大地大妈咪最大 提交于 2019-12-02 20:56:19
I'm writing what will be an intranet application, and one of its features is roughly analogous to content voting - not unlike what SO, Amazon, and many other sites do. Assuming each votable piece of content has a unique ID, and each user (they're authenticated) has a unique ID, the easiest way would seem to be to have a "votes" table... ContentID int UserID int VoteValue int But this creates one row per vote - with millions of pieces of content and tens of thousands of users, that table's gonna be huge huge huge. Is this the best way to do it? I mean, if an int takes 4 bytes, each row takes 12

reddit style voting with django

喜你入骨 提交于 2019-12-02 18:37:57
Hay i need to hand implemeneting a voting system into a model. I've had a huge helping hand from Mike DeSimone making this work in the first place, but i need to expand upon his work. Here is my current code View def show_game(request): game = Game.objects.get(pk=1) discussions = game.gamediscussion_set.filter(reply_to=None) d = { 'game':game, 'discussions':discussions } return render_to_response('show_game', d) Template <ul> {% for discussion in discussions %} {{ discussion.html }} {% endfor %} </ul> Model class GameDiscussion(models.Model): game = models.ForeignKey(Game) message = models

PHP voting, one vote per IP per day: code help needed

风流意气都作罢 提交于 2019-12-01 13:00:13
I am working on a very basic site which will allow people to vote once per 24 hours on an item (game) per IP address. Votes are stored in a table named votes, with columns containing vote ID, game ID, votedate, and IP address. Users go to the vote page for that game via ...vote.php?id=# (where # is the gid). Here is a simplified version of my current vote.php, which is not working: <?php $gid = $_GET["id"]; $ip = $_SERVER['REMOTE_ADDR']; require_once ('config.php'); $q = "SELECT * FROM votes WHERE (gid=$gid)"; $r = @mysqli_query($dbc, $q); if ($r) { while ($row = mysqli_fetch_array($r)) { if (