What's this?:
With this WebGUI macro, it is possible to include and run PHP scripts in WebGUI.
System requirements:
- Web server (tested on Apache 2)
- PHP installed (running from command line)
- WebGUI (tested on WebGUI V7.4.x)
Files:
- argv2param.inc: Include file for the php scripts
- WebGUI/docs/Macro_PHP.html: This document here
- WebGUI/lib/WebGUI/Macro/PHP.pm: WebGUI macro
- WebGUI/lib/WebGUI/Help/Macro_PHP.pm: Help file
- WebGUI/lib/WebGUI/i18n/English/Macro_PHP.pm: Texts in english language
- WebGUI/lib/WebGUI/i18n/German/Macro_PHP.pm: texts in german language
Installation:
- Download the package source from http://sourceforge.net/projects/addons4webgui
- Extract it (or copy the files from it) over the into your WebGUI install. Example: tar xvfz /path/to/Macro_PHP-x.x.x.tar.gz /path/to/WebGUI
- Edit WebGUI.conf file to add the PHP macro to the macro list
- Copy the include file argv2param.inc to your php script directory
- Restart web server
Important notes:
- On the page where the macro is inserted, set the cache timeout and the cache timeout (visitor) to zero!!!
Usage:
ˆPHP([/path/to/php/scriptname.php],[splitter],[var1=value1][splitter][var2=value2][splitter]...);
Example 1: ˆPHP(/srv/www/php/script.php,&,var1=1&var2=2);
Example 2: ˆPHP(/srv/www/php/script.php,&,var1=1&var2=2);
Note: the example 2 explains the usage in a WebGUI article by using the content-rich-editor (this editor changes the & in &).
Macro parameter description:
- Paramter: PHP script. Example: /data/php/example.php
- Paramter (optional, together with parameter 3): splitter between parameters (query string)
- Paramter (optional, together with parameter 2): some parameters (query string). Example: var1=Hello&var2=World
Edit an existing php script:
- Remove root tags and all content of the root tags (<meta ...>, <doctype...>, <html>, </html>, <head>, </head>, <frameset>, </frameset>, <body>, </body>)
- Add require( "argv2param.inc" ); after the <?php tag
- Remove all $_POST[..] and $_GET[..] variables. The variables are determined directly by the macro and the include file argv2param.inc
Sample script:
<?php
require( 'argv2param.inc' );
echo( '<h1>Test form</h1>' );
echo( 'post_var_1 = ' . $post_var_1 . '<br>' );
echo( 'post_var_2 = ' . $post_var_2 . '<br>' );
echo( 'get_var_1 = ' . $get_var_1 . '<br>' );
echo( 'get_var_2 = ' . $get_var_2 . '<br>' );
echo( '<form action="name_of_webgui_page" method="post">' );
echo( '<input name="post_var_1" type="text" value="' . $post_var_1 . '" ><br>' );
echo( '<input name="post_var_2" type="text" value="' . $post_var_2 . '" ><br>' );
echo( '<input type="submit" value="Send">' );
echo( '</form>' );
?>
Note: some php variables are not available. For example $_GET, $_POST, ..., because the macro executes php from the command line (see on http://ch2.php.net/manual/en/features.commandline.php)
Troubleshooting:
See web server log file and/or webgui log file.
|
Changelog:
V3.0.1:
- Renamed and updated this document
V3.0.0:
V2.1.0:
- Migrated to WebGUI 6.8.x
- Added text files
- Added help file
V2.0.1:
- Fixed a little bug in PHP.pm (on line 52)
V2.0.0:
- Migrated to WebGUI V6.7.x
V0.1.2:
|