Пример #1
0
function fix_filename($str, $transliteration, $convert_spaces = false)
{
    if ($convert_spaces) {
        $str = str_replace(' ', '_', $str);
    }
    if ($transliteration) {
        if (function_exists('transliterator_transliterate')) {
            $str = transliterator_transliterate('Accents-Any', $str);
        } else {
            $str = setRemoveFontVi_urlTitle($str);
            //$str = iconv('UTF-8', 'ASCII//TRANSLIT//IGNORE', $str);
        }
        //$str = preg_replace( "/[^a-zA-Z0-9\.\[\]_| -]/", '', $str );
    }
    //    $str=str_replace(array('"',"'","/","\\"),"",$str);
    $str = strip_tags($str);
    // Empty or incorrectly transliterated filename.
    // Here is a point: a good file UNKNOWN_LANGUAGE.jpg could become .jpg in previous code.
    // So we add that default 'file' name to fix that issue.
    if (strpos($str, '.') === 0) {
        $str = 'file' . $str;
    }
    return trim($str);
}
Пример #2
0
    }
    if (file_exists($path . "config.php")) {
        require_once $path . "config.php";
        $cycle = FALSE;
    }
    $path = fix_dirname($path) . '/';
}
if (!empty($_FILES)) {
    $info = pathinfo($_FILES['file']['name']);
    if (in_array(fix_strtolower($info['extension']), $ext)) {
        $tempFile = $_FILES['file']['tmp_name'];
        $targetPath = $storeFolder;
        $targetPathThumb = $storeFolderThumb;
        $_FILES['file']['name'] = fix_filename($_FILES['file']['name'], $transliteration, $convert_spaces);
        //remove font Vi*******************************************************
        $_FILES['file']['name'] = setRemoveFontVi_urlTitle($_FILES['file']['name']);
        // Gen. new file name if exists
        if (file_exists($targetPath . $_FILES['file']['name'])) {
            $i = 1;
            $info = pathinfo($_FILES['file']['name']);
            // append number
            while (file_exists($targetPath . $info['filename'] . "_" . $i . "." . $info['extension'])) {
                $i++;
            }
            $_FILES['file']['name'] = $info['filename'] . "_" . $i . "." . $info['extension'];
        }
        $targetFile = $targetPath . $_FILES['file']['name'];
        $targetFileThumb = $targetPathThumb . $_FILES['file']['name'];
        // check if image (and supported)
        if (in_array(fix_strtolower($info['extension']), $ext_img)) {
            $is_img = TRUE;