~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) { $str = str_replace("\\", "\\\\", $str); $str = str_replace('"', "\\\"", $str); return $str; } # Encode for output in html. does nothing with whitespace # # Example:

~foo.html~

function enc_html($str) { $str = str_replace('&', '&', $str); $str = str_replace('<', '<', $str); $str = str_replace('>', '>', $str); return $str; } # HTML attribute. # # Example: function enc_attr($str) { $str = str_replace('&', '&', $str); $str = str_replace('"', '"', $str); return $str; } # URI agument value. # # Example: http://example.com?foo=~foo.url_val~ function enc_url_val($str) { return rawurlencode($str); } # This is a hack to work around html's stupid syntax for checkboxes. # # Place the template marker just before a " somewhere. # # Example: function enc_checked($str) { if($str == 'Yes') { return '" checked="checked'; } else { 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); } function enc_upper($str) { return strtoupper($str); } # display