X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=encode.php;h=3a11689f465d9101a06b88a6c82033f062cf6e0d;hb=b063dc432f05059d76aa02b08fe94c705ef66868;hp=90ec6c8ac6c99e99fdf272bbc966dc0e7763d508;hpb=3bec0ef771d741361c6c4c4c1ff069398f6e37a0;p=wfpl.git diff --git a/encode.php b/encode.php index 90ec6c8..3a11689 100644 --- a/encode.php +++ b/encode.php @@ -22,6 +22,14 @@ # This file contains basic encodings +# encode for putting within double-quotes in SQL +function enc_sql($str) { + $str = str_replace("\\", "\\\\", $str); + $str = str_replace('"', "\\\"", $str); + return $str; +} + +# encode for output in html. does nothing with whitespace function enc_html($str) { $str = str_replace('&', '&', $str); $str = str_replace('<', '<', $str); @@ -37,4 +45,13 @@ function enc_attr($str) { return $str; } +# this is a stupid hack to work around html's stupid syntax for checkboxes +function enc_checked($str) { + if($str == 'Yes') { + return '" checked="checked'; + } else { + return ''; + } +} +