Exemplo n.º 1
0
 public function action($parent)
 {
     $c = $parent->config;
     $util = new Utility();
     if (strpos($_POST['path'], '/') === 0 || strpos($_POST['path'], '../') !== false || strpos($_POST['path'], './') === 0) {
         $this->r = array('wrong path', 400);
         return;
     }
     $path = $c['current_path'] . $_POST['path'];
     $info = pathinfo($path);
     $base_folder = $c['current_path'] . $util->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++) {
                     $OnlyFileName = $zip->getNameIndex($i);
                     $FullFileName = $zip->statIndex($i);
                     if (substr($FullFileName['name'], -1, 1) == "/") {
                         $util->create_folder($base_folder . $FullFileName['name']);
                     }
                 }
                 //unzip into the folders
                 for ($i = 0; $i < $zip->numFiles; $i++) {
                     $OnlyFileName = $zip->getNameIndex($i);
                     $FullFileName = $zip->statIndex($i);
                     if (!(substr($FullFileName['name'], -1, 1) == "/")) {
                         $fileinfo = pathinfo($OnlyFileName);
                         if (in_array(strtolower($fileinfo['extension']), $ext)) {
                             copy('zip://' . $path . '#' . $OnlyFileName, $base_folder . $FullFileName['name']);
                         }
                     }
                 }
                 $zip->close();
             } else {
                 $this->r = array('Could not extract. File might be corrupt.', 500);
                 return;
             }
             break;
         case "gz":
             $p = new \PharData($path);
             $p->decompress();
             // creates files.tar
             break;
         case "tar":
             // unarchive from the tar
             $phar = new \PharData($path);
             $phar->decompressFiles();
             $files = array();
             $util->check_files_extensions_on_phar($phar, $files, '', $ext);
             $phar->extractTo($current_path . fix_dirname($_POST['path']) . "/", $files, true);
             break;
         default:
             $this->r = array('This extension is not supported. Valid: zip, gz, tar.', 400);
             return;
             break;
     }
 }
Exemplo n.º 2
0
function config_loading($current_path, $fld)
{
    if (file_exists($current_path . $fld . ".config")) {
        require_once $current_path . $fld . ".config";
        return true;
    }
    echo "!!!!" . ($parent = fix_dirname($fld));
    if ($parent != "." && !empty($parent)) {
        config_loading($current_path, $parent);
    }
    return false;
}
Exemplo n.º 3
0
 $cycle = TRUE;
 $max_cycles = 50;
 $i = 0;
 while ($cycle && $i < $max_cycles) {
     $i++;
     if ($parent == "./") {
         $parent = "";
     }
     if (file_exists($current_path . $parent . "config.php")) {
         require_once $current_path . $parent . "config.php";
         $cycle = FALSE;
     }
     if ($parent == "") {
         $cycle = FALSE;
     } else {
         $parent = fix_dirname($parent) . "/";
     }
 }
 if (!is_dir($thumbs_path . $subdir)) {
     create_folder(FALSE, $thumbs_path . $subdir);
 }
 if (isset($_GET['popup'])) {
     $popup = strip_tags($_GET['popup']);
 } else {
     $popup = 0;
 }
 //Sanitize popup
 $popup = !!$popup;
 if (isset($_GET['crossdomain'])) {
     $crossdomain = strip_tags($_GET['crossdomain']);
 } else {
Exemplo n.º 4
0
}
$base = $current_path;
$path = $current_path . $_POST['path'];
$cycle = TRUE;
$max_cycles = 50;
$i = 0;
while ($cycle && $i < $max_cycles) {
    $i++;
    if ($path == $base) {
        $cycle = FALSE;
    }
    if (file_exists($path . "config.php")) {
        require_once $path . "config.php";
        $cycle = FALSE;
    }
    $path = fix_dirname($path) . "/";
    $cycle = FALSE;
}
$path = $current_path . $_POST['path'];
$path_thumb = $thumbs_base_path . $_POST['path'];
if (isset($_POST['name'])) {
    $name = fix_filename($_POST['name'], $transliteration, $convert_spaces, $replace_with);
    if (strpos($name, '../') !== FALSE) {
        response('wrong name', 400)->send();
        exit;
    }
}
$info = pathinfo($path);
if (isset($info['extension']) && !(isset($_GET['action']) && $_GET['action'] == 'delete_folder') && !in_array(strtolower($info['extension']), $ext) && $_GET['action'] != 'create_file') {
    response('wrong extension', 400)->send();
    exit;
Exemplo n.º 5
0
                        response(trans('Zip_No_Extract'), 500)->send();
                        exit;
                    }
                    break;
                case "gz":
                    $p = new PharData($path);
                    $p->decompress();
                    // creates files.tar
                    break;
                case "tar":
                    // unarchive from the tar
                    $phar = new PharData($path);
                    $phar->decompressFiles();
                    $files = array();
                    check_files_extensions_on_phar($phar, $files, '', $ext);
                    $phar->extractTo($current_path . fix_dirname($_POST['path']) . "/", $files, true);
                    break;
                default:
                    response(trans('Zip_Invalid'), 400)->send();
                    exit;
            }
            break;
        case 'media_preview':
            $preview_file = $current_path . $_GET["file"];
            $info = pathinfo($preview_file);
            ob_start();
            ?>
			<div id="jp_container_1" class="jp-video " style="margin:0 auto;">
			    <div class="jp-type-single">
			      <div id="jquery_jplayer_1" class="jp-jplayer"></div>
			      <div class="jp-gui">
    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']);
        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'];
Exemplo n.º 7
0
 $cycle = true;
 $max_cycles = 50;
 $i = 0;
 while ($cycle && $i < $max_cycles) {
     $i++;
     if ($parent == './') {
         $parent = '';
     }
     if (file_exists($current_path . $parent . 'config.php')) {
         require_once $current_path . $parent . 'config.php';
         $cycle = false;
     }
     if ($parent == '') {
         $cycle = false;
     } else {
         $parent = fix_dirname($parent) . '/';
     }
 }
 if (!is_dir($thumbs_path . $subdir)) {
     create_folder(false, $thumbs_path . $subdir);
 }
 if (isset($_GET['popup'])) {
     $popup = $_GET['popup'];
 } else {
     $popup = 0;
 }
 //Sanitize popup
 $popup = !!$popup;
 //view type
 if (!isset($_SESSION['view_type'])) {
     $view = $default_view;
Exemplo n.º 8
0
 /**
  * This method is the heart of the system. It manage the files sent by the applet, check the incoming parameters (md5sum) and
  * reconstruct the files sent in chunk mode.
  *
  * The result is stored in the $files array, and can then be managed by the function given in the callbackAfterUploadManagement
  * class parameter, or within the page whose URL is given in the afterUploadURL applet parameter.
  * Or you can Extend the class and redeclare defaultAfterUploadManagement() to your needs.
  */
 private function receive_uploaded_files()
 {
     $this->logDebug('receive_uploaded_files', 'Entering POST management');
     if (session_id() == '') {
         session_start();
     }
     // we check for the session *after* handling possible error log
     // because an error could have happened because the session-id is missing.
     if (!isset($_SESSION[$this->classparams['var_prefix'] . 'size'])) {
         $this->abort('Invalid session (in afterupload, POST, check of size)');
     }
     if (!isset($_SESSION[$this->classparams['var_prefix'] . 'files'])) {
         $this->abort('Invalid session (in afterupload, POST, check of files)');
     }
     $this->files = $_SESSION[$this->classparams['var_prefix'] . 'files'];
     if (!is_array($this->files)) {
         $this->abort('Invalid session (in afterupload, POST, is_array(files))');
     }
     if ($this->appletparams['sendMD5Sum'] == 'true' && !isset($_POST['md5sum'])) {
         $this->abort('Required POST variable md5sum is missing');
     }
     $cnt = 0;
     foreach ($_FILES as $key => $value) {
         //Let's read the $_FILES data
         if (isset($files_data)) {
             unset($files_data);
         }
         $jupart = isset($_POST['jupart']) ? (int) $_POST['jupart'] : 0;
         $jufinal = isset($_POST['jufinal']) ? (int) $_POST['jufinal'] : 1;
         $relpaths = isset($_POST['relpathinfo']) ? $_POST['relpathinfo'] : null;
         $md5sums = isset($_POST['md5sum']) ? $_POST['md5sum'] : null;
         $mimetypes = isset($_POST['mimetype']) ? $_POST['mimetype'] : null;
         //$relpaths = (isset($_POST["relpathinfo$cnt"])) ? $_POST["relpathinfo$cnt"] : null;
         //$md5sums = (isset($_POST["md5sum$cnt"])) ? $_POST["md5sum$cnt"] : null;
         if (gettype($relpaths) == 'string') {
             $relpaths = array($relpaths);
         }
         if (gettype($md5sums) == 'string') {
             $md5sums = array($md5sums);
         }
         if ($this->appletparams['sendMD5Sum'] == 'true' && !is_array($md5sums)) {
             $this->abort('Expecting an array of MD5 checksums');
         }
         if (!is_array($relpaths)) {
             $this->abort('Expecting an array of relative paths');
         }
         if (!is_array($mimetypes)) {
             $this->abort('Expecting an array of MIME types');
         }
         // Check the MIME type (note: this is easily forged!)
         if (isset($this->classparams['allowed_mime_types']) && is_array($this->classparams['allowed_mime_types'])) {
             if (!in_array($mimetypes[$cnt], $this->classparams['allowed_mime_types'])) {
                 $this->abort('MIME type ' . $mimetypes[$cnt] . ' not allowed');
             }
         }
         if (isset($this->classparams['allowed_file_extensions']) && is_array($this->classparams['allowed_file_extensions'])) {
             $fileExtension = substr(strrchr($value['name'][$cnt], "."), 1);
             if (!in_array($fileExtension, $this->classparams['allowed_file_extensions'])) {
                 $this->abort('File extension ' . $fileExtension . ' not allowed');
             }
         }
         $dstdir = $this->classparams['destdir'];
         $dstname = $dstdir . '/' . $this->classparams['tmp_prefix'] . session_id();
         $tmpname = $dstdir . '/' . $this->classparams['tmp_prefix'] . 'tmp' . session_id();
         // Controls are now done. Let's store the current uploaded files properties in an array, for future use.
         $files_data['name'] = $value['name'][$cnt];
         $files_data['size'] = 'not calculated yet';
         $files_data['tmp_name'] = $value['tmp_name'][$cnt];
         $files_data['error'] = $value['error'][$cnt];
         $files_data['relativePath'] = $relpaths[$cnt];
         $files_data['md5sum'] = $md5sums[$cnt];
         $files_data['mimetype'] = $mimetypes[$cnt];
         if (!move_uploaded_file($files_data['tmp_name'], $tmpname)) {
             if ($classparams['verbose_errors']) {
                 $this->abort("Unable to move uploaded file (from {$files_data['tmp_name']} to {$tmpname})");
             } else {
                 trigger_error("Unable to move uploaded file (from {$files_data['tmp_name']} to {$tmpname})", E_USER_WARNING);
                 $this->abort("Unable to move uploaded file");
             }
         }
         // In demo mode, no file storing is done. We just delete the newly uploaded file.
         if ($this->classparams['demo_mode']) {
             if ($jufinal || !$jupart) {
                 if ($jupart) {
                     $files_data['size'] = ($jupart - 1) * $this->appletparams['maxChunkSize'] + filesize($tmpname);
                 } else {
                     $files_data['size'] = filesize($tmpname);
                 }
                 $files_data['fullName'] = 'Demo mode<BR>No file storing';
                 array_push($this->files, $files_data);
             }
             unlink($tmpname);
             $cnt++;
             continue;
         }
         //If we get here, the upload is a real one (no demo)
         if ($jupart) {
             // got a chunk of a multi-part upload
             $len = filesize($tmpname);
             $_SESSION[$this->classparams['var_prefix'] . 'size'] += $len;
             if ($len > 0) {
                 $src = fopen($tmpname, 'rb');
                 $dst = fopen($dstname, $jupart == 1 ? 'wb' : 'ab');
                 while ($len > 0) {
                     $rlen = $len > 8192 ? 8192 : $len;
                     $buf = fread($src, $rlen);
                     if (!$buf) {
                         fclose($src);
                         fclose($dst);
                         unlink($dstname);
                         $this->abort('read IO error');
                     }
                     if (!fwrite($dst, $buf, $rlen)) {
                         fclose($src);
                         fclose($dst);
                         unlink($dstname);
                         $this->abort('write IO error');
                     }
                     $len -= $rlen;
                 }
                 fclose($src);
                 fclose($dst);
                 unlink($tmpname);
             }
             if ($jufinal) {
                 // This is the last chunk. Check total lenght and
                 // rename it to it's final name.
                 $dlen = filesize($dstname);
                 if ($dlen != $_SESSION[$this->classparams['var_prefix'] . 'size']) {
                     $this->abort('file size mismatch');
                 }
                 if ($this->appletparams['sendMD5Sum'] == 'true') {
                     if ($md5sums[$cnt] != md5_file($dstname)) {
                         $this->abort('MD5 checksum mismatch');
                     }
                 }
                 // remove zero sized files
                 if ($dlen > 0 || $this->classparams['allow_zerosized']) {
                     $dstfinal = $this->dstfinal($files_data['name'], $files_data['relativePath']);
                     if (!rename($dstname, $dstfinal)) {
                         $this->abort('rename IO error');
                     }
                     $_umask = umask(0);
                     // override the system mask
                     if (!chmod($dstfinal, $this->classparams['fileperm'])) {
                         $this->abort('chmod IO error');
                     }
                     umask($_umask);
                     $files_data['size'] = filesize($dstfinal);
                     $files_data['fullName'] = $dstfinal;
                     $files_data['path'] = fix_dirname($dstfinal);
                     array_push($this->files, $files_data);
                 } else {
                     unlink($dstname);
                 }
                 // reset session var
                 $_SESSION[$this->classparams['var_prefix'] . 'size'] = 0;
             }
         } else {
             // Got a single file upload. Trivial.
             if ($this->appletparams['sendMD5Sum'] == 'true') {
                 if ($md5sums[$cnt] != md5_file($tmpname)) {
                     $this->abort('MD5 checksum mismatch');
                 }
             }
             $dstfinal = $this->dstfinal($files_data['name'], $files_data['relativePath']);
             if (!rename($tmpname, $dstfinal)) {
                 $this->abort('rename IO error');
             }
             $_umask = umask(0);
             // override the system mask
             if (!chmod($dstfinal, $this->classparams['fileperm'])) {
                 $this->abort('chmod IO error');
             }
             umask($_umask);
             $files_data['size'] = filesize($dstfinal);
             $files_data['fullName'] = $dstfinal;
             $files_data['path'] = fix_dirname($dstfinal);
             array_push($this->files, $files_data);
         }
         $cnt++;
     }
     echo $this->appletparams['stringUploadSuccess'] . "\n";
     $_SESSION[$this->classparams['var_prefix'] . 'files'] = $this->files;
     session_write_close();
     exit;
 }
Exemplo n.º 9
0
include 'jupload.php';
include '../include/utils.php';
$path = $current_path . $_GET['path'];
$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) . DS;
}
$path = $current_path . $_GET['path'];
if (strpos($_GET['path'], '../') !== FALSE || strpos($_GET['path'], './') !== FALSE || strpos($_GET['path'], '/') === 0) {
    die('path error');
}
$path = str_replace([' ', '/'], ['~', DS], $path);
////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////   The user callback function, that can be called after upload   ////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
 * This function will be called, once all files are uploaded, with the list of uploaded files as an argument.
 *
 * Condition to have this function called:
 * - Have the applet parameter afterUploadURL unset in this file. This makes the applet use its default behavior, that is: afterUploadURL is
 *  the current web page, with the ?afterupload=1 parameter added.
Exemplo n.º 10
0
			    });
			  </script>
			    
			<?php 
            }
            break;
        case 'copy_cut':
            if ($_POST['sub_action'] != 'copy' && $_POST['sub_action'] != 'cut') {
                die('wrong sub-action');
            }
            if (trim($_POST['path']) == '' || trim($_POST['path_thumb']) == '') {
                die('no path');
            }
            $path = $current_path . $_POST['path'];
            $info = pathinfo($path);
            $base_folder = $current_path . fix_dirname($_POST['path']) . "/";
            if (is_dir($path)) {
                // can't copy/cut dirs
                if ($copy_cut_dirs === FALSE) {
                    die(sprintf(lang_Copy_Cut_Not_Allowed, $_POST['sub_action'] == 'copy' ? lcfirst(lang_Copy) : lcfirst(lang_Cut), lang_Folders));
                }
                // size over limit
                if ($copy_cut_max_size !== FALSE && is_int($copy_cut_max_size)) {
                    if ($copy_cut_max_size * 1024 * 1024 < foldersize($path)) {
                        die(sprintf(lang_Copy_Cut_Size_Limit, $_POST['sub_action'] == 'copy' ? lcfirst(lang_Copy) : lcfirst(lang_Cut), $copy_cut_max_size));
                    }
                }
                // file count over limit
                if ($copy_cut_max_count !== FALSE && is_int($copy_cut_max_count)) {
                    if ($copy_cut_max_count < filescount($path)) {
                        die(sprintf(lang_Copy_Cut_Count_Limit, $_POST['sub_action'] == 'copy' ? lcfirst(lang_Copy) : lcfirst(lang_Cut), $copy_cut_max_count));
Exemplo n.º 11
0
                    } else {
                        echo 'failed to open file';
                    }
                    break;
                case "gz":
                    $p = new PharData($path);
                    $p->decompress();
                    // creates files.tar
                    break;
                case "tar":
                    // unarchive from the tar
                    $phar = new PharData($path);
                    $phar->decompressFiles();
                    $files = array();
                    check_files_extensions_on_phar($phar, $files, '', $ext);
                    $phar->extractTo($current_path . fix_dirname($ttH->post['path']) . "/", $files, TRUE);
                    break;
            }
            break;
        case 'media_preview':
            $preview_file = $ttH->get["file"];
            $info = pathinfo($preview_file);
            ?>
<div id="jp_container_1" class="jp-video " style="margin:0 auto;">
    <div class="jp-type-single">
      <div id="jquery_jplayer_1" class="jp-jplayer"></div>
      <div class="jp-gui">
        <div class="jp-video-play">
          <a href="javascript:;" class="jp-video-play-icon" tabindex="1">play</a>
        </div>
        <div class="jp-interface">
Exemplo n.º 12
0
     } else {
         if (is_function_callable('chmod') !== FALSE) {
             chmod($path, 0644);
         }
         echo lang_File_Save_OK;
         $fm->upload($_SESSION['RF']['subfolder'], $path, $parts[count($parts) - 1], "0");
     }
     break;
 case 'rename_file':
     if ($rename_files) {
         $name = fix_filename($name, $transliteration, $convert_spaces, $replace_with);
         if (!empty($name)) {
             if (!rename_file($path, $name, $transliteration)) {
                 die(lang_Rename_existing_file);
             }
             $new_path = fix_dirname($path) . "/" . $name;
             $extenA = explode(".", $path);
             $fm->changePath($new_path . '.' . $extenA[count($extenA) - 1], $path);
             rename_file($path_thumb, $name, $transliteration);
             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], $transliteration);
                     }
                 }
             }
Exemplo n.º 13
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);
     }
 }