Inactive [ADMN/WEB/DEV]PHPsend v0.9 - Execute console commands with PHP in 4 lines of code!!! [1.3.1-R1.0]

Discussion in 'Inactive/Unsupported Plugins' started by kittyPL, Aug 8, 2012.

  1. Offline

    kittyPL

    PHPsend - Connect your website with bukkit server
    Version: 0.9

    Have you ever wanted to make automatic-VIP system?
    Have you ever wondered of web-orieted remote console?
    Have you thought of player list on your website?
    Have you ever needed a lightweight, most simple ever, no-lagging solution?

    This plugins allows you to do this!!!

    Simplicity - Stability - Capabilities

    Code:
    $c=new PHPsend();
    $c->PHPconnect("sv.myserver.org","myPassword");
    $c->PHPcommand("say hello world!");
    $c->PHPdisconnect();
    
    THAT'S ALL!

    Features:
    • Execute console commands from PHP script
    • Using MD5 password to authenticate
    • POST request for Bukkit -> PHP
    • Simple API with 3 fuctions!
    • One command to communicate with website!
    • No-lag due to separate thread
    • Configurable port (default: 11223)
    • EXTREME small (10kb plugin, 2kb API)
    • Support for /reload!!!
    • Exceptions oriented - no crashes and errors!
    • Most simple ever plugin API! Create own Plugins and contact your website!
    • NOW ALSO BUKKIT -> PHP
    • NOW ALSO PHP -> BUKKIT PLUGIN USING PHPSEND -> PHP!!!
    POST ANY BUGS IN COMMENTS (I FIX THEM THEN)!

    Installation:
    Show Spoiler

    * Download and unzip PHPsend.zip.
    * Put PHPsend.jar into plugins folder of your server.
    * Reload/Restart your server.
    * PHPsend will generate config in plugins/PHPsend named config.yml
    * Copy random-password or change it
    * Change port if needed
    * Change postDataUrl if you want to use Bukkit -> PHP
    * Upload PHPsend.php on your website.
    * When you need to use API, on the beggining of the php code include PHPsend.php
    * Write your code and use it as you wish!


    API - Simple Connection Guide
    Show Spoiler

    Firstly, in the beggining of the code include PHPsend.php
    Code:
    <?php
    include_once("PHPsend.php");
    ...
    
    Then you need to create PHPsend connector and connect to server.
    We store the results in $succ.
    Code:
    ...
    $con = new PHPsend();
    $succ = $con->PHPconnect("SERVER ADRESSS","PASSWORD","PORT");
    ...
    
    • $succ is 0 when everything is OK.
    • $succ is 1 when PHPsend couldn't connect to server
    • $succ is 2 when Password is incorrect.
    You can check the results, but I'm going to skip this step now.

    We are connected, so we can execute commands:
    Code:
    ...
    $con->PHPcommand("say Server says Hello!");
    $con->PHPcommand("say Server sets time to Day!");
    $con->PHPcommand("time day");
    ...
    
    PHPcommand return 0 when command was executed, 1 otherwise (THIS DOESN'T
    INCLUDE COMMAND ERROR, LIKE "UNKNOWN COMMAND") but It's rarely used.
    After executing commands, we have to disconnect from server.
    Code:
    ...
    $succ = $con->PHPdisconnect();
    ...
    
    • $succ is 0 when disconnected succesfully
    • $succ is 1 when disconnecting failed (server not responds)
    You can handle those errors, if needed.

    We are done. Next client can connect now.

    For more complex examples, Bukkit -> PHP and Plugin API visit bukkit dev :)


    ---------------------------------​
    NOTE: If you are using JRE1.6, download that version:
    Download - 0.9J1.6


    TODO:
    • I'm open to your suggestions:)
    • Check EVERY SINGLE line for any possible errors.
    Changelog:
    Show Spoiler

    Version 0.9
    *Bukkit -> PHP
    *PHP -> Bukkit -> PHP
    *Plugin API
    *POST requests

    Version 0.7
    *Inital beta release


    Post suggestions and bugs here please :) I'm new to bukkit API and not sure if my code is 100% working :/

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 27, 2016
    KoolKrafter likes this.
  2. Offline

    Pew446

    This really is cool.
     
  3. Offline

    kittyPL

    Thanks :) if you have any ideas what can I add or fix, post it and I'm sure I will do this asap :D
     
  4. Offline

    KoolKrafter

  5. Offline

    Pew446

  6. Offline

    kittyPL

    Yes, and the other plugin is much more complicated. Mine is super-simple, with included API and full protocol documentation. I also want to add some more features :) If you want anything added, post it and I will do this ;>
     
  7. Offline

    KoolKrafter

    Cool thought i'd just point it out. I have to agree yours does look better!:)
     
  8. Offline

    pigplushy

    Ahh, I like this. I might have to steal the idea and edit it a little for my private plugin :p

    On BukkitStats, the plugin does the opposite, it contacts a PHP API instead of the PHP contacting the plugin :)
    Nice work!
     
  9. Offline

    kittyPL

    I think I will add bukkit -> PHP but I don't have ideas how. Maybe configurable commands from config and API for developers? What do you think of it?
     
  10. Offline

    Brant Wladichuk

    I like the simplicity of this!

    If you could implicate Bukkit->PHP that would be awesome


    Idea -
    In plugin config:
    post_data_url: http://my.domain.com/fromServer.php

    Command:
    /website {key} {value}
    ex
    /website name Brant
    Code:
     
    Simple setup on fromServer.php
     
    if($_POST)
    {
            //SOME AUTH HERE TO ENSURE ITS FROM BUKKIT SERVER
     
            $name = $_POST['name'];
            $sender = $_POST['senders']; // Username of person who issued command, always sent by default
            echo $sender.'\'s real name is '.$name;
    }
    Result: Poonter's real name is Brant


    Other example:
    /website {key} {value}, {key} {value}, {key} {value}
    /website name Brant, pass P@ssWerd, updateStatus 'Im posting a status from Minecraft!'

    Above example could authorize fromServer.php to post a status update on their website profile.

    Just a couple thoughts. If you have a better idea, by all means
     
    kittyPL likes this.
  11. Offline

    kittyPL

    Brant Wladichuk
    Hm, I will make it, currently I'm making extreme simple API for plugin devs.
    Now Im making php -> bukkit PHPsend -> PHPsendPlugins -> php.
    My main target is simplicity. Registering PHPsend plugin is just:
    Code:
    pl = new YourClassExtendingPHPsendPlugin();
    MainPhpSend.registerPlugin(pl,"uniquePluginID");
    The plugin class should implement one method:
    Code:
    boolean onCommand(String cmd);
    It should return true if the command should be executed by server console, false if the command was handled by this plugin. Note that the event will be still triggered by other plugins. All plugins must return true to execute console command.
    Of course, I'm adding send(String msg); functiont to allow your plugins communicate with php (Also new PHP API function to allow receiving from plugin)
    Now as you see Im busy, but Im sure I will implement your idea (tomorrow or even today :3). And deafinitely api for plugin devs using you method :)

    Hmm, let me explain last post a bit, when I read it it looks really weird ;)
    Lets say you want to see online players on Webpage. So the PHP website should:
    • Contact server plugin
    • Send online players request
    • Receive the list
    How to do this is really simple ;)
    We make bukkit plugin that hooks into PHPsend.
    Our PHPsend hook checks if incomming message is equal to, for example "PHPgetPlayerList" (It's all up to you :D). If it isn't, just passes the event further. Otherwise, it prepares the list using bukkit hooks. Lets say the protocol of sending player list is:
    • Send number of players online
    • Send maximum number of players
    • For each player online, send his name
    So PHP script after sending "PHPgetPlayerList" should prepare to receieve the required data. You have the required data stored, so you can display it as you want :)

    I like the idea of online player list, I will make tutorial for that while documenting API :3

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 27, 2016
  12. Offline

    pigplushy

    What I did was just make a php api that grabs certain get variables, and then have the plugin just post stuff to a url with the data. For example...

    when a player dies, it sends their username to the php api like...

    link.com/api.php?method=playerDeath&data=USERNAMEHERE

    then the api reads the data, stores it, and echos if it succeeded or not, the echo's show up in console.
     
  13. Offline

    Adrenaline

  14. Offline

    pigplushy

    kittyPL

    If you want any help with plugin->PHP let me know
     
  15. Offline

    kittyPL

    I don't know how to send post variables :) I haven't googled it yet, maybe you know any spimple way. Deadinitely no external libs :3, that would make plugin too big. Hm, on the other hand implementing http protocol isn't the best thing to do :D Maybe I will use something very very lightweight, if Java doesn't support it ;) As I said I haven't googled it, I will do so if you don't have any ideas. Thanx for offering help pigplushy :> Btw, plugin API and hooks are ready to release, but I think I will add bukkit -> php first, then extend plugin API with it. One more thing :)3), Is the get method safe, or should I use post?

    Okay, I have it all in POST data :3 Expect the 0.9 soon! I just need to add commands and hooks for plugin API :>

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 27, 2016
  16. Offline

    pigplushy

    kittyPL Use GET instead of POST

    Also, PM me your skype if you have it, you can hop in a skype call with me and my dev
     
  17. Offline

    kittyPL

    I already made it POST. Everything is finished, Im preparing documentation of Plugin API and command (/website).
    Give me 1 hour and 0.9 will be released :)

    Anyway, pigplushy, thanx for your offer :)

    Brant Wladichuk I implemented your idea :) Update in 30 minutes! :> Btw. Plugin API and tutorials on bukkit dev already ;)

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 27, 2016
  18. Offline

    Pew446

    ?? What idea
     
  19. Offline

    Brant Wladichuk

  20. Offline

    kittyPL

    Updated downloadlink :) New file waits for approval ;/

    Hope md_5 will be here soon :)
     
  21. Offline

    Pew446

    Oh. Tapatalk skipped an entire page. :/
     
  22. Offline

    Sahee

    Code:
    2012-08-10 18:20:07 [SEVERE] Could not load 'plugins/PHPsend.jar' in folder 'plugins'
    org.bukkit.plugin.InvalidPluginException: java.lang.UnsupportedClassVersionError: org/shadowz/phpsend/MainPhpSend : Unsupported major.minor version 51.0
        at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:155)
        at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:305)
        at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:230)
        at org.bukkit.craftbukkit.CraftServer.loadPlugins(CraftServer.java:222)
        at org.bukkit.craftbukkit.CraftServer.reload(CraftServer.java:565)
        at org.bukkit.Bukkit.reload(Bukkit.java:183)
        at org.bukkit.command.defaults.ReloadCommand.execute(ReloadCommand.java:21)
        at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:168)
        at org.bukkit.craftbukkit.CraftServer.dispatchCommand(CraftServer.java:492)
        at org.bukkit.craftbukkit.CraftServer.dispatchServerCommand(CraftServer.java:488)
        at net.minecraft.server.DedicatedServer.ah(DedicatedServer.java:248)
        at net.minecraft.server.DedicatedServer.q(DedicatedServer.java:213)
        at net.minecraft.server.MinecraftServer.p(MinecraftServer.java:476)
        at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:408)
        at net.minecraft.server.ThreadServerApplication.run(SourceFile:539)
    Caused by: java.lang.UnsupportedClassVersionError: org/shadowz/phpsend/MainPhpSend : Unsupported major.minor version 51.0
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:634)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:277)
        at java.net.URLClassLoader.access$000(URLClassLoader.java:73)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:212)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
        at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:41)
        at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:29)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:334)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:264)
        at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:144)
        ... 14 more
    java version:

    java version "1.6.0_18"
    OpenJDK Runtime Environment (IcedTea6 1.8.13) (6b18-1.8.13-0+squeeze2)
    OpenJDK Server VM (build 14.0-b16, mixed mode)
     
  23. Offline

    Pew446

    kittyPL I think you built in JDK 1.7
     
  24. Offline

    kittyPL

    Sahee thank you. This happened while reloading? What was the state of Listening thread (Has any client connected, happened while connecting). Some more info and I start working on it.

    Yup, I built with JDK 1.7. I will try to rebuild for 1.6 now. :)

    Sahee try this one: http://dl.dropbox.com/u/50968480/PHPsendJ1.6.jar If somebody also gets this error please post results of trying this version!

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 27, 2016
  25. Offline

    Sahee

    kittyPL dziaƂa ;)

    eng: Working
     
  26. Offline

    kittyPL

    Okay ;) Thanx for report. I will now provide 2 versions of plugin :)
     
  27. Offline

    kittyPL

    Looking for ideas for new version!!! Post here! :D
     
  28. Offline

    chaseoes

    So what's the difference between this and websend?
     
  29. Offline

    kittyPL

    chaseoes

    PHPsend has plugin API, so you can create your mods using it. It's also much more simple (4 lines to execute command in comprassion to over 10 in websend). Minor things: support for /reload (that really caused making PHPsend :x), official support for 1.3.1 and plugin is being developed, while websend isn't (i think).
     
  30. Offline

    pigplushy

Share This Page