A port of Webmin's weblib.pl to help writing PHP webmin modules
PhpWebmin
consists of a port of Webmin's weblib.pl to PHP, and the integration of
the phplib html template class, to help you in writing Webmin modules in PHP and
to have a true separation between code and html.
Main features:
- Most useful weblib.pl functions ported to PHP
- Phplib's template class added to have a true separation between code and html.
To be done / Known bugs:
- Not all weblib functions have been ported to PHP...
- acl_security.pl should be still written in Perl...
Resources:
How to use it ?
If you already know how to make regular webmin modules
Install PHP4 on your server (>= 4.2.0) and a recent release of Webmin (>= 1.030).
You should be familiar with writing Webmin Modules (if not,
follow the Perl
Writing Webmin Modules
tutorial.
Now to make a PHP webmin module a few things need to be altered:
- Use #!/usr/bin/php4 instead of #!/usr/bin/perl, on the 1st line of your CGI script
- Include web-lib.php and template.inc in your source, instead of a "do '../web-lib.pl';"
- Add the 'lib_' prefix to each web-lib function. (e.g. call lib_init_config();
instead of &init_config(); )
- Please ! Use PHPLib templates to avoid ugly HTML in your PHP code. (read the
official phplib documentation)
If you get a PHP security alert (which talks about force-cgi-redirect),
then you should add the following lines to your php.ini:
cgi.force_redirect=1
cgi.redirect_status_env="MINISERV_CONFIG"
If you use Debian Sarge, with php4-cgi package version 4.3, you must use #!/usr/lib/cgi-bin/php4
instead of #!/usr/bin/php4. /usr/bin/php4 is the CLI version of PHP4, and so can't be used to
run PHP web scripts. If your scripts are not executed but only "No input file specified." is displayed,
you need to set cgi.fix_pathinfo=1 in /etc/php4/cgi/php.ini.
New functions added to the web-lib:
- tmplInit($array)
-
Sets the templates directory to "./tmpl/your_language" accordingly to Webmin
settings. If the directory does not exists, fall back to "./tmpl/en".
Initializes {TB} and {CB} template variables to $tb and $cb global variables
(used as the background colour for table headers and body rows).
Takes an optional array to set template files (similar to set_file in the phplib).
Returns a template object (see the official phplib documentation).
Simple example:
A simple example with templates:
here.
This library is also used in the 'Inventory' and 'Files Backup' module
of the
Linbox Rescue Server.
Authors:
Ludovic
Drolez and
Linbox/Free&ALterSoft.
Initial work done by Nicolas FAURANT.
License:
web-lib.php is licensed under the BSD license. templates.inc which
comes from PHPLib is licensed under the LGPL.
Hosted by: