DCP - A Download control panel/tracker and Auto-updating class

Discussion in 'Resources' started by Kalman Olah, Jul 7, 2011.

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

    Kalman Olah

    DCP - Download Control Panel
    By Kalman Olah
    Latest version: Download

    Would you like to buy me a drink? some useless stuff from Amazon? a car?​
    [​IMG]
    What is DCP - Download Control Panel?
    Download Control Panel, or "DCP" from here, is actually two things. It's a download manager/control panel/tracker, and an auto-updater class for Bukkit plugins. It's also my way of giving back to the Bukkit community.
    What can I do with DCP?
    With DCP, you can have plugin users automatically download updates for your plugin(auto-update). You can also track download counts(download tracking), log downloads, generate links for the latest version of your plugin, and more!
    Where can I find the latest version of DCP?
    The latest version of DCP can always be found at http://kalmanolah.net/files/dl.php?id=DCP&ver=latest .
    How do I set up the web portion of DCP?

    You'll need a MySQL server and a PHP-compatible webserver to use the web portion of DCP, which is required if you want to use the auto-updater class.

    I'll explain how to set up DCP step by step.

    Download the latest version of DCP here.

    Extract the ZIP package to any location. You should find 3 folders inside the /DCP/ folder: /web/, /src/ and /sql/.

    Open up config.inc.php, which can be found in the folder /web/includes/. Edit it so DCP can connect to your MySQL server.

    Example:
    PHP:
    <?php
    /*
     * @author Kalman Olah
     */
    /*
     * Set up our SQL connection.
    */
    $sqlhost    =    'localhost';
    $sqluser    =    'root';
    $sqlpass    =    'password';
    $sqldbname    =    'database';
    /*
    * Set up our timezone.
    * For a list of accepted timezones visit:
    * http://www.php.net/manual/en/timezones.php
    */
    $timezone    =    'Europe/Brussels';
    /*
    * Set up our administrator's password.
    */
    $password    =    'yourpassword';
    ?>
    Note: $password is the password you will be using to log in to DCP. Do NOT make this easy to guess.
    Note: Remember to CHMOD the /files/ folder to 777.

    Move everything in the /DCP/web/ folder, including the edited config.inc.php, to your webserver.

    Open up PHPMyAdmin. Select your chosen database, and go to the "import" tab. Import executemeinyourdb.sql, which can be found in /DCP/sql/. This will create your MySQL table, which will be used to store download information.

    If you don't have access to PHPMyAdmin, check your webhost's control panel for ways to import or execute SQL code, or simply run it in your terminal/command prompt if you are using a dedicated server.

    Congratulations, you've successfully set up the web portion of DCP! You can log in to DCP by visiting the location you extracted the /DCP/web/ folder to.

    How do I set up the plugin portion of DCP?
    Since you're reading this part, I'm going to assume you know what you're doing.
    The package containing the class files can be found in the /DCP/src/ folder. Copy the /me/ folder(the me.kalmanolah.extras package) to your plugin's source folder.
    Add the import at the top of your main class file, like this:
    Code:
    import me.kalmanolah.extras.OKUpdater;
    And call the updating function during your onEnable(), like this:​
    Code:
    public void onEnable(){
    
    String name = this.getDescription().getName();
    
    String version = this.getDescription().getVersion();
    
    String checklocation = "http://yoursite.com/check.php";
    
    String downloadlocation = "http://yoursite.com/dl.php";
    
    Logger log = Logger.getLogger("Minecraft");
    
    String logprefix = "[" + name + "] ";
    
    OKUpdater.update(name, version, checklocation, downloadlocation, log, logprefix);
    
    }
    Where:​
    • "name" is your plugin's name, plugin's folder name, DCP name(/plugins/<name>)​
    • "version" is your plugin's version in a "x.x.x" format​
    • "checklocation" is the location of the check.php file you extracted to your webserver​
    • "downloadlocation" is the location of the dl.php file you extracted to your webserver​
    • "log" is the minecraft logger​
    • "logprefix" is the log prefix in a "[<name>] " format​
    The auto-updating will only work once you create a download in DCP with a name matching your plugin's name, and a version in the x.x.x format.​
    Misc. stuff:
    A permanent link to the latest version of a download can be made like this:
    Code:
    http://<Location of dl.php>/dl.php?id=<name of download>&ver=latest
    e.g.:
    The "latest" version is literally the one you uploaded LAST.​
    If you try to make a new download with the same name & version as an existing download, the old one will be deleted.​
    Screenshots of DCP in action:
    [​IMG]

    Whenever I try to spoiler stuff, 7 empty spoilers appear as well. I'd appreciate it if someone could tell me how to prevent this...

    Update planned for tomorrow:
    - If you add a new version of an existing download, the old download count will remain.
    - If you overwrite a download, the old download count will remain.
    This can be countered by simply deleting the downloads before adding new ones.

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

    Kalman Olah

    Updated

    - Fixed some CSS issues in the web portion.
    - The auto-updater class is now smarter than 50% of the people living in your neighborhood.
    - There is now a "reset downloads" button. Guess what it does?
    - The auto-updater class can now compare any kind of version, so all of the following formats will work: "x", "x.x", "x.x.x", "x.x.x.x", etc... It can also compare "x.x" to "x.x.x".
    - When you create a new download with a name and version of an existing download, the old file will be overwritten, but the download count will remain.
    - When you create a new download with the name of an existing download, the download count of the download with the highest download count between downloads with the same name will be copied.
    - Added some checks to make sure all fields are filled in before creating a new download.
    - The "latest" version is now calculated based on a bunch of checks that made me want to go hit something.

    I will be adding Download IP Logging and IP banning in a few days.

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

    Kalman Olah

    Updated

    - You no longer need to specify an extension for the auto-update function to work.
    - check.php now outputs <latestver>&<filename> instead of just <filename>
    - Added download logging & log deleting and stuff. It distinguishes Minecraft updates from regular downloads using a simple "&mc=1" that is added to the download URL while auto-updating.
    - The auto-updater class has been updated to work with all of the above.
     
  4. Offline

    maetthew

    Couple of questions (and this from a server administrating point of view, not from a plugin development view)
    1. Have I got it right if I assume this does not require any plugin to be installed to Minecraft/plugins/?
    2. Does this actually do the work of updating the plugins? If so, how? Does the "host plugin" updates itself through DCP's classes?
    3. Can I use this from a remote host?
     
  5. Offline

    Kalman Olah

    1 - You could use this as a standalone download counter/manager thingy, yeah. The update function can be included with a plugin of your own, it doesn't require its own plugin.
    2 - This generally downloads the updates to a plugins/<pluginname>/update/ folder, since not all people want to actually update their plugins :p.
    3 - I guess so, yeah.

    Updated DCP.
    Fixed a bug with the updater class, it should be flawless now.

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

    maetthew

    So I don't need to install a plugin to get this to work? There is no .jar for this right? I can't find one anyway :)
     
  7. Offline

    Kalman Olah

    No, you don't need to install a plugin for this to work. I think you misunderstood what it is, though. This is not a plugin auto-updater. This is a plugin auto-updating class that developers can include with their Bukkit plugins. It also comes with the web portion: the link generator and download counter/logger.
     
  8. Offline

    maetthew

    Oh so I can't use this to update all of my plugins then? I thought this somehow checked for new versions of the plugins installed and notified on update. But a plugin developer has to incorporate this class in their plugin for this to work?
     
  9. Offline

    Kalman Olah

    This is a class a plugin developer can add to their plugin that, in combination with the web portion, allows the user's of his plugin to receive automatic updates. It's a developer's resource, hence why it's posted in "Plugin Development" - > "Resources"...
     
  10. Offline

    cronikkk

    Love it! Keep it updated :D Don't stop this project.

    Also, does it have mysql injection protection? if not i have a function somewhere i can give you

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

    Kalman Olah

    It just has the basic mysql_real_escape_string() on all $_POSTs and $_GETs. Haven't had time to work a lot on this.

    EDIT: That function would be great to have :).
     
  12. Offline

    cronikkk

    I'll dig it up its on one of my old panels. Let me know if u need anymore help :p using the panel for my plugins now.
     
  13. Offline

    Kalman Olah

    Thanks :).
     
  14. Offline

    cronikkk

    Its unfortunately not on this computer so i'll check my laptop in a little bit :p but if you want some help if you ever expand this let me know :p
     
  15. Offline

    Kalman Olah

    I'm not planning on adding and major functionality any time soon. I'm just going to improve the CSS a bit. I'll let you know if I plan on actually adding stuff, though :p.
     
  16. Offline

    cronikkk

    :p alright. As long as you keep it updated cuz i can see myself using this for awhile ^^
     
  17. Offline

    DrAgonmoray

    @Kalman Olah
    Hey- First off, thanks for this. :)
    But, I got everything set up correctly (supposedly), but I can't get any of the download links to work.
    For example: http://livecraft.net/DCP/web/dl.php?id=WorldManager&ver=latest
    That takes me to a blank page. The page doesn't error, but it does not start the download. When I check the database, it says it has 3 downloads (I tested the link 3 times)
    Your example download link in the OP works perfectly fine.

    Any ideas what is wrong? What other info can I provide?
     
  18. Offline

    Kalman Olah

    Did you extract all of the web files to the same directory? Is config.inc.php located at http://livecraft.net/DCP/web/inc/config.inc.php ?

    EDIT: Are there any files in the files/ folder? There should be 3.
     
  19. Offline

    DrAgonmoray

    Yes and yes.

    Code:
    /
      DCP
        sql
        src
        web
          files
          inc
            config.inc.php
    Edit:
    The DCP/web/files/ directory is empty. I'm assuming that's where the download files are stored, and that is probably the problem.

    I'd bet you don't have sufficient permissions to access the directory. Let me try changing them.
     
  20. Offline

    Kalman Olah

    Try CHMODing the "files" folder to 777.

    This, pretty much :p

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

    DrAgonmoray

    Haha, I ninja'd you. Didja see my edit?
    Changed the directory permissions and it works flawlessly. Thank you so much! :)

    Edit:
    Lol I just got ninja'd
     
  22. Offline

    Kalman Olah

    You're welcome. Glad it's useful to someone :p.

    (I'll be adding IP banning and cleaning the CSS when I get the time for it.)
     
    DrAgonmoray likes this.
  23. Offline

    DrAgonmoray

    Sweet! I'm looking forward to updates. :D

    Suggestions:
    • Confirmation to reset downloads and delete files. It's been 10 minutes, and I've already deleted a file accidentally lol. Maybe I'm just a klutz.
    • Sort buttons. When you press the categories at the top (Name:, Filename:, etc) it will sort. Name will sort alphabetically, filename will sort alphabetically by file extension, version by version #, downloads by # of downloads.

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

    Kalman Olah

    EDIT: Updated the DCP download. Users who can't connect to your update server will now see an error message instead of a whole load of errors.

    I'll add both tomorrow :).

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

    DrAgonmoray

    This is awesome. :) I can see the downloads I never knew I was getting. o.o I thought like only 4p eople were using my plugins, but I have 45 downloads on WorldManager, 17 downloads on AutoClear, 4 on GlassReturn, and 3 on Teletabs o.o
     
  26. Offline

    Kalman Olah

    Yeah, tons of people don't actaully reply to threads :p.
     
  27. Offline

    DrAgonmoray

    More suggestions:
    • A bit of AJAX or something to update the download count every few minutes/seconds.
    • Configuration to change the timezone it logs downloads in
     
  28. Offline

    Kalman Olah

    It currently logs downloads in the system's timezone, but I'll add an option for you. As for the updating download counts, I was going to add them anyway :p.
     
  29. Offline

    DrAgonmoray

    @Kalman Olah
    I reskinned (and changed some code) my DCP to look like this:
    [​IMG]

    What do you think, lol?
     
  30. Offline

    Kalman Olah

    Sweet, I especially like the new buttons you made :).
     
Thread Status:
Not open for further replies.

Share This Page