示例#1
0
 $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)) {
         try {
             create_img_gd($file_path, $src_thumb, 122, 91);
             new_thumbnails_creation($current_path . $rfm_subfolder . $subdir, $file_path, $file, $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);
         } catch (Exception $e) {
             $src_thumb = $mini_src = "";
         }
     }
     $is_img = true;
     //check if is smaller than thumb
     list($img_width, $img_height, $img_type, $attr) = getimagesize($file_path);
     if ($img_width < 122 && $img_height < 91) {
         $src_thumb = $current_path . $rfm_subfolder . $subdir . $file;
         $show_original = true;
     }
     if ($img_width < 45 && $img_height < 38) {
         $mini_src = $current_path . $rfm_subfolder . $subdir . $file;
         $show_original_mini = true;
     }
 }
 $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;
 }
 move_uploaded_file($tempFile, $targetFile);
 chmod($targetFile, 0755);
 if ($is_img) {
     $memory_error = false;
     if (!create_img_gd($targetFile, $targetFileThumb, 122, 91)) {
         $memory_error = false;
     } else {
         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, $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)) {
             $memory_error = false;
         } else {
             $imginfo = getimagesize($targetFile);
             $srcWidth = $imginfo[0];
             $srcHeight = $imginfo[1];
             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;
示例#3
0
     $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;
 case 'extract':
     if (strpos($_POST['path'], '/') === 0 || strpos($_POST['path'], '../') !== false || strpos($_POST['path'], './') === 0) {
         response('wrong path', 400)->send();
         exit;
     }
     $path = $current_path . $_POST['path'];
     $info = pathinfo($path);
     $base_folder = $current_path . fix_dirname($_POST['path']) . "/";
     switch ($info['extension']) {
         case "zip":
             $zip = new ZipArchive();
             if ($zip->open($path) === true) {
                 //make all the folders
                 for ($i = 0; $i < $zip->numFiles; $i++) {
示例#4
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);
     }
 }