Custom WHM plugin - 404 page not found

chris445

Registered
Apr 2, 2020
4
0
1
United States
cPanel Access Level
Root Administrator
Hi,
I'm writing a new WHM plugin. The plugin gets registered properly using AppConfig and it appears in the 'plugins' section of WHM, but when I click on it, I get a 404 error.

The plugin navigates here:

.../cpsessxxxxxxxxxx/cgi/altas.php

The interface file is here:

/usr/local/cpanel/whostmgr/docroot/cgi/altas.php

The interface code:
PHP:
<?php
require_once '/usr/local/cpanel/php/WHM.php';
WHM::header('Atlas', 0, 0);
echo "Hello.";
WHM::footer();
The config file:
Code:
name=atlas
displayname=Atlas
icon=atlas.png
service=whostmgr
acls=any
target=_self
url=/cgi/altas.php
entryurl=altas.php
Here's what I tried:

- changing the permissions on the file;
- using atlas.cgi written in perl instead of atlas.php
- placing atlas.php and atlas.cgi in different locations

...always the same result: 404. What am I missing?
 

cPanelTJ

Product Owner
Staff member
Jan 29, 2019
90
44
93
Houston, TX
cPanel Access Level
Root Administrator
Twitter
@chris445

You'll first want to clean up your php to make sure it fits within the requirements of the language and within the guidelines outlined in our documentation:


PHP:
<?php
    require_once('/usr/local/cpanel/php/WHM.php');
        WHM::header('Atlas', 0, 0);
?>

do stuff

<?php
    WHM::footer();
?>
Next, make sure your config file is in /var/cpanel/apps.

Then, register your config file to AppConfig using /usr/local/cpanel/bin/register_appconfig /var/cpanel/apps/atlas.conf over command line. Additional documentation can be found here.

At this point, the plugin should appear in the left navigation menu in WHM and the php page should load.
 

chris445

Registered
Apr 2, 2020
4
0
1
United States
cPanel Access Level
Root Administrator
Thanks for the help, @cPanelTJ, but we're still having the same problem.

1. The content of atlas.php is copied from your post and located in /usr/local/cpanel/whostmgr/docroot/cgi/altas.php, the permissions are 0755 like all the other files.
2. atlas.conf is in /var/cpanel/apps/atlas.conf
3. register_appconfig is successful: the atlas link appears in WHM under plugins
4. When I click on it, I still get cPanel's 404 error.

We're stuck in our development efforts until we figure this out. There must be something else we're missing, something that's not in the documentation, because we followed the documentation to the letter. Everything works until the point when we're trying to run the plugin. Please see the screenshots.

Any ideas would be appreciated. Thanks!
 

Attachments

cPanelTJ

Product Owner
Staff member
Jan 29, 2019
90
44
93
Houston, TX
cPanel Access Level
Root Administrator
Twitter
@chris445

I was able to create the files, register the app, and view the page by using the following atlas.conf file:

Code:
service=whostmgr
url=/cgi/atlas.php
acls=all
entryurl=atlas.php
displayname=Atlas
target=_self
name=atlas

user=$authuser
You may be missing the user=$authuser item.