Thread: Vote4cash 562 rs2hd

Page 1 of 4 123 ... LastLast
Results 1 to 10 of 36
  1. #1 Vote4cash 562 rs2hd 
    Donator

    Join Date
    Aug 2009
    Posts
    235
    Thanks given
    3
    Thanks received
    1
    Rep Power
    7
    I am unsure who made this code first but i made it 562 rs2hd from 317


    Purpose: Gives people GP/items for voting on a website.
    Difficulty: 5 (It just uses MySQL, that doesn't make it rise to 10...)

    [size=18pt]WEBSITE SIDE[/size]

    -> A webserver/hosting account with MySQL working.
    -> COM SQL driver (Downloading - com.zip @ UppIT)
    -> A website obviously

    In your web hosting make a new PHP file and call it vote.php, add the following in to it:
    Code:
    <?php
    
    $host="localhost";
    $username="YOUR MYSQL USERNAME";
    $password="YOUR MYSQL PASSWORD";
    $db_name="DATABASE NAME";
    
    $link = mysql_connect("$host", "$username", "$password")or die("cannot connect");
    mysql_select_db("$db_name")or die("cannot select DB");
    
    $username=$_POST['username'];
    $voteid = ($_POST['votenum']);
    
    $username = stripslashes($username);
    $username = mysql_real_escape_string($username);
    
    $time = time();
    $ip = $_SERVER['REMOTE_ADDR'];
    
    	if(clean_requests($time))
    	{
    		if(vote_entries($ip) == 0)
    		{
    			mysql_query("INSERT INTO Votes (username, ip, time, recieved) VALUES ('$username', '$ip', '$time', '0')", $link) or die("An internal error has occured please try again later.<br/>To go back click <a href='index.php'><b>HERE</b></a>");
    			header("Location: ".votenow($voteid)."");
    		}
    		else
    		{
    			die("You have already voted once today<br/>To go back click <a href='index.php'><b>HERE</b></a>");
    		}
    	}
    	else
    	{
    		die("An internal error has occured please try again later.<br/>To go back click <a href='index.php'><b>HERE</b></a>");
    	}
    
    function clean_requests($time)
    {	
    	$query = mysql_query ( "SELECT * FROM Votes");
    	$i = 0;
    	while($row = mysql_fetch_array($query))
    	{
    		$i++;
    		$timerequested = $row['time'];
    		if($time-$timerequested > 12*3600)
    		{
    			if (!mysql_query( "DELETE FROM Votes WHERE time='$timerequested'"))
    			{
    				return false;
    			}
    		}		
    	}
    	return true;	
    }
    
    function vote_entries($ip)
    {	$entries = mysql_query ( "SELECT * FROM Votes WHERE ip = '$ip'" );
    	if ( !$entries ) {
    		die ( "Unable to get number of entries: " . mysql_error () );
    	}
    	return mysql_num_rows ( $entries );
    }
    
    function votenow($votenum)
    {
    	$url = "";
    	if($votenum)
    	{
    		switch($votenum)
    		{
    			case 1:
    				$url = "VOTE LINK 1;
    			break;
    
    			case 2:
    				$url = "VOTE LINK 2";
    			break;
    
    			case 3:
    				$url = "VOTE LINK 3";
    			break;
    
    		default: die("Error!"); break;
    		}
    	}
    	return $url;
    }
    
    ?>
    The above code has three voting websites configured to work with it. If you need more, just ask me, it's easy to add a few more. Just a copy paste of code required.

    You will need to replace the following variables with your MySQL Details, if you don't have them, ask your host:
    YOUR MYSQL USERNAME
    YOUR MYSQL PASSWORD
    DATABASE NAME

    If you haven't already create a new database and call it whatever you like. I called mine vote. Your MySQL details may look like this:

    YOUR MYSQL USERNAME: ammaris1_vote
    YOUR MYSQL PASSWORD: 738883hdgry7
    DATABASE NAME: vote

    Now, time to explain: The above PHP code connects to the database and when you vote, it inserts the username, time and a given variable of 0 when you vote the first time.

    Now, open PhpMyAdmin you probably have it, if you don't ask your host to configure it for you. In PhpMyAdmin, open the newly created database and run this SQL query on it:

    Code:
    CREATE TABLE IF NOT EXISTS `votes` (
      `username` char(50) DEFAULT NULL,
      `ip` char(50) DEFAULT NULL,
      `time` int(50) DEFAULT NULL,
      `recieved` int(1) DEFAULT NULL
    )
    This query creates the tables that are needed to insert the information.

    Now go back to your file manager and create a HTML file, this time call it vote.html. Add this code into it:
    Code:
    <form name="form" method="post" action="vote.php">
    Username:  <input name="username" type="text" id="username">
    Vote #  <select name="votenum">
    <option value="1">VOTE WEBSITE 1</option>
    <option value="2">VOTE WEBSITE 2</option>
    <option value="3">VOTE WEBSITE 3</option>
    </select><br/><br/>
    <input type="submit" value="Vote!"/>
    </form>
    This code connects to vote.php and this is where your players enter their username and where they want to vote. Replace VOTE WEBSITE 1, VOTE WEBSITE 2 and VOTE WEBSITE 3 with the places they are voting, if you don't want to use all 3 spaces just remove the whole line of code where VOTE WEBSITE # is mentioned.
    -----------------------------------------------------------------------------------------------------------
    [size=18pt]Server Side[/size]

    This is the part that most people get wrong. Add your COM driver which you downloaded into your server files and then make a new Java file called MYSQL.java (With capitals). Add this into it:
    Code:
    package com.rs2hd.packethandler;
    
    import java.sql.*;
    import java.security.MessageDigest;
    
    public class MYSQL {
    
            public static Connection con = null;
            public static Statement stm;
    
            public static void createConnection() {
                    try {
                            Class.forName("com.mysql.jdbc.Driver").newInstance();
                            con = DriverManager.getConnection("jdbc:mysql://127.0.0.1/database", "username", "password");
                            stm = con.createStatement();
                    } catch (Exception e) {
                            e.printStackTrace();
                    }
            }
            public static ResultSet query(String s) throws SQLException {
                    try {
                            if (s.toLowerCase().startsWith("select")) {
                                    ResultSet rs = stm.executeQuery(s);
                                    return rs;
                            } else {
                                    stm.executeUpdate(s);
                            }
                            return null;
                    } catch (Exception e) {
                            System.out.println("MySQL Error:"+s);
                            e.printStackTrace();
                    }
                    return null;
            }
    
            public static void destroyCon() {
                    try {
                            stm.close();
                            con.close();
                    } catch (Exception e) {
                            e.printStackTrace();
                    }
            }
            
            public static boolean checkVotes(String playerName)
            {
                    try {
                            Statement statement = con.createStatement();
                            String query = "SELECT * FROM Votes WHERE username = '" + playerName + "'";
                            ResultSet results = statement.executeQuery(query);
                            while(results.next()) {
                                    int recieved = results.getInt("recieved");
                                    if(recieved == 0)
                                    {
                                    return true;
                                    }
                                    
                            }
                    } catch(SQLException e) {
                            e.printStackTrace();
                    }
                    return false;
            }
            public static boolean voteGiven(String playerName)
            {
                    try
                    {
                            query("UPDATE Votes SET recieved = 1 WHERE username = '" + playerName + "'");
                    } catch (Exception e) {
                            e.printStackTrace();
                            return false;
                    }
                    return true;
            }
    }
    Search for this code: "jdbc:mysql://127.0.0.1/database", "username", "password"
    Replace database with your database name and username and password with your MySQL details.

    I added this next part to player.java
    Add the import for MYSQL
    Search
    Code:
    getNpcRender() {
    Under that add this
    Code:
    public void VoteCheck() {
    if(MYSQL.checkVotes(this.details.getUsername())){
    if(MYSQL.voteGiven(this.details.getUsername()))
    {
    getInventory().addItem(995,200000);
    getActionSender().sendMessage("Thank you for voting!");
    }
    }
    }
    Above that code add
    Code:
    public void extraAutoSave() {
    	MYSQL.createConnection();
            }
    Now goto commandspackethandler.java and the command
    Code:
    		if (cmd[0].startsWith("::vote")) {
    			player.VoteCheck();
    	}
    then go to autosaveevent.java and find
    Code:
    .savePlayer(player);
    under it add
    Code:
    player.extraAutoSave();
    Now save and compile, you should not get any errors, post any here and I'll try to help.

    Post any problems/comments below!


    This should work. I made mine a little different cause i am using highscores too.

    Credits:Whoever made vote4cash first 85%(they made it)
    me 15%(I converted it)
    Reply With Quote  
     

  2. #2  
    Registered Member Kayci's Avatar
    Join Date
    Jun 2010
    Posts
    19
    Thanks given
    0
    Thanks received
    0
    Rep Power
    1
    nice job! (Y)(Y)
    Reply With Quote  
     

  3. #3  
    Extreme Donator


    Join Date
    Jul 2009
    Age
    27
    Posts
    4,351
    Thanks given
    826
    Thanks received
    1,239
    Rep Power
    1781
    :trollface:

    Nice job....

    You can find my GitHub here, for what I'm currently working on.
    Reply With Quote  
     

  4. #4  
    Registered Member

    Join Date
    Jul 2009
    Posts
    387
    Thanks given
    27
    Thanks received
    54
    Rep Power
    153
    Already made this for 525, but nice work
    Reply With Quote  
     

  5. #5  
    Donator

    Join Date
    Aug 2009
    Posts
    235
    Thanks given
    3
    Thanks received
    1
    Rep Power
    7
    I didnt see it posted anywhere thats why i posted it.
    Reply With Quote  
     

  6. #6  
    Registered Member

    Join Date
    Jul 2009
    Posts
    387
    Thanks given
    27
    Thanks received
    54
    Rep Power
    153
    I didnt release mine
    Reply With Quote  
     

  7. #7  
    Registered Member charmanter's Avatar
    Join Date
    Jun 2009
    Posts
    168
    Thanks given
    85
    Thanks received
    9
    Rep Power
    44
    Vote4Cash, Vote4Items, Vote for...., they're just not allowed anymore!
    As announced before, these kind of systems are no longer allowed from now on.
    If you still have one, please remove it right away. Any server caught with a system like this will be frozen (a custom term for "banned" ). The nice and hot weather will not unfreeze you though

    The idea of a top list is that the players of your server are supposed to vote when they would like to, and like your server. The Vote4-systems actually changed the complete idea of the toplist into a "Selling a vote for 10m!"-kinda system.
    Any player of a server wants as much cash or items, no matter how good the server is. Thanks to those systems, anybody voted for a server, even if they didn't like the server at all, which is wrong like I said before.

    No discussion is possible about this, this will not be changed at all.

    Looks like this was posted way too late but nice job even tho i was the 1st to make it
    Reply With Quote  
     

  8. #8  
    Donator

    Join Date
    Aug 2009
    Posts
    235
    Thanks given
    3
    Thanks received
    1
    Rep Power
    7
    I dont use it on where that quote is from. I use it on mmorpgtoplist and other sites like that.
    Last edited by bobetoe; 06-11-2010 at 01:17 AM. Reason: censor fix
    Reply With Quote  
     

  9. #9  
    Registered Member charmanter's Avatar
    Join Date
    Jun 2009
    Posts
    168
    Thanks given
    85
    Thanks received
    9
    Rep Power
    44
    heard they also don't allow those so anyways ur server would get removed not trying to be an ass or w/e just sayin even tho this is really good i was the only that had it for awhile nice job
    Reply With Quote  
     

  10. #10  
    Registered Member killmagik's Avatar
    Join Date
    May 2010
    Posts
    61
    Thanks given
    0
    Thanks received
    0
    Rep Power
    1
    Quote Originally Posted by bobetoe View Post
    I am unsure who made this code first but i made it 562 rs2hd from 317


    Purpose: Gives people GP/items for voting on a website.
    Difficulty: 5 (It just uses MySQL, that doesn't make it rise to 10...)

    [size=18pt]WEBSITE SIDE[/size]

    -> A webserver/hosting account with MySQL working.
    -> COM SQL driver (Downloading - com.zip @ UppIT)
    -> A website obviously

    In your web hosting make a new PHP file and call it vote.php, add the following in to it:
    Code:
    <?php
    
    $host="localhost";
    $username="YOUR MYSQL USERNAME";
    $password="YOUR MYSQL PASSWORD";
    $db_name="DATABASE NAME";
    
    $link = mysql_connect("$host", "$username", "$password")or die("cannot connect");
    mysql_select_db("$db_name")or die("cannot select DB");
    
    $username=$_POST['username'];
    $voteid = ($_POST['votenum']);
    
    $username = stripslashes($username);
    $username = mysql_real_escape_string($username);
    
    $time = time();
    $ip = $_SERVER['REMOTE_ADDR'];
    
    	if(clean_requests($time))
    	{
    		if(vote_entries($ip) == 0)
    		{
    			mysql_query("INSERT INTO Votes (username, ip, time, recieved) VALUES ('$username', '$ip', '$time', '0')", $link) or die("An internal error has occured please try again later.<br/>To go back click <a href='index.php'><b>HERE</b></a>");
    			header("Location: ".votenow($voteid)."");
    		}
    		else
    		{
    			die("You have already voted once today<br/>To go back click <a href='index.php'><b>HERE</b></a>");
    		}
    	}
    	else
    	{
    		die("An internal error has occured please try again later.<br/>To go back click <a href='index.php'><b>HERE</b></a>");
    	}
    
    function clean_requests($time)
    {	
    	$query = mysql_query ( "SELECT * FROM Votes");
    	$i = 0;
    	while($row = mysql_fetch_array($query))
    	{
    		$i++;
    		$timerequested = $row['time'];
    		if($time-$timerequested > 12*3600)
    		{
    			if (!mysql_query( "DELETE FROM Votes WHERE time='$timerequested'"))
    			{
    				return false;
    			}
    		}		
    	}
    	return true;	
    }
    
    function vote_entries($ip)
    {	$entries = mysql_query ( "SELECT * FROM Votes WHERE ip = '$ip'" );
    	if ( !$entries ) {
    		die ( "Unable to get number of entries: " . mysql_error () );
    	}
    	return mysql_num_rows ( $entries );
    }
    
    function votenow($votenum)
    {
    	$url = "";
    	if($votenum)
    	{
    		switch($votenum)
    		{
    			case 1:
    				$url = "VOTE LINK 1;
    			break;
    
    			case 2:
    				$url = "VOTE LINK 2";
    			break;
    
    			case 3:
    				$url = "VOTE LINK 3";
    			break;
    
    		default: die("Error!"); break;
    		}
    	}
    	return $url;
    }
    
    ?>
    The above code has three voting websites configured to work with it. If you need more, just ask me, it's easy to add a few more. Just a copy paste of code required.

    You will need to replace the following variables with your MySQL Details, if you don't have them, ask your host:
    YOUR MYSQL USERNAME
    YOUR MYSQL PASSWORD
    DATABASE NAME

    If you haven't already create a new database and call it whatever you like. I called mine vote. Your MySQL details may look like this:

    YOUR MYSQL USERNAME: ammaris1_vote
    YOUR MYSQL PASSWORD: 738883hdgry7
    DATABASE NAME: vote

    Now, time to explain: The above PHP code connects to the database and when you vote, it inserts the username, time and a given variable of 0 when you vote the first time.

    Now, open PhpMyAdmin you probably have it, if you don't ask your host to configure it for you. In PhpMyAdmin, open the newly created database and run this SQL query on it:

    Code:
    CREATE TABLE IF NOT EXISTS `votes` (
      `username` char(50) DEFAULT NULL,
      `ip` char(50) DEFAULT NULL,
      `time` int(50) DEFAULT NULL,
      `recieved` int(1) DEFAULT NULL
    )
    This query creates the tables that are needed to insert the information.

    Now go back to your file manager and create a HTML file, this time call it vote.html. Add this code into it:
    Code:
    <form name="form" method="post" action="vote.php">
    Username:  <input name="username" type="text" id="username">
    Vote #  <select name="votenum">
    <option value="1">VOTE WEBSITE 1</option>
    <option value="2">VOTE WEBSITE 2</option>
    <option value="3">VOTE WEBSITE 3</option>
    </select><br/><br/>
    <input type="submit" value="Vote!"/>
    </form>
    This code connects to vote.php and this is where your players enter their username and where they want to vote. Replace VOTE WEBSITE 1, VOTE WEBSITE 2 and VOTE WEBSITE 3 with the places they are voting, if you don't want to use all 3 spaces just remove the whole line of code where VOTE WEBSITE # is mentioned.
    -----------------------------------------------------------------------------------------------------------
    [size=18pt]Server Side[/size]

    This is the part that most people get wrong. Add your COM driver which you downloaded into your server files and then make a new Java file called MYSQL.java (With capitals). Add this into it:
    Code:
    package com.rs2hd.packethandler;
    
    import java.sql.*;
    import java.security.MessageDigest;
    
    public class MYSQL {
    
            public static Connection con = null;
            public static Statement stm;
    
            public static void createConnection() {
                    try {
                            Class.forName("com.mysql.jdbc.Driver").newInstance();
                            con = DriverManager.getConnection("jdbc:mysql://127.0.0.1/database", "username", "password");
                            stm = con.createStatement();
                    } catch (Exception e) {
                            e.printStackTrace();
                    }
            }
            public static ResultSet query(String s) throws SQLException {
                    try {
                            if (s.toLowerCase().startsWith("select")) {
                                    ResultSet rs = stm.executeQuery(s);
                                    return rs;
                            } else {
                                    stm.executeUpdate(s);
                            }
                            return null;
                    } catch (Exception e) {
                            System.out.println("MySQL Error:"+s);
                            e.printStackTrace();
                    }
                    return null;
            }
    
            public static void destroyCon() {
                    try {
                            stm.close();
                            con.close();
                    } catch (Exception e) {
                            e.printStackTrace();
                    }
            }
            
            public static boolean checkVotes(String playerName)
            {
                    try {
                            Statement statement = con.createStatement();
                            String query = "SELECT * FROM Votes WHERE username = '" + playerName + "'";
                            ResultSet results = statement.executeQuery(query);
                            while(results.next()) {
                                    int recieved = results.getInt("recieved");
                                    if(recieved == 0)
                                    {
                                    return true;
                                    }
                                    
                            }
                    } catch(SQLException e) {
                            e.printStackTrace();
                    }
                    return false;
            }
            public static boolean voteGiven(String playerName)
            {
                    try
                    {
                            query("UPDATE Votes SET recieved = 1 WHERE username = '" + playerName + "'");
                    } catch (Exception e) {
                            e.printStackTrace();
                            return false;
                    }
                    return true;
            }
    }
    Search for this code: "jdbc:mysql://127.0.0.1/database", "username", "password"
    Replace database with your database name and username and password with your MySQL details.

    I added this next part to player.java
    Add the import for MYSQL
    Search
    Code:
    getNpcRender() {
    Under that add this
    Code:
    public void VoteCheck() {
    if(MYSQL.checkVotes(this.details.getUsername())){
    if(MYSQL.voteGiven(this.details.getUsername()))
    {
    getInventory().addItem(995,200000);
    getActionSender().sendMessage("Thank you for voting!");
    }
    }
    }
    Above that code add
    Code:
    public void extraAutoSave() {
    	MYSQL.createConnection();
            }
    Now goto commandspackethandler.java and the command
    Code:
    		if (cmd[0].startsWith("::vote")) {
    			player.VoteCheck();
    	}
    then go to autosaveevent.java and find
    Code:
    .savePlayer(player);
    under it add
    Code:
    player.extraAutoSave();
    Now save and compile, you should not get any errors, post any here and I'll try to help.

    Post any problems/comments below!


    This should work. I made mine a little different cause i am using highscores too.

    Credits:Whoever made vote4cash first 85%(they made it)
    me 15%(I converted it)
    damn WONDERFUL TUT. do you know how to make it so when someone paypals you 10 dollars they instantly become a donator on the server?
    Reply With Quote  
     

Page 1 of 4 123 ... LastLast

Thread Information
Users Browsing this Thread

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


User Tag List

Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •