How onurtasci/cpanelresellertransfer works
Project Type and Purpose
• This is a WHM/cPanel plugin (“resellertransfer”) written in Perl and delivered as a CGI application.
• Purpose: Add a “Reseller Transfer” feature to the WHM interface that lets an admin list resellers and reset their passwords via AJAX calls to the cPanel API.
File‐Structure Analysis
• Top level:
• resellertransfer.cgi (plugin entry point; registered by resellertransfer.conf)
• resellertransfer.conf (cPanel registration file, hooks plugin into WHM)
• LICENSE.md, README (meta / install instructions)
• functions.pl (common business‐logic wrappers around cPanel API calls)
• ajax/:
• cpanel.pl (generic AJAX dispatcher)
• cpanel/getList.pl, cpanel/resetPassword.pl (endpoints invoked by JS)
• assets/:
• css/ (dataTables.checkboxes.css for table UI)
• js/ (JavaScript to call AJAX endpoints, handle DOM)
• page/:
• hasroot.pl (permission check page)
• home.pl (main UI page for the plugin)
Key Components
a. WHM/cPanel Platform
b. Plugin Registration (resellertransfer.conf)
c. CGI Application Entry Point (resellertransfer.cgi)
d. UI Layer
• Static assets: CSS, JS
• home.pl (renders HTML)
e. AJAX Controller Layer
• ajax/cpanel.pl (router)
• getList.pl, resetPassword.pl (handlers)
f. Business Logic Layer (functions.pl)
g. External Service: cPanel’s API (UAPI or XML-API)
h. Authentication & Authorization (hasroot.pl)
Relationships and Data Flow
1. Admin clicks “Reseller Transfer” in WHM → WHM loads home.pl via resellertransfer.cgi
2. home.pl serves HTML + references CSS/JS assets
3. JS issues AJAX to ajax/cpanel.pl?func=getList → routed to getList.pl
4. getList.pl calls functions.pl → interacts with cPanel API → returns JSON list
5. JS populates table; on “Reset Password,” JS calls resetPassword.pl
6. resetPassword.pl calls functions.pl → performs UAPI/API call → returns status
7. JS displays success/failure
Architectural Patterns & Principles
• Separation of concerns:
• Presentation (home.pl + static assets)
• Controllers (ajax/*.pl)
• Business logic (functions.pl)
• Plugin registration isolating it from core WHM code
• Use of REST-style AJAX endpoints
• Lightweight CGI scripts (no heavyweight framework)