The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Adding your scripts within WHM

Discussion in 'cPanel Developers' started by jhyland87, Dec 8, 2008.

  1. jhyland87

    jhyland87 Well-Known Member

    Joined:
    Dec 8, 2008
    Messages:
    153
    Likes Received:
    0
    Trophy Points:
    16
    Hey guys, so I have looked around for a bit. I found out how to add an icon and function into cpanel, but how do I add one for the administrators into WHM? Any help would be appriceated! THanks!

    Justin
     
  2. sunil001

    sunil001 Member

    Joined:
    Oct 19, 2005
    Messages:
    15
    Likes Received:
    1
    Trophy Points:
    3
    Hi,

    Are you looking to add more options for your reseller customer WHM ? or server WHM?

    Sunil
    http://ehostpros.com
     
  3. jhyland87

    jhyland87 Well-Known Member

    Joined:
    Dec 8, 2008
    Messages:
    153
    Likes Received:
    0
    Trophy Points:
    16
  4. Infopro

    Infopro cPanel Sr. Product Evangelist
    Staff Member

    Joined:
    May 20, 2003
    Messages:
    14,482
    Likes Received:
    203
    Trophy Points:
    63
    Location:
    Pennsylvania
    cPanel Access Level:
    Root Administrator
    Twitter:
  5. nickp666

    nickp666 Well-Known Member

    Joined:
    Jan 28, 2005
    Messages:
    770
    Likes Received:
    2
    Trophy Points:
    18
    Location:
    /dev/null
    To make it show up in the 'Plugins' Panel of WHM, the frontend needs to be a CGI script, named: addon_YOURSCRIPTNAME.cgi and it must contain on the second line:

    Code:
    #WHMADDON:someaddon:Plugin Name
    
    The last part of that line can have basic html formatting in it, bold text etc but note this is output between <a> tags for the link to the addon.

    Perl seems to be the best language to use for WHM front ends given that there are perl modules for checking permissions, safely opening files, adding WHM interface parts etc

    Hope that helps
     
  6. nickp666

    nickp666 Well-Known Member

    Joined:
    Jan 28, 2005
    Messages:
    770
    Likes Received:
    2
    Trophy Points:
    18
    Location:
    /dev/null
    Here is a hello world example of a WHM plugin:

    Code:
    #!/usr/bin/perl
    #WHMADDON:helloworld:Hello World <b>Example</b>
    ###############################################################################
    #	This is an example hello world WHM plugin feel free to modify it as you see fit
    ###############################################################################
    # Load general use case perl modules
    use lib '/usr/local/cpanel';
    use Cpanel::cPanelFunctions ();
    use Cpanel::Form            ();
    use Cpanel::Config          ();
    use Whostmgr::HTMLInterface ();
    use Whostmgr::ACLS          ();
    ###############################################################################
    
    print "Content-type: text/html\r\n\r\n";
    
    # Check user has root permissions
    Whostmgr::ACLS::init_acls();
    if ( !Whostmgr::ACLS::hasroot() ) {
    	# User is not root, tell them where to go
    	print "You need to be root to see the hello world example.\n";
    	exit();
    }
    
    # Parse input parameters from GET and POST into $FORM{} for later use
    my %FORM     = Cpanel::Form::parseform();
    
    # Print a WHM Header
    Whostmgr::HTMLInterface::defheader( "Hello World Example Plugin",'/path/to/logo.gif', '/cgi/addon_helloworld.cgi' );
    
    # Print General Output
    print "<p>Hello world indeed...</p>";
    
    # End Example
    
    1;
    
     
  7. jhyland87

    jhyland87 Well-Known Member

    Joined:
    Dec 8, 2008
    Messages:
    153
    Likes Received:
    0
    Trophy Points:
    16
    Thanks guys!

    I tried the hellow world example, Here is the error log

     
    #7 jhyland87, Dec 10, 2008
    Last edited: Dec 10, 2008
  8. jhyland87

    jhyland87 Well-Known Member

    Joined:
    Dec 8, 2008
    Messages:
    153
    Likes Received:
    0
    Trophy Points:
    16
    Nevermind..


    Chown/Chmod issues

    How do I add it to the left menu?
     
  9. nickp666

    nickp666 Well-Known Member

    Joined:
    Jan 28, 2005
    Messages:
    770
    Likes Received:
    2
    Trophy Points:
    18
    Location:
    /dev/null
    if you name the script prefixed with addon_ it will show in the menu, e.g.
    addon_helloworld.cgi
     
  10. jhyland87

    jhyland87 Well-Known Member

    Joined:
    Dec 8, 2008
    Messages:
    153
    Likes Received:
    0
    Trophy Points:
    16
    How can I add PHP to it?

    My script is all PHP.

    THANKS!
     
  11. jhyland87

    jhyland87 Well-Known Member

    Joined:
    Dec 8, 2008
    Messages:
    153
    Likes Received:
    0
    Trophy Points:
    16
    Nevermind, I just made the CGI Forward to a PHP script, and made the PHP chown to admin and chmod to 755 :)!
     
Loading...

Share This Page