JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
clean up include paths and docs
authorJason Woofenden <jason@jasonwoof.com>
Tue, 3 Mar 2015 02:14:49 +0000 (21:14 -0500)
committerJason Woofenden <jason@jasonwoof.com>
Tue, 3 Mar 2015 02:14:49 +0000 (21:14 -0500)
30 files changed:
INSTALL
encode.php
examples/Makefile
examples/config.php [new file with mode: 0644]
examples/db_connect.php [deleted file]
fdb.php
main.php
messages.php
metaform.php
metaform/INSTALL [deleted file]
metaform/Makefile
metaform/preview.html
metaform/styl.styl
metaform/template.html
metaform/template.php
run2.php [deleted file]
session.php
stylus-helpers.styl
tar.php
test/session_test.html
test/session_test.php
test/session_test_db_connect.php
test/tar_test.php
test/tem_test.php
unit_tests.php
unit_tests/db.php
unit_tests/encode.php
unit_tests/format.php
unit_tests/misc.php
uploader.php

diff --git a/INSTALL b/INSTALL
index 09fa003..1f24907 100644 (file)
--- a/INSTALL
+++ b/INSTALL
@@ -1,46 +1,40 @@
-INSTALLING WFPL
+Installing WFPL
+===============
 
 
-This directory must be accessible to your PHP files via the relative path: code/wfpl/
+Just unpack the file somewhere that php has access to. It's recomended to have
+php at ``inc/wfpl/`` relative to your site php files, so you can use
+wfpl_main() and files from metaform without modification.
 
 
-The recommended way to do this is to create a directory named "code" in the
-main folder of your website. And make symbolic links to that "code" directory
-from all directories in your website where you run PHP.
 
 
-Install wfpl within that "code" directory. That is, these files should be in a
-directory named "wfpl" in the "code" directory described above.
+Metaform
+========
 
 
+Metaform is a code generator. Specifically, it generates the files that for a
+web page with a form (which, optionally saves to a database, emails, etc.)
 
 
+You are free to use the installation of metaform here:
 
 
-INSTALLING METAFORM on apache (OPTIONAL)
+https://jasonwoof.com/metaform/
 
 
-Note: metaform is a code generator. It is NOT required to use wfpl. It is a
-tool for auto-generating code for your site which makes use of wfpl.
-
-metaform.php unfortunately has a couple extra steps.
+However, if you'd like to run your own (possibly modified) version, read on for
+how to set up your own:
 
 
-1) make a directory (named "metaform" in this example) for metaform.
 
 
-2) make sure code/wfpl is accessible in this directory (link to your main
-"code" directory) as described above
+Installing Metaform on apache (OPTIONAL)
+=========================================
 
 
-3) make a symbolic link to metaform.php called index.php:
-
-ln -s code/wfpl/metaform.php index.php
+Note: metaform is a code generator. It is NOT required to use wfpl. It is a
+tool for auto-generating code for your site which makes use of wfpl.
 
 
-4) make a file named .htaccess that looks like this:
+You'll need some directives in your .htaccess:
 
 
-php_flag register_globals off
-php_flag magic_quotes_gpc off
-AddDefaultCharset UTF-8
-RewriteEngine  on
-RewriteBase    /metaform/
-RewriteRule    .*\.tgz$  /metaform/index.php
+       php_flag register_globals off
+       php_flag magic_quotes_gpc off
+       AddDefaultCharset UTF-8
+       RewriteEngine  on
+       RewriteRule    .*\.tgz$  /metaform/index.php
 
 
-Note: the above .htaccess file assumes that the "metaform" directory you
-created in step one is IN the root www directory. If it's in a sub directory
-(for example you access it via: http://example.com/my/sub/dir/metaform/) then
-replace the two occurrences of "metaform" in the .htaccess file with the path
-to that directory (for example "my/sub/dir/metaform").
+And a PHP file with:
 
 
-5) If php can't write to /tmp then you'll have to fix the $tmp_dir in
-code/wfpl/tar.php
+       require_once(__DIR__.'/'.'inc/wfpl/metaform.php);
+       metaform_main();
index ca4a919..9a9bdbc 100644 (file)
@@ -268,7 +268,7 @@ function pulldown($name, $in_options, $multiple = false) {
 # output a bunch of <option> tags
 function enc_options($values, $name) {
        if(!isset($GLOBALS[$name . '_options'])) {
 # output a bunch of <option> tags
 function enc_options($values, $name) {
        if(!isset($GLOBALS[$name . '_options'])) {
-               die("pulldown('$name') must be called before this template can be run. See code/wfpl/encode.php");
+               die("pulldown('$name') must be called before this template can be run. See wfpl/encode.php");
        }
        if($GLOBALS[$name . '_options']['multiple']) { # FIXME test this
                $values = explode(', ', $values);
        }
        if($GLOBALS[$name . '_options']['multiple']) { # FIXME test this
                $values = explode(', ', $values);
@@ -281,7 +281,7 @@ function enc_options($values, $name) {
 # returns what the user sees in the pulldown or on the radio button caption
 function enc_pulled($str, $name) {
        if(!isset($GLOBALS[$name . '_options'])) {
 # returns what the user sees in the pulldown or on the radio button caption
 function enc_pulled($str, $name) {
        if(!isset($GLOBALS[$name . '_options'])) {
-               die("pulldown('$name') must be called before this template can be run. See code/wfpl/encode.php");
+               die("pulldown('$name') must be called before this template can be run. See wfpl/encode.php");
        }
        foreach($GLOBALS[$name . '_options']['options'] as &$kv) {
                if($kv[0] == $str) {
        }
        foreach($GLOBALS[$name . '_options']['options'] as &$kv) {
                if($kv[0] == $str) {
@@ -293,7 +293,7 @@ function enc_pulled($str, $name) {
 
 function enc_radio_n($str, $name, $n) {
        if(!isset($GLOBALS[$name . '_options'])) {
 
 function enc_radio_n($str, $name, $n) {
        if(!isset($GLOBALS[$name . '_options'])) {
-               die("pulldown('$name') must be called before this template can be run. See code/wfpl/encode.php");
+               die("pulldown('$name') must be called before this template can be run. See wfpl/encode.php");
        }
 
        if(!isset($GLOBALS[$name . '_options']['options'][$n])) {
        }
 
        if(!isset($GLOBALS[$name . '_options']['options'][$n])) {
@@ -320,7 +320,7 @@ function enc_radio_7($str, $name) { return enc_radio_n($str, $name, 7); }
 
 function enc_radio_caption_n($str, $name, $n) {
        if(!isset($GLOBALS[$name . '_options'])) {
 
 function enc_radio_caption_n($str, $name, $n) {
        if(!isset($GLOBALS[$name . '_options'])) {
-               die("pulldown('$name') must be called before this template can be run. See code/wfpl/encode.php");
+               die("pulldown('$name') must be called before this template can be run. See wfpl/encode.php");
        }
 
        if(!isset($GLOBALS[$name . '_options']['options'][$n])) {
        }
 
        if(!isset($GLOBALS[$name . '_options']['options'][$n])) {
index 7a3c515..9372468 100644 (file)
@@ -1,2 +1,2 @@
-tags: *.php code/*.php code/wfpl/*.php
+tags: *.php inc/*.php inc/wfpl/*.php
        ctags-exuberant --append=yes $?
        ctags-exuberant --append=yes $?
diff --git a/examples/config.php b/examples/config.php
new file mode 100644 (file)
index 0000000..1dc9d0d
--- /dev/null
@@ -0,0 +1,21 @@
+<?php
+
+# Settings
+define('WFPL_DB', 'fixme');
+define('WFPL_DB_USER', 'fixme');
+define('WFPL_DB_PASS', 'fixme');
+# CMS login passwords are stored in the database. See admin_admins.php
+date_default_timezone_set('America/New_York');
+
+# Enable features, auto-includes
+require_once(__DIR__.'/'.'inc/wfpl/format.php');
+require_once(__DIR__.'/'.'inc/wfpl/db.php');
+require_once(__DIR__.'/'.'inc/wfpl/session_messages.php');
+require_once(__DIR__.'/'.'inc/cms.php');
+
+# Connect to the database
+db_connect(WFPL_DB, WFPL_DB_USER, WFPL_DB_PASS);
+
+# Load the requested page (php and/or html)
+require_once(__DIR__.'/'.'inc/wfpl/main.php');
+wfpl_main();
diff --git a/examples/db_connect.php b/examples/db_connect.php
deleted file mode 100644 (file)
index 655e9b9..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-<?php
-
-require_once(__DIR__.'/'.'code/wfpl/db.php');
-
-# fill in whatever database credentials you need here:
-db_connect('database_name', 'username', 'password', 'host');
-
-# all fields are optional. see code/wfpl/db.php for details.
-
-?>
diff --git a/fdb.php b/fdb.php
index c36c712..3716ea6 100644 (file)
--- a/fdb.php
+++ b/fdb.php
@@ -39,7 +39,7 @@ function fdb_set_dir($dir) {
 
 function fdb_get_dir() {
        if(!isset($GLOBALS['fdb_dir'])) {
 
 function fdb_get_dir() {
        if(!isset($GLOBALS['fdb_dir'])) {
-               die('you must call fdb_set_dir() before calling other functions in code/wfpl/fdb.php');
+               die('you must call fdb_set_dir() before calling other functions in wfpl/fdb.php');
        }
        return $GLOBALS['fdb_dir'];
 }
        }
        return $GLOBALS['fdb_dir'];
 }
index e088d67..f5be944 100644 (file)
--- a/main.php
+++ b/main.php
@@ -77,7 +77,7 @@ function wfpl_main($dest = false) {
        if(function_exists('cms_display')) {
                $cms_content = cms_display($basename, $GLOBALS['wfpl_main_template']);
                if(is_string($cms_content)) {
        if(function_exists('cms_display')) {
                $cms_content = cms_display($basename, $GLOBALS['wfpl_main_template']);
                if(is_string($cms_content)) {
-                       run_php($cms_content);
+                       wfpl_main($cms_content);
                        return;
                }
        } else {
                        return;
                }
        } else {
@@ -88,7 +88,7 @@ function wfpl_main($dest = false) {
                header('HTTP/1.0 404 File Not Found');
                if(file_exists('error_404.php') || file_exists('error_404.html')) {
                        $GLOBALS['error_basename'] = $basename;
                header('HTTP/1.0 404 File Not Found');
                if(file_exists('error_404.php') || file_exists('error_404.html')) {
                        $GLOBALS['error_basename'] = $basename;
-                       run_php('error_404');
+                       wfpl_main('error_404');
                        return;
                } else {
                        echo '<!DOCTYPE html><html><head><title>404</title></head><body><h1>404 File Not Found</h1></body></html>';
                        return;
                } else {
                        echo '<!DOCTYPE html><html><head><title>404</title></head><body><h1>404 File Not Found</h1></body></html>';
@@ -110,7 +110,7 @@ function wfpl_main($dest = false) {
                # files can return a basename or URL of a page to be run/displayed
                $other = file_run($php_file);
                if($other) {
                # files can return a basename or URL of a page to be run/displayed
                $other = file_run($php_file);
                if($other) {
-                       run_php($other);
+                       wfpl_main($other);
                        return;
                }
        } elseif($html_exists) {
                        return;
                }
        } elseif($html_exists) {
@@ -134,8 +134,8 @@ function wfpl_main($dest = false) {
                }
 
 
                }
 
 
-               # You'll probably want to require_once(__DIR__.'/'.'code/wfpl/messages.php') or
-               # require_once(__DIR__.'/'.'code/wfpl/session_messages.php') in code/config.php
+               # You'll probably want to require_once(__DIR__.'/'.'lib/wfpl/messages.php') or
+               # require_once(__DIR__.'/'.'lib/wfpl/session_messages.php') in config.php
                if(function_exists('display_messages')) {
                        if(function_exists('atexit_now')) {
                                atexit_now();
                if(function_exists('display_messages')) {
                        if(function_exists('atexit_now')) {
                                atexit_now();
index 41d4a56..53d2d64 100644 (file)
@@ -27,7 +27,7 @@
 # display_messages() for you automaticallly after your main function returns
 # (so long as you require_once this file.) If you want these messages to
 # persist accross browser redirects, then you should
 # display_messages() for you automaticallly after your main function returns
 # (so long as you require_once this file.) If you want these messages to
 # persist accross browser redirects, then you should
-# require_once(__DIR__.'/'.'code/wfpl/session_messages.php')
+# require_once(__DIR__.'/'.'lib/wfpl/session_messages.php')
 #
 # Just make sure your template has a <!--~$messages {~--> section with a
 # ~message html~ tag in it.
 #
 # Just make sure your template has a <!--~$messages {~--> section with a
 # ~message html~ tag in it.
index ad980a6..9f67385 100644 (file)
@@ -23,7 +23,7 @@ require_once(__DIR__.'/'.'http.php');
 require_once(__DIR__.'/'.'tar.php');
 require_once(__DIR__.'/'.'format.php');
 
 require_once(__DIR__.'/'.'tar.php');
 require_once(__DIR__.'/'.'format.php');
 
-# see code/wfpl/metaform/template.html for the html templates for these elements
+# see wfpl/metaform/template.html for the html templates for these elements
 $GLOBALS['types'] = array(
 #    type                  input          format        sql     
        'varname' =>    array('textbox',     'varname',    'varchar(50) binary'),
 $GLOBALS['types'] = array(
 #    type                  input          format        sql     
        'varname' =>    array('textbox',     'varname',    'varchar(50) binary'),
diff --git a/metaform/INSTALL b/metaform/INSTALL
deleted file mode 100644 (file)
index bd038a4..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-Install Instructions For The Files In This Directory
-====================================================
-
-If your directory is already set up for WFPL, then all you have to do is copy
-the files from this directory (except INSTALL and .htaccess) to that directory,
-and it should run as-is. If not, keep reading...
-
-Instructions For Setting Up A Directory For WFPL
-------------------------------------------------
-
-1.     "cd" to the directory that will contain all your content and code files.
-
-2.     make a "code" directory:
-
-               mkdir code
-
-3.     download wfpl:
-
-               cd code
-               git clone git://gitorious.org/wfpl/wfpl.git
-               cd ..
-
-4.     make the run.php link:
-
-               ln -s code/wfpl/run.php
-
-5.     Copy the file named ".htaccess" from this directory to the hosting folder
-       (where you put the php file.)  This is included as a separate step,
-       because the "." at the beginning makes the file hidden. This means it does
-       not show up in directory listings (unless you pass -a) and does not match
-       "*" in shell commands. Here's how you could copy it:
-
-               cp directory-containing-this-INSTALL-file/.htaccess .
-
-6.     If you have a domain name pointing directly at the directory you're
-       setting up (for example, it's accessible as http://example.com/) then
-       you're done! But if this directory is acessed with a directory (or
-       multiple directories) in the URL path (for example:
-       http://example.com/foo/bar/) then you'll need to edit the RewriteRule in
-       .htaccess (read the comments in that file for further explanation and
-       examples.)
-
-
-That's it! Now that you've got the directory set up, just place your php files
-and your html templates in there, and you should be good to go. Remember to
-omit the file extension in the URL.
index f0d0adb..01b24a7 100644 (file)
@@ -36,5 +36,5 @@ style.css: styl.styl .image-mtimes.styl
                ; exit 1 \
        )
 
                ; exit 1 \
        )
 
-tags: *.php code/*.php code/wfpl/*.php
-       exuberant-ctags *.php code/*.php code/wfpl/*.php
+tags: *.php inc/*.php inc/wfpl/*.php
+       exuberant-ctags *.php inc/*.php inc/wfpl/*.php
index 5e1d237..daf43a8 100644 (file)
@@ -3,7 +3,7 @@
 <html>
 <head>
   <title>Meta Form</title>
 <html>
 <head>
   <title>Meta Form</title>
-  <link rel="stylesheet" href="code/wfpl/metaform/style.css" type="text/css">
+  <link rel="stylesheet" href="inc/wfpl/metaform/style.css" type="text/css">
 </head>
 
 <body>
 </head>
 
 <body>
index 36eb71e..cf59d0e 100644 (file)
@@ -1,4 +1,4 @@
-@require 'code/wfpl/stylus-helpers.styl'
+@require 'inc/wfpl/stylus-helpers.styl'
 @require '.image-mtimes.styl'
 
 // dimensions
 @require '.image-mtimes.styl'
 
 // dimensions
index 9bc4e9a..1aa7759 100644 (file)
@@ -6,7 +6,7 @@
        <title><!--~~$title show {~~-->~plural cap~<!--~~}~~--></title>
        <link rel="stylesheet" href="style.css"><!--~html_editor_headers {~-->
        <!--~~$head {~~-->
        <title><!--~~$title show {~~-->~plural cap~<!--~~}~~--></title>
        <link rel="stylesheet" href="style.css"><!--~html_editor_headers {~-->
        <!--~~$head {~~-->
-       <script src="code/ckeditor/ckeditor.js"></script>
+       <script src="inc/ckeditor/ckeditor.js"></script>
        <script>
                function make_wysiwyg(name) {
                        CKEDITOR.replace(name, {
        <script>
                function make_wysiwyg(name) {
                        CKEDITOR.replace(name, {
index ac78d06..4aeb1c0 100644 (file)
@@ -32,9 +32,9 @@ $GLOBALS['~name~_thumb_max_height'] = '70';
 $GLOBALS['~name~_file_name'] = uniqid() . getmypid() . '.jpg'; # comment this out to use uploader's filename
 ~}~~}~
 
 $GLOBALS['~name~_file_name'] = uniqid() . getmypid() . '.jpg'; # comment this out to use uploader's filename
 ~}~~}~
 
-require_once(__DIR__.'/'.'code/wfpl/format.php');~opt_email {~
-require_once(__DIR__.'/'.'code/wfpl/email.php');~}~~uploads_include {~
-require_once(__DIR__.'/'.'code/wfpl/upload.php');~}~
+require_once(__DIR__.'/'.'inc/wfpl/format.php');~opt_email {~
+require_once(__DIR__.'/'.'inc/wfpl/email.php');~}~~uploads_include {~
+require_once(__DIR__.'/'.'inc/wfpl/upload.php');~}~
 
 $GLOBALS['~file_name~_field_to_caption'] = array(~name_to_caption {~
        '~name~' => '~caption phpsq~'~ sep {~,~}~~}~
 
 $GLOBALS['~file_name~_field_to_caption'] = array(~name_to_caption {~
        '~name~' => '~caption phpsq~'~ sep {~,~}~~}~
@@ -148,7 +148,7 @@ function ~file_name~_main_delete($id) {
 }~}~~opt_listing {~
 
 function ~file_name~_csv_download() {
 }~}~~opt_listing {~
 
 function ~file_name~_csv_download() {
-       require_once(__DIR__.'/'.'code/wfpl/csv.php');
+       require_once(__DIR__.'/'.'inc/wfpl/csv.php');
        $rows = db_get_rows('~table_name~', 'id,'.~file_name upper~_DB_FIELDS, 'order by id');
        $fields = explode(',', 'id,'.~file_name upper~_DB_FIELDS);
        $header = array();
        $rows = db_get_rows('~table_name~', 'id,'.~file_name upper~_DB_FIELDS, 'order by id');
        $fields = explode(',', 'id,'.~file_name upper~_DB_FIELDS);
        $header = array();
diff --git a/run2.php b/run2.php
deleted file mode 100644 (file)
index abe0dfa..0000000
--- a/run2.php
+++ /dev/null
@@ -1,150 +0,0 @@
-<?php  # For new template API
-
-#  2006 Public Domain
-#
-#  This file was placed into the public domain on November 16th, 2008 by its
-#  sole author Jason Woofenden
-
-# This file facilitates making a site with mixed PHP and html files. All URLs
-# have the .html extension. One benefit of this is that you can change static
-# html files to php scripts without having to update links.
-
-# This script will pull the filename from the URL. It looks for a file with
-# that name, and for one with the same basename, but with the .php extension
-# and acts accordingly:
-
-#--------------------------------------------#
-#        | .php file exists   | no .php file #
-#--------+--------------------+--------------#
-# .html  | load html file as  | pass html    #
-# file   | a template and run | file through #
-# exists | run the php file   | as is        #
-#--------+--------------------+--------------#
-# no     |                    |              #
-# .html  | run php file       | display 404  #
-# file   |                    |              #
-#--------------------------------------------#
-
-
-
-# To activate this script in a directory, you'll need to:
-#
-# 1) make a symbolic link to (or copy of) this file in your directory. and
-#
-# 3) Set your webserver to run this script instead of html files. Here's how to
-# do that with apache: put something like the following in you your .htaccess
-# file (where /foo/ is the part of the url between the hostname and the
-# filename.) The example below would work for this url:
-# http://example.com/foo/bar.html
-
-# RewriteEngine  on
-# RewriteRule    ^$  /foo/run.php
-# RewriteRule    ^foo/[^/]*\.html$  /foo/run.php
-
-require_once(__DIR__.'/'.'code/wfpl/file_run.php');
-require_once(__DIR__.'/'.'code/wfpl/http.php');
-require_once(__DIR__.'/'.'code/wfpl/template.php');
-
-if(file_exists('code/config.php')) {
-       file_run('code/config.php');
-}
-
-# pass the basename of the page you want for normal execution
-# pass ./page.html to redirect to page.html in this directory
-# pass http://foo.com/bar.html to redirect to a full directory
-function run_php($dest = false) {
-       if($dest) {
-               # if it has a : it must be a full URL, redirect
-               if(strpos($dest, ':')) {
-                       redirect($dest);
-                       exit();
-               }
-
-               # if it starts with './' then it's a relative URL, redirect
-               if(substr($dest, 0, 2) == './') {
-                       redirect(ereg_replace('/[^/]*$', substr($dest, 1), this_url()));
-                       exit();
-               }
-
-               # otherwise, it's a normal basename, display that content
-               $basename = $dest;
-
-       } else { # no dest arg
-               $basename = $_SERVER['REDIRECT_URL'];
-               $basename = ereg_replace('.*/', '', $basename);
-               $basename = ereg_replace('\.html$', '', $basename);
-               if($basename == '') {
-                       $basename = 'index';
-               }
-       }
-
-       $GLOBALS['basename'] = $basename;
-
-       $html_file = "$basename.html";
-       $php_file = "$basename.php";
-
-       $html_exists = file_exists($html_file);
-       $php_exists = file_exists($php_file);
-
-       # cms_get can return one of:
-       # 1) false to indicate that there's no cms content for this basename
-       # 2) a string to request a soft/full redirect just like foo_main()
-       # 3) a hash of key/value pairs to be added to the template
-       if(function_exists('cms_display')) {
-               $cms_content = cms_display($basename);
-               if(is_string($cms_content)) {
-                       run_php($cms_content);
-                       return;
-               }
-       } else {
-               $cms_content = false;
-       }
-
-       if($php_exists) {
-               # files can return a basename or URL of a page to be run/displayed
-               $other = file_run($php_file);
-               if($other) {
-                       run_php($other);
-                       return;
-               }
-       } elseif($html_exists) {
-               readfile($html_file);
-               exit();
-       } elseif(!$cms_content) {
-               header('HTTP/1.0 404 File Not Found');
-               if(file_exists('404.php') || file_exists('404.html')) {
-                       run_php('404');
-                       return;
-               } else {
-                       echo '<!DOCTYPE html><html><head><title>404</title></head><body><h1>404 File Not Found</h1></body></html>';
-                       exit();
-               }
-       }
-
-       $data =& $GLOBALS['wfpl_tem_data'];
-       $data['basename'] = $basename;
-       if(function_exists('display_messages')) {
-               display_messages();
-       }
-       if($cms_content) foreach($cms_content as $name => $value) {
-               $data[$name] .= $value;
-       }
-       if(file_exists("$basename.css")) {
-               $data['css_link'] = "$basename.css";
-       }
-
-       if(file_exists("template.html")) {
-               $template = parse_template_file("template.html");
-               if($html_exists) {
-                       $page_template = parse_template_file($html_file);
-                       $template = merge_templates($template, $page_template);
-               }
-       } elseif($html_exists) {
-               $template = parse_template_file("$html_file");
-       }
-       if($template) print fill_template($template, $data);
-}
-
-run_php();
-
-?>
index bd91a5b..bcf2357 100644 (file)
@@ -20,7 +20,7 @@
 # create table wfpl_sessions (id int unique auto_increment, session_key varchar(16), length int, expires int);
 # create table wfpl_session_data (id int unique auto_increment, session_id int, name varchar(100), value text);
 # run this command to install/clear the tables:
 # create table wfpl_sessions (id int unique auto_increment, session_key varchar(16), length int, expires int);
 # create table wfpl_session_data (id int unique auto_increment, session_id int, name varchar(100), value text);
 # run this command to install/clear the tables:
-#   mysql DATABASE_NAME < code/wfpl/examples/session.sql
+#   mysql DATABASE_NAME < inc/wfpl/examples/session.sql
 # note: you may need these parameters for mysql:  -u USERNAME -p
 
 # GLOSSARY
 # note: you may need these parameters for mysql:  -u USERNAME -p
 
 # GLOSSARY
index 701adfb..b3769a7 100644 (file)
@@ -3,7 +3,7 @@
 // This file contains helpers for using stylus in your project.
 //
 // Put something like this in your styl.styl:
 // This file contains helpers for using stylus in your project.
 //
 // Put something like this in your styl.styl:
-//     @require 'code/wfpl/stylus-helpers.styl'
+//     @require 'inc/wfpl/stylus-helpers.styl'
 
 
 // set units to px if it doesn't have a unit already
 
 
 // set units to px if it doesn't have a unit already
diff --git a/tar.php b/tar.php
index e7beedb..bba514e 100644 (file)
--- a/tar.php
+++ b/tar.php
@@ -82,14 +82,14 @@ function make_tar($dirname, $files, $pre_archive_func = false, $tmpdir = false)
        system('/bin/rm -rf ' . escapeshellarg($tmpdir));
 }
 
        system('/bin/rm -rf ' . escapeshellarg($tmpdir));
 }
 
-# like make_tar above, except it includes a copy of code/wfpl
+# like make_tar above, except it includes a copy of wfpl
 function make_wfpl_tar($dirname, $files) {
        make_tar($dirname, $files, 'add_wfpl_dir');
 }
 
 function add_wfpl_dir($dir) {
        mkdir("$dir/code");
 function make_wfpl_tar($dirname, $files) {
        make_tar($dirname, $files, 'add_wfpl_dir');
 }
 
 function add_wfpl_dir($dir) {
        mkdir("$dir/code");
-       system("rsync -plr --exclude=\".git\" --exclude=\"*.swp\" 'code/wfpl/' '$dir/code/wfpl/'", $return_code);
+       system("rsync -plr --exclude=\".git\" --exclude=\"*.swp\" 'inc/wfpl/' '$dir/inc/wfpl/'", $return_code);
        if($return_code != 0) {
                die("ERROR: while trying to copy wfpl into archive: rsync returned $return_code");
        }
        if($return_code != 0) {
                die("ERROR: while trying to copy wfpl into archive: rsync returned $return_code");
        }
index 684d788..27aee76 100644 (file)
@@ -2,12 +2,12 @@
 
 <html>
 <head>
 
 <html>
 <head>
-  <title>testing code/wfpl/session.php</title>
+  <title>testing inc/wfpl/session.php</title>
 </head>
 
 <body>
 
 </head>
 
 <body>
 
-<h1>testing code/wfpl/session.php</h1>
+<h1>testing inc/wfpl/session.php</h1>
 
 <!--~block {~-->
 <div style="border: 2px solid black; padding: 10px; margin-top: -2px">
 
 <!--~block {~-->
 <div style="border: 2px solid black; padding: 10px; margin-top: -2px">
index dea3291..6537e13 100644 (file)
@@ -5,11 +5,9 @@
 
 # To run this file:
 #
 
 # To run this file:
 #
-# 1) make a link to it from your website directory which has the code/ directory in it
+# 1) edit inc/wfpl/test/session_test_db_connect.php to connect to your TESTING database
 #
 #
-# 2) edit code/wfpl/test/session_test_db_connect.php to connect to your TESTING database
-#
-# 3) add the wfpl_session tables to your TESTING database:
+# 2) add the wfpl_session tables to your TESTING database:
 #
 # create table wfpl_sessions (id int unique auto_increment, session_key varchar(16), length int, expires int);
 # create table wfpl_session_data (id int unique auto_increment, session_id int, name varchar(100), value text);
 #
 # create table wfpl_sessions (id int unique auto_increment, session_key varchar(16), length int, expires int);
 # create table wfpl_session_data (id int unique auto_increment, session_id int, name varchar(100), value text);
@@ -18,8 +16,8 @@
 # WARNING: this code deletes all wfpl sessions. Do not use on a live site's database
 ##############
 
 # WARNING: this code deletes all wfpl sessions. Do not use on a live site's database
 ##############
 
-require_once(__DIR__.'/'.'code/wfpl/test/session_test_db_connect.php');
-require_once(__DIR__.'/'.'code/wfpl/session.php');
+require_once(__DIR__.'/'.'session_test_db_connect.php');
+require_once(__DIR__.'/../'.'session.php');
 
 function session_dump($message) {
        $ses = db_get_rows('wfpl_sessions', 'id,session_key,length,expires');
 
 function session_dump($message) {
        $ses = db_get_rows('wfpl_sessions', 'id,session_key,length,expires');
@@ -48,7 +46,7 @@ function session_dump($message) {
 
 
 function session_test() {
 
 
 function session_test() {
-       tem_load('code/wfpl/test/session_test.html');
+       tem_load(__DIR__.'/'.'session_test.html');
 
        db_delete('wfpl_sessions');
        db_delete('wfpl_session_data');
 
        db_delete('wfpl_sessions');
        db_delete('wfpl_session_data');
@@ -83,5 +81,3 @@ function session_test() {
 
        tem_output();
 }
 
        tem_output();
 }
-
-?>
index 54e10f4..fff0a2c 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 
 <?php
 
-require_once(__DIR__.'/'.'code/wfpl/db.php');
+require_once(__DIR__.'/../'.'db.php');
 
 db_connect('DATABASE_NAME', 'USERNAME', 'PASSWORD');
 
 
 db_connect('DATABASE_NAME', 'USERNAME', 'PASSWORD');
 
index 3c28d40..fb5d9d3 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 
 <?php
 
-require_once(__DIR__.'/'.'code/wfpl/tar.php');
+require_once(__DIR__.'/../'.'tar.php');
 
 # Unfortunately, I don't know how to set the suggested filename for downloads,
 # so you'll have to deal with that yourself.
 
 # Unfortunately, I don't know how to set the suggested filename for downloads,
 # so you'll have to deal with that yourself.
index 2a8ef27..e71d8ea 100644 (file)
@@ -2,77 +2,75 @@
 
 # Copyright (C) 2005 Jason Woofenden  PUBLIC DOMAIN
 
 
 # Copyright (C) 2005 Jason Woofenden  PUBLIC DOMAIN
 
-
 # This file (along with its html template) demonstrates, documents and tests
 # the template system.
 
 # First we'll need the functions in wfpl/template.php:
 # This file (along with its html template) demonstrates, documents and tests
 # the template system.
 
 # First we'll need the functions in wfpl/template.php:
-require_once(__DIR__.'/'.'code/wfpl/template.php');
-# Always use the exact require_once statement above to get access to these
-# functions. You should have in each directory of your projects a copy of wfpl
-# or a symbolic link to it. This allows there to be different versions of wfpl
-# without changing the php for the site.
-
-# Now grab the template (you might want to take a look at this file)
-tem_load('tem_test.php.html');
-# This creates a template object to store all sorts of things, and then reads
-# in the template file and scans through it for sub-templates. Sub templates
-# are parts of the template that may appear any number of times in the output
-# (even zero times) such as a table row meant to hold a database record.
-
-# This is probably not the best example, but this template contains tables for
-# login, and for displaying some fake database content. For this silly example
-# I decide which I'm going to display by checking if the user has submitted a
-# username.
-if(!isset($_REQUEST['user'])) {
-       # tem_set() gives a key/value pair to template.php. When the template is
-       # output (or sub-templates are run with tem_sub) any occurences of ~user~
-       # will be replaced with 'bert'.
-       tem_set('user', 'bert');
-
-       # The template file contains a sub-template called 'login'. By default,
-       # sub-templates do not display at all. They display once for each time you
-       # call tem_sub()
-       tem_sub('login');
-
-       # This runs the template and prints the output. Running the template is
-       # simply replacing all ~key~ tags with the associated value. The values are
-       # set with tem_set() and tem_sub().
+require_once(__DIR__.'/../'.'template.php');
+
+function tem_test_main() {
+       # Now grab the template (you might want to take a look at this file)
+       tem_load('tem_test.php.html');
+       # This creates a template object to store all sorts of things, and then reads
+       # in the template file and scans through it for sub-templates. Sub templates
+       # are parts of the template that may appear any number of times in the output
+       # (even zero times) such as a table row meant to hold a database record.
+
+       # This is probably not the best example, but this template contains tables for
+       # login, and for displaying some fake database content. For this silly example
+       # I decide which I'm going to display by checking if the user has submitted a
+       # username.
+       if(!isset($_REQUEST['user'])) {
+               # tem_set() gives a key/value pair to template.php. When the template is
+               # output (or sub-templates are run with tem_sub) any occurences of ~user~
+               # will be replaced with 'bert'.
+               tem_set('user', 'bert');
+
+               # The template file contains a sub-template called 'login'. By default,
+               # sub-templates do not display at all. They display once for each time you
+               # call tem_sub()
+               tem_sub('login');
+
+               # This runs the template and prints the output. Running the template is
+               # simply replacing all ~key~ tags with the associated value. The values are
+               # set with tem_set() and tem_sub().
+               tem_output();
+
+               exit(0);
+       }
+
+       # Below is an example of using a sub-sub-template many times
+
+       # first set some values to be displayed in the row:
+       tem_set('foo', '*&^@$<>"');
+       tem_set('bar', 'one*&^@$<>"');
+
+       # Now run the row. This runs the sub-template for the row, and appends the data
+       # for the 'foobar_row' entry in the main key/value list. 
+       tem_sub('foobar_row');
+
+       # and a couple more times:
+       tem_set('foo', '"""""****"""""');
+       tem_set('bar', 'two*&^"');
+       tem_sub('foobar_row');
+       tem_set('foo', '<<<<<<&&&&&&&&amp;>>>>>');
+       tem_set('bar', 'threeeeeeee*&^@$<>"eeeeeeeeeeee');
+       tem_sub('foobar_row');
+
+       # Now we have a 'foobar_row' in the main keyval array with three rows of html in it.
+
+       # in the template foobar_row is within a bigger sub-template called
+       # 'foobar_table'. The only reason for this is so that we can have that table
+       # not display at all when we're displaying the login. This is a silly use of
+       # the templates, but I wanted to demonstrate and test a simple use of a
+       # sub-template within a sub-template.
+       tem_sub('foobar_table');
+
+
+       # Now run the main template (the body of the template file)
        tem_output();
        tem_output();
-
-       exit(0);
 }
 
 }
 
-# Below is an example of using a sub-sub-template many times
-
-# first set some values to be displayed in the row:
-tem_set('foo', '*&^@$<>"');
-tem_set('bar', 'one*&^@$<>"');
-
-# Now run the row. This runs the sub-template for the row, and appends the data
-# for the 'foobar_row' entry in the main key/value list. 
-tem_sub('foobar_row');
-
-# and a couple more times:
-tem_set('foo', '"""""****"""""');
-tem_set('bar', 'two*&^"');
-tem_sub('foobar_row');
-tem_set('foo', '<<<<<<&&&&&&&&amp;>>>>>');
-tem_set('bar', 'threeeeeeee*&^@$<>"eeeeeeeeeeee');
-tem_sub('foobar_row');
-
-# Now we have a 'foobar_row' in the main keyval array with three rows of html in it.
-
-# in the template foobar_row is within a bigger sub-template called
-# 'foobar_table'. The only reason for this is so that we can have that table
-# not display at all when we're displaying the login. This is a silly use of
-# the templates, but I wanted to demonstrate and test a simple use of a
-# sub-template within a sub-template.
-tem_sub('foobar_table');
-
-
-# Now run the main template (the body of the template file)
-tem_output();
-
-
-?>
+# if this file were in a wfpl site proper, this would get called automatically,
+# but this is here so you can run it directly from the examples dircectory:
+tem_test_main();
index 3577664..41677e4 100644 (file)
@@ -18,8 +18,8 @@
 
 # This file is for running unit tests. Either on wfpl or your own code.
 
 
 # This file is for running unit tests. Either on wfpl or your own code.
 
-require_once(__DIR__.'/'.'code/wfpl/template.php');
-require_once(__DIR__.'/'.'code/wfpl/messages.php');
+require_once(__DIR__.'/'.'template.php');
+require_once(__DIR__.'/'.'messages.php');
 
 # call this to declare that a unit test has passed
 function unit_test_passed($msg) {
 
 # call this to declare that a unit test has passed
 function unit_test_passed($msg) {
@@ -106,11 +106,11 @@ function run_unit_tests($directory, $basenames) {
 }
 
 # Call this to unit test wfpl. By default it tests everything, or you can pass
 }
 
 # Call this to unit test wfpl. By default it tests everything, or you can pass
-# a space-separated list of the basenames of the files in code/wfpl/unit_tests/
+# a space-separated list of the basenames of the files in wfpl/unit_tests/
 # that you'd like to run.
 function unit_test_wfpl($basenames = 'format db misc encode') {
 # that you'd like to run.
 function unit_test_wfpl($basenames = 'format db misc encode') {
-       tem_load('code/wfpl/unit_tests/template.html');
-       run_unit_tests('code/wfpl/unit_tests', $basenames);
+       tem_load(__DIR__.'/'.'unit_tests/template.html');
+       run_unit_tests(__DIR__.'/'.'unit_tests', $basenames);
        display_messages();
        tem_output();
        exit();
        display_messages();
        tem_output();
        exit();
index 5fd4a49..5077c8f 100644 (file)
 #  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 
 #  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 
-# This file contains tests for functions in code/wfpl/format.php
+# This file contains tests for functions in wfpl/format.php
 #
 #
-# See code/wfpl/test.php for details on how to run or create tests
+# See wfpl/test.php for details on how to run or create tests
 
 
 
 
-require_once(__DIR__.'/'.'code/wfpl/db.php');
+require_once(__DIR__.'/../'.'db.php');
 
 function test_db_reposition($table = 'reposition') {
        db_delete($table);
 
 function test_db_reposition($table = 'reposition') {
        db_delete($table);
index 911a8af..9aec5b5 100644 (file)
 #  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 
 #  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 
-# This file contains tests for functions in code/wfpl/format.php
+# This file contains tests for functions in wfpl/encode.php
 #
 #
-# See code/wfpl/test.php for details on how to run or create tests
+# See wfpl/test.php for details on how to run or create tests
 
 
 
 
-require_once(__DIR__.'/'.'code/wfpl/encode.php');
+require_once(__DIR__.'/../'.'encode.php');
 
 function _test_encode_pulled($field, $value, $correct) {
        unit_test_func('enc_pulled', $value, $field, $correct);
 
 function _test_encode_pulled($field, $value, $correct) {
        unit_test_func('enc_pulled', $value, $field, $correct);
index 5ccb154..6d5de15 100644 (file)
 #  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 
 #  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 
-# This file contains tests for functions in code/wfpl/format.php
+# This file contains tests for functions in wfpl/format.php
 #
 #
-# See code/wfpl/test.php for details on how to run or create tests
+# See wfpl/test.php for details on how to run or create tests
 
 
 
 
-require_once(__DIR__.'/'.'code/wfpl/format.php');
+require_once(__DIR__.'/../'.'format.php');
 
 function _test_format_money($arg, $dollars_correct, $money_correct) {
        unit_test_func('format_dollars', $arg, $dollars_correct);
 
 function _test_format_money($arg, $dollars_correct, $money_correct) {
        unit_test_func('format_dollars', $arg, $dollars_correct);
index 71fa7f9..bb61794 100644 (file)
 #  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 
 #  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 
-# This file contains tests for functions in code/wfpl/misc.php
+# This file contains tests for functions in wfpl/misc.php
 #
 #
-# See code/wfpl/unit_tests.php for details on how to run or create tests
+# See wfpl/unit_tests.php for details on how to run or create tests
 
 
 
 
-require_once(__DIR__.'/'.'code/wfpl/misc.php');
+require_once(__DIR__.'/../'.'misc.php');
 
 function test_ordinalize() {
        $tests = array(
 
 function test_ordinalize() {
        $tests = array(
index a793385..0badb1a 100644 (file)
@@ -51,17 +51,17 @@ function uploader($progress_url = '') {
        }
 
        $html = new tem();
        }
 
        $html = new tem();
-       $html->load('code/wfpl/uploader/uploader.html');
+       $html->load(__DIR__.'/'.'uploader/uploader.html');
        $html->set('filename', $filename);
        $html->set('host', $GLOBALS['wfpl_uploader_host']);
        $html->set('port', $GLOBALS['wfpl_uploader_port']);
        $html->show('main');
        $html = $html->get('main');
 
        $html->set('filename', $filename);
        $html->set('host', $GLOBALS['wfpl_uploader_host']);
        $html->set('port', $GLOBALS['wfpl_uploader_port']);
        $html->show('main');
        $html = $html->get('main');
 
-       $css = read_whole_file('code/wfpl/uploader/uploader.css');
+       $css = read_whole_file(__DIR__.'/'.'uploader/uploader.css');
 
        $javascript = new tem();
 
        $javascript = new tem();
-       $javascript->load('code/wfpl/uploader/progress.js');
+       $javascript->load(__DIR__.'/'.'uploader/progress.js');
        $javascript->set('url', $progress_url);
        $javascript = $javascript->run();
 
        $javascript->set('url', $progress_url);
        $javascript = $javascript->run();
 
@@ -80,7 +80,7 @@ function uploader_move($tmp_filename, $filename) {
 # start a daemon to accept file uploads and give progress indicators
 # if the port is used (eg if the daemon is already running) this will do nothing.
 function uploader_daemon_start($port) {
 # start a daemon to accept file uploads and give progress indicators
 # if the port is used (eg if the daemon is already running) this will do nothing.
 function uploader_daemon_start($port) {
-       exec(path_to('tcpserver') . " -q -R -H -llocalhost 0 $port " . path_to('perl') . ' code/wfpl/uploader/daemon.pl ' . $GLOBALS['wfpl_uploader_path'] . ' >/dev/null 2>/dev/null < /dev/null &');
+       exec(path_to('tcpserver') . " -q -R -H -llocalhost 0 $port " . path_to('perl') . ' lib/wfpl/uploader/daemon.pl ' . $GLOBALS['wfpl_uploader_path'] . ' >/dev/null 2>/dev/null < /dev/null &');
 }
 
 /* call this to respond to the javascript async request for progress on the upload */
 }
 
 /* call this to respond to the javascript async request for progress on the upload */