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.

WHM Plugin PHP Wrapper

Discussion in 'cPanel Developers' started by KMyers, Oct 15, 2010.

  1. KMyers

    KMyers Member

    Joined:
    May 20, 2007
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Miami, Florida
    cPanel Access Level:
    Root Administrator
    Twitter:
    Greetings,
    Is there any way someone can post a simple template to create a WHM plugin using PHP. I am looking for a simple "Hello World" style script?
     
  2. 9xlinux

    9xlinux Well-Known Member

    Joined:
    Dec 20, 2009
    Messages:
    185
    Likes Received:
    0
    Trophy Points:
    16
    cPanel Access Level:
    Root Administrator
    Code:
    #!/usr/bin/perl
    #WHMADDON:HelloWorld:Hello World
    
    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";
    
    Whostmgr::ACLS::init_acls();
    if ( !Whostmgr::ACLS::hasroot() ) {
    print "You need to be root...\n";
    exit();
    }
    print "<meta http-equiv=\"refresh\" content=\"0;url=hello.php\">";
    1;
     
  3. d_t

    d_t Well-Known Member

    Joined:
    Sep 20, 2003
    Messages:
    243
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    Bucharest
    file: /usr/local/cpanel/whostmgr/docroot/cgi/addon_test.php
    Code:
    #!/usr/bin/php -q
    <?
    #WHMADDON:addonupdates:Test php
    echo "Hello World!";
    
    (you shoul chmod +x addon_test.php)

    See also CreatingWhmPlugins < AllDocumentation/AutomationIntegration < TWiki

    @9xlinux that is very unsecure, anyone can access php script directly without any check.
     
Loading...

Share This Page