[DEV/WEB] WebSend v2.4 - Use PHP and other web-languages for bukkit! [1.4.7-R1.0]

Discussion in 'Archived: Plugin Releases' started by Waterflames, Jul 21, 2011.

  1. Offline

    Waterflames

    websend-icon-text-smaller.png

    WebSend - Use PHP for Bukkit!:
    Version: v2.3
    BukkitDev: http://dev.bukkit.org/server-mods/websend/
    What does this plugin do?
    A scheme:
    Ingame command -> Your php-enabled server
    -> Your PHP file does stuff and provides output/commands -> Plugin executes commands and prints output.
    Or:
    Webpage command -> bukkit server -> Plugin executes commands and prints output.

    Example scripts are provided in the files.
    !!! IMPORTANT NOTE !!!
    Use the bukkitDev forum for bugs, questions and other stuff. I will no longer respond here!

    A few of the possibilities:
    • Online adminstration screen
    • Online console
    • Membership system (become VIP with a donation)
    • Paypal donation system
    • ...
    Features:
    • Seperate thread (no server lag because of the wait.)
    • Commands (ingame or console emulation)
    • Command to color output send from php.
    • Secure connection (protected with password hash)
    • Permissions support (just "websend")
    • Both ways enabled (PHP -> bukkit | bukkit -> php (-> bukkit))
    Installation: (more detailed instructions can be found on bukkitdev):
    1. Put the plugin in the plugin folder.
    2. Start/reload server to allow the config file to be generated.
    3. Open the example php file and fill in your password.
    4. Upload the example php file to your server.
    5. Open the config file and fill in the settings.
    6. Reload server and test with "/ws timeset".
    7. Go to the bukkitDev page to find instructions to get started.
    Download on bukkitdev.

    Changelog:
    Show Spoiler

    For more changelog, visit the bukkitdev "files" section.
    Version 0.9:
    • Fixes false error reporting
    • A debug feature was added.
    Version 0.8.1:
    • Couple of small bugfixes for 1240
    Version 0.8:
    • Added error report on invalid /Command/
    • Added warning if the first line doesn't contain the password.
    • Added proper disabling code for ServerSocket.
    • Tweaked the variable checking.
    Version 0.7.1:
    • Added extra POST data. (Info)
    Version 0.7:
    • Enabled input from console
    • Implemented a config line to use a custom port.
    Version 0.6:
    • Added extra POST data. (Info)
    Version 0.5:
    • Added the other way (PHP -> bukkit) Port 4445 needs to be forwarded.
    • Improved config file reading
    • Optimized code structure.
    Version 0.4:
    • Added option to use port 4444 opposed to the default
    Version 0.3:
    • Added color feature. (examples in supplied zip.)
    • Added Console command option (Use /Command/ExecuteConsoleCommand)
    Version 0.2
    • Fixed permissions plugin absence error.
    Version 0.1
    • Plugin released
     

    Attached Files:

  2. Offline

    Waterflames

    Yes it is possible.

    Install this plugin.

    And use: echo "/Command/ExecuteConsoleCommand:simplebroadcast Hey everyone, $param is now member;";
     
    sourcemaker likes this.
  3. Offline

    ReCreate

    Is the source code available? And i have a feature request. Run predefined commands at timed intervals. I dont like having to use external plugins or programs.
     
  4. Offline

    Waterflames

    Source code is not yet available.
    The timed commands don't really fit into what this plugin is about, but i'll think about it.
     
  5. Offline

    sourcemaker

    Yes! Thanks VERY VERY much!
    Awsome support! Thanks!
     
  6. Offline

    Darazo

    This plugin is not compatible with the latest recommended [1240] build of bukkit. Can we expect an update anytime soon?
     
  7. Offline

    Waterflames

    I haven't tested it with 1240, thats why I didn't change the title. It should work just fine.
    EDIT: There is a bug when using console, trying to fix it ASAP.
     
  8. Error :
    Code:
    22:28:37 [INFO] WARNING: During a web-triggered connection attempt
    22:28:37 [INFO] no password was found on the first line, any command
    22:28:37 [INFO] before the authentification will be ignored.
    22:28:37 [SEVERE] Exception in thread "Thread-440"
    22:28:37 [SEVERE] java.lang.NullPointerException
    22:28:37 [SEVERE]       at websend.PHPSktSrvrThread.run(Main.java:335)
    
    Please help me :)
     
  9. Offline

    Waterflames

    Try this one. Click.
     
  10. Thx, but :
    Code:
    23:48:41 [INFO] WARNING: During a web-triggered connection attempt
    23:48:41 [INFO] no password was found on the first line, any command
    23:48:41 [INFO] before the authentification will be ignored.
    23:48:41 [SEVERE] Exception in thread "Thread-12"
    23:48:41 [SEVERE] java.lang.NullPointerException
    23:48:41 [SEVERE]       at websend.PHPSktSrvrThread.run(Main.java:335)
     
  11. Offline

    Waterflames

    I will look into it tomorrow
     
  12. Offline

    Darazo

    This version works for me on CB1240. Thanks.
     
  13. Offline

    Waterflames

    What script are you using?
     
  14. PHP:
    <?php
    $PORT 
    4445;
    $HOST "127.0.0.1"//the ip of the bukkit server (in this case it's the same machine)
    $password "*********";

    //Can't touch this:
    $sock socket_create(AF_INETSOCK_STREAM0//Creating a TCP socket
    or die("error: could not create socket\n");
    $succ socket_connect($sock$HOST$PORT//Connecting to to server using that socket
    or die("error: could not connect to host\n");

    //Begin custom code here.
    socket_write($sock$command md5($password).";"strlen($command) + 1//Put md5(password) first to let the server accept the next commands.
    or die("error: failed to write to socket\n");

    socket_write($sock$command "/Command/ExecuteConsoleCommand:time day;"strlen($command) + 1//Writing text/command we want to send to the server
    or die("error: failed to write to socket\n");

    socket_write($sock$command "Time set to day;"strlen($command) + 1)
    or die(
    "error: failed to write to socket\n");
    ?>
     
  15. Offline

    Waterflames

    That script is wrong.
    This line:
    PHP:
    socket_write($sock$command md5($password).";"strlen($command) + 1
    Should be:
    PHP:
    socket_write($sock$command md5($password)."<Password>"strlen($command) + 1)
     
  16. Thank you :)
     
  17. Offline

    Grimmy777

    First of all, this plugins is great!

    I only have two issues, one is that I am getting this error:
    ERROR: While parsing php outputm websend found
    an error on line 1: Invalid command.

    The odd thing is the command I am sending is going through and working so I am not sure what I get that error

    my code in the php file is
    Code:
    //Begin custom code here.
    socket_write($sock, $command = md5($password)."<Password>", strlen($command) + 1) //Put md5(password) first to let the server accept the next commands.
    or die("error: failed to write to socket\n");
    
    //socket_write($sock, $command = "/Command/ExecuteConsoleCommand:money grant '.$PlayerName.' 1;", strlen($command) + 1) //Writing text/command we want to send to the server
    //or die("error: failed to write to socket\n");
    
    $text = "/Command/ExecuteConsoleCommand:money grant $PlayerName 0;"; //the text/command we want to send to the server
    
    socket_write($sock, $text, strlen($text) + 1) //Writing the text to the socket
    or die("error: failed to write to socket\n");
    The second issue I have really isn't an issue so much as a desire. I only want them to be able to issue this command once a day. Is there a way i can track if they have already issued it in that day and how do I track the ip address of the person submitting the form that goes to the php or is that not possible?

    Thanks for your help and an awesome plugin!
     
  18. Offline

    Waterflames

    1. Error reporting is very buggy, if your script works ignore it.
    2.Im going to assume you want each player to have access to this command once a day.
    , and that you are talking about bukkit -> php.
    Right now, only the playername is sent trough as a POST variable, but if you would like the player ip as wel, I could implement that.

    For more info about the POST data, go to the websend bukkitdev pages
     
  19. Offline

    Grimmy777

    I'm talking about php->bukkit. I am building a voting module and I want them to only be able to vote once a day. So if they have already gone to the php to vote w/i the past 24 hours then i want the php to just say, sorry, you have already voted w/i the last 24 hours. I don't know how to make the php detect their ip though so it knows if they have voted already and how to make it log it somehow. I have a mysql database so I could use that if I knew how to read and save to a mysql from a php. =)
     
  20. Offline

    Waterflames

    From what I see, that check doesn't need websend.
    Maybe use a ip check together with a cookie?
    Info IP.
    Info cookie.

    Mysql use depends on how many visitors your site gets daily. If it is more than 1000, you could consider mysql. Under 1000, an alternative is a simple txt list.
     
  21. Offline

    teeth

    I have been trying to run the example for PHP - Bukkit but with no luck : (
    http://mc.myserver.com/scripts/day.php
    PHP:
    <?php
         $HOST 
    "xxx.xxx.xxx.xxx"//the ip of the bukkit server
         
    $password "xxxxxx";
         
    //Can't touch this:
         
    $sock socket_create(AF_INETSOCK_STREAM0)
         or die(
    "error: could not create socket\n");
         
    $succ socket_connect($sock$HOST4445)
         or die(
    "error: could not connect to host\n");
         
    //Authentification
         
    socket_write($sock$command md5($password)."<Password>"strlen($command) + 1)
         or die(
    "error: failed to write to socket\n");
         
    //Begin custom code here.
         
    socket_write($sock$command "/Command/ExecuteConsoleCommand:time day;"strlen($command) + 1//Writing text/command we want to send to the server
         
    or die("error: failed to write to socket\n");
         
    socket_write($sock$command "Time set to day;"strlen($command) + 1)
         or die(
    "error: failed to write to socket\n");
         
    ?>
    CB 1240 Console Error message
    Code:
    11:25:00 [INFO] /Command/ExecuteConsoleCommand:time day
    11:25:00 [SEVERE] Exception in thread "Thread-19"
    11:25:00 [SEVERE] java.lang.IllegalAccessError: tried to access method org.bukkit.command.ConsoleCommandSender.<init>(Lorg/bukkit/Server;)V from class websend.Interpretator
    11:25:00 [SEVERE]     at websend.Interpretator.NoPlayerInterpretate(Interpretator.java:86)
    11:25:00 [SEVERE]     at websend.PHPSktSrvrThread.run(Main.java:359)
    
    *CHECKS WHAT VERSION IS LATEST* Finds out that i was using an outdated version for 1.8.1 and is now happy :)
     
  22. Offline

    Waterflames

    Soooo, does it work now, or is there still an issue?
     
  23. Offline

    Grimmy777

    Got it all working, thanks again for the plugin and the links!!
     
  24. Offline

    Waterflames

    Tnx for using this plugin!
     
  25. Offline

    n3wton

    is there an 'argc' variable? or a way of counting how many arguments have been sent? (note: bukkit -> php)

    At the moment I just loop through the arguments until it fails which is a bad way of doing :p

    Awsome plugin!

    Edit: Gah I'm a fool... just use the php command count($args)
    Cheers!

    N3wton
     
  26. Offline

    Waterflames

    :p
    Tnx for using the plugin!
     
  27. Offline

    ReCreate

    I have modded this plugin for my own(personal/private) use, but I decided i'll just request you add the following values to be sent via postdata so i can continue to use your updates of this plugin.

    netherEnabled, flyingEnabled, serverName, defaultGameMode, onlineMode

    Code:
                  out.write("serverName=" + URLEncoder.encode(String.valueOf(Main.plugin.getServer().getServerName()), "UTF-8") + "&");
                  out.write("netherEnabled=" + URLEncoder.encode(String.valueOf(Main.plugin.getServer().getAllowNether()), "UTF-8") + "&");
                  out.write("flyingEnabled=" + URLEncoder.encode(String.valueOf(Main.plugin.getServer().getAllowFlight()), "UTF-8") + "&");
                  out.write("defaultGameMode=" + URLEncoder.encode(String.valueOf(Main.plugin.getServer().getDefaultGameMode()), "UTF-8") + "&");
                  out.write("onlineMode=" + URLEncoder.encode(String.valueOf(Main.plugin.getServer().getOnlineMode()), "UTF-8") + "&");
    If you want, to be quicker to just add (not much room for change in code that simple, i think)

    If you could do that, it would be great. Thanks
     
  28. Offline

    Waterflames

    Will be in the next version.
     
  29. Offline

    ReCreate

    Cool. Thanks!
     
  30. Offline

    kropto

    Code:
    20:16:23 [INFO] /Command/ExecuteConsoleCommand:time day
    [B]20:16:23 [INFO] ERROR: While parsing php output, websend found[/B]
    [B]20:16:23 [INFO] an error on line 1: Invalid command.[/B]
    20:16:23 [INFO] Time set to day in world : world
    20:16:23 [INFO] Time set to day in world : world_nether
    
    What's wrong?

    Code:
         socket_write($sock, $command = "/Command/ExecuteConsoleCommand:time day;", strlen($command) + 1) //Writing text/command we want to send to the server
         or die("error: failed to write to socket\n");
     
  31. Offline

    Waterflames

    If it works: ignore it. The errors are very buggy.
     

Share This Page