From: Jason Woofenden Date: Tue, 17 Apr 2007 17:34:23 +0000 (-0400) Subject: db_printf()'s %s, dwt_append(), states pulldown, tem_top_subs() X-Git-Url: https://jasonwoof.com/gitweb/?p=wfpl.git;a=commitdiff_plain;h=848c8a4d215f9cce1db0a7d37e733b5959b8210f db_printf()'s %s, dwt_append(), states pulldown, tem_top_subs() textareas get their own line(s) in e-mails --- diff --git a/db.php b/db.php index 065ac0e..3e4f725 100644 --- a/db.php +++ b/db.php @@ -130,6 +130,8 @@ function _db_printf($str, $args) { if($chr == '"') { $out .= '"' . enc_sql(array_pop($args)) . '"'; + } elseif($chr == 's') { + $out .= enc_sql(array_pop($args)); } elseif($chr == 'i') { $int = format_int(array_pop($args)); if($int == '') $int = '0'; diff --git a/dwt.php b/dwt.php index 7d68258..78daa54 100644 --- a/dwt.php +++ b/dwt.php @@ -21,8 +21,8 @@ require_once('code/wfpl/misc.php'); function dwt_reset() { - $GLOBALS['_dwt_keys'] = array(); - $GLOBALS['_dwt_values'] = array(); + $GLOBALS['_dwt_keys'] = array(''); + $GLOBALS['_dwt_values'] = array(''); } function dwt_init() { @@ -46,9 +46,35 @@ function dwt_set($name, $value) { dwt_set_raw("", $value); } +# returns index into arrays +function dwt_find_raw($name) { + for($i = 0; $i < count($GLOBALS['_dwt_keys']); ++$i) { + if($GLOBALS['_dwt_keys'][$i] == $name) { + return $i; + } + } + return null; +} + +# returns index into arrays +function dwt_find($name) { + return dwt_find_raw(""); +} + +function dwt_append($name, $value) { + $index = dwt_find($name); + if($index !== null) { + $GLOBALS['_dwt_values'][$index] .= $value; + } else { + dwt_set($name, $value); + } +} + function dwt_output($filename = null) { if($filename !== null) { dwt_load($filename); } print(str_replace($GLOBALS['_dwt_keys'], $GLOBALS['_dwt_values'], $GLOBALS['_dwt_template'])); } + +?> diff --git a/encode.php b/encode.php index ab2c271..a4c4587 100644 --- a/encode.php +++ b/encode.php @@ -89,4 +89,20 @@ function enc_tab($str) { return substr($out, 0, -1); } + +# display