Ignore:
Timestamp:
May 1, 2015 1:15:16 AM (9 years ago)
Author:
anonymous
Message:

Non-breaking function changes to App and Utilities.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/Utilities.inc.php

    r507 r518  
    8282    if (!empty($var)) {
    8383        ?>
    84         <script type="text/javascript" charset="utf-8">
     84        <script type="text/javascript">
    8585        /* <![CDATA[ */
    86         window.console && console.log('<?php printf('%s: %s (on line %s of %s)', $prefix, str_replace("'", "\\'", getDump($var, true)), $line, $file); ?>');
     86        console.log('<?php printf('%s: %s (on line %s of %s)', $prefix, str_replace("'", "\\'", getDump($var, true)), $line, $file); ?>');
    8787        /* ]]> */
    8888        </script>
     
    536536}
    537537
     538/**
     539 * Removes non-latin characters from file name, using htmlentities to convert known weirdos into regular squares.
     540 *
     541 * @access  public
     542 * @param   string  $file_name  A name of a file.
     543 * @return  string              The same name, but cleaned.
     544 */
     545function cleanFileName($file_name)
     546{
     547    $app =& App::getInstance();
     548
     549    $file_name = preg_replace(array(
     550        '/&([a-z]{1,2})(?:acute|cedil|circ|grave|lig|orn|ring|slash|th|tilde|uml|caron);/ui',
     551        '/&(?:amp);/ui',
     552        '/[&;]+/u',
     553        '/[^a-zA-Z0-9()@._=+-]+/u',
     554        '/^_+|_+$/u'
     555    ), array(
     556        '$1',
     557        'and',
     558        '',
     559        '_',
     560        ''
     561    ), htmlentities($file_name, ENT_NOQUOTES | ENT_IGNORE, $app->getParam('character_set')));
     562    return mb_substr($file_name, 0, 250);
     563}
     564
    538565/*
    539566* Convert a php.ini value (8M, 512K, etc), into integer value of bytes.
Note: See TracChangeset for help on using the changeset viewer.