Home

Awesome

FlexForms Modules for PHP

Official PHP modules for FlexForms. Choose from a MIT or LGPL license.

Formerly called Admin Pack Modules. The modules in this repository extend FlexForms and also Admin Pack.

Donate Discord

Features

Available Modules

Usage

Copy all the files for a specific module into the same directory that FlexForms resides in (e.g. support/flex_forms.php). Then use require_once directives to include the required functionality after including FlexForms. Modules register themselves automatically with the FlexForms class.

The following new field types are added:

New type-specific options for array fields:

Examples

Example code showing how to use most modules can be found in the Admin Pack admin.php file.

reCAPTCHA Module Example

Since it doesn't really belong in Admin Pack, here's a brief example of using the reCAPTCHA module:

<?php
	// This example is derived from:
	//   https://github.com/cubiclesoft/php-flexforms/blob/master/docs/flex_forms.md

	require_once "support/str_basics.php";
	require_once "support/flex_forms.php";
	require_once "support/flex_forms_recaptcha.php";

	// ...

	$errors = array();
	if (isset($_REQUEST[$ff->GetHashedFieldName("name")]))
	{
		// ...

		$result = FlexForms_reCAPTCHA::IsValid("[Your secret key goes here]");
		if (!$result["success"])  $errors["recaptcha"] = $result["error"] . " (" . $result["errorcode"] . ")";

		if (!count($errors))
		{
			// ...
		}
	}

	// ...

	// Make your own site and secret key:  https://www.google.com/recaptcha/admin

	$contentopts = array(
		"hashnames" => true,
		"fields" => array(
			// ...
			array(
				"title" => "Module:  Invisible reCAPTCHA",
				"type" => "recaptcha",
				"name" => "recaptcha",
				"sitekey" => "[Your site key here]",
				"size" => "invisible",
				"desc" => "Description for reCAPTCHA."
			)
		),
		"submit" => "Submit"
	);

	$ff->Generate($contentopts, $errors);
?>

Even though the 'recaptcha' name attribute is not output, it is used for displaying error messages regarding reCAPTCHA submissions.

FlexForms_reCAPTCHA::IsValid($secretkey, $remoteip = true, $allowedhosts = true)

Module: reCAPTCHA

Access: public static

Parameters:

Returns: A standard array of information.

This function sends the reCAPTCHA code in $_REQUEST["g-recaptcha-response"] to the Google reCAPTCHA verification server. The included HTTP, WebBrowser, and IPAddr classes are loaded as needed. The defaults are generally good enough but customizations of the sitekey/secretkey (e.g. removing domain restrictions, proxying requests) may require calling this function with corrected options for $remoteip and $allowedhosts to guarantee that the CAPTCHA was solved by a valid IP address and hostname.