Ejemplo n.º 1
0
    if ($path == $current_path) {
        $cycle = false;
    }
    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 (isset($info['extension']) && 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);
        $file_name_splitted = explode('.', $_FILES['file']['name']);
        array_pop($file_name_splitted);
        $_FILES['file']['name'] = implode('-', $file_name_splitted) . '.' . $info['extension'];
        if (file_exists($targetPath . $_FILES['file']['name'])) {
            $i = 1;
            $info = pathinfo($_FILES['file']['name']);
            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'];
        if (in_array(fix_strtolower($info['extension']), $ext_img) && @getimagesize($tempFile) != false) {
            $is_img = true;
    if ($path == $current_path) {
        $cycle = FALSE;
    }
    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, $replace_with);
        // 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;
Ejemplo n.º 3
0
                         $paths .= "/";
                     }
                     $base_dir = $paths . substr_replace($info['dirname'] . "/", '', 0, strlen($current_path));
                     if (file_exists($base_dir . $fixed_image_creation_name_to_prepend[$k] . $info['filename'] . $fixed_image_creation_to_append[$k] . "." . $info['extension'])) {
                         rename_file($base_dir . $fixed_image_creation_name_to_prepend[$k] . $info['filename'] . $fixed_image_creation_to_append[$k] . "." . $info['extension'], $fixed_image_creation_name_to_prepend[$k] . $name . $fixed_image_creation_to_append[$k], $transliteration);
                     }
                 }
             }
         } else {
             die(lang_Empty_name);
         }
     }
     break;
 case 'duplicate_file':
     if ($duplicate_files) {
         $name = fix_filename($name, $transliteration);
         if (!empty($name)) {
             if (!duplicate_file($path, $name)) {
                 die(lang_Rename_existing_file);
             }
             duplicate_file($path_thumb, $name);
             if ($fixed_image_creation) {
                 $info = pathinfo($path);
                 foreach ($fixed_path_from_filemanager as $k => $paths) {
                     if ($paths != "" && $paths[strlen($paths) - 1] != "/") {
                         $paths .= "/";
                     }
                     $base_dir = $paths . substr_replace($info['dirname'] . "/", '', 0, strlen($current_path));
                     if (file_exists($base_dir . $fixed_image_creation_name_to_prepend[$k] . $info['filename'] . $fixed_image_creation_to_append[$k] . "." . $info['extension'])) {
                         duplicate_file($base_dir . $fixed_image_creation_name_to_prepend[$k] . $info['filename'] . $fixed_image_creation_to_append[$k] . "." . $info['extension'], $fixed_image_creation_name_to_prepend[$k] . $name . $fixed_image_creation_to_append[$k]);
                     }
Ejemplo n.º 4
0
function fix_path($path, $transliteration, $convert_spaces = false, $replace_with = "_")
{
    $info = pathinfo($path);
    $tmp_path = $info['dirname'];
    $str = strtolower(fix_filename($info['filename'], $transliteration, $convert_spaces, $replace_with));
    if ($tmp_path != "") {
        return $tmp_path . DIRECTORY_SEPARATOR . $str;
    } else {
        return $str;
    }
}
Ejemplo n.º 5
0
 if ($file != fix_filename($file, $transliteration)) {
     $file1 = fix_filename($file, $transliteration);
     $file_path1 = $current_path . $rfm_subfolder . $subdir . $file1;
     if (file_exists($file_path1)) {
         $i = 1;
         $info = pathinfo($file1);
         while (file_exists($current_path . $rfm_subfolder . $subdir . $info['filename'] . ".[" . $i . "]." . $info['extension'])) {
             $i++;
         }
         $file1 = $info['filename'] . ".[" . $i . "]." . $info['extension'];
         $file_path1 = $current_path . $rfm_subfolder . $subdir . $file1;
     }
     $filename = substr($file1, 0, '-' . (strlen($file_array['extension']) + 1));
     rename_file($file_path, fix_filename($filename, $transliteration), $transliteration);
     $file = $file1;
     $file_array['extension'] = fix_filename($file_array['extension'], $transliteration);
     $file_path = $file_path1;
 }
 $is_img = false;
 $is_video = false;
 $is_audio = false;
 $show_original = false;
 $show_original_mini = false;
 $mini_src = "";
 $src_thumb = "";
 $extension_lower = fix_strtolower($file_array['extension']);
 if (in_array($extension_lower, $ext_img)) {
     $src = $base_url . $cur_dir . rawurlencode($file);
     $mini_src = $src_thumb = $thumbs_path . $subdir . $file;
     //add in thumbs folder if not exist
     if (!file_exists($src_thumb)) {
Ejemplo n.º 6
0
 if ($file != fix_filename($file)) {
     $file1 = fix_filename($file);
     $file_path1 = $current_path . $subfolder . $subdir . $file1;
     if (file_exists($file_path1)) {
         $i = 1;
         $info = pathinfo($file1);
         while (file_exists($current_path . $subfolder . $subdir . $info['filename'] . ".[" . $i . "]." . $info['extension'])) {
             $i++;
         }
         $file1 = $info['filename'] . ".[" . $i . "]." . $info['extension'];
         $file_path1 = $current_path . $subfolder . $subdir . $file1;
     }
     $filename = substr($file1, 0, '-' . (strlen($file_array['extension']) + 1));
     rename_file($file_path, fix_filename($filename));
     $file = $file1;
     $file_array['extension'] = fix_filename($file_array['extension']);
     $file_path = $file_path1;
 }
 $is_img = false;
 $is_video = false;
 $is_audio = false;
 $show_original = false;
 $show_original_mini = false;
 $mini_src = "";
 $src_thumb = "";
 $extension_lower = mb_strtolower($file_array['extension']);
 if (in_array($extension_lower, $ext_img)) {
     $src = $base_url . $cur_dir . $file;
     $mini_src = $src_thumb = $thumbs_path . $subdir . $file;
     //add in thumbs folder if not exist
     if (!file_exists($src_thumb)) {
Ejemplo n.º 7
0
        $cycle = FALSE;
    }
    $path = fix_dirname($path) . '/';
}
if (!empty($_FILES)) {
    $info = pathinfo($_FILES['file']['name']);
    $mime_type = get_file_mime_type($_FILES['file']['tmp_name']);
    $extension = get_extension_from_mime($mime_type);
    if ($extension === '' || $extension == 'so') {
        $extension = $info['extension'];
    }
    if (in_array(fix_strtolower($extension), $ext)) {
        $tempFile = $_FILES['file']['tmp_name'];
        $targetPath = $storeFolder;
        $targetPathThumb = $storeFolderThumb;
        $_FILES['file']['name'] = fix_filename($info['filename'] . "." . $extension, $transliteration, $convert_spaces, $replace_with);
        // LowerCase
        if ($lower_case) {
            $_FILES['file']['name'] = fix_strtolower($_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 . "." . $extension)) {
                $i++;
            }
            $_FILES['file']['name'] = $info['filename'] . "_" . $i . "." . $extension;
        }
        $targetFile = $targetPath . $_FILES['file']['name'];
Ejemplo n.º 8
0
     if (isset($_GET['descending'])) {
         $_SESSION['RF']["descending"] = $_GET['descending'] === "TRUE";
     }
     break;
 case 'image_size':
     // not used
     $pos = strpos($_POST['path'], $upload_dir);
     if ($pos !== false) {
         $info = getimagesize(substr_replace($_POST['path'], $current_path, $pos, strlen($upload_dir)));
         response($info)->send();
         exit;
     }
     break;
 case 'save_img':
     $info = pathinfo($_POST['name']);
     if (strpos($_POST['path'], '/') === 0 || strpos($_POST['path'], '../') !== false || strpos($_POST['path'], './') === 0 || strpos($_POST['url'], 'http://s3.amazonaws.com/feather') !== 0 && strpos($_POST['url'], 'https://s3.amazonaws.com/feather') !== 0 || $_POST['name'] != fix_filename($_POST['name'], $transliteration, $convert_spaces, $replace_with) || !in_array(strtolower($info['extension']), array('jpg', 'jpeg', 'png'))) {
         response('wrong data', 400)->send();
         exit;
     }
     $image_data = file_get_contents($_POST['url']);
     if ($image_data === false) {
         response(trans('Aviary_No_Save'), 400)->send();
         exit;
     }
     require_once 'include/php_image_magician.php';
     $magicianObj = new imageLib($_POST['url']);
     $magicianObj->saveImage($current_path . $_POST['path'] . $_POST['name']);
     create_img($current_path . $_POST['path'] . $_POST['name'], $thumbs_base_path . $_POST['path'] . $_POST['name'], 122, 91);
     // TODO something with this function cause its blowing my mind
     new_thumbnails_creation($current_path . $_POST['path'], $current_path . $_POST['path'] . $_POST['name'], $_POST['name'], $current_path, $relative_image_creation, $relative_path_from_current_pos, $relative_image_creation_name_to_prepend, $relative_image_creation_name_to_append, $relative_image_creation_width, $relative_image_creation_height, $relative_image_creation_option, $fixed_image_creation, $fixed_path_from_filemanager, $fixed_image_creation_name_to_prepend, $fixed_image_creation_to_append, $fixed_image_creation_width, $fixed_image_creation_height, $fixed_image_creation_option);
     break;
Ejemplo n.º 9
0
                } else {
                    ?>
                                                        <a class="preview disabled"><i class="icon-eye-open icon-white"></i></a>
                                                    <?php 
                }
                ?>
                                                    <a 
                                                        onclick="edit(<?php 
                echo $voila_id;
                ?>
, '<?php 
                echo $file_path;
                ?>
',
                                                                            '<?php 
                echo fix_filename($filename, $transliteration);
                ?>
',
                                                                            '<?php 
                echo $transliteration;
                ?>
')" id="renaming" rel="<?php 
                echo $voila_id;
                ?>
" data-toggle="modal" href="#form-content" class="tip-left edit-button rename-file-paths <?php 
                if ($rename_files && !$file_prevent_rename) {
                    echo "rename-file1";
                }
                ?>
" title="<?php 
                echo trans('Rename');
Ejemplo n.º 10
0
    if ($path == $current_path) {
        $cycle = FALSE;
    }
    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);
        // 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;
Ejemplo n.º 11
0
                         $paths .= "/";
                     }
                     $base_dir = $paths . substr_replace($info['dirname'] . "/", '', 0, strlen($current_path));
                     if (file_exists($base_dir . $fixed_image_creation_name_to_prepend[$k] . $info['filename'] . $fixed_image_creation_to_append[$k] . "." . $info['extension'])) {
                         rename_file($base_dir . $fixed_image_creation_name_to_prepend[$k] . $info['filename'] . $fixed_image_creation_to_append[$k] . "." . $info['extension'], $fixed_image_creation_name_to_prepend[$k] . $name . $fixed_image_creation_to_append[$k], $transliteration);
                     }
                 }
             }
         } else {
             die(lang_Empty_name);
         }
     }
     break;
 case 'duplicate_file':
     if ($duplicate_files) {
         $name = fix_filename($name, $transliteration, $convert_spaces);
         if (!empty($name)) {
             if (!duplicate_file($path, $name)) {
                 die(lang_Rename_existing_file);
             }
             duplicate_file($path_thumb, $name);
             if ($fixed_image_creation) {
                 $info = pathinfo($path);
                 foreach ($fixed_path_from_filemanager as $k => $paths) {
                     if ($paths != "" && $paths[strlen($paths) - 1] != "/") {
                         $paths .= "/";
                     }
                     $base_dir = $paths . substr_replace($info['dirname'] . "/", '', 0, strlen($current_path));
                     if (file_exists($base_dir . $fixed_image_creation_name_to_prepend[$k] . $info['filename'] . $fixed_image_creation_to_append[$k] . "." . $info['extension'])) {
                         duplicate_file($base_dir . $fixed_image_creation_name_to_prepend[$k] . $info['filename'] . $fixed_image_creation_to_append[$k] . "." . $info['extension'], $fixed_image_creation_name_to_prepend[$k] . $name . $fixed_image_creation_to_append[$k]);
                     }
Ejemplo n.º 12
0
function fix_path($path, $transliteration)
{
    $path = fixName($path);
    $info = pathinfo($path);
    if (($s = strrpos($path, '/')) !== false) {
        $s++;
    }
    if (($e = strrpos($path, '.') - $s) !== strlen($info['filename'])) {
        $info['filename'] = substr($path, $s, $e);
        $info['basename'] = substr($path, $s);
    }
    $tmp_path = $info['dirname'] . DIRECTORY_SEPARATOR . $info['basename'];
    $str = fix_filename($info['filename'], $transliteration);
    if ($tmp_path != "") {
        return $tmp_path . DIRECTORY_SEPARATOR . $str;
    } else {
        return $str;
    }
}
Ejemplo n.º 13
0
function fix_path($path, $transliteration, $convert_spaces = false)
{
    echo 'aaaaaaaaaaaaa';
    die;
    $info = pathinfo($path);
    $tmp_path = $info['dirname'];
    $str = fix_filename($info['filename'], $transliteration, $convert_spaces);
    if ($tmp_path != "") {
        return $tmp_path . DIRECTORY_SEPARATOR . $str;
    } else {
        return $str;
    }
}
    if ($path == $current_path) {
        $cycle = false;
    }
    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']);
        if (file_exists($targetPath . $_FILES['file']['name'])) {
            $i = 1;
            $info = pathinfo($_FILES['file']['name']);
            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'];
        if (in_array(fix_strtolower($info['extension']), $ext_img)) {
            $is_img = true;
        } else {
            $is_img = false;
        }
Ejemplo n.º 15
0
         $_SESSION['descending'] = $_GET['descending'] === 'true';
     }
     break;
 case 'image_size':
     if (realpath(dirname(_PS_ROOT_DIR_ . $_POST['path'])) != realpath(_PS_ROOT_DIR_ . $upload_dir)) {
         die;
     }
     $pos = strpos($_POST['path'], $upload_dir);
     if ($pos !== false) {
         $info = getimagesize(substr_replace($_POST['path'], $current_path, $pos, strlen($upload_dir)));
         echo json_encode($info);
     }
     break;
 case 'save_img':
     $info = pathinfo($_POST['name']);
     if (strpos($_POST['path'], '/') === 0 || strpos($_POST['path'], '../') !== false || strpos($_POST['path'], './') === 0 || strpos($_POST['url'], 'http://featherfiles.aviary.com/') !== 0 || $_POST['name'] != fix_filename($_POST['name'], $transliteration) || !in_array(strtolower($info['extension']), array('jpg', 'jpeg', 'png'))) {
         die('wrong data');
     }
     $image_data = get_file_by_url($_POST['url']);
     if ($image_data === false) {
         die('file could not be loaded');
     }
     $put_contents_path = $current_path;
     if (isset($_POST['path'])) {
         $put_contents_path .= str_replace("", "", $_POST['path']);
     }
     if (isset($_POST['name'])) {
         $put_contents_path .= str_replace("", "", $_POST['name']);
     }
     file_put_contents($put_contents_path, $image_data);
     //new thumb creation
     }
     if (isset($_GET['descending'])) {
         $_SESSION['RF']["descending"] = $_GET['descending'] === "TRUE";
     }
     break;
 case 'image_size':
     // not used
     $pos = strpos($_POST['path'], $upload_dir);
     if ($pos !== FALSE) {
         $info = getimagesize(substr_replace($_POST['path'], $current_path, $pos, strlen($upload_dir)));
         echo json_encode($info);
     }
     break;
 case 'save_img':
     $info = pathinfo($_POST['name']);
     if (strpos($_POST['path'], '/') === 0 || strpos($_POST['path'], '../') !== FALSE || strpos($_POST['path'], './') === 0 || strpos($_POST['url'], 'http://featherfiles.aviary.com/') !== 0 || $_POST['name'] != fix_filename($_POST['name'], $transliteration, $convert_spaces, $replace_with) || !in_array(strtolower($info['extension']), array('jpg', 'jpeg', 'png'))) {
         die('wrong data');
     }
     $image_data = get_file_by_url($_POST['url']);
     if ($image_data === FALSE) {
         die(lang_Aviary_No_Save);
     }
     file_put_contents($current_path . $_POST['path'] . $_POST['name'], $image_data);
     create_img($current_path . $_POST['path'] . $_POST['name'], $thumbs_base_path . $_POST['path'] . $_POST['name'], 122, 91);
     // TODO something with this function cause its blowing my mind
     new_thumbnails_creation($current_path . $_POST['path'], $current_path . $_POST['path'] . $_POST['name'], $_POST['name'], $current_path, $relative_image_creation, $relative_path_from_current_pos, $relative_image_creation_name_to_prepend, $relative_image_creation_name_to_append, $relative_image_creation_width, $relative_image_creation_height, $relative_image_creation_option, $fixed_image_creation, $fixed_path_from_filemanager, $fixed_image_creation_name_to_prepend, $fixed_image_creation_to_append, $fixed_image_creation_width, $fixed_image_creation_height, $fixed_image_creation_option);
     break;
 case 'extract':
     if (strpos($_POST['path'], '/') === 0 || strpos($_POST['path'], '../') !== FALSE || strpos($_POST['path'], './') === 0) {
         die('wrong path');
     }
Ejemplo n.º 17
0
 } else {
     $filter = '';
 }
 if (!isset($_SESSION['sort_by'])) {
     $_SESSION['sort_by'] = '';
 }
 if (isset($_GET['sort_by'])) {
     $sort_by = $_SESSION['sort_by'] = fix_filename($_GET['sort_by'], $transliteration);
 } else {
     $sort_by = $_SESSION['sort_by'];
 }
 if (!isset($_SESSION['descending'])) {
     $_SESSION['descending'] = false;
 }
 if (isset($_GET['descending'])) {
     $descending = $_SESSION['descending'] = fix_filename($_GET['descending'], $transliteration) === 'true';
 } else {
     $descending = $_SESSION['descending'];
 }
 $lang = $default_language;
 if (isset($_GET['lang']) && $_GET['lang'] != 'undefined' && $_GET['lang'] != '') {
     $lang = $_GET['lang'];
 }
 $language_file = 'lang/' . $default_language . '.php';
 if ($lang != $default_language) {
     $path_parts = pathinfo($lang);
     if (is_readable('lang/' . $path_parts['basename'] . '.php')) {
         $language_file = 'lang/' . $path_parts['basename'] . '.php';
     } else {
         $lang = $default_language;
     }
Ejemplo n.º 18
0
                     }
                     $base_dir = $paths . substr_replace($info['dirname'] . "/", '', 0, strlen($current_path));
                     if (file_exists($base_dir . $fixed_image_creation_name_to_prepend[$k] . $info['filename'] . $fixed_image_creation_to_append[$k] . "." . $info['extension'])) {
                         rename_file($base_dir . $fixed_image_creation_name_to_prepend[$k] . $info['filename'] . $fixed_image_creation_to_append[$k] . "." . $info['extension'], $fixed_image_creation_name_to_prepend[$k] . $name . $fixed_image_creation_to_append[$k], $transliteration);
                     }
                 }
             }
         } else {
             response(trans('Empty_name'), 400)->send();
             exit;
         }
     }
     break;
 case 'duplicate_file':
     if ($duplicate_files) {
         $name = fix_filename($name, $transliteration, $convert_spaces, $replace_with);
         if (!empty($name)) {
             if (!duplicate_file($path, $name)) {
                 response(trans('Rename_existing_file'), 403)->send();
                 exit;
             }
             duplicate_file($path_thumb, $name);
             if ($fixed_image_creation) {
                 $info = pathinfo($path);
                 foreach ($fixed_path_from_filemanager as $k => $paths) {
                     if ($paths != "" && $paths[strlen($paths) - 1] != "/") {
                         $paths .= "/";
                     }
                     $base_dir = $paths . substr_replace($info['dirname'] . "/", '', 0, strlen($current_path));
                     if (file_exists($base_dir . $fixed_image_creation_name_to_prepend[$k] . $info['filename'] . $fixed_image_creation_to_append[$k] . "." . $info['extension'])) {
                         duplicate_file($base_dir . $fixed_image_creation_name_to_prepend[$k] . $info['filename'] . $fixed_image_creation_to_append[$k] . "." . $info['extension'], $fixed_image_creation_name_to_prepend[$k] . $name . $fixed_image_creation_to_append[$k]);
Ejemplo n.º 19
0
                 foreach ($fixed_path_from_filemanager as $k => $paths) {
                     if ($paths != "" && $paths[strlen($paths) - 1] != "/") {
                         $paths .= "/";
                     }
                     $base_dir = $paths . substr_replace($path, '', 0, strlen($current_path));
                     rename_folder($base_dir, $name);
                 }
             }
         } else {
             die(lang_Empty_name);
         }
     }
     break;
 case 'rename_file':
     if ($rename_files) {
         $name = fix_filename($name);
         if (!empty($name)) {
             if (!rename_file($path, $name)) {
                 die(lang_Rename_existing_file);
             }
             rename_file($path_thumb, $name);
             if ($fixed_image_creation) {
                 $info = pathinfo($path);
                 foreach ($fixed_path_from_filemanager as $k => $paths) {
                     if ($paths != "" && $paths[strlen($paths) - 1] != "/") {
                         $paths .= "/";
                     }
                     $base_dir = $paths . substr_replace($info['dirname'] . "/", '', 0, strlen($current_path));
                     if (file_exists($base_dir . $fixed_image_creation_name_to_prepend[$k] . $info['filename'] . $fixed_image_creation_to_append[$k] . "." . $info['extension'])) {
                         rename_file($base_dir . $fixed_image_creation_name_to_prepend[$k] . $info['filename'] . $fixed_image_creation_to_append[$k] . "." . $info['extension'], $fixed_image_creation_name_to_prepend[$k] . $name . $fixed_image_creation_to_append[$k]);
                     }
Ejemplo n.º 20
0
function fix_path($path, $transliteration)
{
    $info = pathinfo($path);
    $tmp_path = $info['dirname'];
    $str = fix_filename($info['filename'], $transliteration);
    if ($tmp_path != "") {
        return $tmp_path . DIRECTORY_SEPARATOR . $str;
    } else {
        return $str;
    }
}
Ejemplo n.º 21
0
 function upload()
 {
     if (!defined('FMPATH')) {
         define('FMPATH', 'public/vendor/filemanager/');
     }
     include FMPATH . 'config/config.php';
     if ($_SESSION['RF']["verify"] != "RESPONSIVEfilemanager") {
         die('forbiden');
     }
     include FMPATH . 'include/utils.php';
     if (isset($_POST['path'])) {
         $storeFolder = $_POST['path'];
         $storeFolderThumb = $_POST['path_thumb'];
     } else {
         $storeFolder = $current_path . $_POST["fldr"];
         // correct for when IE is in Compatibility mode
         $storeFolderThumb = $thumbs_base_path . $_POST["fldr"];
     }
     $path_pos = strpos($storeFolder, $current_path);
     $thumb_pos = strpos($storeFolderThumb, $thumbs_base_path);
     if ($path_pos !== 0 || $thumb_pos !== 0 || strpos($storeFolderThumb, '../', strlen($thumbs_base_path)) !== FALSE || strpos($storeFolderThumb, './', strlen($thumbs_base_path)) !== FALSE || strpos($storeFolder, '../', strlen($current_path)) !== FALSE || strpos($storeFolder, './', strlen($current_path)) !== FALSE) {
         die('wrong path');
     }
     $path = $storeFolder;
     $cycle = TRUE;
     $max_cycles = 50;
     $i = 0;
     while ($cycle && $i < $max_cycles) {
         $i++;
         if ($path == $current_path) {
             $cycle = FALSE;
         }
         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, $replace_with);
             // 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;
             } else {
                 $is_img = FALSE;
             }
             // upload
             move_uploaded_file($tempFile, $targetFile);
             chmod($targetFile, 0755);
             if ($is_img) {
                 $memory_error = FALSE;
                 if (!create_img($targetFile, $targetFileThumb, 122, 91)) {
                     $memory_error = FALSE;
                 } else {
                     // TODO something with this long function baaaah...
                     if (!new_thumbnails_creation($targetPath, $targetFile, $_FILES['file']['name'], $current_path, $relative_image_creation, $relative_path_from_current_pos, $relative_image_creation_name_to_prepend, $relative_image_creation_name_to_append, $relative_image_creation_width, $relative_image_creation_height, $relative_image_creation_option, $fixed_image_creation, $fixed_path_from_filemanager, $fixed_image_creation_name_to_prepend, $fixed_image_creation_to_append, $fixed_image_creation_width, $fixed_image_creation_height, $fixed_image_creation_option)) {
                         $memory_error = FALSE;
                     } else {
                         $imginfo = getimagesize($targetFile);
                         $srcWidth = $imginfo[0];
                         $srcHeight = $imginfo[1];
                         // resize images if set
                         if ($image_resizing) {
                             if ($image_resizing_width == 0) {
                                 if ($image_resizing_height == 0) {
                                     $image_resizing_width = $srcWidth;
                                     $image_resizing_height = $srcHeight;
                                 } else {
                                     $image_resizing_width = $image_resizing_height * $srcWidth / $srcHeight;
                                 }
                             } elseif ($image_resizing_height == 0) {
                                 $image_resizing_height = $image_resizing_width * $srcHeight / $srcWidth;
                             }
                             // new dims and create
                             $srcWidth = $image_resizing_width;
                             $srcHeight = $image_resizing_height;
                             create_img($targetFile, $targetFile, $image_resizing_width, $image_resizing_height, $image_resizing_mode);
                         }
                         //max resizing limit control
                         $resize = FALSE;
                         if ($image_max_width != 0 && $srcWidth > $image_max_width && $image_resizing_override === FALSE) {
                             $resize = TRUE;
                             $srcWidth = $image_max_width;
                             if ($image_max_height == 0) {
                                 $srcHeight = $image_max_width * $srcHeight / $srcWidth;
                             }
                         }
                         if ($image_max_height != 0 && $srcHeight > $image_max_height && $image_resizing_override === FALSE) {
                             $resize = TRUE;
                             $srcHeight = $image_max_height;
                             if ($image_max_width == 0) {
                                 $srcWidth = $image_max_height * $srcWidth / $srcHeight;
                             }
                         }
                         if ($resize) {
                             create_img($targetFile, $targetFile, $srcWidth, $srcHeight, $image_max_mode);
                         }
                     }
                 }
                 // not enough memory
                 if ($memory_error) {
                     unlink($targetFile);
                     header('HTTP/1.1 406 Not enought Memory', TRUE, 406);
                     exit;
                 }
             }
         } else {
             header('HTTP/1.1 406 file not permitted', TRUE, 406);
             exit;
         }
     } else {
         header('HTTP/1.1 405 Bad Request', TRUE, 405);
         exit;
     }
     // redirect
     if (isset($_POST['submit'])) {
         $query = http_build_query(array('type' => $_POST['type'], 'lang' => $_POST['lang'], 'popup' => $_POST['popup'], 'field_id' => $_POST['field_id'], 'fldr' => $_POST['fldr']));
         header("location: dialog.php?" . $query);
     }
 }