function session_test() { tem_load('code/wfpl/test/session_test.html'); db_delete('wfpl_sessions'); db_delete('wfpl_session_data'); session_dump('Clean slate'); session_new(); session_dump('new session'); session_set('username', 'jason'); session_dump('username jason'); session_set('username', 'phil'); session_dump('overwrote username as phil'); $old = $GLOBALS['session_id']; session_new(); session_dump('new session'); session_set('username', 'jason'); session_set('bamph', 'foo'); session_dump('set username=jason and bamph=foo in new session'); session_clear('username'); session_dump('cleared username in new session'); _kill_session($old); session_dump('killed old session'); kill_session(); session_dump('kill_session()'); tem_output(); }
function preview() { tem_load('code/wfpl/metaform/preview.html'); tem_set('form_name', $GLOBALS['form_name']); tem_set('fields', $_REQUEST['fields']); $preview_tem = new tem(); $preview_tem->load_str(make_html(false)); if ($GLOBALS['opt_db'] == 'Yes') { $preview_tem->show('new_msg'); } $fields = get_fields(); foreach ($fields as $field) { list($name, $type, $input, $format, $sql) = $field; if ($type == 'pulldown') { pulldown($name, array('option 1', 'option 2', 'option 3')); } } $preview = $preview_tem->run(); unset($preview_tem); $preview = ereg_replace('type="submit"', 'type="submit" disabled="disabled"', $preview); tem_set('preview', $preview); tem_show('hiddens'); set_form_action(); tem_output(); }
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();