From 410481c790e47f6a8193a2f3eb67e09180be0339 Mon Sep 17 00:00:00 2001 From: Jason Woofenden Date: Mon, 25 Jun 2007 12:51:03 -0400 Subject: [PATCH] added: dwt_load_str() and enc_jsdq() --- dwt.php | 8 ++++++-- encode.php | 6 ++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/dwt.php b/dwt.php index 6cd2d66..82629ff 100644 --- a/dwt.php +++ b/dwt.php @@ -32,11 +32,15 @@ function dwt_init() { dwt_reset(); } -function dwt_load($filename) { - $GLOBALS['_dwt_template'] = read_whole_file($filename); +function dwt_load_str($str) { + $GLOBALS['_dwt_template'] = $str; dwt_init(); } +function dwt_load($filename) { + dwt_load_str(read_whole_file($filename)); +} + function dwt_set_raw($name, $value) { $GLOBALS['_dwt_keys'][] = $name; $GLOBALS['_dwt_values'][] = $value; diff --git a/encode.php b/encode.php index 38b09bd..3f4119c 100644 --- a/encode.php +++ b/encode.php @@ -27,6 +27,12 @@ # such as < will display properly. +function enc_jsdq($str) { + $str = enc_sql($str); + $str = str_replace("\n", "\\n", $str); + return str_replace("\r", "\\r", $str); +} + # encode for putting within double-quotes in SQL function enc_sql($str) { $str = str_replace("\\", "\\\\", $str); -- 1.7.10.4