LegacyP7 Posted March 27, 2012 Share Posted March 27, 2012 Hello everyone. I recently coded a Minecraft Voting for Diamonds script. Basically, you enter your username, you vote on the sites, then click "Get Reward". The reward then goes through a RCON script, and rewards the user with their diamonds in-game. the full script works fine, and I am happy with it, but there is one small problem; and that is users being able to abuse the system. If they wanted to, they could just refresh the page, and click Get Rewarded again, and again. I want to make something like this: It has a countdown on the link, which is started upon click, and then the link re-activates when the timer is done. My script already has "disabled=..." tags, so you have to click all links, this way would make sure a user cannot click the link until the timer is done. I'm pretty new to PHP, and please forgive me if it is not 100% PHP, but this place seemed extremely helpful. I am also pretty new to PHP, so make it for dummies xD Thanks everyone! Quote Link to comment https://forums.phpfreaks.com/topic/259829-minecraft-voting-for-diamonds-script-help-required/ Share on other sites More sharing options...
willpower Posted March 28, 2012 Share Posted March 28, 2012 Hi and welcome. You havent had any responses as your question is a little vague. Perhaps if you explain what you have accomplished, what you have tried and what is failing...maybe by posting some of your code, any errors you get, etc you may get more help. Will Quote Link to comment https://forums.phpfreaks.com/topic/259829-minecraft-voting-for-diamonds-script-help-required/#findComment-1331753 Share on other sites More sharing options...
guinbRo Posted March 28, 2012 Share Posted March 28, 2012 I could be misunderstanding your problem, but it sounds like sessions would solve your problem. For example, when the user claims the diamonds create a session that signifies that they've gotten their diamonds. Here's an example: <?php session_start(); if(isset($_SESSION['gotDiamonds'])) { echo'You've already gotten diamonds!'; } else { //proceed with giving them diamonds $_SESSION['gotDiamonds'] = true; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/259829-minecraft-voting-for-diamonds-script-help-required/#findComment-1331766 Share on other sites More sharing options...
LegacyP7 Posted March 28, 2012 Author Share Posted March 28, 2012 I could be misunderstanding your problem, but it sounds like sessions would solve your problem. For example, when the user claims the diamonds create a session that signifies that they've gotten their diamonds. Here's an example: <?php session_start(); if(isset($_SESSION['gotDiamonds'])) { echo'You've already gotten diamonds!'; } else { //proceed with giving them diamonds $_SESSION['gotDiamonds'] = true; } ?> Hello. Can sessions be deleted after 24 hours? And created when the user clicks a button to get their reward? If so, that would work well. However, I like the idea of the countdown on the button. When the button is clicked, it becomes disabled, and the countdown starts. When the countdown becomes 0, the button re-activates. How can I make this? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/259829-minecraft-voting-for-diamonds-script-help-required/#findComment-1332055 Share on other sites More sharing options...
LegacyP7 Posted March 30, 2012 Author Share Posted March 30, 2012 Any more help? Quote Link to comment https://forums.phpfreaks.com/topic/259829-minecraft-voting-for-diamonds-script-help-required/#findComment-1332671 Share on other sites More sharing options...
Jessica Posted March 30, 2012 Share Posted March 30, 2012 If you store it in sessions, the user would only need to close their browser and open it up again to "cheat". You will probably need to store some info like their IP address, in your database. Quote Link to comment https://forums.phpfreaks.com/topic/259829-minecraft-voting-for-diamonds-script-help-required/#findComment-1332676 Share on other sites More sharing options...
LegacyP7 Posted March 30, 2012 Author Share Posted March 30, 2012 If you store it in sessions, the user would only need to close their browser and open it up again to "cheat". You will probably need to store some info like their IP address, in your database. How can I do this? I don't want anyone cheating Quote Link to comment https://forums.phpfreaks.com/topic/259829-minecraft-voting-for-diamonds-script-help-required/#findComment-1332729 Share on other sites More sharing options...
LegacyP7 Posted March 30, 2012 Author Share Posted March 30, 2012 EDIT: Now using "setrawcookie" to prevent cheating, and URL encoding. Start Page: <center> Vote here for free <font color='#3F92D1'><b>DIAMONDS!</b></font> <br/> <br/> Enter your EXACT username! <form method='POST' action='1new.php'> <br/> <input type="text" name='username' id='user' class='text'> <br/> <input type="submit" class='submit'> </form> </center> Second Page: <?php $username = $_POST['username']; echo ("<font color='blue'>$username is logged in! </font><img src='http://cdn1.iconfinder.com/data/icons/drf/PNG/lock.png'>"); ?> //Buttons here <?php if(isset($_COOKIE["reward"])) { echo "You've already voted from this IP today!"; } else { echo ("<input type='submit' value='Get Reward' id='submit'/>"); } ?> Set Cookies Page: <?php $username = $_POST['username']; setrawcookie("reward", time()+60); ?> Last Page: <?php $username = $_POST['username']; print ("<font face='Arial' color='cyan'>$username"); echo ( " thank you for voting today! Come back in 24 hours to vote again!</font>" ); ?> Obviously, there is lots of HTML and CSS in there, but it would use up pages Is there any way I can improve the code, and make it more secure? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/259829-minecraft-voting-for-diamonds-script-help-required/#findComment-1332785 Share on other sites More sharing options...
LegacyP7 Posted March 30, 2012 Author Share Posted March 30, 2012 Edit, skip this post. It was a mistake on my behalf. Quote Link to comment https://forums.phpfreaks.com/topic/259829-minecraft-voting-for-diamonds-script-help-required/#findComment-1332788 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.