X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=encode.php;h=5b8eadf9426beb13051670821f51991f8f4bf25d;hb=130669e105c06dbfa3272ae9a2c41d5f11003a80;hp=3a11689f465d9101a06b88a6c82033f062cf6e0d;hpb=2eab32b23556a89b3190e208b88c1fd3bec4eb4d;p=wfpl.git diff --git a/encode.php b/encode.php index 3a11689..5b8eadf 100644 --- a/encode.php +++ b/encode.php @@ -20,7 +20,13 @@ # MA 02111-1307, USA. -# This file contains basic encodings +# This file contains basic encodings. These are used by the encoder. You can +# specify any template tag to be encoded with this syntax: ~variable.encoding~ +# +# this example:

~foo.html~

+# will encode foo (using enc_html()) before displaying it, so that characters +# such as < will display properly. + # encode for putting within double-quotes in SQL function enc_sql($str) { @@ -53,5 +59,20 @@ function enc_checked($str) { return ''; } } - +# add a tab at the begining of each non-empty line +function enc_tab($str) { + $lines = explode("\n", $str); + $out = ''; + foreach($lines as $line) { + if($line) { + $out .= "\t$line"; + } + $out .= "\n"; + } + + # remove the extra newline added above + return substr($out, 0, -1); +} + +?>