Thread: Vote4Cash

Results 1 to 5 of 5
  1. #1 Vote4Cash 
    Donator


    Join Date
    Aug 2012
    Posts
    2,462
    Thanks given
    312
    Thanks received
    459
    Rep Power
    457
    i did have this as my php...

    Code:
    <?php
    
    /**
     * @author Stuart <RogueX | iVariable>
     * @version 1.1 UPDATED: 06.09.2010
     * @comment fixed a few bugs
     */
    
    /**
     * mysql database hostname
     */
    define("MYSQL_HOST", "mysql.x90x.net");
    /**
     *  mysql username to connect to the database server
     */
    define("MYSQL_USERNAME", "u457845833_vote");
    /**
     *  mysql password the password to connect to the database server
     */
    define("MYSQL_PASSWORD", "*********");
    /**
     *  mysql database the database name in which you have your vote table setup
     */
    define("MYSQL_DATABASE", "u457845833_vote");
    /**
     *  vote url this is the url which where users will be sent to on voting
     */
    define("VOTE_URL", "http://runetoplist.com/Dds+Specz/vote/?i=ddsspecz.no-ip.info");
    /**
     * The number of hours between voting
     */
    define("VOTE_HOURS", 24);
    
    
    /**
     *  connect() this function is used to connect to the mysql database server.
     */
    function connect()
    {
        if (!@mysql_connect(MYSQL_HOST, MYSQL_USERNAME, MYSQL_PASSWORD))
            die("Could not connect to mysql database: " . mysql_error());
        if (!@mysql_select_db(MYSQL_DATABASE))
            die("Could not select mysql database: " . mysql_error());
        $tables = mysql_list_tables(MYSQL_DATABASE);
        while (list($temp) = mysql_fetch_array($tables)) {
            if ($temp == "votes") {
                return;
            }
        }
        query("CREATE TABLE `votes` (
            `playerName` VARCHAR( 255 ) NOT NULL ,
            `ip` VARCHAR( 255 ) NOT NULL,
            `time` BIGINT NOT NULL ,
            `recieved` INT( 1 ) NOT NULL DEFAULT '0')");
    }
    /**
     *  query(string query) this function is used to query the mysql database server.
     */
    function query($s)
    {
        $query = @mysql_query($s);
        if (!$query)
            die("Error running query('" . $s . "'): " . mysql_error());
        return $query;
    }
    /**
     *  anti_inject(string text) this function is used to make sure no injections can be made.
     */
    function anti_inject($sql)
    {
        $sql = preg_replace(sql_regcase("/(from|select|insert|delete|where|drop table|show tables|#|\*|--|\\\\)/"),
            "", $sql);
        $sql = trim($sql);
        $sql = strip_tags($sql);
        $sql = addslashes($sql);
        $sql = strtolower($sql);
        return $sql;
    }
    /**
     *  clean_request(int timestamp, string username) this function is used to delete any entries if they have already expired.
     */
    function clean_request($time, $username)
    {
        $query = query("SELECT * FROM `votes` WHERE `playerName`='" . $username . "'");
        if (mysql_num_rows($query) > 0) {
            $row = mysql_fetch_array($query);
            $timerequested = $row['time'];
            if ($time - $timerequested > VOTE_HOURS * 3600)
                query("DELETE FROM `votes` WHERE time='" . $timerequested . "'");
        }
    }
    /**
     *  vote_entries(string ip) this function is used return the number of rows within the table
     */
    function vote_entries($ip)
    {
        $query = query("SELECT * FROM `votes` WHERE ip='" . $ip . "'");
        return mysql_num_rows($query);
    }
    
    
    /**
     * This is the actual working of the script please do not touch anything below if you do not know what you are doing...
     */
    if (isset($_POST['submit']) || isset($_GET['username']) && isset($_GET['type'])) {
        connect();
        if ($_POST['submit']) {
            if(@fsockopen($_SERVER['REMOTE_ADDR'], 80, $errno, $errstr, 1))
                die("Sorry but you have port 80 open, this is to stop voting by proxy address.");
            if(isset($_COOKIE['voted']))
                die("Sorry but it looks like you have already voted...");
            $username = anti_inject($_POST['username']);
            $ip = gethostbyaddr($_SERVER['REMOTE_ADDR']);
            clean_request(time(), $username);
            if (vote_entries($ip) == 0) {
                setcookie ("voted", "yes", VOTE_HOURS * 3600);
                query("INSERT INTO `votes` (`playerName`, `ip`, `time`) VALUES ('" . $username .
                    "', '" . $ip . "', '" . time() . "')");
                header("Location: " . VOTE_URL . "");
            } else {
                die("You have already voted once today.");
            }
        } elseif ($_GET['type'] == "checkvote") {
            $username = anti_inject($_GET['username']);
            $query = query("SELECT * FROM `votes` WHERE `playerName`='" . $username . "'");
            if (mysql_num_rows($query) == 1) {
                $results = mysql_fetch_array($query);
                if ($results['recieved'] == 0) {
                    query("UPDATE `votes` SET `recieved`='1' WHERE `playerName`='" . $username . "'");
                    die("user needs reward...");
                } else {
                    die("user been given reward...");
                }
            } else {
              die("Vote not found... ".  $username .".");
            }
        }
    }
    
    ?>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Vote for a reward!</title>
    </head>
    <body>
    <div align="center" style="color:#00F"><h2>Vote for a reward!</h3></div>
    <table align="center">
    
    <form action="vote.php" method="post">
      <tr>
        <td align="right">Username: </td>
        <td><input name="username" type="text" /></td>
      </tr>
      <tr>
              <td>&nbsp;</td>
        <td align="center"><input type="submit" name="submit" value="Vote now" /></td>
      </tr>
    
    </form>
    </table>
    </body>
    </html>

    and this is my command

    Code:
    if (playerCommand.equalsIgnoreCase("claim")) {
    					for (int j = 0; j < Server.playerHandler.players.length; j++) {
    						if (Server.playerHandler.players[j] != null) {
    							Client c2 = (Client)Server.playerHandler.players[j];
    							if(c.checkVotes(c.playerName)) {
    								c.getItems().addItem(995, 2000000);
    								//c.votePoints += 5;
    								c.sendMessage("<col=1532693>Thanks for voting, you receive 2m and 5 vote points!</col>");
    								c.sendMessage("<col=1532693>Make sure you vote every 24 hours.</col>");
    								c2.sendMessage("<col=255>[" + Misc.optimizeText(c.playerName) + "]<col=0> has voted and received 2M and 5 votepoints!");
    	                                                        return;
    							} else {
    								c.sendMessage("<col=1532693>You have voted already today, thanks!</col>");
    	                                                        return;
    							}
    						}
    					}
    				}

    this is in client.java
    Code:
    public boolean checkVotes(String playerName) {
            try {
                    String urlString = "http://dds-specz.x90x.net/vote.php?type=checkvote&username="+playerName;
                    urlString = urlString.replaceAll(" ", "%20");
                    URL url = new URL(urlString);
                    BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream()));
                    String results = reader.readLine();
                    if(results.length() > 0) {
                            if(results.equals("user needs reward..."))
                                    return true;
                            else 
                                    return false;
                    }
            } catch (MalformedURLException e) {
                    System.out.println("Malformed URL Exception in checkVotes(String playerName)");
            } catch (IOException e) {
                    System.out.println("IO Exception in checkVotes(String playerName)");
            }
            return false;
    }

    and this is what i have were the log in message is....
    Code:
    if(checkVotes(playerName)) {
    				vote = 1;
    			}
    			if (vote == 1) {
    				getPA().showInterface(19050);
    			}

    but when i vote with my user name and go in server it says i havent voted... please help.
    Attached image

    Attached image
    Reply With Quote  
     

  2. #2  
    Registered Member

    Join Date
    Dec 2010
    Posts
    1,982
    Thanks given
    174
    Thanks received
    256
    Rep Power
    223
    Lol

    Code:
    if (playerCommand.equalsIgnoreCase("reward")) {
    					if (c.vote == 1) {
    						c.getPA().showInterface(19050);
    					} else if (c.vote == 0) {
    	            					c.sendMessage("You haven't voted.");
    					}
    				}
    Idk what is going on here.
    Reply With Quote  
     

  3. #3  
    Donator


    Join Date
    Aug 2012
    Posts
    2,462
    Thanks given
    312
    Thanks received
    459
    Rep Power
    457
    Quote Originally Posted by Someone View Post
    Lol

    Code:
    if (playerCommand.equalsIgnoreCase("reward")) {
    					if (c.vote == 1) {
    						c.getPA().showInterface(19050);
    					} else if (c.vote == 0) {
    	            					c.sendMessage("You haven't voted.");
    					}
    				}
    Idk what is going on here.
    if(checkVotes(playerName)) {
    vote = 1;
    }
    if (vote == 1) {
    getPA().showInterface(19050);
    }
    Attached image

    Attached image
    Reply With Quote  
     

  4. #4  
    Donator


    Join Date
    Aug 2012
    Posts
    2,462
    Thanks given
    312
    Thanks received
    459
    Rep Power
    457
    Code:
    if (playerCommand.equalsIgnoreCase("claim")) {
    					for (int j = 0; j < Server.playerHandler.players.length; j++) {
    						if (Server.playerHandler.players[j] != null) {
    							Client c2 = (Client)Server.playerHandler.players[j];
    							if(c.checkVotes(c.playerName)) {
    								c.getItems().addItem(995, 2000000);
    								//c.votePoints += 5;
    								c.sendMessage("<col=1532693>Thanks for voting, you receive 2m and 5 vote points!</col>");
    								c.sendMessage("<col=1532693>Make sure you vote every 24 hours.</col>");
    								c2.sendMessage("<col=255>[" + Misc.optimizeText(c.playerName) + "]<col=0> has voted and received 2M and 5 votepoints!");
    	                                                        return;
    							} else {
    								c.sendMessage("<col=1532693>You have voted already today, thanks!</col>");
    	                                                        return;
    							}
    						}
    					}
    				}

    my new command.
    Attached image

    Attached image
    Reply With Quote  
     

  5. #5  
    Banned

    Join Date
    Aug 2013
    Age
    27
    Posts
    1,128
    Thanks given
    373
    Thanks received
    754
    Rep Power
    0
    Quote Originally Posted by Project Pk View Post
    Code:
    if (playerCommand.equalsIgnoreCase("claim")) {
    					for (int j = 0; j < Server.playerHandler.players.length; j++) {
    						if (Server.playerHandler.players[j] != null) {
    							Client c2 = (Client)Server.playerHandler.players[j];
    							if(c.checkVotes(c.playerName)) {
    								c.getItems().addItem(995, 2000000);
    								//c.votePoints += 5;
    								c.sendMessage("<col=1532693>Thanks for voting, you receive 2m and 5 vote points!</col>");
    								c.sendMessage("<col=1532693>Make sure you vote every 24 hours.</col>");
    								c2.sendMessage("<col=255>[" + Misc.optimizeText(c.playerName) + "]<col=0> has voted and received 2M and 5 votepoints!");
    	                                                        return;
    							} else {
    								c.sendMessage("<col=1532693>You have voted already today, thanks!</col>");
    	                                                        return;
    							}
    						}
    					}
    				}

    my new command.
    You must do another vote4cash with right callback.php sir, so it show when people vote, and they really need to vote, can't be glitched.
    If you can't do your own vote4cash use the GTLVote: http://www.rune-server.org/runescape...-pi-667-a.html

    If you need help tell me
    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. Vote4cash 562 rs2hd
    By bobetoe in forum Tutorials
    Replies: 35
    Last Post: 09-12-2013, 07:01 PM
  2. Vote4Cash Help
    By Solstice12 in forum Help
    Replies: 2
    Last Post: 09-11-2010, 03:01 AM
  3. Replies: 23
    Last Post: 08-19-2010, 11:34 PM
  4. Replies: 4
    Last Post: 06-30-2010, 02:55 AM
  5. Replies: 9
    Last Post: 06-22-2010, 02:19 AM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •