JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
metaform has option for a session-based login-required
[wfpl.git] / metaform / template.php
index aed6054..5f59c6d 100644 (file)
@@ -31,12 +31,7 @@ $GLOBALS['~name~_max_height'] = '400';<!--~thumb_settings {~-->
 $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
-<!--~}~--><!--~}~--><!--~opt_http_pass_1 {~-->
-# 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() {<!--~}~--><!--~opt_display_2_else {~-->
 
 
-function _~file_name~_main() {<!--~}~--><!--~opt_http_pass_2 {~-->
-       # 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() {<!--~}~--><!--~opt_pass {~-->
+       if(!logged_in_as_admin()) {
+               $GLOBALS['url'] = this_url();
+               return 'admin_login';
        }
 <!--~}~--><!--~pulldowns {~-->
        pulldown('~name~', array('option 1', 'option 2', 'option 3'));