JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
upload.php cleanup: really don't make dot files
[wfpl.git] / encode.php
index c09de2a..43a8a2d 100644 (file)
@@ -1,19 +1,9 @@
 <?php
 
-#  Copyright (C) 2005 Jason Woofenden
-#
-#  This program is free software: you can redistribute it and/or modify
-#  it under the terms of the GNU General Public License as published by
-#  the Free Software Foundation, either version 3 of the License, or
-#  (at your option) any later version.
-#  
-#  This program is distributed in the hope that it will be useful,
-#  but WITHOUT ANY WARRANTY; without even the implied warranty of
-#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#  GNU General Public License for more details.
-#  
-#  You should have received a copy of the GNU General Public License
-#  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+# This program is in the public domain within the United States. Additionally,
+# we waive copyright and related rights in the work worldwide through the CC0
+# 1.0 Universal public domain dedication, which can be found at
+# http://creativecommons.org/publicdomain/zero/1.0/
 
 
 # This file contains basic encodings. These are used by the encoder. You can
@@ -74,7 +64,7 @@ function enc_htmlbr($str) {
 # Example: <p>~foo htmlbrtab~</p>
 function enc_htmlbrtab($str) {
        $str = enc_htmlbr($str);
-       $whitespace_to_nbsp = create_function('$matches', '$count = 0; $chars = str_split($matches[0]); foreach ($chars as $c) { if ($c == " ") { $count += 2; } else if ($c == "\t") { $count += 8; } } return str_repeat("&nbsp;", $count);');
+       $whitespace_to_nbsp = create_function('$matches', '$count = 0; $chars = str_split($matches[0]); foreach ($chars as $c) { if ($c == " ") { $count += 1; } else if ($c == "\t") { $count += 8; } } return str_repeat("&nbsp;", $count);');
        $str = preg_replace_callback("|^[ \t]+|m", $whitespace_to_nbsp, $str);
        return $str;
 }
@@ -444,12 +434,12 @@ function wfpl_nth_word($str, $n) {
 
 # encoding is a space separated list of:
 # image_filename width height thumb_filename thumb_width thumb_height
-function enc_image_src($str) { wfpl_nth_word($str, 0); }
-function enc_image_width($str) { wfpl_nth_word($str, 1); }
-function enc_image_height($str) { wfpl_nth_word($str, 2); }
-function enc_thumb_src($str) { wfpl_nth_word($str, 3); }
-function enc_thumb_width($str) { wfpl_nth_word($str, 4); }
-function enc_thumb_height($str) { wfpl_nth_word($str, 5); }
+function enc_image_src($str) { return wfpl_nth_word($str, 0); }
+function enc_image_width($str) { return wfpl_nth_word($str, 1); }
+function enc_image_height($str) { return wfpl_nth_word($str, 2); }
+function enc_thumb_src($str) { return wfpl_nth_word($str, 3); }
+function enc_thumb_width($str) { return wfpl_nth_word($str, 4); }
+function enc_thumb_height($str) { return wfpl_nth_word($str, 5); }
 
 # example template: Length: ~length html~ day~length s~
 function enc_s($str) {