(php) read plugin informations

Discussion in 'Bukkit Help' started by Puseidr, Mar 19, 2013.

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

    Puseidr

    hello everyone,
    can someone tell me how to read the name, main and version information of a plugin with php?

    i want to write a pluginlist in php with the installed plugins and i need all informations for an updatecheck, but dont know how to get these informations out of the .jar-file

    does someone have a simple code snippet to do that, or do i need another plugin to export the informations?
     
  2. Offline

    JWhy

    Code:
    <?php
     
    function getPluginInfo($jarfile){
        $pdf_array = yaml_parse(file_get_contents('zip://' . $plugin_file . '#plugin.yml'));
     
        $plugin['name'] = isset($pdf_array['name']) ? $pdf_array['name'] : 'Unknown';
        $plugin['version'] = isset($pdf_array['version']) ? $pdf_array['version'] : '0.1';
        $plugin['main'] = isset($pdf_array['main']) ? $pdf_array['main'] : 'null';
     
        return($plugin);
    }
     
    //Example
     
    $we = getPluginInfo('/home/bukkit/plugins/WorldEdit.jar');
    ?>
    <p>Name: <?=$we['name'];?></p>
    <p>Version: <?=$we['version'];?></p>
    <p>Main class: <?=$we['main'];?></p>
    
     
Thread Status:
Not open for further replies.

Share This Page