Recent Changes - Search:

Cookbook

PmWiki

pmwiki.org

ZAP Form Processor

(redirected from Cookbook.Acme)

Summary: The ZAP forms processor handles data and file management, page insertions (forums, blogs), email & newsletters, e-commerce, and more.
Status: Stable (relies on latest Beta version of PmWiki)
Maintainer:

ZAP's Documentation and Support Website

For more extensive information, demos and support about ZAP:
http://zapdoc.web-farm.org

What can this recipe do?

Basically, ZAP extends the forms script that comes standard with PmWiki by adding a (:zapform:) and (:zapend:) markup to create forms that act in special ways controlled by standard input fields: text, textarea, select, radio, checkbox, etc. As of 2007, ZAP added an optional zap input field which uses session variables for more secure data transfer. ZAP and ZAPtoolbox also offers a few additional markups, markup expressions, page variables, conditionals etc. ZAP stores data invisibly on wiki pages (visible when you edit), and makes it retrievable as standard PmWiki text variables for easy use in pagelists and searching.

To install, simply download zap and if desired the zap toolbox, and enable as needed in local config files. For the documentation, download the zapdocs.zip file, dump into wiki.d, and goto Support.HomePage. Please direct all questions/comments to the PmWiki mailing list.

KAL: I've created a file zapdocsnew.zip, where the groups of the ZAP pages are changed to ZAP* (i.e. added a Suffix ZAP to all groupnames) and the references are (hopefully all) changed accordingly. See also pmwiki maillist, mails to ZAp-support in Aug 2007.

Sample ZAP forms

To create a very basic ZAP form, just sandwich standard text boxes, password boxes, radio buttons, checkboxes, whatever between the (:zapform:) and (:zapend:) markups. The ZAP forms processing engine will be called, and depending on the field names and values, various actions triggered. Here is how to set up a simple form that saves data:

(:messages:)
(:zapform:)
(:input text "Field1":)
(:input text "Field2":)
(:input hidden savedata "Field1,Field2":)
(:input submit value="Zap it!":)
(:zapend:)

If you want to look at the data, just edit the data page. You will notice them stored as text variables in the standard hidden format. To retrieve the data, use the normal syntax. In the above example, just put the following somewhere on the same page:

Field 1: {$:Field1}
Field 2: {$:Field2}

On another page you can write {Group.Name$:Field} to retrieve these values. To update a form field, simply prepopulate it with existing data and then resave with the changes. Fields not list will not be changed. Here is an example combining lines from the two samples above:

(:messages:)
(:zapdata:)
(:zapform:)
(:input text "Field1" {$:Field1}:)
(:input text "Field2" {$:Field2}:)
(:input hidden savedata "Field1,Field2":)
(:input submit value="Zap it!":)
(:zapend:)
Data:\\ 
Field 1: {$:Field1}
Field 2: {$:Field2}

ZAP Features

The ZAP Forms Processor has many built in features, and is easy to extend. Throw in PmWiki's fantastic flexibility and you end up being able to do about anything you want with a form--including some rather complex and powerful applications. Below is a partial list of actions you can trigger in a ZAP form. (Most require the ZAPtoolbox). For more information plus code snippets illustrating ZAP at work, see the documentation download.

  • New Member Registration
  • Member Login
  • Group Management
  • Form Validation (pattern matching)
  • Password Protect Forms
  • Field Replacements
  • Forward Browser to Any Page
  • Save Data on Any Page
  • Get Full URL's for Pages
  • Random Number Generator and Captcha
  • Time & Time Formatting
  • Messaging System
  • Pass Data via Get Variables
  • Save Data/Erase Data
  • Hide Data from Text Variables
  • Advanced List Management
  • Find and Replace
  • Create Pages (templated from form data)
  • Delete Pages
  • Upload Files in a ZAP Form
  • Email to Addresses, Members, or Newslists
  • Shopping Cart & Order Forms
  • Payment Processing through PayPal
  • Post Submission Conditional Processing
  • Basic Math and PHP
  • Instant Messaging
  • Self grading quizzes and even courses
  • Many new ZAP markups and custom conditions
  • Edit pages or sections of pages
  • Page insertions
  • Powerful Logging (sort, trim, etc)
  • And probably more!

ZAP Security

Combining form submissions with the kind of power available in ZAP calls for strict security measures. In addition to automatically disabling PmWiki directives, and other malicious php code in form submissions, ZAP has several built in security measures--including tough forged header protection, and an internal security system controlling all toolbox commands. ZAP also sets up its own permissions level within PmWiki allowing you to limit who can submit forms to specific users, groups, or passwords, and even have different permissions on different groups and/or pages.

At present there are NO known security vulnerabilities. However, no software is perfectly safe. See the ZAP support site for a full discussion of ZAP's security features.

Contributors

  • Caveman Click here to learn more about the story behind this recipe...
  • Many others who have suggested countless ideas along the way.

Comments

I would like to use the Zap forms to send an email however I would like to dynamically create the email subject based on the data entered in the form - would something like this be possible? Karl - 7-1-2008


Hi, Karl. Yes, you can use any value entered in the form as a variable within (:zap:) tags by enclosing its name in {braces}, so for instance if you have a field named Subject, you could construct a custom subject line with

(:zap emailsubject="Mail from my Zap form: {Subject}":)

Hope that helps. Ben Stallings July 02, 2008, at 11:27 AM


Ben, Thanks for your response. Unfortunately, the change did not produce the desired results. The syntax, I used was:

(:zapform:)
(:zap email="test@abc.com":)
(:zap emailsubject="{Name1} {Name2} - Email Subject":)
(:zap emailfrom="test@abc.net":)
(:input text Name1:)
(:input text Name2:)
(:zap emailtemplate="Main.TestTemplate":)
(:input submit value="Submit":)
(:zapend:)

The resulting email subject was: {Name1} {Name2} - Email Subject


I updated zap to work with $SiteAdminGroup Variable rater than $SiteGroup. This is an important security fix, cause Zap don't allow to write in this group. Since I'm not a programmer someone with thous skills blease verify the changes. zap_2007-12-04.phpΔ

 if ((($vv[0] == $SiteAdminGroup) || ($vv[0] == "Site")) && ($EnableZAPsiteEdits != true))
 ZAPabort('site', "Group $SiteAdminGroup is blocked on this system. ");
  • to:
 if ((($vv[0] == $SiteAdminGroup) || ($vv[0] == "SiteAdmin")) && ($EnableZAPsiteEdits != true))
 ZAPabort('site', "Group $SiteAdminGroup is blocked on this system. ");

I did not check your work but this is an important upgrade. Thanks! Caveman


Please help! Running zap+zaptoolsbox I obtain:

Fatal error: Call to undefined function: pagetextvar() in /home/httpd/vhosts/poincare.org/subdomains/chronos/httpdocs/cookbook/zap.php on line 326

You must upgrade to PmWiki 2.2, as ZAP requires its PTV capabilities. Caveman


Please Help me, too.

I'm running a ZAP as a newsletter system on a webside to protest against water privatisation. Thus, it's not a wiki, I handle it with a login section. If you're not logged in, the newsletter gives back an error. How can I make this work for not logged-in users? I would be in debt to everyone who'll treat this as a matter of urgent. Sitelink(approve links) -- Chris

Edit - History - Print - Recent Changes - Search
Page last modified on October 08, 2008, at 05:20 PM