Thread: Problem with my voting system

Results 1 to 6 of 6
  1. #1 Problem with my voting system 
    Donator

    Join Date
    Jun 2014
    Posts
    143
    Thanks given
    22
    Thanks received
    5
    Rep Power
    7
    So I'm writing my own voting system, because I was hacked with an exploit from motivote. It votes and rewards just fine, but the problem is, they can vote from the same IP on different accounts. I'm trying to fix this but to no use. My code is below, can anyone see what I'm doing wrong?
    Commands.java
    Code:
     
                           case "vote":
    				String ip = player.getLastIP();
    				boolean isInList = false;
    				for (int x = 0; x < Settings.voteips.size(); x++) {
    					if (Settings.voteips.get(x).equals(ip) && player.getVoted() == false) {
    						player.sm("You voted on a different account already, sorry.");
    						player.setVoted(true);
    						player.setVotedTime(12 * 60 * 1000 * 60);
    						return true;
    					}
    				}
    				for (int x = 0; x < Settings.voteips.size(); x++) {
    					if (Settings.voteips.get(x).equals(ip)) {
    						isInList = true;
    					}
    				}
    				if (player.getVoted() == true && isInList == true) {
    					if (player.getVotedTime() > Utils.currentTimeMillis()) {
    						player.sm("Please remember that you only vote once every 12 hours.");
    						return true;
    					} else {
    						for (int x = 0; x < Settings.voteips.size(); x++) {
    							if (Settings.voteips.get(x).equals(ip)) {
    								Settings.voteips.remove(x);
    							}
    						}
    						player.setVoted(false);
    					}
    				}
    				if (player.getVotedTime() < Utils.currentTimeMillis() && player.getVoted() == false) {
    					//vote stuff
    					player.setVotedRand(Utils.random(150000) + Utils.currentTimeMillis());
    				}
    				return true;
    			case "claimvote":
    				if (player.getVotedRand() > Utils.currentTimeMillis()) {
    					player.sm(
    							"If you have not voted at all sites, please do so, otherwise allow 1-2 minutes to process.");
    					return true;
    				}
    				if (player.getVoted() == false) {
    					player.getBank().addItem(995, 20000000, true);
    					player.getPackets().sendGameMessage("Thanks for voting. Your reward has been added to you bank.");
    					player.addToVoteTotal(1);
    					player.setSpins(5 + player.getSpins());
    					player.sm("You've been awarded 5 spins.");
    					World.sendWorldMessage("<col=6b00b3>" + player.getUsername().substring(0, 1).toUpperCase()
    							+ player.getUsername().substring(1, player.getUsername().length())
    							+ " has just voted for the server, and has voted " + player.getVoteTotal() + " times!",
    							false);
    
    					player.sm("You have voted " + player.getVoteTotal() + " times!");
    					int random1 = Utils.random(Settings.RandomItems.length);
    					int itemrandom = Settings.RandomItems[random1];
    					player.getBank().addItem(itemrandom, 1, true);
    					player.sm("A " + ItemDefinitions.getItemDefinitions(itemrandom).getName()
    							+ " has been added to your bank");
    					World.sendWorldMessage("<col=6b00b3>" + player.getUsername().substring(0, 1).toUpperCase()
    							+ player.getUsername().substring(1, player.getUsername().length()) + " has just gotten a: "
    							+ ItemDefinitions.getItemDefinitions(itemrandom).getName() + " for voting!", false);
    					Settings.voteips.add(player.getLastIP());
    					player.setVoted(true);
    					player.setVotedTime(Utils.currentTimeMillis() + (12 * 60 * 60 * 1000));
    				} else {
    					player.sm("You cannot claimvote yet.");
    				}
    
    				return true;
    Settings.java
    Code:
    public static ArrayList<String> voteips = new ArrayList<String>();
    If you see something like "getVoteRand" or "getVotedTime", these are just setters and getters of a long, and the timers work fine.

    Maybe this is the fix?
    Don't think so. Just had an idea that it might need to be synchronized
    Code:
    public static volatile ArrayList<String> voteips = new ArrayList<String>();
    also yes I realize they don't actually need to vote, they could just ::vote and wait.
    Bro
    Reply With Quote  
     

  2. #2  
    Registered Member
    Join Date
    Jul 2016
    Posts
    115
    Thanks given
    3
    Thanks received
    11
    Rep Power
    9
    This doesn't even check if they have voted at all. This just basically lets a player do ;;vote and ;;claimvote no problem. You're 100% better off using motivote. Go to [Only registered and activated users can see links. ] then sign in and manage my server to get started.
    Reply With Quote  
     

  3. #3  
    Donator


    Join Date
    Jul 2013
    Posts
    1,235
    Thanks given
    1
    Thanks received
    492
    Rep Power
    0
    Quote Originally Posted by 090782714488 View Post
    This doesn't even check if they have voted at all. This just basically lets a player do ;;vote and ;;claimvote no problem. You're 100% better off using motivote. Go to [Only registered and activated users can see links. ] then sign in and manage my server to get started.
    Motivote is horrid, better off using an older system with exploits than motivote

    [Only registered and activated users can see links. ]
    Reply With Quote  
     

  4. Thankful user:


  5. #4  
    Donator

    Join Date
    Jun 2014
    Posts
    143
    Thanks given
    22
    Thanks received
    5
    Rep Power
    7
    Quote Originally Posted by 090782714488 View Post
    This doesn't even check if they have voted at all. This just basically lets a player do ;;vote and ;;claimvote no problem. You're 100% better off using motivote. Go to [Only registered and activated users can see links. ] then sign in and manage my server to get started.
    also yes I realize they don't actually need to vote, they could just ::vote and wait.
    Motivote is trash, I got hacked through an exploit
    Bro
    Reply With Quote  
     

  6. #5  
    Registered Member
    Join Date
    Jul 2016
    Posts
    115
    Thanks given
    3
    Thanks received
    11
    Rep Power
    9
    Quote Originally Posted by Grovine View Post
    Motivote is trash, I got hacked through an exploit
    What's the exploit? Pm me it.
    Reply With Quote  
     

  7. #6  
    Registered Member

    Join Date
    Jun 2010
    Posts
    596
    Thanks given
    76
    Thanks received
    100
    Rep Power
    87
    The vote command does seem to look like it wouldn't work properly. Also speaking of that command, here's a revised code of that command.
    Just did it to show you there's a better way to check list and boolean statements. I hope you learn from this
    Code:
    case "vote":
    	String ip = player.getLastIP();
    	if (Settings.voteips.contains(ip)) {
    		if (!player.getVoted()) {
    			player.sm("You voted on a different account already, sorry.");
    			player.setVoted(true);
    			player.setVotedTime(12 * 60 * 1000 * 60);
    		} else {
    			if (player.getVotedTime() > Utils.currentTimeMillis()) {
    				player.sm("Please remember that you only vote once every 12 hours.");
    				return true;
    			}
    			player.setVoted(false);
    			Settings.voteips.remove(ip);
    		}
    	}
    	if (player.getVotedTime() < Utils.currentTimeMillis() && !player.getVoted()) {
    		player.setVotedRand(Utils.random(150000) + Utils.currentTimeMillis());
    	}
    	return true;
    OT:
    Instead of a list, I would suggest using a Map. Store the String-IP as the key and Long-Time as the value.
    This way you can do this to check if they have to wait to vote again.
    Code:
    long time = map.get(ip);
    if (time > Utils.currentTimeMillis()) {
            player.setVoted(time);
    	player.sm("Please remember you can only vote every 12 hours.");
    	return;
    }
    Do this to set it to show they have voted.
    Code:
    //Sets the "unlock time" if which they can vote again.
    map.put(ip, (Utils.currentTimeMillis() + (12 * 60 * 60 * 1000));


    Reply With Quote  
     


Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. Problem with my referral system
    By lucasouwens in forum Help
    Replies: 4
    Last Post: 11-14-2015, 01:05 PM
  2. Problem with GTL voting system.
    By Max _ in forum Help
    Replies: 4
    Last Post: 06-10-2014, 07:24 PM
  3. A problem with my model
    By Mr Reece in forum Help
    Replies: 3
    Last Post: 05-09-2009, 12:07 AM
  4. Problem with my pvp
    By Shamon King in forum Help
    Replies: 10
    Last Post: 10-27-2008, 02:34 PM
  5. Problem With My Shop!!
    By 1337scape in forum RS2 Server
    Replies: 0
    Last Post: 09-15-2007, 05:53 PM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •