Extension:PostForm
![]() |
WARNING: the code or configuration described here poses a major security risk.
Problem: content of submitted forms may be available via Google via postform.log |
![]() |
This extension stores its source code on a wiki page. Please be aware that this code may be unreviewed or maliciously altered. They may contain security holes, outdated interfaces that are no longer compatible etc. The developer is encouraged and invited to request access to MediaWiki's code repository to address this. |
PostForm Release status: beta |
|
---|---|
Implementation | Tag |
Description | Creates a form to send data via email |
Author(s) | RUNA (Runa_cgtalk) |
Last version | 0.1 (December 2009) |
MediaWiki | tested on 1.10.2 |
License | GPL |
Download | See the section labeled code below |
Check usage (experimental) |
Contents |
[edit] Requirements
- php-dom
- php-mssql (to use <dbsource> parameter for dropdownlist)
[edit] Installation
To install this extension
- Create folder "/extensions/PostForm"
- Create files: PostForm.php, PostForm.xsl, PostFormShort.xsl, script.js (see #Code section)
- Copy these files in the folder "/extensions/PostForm"
- Add the following to LocalSettings.php:
require_once("$IP/extensions/PostForm/PostForm.php");
[edit] Syntax
<postform name="FormName" to="Recipient email" subject="Email Subject" from="Sender email">Form Title <itext title="Field title" name="field_name(will be displayed in the letter)"/> - input string <itextarea title="Field title" name="field_name"/> - textarea <iselect title="Field title" name="field_name"> - dropdown list (select) <ioption/> - empty item <ioption>item value</ioption> </iselect> <iselect title="Field title" name="field_name"> - dropdown list v.2 <source>Uploaded FileName</source> </iselect> <iselect title="Field title" name="field_name"> - dropdown list v.3 <dbsource> <server>DB server address</server> <type>DB type (MySQL, MSSQL)</type> <database>DB name</database> <user>DB username</user> <password>DB password</password> <table>Table</table> <field>Field</field> <cond>SQL-condition</cond> </dbsource> </iselect> <radiogroup title="Group Name" name="field_name"> - Group of radiobuttons <iradio title="Title" value="Value"/> </radiogroup> <icheckbox title="Single checkbox title" name="field_name" value="Value"/> - single checkbox <checkboxgroup title="Title of group"> - checkbox group <icheckbox title="Title" value="Value"> <icheckbox title="Title" checked=""> </checkboxgroup> <ibutton title="Button text"/> - submit button <formsenttext>Text with a successful form submission</formsenttext> </postform>
Google Translate was used for translation
The form may be a short form (when you need to save space). In this case the field names are written in the text box. When you click on the field - the name disappears, and you can begin typing. To use a short form form, you must specify a parameter: short = "yes". Example: <postform short="yes" ...> ...</ postform>
Fields "iradio" and "icheckbox" may have a parameter: checked = "", which means that the field will be marked by default. In one "radiogroup" only one element "iradio" may have an attribute: "checked"; if it is present in several elements, it selected will be the last marked.
Fields "itext", "itextarea", "iselect" may be setting req = "", which means "required field", and in this case the field pomechaetmsya asterisk (*). When submitting a form is verification of mandatory fields on the availability of data. If the test fails, a diagnostic message.
For the dropdown list there is the possibility of positioning and filtering as you type. In order to use it, you need to move the focus to the element of the list (by clicking on it or using the key Tab) and start typing. As you type in the list will remain only those elements, which include the typed text. To return the list to its original state, it is necessary to divert the focus from the element (by clicking elsewhere in the form or press Tab).
In the "iselect" v.2 must write the name of the downloaded files with the contents of the following format:
<list> <item> ...</ item> <item> ...</ item> ... </ list>
Field "iselect" v.3. Getting data from SQL-source. Parameter <type> - type of database. The options are: MySQL, MSSQL Parameters: <user>, <password>, <cond> - are not binding and are used only in case of their instructions. By default database connection is with the following data:
user: wikisql
password: asdfghjkl
That is in the source database must exist a user with that password.
Attention! The user should be the minimum rights, giving him only the right to read the data. Otherwise, there is risk of damage or loss of data, as well as communication with the server is low-level.
[edit] Sample
<postform to="[email protected]" subject="Mail Subject" from="[email protected]">Form Sample <itext title="Input text" name="Input_text"/> <itext title="Required Input text" name="Required_Input_text" req=""/> <itextarea title="Textarea" name="Textarea"/> <iselect title="Dropdown list" name="Dropdown_list"> <ioption/> <ioption>Item 1</ioption> <ioption>Item 2</ioption> <ioption>Item 3</ioption> </iselect> <radiogroup title="Radiobutton group" name="Radiobutton_group"> <iradio title="radio 1" value="1" checked=""/> <iradio title="radio 2" value="2"/> <iradio title="radio 3" value="3"/> </radiogroup> <icheckbox title="Single checkbox" name="Single_checkbox"/> <checkboxgroup title="Checkbox group"> <icheckbox title="checkbox 1"/> <icheckbox title="checkbox 2" checked=""/> <icheckbox title="checkbox 3"/> </checkboxgroup> <ibutton title="Send"/> </postform>
Result:
Form Sample
Short Form Sample