Find UAPI replacement for API1 functions

Operating System & Version
CentOS v7.9.2009 xen hvm [panel]
cPanel & WHM Version
100.0.7

ecartz

Member
Oct 23, 2021
8
4
3
United States
cPanel Access Level
Root Administrator
I am currently trying to add an application to cPanel. Because I want the application to be authenticated if cPanel is and the application creates and accesses a MySQL database, I am looking at how phpMyAdmin works (because the flow is similar to what I want). I found the following code in a Template Toolkit file:
Code:
[% SET CPANEL.CPVAR.dprefix = "../";
    Api1.pre_exec("Cgi", "phpmyadminlink");
    SET phpMyadmin_url = Api1.exec("Cgi", "phpmyadminlink", [undef]);
    Api1.post_exec("Cgi", "phpmyadminlink");
-%]
As best I can tell, the Template Toolkit file transitions between the main cPanel page and phpMyAdmin, which runs as a third party application.

I think that this code is obsolete and should be replaced with something else. The problem is that I'm having trouble understanding what Api1, Cgi, and phpmyadminlink combine to do. So how do I find out what it does, what UAPI code replaces it, and therefore what I actually want to do?

Alternately, perhaps this is an XY problem. Perhaps this entire way of linking to a third party application is obsolete and phpMyAdmin just hasn't caught up yet. How can I link to a third party application that works like phpMyAdmin in that

1. It requires a cPanel authentication.
2. It links from the main cPanel page.
3. The application itself doesn't have to change much. In particular, the files do not need to be renamed from .php to .live.php or .livephp. I realize that some functionality may change or need to be removed as inconsistent (e.g. phpMyAdmin loses the ability to create databases or edit privileges).

I've seen documentation like Add Plugins to the Jupiter theme but that doesn't really cover what I need. While I may have to add a LivePHP plugin to handle creating the initial database, domain, etc., the main thing that I need is the ability to add a third party application. The LivePHP would just be to help cover the holes where the application needs more integration. But I have an existing application. I don't want to rewrite the whole thing. I just want to tweak it into working.

Note: I've added OS and cPanel versions of my test platform to the post, but I'm not looking for version specific responses. Presumably any solution would be used on multiple versions.
 
Last edited by a moderator:

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
10,360
1,628
363
cPanel Access Level
Root Administrator
Hey there! If I'm understanding this correctly, it sounds like you're just creating a plugin that will be inside the cPanel interface, much like WordPress Toolkit. PHPMyAdmin has authentication steps built-in because it connects to the databases inside cPanel.

Can you review the details here to see if that is what you are looking for?

 

ecartz

Member
Oct 23, 2021
8
4
3
United States
cPanel Access Level
Root Administrator
WordPress Toolkit
As best I can tell, WordPress Toolkit was originally written for a different panel software and ported to work on cPanel. Obviously that approach works for them, but to follow it, I would first have to start using the other software. I don't see that as a good example in general.

I also don't like WordPress Toolkit as an example because they are basically written from scratch for the things that it does. It's not like it loads the WordPress application admin in third party. The toolkit itself loads as a plugin and then it installs the application as user software.

One of the things that I would like to gain out of the integration would be for the admin interface to be separate from the rest of the software. So it can

1. Upgrade the user-facing software from within the admin.
2. Install add-on modules from within the admin.
3. Backups run from within the admin.
4. Upload files within the admin.

The traditional way that the application works is that it has to give the web server the ability to write to certain directories to make the backups and upload the (mostly image) files. It can't do the upgrade at all without what I would consider an unsafe level of permissions (meaning that I have software that can do it, but I have to extend the file permissions to the point of meaninglessness to make it work). Installing add-ons is currently done in two steps: the file is moved manually via FTP by the user (bad) and then registered and installed by the software. I would like to reduce that to one step (from the admin user's perspective), so that the files are transferred automatically and in the background. And of course, I still need access to the application software for the actual registration and install.

If I can't do those things, then I don't see the advantage of doing a direct integration with cPanel over the existing Installatron/Softaculous integrations. Those already do the basic install of the software in the domain-owner's space. My goal is to separate the admin from the rest of the software. This should improve both security (because the admin will no longer be available from the public-facing website and the user-facing code will no longer need admin-level privileges) and functionality (because the admin will be integrated with cPanel). I would also like to move the configuration files outside of the web space as well.

Overall, phpMyAdmin works more like I would like to work than WordPress Toolkit does. It is primarily a separate application. It runs from within the admin. It is mostly the same, with some modifications (and I think that the modifications could be smaller with some coordination with phpMyAdmin). The files do not need renamed to work.

In terms of your link, I would point out that that is the same documentation that I linked, just a different page. It covers writing something from scratch. What I want to do is to integrate a third party application (in this case, I am the third party, you and your WHM/cPanel customers are the other two parties) into cPanel. I don't see any documentation on that at all.

More relevant links might be Create a New Jupiter Interface and Create a New Jupiter Interface in PHP, but those don't deal with integrating applications. They just let me write new pages.

Currently, I have a new page that calls UAPI functions. I can manually modify the URL to get to it. What I don't have is the capability to link to it from the main page. Also, as I said, what I really want is the ability to link to my application from the main page. I don't have even the beginnings of that, except the phpMyAdmin example with its special API1 call to get the link.
 

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
10,360
1,628
363
cPanel Access Level
Root Administrator
Thanks for that clarification - I see what you're saying now.

We don't have any ready-made tools to import or embed an app within the cPanel interface. While WordPress Toolkit was built for Plesk originally, we incorporated that into cPanel through the plugin system.

There are definitely developers that have successfully put custom apps inside cPanel, but they used a mix of custom code and the plugin system. No matter what you end of trying, it does need to get incorporated with the plugin system in order to work inside cPanel.
 

ecartz

Member
Oct 23, 2021
8
4
3
United States
cPanel Access Level
Root Administrator
So it looks like the replacement for
Code:
    Api1.pre_exec("Cgi", "phpmyadminlink");
    SET phpMyadmin_url = Api1.exec("Cgi", "phpmyadminlink", [undef]);
    Api1.post_exec("Cgi", "phpmyadminlink");
should be
Code:
    SET phpMyadmin_url = CPANEL.ENV.cp_security_token _ "/3rdparty/phpMyAdmin/index.php";
Feel free to update those .tt files (in both Paper Lantern and Jupiter) to use it. I disclaim any copyright. The advantage being that that would allow you to remove another Api1 function from those that need to be preserved. Same thing for phpPgAdmin.