-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();
# 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);
# 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) {
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])) {
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])) {
-tags: *.php code/*.php code/wfpl/*.php
+tags: *.php inc/*.php inc/wfpl/*.php
ctags-exuberant --append=yes $?
--- /dev/null
+<?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();
+++ /dev/null
-<?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.
-
-?>
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'];
}
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 {
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>';
# 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) {
}
- # 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();
# 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.
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'),
+++ /dev/null
-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.
; 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
<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>
-@require 'code/wfpl/stylus-helpers.styl'
+@require 'inc/wfpl/stylus-helpers.styl'
@require '.image-mtimes.styl'
// dimensions
<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, {
$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 {~,~}~~}~
}~}~~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();
+++ /dev/null
-<?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();
-
-?>
# 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
// 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
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");
- 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");
}
<html>
<head>
- <title>testing code/wfpl/session.php</title>
+ <title>testing inc/wfpl/session.php</title>
</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">
# 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);
# 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_test() {
- tem_load('code/wfpl/test/session_test.html');
+ tem_load(__DIR__.'/'.'session_test.html');
db_delete('wfpl_sessions');
db_delete('wfpl_session_data');
tem_output();
}
-
-?>
<?php
-require_once(__DIR__.'/'.'code/wfpl/db.php');
+require_once(__DIR__.'/../'.'db.php');
db_connect('DATABASE_NAME', 'USERNAME', 'PASSWORD');
<?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.
# 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:
-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', '<<<<<<&&&&&&&&>>>>>');
+ 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();
-
- 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', '<<<<<<&&&&&&&&>>>>>');
-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();
# 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 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') {
- 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();
# 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);
# 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);
# 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);
# 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(
}
$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');
- $css = read_whole_file('code/wfpl/uploader/uploader.css');
+ $css = read_whole_file(__DIR__.'/'.'uploader/uploader.css');
$javascript = new tem();
- $javascript->load('code/wfpl/uploader/progress.js');
+ $javascript->load(__DIR__.'/'.'uploader/progress.js');
$javascript->set('url', $progress_url);
$javascript = $javascript->run();
# 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 */