From 1c6e9a5776476a1c6f8c5ace08ceaba64ffa05eb Mon Sep 17 00:00:00 2001 From: Jason Woofenden Date: Sun, 8 Nov 2009 15:08:51 -0500 Subject: [PATCH] metaform has option for a session-based login-required --- metaform.php | 10 +++++----- metaform/main.html | 2 +- metaform/preview.html | 2 +- metaform/template.php | 18 +++++------------- 4 files changed, 12 insertions(+), 20 deletions(-) diff --git a/metaform.php b/metaform.php index f90ad17..0f7563e 100644 --- a/metaform.php +++ b/metaform.php @@ -87,8 +87,8 @@ function metaform() { tem_set('opt_listing', $GLOBALS['opt_listing']); $GLOBALS['opt_display'] = format_yesno($_REQUEST['opt_display']); tem_set('opt_display', $GLOBALS['opt_display']); - $GLOBALS['opt_http_pass'] = format_yesno($_REQUEST['opt_http_pass']); - tem_set('opt_http_pass', $GLOBALS['opt_http_pass']); + $GLOBALS['opt_pass'] = format_yesno($_REQUEST['opt_pass']); + tem_set('opt_pass', $GLOBALS['opt_pass']); } if(isset($_REQUEST['fields'])) { @@ -437,9 +437,9 @@ function make_php() { $tem->show('opt_email_1'); $tem->show('opt_email_2'); } - if($GLOBALS['opt_http_pass'] == 'Yes') { - $tem->show('opt_http_pass_1'); - $tem->show('opt_http_pass_2'); + if($GLOBALS['opt_pass'] == 'Yes') { + $tem->show('opt_pass'); + $tem->show('opt_pass'); } return $tem->run(); } diff --git a/metaform/main.html b/metaform/main.html index 80f7d2b..f698d14 100644 --- a/metaform/main.html +++ b/metaform/main.html @@ -30,7 +30,7 @@

Provide a "Display" page.

-

Password protect this form (with HTTP authentication).

+

Password protect this form.

Below, specify the fields you'd like in your form, one field per line. After each field name, put at least one space, then the field type. The following field types are available: , ~type html~.

Example:

diff --git a/metaform/preview.html b/metaform/preview.html
index 5f20a5b..e8a07d2 100644
--- a/metaform/preview.html
+++ b/metaform/preview.html
@@ -14,7 +14,7 @@
     

~hiddens~

-

+

diff --git a/metaform/template.php b/metaform/template.php index aed6054..5f59c6d 100644 --- a/metaform/template.php +++ b/metaform/template.php @@ -31,12 +31,7 @@ $GLOBALS['~name~_max_height'] = '400'; $GLOBALS['~name~_thumb_max_width'] = '70'; $GLOBALS['~name~_thumb_max_height'] = '70'; $GLOBALS['~name~_file_name'] = uniqid() . getmypid() . '.jpg'; # comment this out to use uploader's filename - -# Define the username and password required to view this form: -define('AUTH_REALM', '~file_name~ administration area'); -define('AUTH_USER', 'fixme'); -define('AUTH_PASS', 'fixme'); - + require_once('code/wfpl/template.php'); require_once('code/wfpl/format.php'); @@ -133,13 +128,10 @@ function ~file_name~_display_main() { function ~file_name~_edit_main() { -function _~file_name~_main() { - # To remove password protection, just delete this block: - if (!isset($_SERVER['PHP_AUTH_USER']) || $_SERVER['PHP_AUTH_USER'] != AUTH_USER || $_SERVER['PHP_AUTH_PW'] != AUTH_PASS) { - header('WWW-Authenticate: Basic realm="' . AUTH_REALM . '"'); - header('HTTP/1.0 401 Unauthorized'); - echo '401 Unauthorized'; - exit; +function _~file_name~_main() { + if(!logged_in_as_admin()) { + $GLOBALS['url'] = this_url(); + return 'admin_login'; } pulldown('~name~', array('option 1', 'option 2', 'option 3')); -- 1.7.10.4