Not signed in (Sign In)

Vanilla 1.1.10 is a product of Lussumo. More Information: Documentation, Community Support.

    • CommentAuthorkenysc
    • CommentTimeFeb 4th 2010
     
    If I use Chinese as Collection and Album names, the corresponding folders will use only under-dashes as folder names. Thus if the names are of same number of Chinese chars, they mess-up with others. I notices that the images are still be available in the "merged" folders, but what about photos with same filenames but put in different Albums?

    To reproduce this bug:
    1. Create a test collection
    2. Create a test Albums within this collection with this Chinese Album name: ???????
    3. Create a test Albums within this collection with this Chinese Album name: ???????
    4. Put photos with SAME filenames in these albums

    Suggested solutions:
    1. use random codes as folder names
    2. use unicode folder names
    3. (not a good one) check for existing folders names and append a number to the to-be-created folder name

    Cheers,
    •  
      CommentAuthorsidtheduck
    • CommentTimeFeb 5th 2010
     
    kenysc,

    Yes, this is an issue with Plogger. We have talked about implementing transliteration for storing directories. If you would prefer the #1 or #2 solution above, I can probably work something up that will work as a temporary solution.
    •  
      CommentAuthorsidtheduck
    • CommentTimeFeb 5th 2010
     
    Here's a quick and dirty temporary solution.
    Open plog-includes/plog-functions.php and replace the sanitize_filename() function with this one:
    // Sanitize filename by replacing international characters with underscores
    function sanitize_filename($str, $is_file = false) {
    global $config;
    // Allow only alphanumeric characters, hyphen, and dot in file names
    // Spaces will be changed to dashes, special chars will be suppressed, & the rest will be replaced with underscores
    $special_chars = array ('#', '$', '%', '^', '&', '*', '!', '~', '"', '\'', '=', '?', '/', '[', ']', '(', ')', '|', '<', '>', ';', ':', '\\', ', ');
    $str = str_replace($special_chars, '', $str);
    $str = str_replace(' ', '-', $str);
    // urlencode the string to get the url escaped equivalent
    $str = urlencode($str);
    // change the percentages to hyphens
    $str = str_replace('%', '-', $str);
    // drop any additional characters (should be nothing, but just in case)
    $str = preg_replace("/[^a-zA-Z0-9\-\.]/", '', $str);
    // remove any double hyphens from the string
    $str = str_replace('--', '-', $str);
    if ($is_file && intval($config['truncate']) > 0 && isset($str{intval($config['truncate'])})) {
    $str = substr($str, 0, intval($config['truncate']));
    }
    return $str;
    }


    Please note that while your collection and album names will be kept in the originating language for display, the pictures will not (as the pictures use the filename as the name - another change I would like to do to Plogger that hasn't been implemented yet).
    • CommentAuthorkenysc
    • CommentTimeFeb 8th 2010
     
    Thanks for looking in to this. Personally I prefer solution #2 as it's more consistent. Will mod the files and try. Cheers =)
    •  
      CommentAuthorsidtheduck
    • CommentTimeFeb 9th 2010
     
    kenysc,

    The posted solution uses urlencode to encode the folder names to their ISO encoded alternates (not necessarily unicode, but it includes unicode character sets). The whole reason for the filename sanitation is not necessarily for storage on the server (this typically is fine with international characters), but the URL path to those directories and files when linking through a website (which uses ISO-latin characters only, unless you are on select specific Chinese or Russian servers that allow for their own character sets to be used in URLs). Using urlencode() ensures that the filenames are specific to the name specified (they are not just random characters), but also that the paths are safe to use as an URL when linking to folders / files from the web.