Complete Guide to Writing Plugins in DirectAdmin: Structure, PHP Handling, GET/POST Support, and Optional Templates

This article provides a comprehensive guide to creating plugins in DirectAdmin. It explains how the plugin system works, how to structure plugin files, how to run PHP with a custom php.ini, how to properly handle GET and POST variables inside plugin scripts, and how to use optional templates such as plugin_iframe.html for custom iframe output.

Writing Plugins in DirectAdminPHP Handling

~3 min read · Updated Mar 1, 2026

1. Introduction to DirectAdmin Plugins


DirectAdmin’s plugin system allows developers to extend the control panel with custom functionality. A plugin is essentially a collection of files—scripts, HTML templates, and hook definitions—that integrate with the DirectAdmin interface.

To get started, DirectAdmin provides a sample plugin:

  • hello_world.tar.gz — a simple example demonstrating plugin structure and hooks.

Plugins can:

  • Add new menu items to DirectAdmin skins
  • Execute custom scripts
  • Send files or raw output directly to the browser
  • Bypass the default DirectAdmin header/footer “bubble”
  • Control HTTP headers and socket behavior

More advanced features are documented in the DirectAdmin versions system.

---

2. Running PHP with a Custom php.ini


If your plugin requires a custom php.ini, you can specify it directly in the shebang line of your PHP script.

2.1 Using a Custom php.ini


#!/usr/local/bin/php -nc /usr/local/directadmin/plugins/PLUGIN_NAME/yourphp.ini

Important: The -n option disables loading of the system-wide php.ini, preventing duplicate module loading (e.g., ionCube, Zend).

2.2 Running PHP Without Any php.ini


#!/usr/local/bin/php -n

This forces PHP to use internal defaults only.

2.3 Debugging Shebang Issues

If your script fails to run, ensure it is saved in UNIX format. Convert using:


yum install dos2unix
dos2unix index.html
---

3. Using $_GET and $_POST Inside Plugins


DirectAdmin plugins run under CLI PHP (/usr/local/bin/php), which does not automatically populate $_GET and $_POST. Instead, DirectAdmin passes data through environment variables.

You can reconstruct these arrays manually:


// Build $_GET
$_GET = Array();
$QUERY_STRING = getenv('QUERY_STRING');
if ($QUERY_STRING != "") {
    parse_str(html_entity_decode($QUERY_STRING), $get_array);
    foreach ($get_array as $key => $value) {
        $_GET[urldecode($key)] = urldecode($value);
    }
}

// Build $_POST
$_POST = Array();
$POST_STRING = getenv('POST');
if ($POST_STRING != "") {
    parse_str(html_entity_decode($POST_STRING), $post_array);
    foreach ($post_array as $key => $value) {
        $_POST[urldecode($key)] = urldecode($value);
    }
}

This allows your plugin to behave similarly to a normal PHP web application.

---

4. Optional Template: plugin_iframe.html


DirectAdmin supports an optional template for plugins that use:

iframe=yes

By default, DirectAdmin wraps plugin output in a hardcoded iframe layout. If you want full control over the iframe HTML, create:

/usr/local/directadmin/data/templates/custom/plugin_iframe.html

Example template:




    
    


    
|OUTPUT|

This is especially useful for debugging or for plugins that require custom styling.

---

5. Summary


DirectAdmin’s plugin system is lightweight, flexible, and easy to extend. By combining:

  • custom scripts
  • custom php.ini handling
  • GET/POST reconstruction
  • optional iframe templates

you can build powerful integrations that feel native inside the DirectAdmin interface.

Written & researched by Dr. Shahin Siami

Related Articles

Email Client Configuration & Dovecot Quota/Monitoring Guide for DirectAdmin Users

This guide explains how to configure popular email clients (iPhone Mail, Thunderbird, Gmail POP/SMTP), enable Dovecot LMTP quota warnings, and check the last login time for all email accounts on a DirectAdmin server. It includes step by step instructions, recommended IMAP/SMTP settings, and useful administrative scripts.

Continue

Troubleshooting Dovecot in DirectAdmin – Fixing IMAP Errors, Authentication Issues, and SSL Certificate Checks

Dovecot is the IMAP/POP3 server used by DirectAdmin. Sometimes users encounter errors such as “Connection dropped by IMAP server” or “unknown user” during authentication. This guide explains how to fix corrupted Dovecot indexes, understand authentication logs, hide unnecessary warnings, and manually inspect SSL certificates on IMAP ports 143 and 993.

Continue

DNS Troubleshooting in DirectAdmin – When named is Running but Domains Do Not Resolve

Sometimes the named (BIND) service runs normally, yet DNS queries fail or domains do not resolve from outside. This guide provides a complete troubleshooting workflow for checking named listeners, firewall rules, named.conf configuration, DNS propagation issues, subdomain problems, resolv.conf errors, and common Apache/Nginx misconfigurations.

Continue

Managing DNS Records in DirectAdmin – Complete Practical Guide for Administrators

DirectAdmin provides a powerful DNS management system that allows administrators to control TTL values, create SRV records, enable DNSSEC, manage subdomain delegation, automate TLSA records, and perform mass DNS updates. This guide explains all essential DNS operations in DirectAdmin with real-world examples and best practices.

Continue

DNS and Nameservers in DirectAdmin – Complete, Practical, and Professional Guide

DNS is the backbone of the internet, responsible for translating domain names into IP addresses. DirectAdmin allows you to create private nameservers (ns1/ns2), manage DNS zones, configure DNS clustering, use external DNS, and troubleshoot common issues. This guide provides a complete, clear, and practical explanation of DNS concepts and their implementation in DirectAdmin.

Continue

CustomBuild in DirectAdmin – Complete Guide to Installation, Updates, Configuration, and Advanced Customization

CustomBuild is DirectAdmin’s primary software management system. It installs, updates, configures, and rebuilds essential services such as Apache, Nginx, PHP, MariaDB/MySQL, Exim, Dovecot, FTP servers, and more. Because most components are compiled from source, CustomBuild offers exceptional flexibility, fast access to new versions, and optimized performance.

Continue