Пример #1
0
include 'config/config.php';
if ($_SESSION['RF']["verify"] != "RESPONSIVEfilemanager") {
    die('forbiden');
}
include 'include/utils.php';
include 'include/mime_type_lib.php';
if (strpos($_POST['path'], '/') === 0 || strpos($_POST['path'], '../') !== FALSE || strpos($_POST['path'], './') === 0) {
    die('wrong path');
}
if (strpos($_POST['name'], '/') !== FALSE) {
    die('wrong path');
}
$path = $current_path . $_POST['path'];
$name = $_POST['name'];
$info = pathinfo($name);
if (!in_array(fix_strtolower($info['extension']), $ext)) {
    die('wrong extension');
}
$img_size = (string) filesize($path . $name);
// Get the image size as string
$mime_type = get_file_mime_type($name);
// Get the correct MIME type depending on the file.
header('Pragma: private');
header('Cache-control: private, must-revalidate');
header("Content-Type: " . $mime_type);
// Set the correct MIME type
header("Content-Length: " . $img_size);
header('Content-Disposition: attachment; filename="' . $name . '"');
readfile($path . $name);
exit;
Пример #2
0
         $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)) {
         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 (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;
     }
     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);
Пример #4
0
 protected function formatColor($value)
 {
     $rgbArray = array();
     // *** If it's an array it should be R, G, B
     if (is_array($value)) {
         if (key($value) == 0 && count($value) == 3) {
             $rgbArray['r'] = $value[0];
             $rgbArray['g'] = $value[1];
             $rgbArray['b'] = $value[2];
         } else {
             $rgbArray = $value;
         }
     } else {
         if (fix_strtolower($value) == 'transparent') {
             $rgbArray = array('r' => 255, 'g' => 255, 'b' => 255, 'a' => 127);
         } else {
             // *** ...Else it should be hex. Let's make it RGB
             $rgbArray = $this->hex2dec($value);
         }
     }
     return $rgbArray;
 }
Пример #5
0
 $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;
 } else {
     $is_img = false;
 }
 if ($is_img) {
     move_uploaded_file($tempFile, $targetFile);
     chmod($targetFile, 0755);
     $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);
Пример #6
0
     $_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'];
 $targetFileThumb = $targetPathThumb . $_FILES['file']['name'];
 // check if image (and supported)
 if (in_array(fix_strtolower($extension), $ext_img)) {
     $is_img = TRUE;
 } else {
     $is_img = FALSE;
 }
 if (!checkresultingsize($_FILES['file']['size'])) {
     response(sprintf(trans('max_size_reached'), $MaxSizeTotal) . AddErrorLocation(), 406)->send();
     exit;
 }
 // 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;
Пример #7
0
 /**
  * Convert a value ending in 'G','M' or 'K' to bytes
  *
  */
 private function tobytes($val)
 {
     $val = trim($val);
     $last = fix_strtolower($val[strlen($val) - 1]);
     switch ($last) {
         case 'g':
             $val *= 1024;
         case 'm':
             $val *= 1024;
         case 'k':
             $val *= 1024;
     }
     return $val;
 }
Пример #8
0
    public static function get_uploaded_files_markup($results = array())
    {
        $lan_iso = Context::getcontext()->language->iso_code;
        include_once _PS_ROOT_DIR_ . '/modules/revsliderprestashop/views/config/config.php';
        // include_once(_PS_ROOT_DIR_.'/modules/revsliderprestashop/views/lang/'.$lan_iso.'.php');
        include_once _PS_ROOT_DIR_ . '/modules/revsliderprestashop/views/include/utils.php';
        $upload_dir = __PS_BASE_URI__ . 'modules/revsliderprestashop/uploads/';
        $current_path = _PS_ROOT_DIR_ . '/modules/revsliderprestashop/uploads/';
        $url = uploads_url();
        ob_start();
        if (!empty($results)) {
            ?>
                     <div id="divImageList" > <ul id="selectable" class="">
                     <?php 
            $num = 0;
            foreach ($results as $id => $filename) {
                //$img = $results[$num];
                $thumbsize = GlobalsRevSlider::IMAGE_SIZE_THUMBNAIL;
                $mediumsize = GlobalsRevSlider::IMAGE_SIZE_MEDIUM;
                $largesize = GlobalsRevSlider::IMAGE_SIZE_LARGE;
                $filerealname = substr($filename, 0, strrpos($filename, '.'));
                $fileext = substr($filename, strrpos($filename, '.'), strlen($filename) - strlen($filerealname));
                $thumbimg = $img = "{$filerealname}-{$thumbsize}x{$thumbsize}{$fileext}";
                $mediumimg = "{$filerealname}-{$mediumsize}x{$mediumsize}{$fileext}";
                $largeimg = "{$filerealname}-{$largesize}x{$largesize}{$fileext}";
                $file_path = $file_path = $current_path . $largeimg;
                $date = filemtime($file_path);
                $size = filesize($file_path);
                // $file_ext = substr(strrchr($file, '.'), 1);
                $file_infos = pathinfo($file_path);
                $file_ext = $file_infos['extension'];
                // $sorted[$k] = array('file' => $file, 'date' => $date, 'size' => $size, 'extension' => $file_ext);
                $extension_lower = fix_strtolower($file_ext);
                $is_img = true;
                list($img_width, $img_height, $img_type, $attr) = getimagesize($file_path);
                // if (++$num % 4 === 1):
                ?>
<li data-image="<?php 
                echo $filename;
                ?>
" data-large="<?php 
                echo $upload_dir . $img;
                ?>
" data-medium="<?php 
                echo $upload_dir . $img;
                ?>
" data-thumb="<?php 
                echo $upload_dir . $img;
                ?>
" class="ff-item-type-2 file">
		<figure data-type="img" data-name="1117858_1577750_graph-1024x1024.png">
			<a data-function="apply" data-field_id="" data-file="<?php 
                echo $upload_dir . $img;
                ?>
" class="link" href="javascript:void('')">
				<div class="img-precontainer">
										<div class="img-container">
						<span></span>
						<img alt="<?php 
                echo $img;
                ?>
" src="<?php 
                echo $upload_dir . $img;
                ?>
"  class="original "  >
					</div>
				</div>
				<div class="img-precontainer-mini original-thumb">
					<div class="filetype png hide">png</div>
					<div class="img-container-mini">
						<span></span>
						<img src="<?php 
                echo $upload_dir . $img;
                ?>
" class=" " alt="<?php 
                echo $img;
                ?>
 thumbnails">
											</div>
				</div>
							</a>
			<div class="box">
				<h4 class="ellipsis">
					<a data-function="apply" data-field_id="" data-file="<?php 
                echo $img;
                ?>
" class="link" href="javascript:void('')">
						<?php 
                echo $img;
                ?>
</a></h4>
			</div>
			<?php 
                $date = filemtime($current_path . $img);
                ?>
			<input type="hidden" class="date" value="<?php 
                echo $date;
                ?>
"/>
			<input type="hidden" class="size" value="<?php 
                echo $size;
                ?>
"/>
			<input type="hidden" class="extension" value="<?php 
                echo $extension_lower;
                ?>
"/>
			<input type="hidden" class="name" value=""/>
			<div class="file-date"><?php 
                echo date(lang_Date_type, $date);
                ?>
</div>
			<div class="file-size"><?php 
                echo makeSize($size);
                ?>
</div>
			<div class='img-dimension'><?php 
                if ($is_img) {
                    echo $img_width . "x" . $img_height;
                }
                ?>
</div>
			<div class='file-extension'><?php 
                echo Tools::safeOutput($extension_lower);
                ?>
</div>
Пример #9
0
 function force_download()
 {
     include FMPATH . 'config/config.php';
     if ($_SESSION['RF']["verify"] != "RESPONSIVEfilemanager") {
         die('forbiden');
     }
     include FMPATH . 'include/utils.php';
     include FMPATH . 'include/mime_type_lib.php';
     if (strpos($_POST['path'], '/') === 0 || strpos($_POST['path'], '../') !== FALSE || strpos($_POST['path'], './') === 0) {
         die('wrong path');
     }
     if (strpos($_POST['name'], '/') !== FALSE) {
         die('wrong path');
     }
     $path = $current_path . $_POST['path'];
     $name = $_POST['name'];
     $info = pathinfo($name);
     if (!in_array(fix_strtolower($info['extension']), $ext)) {
         die('wrong extension');
     }
     $img_size = (string) filesize($path . $name);
     // Get the image size as string
     $mime_type = get_file_mime_type($path . $name);
     // Get the correct MIME type depending on the file.
     header('Pragma: private');
     header('Cache-control: private, must-revalidate');
     header("Content-Type: " . $mime_type);
     // Set the correct MIME type
     header("Content-Length: " . $img_size);
     header('Content-Disposition: attachment; filename="' . $name . '"');
     readfile($path . $name);
     exit;
 }