Help with votifier code

Discussion in 'Bukkit Help' started by IcyRelic, Nov 17, 2012.

Thread Status:
Not open for further replies.
  1. Offline

    IcyRelic

    ok here is what i have for my votifier code to test a server


    PHP:
    <?php
     
    //turn all errors on for debug
    ini_set('error_reporting'E_ALL);
     
    //main function
    function Votifier($public_key$server_ip$server_port$username)
    {
    //pharse the public key
    $public_key wordwrap($public_key65"\n"true);
    $public_key EOF;
    //get user IP
    $address $_SERVER['REMOTE_ADDR'];
     
    //set voting time
    $timeStamp time();
     
    //create basic required string for Votifier
    $string "VOTE\mcserverslist.org\n$username\n$address\n$timeStamp\n";
     
    //fill blanks to make packet lenght 256
    $leftover = (256 strlen($string)) / 2;
    while (
    $leftover 0) {
    $string.= "\x0";
    $leftover--;
    }
     
    //encrypt string before send
    openssl_public_encrypt($string,$crypted,$public_key);
     
    //try to connect to server
    $socket fsockopen($server_ip$server_port$errno$errstr3);
    if (
    $socket)
    {
    fwrite($socket$crypted); //on success send encrypted packet to server
    return true;
    }
    else
    return 
    false//on fail return false
    }
     
    $public_key "My public key here not really this but my actual public key";
    $server_ip "play.icyrelic.com";
    $server_port "8192";
    $username "IcyRelic";
     
    $username preg_replace("/[^A-Za-z0-9_]+/",'',$username);
     
    //call function, you can also improve the error reporting, this is only basic
    if(Votifier($public_key$server_ip$server_port$username))
    echo 
    'Success!';
    else
    echo 
    'Error!';
     
    ?>

    it returns in the console saying


    unable to decrypt vote record make sure your public key matches the one you gave the server list
     
  2. Offline

    lethaltactics

    Same issue
     
  3. Offline

    marin1805

    This code is copied from http://topg.org/php_votifier. Beside that you changed top from topg.org to mcserverslist.org (wich is rude) you also changed the function.

    PHP:
    //parse the public key (if you change anything here it won't work!)
    $public_key wordwrap($public_key65"\n"true);
    $public_key = <<<EOF
    -----BEGIN PUBLIC KEY-----
    $public_key
    -----END PUBLIC KEY-----
    EOF;
     
Thread Status:
Not open for further replies.

Share This Page