X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=format.php;h=f931cdd8c3fc6afebe277a129e8862795848686e;hb=423f31ad0add74bbb6066d3c9f760ad0a5580cda;hp=f90fc1f15c4ba9f876dc851e32e56206d9705a4c;hpb=f22b600c925131bb767db73d77dc595f18a1406a;p=wfpl.git diff --git a/format.php b/format.php index f90fc1f..f931cdd 100644 --- a/format.php +++ b/format.php @@ -112,24 +112,50 @@ function format_filename($str, $allow_uppercase = false) { return ereg_replace('^[.-]', '_', $str); } +function format_path($str, $allow_uppercase = false) { + if(!$allow_uppercase) { + $str = strtolower($str); + } + $str = ereg_replace('[^a-zA-Z0-9_./-]', '_', $str); + return ereg_replace('^[.-]', '_', $str); +} + function client_path_to_filename($path) { $filename = ereg_replace(".*[:/\\]", '', $path); return format_filename($filename, true); } -function format_h_w_image($str) { +function format_image_w_h($str) { $fields = explode(' ', $str); if(count($fields) != 3) { return ''; } - list($width, $height, $filename) = $fields; + list($filename, $width, $height) = $fields; + $filename = format_path($filename); + $width = format_int_0($width); + $height = format_int_0($height); + + return "$filename $width $height"; +} + +function format_image_w_h_thumb_w_h($str) { + $fields = explode(' ', $str); + if(count($fields) != 6) { + die('count: ' . count($fields)); + return ''; + } + + list($filename, $width, $height, $thumb_filename, $thumb_width, $thumb_height) = $fields; + $filename = format_path($filename); $width = format_int_0($width); $height = format_int_0($height); - $filename = format_filename($filename); + $thumb_filename = format_path($thumb_filename); + $thumb_width = format_int_0($thumb_width); + $thumb_height = format_int_0($thumb_height); - return "$width $height $filename"; + return "$filename $width $height $thumb_filename $thumb_width $thumb_height"; } function format_varname($str) {